Advertisement
Moolah60

OoT SetBIconFunc

Feb 6th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.36 KB | None | 0 0
  1. typedef unsigned char u8;
  2. typedef unsigned short u16;
  3. typedef unsigned int u32;
  4.  
  5. void SetBIcon(int unk, void* somePointer) {
  6.     void* someAddress = (void*) 0x8011A5D0;
  7.     u8 someByte = *(u8 *) (somePointer + 0x434);
  8.     if (someByte != 0x56) { // Not sure what this is checking for.
  9.         void* otherAddress = 0x800F8C70;
  10.         void* address3 = 0x800F8CC0;
  11.         u16 someValue = *(u16 *) (otherAddress + 2); // 800F8C72 (0x00F0 in this case)
  12.         u16 someValue2 = *(u16 *) (someAddress + 0x70); // resolves to 8011A640. + 8 from actual item id address. (0x1123)
  13.         u8 someByte3 = *(u8 *) (address3 + 1); // 800F8CC1 (4 in this case)
  14.  
  15.         u16 maskedValue = someValue2 & someValue;
  16.         u16 shiftedMaskedValue = maskedValue >> someByte3;
  17.         *(u8 *)(somePointer + 0x13E) = (u8) shiftedMaskedValue; // This is stored at itemIconId + 1.
  18.  
  19.         u16 maskValue2 = *(u16 *) (otherAddress + 4); // 0x0F00
  20.         u8 shiftValue2 = *(u8 *) (address3 + 2); // 8
  21.         u16 maskedValue2 = someValue2 & maskValue2;
  22.         u8 shiftedMaskedValue2 = maskedValue2 >> shiftValue2;
  23.         shiftedMaskedValue2 -= 1;
  24.         *(u8 *)(somePointer + 0x13C) = shiftedMaskedValue2; // IconId pointer - 1.
  25.  
  26.         u16 maskValue3 = *(u16 *) (otherAddress + 6); // 0xF000
  27.         u8 shiftValue3 = *(u8 *) (address3 + 3); // 0x0C
  28.         u16 maskedValue3 = someValue2 & maskValue3;
  29.         u8 shiftedMaskedValue3 = maskedValue3 >> shiftValue3;
  30.         shiftedMaskedValue3 -= 1;
  31.         *(u8 *)(somePointer + 0x13F) = shiftedMaskedValue3; // IconId pointer + 2.
  32.  
  33.         if (*(u8 *)(someAddress + 0x13E2) == 0xFF) { // Check for no item id equipped?
  34.             *(u8 *)(somePointer + 0x13D) = 0xFF; // Set icon id to no item equipped.
  35.         }
  36.         else {
  37.             u8 itemIdEquipped = *(u8 *) (someAddress + 0x68) // Points to 0x011A638. This is the equipped item id.
  38.             if (itemIdEquipped == 0x55) { // 0x55 = Giant's Knife (Broken)
  39.                 itemIdEquipped = 0x3D; // 0x3D = Giant's Knife & Biggoron's Sword.
  40.             }
  41.  
  42.             *(u8 *)(somePointer + 0x13D) = itemIdEquipped; // Set the icon id.
  43.         }
  44.  
  45.         // Call some subfunctions
  46.         someFunc1(address3, *(char *)(somePointer + 0x141));
  47.         int value = someFunc2(somePointer); // might not be an int. Return value goes unused.
  48.         someFunc3(unk, someAddress);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement