Almost finish decompiling intro

This commit is contained in:
Diegoisawesome
2018-02-15 16:54:34 -06:00
parent 398e775d90
commit 34716558b1
20 changed files with 2422 additions and 6058 deletions

View File

@@ -516,7 +516,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
}
else
{
if (sub_81534D0(3) != TRUE)
if (Save_LoadGameData(3) != TRUE)
memset(gDecompressionBuffer, 0, 0x2000);
}
@@ -885,7 +885,7 @@ void CB2_DoHallOfFamePC(void)
static void Task_HofPC_CopySaveData(u8 taskId)
{
sub_81980F0(0, 0x1E, 0, 0xC, 0x226);
if (sub_81534D0(3) != 1)
if (Save_LoadGameData(3) != 1)
{
gTasks[taskId].func = Task_HofPC_PrintDataIsCorrupted;
}

2281
src/intro.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -166,7 +166,7 @@ static void InitMainCallbacks(void)
gUnknown_0203CF5C = NULL;
gMain.vblankCounter2 = 0;
gMain.callback1 = NULL;
SetMainCallback2(c2_copyright_1);
SetMainCallback2(CB2_InitCopyrightScreenAfterBootup);
gSaveBlock2Ptr = &gSaveblock2;
gPokemonStoragePtr = &gPokemonStorage;
}

View File

@@ -241,7 +241,7 @@ static void CB2_MysteryEventMenu(void)
u16 unkVal = RunMysteryEventScript(gDecompressionBuffer);
CpuFill32(0, gDecompressionBuffer, 0x7D4);
if (!GetEventLoadMessage(gStringVar4, unkVal))
TrySavingData(NORMAL_SAVE);
TrySavingData(SAVE_NORMAL);
gMain.state++;
}
break;

View File

@@ -20,8 +20,8 @@ void sub_81700F8(void)
gMain.inBattle = FALSE;
SetSaveBlocksPointers(sub_815355C());
sub_808447C();
ResetSaveCounters();
sub_81534D0(0);
Save_ResetSaveCounters();
Save_LoadGameData(0);
if (gSaveFileStatus == 0 || gSaveFileStatus == 2)
Sav2_ClearSetDefault();
SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound);

View File

@@ -3,6 +3,7 @@
#include "save.h"
#include "constants/game_stat.h"
#include "task.h"
#include "decompress.h"
// for the chunk declarations
extern struct SaveBlock2 gSaveblock2;
@@ -96,7 +97,7 @@ void ClearSaveData(void)
}
}
void ResetSaveCounters(void)
void Save_ResetSaveCounters(void)
{
gSaveCounter = 0;
gLastWrittenSector = 0;
@@ -670,25 +671,25 @@ u8 HandleSavingData(u8 saveType)
UpdateSaveAddresses();
switch (saveType)
{
case HOF_DELETE_SAVE: // deletes HOF before overwriting HOF completely. unused
case SAVE_HALL_OF_FAME_ERASE_BEFORE: // deletes HOF before overwriting HOF completely. unused
for (i = 0xE * 2 + 0; i < 32; i++)
EraseFlashSector(i);
case HOF_SAVE: // hall of fame.
case SAVE_HALL_OF_FAME: // hall of fame.
if (GetGameStat(GAME_STAT_ENTERED_HOF) < 999)
IncrementGameStat(GAME_STAT_ENTERED_HOF);
SaveSerializedGame();
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
tempAddr = (u8 *)0x201C000; // FIXME: make this a label.
tempAddr = gDecompressionBuffer;
HandleWriteSectorNBytes(0x1C, tempAddr, 0xF80);
HandleWriteSectorNBytes(0x1D, tempAddr + 0xF80, 0xF80);
break;
case NORMAL_SAVE: // normal save. also called by overwriting your own save.
case SAVE_NORMAL: // normal save. also called by overwriting your own save.
default:
SaveSerializedGame();
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
break;
case LINK_SAVE: // _081532C4
case LINK2_SAVE:
case SAVE_LINK: // _081532C4
case SAVE_LINK2:
SaveSerializedGame();
for(i = 0; i < 5; i++)
ClearSaveData_2(i, gRamSaveSectionLocations);
@@ -702,7 +703,7 @@ u8 HandleSavingData(u8 saveType)
save_write_to_flash(0, gRamSaveSectionLocations);
break;
*/
case DIFFERENT_FILE_SAVE:
case SAVE_OVERWRITE_DIFFERENT_FILE:
for (i = (0xE * 2 + 0); i < 32; i++)
EraseFlashSector(i); // erase HOF.
SaveSerializedGame();
@@ -799,7 +800,7 @@ bool8 sub_8153474(void)
return retVal;
}
u8 sub_81534D0(u8 a1)
u8 Save_LoadGameData(u8 a1)
{
u8 result;