diff options
| author | Roman971 <32455037+Roman971@users.noreply.github.com> | 2020-12-18 01:12:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-17 19:12:22 -0500 |
| commit | 83e53bbaf255c9936414f6b249dcec46cef8471b (patch) | |
| tree | 723feb17a0e559b60ad8ea1d10ef39056d9ba04c /src/code | |
| parent | 0376242365c15345f7ab33edfab7408877164a92 (diff) | |
Fix some non matchings in actors and parameter (#540)
* Fix some non matchings in actors and parameter
- `EnTuboTrap_HandleImpact` from `z_en_tubo_trap.c` (fully matching)
- `func_80ADA35C` from `z_en_po_sisters.c` (fully matching)
- `func_80B0B81C` from `z_en_stream.c` (fully matching)
- `Item_Give` from `z_parameter.c` (1 non matching left)
* Rectify bss ordering comment
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_parameter.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 4f64280d2..1b1b0f993 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1304,15 +1304,10 @@ void func_80084BF4(GlobalContext* globalCtx, u16 flag) { s16 sAmmoRefillCounts[] = { 5, 10, 20, 30, 5, 10, 30, 0, 5, 20, 1, 5, 20, 50, 200, 10 }; -#ifdef NON_MATCHING -// regalloc, minor ordering and stack usage differences u8 Item_Give(GlobalContext* globalCtx, u8 item) { s16 i; s16 slot; - s16 oldItem; - s16 bottleSlot; - s16 prevTradeItem; - s8 bombCount; + s16 temp; slot = SLOT(item); if (item >= ITEM_STICKS_5) { @@ -1571,16 +1566,12 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } else if (item == ITEM_BOMB) { // Translates to: "Bomb Bomb Bomb Bomb Bomb Bomb Bomb" osSyncPrintf(" 爆弾 爆弾 爆弾 爆弾 爆弾 爆弾 爆弾 \n"); - bombCount = AMMO(ITEM_BOMB) + 1; - AMMO(ITEM_BOMB) = bombCount; - if (bombCount > CUR_CAPACITY(UPG_BOMB_BAG)) { + if ((AMMO(ITEM_BOMB) += 1) > CUR_CAPACITY(UPG_BOMB_BAG)) { AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); } return ITEM_NONE; } else if ((item >= ITEM_BOMBS_5) && (item <= ITEM_BOMBS_30)) { - bombCount = AMMO(ITEM_BOMB) + sAmmoRefillCounts[item - ITEM_BOMBS_5]; - AMMO(ITEM_BOMB) = bombCount; - if (bombCount > CUR_CAPACITY(UPG_BOMB_BAG)) { + if ((AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]) > CUR_CAPACITY(UPG_BOMB_BAG)) { AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); } return ITEM_NONE; @@ -1713,50 +1704,52 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { Rupees_ChangeBy(sAmmoRefillCounts[item - ITEM_RUPEE_GREEN + 10]); return ITEM_NONE; } else if (item == ITEM_BOTTLE) { + temp = SLOT(item); + for (i = 0; i < 4; i++) { - if (gSaveContext.inventory.items[SLOT(item) + i] == ITEM_NONE) { - gSaveContext.inventory.items[SLOT(item) + i] = item; + if (gSaveContext.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.inventory.items[temp + i] = item; return ITEM_NONE; } } } else if (((item >= ITEM_POTION_RED) && (item <= ITEM_POE)) || (item == ITEM_MILK)) { - bottleSlot = SLOT(item); + temp = SLOT(item); if ((item != ITEM_MILK_BOTTLE) && (item != ITEM_LETTER_RUTO)) { if (item == ITEM_MILK) { item = ITEM_MILK_BOTTLE; - bottleSlot = SLOT(item); + temp = SLOT(item); } for (i = 0; i < 4; i++) { - if (gSaveContext.inventory.items[bottleSlot + i] == ITEM_BOTTLE) { + if (gSaveContext.inventory.items[temp + i] == ITEM_BOTTLE) { // Translates to: "Item_Pt(1)=%d Item_Pt(2)=%d Item_Pt(3)=%d Empty Bottle=%d Content=%d" osSyncPrintf("Item_Pt(1)=%d Item_Pt(2)=%d Item_Pt(3)=%d 空瓶=%d 中味=%d\n", gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], - gSaveContext.equips.cButtonSlots[2], bottleSlot + i, item); + gSaveContext.equips.cButtonSlots[2], temp + i, item); - if ((bottleSlot + i) == gSaveContext.equips.cButtonSlots[0]) { + if ((temp + i) == gSaveContext.equips.cButtonSlots[0]) { gSaveContext.equips.buttonItems[1] = item; Interface_LoadItemIcon2(globalCtx, 1); gSaveContext.buttonStatus[1] = BTN_ENABLED; - } else if ((bottleSlot + i) == gSaveContext.equips.cButtonSlots[1]) { + } else if ((temp + i) == gSaveContext.equips.cButtonSlots[1]) { gSaveContext.equips.buttonItems[2] = item; Interface_LoadItemIcon2(globalCtx, 2); gSaveContext.buttonStatus[2] = BTN_ENABLED; - } else if ((bottleSlot + i) == gSaveContext.equips.cButtonSlots[2]) { + } else if ((temp + i) == gSaveContext.equips.cButtonSlots[2]) { gSaveContext.equips.buttonItems[3] = item; Interface_LoadItemIcon1(globalCtx, 3); gSaveContext.buttonStatus[3] = BTN_ENABLED; } - gSaveContext.inventory.items[bottleSlot + i] = item; + gSaveContext.inventory.items[temp + i] = item; return ITEM_NONE; } } } else { for (i = 0; i < 4; i++) { - if (gSaveContext.inventory.items[bottleSlot + i] == ITEM_NONE) { - gSaveContext.inventory.items[bottleSlot + i] = item; + if (gSaveContext.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.inventory.items[temp + i] = item; return ITEM_NONE; } } @@ -1766,12 +1759,12 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { gSaveContext.itemGetInf[1] |= 0x8000; } - prevTradeItem = INV_CONTENT(item); + temp = INV_CONTENT(item); INV_CONTENT(item) = item; - if (prevTradeItem != ITEM_NONE) { + if (temp != ITEM_NONE) { for (i = 1; i < 4; i++) { - if (prevTradeItem == gSaveContext.equips.buttonItems[i]) { + if (temp == gSaveContext.equips.buttonItems[i]) { if (item != ITEM_SOLD_OUT) { gSaveContext.equips.buttonItems[i] = item; Interface_LoadItemIcon1(globalCtx, i); @@ -1786,20 +1779,17 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return ITEM_NONE; } - oldItem = gSaveContext.inventory.items[slot]; - osSyncPrintf("Item_Register(%d)=%d %d\n", slot, item, oldItem); + temp = gSaveContext.inventory.items[slot]; + osSyncPrintf("Item_Register(%d)=%d %d\n", slot, item, temp); INV_CONTENT(item) = item; - return oldItem; + return temp; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Item_Give.s") -#endif u8 Item_CheckObtainability(u8 item) { s16 i; s16 slot; - s32 bottleSlot; + s32 temp; slot = SLOT(item); if (item >= ITEM_STICKS_5) { @@ -1898,22 +1888,22 @@ u8 Item_CheckObtainability(u8 item) { } else if (item == ITEM_BOTTLE) { return ITEM_NONE; } else if (((item >= ITEM_POTION_RED) && (item <= ITEM_POE)) || (item == ITEM_MILK)) { - bottleSlot = SLOT(item); + temp = SLOT(item); if ((item != ITEM_MILK_BOTTLE) && (item != ITEM_LETTER_RUTO)) { if (item == ITEM_MILK) { item = ITEM_MILK_BOTTLE; - bottleSlot = SLOT(item); + temp = SLOT(item); } for (i = 0; i < 4; i++) { - if (gSaveContext.inventory.items[bottleSlot + i] == ITEM_BOTTLE) { + if (gSaveContext.inventory.items[temp + i] == ITEM_BOTTLE) { return ITEM_NONE; } } } else { for (i = 0; i < 4; i++) { - if (gSaveContext.inventory.items[bottleSlot + i] == ITEM_NONE) { + if (gSaveContext.inventory.items[temp + i] == ITEM_NONE) { return ITEM_NONE; } } @@ -3055,6 +3045,13 @@ u16 D_80125B54 = 0xC220; // unused u16 D_80125B58 = 0xC20C; // unused s16 D_80125B5C[] = { 91, 91 }; // unused +// Due to an unknown reason, bss ordering changes within the 5 static variables in the function below. +// In order to restore the correct order, we need a specific number of bss variables in the file before that point. +// For this, we introduce 3 dummy variables which end up in padding at the end of the file's bss, so they don't actually take space. +s8 sBssDummy1; +s8 sBssDummy2; +s8 sBssDummy3; + #ifdef NON_MATCHING // mostly regalloc, minor ordering and stack usage differences void Interface_Draw(GlobalContext* globalCtx) { |
