mirror of
https://github.com/pret/pokeplatinum.git
synced 2024-11-23 05:49:44 +00:00
Document GameStart overlay routines
This commit is contained in:
parent
e855dada7e
commit
e333256bac
@ -22,6 +22,8 @@ enum HeapId {
|
||||
|
||||
HEAP_ID_CHOOSE_STARTER_APP = 47,
|
||||
|
||||
HEAP_ID_GAME_START = 77,
|
||||
|
||||
HEAP_ID_LIBRARY_TV = 120,
|
||||
};
|
||||
|
||||
@ -34,6 +36,7 @@ enum HeapSize {
|
||||
HEAP_SIZE_CHOOSE_STARTER_APP = 0x40000,
|
||||
HEAP_SIZE_LIBRARY_TV = 0x40000,
|
||||
HEAP_SIZE_DISTORTION_WORLD_WARP = 0x50000,
|
||||
HEAP_SIZE_GAME_START = 0x20000,
|
||||
};
|
||||
|
||||
#endif // POKEPLATINUM_CONSTANTS_HEAP_H
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include "overlay_manager.h"
|
||||
|
||||
extern const OverlayManagerTemplate Unk_ov57_021D0F70;
|
||||
extern const OverlayManagerTemplate Unk_ov57_021D0F80;
|
||||
extern const OverlayManagerTemplate Unk_ov57_021D0F90;
|
||||
extern const OverlayManagerTemplate gGameStartLoadSaveOverlayTemplate;
|
||||
extern const OverlayManagerTemplate gGameStartNewSaveOverlayTemplate;
|
||||
extern const OverlayManagerTemplate gGameStartRowanIntroOverlayTemplate;
|
||||
|
||||
#endif // POKEPLATINUM_GAME_START_H
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include "overlay_manager.h"
|
||||
#include "savedata.h"
|
||||
|
||||
enum OSResetParameter {
|
||||
RESET_CLEAN = 0,
|
||||
RESET_ERROR,
|
||||
};
|
||||
|
||||
typedef struct ApplicationArgs {
|
||||
int unk_00;
|
||||
BOOL error;
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include "play_time.h"
|
||||
|
||||
void sub_02017428(void);
|
||||
void sub_02017434(PlayTime *playTime);
|
||||
void PlayTime_FlagNotStarted(void);
|
||||
void PlayTime_Start(PlayTime *playTime);
|
||||
void sub_02017458(void);
|
||||
|
||||
#endif // POKEPLATINUM_UNK_02017428_H
|
||||
|
184
src/game_start.c
184
src/game_start.c
@ -1,9 +1,7 @@
|
||||
#include "game_start.h"
|
||||
|
||||
#include <nitro.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "constants/game_options.h"
|
||||
#include "constants/heap.h"
|
||||
|
||||
#include "berry_patches.h"
|
||||
#include "game_options.h"
|
||||
@ -30,158 +28,152 @@
|
||||
#include "constdata/const_020EA11C.h"
|
||||
#include "constdata/const_020F6824.h"
|
||||
|
||||
static int ov57_021D0D80(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0D98(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0DAC(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0DC8(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0DE0(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0E00(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0E1C(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0E34(OverlayManager *param0, int *param1);
|
||||
static int ov57_021D0E90(OverlayManager *param0, int *param1);
|
||||
static void ov57_021D0EAC(int param0, SaveData *param1, BOOL param2);
|
||||
static int GameStartRowanIntro_Init(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartRowanIntro_Main(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartRowanIntro_Exit(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartNewSave_Init(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartNewSave_Main(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartNewSave_Exit(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartLoadSave_Init(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartLoadSave_Main(OverlayManager *ovyManager, int *state);
|
||||
static int GameStartLoadSave_Exit(OverlayManager *ovyManager, int *state);
|
||||
|
||||
static void InitializeNewSave(enum HeapId heapID, SaveData *saveData, BOOL setTrainerID);
|
||||
static void TryLoadingSave(int unused, SaveData *saveData);
|
||||
static void StartNewSave(int unused, SaveData *saveData);
|
||||
|
||||
const OverlayManagerTemplate Unk_ov57_021D0F90 = {
|
||||
ov57_021D0D80,
|
||||
ov57_021D0D98,
|
||||
ov57_021D0DAC,
|
||||
0xffffffff
|
||||
const OverlayManagerTemplate gGameStartRowanIntroOverlayTemplate = {
|
||||
.init = GameStartRowanIntro_Init,
|
||||
.main = GameStartRowanIntro_Main,
|
||||
.exit = GameStartRowanIntro_Exit,
|
||||
.overlayID = FS_OVERLAY_ID_NONE,
|
||||
};
|
||||
|
||||
const OverlayManagerTemplate Unk_ov57_021D0F80 = {
|
||||
ov57_021D0DC8,
|
||||
ov57_021D0DE0,
|
||||
ov57_021D0E00,
|
||||
0xffffffff
|
||||
const OverlayManagerTemplate gGameStartNewSaveOverlayTemplate = {
|
||||
.init = GameStartNewSave_Init,
|
||||
.main = GameStartNewSave_Main,
|
||||
.exit = GameStartNewSave_Exit,
|
||||
.overlayID = FS_OVERLAY_ID_NONE,
|
||||
};
|
||||
|
||||
const OverlayManagerTemplate Unk_ov57_021D0F70 = {
|
||||
ov57_021D0E1C,
|
||||
ov57_021D0E34,
|
||||
ov57_021D0E90,
|
||||
0xffffffff
|
||||
const OverlayManagerTemplate gGameStartLoadSaveOverlayTemplate = {
|
||||
.init = GameStartLoadSave_Init,
|
||||
.main = GameStartLoadSave_Main,
|
||||
.exit = GameStartLoadSave_Exit,
|
||||
.overlayID = FS_OVERLAY_ID_NONE,
|
||||
};
|
||||
|
||||
static int ov57_021D0D80(OverlayManager *param0, int *param1)
|
||||
static BOOL GameStartRowanIntro_Init(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
Heap_Create(3, 77, 131072);
|
||||
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_GAME_START, HEAP_SIZE_GAME_START);
|
||||
InitRNG();
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0D98(OverlayManager *param0, int *param1)
|
||||
static BOOL GameStartRowanIntro_Main(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
SaveData *v0 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData;
|
||||
|
||||
StartNewSave(77, v0);
|
||||
return 1;
|
||||
SaveData *saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData;
|
||||
StartNewSave(HEAP_ID_GAME_START, saveData);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0DAC(OverlayManager *param0, int *param1)
|
||||
static int GameStartRowanIntro_Exit(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
Heap_Destroy(77);
|
||||
EnqueueApplication(0xffffffff, &Unk_020F6824);
|
||||
|
||||
return 1;
|
||||
Heap_Destroy(HEAP_ID_GAME_START);
|
||||
EnqueueApplication(FS_OVERLAY_ID_NONE, &Unk_020F6824);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0DC8(OverlayManager *param0, int *param1)
|
||||
static int GameStartNewSave_Init(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
Heap_Create(3, 77, 131072);
|
||||
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_GAME_START, HEAP_SIZE_GAME_START);
|
||||
InitRNG();
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0DE0(OverlayManager *param0, int *param1)
|
||||
static int GameStartNewSave_Main(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
SaveData *v0 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData;
|
||||
|
||||
ov57_021D0EAC(77, v0, 1);
|
||||
sub_02017434(SaveData_GetPlayTime(v0));
|
||||
|
||||
return 1;
|
||||
SaveData *saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData;
|
||||
InitializeNewSave(HEAP_ID_GAME_START, saveData, 1);
|
||||
PlayTime_Start(SaveData_GetPlayTime(saveData));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0E00(OverlayManager *param0, int *param1)
|
||||
static int GameStartNewSave_Exit(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
Heap_Destroy(77);
|
||||
EnqueueApplication(0xffffffff, &gFieldSystemNewGameTemplate);
|
||||
return 1;
|
||||
Heap_Destroy(HEAP_ID_GAME_START);
|
||||
EnqueueApplication(FS_OVERLAY_ID_NONE, &gFieldSystemNewGameTemplate);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0E1C(OverlayManager *param0, int *param1)
|
||||
static int GameStartLoadSave_Init(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
Heap_Create(3, 77, 131072);
|
||||
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_GAME_START, HEAP_SIZE_GAME_START);
|
||||
InitRNG();
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0E34(OverlayManager *param0, int *param1)
|
||||
static int GameStartLoadSave_Main(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
SaveData *v0 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData;
|
||||
SystemData *v1 = SaveData_GetSystemData(v0);
|
||||
SaveData *saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData;
|
||||
SystemData *systemData = SaveData_GetSystemData(saveData);
|
||||
|
||||
TryLoadingSave(77, v0);
|
||||
Options_SetSystemButtonMode(v0, OPTIONS_BUTTON_MODE_NORMAL);
|
||||
TryLoadingSave(HEAP_ID_GAME_START, saveData);
|
||||
Options_SetSystemButtonMode(saveData, OPTIONS_BUTTON_MODE_NORMAL);
|
||||
|
||||
if (!SystemData_MatchesCurrentSystem(v1) || !SystemData_MatchesCurrentRTCOffset(v1)) {
|
||||
GameTime_StartPenalty(SaveData_GetGameTime(v0));
|
||||
SystemData_Init(v1);
|
||||
Party_SetShayminLandForm(Party_GetFromSavedata(v0));
|
||||
if (!SystemData_MatchesCurrentSystem(systemData) || !SystemData_MatchesCurrentRTCOffset(systemData)) {
|
||||
GameTime_StartPenalty(SaveData_GetGameTime(saveData));
|
||||
SystemData_Init(systemData);
|
||||
Party_SetShayminLandForm(Party_GetFromSavedata(saveData));
|
||||
}
|
||||
|
||||
sub_02017434(SaveData_GetPlayTime(v0));
|
||||
return 1;
|
||||
PlayTime_Start(SaveData_GetPlayTime(saveData));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int ov57_021D0E90(OverlayManager *param0, int *param1)
|
||||
static int GameStartLoadSave_Exit(OverlayManager *ovyManager, int *state)
|
||||
{
|
||||
Heap_Destroy(77);
|
||||
EnqueueApplication(0xffffffff, &gFieldSystemContinueTemplate);
|
||||
return 1;
|
||||
Heap_Destroy(HEAP_ID_GAME_START);
|
||||
EnqueueApplication(FS_OVERLAY_ID_NONE, &gFieldSystemContinueTemplate);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#include "data/berry_init.h"
|
||||
|
||||
static void ov57_021D0EAC(int param0, SaveData *param1, BOOL param2)
|
||||
static void InitializeNewSave(enum HeapId heapID, SaveData *saveData, BOOL setTrainerID)
|
||||
{
|
||||
u32 v0;
|
||||
BerryPatch *v1;
|
||||
TrainerInfo *v2;
|
||||
GameTime *v3;
|
||||
RecordMixedRNG *v4;
|
||||
u32 rnd;
|
||||
BerryPatch *berryPatches;
|
||||
TrainerInfo *trainerInfo;
|
||||
GameTime *gameTime;
|
||||
RecordMixedRNG *rngCollection;
|
||||
|
||||
SystemData_Init(SaveData_GetSystemData(param1));
|
||||
SystemData_Init(SaveData_GetSystemData(saveData));
|
||||
|
||||
v3 = SaveData_GetGameTime(param1);
|
||||
GameTime_Clear(v3);
|
||||
gameTime = SaveData_GetGameTime(saveData);
|
||||
GameTime_Clear(gameTime);
|
||||
|
||||
v4 = SaveData_GetRecordMixedRNG(param1);
|
||||
RecordMixedRNG_SetEntrySeed(v4, 1, MTRNG_Next());
|
||||
sub_0206C008(param1);
|
||||
rngCollection = SaveData_GetRecordMixedRNG(saveData);
|
||||
RecordMixedRNG_SetEntrySeed(rngCollection, RECORD_MIXED_RNG_PLAYER_OVERRIDE, MTRNG_Next());
|
||||
sub_0206C008(saveData);
|
||||
|
||||
v2 = SaveData_GetTrainerInfo(param1);
|
||||
v0 = MTRNG_Next();
|
||||
trainerInfo = SaveData_GetTrainerInfo(saveData);
|
||||
rnd = MTRNG_Next();
|
||||
|
||||
if (param2) {
|
||||
TrainerInfo_SetID(v2, v0);
|
||||
if (setTrainerID) {
|
||||
TrainerInfo_SetID(trainerInfo, rnd);
|
||||
}
|
||||
|
||||
TrainerInfo_SetAppearance(v2, sub_0205C9BC(v0, TrainerInfo_Gender(v2), 0));
|
||||
TrainerInfo_SetAppearance(trainerInfo, sub_0205C9BC(rnd, TrainerInfo_Gender(trainerInfo), 0));
|
||||
|
||||
v1 = MiscSaveBlock_GetBerryPatches(param1);
|
||||
BerryPatches_Init(v1, param0, sBerryInitTable, NELEMS(sBerryInitTable) / 2);
|
||||
berryPatches = MiscSaveBlock_GetBerryPatches(saveData);
|
||||
BerryPatches_Init(berryPatches, heapID, sBerryInitTable, NELEMS(sBerryInitTable) / 2);
|
||||
}
|
||||
|
||||
static void TryLoadingSave(int unused, SaveData *saveData)
|
||||
{
|
||||
if (!SaveData_Load(saveData)) {
|
||||
OS_ResetSystem(0);
|
||||
OS_ResetSystem(RESET_CLEAN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,11 +42,6 @@
|
||||
FS_EXTERN_OVERLAY(game_start);
|
||||
FS_EXTERN_OVERLAY(overlay77);
|
||||
|
||||
enum OSResetParameter {
|
||||
RESET_CLEAN = 0,
|
||||
RESET_ERROR,
|
||||
};
|
||||
|
||||
typedef struct Application {
|
||||
FSOverlayID currOverlayID;
|
||||
OverlayManager *currOverlay;
|
||||
@ -110,7 +105,7 @@ void NitroMain(void)
|
||||
sub_0200F344(0, 0x0);
|
||||
sub_0200F344(1, 0x0);
|
||||
sApplication.args.error = TRUE;
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &Unk_ov57_021D0F70);
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartLoadSaveOverlayTemplate);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -123,7 +118,7 @@ void NitroMain(void)
|
||||
|
||||
InitRNG();
|
||||
sub_0200AB84();
|
||||
sub_02017428();
|
||||
PlayTime_FlagNotStarted();
|
||||
|
||||
gIgnoreCartridgeForWake = FALSE;
|
||||
|
||||
|
@ -248,7 +248,7 @@ int ov73_021D0F7C(OverlayManager *param0, int *param1)
|
||||
sub_0208716C(v0->unk_74);
|
||||
OverlayManager_FreeData(param0);
|
||||
Heap_Destroy(v1);
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &Unk_ov57_021D0F80);
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartNewSaveOverlayTemplate);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1163,10 +1163,10 @@ static void ov97_0222C094(UnkStruct_0222AE60 *param0)
|
||||
{
|
||||
switch (param0->unk_58) {
|
||||
case 1:
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &Unk_ov57_021D0F70);
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartLoadSaveOverlayTemplate);
|
||||
break;
|
||||
case 2:
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &Unk_ov57_021D0F90);
|
||||
EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartRowanIntroOverlayTemplate);
|
||||
break;
|
||||
case 3:
|
||||
EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D71C);
|
||||
|
@ -6,20 +6,20 @@
|
||||
#include "play_time.h"
|
||||
#include "unk_02022844.h"
|
||||
|
||||
static BOOL Unk_021BF658 = 0;
|
||||
static BOOL sStarted = FALSE;
|
||||
static u64 Unk_021BF668 = 0;
|
||||
static u64 Unk_021BF660 = 0;
|
||||
static u64 Unk_021BF670 = 0;
|
||||
static PlayTime *sPlayTime = NULL;
|
||||
|
||||
void sub_02017428(void)
|
||||
void PlayTime_FlagNotStarted()
|
||||
{
|
||||
Unk_021BF658 = 0;
|
||||
sStarted = FALSE;
|
||||
}
|
||||
|
||||
void sub_02017434(PlayTime *playTime)
|
||||
void PlayTime_Start(PlayTime *playTime)
|
||||
{
|
||||
Unk_021BF658 = 1;
|
||||
sStarted = TRUE;
|
||||
Unk_021BF668 = 0;
|
||||
Unk_021BF660 = 0;
|
||||
sPlayTime = playTime;
|
||||
@ -28,7 +28,7 @@ void sub_02017434(PlayTime *playTime)
|
||||
|
||||
void sub_02017458(void)
|
||||
{
|
||||
if (Unk_021BF658) {
|
||||
if (sStarted) {
|
||||
u64 v0 = sub_0202295C(sub_0202293C() - Unk_021BF670);
|
||||
|
||||
if (v0 > Unk_021BF660) {
|
||||
|
Loading…
Reference in New Issue
Block a user