From 1e03b662f2a1d7ea5221695facb33b09eb6c0754 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 24 Apr 2022 00:41:17 +1000 Subject: [PATCH] Parameter/Item Misc Cleanup (#1201) * Misc parameter cleanup * More cleanup * More cleanup * ia4, more readable * More comments * PR Suggestion --- assets/xml/textures/do_action_static.xml | 11 +- include/z64item.h | 2 +- src/code/z_demo.c | 4 +- src/code/z_message_PAL.c | 6 +- src/code/z_parameter.c | 167 ++++++++++-------- src/code/z_play.c | 4 +- .../actors/ovl_player_actor/z_player.c | 4 +- .../ovl_kaleido_scope/z_kaleido_collect.c | 58 +++--- .../misc/ovl_kaleido_scope/z_kaleido_debug.c | 13 +- 9 files changed, 148 insertions(+), 121 deletions(-) diff --git a/assets/xml/textures/do_action_static.xml b/assets/xml/textures/do_action_static.xml index 9ae8d9815d..a821e7b2a7 100644 --- a/assets/xml/textures/do_action_static.xml +++ b/assets/xml/textures/do_action_static.xml @@ -1,5 +1,6 @@ + @@ -10,7 +11,7 @@ - + @@ -29,6 +30,8 @@ + + @@ -39,7 +42,7 @@ - + @@ -58,6 +61,8 @@ + + @@ -68,7 +73,7 @@ - + diff --git a/include/z64item.h b/include/z64item.h index 05b2a24b2a..61edc54fa1 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -44,7 +44,7 @@ typedef enum { /* 0x15 */ QUEST_STONE_OF_AGONY, /* 0x16 */ QUEST_GERUDO_CARD, /* 0x17 */ QUEST_SKULL_TOKEN, - /* 0x18 */ QUEST_HEART_PIECE + /* 0x1C */ QUEST_HEART_PIECE_COUNT = 0x1C } QuestItem; typedef enum { diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 697618917e..91510b466b 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -392,10 +392,10 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } break; case 28: - globalCtx->unk_11DE9 = 1; + globalCtx->unk_11DE9 = true; break; case 29: - globalCtx->unk_11DE9 = 0; + globalCtx->unk_11DE9 = false; break; case 30: Flags_SetEnv(globalCtx, 3); diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index 7d3fe73250..a9bac80d9f 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -1592,7 +1592,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { if (textId == 0xC2 || textId == 0xFA) { // Increments text id based on piece of heart count, assumes the piece of heart text is all // in order and that you don't have more than the intended amount of heart pieces. - textId += (gSaveContext.inventory.questItems & 0xF0000000 & 0xF0000000) >> 0x1C; + textId += (gSaveContext.inventory.questItems & 0xF0000000 & 0xF0000000) >> QUEST_HEART_PIECE_COUNT; } else if (msgCtx->textId == 0xC && CHECK_OWNED_EQUIP(EQUIP_SWORD, 2)) { textId = 0xB; // Traded Giant's Knife for Biggoron Sword } else if (msgCtx->textId == 0xB4 && (gSaveContext.eventChkInf[9] & 0x40)) { @@ -3259,8 +3259,8 @@ void Message_Update(GlobalContext* globalCtx) { } else { msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT; } - if ((s32)(gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000) { - gSaveContext.inventory.questItems ^= 0x40000000; + if ((s32)(gSaveContext.inventory.questItems & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)) { + gSaveContext.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT); gSaveContext.healthCapacity += 0x10; gSaveContext.health += 0x10; } diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index f8f5bb6bec..1073d14adc 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -134,12 +134,28 @@ static s16 sMagicBorderG = 255; static s16 sMagicBorderB = 255; static s16 sExtraItemBases[] = { - ITEM_STICK, ITEM_STICK, ITEM_NUT, ITEM_NUT, ITEM_BOMB, ITEM_BOMB, ITEM_BOMB, ITEM_BOMB, ITEM_BOW, - ITEM_BOW, ITEM_BOW, ITEM_SEEDS, ITEM_BOMBCHU, ITEM_BOMBCHU, ITEM_STICK, ITEM_STICK, ITEM_NUT, ITEM_NUT, + ITEM_STICK, // ITEM_STICKS_5 + ITEM_STICK, // ITEM_STICKS_10 + ITEM_NUT, // ITEM_NUTS_5 + ITEM_NUT, // ITEM_NUTS_10 + ITEM_BOMB, // ITEM_BOMBS_5 + ITEM_BOMB, // ITEM_BOMBS_10 + ITEM_BOMB, // ITEM_BOMBS_20 + ITEM_BOMB, // ITEM_BOMBS_30 + ITEM_BOW, // ITEM_ARROWS_SMALL + ITEM_BOW, // ITEM_ARROWS_MEDIUM + ITEM_BOW, // ITEM_ARROWS_LARGE + ITEM_SEEDS, // ITEM_SEEDS_30 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_5 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_20 + ITEM_STICK, // ITEM_STICK_UPGRADE_20 + ITEM_STICK, // ITEM_STICK_UPGRADE_30 + ITEM_NUT, // ITEM_NUT_UPGRADE_30 + ITEM_NUT, // ITEM_NUT_UPGRADE_40 }; static s16 D_80125A58 = 0; -static s16 D_80125A5C = 0; +static s16 D_80125A5C = false; static Gfx sSetupDL_80125A60[] = { gsDPPipeSync(), @@ -596,7 +612,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { break; } - if ((globalCtx->roomCtx.curRoom.unk_03 == 1) && (interfaceCtx->minimapAlpha >= 0xFF)) { + if ((globalCtx->roomCtx.curRoom.unk_03 == 1) && (interfaceCtx->minimapAlpha >= 255)) { interfaceCtx->minimapAlpha = 255; } } @@ -606,7 +622,7 @@ void func_80083108(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; s16 i; - s16 sp28 = 0; + s16 sp28 = false; if ((gSaveContext.cutsceneIndex < 0xFFF0) || ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.cutsceneIndex == 0xFFF0))) { @@ -708,7 +724,7 @@ void func_80083108(GlobalContext* globalCtx) { } else if (msgCtx->msgMode == MSGMODE_NONE) { if ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) { if (gSaveContext.buttonStatus[0] != BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[0] = BTN_DISABLED; @@ -718,20 +734,20 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) && (gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; } else { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; } } else { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -760,7 +776,7 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.equips.buttonItems[0] = ITEM_NONE; } else { gSaveContext.equips.buttonItems[0] = ITEM_BOW; - sp28 = 1; + sp28 = true; } } } else { @@ -776,25 +792,25 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[0] = gSaveContext.equips.buttonItems[0]; } } - sp28 = 1; + sp28 = true; } if (sp28) { Interface_LoadItemIcon1(globalCtx, 0); - sp28 = 0; + sp28 = false; } for (i = 1; i < 4; i++) { if ((gSaveContext.equips.buttonItems[i] != ITEM_OCARINA_FAIRY) && (gSaveContext.equips.buttonItems[i] != ITEM_OCARINA_TIME)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; } else { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -814,14 +830,14 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; - sp28 = 1; + sp28 = true; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { Interface_LoadItemIcon1(globalCtx, 0); } } } else if ((gSaveContext.buttonStatus[0] & 0xFF) == BTN_DISABLED) { - sp28 = 1; + sp28 = true; if (((gSaveContext.buttonStatus[0] & 0xFF) == BTN_DISABLED) || ((gSaveContext.buttonStatus[0] & 0xFF) == BTN_ENABLED)) { @@ -837,7 +853,7 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; - sp28 = 1; + sp28 = true; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { Interface_LoadItemIcon1(globalCtx, 0); @@ -845,7 +861,7 @@ void func_80083108(GlobalContext* globalCtx) { } } else { if (gSaveContext.buttonStatus[0] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[0] = BTN_DISABLED; @@ -857,7 +873,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -868,7 +884,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -881,7 +897,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -892,7 +908,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK)) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -905,7 +921,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) || (gSaveContext.equips.buttonItems[i] == ITEM_LONGSHOT)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -916,7 +932,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) || (gSaveContext.equips.buttonItems[i] == ITEM_LONGSHOT)) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -929,7 +945,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) || (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_TIME)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -940,7 +956,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) || (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_TIME)) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -952,7 +968,7 @@ void func_80083108(GlobalContext* globalCtx) { for (i = 1; i < 4; i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_FARORES_WIND) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -963,7 +979,7 @@ void func_80083108(GlobalContext* globalCtx) { for (i = 1; i < 4; i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_FARORES_WIND) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -976,7 +992,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] == ITEM_DINS_FIRE) || (gSaveContext.equips.buttonItems[i] == ITEM_NAYRUS_LOVE)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; @@ -987,7 +1003,7 @@ void func_80083108(GlobalContext* globalCtx) { if ((gSaveContext.equips.buttonItems[i] == ITEM_DINS_FIRE) || (gSaveContext.equips.buttonItems[i] == ITEM_NAYRUS_LOVE)) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -1006,13 +1022,13 @@ void func_80083108(GlobalContext* globalCtx) { if ((globalCtx->sceneNum != SCENE_TAKARAYA) || (gSaveContext.equips.buttonItems[i] != ITEM_LENS)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_DISABLED; } else { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -1033,7 +1049,7 @@ void func_80083108(GlobalContext* globalCtx) { !((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { - sp28 = 1; + sp28 = true; } gSaveContext.buttonStatus[i] = BTN_ENABLED; @@ -1304,7 +1320,10 @@ void func_80084BF4(GlobalContext* globalCtx, u16 flag) { } u8 Item_Give(GlobalContext* globalCtx, u8 item) { - static s16 sAmmoRefillCounts[] = { 5, 10, 20, 30, 5, 10, 30, 0, 5, 20, 1, 5, 20, 50, 200, 10 }; + static s16 sAmmoRefillCounts[] = { 5, 10, 20, 30 }; // Sticks, nuts, bombs + static s16 sArrowRefillCounts[] = { 5, 10, 30 }; + static s16 sBombchuRefillCounts[] = { 5, 20 }; + static s16 sRupeeRefillCounts[] = { 1, 5, 20, 50, 200, 10 }; s16 i; s16 slot; s16 temp; @@ -1586,17 +1605,17 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } else if ((item == ITEM_BOMBCHUS_5) || (item == ITEM_BOMBCHUS_20)) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; - AMMO(ITEM_BOMBCHU) += sAmmoRefillCounts[item - ITEM_BOMBCHUS_5 + 8]; + AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_5]; return ITEM_NONE; } else { - AMMO(ITEM_BOMBCHU) += sAmmoRefillCounts[item - ITEM_BOMBCHUS_5 + 8]; + AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_5]; if (AMMO(ITEM_BOMBCHU) > 50) { AMMO(ITEM_BOMBCHU) = 50; } return ITEM_NONE; } } else if ((item >= ITEM_ARROWS_SMALL) && (item <= ITEM_ARROWS_LARGE)) { - AMMO(ITEM_BOW) += sAmmoRefillCounts[item - ITEM_ARROWS_SMALL + 4]; + AMMO(ITEM_BOW) += sArrowRefillCounts[item - ITEM_ARROWS_SMALL]; if ((AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) || (AMMO(ITEM_BOW) < 0)) { AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); @@ -1659,7 +1678,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } return ITEM_NONE; } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { - gSaveContext.inventory.questItems += 1 << (QUEST_HEART_PIECE + 4); + gSaveContext.inventory.questItems += 1 << QUEST_HEART_PIECE_COUNT; return ITEM_NONE; } else if (item == ITEM_HEART_CONTAINER) { gSaveContext.healthCapacity += 0x10; @@ -1696,7 +1715,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return item; } else if ((item >= ITEM_RUPEE_GREEN) && (item <= ITEM_INVALID_8)) { - Rupees_ChangeBy(sAmmoRefillCounts[item - ITEM_RUPEE_GREEN + 10]); + Rupees_ChangeBy(sRupeeRefillCounts[item - ITEM_RUPEE_GREEN]); return ITEM_NONE; } else if (item == ITEM_BOTTLE) { temp = SLOT(item); @@ -1942,26 +1961,26 @@ s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u16 oldItem, u16 newItem) { break; } } - return 1; + return true; } } - return 0; + return false; } s32 Inventory_HasEmptyBottle(void) { u8* items = gSaveContext.inventory.items; if (items[SLOT_BOTTLE_1] == ITEM_BOTTLE) { - return 1; + return true; } else if (items[SLOT_BOTTLE_2] == ITEM_BOTTLE) { - return 1; + return true; } else if (items[SLOT_BOTTLE_3] == ITEM_BOTTLE) { - return 1; + return true; } else if (items[SLOT_BOTTLE_4] == ITEM_BOTTLE) { - return 1; + return true; } else { - return 0; + return false; } } @@ -1969,15 +1988,15 @@ s32 Inventory_HasSpecificBottle(u8 bottleItem) { u8* items = gSaveContext.inventory.items; if (items[SLOT_BOTTLE_1] == bottleItem) { - return 1; + return true; } else if (items[SLOT_BOTTLE_2] == bottleItem) { - return 1; + return true; } else if (items[SLOT_BOTTLE_3] == bottleItem) { - return 1; + return true; } else if (items[SLOT_BOTTLE_4] == bottleItem) { - return 1; + return true; } else { - return 0; + return false; } } @@ -2019,11 +2038,11 @@ s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { } osSyncPrintf("妖精使用=%d\n", bottleSlot); // "Fairy Usage=%d" gSaveContext.inventory.items[bottleSlot + i] = ITEM_BOTTLE; - return 1; + return true; } } - return 0; + return false; } void func_80086D5C(s32* buf, u16 size) { @@ -2092,11 +2111,11 @@ void Interface_SetNaviCall(GlobalContext* globalCtx, u16 naviCallState) { func_800F4524(&D_801333D4, NA_SE_VO_NA_HELLO_2, 32); } - interfaceCtx->naviCalling = 1; + interfaceCtx->naviCalling = true; sCUpInvisible = 0; sCUpTimer = 10; } else if ((naviCallState == 0x1F) && interfaceCtx->naviCalling) { - interfaceCtx->naviCalling = 0; + interfaceCtx->naviCalling = false; } } @@ -2119,7 +2138,7 @@ void Interface_LoadActionLabelB(GlobalContext* globalCtx, u16 action) { &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2228); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); - interfaceCtx->unk_1FA = 1; + interfaceCtx->unk_1FA = true; } s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) { @@ -2133,7 +2152,7 @@ s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) { // clang-format off if (healthChange > 0) { Audio_PlaySoundGeneral(NA_SE_SY_HP_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if ((gSaveContext.doubleDefense != 0) && (healthChange < 0)) { + } else if (gSaveContext.doubleDefense && (healthChange < 0)) { healthChange >>= 1; osSyncPrintf("ハート減少半分!!=%d\n", healthChange); // "Heart decrease halved!!=%d" } @@ -2163,9 +2182,9 @@ s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) { if (gSaveContext.health <= 0) { gSaveContext.health = 0; - return 0; + return false; } else { - return 1; + return true; } } @@ -2602,7 +2621,7 @@ void Interface_DrawMagicBar(GlobalContext* globalCtx) { void func_80088AA0(s16 arg0) { gSaveContext.timerX[1] = 140; gSaveContext.timerY[1] = 80; - D_80125A5C = 0; + D_80125A5C = false; gSaveContext.timer2Value = arg0; if (arg0 != 0) { @@ -2625,7 +2644,7 @@ void func_80088AF0(GlobalContext* globalCtx) { void func_80088B34(s16 arg0) { gSaveContext.timerX[0] = 140; gSaveContext.timerY[0] = 80; - D_80125A5C = 0; + D_80125A5C = false; gSaveContext.timer1Value = arg0; if (arg0 != 0) { @@ -3491,11 +3510,11 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.timer1Value == 0) { gSaveContext.timer1State = 10; - if (D_80125A5C != 0) { + if (D_80125A5C) { gSaveContext.health = 0; globalCtx->damagePlayer(globalCtx, -(gSaveContext.health + 2)); } - D_80125A5C = 0; + D_80125A5C = false; } else if (gSaveContext.timer1Value > 60) { if (timerDigits[4] == 1) { Audio_PlaySoundGeneral(NA_SE_SY_MESSAGE_WOMAN, &D_801333D4, 4, &D_801333E0, @@ -3791,7 +3810,7 @@ void Interface_Draw(GlobalContext* globalCtx) { } void Interface_Update(GlobalContext* globalCtx) { - static u8 D_80125B60 = 0; + static u8 D_80125B60 = false; static s16 sPrevTimeIncrement = 0; MessageContext* msgCtx = &globalCtx->msgCtx; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; @@ -3856,9 +3875,9 @@ void Interface_Update(GlobalContext* globalCtx) { alpha = 0; } - alpha1 = 0xFF - alpha; - if (alpha1 >= 0xFF) { - alpha1 = 0xFF; + alpha1 = 255 - alpha; + if (alpha1 >= 255) { + alpha1 = 255; } osSyncPrintf("case 50 : alpha=%d alpha1=%d\n", alpha, alpha1); @@ -3907,7 +3926,7 @@ void Interface_Update(GlobalContext* globalCtx) { } gSaveContext.unk_13EC++; - if (alpha1 == 0xFF) { + if (alpha1 == 255) { gSaveContext.unk_13E8 = 0; } @@ -4060,7 +4079,7 @@ void Interface_Update(GlobalContext* globalCtx) { gSaveContext.timer1State = 1; gSaveContext.timerX[0] = 140; gSaveContext.timerY[0] = 80; - D_80125A5C = 1; + D_80125A5C = true; } } else { if (((D_80125A58 == 0) || (D_80125A58 == 3)) && (gSaveContext.timer1State < 5)) { @@ -4112,15 +4131,15 @@ void Interface_Update(GlobalContext* globalCtx) { // handle suns song in areas where time moves if (globalCtx->envCtx.timeIncrement != 0) { if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { - D_80125B60 = 0; + D_80125B60 = false; if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime <= 0xC001)) { - D_80125B60 = 1; + D_80125B60 = true; } gSaveContext.sunsSongState = SUNSSONG_SPEED_TIME; sPrevTimeIncrement = gTimeIncrement; gTimeIncrement = 400; - } else if (D_80125B60 == 0) { + } else if (!D_80125B60) { if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime <= 0xC001)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gTimeIncrement = sPrevTimeIncrement; @@ -4136,12 +4155,12 @@ void Interface_Update(GlobalContext* globalCtx) { gSaveContext.nextDayTime = 0; globalCtx->fadeTransition = 4; gSaveContext.nextTransition = 2; - globalCtx->unk_11DE9 = 1; + globalCtx->unk_11DE9 = true; } else { gSaveContext.nextDayTime = 0x8001; globalCtx->fadeTransition = 5; gSaveContext.nextTransition = 3; - globalCtx->unk_11DE9 = 1; + globalCtx->unk_11DE9 = true; } if (globalCtx->sceneNum == SCENE_SPOT13) { diff --git a/src/code/z_play.c b/src/code/z_play.c index 7a3fed57c3..7138b9a7be 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -334,7 +334,7 @@ void Gameplay_Init(GameState* thisx) { globalCtx->sceneLoadFlag = -0x14; globalCtx->unk_11E16 = 0xFF; globalCtx->unk_11E18 = 0; - globalCtx->unk_11DE9 = 0; + globalCtx->unk_11DE9 = false; if (gSaveContext.gameMode != 1) { if (gSaveContext.nextTransition == 0xFF) { @@ -856,7 +856,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1, "../z_play.c", 3637); } - if (globalCtx->unk_11DE9 == 0) { + if (!globalCtx->unk_11DE9) { Actor_UpdateAll(globalCtx, &globalCtx->actorCtx); } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index af79764ad7..ac0dbdd8a9 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3826,7 +3826,7 @@ s32 func_808382DC(Player* this, GlobalContext* globalCtx) { } func_80832698(this, NA_SE_VO_LI_TAKEN_AWAY); - globalCtx->unk_11DE9 = 1; + globalCtx->unk_11DE9 = true; func_80078884(NA_SE_OC_ABYSS); } else if ((this->unk_8A1 != 0) && ((this->unk_8A1 >= 2) || (this->invincibilityTimer == 0))) { u8 sp5C[] = { 2, 1, 1 }; @@ -12056,7 +12056,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { } else { if ((this->getItemId == GI_HEART_CONTAINER_2) || (this->getItemId == GI_HEART_CONTAINER) || ((this->getItemId == GI_HEART_PIECE) && - ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { + ((gSaveContext.inventory.questItems & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)))) { temp1 = NA_BGM_HEART_GET | 0x900; } else { temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c index c3954bb454..7fa97a1c2b 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -70,7 +70,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx s16 pad1; s16 phi_v1; s16 pad2; - s16 phi_s0_2; + s16 cursorItem; s16 sp208[3]; OPEN_DISPS(gfxCtx, "../z_kaleido_collect.c", 248); @@ -141,33 +141,33 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx if (pauseCtx->cursorPoint[PAUSE_QUEST] != 0x18) { if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { if (pauseCtx->cursorPoint[PAUSE_QUEST] < 6) { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x66; - osSyncPrintf("000 ccc=%d\n", phi_s0_2); + cursorItem = ITEM_MEDALLION_FOREST + pauseCtx->cursorPoint[PAUSE_QUEST]; + osSyncPrintf("000 ccc=%d\n", cursorItem); } else if (pauseCtx->cursorPoint[PAUSE_QUEST] < 0x12) { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x54; - osSyncPrintf("111 ccc=%d\n", phi_s0_2); + cursorItem = ITEM_SCALE_GOLDEN + pauseCtx->cursorPoint[PAUSE_QUEST]; + osSyncPrintf("111 ccc=%d\n", cursorItem); } else { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x5A; - osSyncPrintf("222 ccc=%d (%d, %d, %d)\n", phi_s0_2, pauseCtx->cursorPoint[PAUSE_QUEST], + cursorItem = ITEM_SONG_MINUET + pauseCtx->cursorPoint[PAUSE_QUEST]; + osSyncPrintf("222 ccc=%d (%d, %d, %d)\n", cursorItem, pauseCtx->cursorPoint[PAUSE_QUEST], 0x12, 0x6C); } } else { - phi_s0_2 = PAUSE_ITEM_NONE; + cursorItem = PAUSE_ITEM_NONE; osSyncPrintf("999 ccc=%d (%d, %d)\n", PAUSE_ITEM_NONE, pauseCtx->cursorPoint[PAUSE_QUEST], 0x18); } } else { if ((gSaveContext.inventory.questItems & 0xF0000000) != 0) { - phi_s0_2 = 0x72; + cursorItem = ITEM_HEART_CONTAINER; } else { - phi_s0_2 = PAUSE_ITEM_NONE; + cursorItem = PAUSE_ITEM_NONE; } - osSyncPrintf("888 ccc=%d (%d, %d, %x)\n", phi_s0_2, pauseCtx->cursorPoint[PAUSE_QUEST], 0x72, - gSaveContext.inventory.questItems & 0xF0000000); + osSyncPrintf("888 ccc=%d (%d, %d, %x)\n", cursorItem, pauseCtx->cursorPoint[PAUSE_QUEST], + ITEM_HEART_CONTAINER, gSaveContext.inventory.questItems & 0xF0000000); } sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; - pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; } @@ -221,12 +221,12 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x5A; + cursorItem = ITEM_SONG_MINUET + pauseCtx->cursorPoint[PAUSE_QUEST]; } else { - phi_s0_2 = PAUSE_ITEM_NONE; + cursorItem = PAUSE_ITEM_NONE; } sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; - pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; } } else { @@ -239,17 +239,17 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { if (pauseCtx->cursorPoint[PAUSE_QUEST] < 6) { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x66; + cursorItem = ITEM_MEDALLION_FOREST + pauseCtx->cursorPoint[PAUSE_QUEST]; } else if (pauseCtx->cursorPoint[PAUSE_QUEST] < 0xC) { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x4E; + cursorItem = ITEM_BOMB_BAG_30 + pauseCtx->cursorPoint[PAUSE_QUEST]; } else { - phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x69; + cursorItem = ITEM_MEDALLION_SPIRIT + pauseCtx->cursorPoint[PAUSE_QUEST]; } } else { - phi_s0_2 = PAUSE_ITEM_NONE; + cursorItem = PAUSE_ITEM_NONE; } sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; - pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; } } @@ -324,7 +324,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx } } - if (CHECK_QUEST_ITEM(sp218)) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST + sp218)) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, D_8082A0D8[sp218], D_8082A0E4[sp218], D_8082A0F0[sp218], 0); @@ -349,8 +349,8 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); for (sp218 = 0; sp218 < QUEST_KOKIRI_EMERALD - QUEST_SONG_MINUET; sp218++, sp21A += 4) { - if (CHECK_QUEST_ITEM(sp218 + QUEST_SONG_MINUET)) { - if ((sp218 + QUEST_SONG_MINUET) == sp216) { + if (CHECK_QUEST_ITEM(QUEST_SONG_MINUET + sp218)) { + if ((QUEST_SONG_MINUET + sp218) == sp216) { pauseCtx->questVtx[sp21A + 0].v.ob[0] = pauseCtx->questVtx[sp21A + 2].v.ob[0] = pauseCtx->questVtx[sp21A + 0].v.ob[0] - 2; @@ -376,7 +376,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { - if (CHECK_QUEST_ITEM(sp218 + 0x12)) { + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD + sp218)) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_KOKIRI_EMERALD + sp218], 24, 24, 0); } @@ -386,7 +386,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { - if (CHECK_QUEST_ITEM(sp218 + 0x15)) { + if (CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY + sp218)) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_STONE_OF_AGONY + sp218], 24, 24, 0); @@ -429,7 +429,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx } } - if ((gSaveContext.inventory.questItems >> 0x1C) != 0) { + if ((gSaveContext.inventory.questItems >> QUEST_HEART_PIECE_COUNT) != 0) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -445,7 +445,9 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); POLY_OPA_DISP = KaleidoScope_QuadTextureIA8( - POLY_OPA_DISP, gItemIcons[0x79 + (((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> 0x1C)], + POLY_OPA_DISP, + gItemIcons[0x79 + + (((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> QUEST_HEART_PIECE_COUNT)], 48, 48, 0); } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index a9b9eb6188..f79725546b 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -302,8 +302,9 @@ void KaleidoScope_DrawDebugEditor(GlobalContext* globalCtx) { KaleidoScope_DrawDigit(globalCtx, spD8[3], 165, 185); // Heart Pieces (X / 4) - KaleidoScope_DrawDigit(globalCtx, ((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> 0x1C, 210, - 185); + KaleidoScope_DrawDigit(globalCtx, + ((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> QUEST_HEART_PIECE_COUNT, + 210, 185); // Handles navigating the menu to different sections with the D-Pad // When the same direction is held, registers the input periodically based on a timer @@ -394,13 +395,13 @@ void KaleidoScope_DrawDebugEditor(GlobalContext* globalCtx) { case 0x5C: if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - if ((((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> 0x1C) != 0) { - gSaveContext.inventory.questItems -= 0x10000000; + if ((((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> QUEST_HEART_PIECE_COUNT) != 0) { + gSaveContext.inventory.questItems -= (1 << QUEST_HEART_PIECE_COUNT); } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - if ((gSaveContext.inventory.questItems & 0xF0000000) <= 0x40000000) { - gSaveContext.inventory.questItems += 0x10000000; + if ((gSaveContext.inventory.questItems & 0xF0000000) <= (4 << QUEST_HEART_PIECE_COUNT)) { + gSaveContext.inventory.questItems += (1 << QUEST_HEART_PIECE_COUNT); } } break;