Advertisement
Moolah60

OoT SetBIconFunc Simplified

Feb 6th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.74 KB | None | 0 0
  1. typedef unsigned char u8;
  2. typedef unsigned short u16;
  3. typedef unsigned int u32;
  4.  
  5. const static u16 maskValues[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 };
  6. const static u8 shiftValues[4] = { 0x00, 0x04, 0x08, 0x0C };
  7.  
  8. void SetBIcon(int unk, void* somePointer) {
  9.     void* someAddress = (void*) 0x8011A5D0;
  10.     u8 someByte = *(u8 *) (somePointer + 0x434);
  11.     if (someByte != 0x56) { // Not sure what this is checking for.
  12.         void* otherAddress = 0x800F8C70;
  13.  
  14.         u16 someItemRelatedValue = (someAddress + 0x70); // resolves to 8011A640. + 8 from actual item id address. (0x1123)
  15.         *(u8 *) (somePointer + 0x13E) = (u8) ((someItemRelatedValue & maskValues[1]) >> shiftValues[1]);
  16.         *(u8 *) (somePointer + 0x13C) = (u8) ((someItemRelatedValue & maskValues[2]) >> shiftValues[2]) - 1;
  17.         *(u8 *) (somePointer + 0x13F) = (u8) ((someItemRelatedValue & maskValues[3]) >> shiftValues[3]) - 1;
  18.  
  19.         if (*(u8 *)(someAddress + 0x13E2) == 0xFF) { // Check for no item id equipped?
  20.             *(u8 *)(somePointer + 0x13D) = 0xFF; // Set icon id to no item equipped.
  21.         }
  22.         else {
  23.             u8 itemIdEquipped = *(u8 *) (someAddress + 0x68) // Points to 0x011A638. This is the equipped item id.
  24.             if (itemIdEquipped == 0x55) { // 0x55 = Giant's Knife (Broken)
  25.                 itemIdEquipped = 0x3D; // 0x3D = Giant's Knife & Biggoron's Sword.
  26.             }
  27.  
  28.             *(u8 *)(somePointer + 0x13D) = itemIdEquipped; // Set the icon id.
  29.         }
  30.  
  31.         // Call some subfunctions
  32.         someFunc1(address3, *(char *)(somePointer + 0x141)); // this points to 0x801DAA30.
  33.         int value = someFunc2(somePointer); // might not be an int. Return value goes unused.
  34.         someFunc3(unk, someAddress);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement