diff options
| author | Random <28494085+Random06457@users.noreply.github.com> | 2020-10-11 19:45:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-11 13:45:08 -0400 |
| commit | b010db7c19207f0e607d5ccaf0d1f2350dda3964 (patch) | |
| tree | 12dc8d3a3dfb57705ba907dd0af855662ed35bde /include | |
| parent | 9d3554220793d515230844f894ede66100bdc039 (diff) | |
Decompile z_sram.c (#431)
* Decompile z_sram.c
* rename Sram_CalcChecksum to Sram_WriteSaveSlot
* progress
* done i think
* add original name comments
* temp substructs
* minor fixes
* review
* review 2
* fix
Co-authored-by: fig <fig02srl@gmail.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/functions.h | 25 | ||||
| -rw-r--r-- | include/macros.h | 12 | ||||
| -rw-r--r-- | include/variables.h | 15 | ||||
| -rw-r--r-- | include/z64.h | 291 | ||||
| -rw-r--r-- | include/z64save.h | 190 |
5 files changed, 318 insertions, 215 deletions
diff --git a/include/functions.h b/include/functions.h index 92792bc78..212e03cf4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1397,14 +1397,21 @@ void SkinMatrix_SetScaleRotateYRPTranslate(MtxF* mf, f32 scaleX, f32 scaleY, f32 f32 dx, f32 dy, f32 dz); Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src); void func_800A7EC0(MtxF* mf, s16 a, f32 x, f32 y, f32 z); -// ? func_800A81A0(?); -// ? func_800A82C8(?); -// ? func_800A9A9C(?); -// ? func_800A9D28(?); -void func_800A9D40(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, - u8 handlePulse, u32 handleSpeed); -void func_800A9E14(UNK_PTR dramAddr, size_t size, UNK_TYPE arg2); -void Sram_ReadWrite(UNK_TYPE arg0, UNK_PTR dramAddr, size_t size, UNK_TYPE arg3); +void Sram_InitNewSave(void); +void Sram_InitDebugSave(void); +void Sram_OpenSave(SramContext* sramCtx); +void Sram_WriteSave(s32 unused); +void Sram_VerifyAndLoadAllSaves(FileChooseContext* fileChoose, SramContext* sramCtx); +void Sram_InitSave(FileChooseContext* fileChoose, SramContext* sramCtx); +void Sram_EraseSave(FileChooseContext* fileChoose, SramContext* sramCtx); +void Sram_CopySave(FileChooseContext* fileChoose, SramContext* sramCtx); +void Sram_Write16Bytes(SramContext* sramCtx); +void Sram_InitSram(GameState* gameState, SramContext* sramCtx); +void Sram_Alloc(GameState* gameState, SramContext* sramCtx); +void Sram_Init(GlobalContext* globalCtx, SramContext* sramCtx); +void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, u8 handlePulse, u32 handleSpeed); +void SsSram_Dma(void* dramAddr, size_t size, s32 direction); +void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction); void func_800A9F30(PadMgr*, s32); void func_800A9F6C(f32, u8, u8, u8); void func_800AA000(f32, u8, u8, u8); @@ -2284,7 +2291,7 @@ void func_800F6584(UNK_TYPE); void func_800F6584(UNK_TYPE); // ? func_800F66C0(?); void func_800F66DC(s8); -// ? func_800F6700(?); +void func_800F6700(s8 outputMode); void func_800F67A0(u8); // ? func_800F6828(?); void func_800F68BC(s8); diff --git a/include/macros.h b/include/macros.h index 8ebfb26fb..d61729e57 100644 --- a/include/macros.h +++ b/include/macros.h @@ -30,19 +30,19 @@ #define LINK_AGE_IN_YEARS (LINK_IS_CHILD ? YEARS_CHILD : YEARS_ADULT) #define SLOT(item) gItemSlots[item] -#define INV_CONTENT(item) gSaveContext.items[SLOT(item)] -#define AMMO(item) gSaveContext.ammo[SLOT(item)] +#define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)] +#define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] #define BEANS_BOUGHT AMMO(ITEM_BEAN + 1) -#define ALL_EQUIP_VALUE(equip) ((s32)(gSaveContext.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) +#define ALL_EQUIP_VALUE(equip) ((s32)(gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_EQUIP_VALUE(equip) ((s32)(gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CHECK_OWNED_EQUIP(equip, value) ((gBitFlags[value] << gEquipShifts[equip]) & gSaveContext.equipment) +#define CHECK_OWNED_EQUIP(equip, value) ((gBitFlags[value] << gEquipShifts[equip]) & gSaveContext.inventory.equipment) -#define CUR_UPG_VALUE(upg) ((s32)(gSaveContext.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define CUR_UPG_VALUE(upg) ((s32)(gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) -#define CHECK_QUEST_ITEM(item) (gBitFlags[item] & gSaveContext.questItems) +#define CHECK_QUEST_ITEM(item) (gBitFlags[item] & gSaveContext.inventory.questItems) #define B_BTN_ITEM ((gSaveContext.buttonStatus[0] == ITEM_NONE) \ ? ITEM_NONE \ diff --git a/include/variables.h b/include/variables.h index 135d5c2e7..7c13c6474 100644 --- a/include/variables.h +++ b/include/variables.h @@ -439,16 +439,7 @@ extern RomFile gObjectTable[402]; extern EntranceInfo gEntranceTable[1556]; extern Scene gSceneTable[110]; //extern ? D_8012A4A0; -//extern ? D_8012A4E0; -//extern ? D_8012A4EC; -//extern ? D_8012A4F8; -//extern ? D_8012A544; -//extern ? D_8012A550; -//extern ? D_8012A5B0; -//extern ? D_8012A5B4; -//extern ? D_8012A600; -//extern ? D_8012A60C; -//extern ? D_8012A66C; +extern u16 gSramSlotOffsets[2][3]; //extern ? D_8012A690; //extern ? D_8012A69C; //extern ? D_8012A6A4; @@ -704,8 +695,8 @@ extern s32 D_80130514; //extern ? D_80131880; //extern ? D_80131884; //extern ? D_8013188C; -//extern ? D_80131BE4; -//extern ? D_80131BE8; +extern u8* gScarecrowCustomSongPtr; +extern u8* gScarecrowSpawnSongPtr; //extern ? D_80131BEC; //extern ? D_80131BF0; //extern ? D_80131C00; diff --git a/include/z64.h b/include/z64.h index bd7cb633a..303fe24a9 100644 --- a/include/z64.h +++ b/include/z64.h @@ -3,6 +3,7 @@ #include "ultra64.h" #include "ultra64/gs2dex.h" +#include "z64save.h" #include "z64light.h" #include "z64actor.h" #include "z64player.h" @@ -56,178 +57,6 @@ typedef struct { } GameInfo; // size = 0x15D4 typedef struct { - /* 0x00 */ u8 buttonItems[4]; - /* 0x04 */ u8 cButtonSlots[3]; - /* 0x08 */ u16 equipment; -} ItemEquips; // size = 0x0A - -typedef struct { - /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch; - /* 0x08 */ u32 clear; - /* 0x0C */ u32 collect; - /* 0x10 */ u32 unk; - /* 0x14 */ u32 rooms; - /* 0x18 */ u32 floors; -} SaveSceneFlags; // size = 0x1C - -typedef struct { - /* 0x00 */ s16 scene; - /* 0x02 */ Vec3s pos; - /* 0x08 */ s16 angle; -} HorseData; // size = 0x0A - -typedef struct { - /* 0x00 */ Vec3f pos; - /* 0x0C */ s16 yaw; - /* 0x0E */ s16 playerParams; - /* 0x10 */ s16 entranceIndex; - /* 0x12 */ u8 roomIndex; - /* 0x13 */ s8 data; - /* 0x14 */ u32 tempSwchFlags; - /* 0x18 */ u32 tempCollectFlags; -} RespawnData; // size = 0x1C - -typedef enum { - /* 0x00 */ RESPAWN_MODE_DOWN, /* Normal Void Outs */ - /* 0x01 */ RESPAWN_MODE_RETURN, /* Grotto Returnpoints */ - /* 0x02 */ RESPAWN_MODE_TOP /* Farore's Wind */ -} RespawnMode; - -typedef enum { - /* 0x00 */ BTN_ENABLED, - /* 0xFF */ BTN_DISABLED = 0xFF -} ButtonStatus; - -// Save Context (dbg ram start: 8015E660) -typedef struct { - /* 0x0000 */ s32 entranceIndex; - /* 0x0004 */ s32 linkAge; // 0: Adult; 1: Child - /* 0x0008 */ s32 cutsceneIndex; - /* 0x000C */ u16 dayTime; // "zelda_time" - /* 0x0010 */ s32 nightFlag; - /* 0x0014 */ s32 unk_14; - /* 0x0018 */ s32 unk_18; - /* 0x001C */ char newf[6]; // string "ZELDAZ" - /* 0x0022 */ s16 deaths; - /* 0x0024 */ char playerName[8]; - /* 0x002C */ s16 n64ddFlag; - /* 0x002E */ s16 healthCapacity; // "max_life" - /* 0x0030 */ s16 health; // "now_life" - /* 0x0032 */ s8 magicLevel; - /* 0x0033 */ s8 magic; - /* 0x0034 */ s16 rupees; - /* 0x0036 */ u16 swordHealth; - /* 0x0038 */ u16 naviTimer; - /* 0x003A */ u8 magicAcquired; - /* 0x003B */ char unk_3B[0x0001]; - /* 0x003C */ u8 doubleMagic; - /* 0x003D */ u8 doubleDefense; - /* 0x003E */ u8 bgsFlag; - /* 0x0040 */ ItemEquips childEquips; - /* 0x004A */ ItemEquips adultEquips; - /* 0x0054 */ char unk_54[0x0014]; - /* 0x0068 */ ItemEquips equips; - /* 0x0072 */ char unk_72[0x0002]; - /* 0x0074 */ u8 items[24]; - /* 0x008C */ s8 ammo[16]; - /* 0x009C */ u16 equipment; - /* 0x00A0 */ u32 upgrades; - /* 0x00A4 */ u32 questItems; - /* 0x00A8 */ u8 dungeonItems[20]; - /* 0x00BC */ s8 dungeonKeys[19]; - /* 0x00CF */ s8 defenseHearts; - /* 0x00D0 */ s16 gsTokens; - /* 0x00D4 */ SaveSceneFlags sceneFlags[124]; - struct { - /* 0x0E64 */ Vec3i pos; - /* 0x0E70 */ s32 yaw; - /* 0x0E74 */ s32 playerParams; - /* 0x0E78 */ s32 entranceIndex; - /* 0x0E7C */ s32 roomIndex; - /* 0x0E80 */ s32 set; - /* 0x0E84 */ s32 tempSwchFlags; - /* 0x0E88 */ s32 tempCollectFlags; - } fw; - /* 0x0E8C */ char unk_E8C[0x0010]; - /* 0x0E9C */ s32 gsFlags[6]; - /* 0x0EB4 */ char unk_EB4[0x0010]; - /* 0x0EC4 */ s32 unk_EC4; - /* 0x0EC8 */ char unk_EC8[0x000C]; - /* 0x0ED4 */ u16 eventChkInf[14]; // "event_chk_inf" - /* 0x0EF0 */ u16 itemGetInf[4]; // "item_get_inf" - /* 0x0EF8 */ u16 infTable[30]; // "inf_table" - /* 0x0F34 */ char unk_F34[0x0004]; - /* 0x0F38 */ u32 worldMapAreaData; // "area_arrival" - /* 0x0F3C */ char unk_F3C[0x0389]; - /* 0x12C5 */ u8 unk_12C5; - /* 0x12C6 */ char unk_12C6[0x0082]; - /* 0x1348 */ HorseData horseData; - /* 0x1352 */ u16 checksum; // "check_sum" - /* 0x1354 */ s32 fileNum; // "file_no" - /* 0x1358 */ char unk_1358[0x0004]; - /* 0x135C */ s32 gameMode; - /* 0x1360 */ s32 sceneSetupIndex; - /* 0x1364 */ s32 respawnFlag; // "restart_flag" - /* 0x1368 */ RespawnData respawn[3]; // "restart_data" - /* 0x13BC */ f32 unk_13BC; - /* 0x13C0 */ u16 unk_13C0; - /* 0x13C2 */ char unk_13C2[0x0001]; - /* 0x13C3 */ u8 unk_13C3; - /* 0x13C4 */ s16 dogParams; - /* 0x13C6 */ u8 textTriggerFlags; - /* 0x13C7 */ u8 unk_13C7; - /* 0x13C8 */ s16 nayrusLoveTimer; - /* 0x13CA */ char unk_13CA[0x0002]; - /* 0x13CC */ s16 rupeeAccumulator; - /* 0x13CE */ s16 timer1State; - /* 0x13D0 */ s16 timer1Value; - /* 0x13D2 */ s16 timer2State; - /* 0x13D4 */ s16 timer2Value; - /* 0x13D6 */ s16 timerX[2]; - /* 0x13DA */ s16 timerY[2]; - /* 0x13DE */ char unk_13DE[0x0002]; - /* 0x13E0 */ u8 seqIndex; - /* 0x13E1 */ u8 nightSeqIndex; - /* 0x13E2 */ u8 buttonStatus[5]; - /* 0x13E7 */ u8 unk_13E7; - /* 0x13E8 */ u16 unk_13E8; // alpha type? - /* 0x13EA */ u16 unk_13EA; // also alpha type? - /* 0x13EC */ u16 unk_13EC; // alpha type counter? - /* 0x13EE */ u16 unk_13EE; // previous alpha type? - /* 0x13F0 */ s16 unk_13F0; - /* 0x13F2 */ s16 unk_13F2; - /* 0x13F4 */ s16 unk_13F4; - /* 0x13F6 */ s16 unk_13F6; - /* 0x13F8 */ s16 unk_13F8; - /* 0x13FA */ u16 eventInf[4]; // "event_inf" - /* 0x1402 */ u16 mapIndex; // intended for maps/minimaps but commonly used as the dungeon index - /* 0x1404 */ u16 minigameState; - /* 0x1406 */ u16 minigameScore; // "yabusame_total" - /* 0x1408 */ char unk_1408[0x0001]; - /* 0x1409 */ u8 language; - /* 0x140A */ u8 audioSetting; - /* 0x140B */ char unk_140B[0x0001]; - /* 0x140C */ u8 zTargetingSetting; // 0: Switch; 1: Hold - /* 0x140E */ u16 unk_140E; // bgm related - /* 0x1410 */ u8 unk_1410; - /* 0x1411 */ u8 unk_1411; - /* 0x1412 */ u16 nextCutsceneIndex; - /* 0x1414 */ u8 cutsceneTrigger; - /* 0x1415 */ u8 chamberCutsceneNum; - /* 0x1416 */ u16 nextDayTime; // "next_zelda_time" - /* 0x1418 */ u8 fadeDuration; - /* 0x1419 */ u8 unk_1419; // transition related - /* 0x141A */ u16 environmentTime; - /* 0x141C */ u8 dogIsLost; - /* 0x141D */ u8 nextTransition; - /* 0x141E */ char unk_141E[0x0002]; - /* 0x1420 */ s16 worldMapArea; - /* 0x1422 */ s16 unk_1422; // day time related - /* 0x1424 */ s16 healthAccumulator; -} SaveContext; // size = 0x1428 - -typedef struct { /* 0x00000 */ u16 headMagic; // 1234 /* 0x00008 */ Gfx polyOpaBuffer[0x17E0]; /* 0x0BF08 */ Gfx polyXluBuffer[0x800]; @@ -266,12 +95,12 @@ typedef struct { typedef struct OSScTask { /* 0x00 */ struct OSScTask* next; - /* 0x04 */ u32 state; - /* 0x08 */ u32 flags; - /* 0x0C */ CfbInfo* framebuffer; - /* 0x10 */ OSTask list; - /* 0x50 */ OSMesgQueue* msgQ; - /* 0x54 */ OSMesg msg; + /* 0x04 */ u32 state; + /* 0x08 */ u32 flags; + /* 0x0C */ CfbInfo* framebuffer; + /* 0x10 */ OSTask list; + /* 0x50 */ OSMesgQueue* msgQ; + /* 0x54 */ OSMesg msg; } OSScTask; typedef struct GraphicsContext { @@ -657,10 +486,6 @@ typedef struct { } SoundSource; // size = 0x1C typedef struct { - /* 0x00 */ char unk_0[0x4]; -} SubGlobalContext1F74; // size = 0x4 - -typedef struct { /* 0x000 */ char unk_00[0x128]; /* 0x128 */ void* staticSegments[3]; /* 0x134 */ Gfx* dpList; @@ -1030,8 +855,7 @@ typedef struct { /* 0x1C4 */ Collider* colOc[COLLISION_CHECK_OC_MAX]; /* 0x28C */ s32 colOcLineCount; /* 0x290 */ OcLine* colOcLine[COLLISION_CHECK_OC_LINE_MAX]; - -} CollisionCheckContext; // size = 0x29C SubGlobalContext11E60 +} CollisionCheckContext; // size = 0x29C typedef struct ListAlloc { /* 0x00 */ struct ListAlloc* prev; @@ -1104,8 +928,10 @@ typedef struct { } EntranceEntry; typedef struct { - /* 0x00 */ void* read_buff; -} Sram; // size = 0x4 + /* 0x00 */ u8* readBuff; +} SramContext; // size = 0x4 + +#define SRAM_SIZE 0x8000 typedef struct GameAllocEntry { /* 0x00 */ struct GameAllocEntry* next; @@ -1141,7 +967,7 @@ typedef struct { /* 0x0000 */ GameState state; /* 0x00A4 */ void* staticSegment; /* 0x00A8 */ View view; - /* 0x01D0 */ Sram sram; + /* 0x01D0 */ SramContext sramCtx; /* 0x01D4 */ u16 unk_1D4; // not used in mq dbg (some sort of timer that doesn't seem to affect anything) /* 0x01D6 */ s16 coverAlpha; /* 0x01D8 */ s16 addAlpha; // not used in mq dbg @@ -1221,7 +1047,7 @@ typedef struct GlobalContext { /* 0x01C24 */ ActorContext actorCtx; /* 0x01D64 */ CutsceneContext csCtx; // "demo_play" /* 0x01DB4 */ SoundSource soundSources[16]; - /* 0x01F74 */ SubGlobalContext1F74 sub_1F74; + /* 0x01F74 */ SramContext sramCtx; /* 0x01F78 */ SkyboxContext skyboxCtx; /* 0x020C8 */ char unk_20C8[0x10]; /* 0x020D8 */ MessageContext msgCtx; // "message" @@ -1291,6 +1117,95 @@ typedef struct { /* 0x00A8 */ View view; } OpeningContext; // size = 0x1D0 +typedef struct { + /* 0x00000 */ GameState state; + /* 0x000A4 */ Vtx* allocVtx1; + /* 0x000A8 */ void* staticSegment; + /* 0x000AC */ void* parameterSegment; + /* 0x000B0 */ char unk_B0[0x8]; + /* 0x000B8 */ View view; + /* 0x001E0 */ SramContext sramCtx; + /* 0x001E4 */ char unk_1E4[0x4]; + /* 0x001E8 */ SkyboxContext skyboxCtx; + /* 0x00338 */ char unk_338[0x10]; + /* 0x00348 */ MessageContext msgCtx; + /* 0x0E760 */ char kanfont[0xE188]; + /* 0x1C8E8 */ EnvironmentContext envCtx; + /* 0x1C9E4 */ char unk_1C9E4[0x4]; + /* 0x1C9E8 */ Vtx* allocVtx2; + /* 0x1C9EC */ Vtx* allocVtx3; + /* 0x1C9F0 */ Vtx* allocVtx4; + /* 0x1C9F4 */ u8 n64ddFlag; + /* 0x1C9F6 */ u16 deaths[3]; + /* 0x1C9FC */ u8 fileNames[3][8]; + /* 0x1CA14 */ u16 healthCapacities[3]; + /* 0x1CA1C */ u32 questItems[3]; + /* 0x1CA28 */ s16 n64ddFlags[3]; + /* 0x1CA2E */ s8 heartStatus[3]; + /* 0x1CA32 */ u16 nowLife[3]; + /* 0x1CA38 */ s16 btnIdx; + /* 0x1CA3A */ u16 yesNoButtonIdx; + /* 0x1CA3C */ s16 menuIdx; + /* 0x1CA3E */ s16 fileSelectStateIdx; + /* 0x1CA40 */ s16 unkActionIndex; + /* 0x1CA42 */ u16 nextFileSelectStateIdx; + /* 0x1CA44 */ s16 openFileStateIdx; + /* 0x1CA46 */ s16 selectedFileIdx; + /* 0x1CA48 */ char unk_1CA48[0x2]; + /* 0x1CA4A */ u16 fileNamesY[3]; + /* 0x1CA50 */ u16 actionTimer; + /* 0x1CA52 */ u16 buttonsY[6]; + /* 0x1CA5E */ s16 copyDestFileIdx; + /* 0x1CA60 */ u16 fileWarningTexIdx; + /* 0x1CA62 */ u16 warningFileIdx; + /* 0x1CA64 */ u16 titleTexIdx; + /* 0x1CA66 */ u16 nextTitleTexIdx; + /* 0x1CA68 */ s16 windowR; + /* 0x1CA6A */ s16 windowG; + /* 0x1CA6C */ s16 windowB; + /* 0x1CA6E */ u16 selectFileTitleA; + /* 0x1CA70 */ u16 openFileTitleA; + /* 0x1CA72 */ u16 windowA; + /* 0x1CA74 */ u16 fileButtonsA[3]; + /* 0x1CA7A */ u16 fileNameBoxesA[3]; + /* 0x1CA80 */ u16 fileNamesA[3]; + /* 0x1CA86 */ u16 metalJointsA[3]; + /* 0x1CA8C */ u16 fileInfoA; + /* 0x1CA8E */ u16 targetFileInfoBoxA; + /* 0x1CA90 */ u16 unkFileInfoBoxA; + /* 0x1CA92 */ u16 copyButtonA; + /* 0x1CA94 */ u16 eraseButtonA; + /* 0x1CA96 */ u16 yesBiuttonA; + /* 0x1CA98 */ u16 quitButtonA; + /* 0x1CA9A */ u16 optionButtonA; + /* 0x1CA9C */ u16 newFileNameBoxA; + /* 0x1CA9E */ u16 decideCancelTextA; + /* 0x1CAA0 */ u16 fileEmptyTextA; + /* 0x1CAA2 */ u16 highlightColorR; + /* 0x1CAA4 */ u16 highlightColorG; + /* 0x1CAA6 */ u16 highlightColorB; + /* 0x1CAA8 */ u16 highlightColorA; + /* 0x1CAAA */ u16 highlightColorAIncrease; + /* 0x1CAAC */ char unk_1CAAC[0x6]; + /* 0x1CAB2 */ u16 stickXTimer; + /* 0x1CAB4 */ u16 stickYTimer; + /* 0x1CAB6 */ u16 idxXOff; + /* 0x1CAB8 */ u16 idxYOff; + /* 0x1CABA */ s16 stickX; + /* 0x1CABC */ s16 stickY; + /* 0x1CABE */ u16 newFileNameBoxX; + /* 0x1CAC0 */ u16 windowX; + /* 0x1CAC4 */ f32 windowRotX; + /* 0x1CAC8 */ u16 kbdButtonIdx; + /* 0x1CACA */ u16 unk_1CACA; + /* 0x1CACC */ u16 kbdCharBoxA; + /* 0x1CACE */ s16 kbdCharIdx; + /* 0x1CAD0 */ s16 kbdCharX; + /* 0x1CAD2 */ s16 kbdCharY; + /* 0x1CAD4 */ s16 newFileNameCharCount; + /* 0x1CAD6 */ u16 unk_1CAD6[3]; +} FileChooseContext; // size = 0x1CADC + typedef enum { DPM_UNK = 0, DPM_PLAYER = 1, diff --git a/include/z64save.h b/include/z64save.h new file mode 100644 index 000000000..7ef1cba0e --- /dev/null +++ b/include/z64save.h @@ -0,0 +1,190 @@ +#ifndef _Z64SAVE_H_ +#define _Z64SAVE_H_ + +#include "ultra64.h" +#include "z64math.h" + +typedef struct { + /* 0x00 */ u8 buttonItems[4]; + /* 0x04 */ u8 cButtonSlots[3]; + /* 0x08 */ u16 equipment; +} ItemEquips; // size = 0x0A + +typedef struct { + /* 0x00 */ u8 items[24]; + /* 0x18 */ s8 ammo[16]; + /* 0x28 */ u16 equipment; + /* 0x2C */ u32 upgrades; + /* 0x30 */ u32 questItems; + /* 0x34 */ u8 dungeonItems[20]; + /* 0x48 */ s8 dungeonKeys[19]; + /* 0x5B */ s8 defenseHearts; + /* 0x5C */ s16 gsTokens; +} Inventory; // size = 0x5E + +typedef struct { + /* 0x00 */ u32 chest; + /* 0x04 */ u32 swch; + /* 0x08 */ u32 clear; + /* 0x0C */ u32 collect; + /* 0x10 */ u32 unk; + /* 0x14 */ u32 rooms; + /* 0x18 */ u32 floors; +} SavedSceneFlags; // size = 0x1C + +typedef struct { + /* 0x00 */ s16 scene; + /* 0x02 */ Vec3s pos; + /* 0x08 */ s16 angle; +} HorseData; // size = 0x0A + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ s16 yaw; + /* 0x0E */ s16 playerParams; + /* 0x10 */ s16 entranceIndex; + /* 0x12 */ u8 roomIndex; + /* 0x13 */ s8 data; + /* 0x14 */ u32 tempSwchFlags; + /* 0x18 */ u32 tempCollectFlags; +} RespawnData; // size = 0x1C + +typedef struct { + /* 0x00 */ Vec3i pos; + /* 0x0C */ s32 yaw; + /* 0x10 */ s32 playerParams; + /* 0x14 */ s32 entranceIndex; + /* 0x18 */ s32 roomIndex; + /* 0x1C */ s32 set; + /* 0x20 */ s32 tempSwchFlags; + /* 0x24 */ s32 tempCollectFlags; +} FaroresWindData; // size = 0x28 + +typedef struct { + /* 0x0000 */ s32 entranceIndex; // start of `save` substruct, originally called "memory" + /* 0x0004 */ s32 linkAge; // 0: Adult; 1: Child + /* 0x0008 */ s32 cutsceneIndex; + /* 0x000C */ u16 dayTime; // "zelda_time" + /* 0x0010 */ s32 nightFlag; + /* 0x0014 */ s32 numDays; + /* 0x0018 */ s32 unk_18; // increments with numDays, gets reset by goron for bgs and one other use + /* 0x001C */ char newf[6]; // string "ZELDAZ". start of `info` substruct, originally called "information" + /* 0x0022 */ s16 deaths; + /* 0x0024 */ char playerName[8]; + /* 0x002C */ s16 n64ddFlag; + /* 0x002E */ s16 healthCapacity; // "max_life" + /* 0x0030 */ s16 health; // "now_life" + /* 0x0032 */ s8 magicLevel; + /* 0x0033 */ s8 magic; + /* 0x0034 */ s16 rupees; + /* 0x0036 */ u16 swordHealth; + /* 0x0038 */ u16 naviTimer; + /* 0x003A */ u8 magicAcquired; + /* 0x003B */ char unk_3B[0x01]; + /* 0x003C */ u8 doubleMagic; + /* 0x003D */ u8 doubleDefense; + /* 0x003E */ u8 bgsFlag; + /* 0x003F */ u8 ocarinaGameReward; + /* 0x0040 */ ItemEquips childEquips; + /* 0x004A */ ItemEquips adultEquips; + /* 0x0054 */ u32 unk_54; // this may be incorrect, currently used for alignement + /* 0x0058 */ char unk_58[0x0E]; + /* 0x0066 */ s16 savedSceneNum; + /* 0x0068 */ ItemEquips equips; + /* 0x0074 */ Inventory inventory; + /* 0x00D4 */ SavedSceneFlags sceneFlags[124]; + /* 0x0E64 */ FaroresWindData fw; + /* 0x0E8C */ char unk_E8C[0x10]; + /* 0x0E9C */ s32 gsFlags[6]; + /* 0x0EB4 */ char unk_EB4[0x10]; + /* 0x0EC4 */ s32 horseRaceRecord; + /* 0x0EC8 */ char unk_EC8[0x0C]; + /* 0x0ED4 */ u16 eventChkInf[14]; // "event_chk_inf" + /* 0x0EF0 */ u16 itemGetInf[4]; // "item_get_inf" + /* 0x0EF8 */ u16 infTable[30]; // "inf_table" + /* 0x0F34 */ char unk_F34[0x04]; + /* 0x0F38 */ u32 worldMapAreaData; // "area_arrival" + /* 0x0F3C */ char unk_F3C[0x4]; + /* 0x0F40 */ u8 scarecrowCustomSongSet; + /* 0x0F41 */ u8 scarecrowCustomSong[0x360]; + /* 0x12A1 */ char unk_12A1[0x24]; + /* 0x12C5 */ u8 scarecrowSpawnSongSet; + /* 0x12C6 */ u8 scarecrowSpawnSong[0x80]; + /* 0x1346 */ char unk_1346[0x02]; + /* 0x1348 */ HorseData horseData; + /* 0x1352 */ u16 checksum; // "check_sum" + /* 0x1354 */ s32 fileNum; // "file_no" + /* 0x1358 */ char unk_1358[0x0004]; + /* 0x135C */ s32 gameMode; + /* 0x1360 */ s32 sceneSetupIndex; + /* 0x1364 */ s32 respawnFlag; // "restart_flag" + /* 0x1368 */ RespawnData respawn[3]; // "restart_data" + /* 0x13BC */ f32 entranceSpeed; + /* 0x13C0 */ u16 entranceSound; + /* 0x13C2 */ char unk_13C2[0x0001]; + /* 0x13C3 */ u8 unk_13C3; + /* 0x13C4 */ s16 dogParams; + /* 0x13C6 */ u8 textTriggerFlags; + /* 0x13C7 */ u8 showTitleCard; + /* 0x13C8 */ s16 nayrusLoveTimer; + /* 0x13CA */ char unk_13CA[0x0002]; + /* 0x13CC */ s16 rupeeAccumulator; + /* 0x13CE */ s16 timer1State; + /* 0x13D0 */ s16 timer1Value; + /* 0x13D2 */ s16 timer2State; + /* 0x13D4 */ s16 timer2Value; + /* 0x13D6 */ s16 timerX[2]; + /* 0x13DA */ s16 timerY[2]; + /* 0x13DE */ char unk_13DE[0x0002]; + /* 0x13E0 */ u8 seqIndex; + /* 0x13E1 */ u8 nightSeqIndex; + /* 0x13E2 */ u8 buttonStatus[5]; + /* 0x13E7 */ u8 unk_13E7; // alpha related + /* 0x13E8 */ u16 unk_13E8; // alpha type? + /* 0x13EA */ u16 unk_13EA; // also alpha type? + /* 0x13EC */ u16 unk_13EC; // alpha type counter? + /* 0x13EE */ u16 unk_13EE; // previous alpha type? + /* 0x13F0 */ s16 unk_13F0; // magic related + /* 0x13F2 */ s16 unk_13F2; // magic related + /* 0x13F4 */ s16 unk_13F4; // magic related + /* 0x13F6 */ s16 unk_13F6; // magic related + /* 0x13F8 */ s16 unk_13F8; // magic related + /* 0x13FA */ u16 eventInf[4]; // "event_inf" + /* 0x1402 */ u16 mapIndex; // intended for maps/minimaps but commonly used as the dungeon index + /* 0x1404 */ u16 minigameState; + /* 0x1406 */ u16 minigameScore; // "yabusame_total" + /* 0x1408 */ char unk_1408[0x0001]; + /* 0x1409 */ u8 language; + /* 0x140A */ u8 audioSetting; + /* 0x140B */ char unk_140B[0x0001]; + /* 0x140C */ u8 zTargetSetting; // 0: Switch; 1: Hold + /* 0x140E */ u16 unk_140E; // bgm related + /* 0x1410 */ u8 unk_1410; // transition related + /* 0x1411 */ char unk_1411[0x0001]; + /* 0x1412 */ u16 nextCutsceneIndex; + /* 0x1414 */ u8 cutsceneTrigger; + /* 0x1415 */ u8 chamberCutsceneNum; + /* 0x1416 */ u16 nextDayTime; // "next_zelda_time" + /* 0x1418 */ u8 fadeDuration; + /* 0x1419 */ u8 unk_1419; // transition related + /* 0x141A */ u16 environmentTime; + /* 0x141C */ u8 dogIsLost; + /* 0x141D */ u8 nextTransition; + /* 0x141E */ char unk_141E[0x0002]; + /* 0x1420 */ s16 worldMapArea; + /* 0x1422 */ s16 unk_1422; // day time related + /* 0x1424 */ s16 healthAccumulator; +} SaveContext; // size = 0x1428 + +typedef enum { + /* 0x00 */ RESPAWN_MODE_DOWN, /* Normal Void Outs */ + /* 0x01 */ RESPAWN_MODE_RETURN, /* Grotto Returnpoints */ + /* 0x02 */ RESPAWN_MODE_TOP /* Farore's Wind */ +} RespawnMode; + +typedef enum { + /* 0x00 */ BTN_ENABLED, + /* 0xFF */ BTN_DISABLED = 0xFF +} ButtonStatus; + +#endif |
