SaveFile cleanup part 3

This commit is contained in:
Henny022p 2023-08-02 22:19:34 +02:00
parent 1e02286d2c
commit ea30d2264b
10 changed files with 65 additions and 57 deletions

View File

@ -367,7 +367,7 @@ typedef struct {
/*0x1c*/ u16 charmTimer;
/*0x1e*/ u16 picolyteTimer;
/*0x20*/ u16 effectTimer;
/*0x22*/ u8 filler4[6];
/*0x22*/ u8 filler22[2];
} Stats;
#define SLOT_A 0

View File

@ -33,48 +33,57 @@ extern SaveResult HandleSave(u32 idx);
* The contents of this structure are read from and written to EEPROM.
*/
typedef struct {
/*0x000*/ u8 invalid; /**< File is invalid. */
/*0x001*/ u8 initialized; /**< File is initialized. */
/*0x002*/ u8 msg_speed; /**< Message speed. */
/*0x003*/ u8 brightness; /**< Brightness. */
/*0x004*/ u8 filler4[0x2]; /**< unused filler */
/*0x000*/ u8 invalid; /**< save file is invalid */
/*0x001*/ u8 initialized; /**< save file is initialized */
/*0x002*/ u8 msg_speed; /**< message speed setting */
/*0x003*/ u8 brightness; /**< brightness setting */
/*0x004*/ u8 filler4[2]; /**< unused filler */
/*0x006*/ u8 saw_staffroll; /**< beat the game and watched the credits */
/*0x007*/ u8 dws_barrel_state; /**< state of the big barrel in DWS, 0 or 2 */
/*0x008*/ u8 global_progress; /**< @see UpdateGlobalProgress */
/*0x009*/ u8 available_figurines; /**< figurines available to get */
/*0x00A*/ u8 fillerA[0x16]; /**< unused filler */
/*0x00A*/ u8 fillerA[22]; /**< unused filler */
/*0x020*/ u16 map_hints; /**< bitmask, used by subtask MapHint */
/*0x022*/ u8 filler22[0x1e]; /**< unused filler */
/*0x022*/ u8 filler22[30]; /**< unused filler */
/*0x040*/ u32 windcrests; /**< upper 8 bit Windcrest flags @see WindcrestID
* lower bits used for other things */
/*0x044*/ u8 filler44[0xC]; /**< unused filler */
/*0x044*/ u8 filler44[12]; /**< unused filler */
/*0x050*/ u32 enemies_killed; /**< number of enemies killed */
/*0x054*/ u8 filler54[0x8]; /**< unused filler */
/*0x054*/ u8 filler54[8]; /**< unused filler */
/*0x05C*/ u32 items_bought; /**< number of items bought in stockwells shop */
/*0x060*/ u32 areaVisitFlags[8]; /**< Area visit flags. */
/*0x080*/ char name[FILENAME_LENGTH]; /**< Save file name. */
/*0x086*/ u8 filler86[2]; /**< unused filler */
/*0x088*/ PlayerRoomStatus saved_status; /**< Player room status. */
/*0x0A8*/ Stats stats; /**< Player stats. */
/*0x0D0*/ u8 fillerD0[34];
/*0x0F2*/ u8 inventory[36];
/*0x116*/ u8 didAllFusions;
/*0x117*/ u8 fusedKinstoneCount;
/*0x118*/ u8 kinstoneTypes[0x13]; // 0x65-0x75 for each kinstone type present in kinstone bag
/*0x12B*/ u8 kinstoneAmounts[0x13]; // amount of each kinstone type above
/*0x13E*/ u8 filler13E[3];
/*0x141*/ u8 fuserProgress[128]; // indexed by fuser id, incremented after fusion
/*0x1C1*/ u8 fuserOffers[128]; // available kinstone fusion for each fuser
/*0x241*/ u8 fusedKinstones[13]; /**< Bitfield for fused kinstones. @see CheckKinstoneFused */
/*0x24E*/ u8 fusionUnmarked[13]; /**< Bitfield for disabled fusion map markers. @see CheckFusionMapMarkerDisabled */
/*0x25B*/ u8 filler25B;
/*0x25C*/ u8 flags[0x200]; /**< Flags. */
/*0x45C*/ u8 dungeonKeys[0x10]; // TODO Indexed by dungeon id, keys per dungeon
/*0x46C*/ u8 dungeonItems[0x10]; // TODO items in the dungeon. 4: compass, 2: big key, 1: small key
/*0x47C*/ u8 dungeonWarps[0x10]; // TODO indexed by dungeon id, EnableDungeonWarp, IsDungeonWarpActive
/*0x48C*/ u32 timers[7];
/*0x4A8*/ u32 demo_timer; /**< Demo timer. */
/*0x4AC*/ u8 filler4ac[0x8];
/*0x0CC*/ u8 fillerCC[2]; /**< unused filler */
/*0x0D0*/ u8 figurines[36]; /**< figurine bitset */
/*0x0F2*/ u8 inventory[36]; /**< 2 bit per item @see Item */
/*0x116*/ u8 didAllFusions; /**< completed all 100 kinstone fusions */
/*0x117*/ u8 fusedKinstoneCount; /**< number of kinstones fused */
/*0x118*/ u8 kinstoneTypes[19]; /**< item id for each kinstone type present in kinstone bag */
/*0x12B*/ u8 kinstoneAmounts[19]; /**< amount of each kinstone type above */
/*0x13E*/ u8 filler13E[3]; /**< unused filler */
/*0x141*/ u8 fuserProgress[128]; /**< indexed by fuser id, incremented after fusion */
/*0x1C1*/ u8 fuserOffers[128]; /**< available kinstone fusion for each fuser */
/*0x241*/ u8 fusedKinstones[13]; /**< bitfield for fused kinstones
* @see CheckKinstoneFused */
/*0x24E*/ u8 fusionUnmarked[13]; /**< bitfield for disabled fusion map markers
* @see CheckFusionMapMarkerDisabled */
/*0x25B*/ u8 filler25B; /**< unused filler */
/*0x25C*/ u8 flags[0x200]; /**< flags */
/*0x45C*/ u8 dungeonKeys[0x10]; /**< indexed by dungeon id, keys per dungeon */
/*0x46C*/ u8 dungeonItems[0x10]; /**< dungeon items 4: compass, 2: big key, 1: small key */
/*0x47C*/ u8 dungeonWarps[0x10]; /**< indexed by dungeon id */
/*0x48C*/ u32 darknut_timer; /**< timer for darknut fight before Vaati fight */
/*0x490*/ u32 drug_kill_count; /**< "timer" enemy kill count when turning in the last drug quest item */
/*0x494*/ u32 biggoron_timer; /**< timer for biggoron mirror shield */
/*0x498*/ u32 vaati_timer; /**< timer for vaati wrath fight */
/*0x49C*/ u32 timer4; /**< "timer4" unused */
/*0x4A0*/ u32 timer5; /**< "timer5" unused */
/*0x4A4*/ u32 timer6; /**< "timer6" unused */
/*0x4A8*/ u32 demo_timer; /**< timer for US demo version playtime limit */
/*0x4AC*/ u8 filler4ac[8]; /**< unused filler */
} SaveFile;
/**

View File

@ -998,8 +998,8 @@ void sub_0804235C(Entity* this) {
void VaatiWrathType0PreAction(Entity* this) {
int temp;
if ((gRoomTransition.field_0x38 & 2) == 0) {
if (gSave.timers[3] != 0) {
gSave.timers[3]--;
if (gSave.vaati_timer != 0) {
gSave.vaati_timer--;
} else {
temp = gPlayerState.framestate_last;
switch (temp) {

View File

@ -25,8 +25,8 @@
u32 StairsAreValid(void);
void ClearFlagArray(const u16*);
void DummyHandler(u32* a1);
void sub_08053434(u32* a1);
void sub_080534E4(u32* a1);
void DarknutTimerHandler(u32* a1);
void BiggoronTimerHandler(u32* a1);
void InitAllRoomResInfo(void);
void InitRoomResInfo(RoomResInfo* info, RoomHeader* hdr, u32 area, u32 room);
void sub_080532E4(void);
@ -839,24 +839,25 @@ void sub_080533CC(void) {
void UpdateTimerCallbacks(void) {
static void (*const sHandlers[])(u32*) = {
sub_08053434, DummyHandler, sub_080534E4, DummyHandler, DummyHandler, DummyHandler, DummyHandler, DummyHandler,
DarknutTimerHandler, DummyHandler, BiggoronTimerHandler, DummyHandler,
DummyHandler, DummyHandler, DummyHandler, DummyHandler,
};
u32* p;
u32 i;
p = gSave.timers;
p = &gSave.darknut_timer;
for (i = 0; i < 8; i++, p++) {
(sHandlers[i])(p);
}
}
void DummyHandler(u32* a1) {
void DummyHandler(u32* timer) {
}
void sub_08053434(u32* a1) {
if (gArea.locationIndex == 29 && *a1) {
if (!--*a1) {
void DarknutTimerHandler(u32* timer) {
if (gArea.locationIndex == 29 && *timer) {
if (!--*timer) {
ResetTimerFlags();
MenuFadeIn(5, 6);
}
@ -878,33 +879,31 @@ void ResetTimerFlags(void) {
0xFFFF,
};
gSave.timers[0] = 0;
gSave.darknut_timer = 0;
if (CheckLocalFlagByBank(FLAG_BANK_10, LV6_ZELDA_DISCURSE))
ClearGlobalFlag(ZELDA_CHASE);
ClearFlagArray(sClearFlags);
}
void StartDarkNutTimer(void) {
gSave.timers[0] = 10800;
gSave.darknut_timer = 10800;
}
void sub_080534AC(void) {
if (CheckLocalFlagByBank(FLAG_BANK_10, LV6_KANE_START)) {
ClearLocalFlagByBank(FLAG_BANK_10, LV6_KANE_START);
gSave.timers[0] = 0;
gSave.darknut_timer = 0;
SoundReq(SONG_STOP_BGM);
}
}
void sub_080534E4(u32* a1) {
if (gRoomControls.area != AREA_VEIL_FALLS_TOP) {
if (*a1)
--*a1;
}
void BiggoronTimerHandler(u32* timer) {
if (gRoomControls.area != AREA_VEIL_FALLS_TOP && *timer)
--*timer;
}
void InitBiggoronTimer(void) {
gSave.timers[2] = 36000;
gSave.biggoron_timer = 36000;
}
void ResetTmpFlags(void) {

View File

@ -54,7 +54,7 @@ void Vaati3StartManager_Type0_Init(Vaati3StartManager* this) {
*(u8*)&gRoomTransition.field_0x3a = 0x20;
*((u8*)&gRoomTransition.field_0x3a + 1) = 0x20;
#if !defined(EU) && !defined(JP)
gSave.timers[3] = 0x1194;
gSave.vaati_timer = 0x1194;
#endif
}

View File

@ -147,7 +147,7 @@ void FigurineMenu0_Type2(void) {
gFigurineMenu.unk20++;
switch (gFigurineMenu.unk20) {
case 0x40:
gFigurineMenu.duplicate = WriteBit(&gSave.stats.filler4[4], gFigurineMenu.figure_idx);
gFigurineMenu.duplicate = WriteBit(gSave.figurines, gFigurineMenu.figure_idx);
gMenu.column_idx = 1;
default:
bVar1 = gFigurineMenu.unk20 >> 2;
@ -285,7 +285,7 @@ u32 sub_080A4948(s32 param_1) {
uVar2 = 0;
iVar1 = !gSave.saw_staffroll ? 0x82 : 0x88;
if ((0 < param_1) || (iVar1 >= param_1)) {
if (ReadBit((u32*)&gSave.stats.filler4[4], param_1)) {
if (ReadBit((u32*)gSave.figurines, param_1)) {
uVar2 = 1;
}
}

View File

@ -429,7 +429,7 @@ void sub_0806D5D4(void) {
}
void sub_0806D600(Entity* this, ScriptExecutionContext* context) {
context->condition = gSave.timers[2] == 0;
context->condition = gSave.biggoron_timer == 0;
}
void sub_0806D620(void) {

View File

@ -706,13 +706,13 @@ void sub_08060318(void) {
}
void sub_08060340(void) {
gSave.timers[1] = gSave.enemies_killed;
gSave.drug_kill_count = gSave.enemies_killed;
}
u32 sub_08060354(void) {
s32 iVar2;
iVar2 = gSave.enemies_killed - gSave.timers[1];
iVar2 = gSave.enemies_killed - gSave.drug_kill_count;
if (CheckGlobalFlag(DRUG_1) == 0) {
if (4 < iVar2) {
return 0x8444;

View File

@ -182,7 +182,7 @@ void sub_0806387C(Entity* this) {
if (CheckLocalFlag(SHOP05_OPEN) == 0) {
r5 = 0;
for (r4 = 1; r4 <= 0x82; r4++) {
if (ReadBit(&gSave.stats.filler4[4], r4)) {
if (ReadBit(gSave.figurines, r4)) {
r5++;
}
}

View File

@ -626,7 +626,7 @@ void sub_08088328(FigurineDeviceEntity* this) {
if (uVar6 > 0x88) {
uVar6 = 1;
}
if (sub_08088160(this, uVar6) && ReadBit(&gSave.stats.filler4[4], uVar6) == 0) {
if (sub_08088160(this, uVar6) && ReadBit(gSave.figurines, uVar6) == 0) {
uVar2 = TRUE;
} else {
uVar6++;
@ -640,7 +640,7 @@ void sub_08088328(FigurineDeviceEntity* this) {
if (uVar6 > 0x88) {
uVar6 = 1;
}
if (sub_08088160(this, uVar6) && ReadBit(&gSave.stats.filler4[4], uVar6) != 0) {
if (sub_08088160(this, uVar6) && ReadBit(gSave.figurines, uVar6) != 0) {
uVar2 = FALSE;
} else {
uVar6++;