From c73e2ab72618b01c96f63868a8f1001e86eaa461 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 22 Sep 2023 17:50:44 +0200 Subject: [PATCH] Make macros for age reqs data and access (#1549) * Make macros for age reqs data and access * line breaks for readability --- .../ovl_kaleido_scope/z_kaleido_equipment.c | 11 +- .../misc/ovl_kaleido_scope/z_kaleido_item.c | 11 +- .../misc/ovl_kaleido_scope/z_kaleido_scope.h | 14 ++ .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 146 ++++++++++++++++-- 4 files changed, 157 insertions(+), 25 deletions(-) diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index e3e5997a51..1af28c4a72 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -441,9 +441,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { osSyncPrintf("kscope->select_name[Display_Equipment] = %d\n", pauseCtx->cursorItem[PAUSE_EQUIP]); - if (!((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || - (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == - ((void)0, gSaveContext.save.linkAge)))) { + if (!CHECK_AGE_REQ_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP])) { pauseCtx->nameColorSet = 1; } @@ -473,9 +471,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && CHECK_BTN_ALL(input->press.button, BTN_A) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { - if ((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || - (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == - ((void)0, gSaveContext.save.linkAge))) { + if (CHECK_AGE_REQ_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP])) { Inventory_ChangeEquipment(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]); if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { @@ -529,8 +525,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { for (k = 0, temp = rowStart + 1, bit = rowStart, j = point; k < 3; k++, bit++, j += 4, temp++) { if ((gBitFlags[bit] & gSaveContext.save.info.inventory.equipment) && (pauseCtx->cursorSpecialPos == 0)) { - if ((gEquipAgeReqs[i][k + 1] == 9) || - (gEquipAgeReqs[i][k + 1] == ((void)0, gSaveContext.save.linkAge))) { + if (CHECK_AGE_REQ_EQUIP(i, k + 1)) { if (temp == cursorSlot) { pauseCtx->equipVtx[j].v.ob[0] = pauseCtx->equipVtx[j + 2].v.ob[0] = pauseCtx->equipVtx[j].v.ob[0] - 2; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 5294bfdcb3..6d8a846c96 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -24,7 +24,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gDPPipeSync(POLY_OPA_DISP++); - if (!((gSlotAgeReqs[SLOT(item)] == 9) || gSlotAgeReqs[SLOT(item)] == ((void)0, gSaveContext.save.linkAge))) { + if (!CHECK_AGE_REQ_SLOT(SLOT(item))) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 100, pauseCtx->alpha); } else { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); @@ -340,8 +340,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; - if (!((gSlotAgeReqs[cursorSlot] == 9) || - (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.save.linkAge)))) { + if (!CHECK_AGE_REQ_SLOT(cursorSlot)) { pauseCtx->nameColorSet = 1; } @@ -351,9 +350,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { if ((pauseCtx->debugState == 0) && (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { if (CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { - if (((gSlotAgeReqs[cursorSlot] == 9) || - (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.save.linkAge))) && - (cursorItem != ITEM_SOLD_OUT)) { + if (CHECK_AGE_REQ_SLOT(cursorSlot) && (cursorItem != ITEM_SOLD_OUT)) { if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { pauseCtx->equipTargetCBtn = 0; } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { @@ -438,7 +435,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { if (gSaveContext.save.info.inventory.items[i] != ITEM_NONE) { if ((pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0)) { - if ((gSlotAgeReqs[i] == 9) || (gSlotAgeReqs[i] == ((void)0, gSaveContext.save.linkAge))) { + if (CHECK_AGE_REQ_SLOT(i)) { if ((sEquipState == 2) && (i == 3)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, magicArrowEffectsR[pauseCtx->equipTargetItem - 0xBF], magicArrowEffectsG[pauseCtx->equipTargetItem - 0xBF], diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h index e8d8af8e40..d352ad678e 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h @@ -9,8 +9,22 @@ extern s16 D_8082AAEC[]; extern s16 D_8082AB2C[]; extern u8 gSlotAgeReqs[]; extern u8 gEquipAgeReqs[EQUIP_TYPE_MAX][4]; +extern u8 gItemAgeReqs[]; extern u8 gAreaGsFlags[]; +#define AGE_REQ_ADULT LINK_AGE_ADULT +#define AGE_REQ_CHILD LINK_AGE_CHILD +#define AGE_REQ_NONE 9 + +#define CHECK_AGE_REQ_SLOT(slot) \ + ((gSlotAgeReqs[slot] == AGE_REQ_NONE) || gSlotAgeReqs[slot] == ((void)0, gSaveContext.save.linkAge)) + +#define CHECK_AGE_REQ_EQUIP(y, x) \ + ((gEquipAgeReqs[y][x] == AGE_REQ_NONE) || (gEquipAgeReqs[y][x] == ((void)0, gSaveContext.save.linkAge))) + +#define CHECK_AGE_REQ_ITEM(item) \ + ((gItemAgeReqs[item] == AGE_REQ_NONE) || (gItemAgeReqs[item] == ((void)0, gSaveContext.save.linkAge))) + void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx); s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s32 point); void KaleidoScope_DrawDebugEditor(PlayState* play); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 0ea6f38ed4..839372999c 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -168,20 +168,146 @@ static u16 D_8082ABEC[] = { }; u8 gSlotAgeReqs[] = { - 1, 9, 9, 0, 0, 9, 1, 9, 9, 0, 0, 9, 1, 9, 1, 0, 0, 9, 9, 9, 9, 9, 0, 1, + AGE_REQ_CHILD, // SLOT_DEKU_STICK + AGE_REQ_NONE, // SLOT_DEKU_NUT + AGE_REQ_NONE, // SLOT_BOMB + AGE_REQ_ADULT, // SLOT_BOW + AGE_REQ_ADULT, // SLOT_ARROW_FIRE + AGE_REQ_NONE, // SLOT_DINS_FIRE + AGE_REQ_CHILD, // SLOT_SLINGSHOT + AGE_REQ_NONE, // SLOT_OCARINA + AGE_REQ_NONE, // SLOT_BOMBCHU + AGE_REQ_ADULT, // SLOT_HOOKSHOT + AGE_REQ_ADULT, // SLOT_ARROW_ICE + AGE_REQ_NONE, // SLOT_FARORES_WIND + AGE_REQ_CHILD, // SLOT_BOOMERANG + AGE_REQ_NONE, // SLOT_LENS_OF_TRUTH + AGE_REQ_CHILD, // SLOT_MAGIC_BEAN + AGE_REQ_ADULT, // SLOT_HAMMER + AGE_REQ_ADULT, // SLOT_ARROW_LIGHT + AGE_REQ_NONE, // SLOT_NAYRUS_LOVE + AGE_REQ_NONE, // SLOT_BOTTLE_1 + AGE_REQ_NONE, // SLOT_BOTTLE_2 + AGE_REQ_NONE, // SLOT_BOTTLE_3 + AGE_REQ_NONE, // SLOT_BOTTLE_4 + AGE_REQ_ADULT, // SLOT_TRADE_ADULT + AGE_REQ_CHILD, // SLOT_TRADE_CHILD }; -u8 gEquipAgeReqs[EQUIP_TYPE_MAX][4] = { - { 0, 1, 0, 0 }, - { 9, 1, 9, 0 }, - { 0, 9, 0, 0 }, - { 9, 9, 0, 0 }, +u8 gEquipAgeReqs[4][4] = { + { + AGE_REQ_ADULT, // 0 UPG_QUIVER + AGE_REQ_CHILD, // EQUIP_TYPE_SWORD EQUIP_VALUE_SWORD_KOKIRI + AGE_REQ_ADULT, // EQUIP_TYPE_SWORD EQUIP_VALUE_SWORD_MASTER + AGE_REQ_ADULT, // EQUIP_TYPE_SWORD EQUIP_VALUE_SWORD_BIGGORON + }, + { + AGE_REQ_NONE, // 0 UPG_BOMB_BAG + AGE_REQ_CHILD, // EQUIP_TYPE_SHIELD EQUIP_VALUE_SHIELD_DEKU + AGE_REQ_NONE, // EQUIP_TYPE_SHIELD EQUIP_VALUE_SHIELD_HYLIAN + AGE_REQ_ADULT, // EQUIP_TYPE_SHIELD EQUIP_VALUE_SHIELD_MIRROR + }, + { + AGE_REQ_ADULT, // 0 UPG_STRENGTH + AGE_REQ_NONE, // EQUIP_TYPE_TUNIC EQUIP_VALUE_TUNIC_KOKIRI + AGE_REQ_ADULT, // EQUIP_TYPE_TUNIC EQUIP_VALUE_TUNIC_GORON + AGE_REQ_ADULT, // EQUIP_TYPE_TUNIC EQUIP_VALUE_TUNIC_ZORA + }, + { + AGE_REQ_NONE, // 0 UPG_SCALE + AGE_REQ_NONE, // EQUIP_TYPE_BOOTS EQUIP_VALUE_BOOTS_KOKIRI + AGE_REQ_ADULT, // EQUIP_TYPE_BOOTS EQUIP_VALUE_BOOTS_IRON + AGE_REQ_ADULT, // EQUIP_TYPE_BOOTS EQUIP_VALUE_BOOTS_HOVER + }, }; u8 gItemAgeReqs[] = { - 1, 9, 9, 0, 0, 9, 1, 9, 9, 9, 0, 0, 0, 9, 1, 9, 1, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 1, 9, 0, 9, 0, 0, 9, 0, 0, 1, 1, 1, 0, 0, 0, 9, 9, 9, 1, 0, 0, 9, 9, 0, + AGE_REQ_CHILD, // ITEM_DEKU_STICK + AGE_REQ_NONE, // ITEM_DEKU_NUT + AGE_REQ_NONE, // ITEM_BOMB + AGE_REQ_ADULT, // ITEM_BOW + AGE_REQ_ADULT, // ITEM_ARROW_FIRE + AGE_REQ_NONE, // ITEM_DINS_FIRE + AGE_REQ_CHILD, // ITEM_SLINGSHOT + AGE_REQ_NONE, // ITEM_OCARINA_FAIRY + AGE_REQ_NONE, // ITEM_OCARINA_OF_TIME + AGE_REQ_NONE, // ITEM_BOMBCHU + AGE_REQ_ADULT, // ITEM_HOOKSHOT + AGE_REQ_ADULT, // ITEM_LONGSHOT + AGE_REQ_ADULT, // ITEM_ARROW_ICE + AGE_REQ_NONE, // ITEM_FARORES_WIND + AGE_REQ_CHILD, // ITEM_BOOMERANG + AGE_REQ_NONE, // ITEM_LENS_OF_TRUTH + AGE_REQ_CHILD, // ITEM_MAGIC_BEAN + AGE_REQ_ADULT, // ITEM_HAMMER + AGE_REQ_ADULT, // ITEM_ARROW_LIGHT + AGE_REQ_NONE, // ITEM_NAYRUS_LOVE + AGE_REQ_NONE, // ITEM_BOTTLE_EMPTY + AGE_REQ_NONE, // ITEM_BOTTLE_POTION_RED + AGE_REQ_NONE, // ITEM_BOTTLE_POTION_GREEN + AGE_REQ_NONE, // ITEM_BOTTLE_POTION_BLUE + AGE_REQ_NONE, // ITEM_BOTTLE_FAIRY + AGE_REQ_NONE, // ITEM_BOTTLE_FISH + AGE_REQ_NONE, // ITEM_BOTTLE_MILK_FULL + AGE_REQ_NONE, // ITEM_BOTTLE_RUTOS_LETTER + AGE_REQ_NONE, // ITEM_BOTTLE_BLUE_FIRE + AGE_REQ_NONE, // ITEM_BOTTLE_BUG + AGE_REQ_NONE, // ITEM_BOTTLE_BIG_POE + AGE_REQ_NONE, // ITEM_BOTTLE_MILK_HALF + AGE_REQ_NONE, // ITEM_BOTTLE_POE + AGE_REQ_CHILD, // ITEM_WEIRD_EGG + AGE_REQ_CHILD, // ITEM_CHICKEN + AGE_REQ_CHILD, // ITEM_ZELDAS_LETTER + AGE_REQ_CHILD, // ITEM_MASK_KEATON + AGE_REQ_CHILD, // ITEM_MASK_SKULL + AGE_REQ_CHILD, // ITEM_MASK_SPOOKY + AGE_REQ_CHILD, // ITEM_MASK_BUNNY_HOOD + AGE_REQ_CHILD, // ITEM_MASK_GORON + AGE_REQ_CHILD, // ITEM_MASK_ZORA + AGE_REQ_CHILD, // ITEM_MASK_GERUDO + AGE_REQ_CHILD, // ITEM_MASK_TRUTH + AGE_REQ_CHILD, // ITEM_SOLD_OUT + AGE_REQ_ADULT, // ITEM_POCKET_EGG + AGE_REQ_ADULT, // ITEM_POCKET_CUCCO + AGE_REQ_ADULT, // ITEM_COJIRO + AGE_REQ_ADULT, // ITEM_ODD_MUSHROOM + AGE_REQ_ADULT, // ITEM_ODD_POTION + AGE_REQ_ADULT, // ITEM_POACHERS_SAW + AGE_REQ_ADULT, // ITEM_BROKEN_GORONS_SWORD + AGE_REQ_ADULT, // ITEM_PRESCRIPTION + AGE_REQ_ADULT, // ITEM_EYEBALL_FROG + AGE_REQ_ADULT, // ITEM_EYE_DROPS + AGE_REQ_ADULT, // ITEM_CLAIM_CHECK + AGE_REQ_ADULT, // ITEM_BOW_FIRE + AGE_REQ_ADULT, // ITEM_BOW_ICE + AGE_REQ_ADULT, // ITEM_BOW_LIGHT + AGE_REQ_CHILD, // ITEM_SWORD_KOKIRI + AGE_REQ_ADULT, // ITEM_SWORD_MASTER + AGE_REQ_ADULT, // ITEM_SWORD_BIGGORON + AGE_REQ_CHILD, // ITEM_SHIELD_DEKU + AGE_REQ_NONE, // ITEM_SHIELD_HYLIAN + AGE_REQ_ADULT, // ITEM_SHIELD_MIRROR + AGE_REQ_NONE, // ITEM_TUNIC_KOKIRI + AGE_REQ_ADULT, // ITEM_TUNIC_GORON + AGE_REQ_ADULT, // ITEM_TUNIC_ZORA + AGE_REQ_NONE, // ITEM_BOOTS_KOKIRI + AGE_REQ_ADULT, // ITEM_BOOTS_IRON + AGE_REQ_ADULT, // ITEM_BOOTS_HOVER + AGE_REQ_CHILD, // ITEM_BULLET_BAG_30 + AGE_REQ_CHILD, // ITEM_BULLET_BAG_40 + AGE_REQ_CHILD, // ITEM_BULLET_BAG_50 + AGE_REQ_ADULT, // ITEM_QUIVER_30 + AGE_REQ_ADULT, // ITEM_QUIVER_40 + AGE_REQ_ADULT, // ITEM_QUIVER_50 + AGE_REQ_NONE, // ITEM_BOMB_BAG_20 + AGE_REQ_NONE, // ITEM_BOMB_BAG_30 + AGE_REQ_NONE, // ITEM_BOMB_BAG_40 + AGE_REQ_CHILD, // ITEM_STRENGTH_GORONS_BRACELET + AGE_REQ_ADULT, // ITEM_STRENGTH_SILVER_GAUNTLETS + AGE_REQ_ADULT, // ITEM_STRENGTH_GOLD_GAUNTLETS + AGE_REQ_NONE, // ITEM_SCALE_SILVER + AGE_REQ_NONE, // ITEM_SCALE_GOLDEN + AGE_REQ_ADULT, // ITEM_GIANTS_KNIFE }; u8 gAreaGsFlags[] = { @@ -2557,7 +2683,7 @@ void KaleidoScope_Update(PlayState* play) { gSegments[8] = VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); for (i = 0; i < ARRAY_COUNTU(gItemAgeReqs); i++) { - if ((gItemAgeReqs[i] != 9) && (gItemAgeReqs[i] != ((void)0, gSaveContext.save.linkAge))) { + if (!CHECK_AGE_REQ_ITEM(i)) { KaleidoScope_GrayOutTextureRGBA32(SEGMENTED_TO_VIRTUAL(gItemIcons[i]), ITEM_ICON_WIDTH * ITEM_ICON_HEIGHT); }