From ddc643f708543fafc73c55eddddf1f34c401cb02 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Wed, 29 Sep 2021 02:17:39 +0100 Subject: [PATCH] `ovl_opening` OK (#300) * ovl_opening OK * un-format z64save.h * Actually change the other uses of nextCutsceneIndex * format * Review * engineer's review * Get it to match again --- include/functions.h | 2 +- include/variables.h | 2 +- spec | 3 +- .../gamestates/ovl_opening/z_opening.c | 60 ++++++++++++++++--- .../gamestates/ovl_opening/z_opening.h | 4 +- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/include/functions.h b/include/functions.h index b5ab76f9a0..cabbad7d5d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2820,7 +2820,7 @@ void Sram_IncrementDay(void); u32 Sram_CalcChecksum(u8* data, u32 length); // void func_80144628(void); // void Sram_GenerateRandomSaveFields(void); -// void func_80144890(void); +void func_80144890(void); // void func_80144968(void); // void func_80144A94(void); // void func_80144E78(void); diff --git a/include/variables.h b/include/variables.h index ba99e95eb3..6b37d9d5e2 100644 --- a/include/variables.h +++ b/include/variables.h @@ -910,7 +910,7 @@ extern UNK_TYPE1 D_801BA550; // extern UNK_TYPE1 D_801BB100; // extern UNK_TYPE2 D_801BB124; // extern UNK_TYPE2 D_801BB128; -// extern UNK_TYPE1 D_801BB12C; +extern u8 D_801BB12C; // extern UNK_TYPE1 D_801BB130; extern cutscene_update_func sCsStateHandlers1[5]; extern cutscene_update_func sCsStateHandlers2[5]; diff --git a/spec b/spec index 222c54f222..dfa4f46360 100644 --- a/spec +++ b/spec @@ -712,8 +712,7 @@ beginseg name "ovl_opening" compress include "build/src/overlays/gamestates/ovl_opening/z_opening.o" - include "build/data/ovl_opening/ovl_opening.data.o" - include "build/data/ovl_opening/ovl_opening.reloc.o" + include "build/src/overlays/gamestates/ovl_opening/ovl_opening_reloc.o" endseg beginseg diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index e086158fc9..b19955071a 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -1,18 +1,64 @@ /* * File: z_opening.c * Overlay: ovl_opening - * Description: + * Description: Initializes the game into the title screen */ #include "z_opening.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_SetupForTitleCutscene.s") +void Opening_SetupForTitleCutscene(OpeningContext* this) { + static s32 openingEntrances[] = { 0x1C00, 0x1C10 }; + static s32 openingCutscenes[] = { 0xFFFA, 0xFFFA }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/func_80803EA0.s") + gSaveContext.eventInf[1] &= (u8)~0x80; + gSaveContext.gameMode = 1; -void Opening_Main(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_Main.s") + func_80144890(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_Destroy.s") + gSaveContext.entranceIndex = openingEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.cutscene = openingCutscenes[D_801BB12C]; + gSaveContext.sceneSetupIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_Init.s") + gSaveContext.time = CLOCK_TIME(8, 0); + gSaveContext.day = 1; + + { + GameState* thisx = &this->gameState; + thisx->running = false; + } + SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); + gSaveContext.playerForm = PLAYER_FORM_HUMAN; +} + +void func_80803EA0(OpeningContext* this) { + SREG(33) |= 1; +} + +void Opening_Main(GameState* thisx) { + OpeningContext* this = (OpeningContext*)thisx; + + func_8012CF0C(this->gameState.gfxCtx, 0, 1, 0, 0, 0); + Opening_SetupForTitleCutscene(this); + func_80803EA0(this); +} + +void Opening_Destroy(GameState* thisx) { + ShrinkWindow_Fini(); +} + +void Opening_Init(GameState* thisx) { + OpeningContext* this = (OpeningContext*)thisx; + + Game_SetFramerateDivisor(&this->gameState, 1); + SysMatrix_StateAlloc(&this->gameState); + ShrinkWindow_Init(); + View_Init(&this->view, this->gameState.gfxCtx); + this->gameState.main = Opening_Main; + this->gameState.destroy = Opening_Destroy; + + gSaveContext.respawnFlag = 0; + gSaveContext.respawn[4].entranceIndex = 0xFF; + gSaveContext.respawn[5].entranceIndex = 0xFF; + gSaveContext.respawn[6].entranceIndex = 0xFF; + gSaveContext.respawn[7].entranceIndex = 0xFF; +} diff --git a/src/overlays/gamestates/ovl_opening/z_opening.h b/src/overlays/gamestates/ovl_opening/z_opening.h index 81a12f6309..809767fe48 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.h +++ b/src/overlays/gamestates/ovl_opening/z_opening.h @@ -7,8 +7,8 @@ void Opening_Init(GameState* thisx); void Opening_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState common; - /* 0x0A4 */ UNK_TYPE1 padA4[0x4]; + /* 0x000 */ GameState gameState; + /* 0x0A4 */ UNK_TYPE1 unk_A4[0x4]; /* 0x0A8 */ View view; } OpeningContext; // size = 0x210