diff options
| author | Zelllll <56516451+Zelllll@users.noreply.github.com> | 2021-05-25 17:49:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-25 18:49:11 -0400 |
| commit | 6c860166039e53517e1c1da6629a361c0922dc07 (patch) | |
| tree | 82c1b3d20ea19c1b14c77d9aa4aca2f4a84192f8 /src/code | |
| parent | cf3eb3b2e19bb60ec9d93b04a57127585e8ac6df (diff) | |
partially finish `code_0x8012EC80`, document all of gSaveContext (#138)
* not ok, why?
* OK!
* fix data
* finish data etc
* work on save context
* save finished
* first func done
* roomInf
* done for now
* add missing file
* add most og names for struct members
* fix accidental change
* Update z_en_ginko_man.c
* Update z_scene.c
* maybe fix stuff hopefully
* proto
* sasa
* Update include/z64save.h
Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
* Update z64save.h
Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/code_0x8012EC80.c | 406 | ||||
| -rw-r--r-- | src/code/z_en_item00.c | 36 | ||||
| -rw-r--r-- | src/code/z_scene.c | 60 | ||||
| -rw-r--r-- | src/code/z_scene_table.c | 2 | ||||
| -rw-r--r-- | src/code/z_snap.c | 19 |
5 files changed, 465 insertions, 58 deletions
diff --git a/src/code/code_0x8012EC80.c b/src/code/code_0x8012EC80.c new file mode 100644 index 000000000..2be7a0db1 --- /dev/null +++ b/src/code/code_0x8012EC80.c @@ -0,0 +1,406 @@ +#include <ultra64.h> +#include <global.h> + +// Bit Flag array in which gBitFlags[n] is literally (1 << n) +u32 gBitFlags[] = { + (1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4), (1 << 5), (1 << 6), (1 << 7), + (1 << 8), (1 << 9), (1 << 10), (1 << 11), (1 << 12), (1 << 13), (1 << 14), (1 << 15), + (1 << 16), (1 << 17), (1 << 18), (1 << 19), (1 << 20), (1 << 21), (1 << 22), (1 << 23), + (1 << 24), (1 << 25), (1 << 26), (1 << 27), (1 << 28), (1 << 29), (1 << 30), (1 << 31), +}; + +u16 gEquipMasks[] = { 0x000F, 0x00F0, 0x0F00, 0xF000 }; +u16 gEquipNegMasks[] = { 0xFFF0, 0xFF0F, 0xF0FF, 0x0FFF }; +u32 gUpgradeMasks[] = { + 0x00000007, 0x00000038, 0x000001C0, 0x00000E00, 0x00003000, 0x0001C000, 0x000E0000, 0x00700000, +}; +u32 gUpgradeNegMasks[] = { + 0xFFFFFFF8, 0xFFFFFFC7, 0xFFFFFE3F, 0xFFFFF1FF, 0xFFFFCFFF, 0xFFFE3FFF, 0xFFF1FFFF, 0xFF8FFFFF, +}; +u8 gEquipShifts[] = { 0, 4, 8, 12 }; +u8 gUpgradeShifts[] = { 0, 3, 6, 9, 12, 14, 17, 20, 0, 0, 0, 30, 0, 40, 0, 50 }; + +u16 gUpgradeCapacities[][4] = { + { 0, 20, 30, 40 }, // Bomb Bags + { 0, 0, 0, 0 }, // Unused (Scale) + { 0, 0, 0, 0 }, // Unused (Strength) + { 99, 200, 500, 500 }, // Wallets + { 0, 30, 40, 50 }, // Quivers + { 0, 10, 20, 30 }, // Unused (Deku Stick) + { 0, 20, 30, 40 }, // Unused (Deku Nut) +}; + +u32 gGsFlagsMask[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; +u32 gGsFlagsShift[] = { 0, 8, 16, 24 }; + +// TODO: use symbols for these icon textures once textures are properly in C +void* gItemIcons[] = { + 0x08000000, 0x08001000, 0x08002000, 0x08003000, 0x08004000, 0x08005000, 0x08006000, 0x08007000, 0x08008000, + 0x08009000, 0x0800A000, 0x0800B000, 0x0800C000, 0x0800D000, 0x0800E000, 0x0800F000, 0x08010000, 0x08011000, + 0x08012000, 0x08013000, 0x08014000, 0x08015000, 0x08016000, 0x08017000, 0x08018000, 0x08019000, 0x0801A000, + 0x0801B000, 0x0801C000, 0x0801D000, 0x0801E000, 0x0801F000, 0x08020000, 0x08021000, 0x08022000, 0x08023000, + 0x08024000, 0x08025000, 0x08026000, 0x08027000, 0x08028000, 0x08029000, 0x0802A000, 0x0802B000, 0x0802C000, + 0x0802D000, 0x0802E000, 0x0802F000, 0x08030000, 0x08031000, 0x08032000, 0x08033000, 0x08034000, 0x08035000, + 0x08036000, 0x08037000, 0x08038000, 0x08039000, 0x0803A000, 0x0803B000, 0x0803C000, 0x0803D000, 0x0803E000, + 0x0803F000, 0x08040000, 0x08041000, 0x08042000, 0x08043000, 0x08044000, 0x08045000, 0x08046000, 0x08047000, + 0x08048000, 0x08049000, 0x0804A000, 0x0804B000, 0x0804C000, 0x0804D000, 0x0804E000, 0x0804F000, 0x08050000, + 0x08051000, 0x08052000, 0x08053000, 0x08054000, 0x08055000, 0x08056000, 0x08057000, 0x08058000, 0x08059000, + 0x0805A000, 0x0805B000, 0x0805C000, 0x0805D000, 0x0805E000, 0x0805F000, 0x08060000, 0x08062000, 0x08062000, + 0x08062000, 0x08062000, 0x08062000, 0x08062000, 0x08062000, 0x08062000, 0x08062000, 0x08062000, 0x08062000, + 0x08062000, 0x08061000, 0x09000000, 0x09000900, 0x09001200, 0x08062000, 0x08062000, 0x08062000, 0x09003600, + 0x09004800, 0x09003F00, 0x09005100, 0x09005A00, 0x09006300, 0x09006C00, 0x08062180, 0x08062A80, 0x08063380, + 0x020028A0, 0x020025A0, 0x020027A0, 0x020026A0, 0x020024A0, +}; + +// Used to map item IDs to inventory slots +u8 gItemSlots[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x05, 0x05, 0x05, 0x05, 0x05, 0x0B, 0x0B, 0x11, + 0x11, 0x11, 0x1D, 0x23, 0x29, 0x2F, 0x28, 0x26, 0x19, 0x20, 0x1E, 0x2C, 0x24, 0x25, 0x18, 0x27, + 0x1C, 0x2B, 0x21, 0x2A, 0x2D, 0x1B, 0x1F, 0x1A, 0x22, 0x2E, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, +}; + +u16 gItemPrices[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 20, + 5, 20, 20, 50, 50, 200, 20, 20, 20, 200, 5, 0, 200, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +// Used to map scene indexes to their region in Termina +u16 gScenesPerRegion[11][27] = { + // Great Bay + { + SCENE_30GYOSON, + SCENE_LABO, + SCENE_FISHERMAN, + SCENE_SINKAI, + SCENE_31MISAKI, + SCENE_TORIDE, + SCENE_KAIZOKU, + SCENE_PIRATE, + SCENE_35TAKI, + SCENE_KINDAN2, + -1, + }, + // Zora Hall + { + SCENE_33ZORACITY, + SCENE_BANDROOM, + -1, + }, + // Romani Ranch + { + SCENE_F01, + SCENE_ROMANYMAE, + SCENE_OMOYA, + SCENE_F01C, + SCENE_F01_B, + SCENE_KOEPONARACE, + -1, + }, + // Deku Palace + { + SCENE_22DEKUCITY, + SCENE_DEKU_KING, + SCENE_26SARUNOMORI, + SCENE_DANPEI, + -1, + }, + // Southern Swamp + { + SCENE_20SICHITAI, + SCENE_20SICHITAI2, + SCENE_MAP_SHOP, + SCENE_WITCH_SHOP, + SCENE_21MITURINMAE, + SCENE_KINSTA1, + -1, + }, + // Clock Town + { + SCENE_00KEIKOKU, SCENE_TENMON_DAI, SCENE_13HUBUKINOMITI, + SCENE_24KEMONOMITI, SCENE_SYATEKI_MORI, SCENE_IKANAMAE, + SCENE_TOWN, SCENE_SYATEKI_MIZU, SCENE_BOWLING, + SCENE_TAKARAYA, SCENE_YADOYA, SCENE_SONCHONOIE, + SCENE_MILK_BAR, SCENE_ICHIBA, SCENE_BOMYA, + SCENE_AYASHIISHOP, SCENE_8ITEMSHOP, SCENE_DOUJOU, + SCENE_POSTHOUSE, SCENE_TAKARAKUJI, SCENE_BACKTOWN, + SCENE_CLOCKTOWER, SCENE_INSIDETOWER, SCENE_OKUJOU, + SCENE_ALLEY, SCENE_DEKUTES, -1, + }, + // Snowhead + { + SCENE_10YUKIYAMANOMURA, + SCENE_10YUKIYAMANOMURA2, + SCENE_KAJIYA, + SCENE_12HAKUGINMAE, + SCENE_14YUKIDAMANOMITI, + SCENE_GORONRACE, + SCENE_GORON_HAKA, + SCENE_17SETUGEN, + SCENE_17SETUGEN2, + -1, + }, + // Ikana Graveyard + { + SCENE_BOTI, + SCENE_DANPEI2TEST, + -1, + }, + // Ikana Canyon + { + SCENE_CASTLE, + SCENE_IKNINSIDE, + SCENE_IKANA, + SCENE_SECOM, + SCENE_MUSICHOUSE, + SCENE_RANDOM, + SCENE_REDEAD, + SCENE_TOUGITES, + SCENE_HAKASHITA, + -1, + }, + // Goron Village + { + SCENE_11GORONNOSATO, + SCENE_11GORONNOSATO2, + SCENE_16GORON_HOUSE, + SCENE_GORONSHOP, + -1, + }, + // Stone Tower + { + SCENE_F40, + SCENE_F41, + -1, + }, +}; + +s32 func_8012EC80(GlobalContext* globalCtx) { + if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { + return 0xFF; + } else if (gSaveContext.unk_1015 == 0xFF) { + return 0xFF; + } else if (gSaveContext.equips.buttonItems[((gSaveContext.playerForm == 4) ? 0 : gSaveContext.playerForm)][0] == + 0xFF) { + if (globalCtx->interfaceCtx.unk_21C != 0) { + if (globalCtx->interfaceCtx.unk_21E != 0) { + return globalCtx->interfaceCtx.unk_21E; + } + } + return 0xFF; + } else { + return gSaveContext.equips.buttonItems[((gSaveContext.playerForm == 4) ? 0 : gSaveContext.playerForm)][0]; + } +} + +void func_8012ED34(s16 equipment); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012ED34.asm") + +u8 func_8012ED78(GlobalContext* globalCtx, s16 equipment); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012ED78.asm") + +void func_8012EDE8(s16 arg0, u32 arg1); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012EDE8.asm") + +s32 func_8012EE34(s16 arg0) { + s16 num = 0; + + if (arg0 >= 0x20) { + if (arg0 < 0x40) { + num = 1; + } else if (arg0 < 0x60) { + num = 2; + } else if (arg0 < 0x80) { + num = 3; + } else if (arg0 < 0xA0) { + num = 4; + } else if (arg0 < 0xC0) { + num = 5; + } else if (arg0 < 0xE0) { + num = 6; + } + } + + if (gSaveContext.roomInf[125][num] & gBitFlags[arg0 - (num << 5)]) { + return 1; + } + + return 0; +} + +/* static */ u16 D_801C2380[12][6] = { + { + SCENE_00KEIKOKU, + SCENE_BOTI, + SCENE_13HUBUKINOMITI, + SCENE_24KEMONOMITI, + SCENE_IKANAMAE, + SCENE_TOWN, + }, + { + SCENE_ICHIBA, + SCENE_BACKTOWN, + SCENE_CLOCKTOWER, + SCENE_ALLEY, + -1, + }, + { + SCENE_20SICHITAI, + SCENE_20SICHITAI2, + SCENE_21MITURINMAE, + SCENE_22DEKUCITY, + SCENE_DEKU_KING, + SCENE_KINSTA1, + }, + { -1 }, + { + SCENE_10YUKIYAMANOMURA, + SCENE_10YUKIYAMANOMURA2, + SCENE_11GORONNOSATO, + SCENE_11GORONNOSATO2, + SCENE_16GORON_HOUSE, + SCENE_12HAKUGINMAE, + }, + { + SCENE_14YUKIDAMANOMITI, + SCENE_GORONRACE, + SCENE_17SETUGEN, + SCENE_17SETUGEN2, + -1, + }, + { + SCENE_F01, + SCENE_ROMANYMAE, + SCENE_OMOYA, + SCENE_F01C, + SCENE_F01_B, + SCENE_KOEPONARACE, + }, + { -1 }, + { + SCENE_30GYOSON, + SCENE_SINKAI, + SCENE_31MISAKI, + SCENE_TORIDE, + SCENE_KAIZOKU, + SCENE_33ZORACITY, + }, + { + SCENE_35TAKI, + -1, + }, + { + SCENE_F40, + SCENE_F41, + SCENE_CASTLE, + SCENE_IKANA, + SCENE_REDEAD, + -1, + }, +}; + +#ifdef NON_EQUIVALENT +// loop seems wrong? +void func_8012EF0C(s16 arg0) { + s16 i; + s16 num; + s16 sceneIndex; + + if ((arg0 >= 0) && (arg0 < ARRAY_COUNT(D_801C2380))) { + i = 0; + num = 0; + sceneIndex = D_801C2380[arg0][i]; + + while (sceneIndex != 0xFFFF) { + sceneIndex = D_801C2380[arg0][i]; + if (sceneIndex < 0x20) { + num = 0; + } else if (sceneIndex < 0x40) { + num = 1; + } else if (sceneIndex < 0x60) { + num = 2; + } else if (sceneIndex < 0x80) { + num = 3; + } else if (sceneIndex < 0xA0) { + num = 4; + } else if (sceneIndex < 0xC0) { + num = 5; + } else if (sceneIndex < 0xE0) { + num = 6; + } + + gSaveContext.roomInf[125][sceneIndex] |= gBitFlags[(-(num << 7)) + num]; + i++; + } + + if (i == 0) { + gSaveContext.unk_F60 |= 3; + } else if (i == 1) { + gSaveContext.unk_F60 |= 0x1C; + } else if (i == 2) { + gSaveContext.unk_F60 |= 0xE0; + } else if (i == 3) { + gSaveContext.unk_F60 |= 0x100; + } else if (i == 4) { + gSaveContext.unk_F60 |= 0x1E00; + } else if (i == 5) { + gSaveContext.unk_F60 |= 0x6000; + } + } + + dREG(82) = 0; +} +#else +void func_8012EF0C(s16 arg0); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012EF0C.asm") +#endif + +void func_8012F0EC(s16 arg0); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012F0EC.asm") + +#ifdef NON_MATCHING +// regalloc +void func_8012F1BC(s16 sceneIndex) { + if (sceneIndex == SCENE_KINSTA1) { + gSaveContext.roomInf[126][0] = ((((gSaveContext.roomInf[126][0] & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.roomInf[126][0] & 0xFFFF); + } else { + gSaveContext.roomInf[126][0] = + ((gSaveContext.roomInf[126][0] + 1) & 0xFFFF) | (gSaveContext.roomInf[126][0] & 0xFFFF0000); + } +} +#else +void func_8012F1BC(s16 arg0); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012F1BC.asm") +#endif + +s16 func_8012F22C(s16 sceneIndex) { + if (sceneIndex == SCENE_KINSTA1) { + return (gSaveContext.roomInf[126][0] & 0xFFFF0000) >> 0x10; + } else { + return gSaveContext.roomInf[126][0] & 0xFFFF; + } +} + +void func_8012F278(GlobalContext* globalCtx); +#pragma GLOBAL_ASM("./asm/non_matchings/code/code_0x8012EC80/func_8012F278.asm") + +u32 D_801C2410[] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000101, 0x01000000, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00010100, 0x00000101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000001, 0x00000001, 0x01000000, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x01010101, 0x01010101, + 0x00010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 9eeecf4fb..c8e54ec09 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -813,22 +813,22 @@ void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { } s16 func_800A7650(s16 dropId) { - s16 maxLife; + s16 healthCapacity; if ((((dropId == ITEM00_BOMBS_A) || (dropId == ITEM00_BOMBS_0) || (dropId == ITEM00_BOMBS_B)) && - (gSaveContext.perm.inv.items[D_801C207E] == 0xFF)) || + (gSaveContext.inventory.items[gItemSlots[6]] == 0xFF)) || (((dropId == ITEM00_ARROWS_10) || (dropId == ITEM00_ARROWS_30) || (dropId == ITEM00_ARROWS_40) || (dropId == ITEM00_ARROWS_50)) && - (gSaveContext.perm.inv.items[D_801C2079] == 0xFF)) || - (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && (gSaveContext.perm.unk24.unk14 == 0))) { + (gSaveContext.inventory.items[gItemSlots[1]] == 0xFF)) || + (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && (gSaveContext.magicLevel == 0))) { return ITEM00_NO_DROP; } ; if (dropId == ITEM00_HEART) { - maxLife = gSaveContext.perm.unk24.maxLife; - if (maxLife == gSaveContext.perm.unk24.currentLife) { + healthCapacity = gSaveContext.healthCapacity; + if (healthCapacity == gSaveContext.health) { return ITEM00_RUPEE_GREEN; } } @@ -1071,9 +1071,9 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 if (dropId == ITEM00_MASK) { dropQuantity = 1; - if (gSaveContext.perm.unk20 != 1) { - if (gSaveContext.perm.unk20 != 2) { - if (gSaveContext.perm.unk20 != 4) { + if (gSaveContext.playerForm != 1) { + if (gSaveContext.playerForm != 2) { + if (gSaveContext.playerForm != 4) { dropId = ITEM00_RUPEE_GREEN; } else { dropId = ITEM00_ARROWS_10; @@ -1102,39 +1102,39 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.perm.unk24.currentLife < 0x11) { + if (gSaveContext.health < 0x11) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); func_800F0568(globalCtx, spawnPos, 0x28, 0x28E7); return; } - if (gSaveContext.perm.unk24.currentLife < 0x31) { + if (gSaveContext.health < 0x31) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 3; - } else if (gSaveContext.perm.unk24.currentLife < 0x51) { + } else if (gSaveContext.health < 0x51) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 1; - } else if ((gSaveContext.perm.unk24.unk14 != 0) && (gSaveContext.perm.unk24.currentMagic == 0)) { + } else if ((gSaveContext.magicLevel != 0) && (gSaveContext.magic == 0)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; - } else if ((gSaveContext.perm.unk24.unk14 != 0) && - ((gSaveContext.perm.unk24.unk14 >> 1) >= gSaveContext.perm.unk24.currentMagic)) { + } else if ((gSaveContext.magicLevel != 0) && + ((gSaveContext.magicLevel >> 1) >= gSaveContext.magic)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; - } else if (gSaveContext.perm.inv.quantities[D_801C2078[1]] < 6) { + } else if (gSaveContext.inventory.ammo[gItemSlots[1]] < 6) { params = 0xA0; dropId = ITEM00_ARROWS_30; dropQuantity = 1; - } else if (gSaveContext.perm.inv.quantities[D_801C2078[6]] < 6) { + } else if (gSaveContext.inventory.ammo[gItemSlots[6]] < 6) { params = 0xB0; dropId = ITEM00_BOMBS_A; dropQuantity = 1; - } else if (gSaveContext.perm.unk24.unk14 < 11) { + } else if (gSaveContext.rupees < 11) { params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 0841d72ae..78c57d478 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -148,12 +148,12 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 loadedCount; void* nextObject; s16 playerObjectId; - u8 unk20; + u8 playerForm; globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || - (gSaveContext.extra.unk10 == 0x02 && gSaveContext.extra.unk42 == 0x0CFF)) { + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[1].playerParams == 0x0CFF)) { // Skull Kid Object Object_Spawn(&globalCtx->objectCtx, OBJECT_STK); return; @@ -163,8 +163,8 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; globalCtx->objectCtx.num = loadedCount; globalCtx->objectCtx.spawnedObjectCount = loadedCount; - unk20 = gSaveContext.perm.unk20; - playerObjectId = gLinkFormObjectIndexes[unk20]; + playerForm = gSaveContext.playerForm; + playerObjectId = gLinkFormObjectIndexes[playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&globalCtx->objectCtx, playerObjectId); @@ -384,7 +384,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { u32 dayTime; if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { - gSaveContext.extra.environmentTime = gSaveContext.perm.time = + gSaveContext.environmentTime = gSaveContext.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); } @@ -394,32 +394,32 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->kankyoContext.unk2 = 0; } - if ((gSaveContext.perm.inv.items[0] == 0xFF) && (globalCtx->kankyoContext.unk2 != 0)) { + if ((gSaveContext.inventory.items[0] == 0xFF) && (globalCtx->kankyoContext.unk2 != 0)) { globalCtx->kankyoContext.unk2 = 5; } - if (gSaveContext.extra.unk2b8 == 0) { + if (gSaveContext.unk_3F58 == 0) { REG(15) = globalCtx->kankyoContext.unk2; } - dayTime = gSaveContext.perm.time; + dayTime = gSaveContext.time; globalCtx->kankyoContext.unk4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.perm.time; + dayTime = gSaveContext.time; globalCtx->kankyoContext.unk8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.perm.time; + dayTime = gSaveContext.time; globalCtx->kankyoContext.unkC = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; - if (globalCtx->kankyoContext.unk2 == 0 && gSaveContext.perm.cutscene < 0xFFF0) { - gSaveContext.extra.environmentTime = gSaveContext.perm.time; - - if (gSaveContext.extra.environmentTime >= 0x2AAA && gSaveContext.extra.environmentTime < 0x4555) { - gSaveContext.extra.environmentTime = 0x3555; - } else if (gSaveContext.extra.environmentTime >= 0x4555 && gSaveContext.extra.environmentTime < 0x5555) { - gSaveContext.extra.environmentTime = 0x5555; - } else if (gSaveContext.extra.environmentTime >= 0xAAAA && gSaveContext.extra.environmentTime < 0xB555) { - gSaveContext.extra.environmentTime = 0xB555; - } else if (gSaveContext.extra.environmentTime >= 0xC000 && gSaveContext.extra.environmentTime < 0xCAAA) { - gSaveContext.extra.environmentTime = 0xCAAA; + if (globalCtx->kankyoContext.unk2 == 0 && gSaveContext.cutscene < 0xFFF0) { + gSaveContext.environmentTime = gSaveContext.time; + + if (gSaveContext.environmentTime >= 0x2AAA && gSaveContext.environmentTime < 0x4555) { + gSaveContext.environmentTime = 0x3555; + } else if (gSaveContext.environmentTime >= 0x4555 && gSaveContext.environmentTime < 0x5555) { + gSaveContext.environmentTime = 0x5555; + } else if (gSaveContext.environmentTime >= 0xAAAA && gSaveContext.environmentTime < 0xB555) { + gSaveContext.environmentTime = 0xB555; + } else if (gSaveContext.environmentTime >= 0xC000 && gSaveContext.environmentTime < 0xCAAA) { + gSaveContext.environmentTime = 0xCAAA; } } } @@ -450,7 +450,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->unk814 = cmd->soundSettings.musicSeq; globalCtx->unk815 = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.extra.unk276 == 0xFF || func_801A8A50(0) == 0x57) { + if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == 0x57) { audio_setBGM(cmd->soundSettings.bgmId); } } @@ -465,9 +465,9 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { SceneCmd** altHeaderList; SceneCmd* altHeader; - if (gSaveContext.extra.sceneSetupIndex) { + if (gSaveContext.sceneSetupIndex) { altHeaderList = (SceneCmd**)Lib_SegmentedToVirtual(cmd->altHeaders.segment); - altHeader = altHeaderList[gSaveContext.extra.sceneSetupIndex - 1]; + altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; if (altHeader != NULL) { Scene_ProcessHeader(globalCtx, (SceneCmd*)Lib_SegmentedToVirtual(altHeader)); @@ -509,24 +509,24 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) s16 i = 0; while (true) { - if (scenesPerMapArea[i].scenes[j] == 0xFFFF) { + if (gScenesPerRegion[i][j] == 0xFFFF) { i++; j = 0; - if (i == (s32)(sizeof(scenesPerMapArea) / sizeof(SceneIdList))) { + if (i == ARRAY_COUNT(gScenesPerRegion)) { break; } } - if (globalCtx->sceneNum == scenesPerMapArea[i].scenes[j]) { + if (globalCtx->sceneNum == gScenesPerRegion[i][j]) { break; } j++; } - if (i < (s32)(sizeof(scenesPerMapArea) / sizeof(SceneIdList))) { - gSaveContext.perm.mapsVisited = (gBitFlags[i] | gSaveContext.perm.mapsVisited) | gSaveContext.perm.mapsVisited; + if (i < ARRAY_COUNT(gScenesPerRegion)) { + gSaveContext.mapsVisited = (gBitFlags[i] | gSaveContext.mapsVisited) | gSaveContext.mapsVisited; } } @@ -609,5 +609,5 @@ u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) { * Creates an entrance index from the current entrance index with the given spawn index. */ u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) { - return Entrance_CreateIndex(gSaveContext.perm.entranceIndex >> 9, spawnIndex, 0); + return Entrance_CreateIndex(gSaveContext.entranceIndex >> 9, spawnIndex, 0); } diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index ef6bdaafd..6a363231a 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -2657,7 +2657,7 @@ static EntranceTableEntry* sCutsceneEntranceTable[] = { #define SCENE_ENTRANCE_NONE() \ { 0, NULL, NULL } -/*static*/ SceneEntranceTableEntry sSceneEntranceTable[] = { +static SceneEntranceTableEntry sSceneEntranceTable[] = { SCENE_ENTRANCE(sMayorsResidenceEntranceTable, "Z2_SONCHONOIE"), SCENE_ENTRANCE(sMajorasLairEntranceTable, "Z2_LAST_BS"), SCENE_ENTRANCE(sMagicHagsPotionShopEntranceTable, "Z2_WITCH_SHOP"), diff --git a/src/code/z_snap.c b/src/code/z_snap.c index f2c1328ea..b51dde076 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -13,8 +13,8 @@ s32 func_8013A240(GlobalContext* globalCtx) { s32 seen; s32 count = 0; - gSaveContext.perm.pictoFlags0 = 0; - gSaveContext.perm.pictoFlags1 = 0; + gSaveContext.roomInf[123][3] = 0; + gSaveContext.roomInf[123][4] = 0; if (globalCtx->sceneNum == SCENE_20SICHITAI) { func_8013A41C(1); @@ -77,29 +77,30 @@ s32 func_8013A240(GlobalContext* globalCtx) { void func_8013A41C(s32 flag) { if (flag < 0x20) { - gSaveContext.perm.pictoFlags0 |= (1 << flag); + gSaveContext.roomInf[123][3] |= (1 << flag); } else { flag &= 0x1F; - gSaveContext.perm.pictoFlags1 |= (1 << flag); + gSaveContext.roomInf[123][4] |= (1 << flag); } } void func_8013A46C(s32 flag) { if (flag < 0x20) { - gSaveContext.perm.pictoFlags0 &= ~(1 << flag); + gSaveContext.roomInf[123][3] &= ~(1 << flag); } else { flag &= 0x1F; - gSaveContext.perm.pictoFlags1 &= ~(1 << flag); + gSaveContext.roomInf[123][4] &= ~(1 << flag); } } u32 func_8013A4C4(s32 flag) { - SaveContextPerm* save = &gSaveContext.perm; + SaveContext* saveCtx = &gSaveContext; + if (flag < 0x20) { - return save->pictoFlags0 & (1 << flag); + return saveCtx->roomInf[123][3] & (1 << flag); } else { flag &= 0x1F; - return save->pictoFlags1 & (1 << flag); + return saveCtx->roomInf[123][4] & (1 << flag); } } |
