diff options
| author | fig02 <fig02srl@gmail.com> | 2020-10-11 21:52:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-11 21:52:50 -0400 |
| commit | ed719f3da03afcfd5b4ebb47506d63564073a066 (patch) | |
| tree | 65f79157fde359aa929beec9ce143144af70b076 /src | |
| parent | b010db7c19207f0e607d5ccaf0d1f2350dda3964 (diff) | |
Make Gamestates use thisx for entry point functions (#437)
* fix colliderinit typo
* fix initchain
* reloc
* thisx
* sample
* review
* forgot sample main
Diffstat (limited to 'src')
| -rw-r--r-- | src/code/z_play.c | 11 | ||||
| -rw-r--r-- | src/code/z_prenmi.c | 46 | ||||
| -rw-r--r-- | src/code/z_sample.c | 10 | ||||
| -rw-r--r-- | src/overlays/gamestates/ovl_opening/z_opening.c | 10 | ||||
| -rw-r--r-- | src/overlays/gamestates/ovl_select/z_select.c | 11 | ||||
| -rw-r--r-- | src/overlays/gamestates/ovl_title/z_title.c | 12 |
6 files changed, 60 insertions, 40 deletions
diff --git a/src/code/z_play.c b/src/code/z_play.c index 370005456..bbb77f7da 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -146,8 +146,8 @@ Gfx* func_800BC8A0(GlobalContext* globalCtx, Gfx* gfx) { globalCtx->lightCtx.unk_0A, 1000); } -void Gameplay_Destroy(GlobalContext* globalCtx) { - s32 pad; +void Gameplay_Destroy(GameState* thisx) { + GlobalContext* globalCtx = (GlobalContext*)thisx; Player* player = PLAYER; globalCtx->state.gfxCtx->callback = NULL; @@ -191,7 +191,8 @@ void Gameplay_Destroy(GlobalContext* globalCtx) { #ifdef NON_MATCHING // regalloc and stack usage differences // also missing some extra duplicated instructions -void Gameplay_Init(GlobalContext* globalCtx) { +void Gameplay_Init(GameState* thisx) { + GlobalContext* globalCtx = (GlobalContext*)thisx; GraphicsContext* gfxCtx; void* zAlloc; // 0x84 void* zAllocAligned; @@ -1329,7 +1330,9 @@ void Gameplay_Draw(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Gameplay_Draw.s") #endif -void Gameplay_Main(GlobalContext* globalCtx) { +void Gameplay_Main(GameState* thisx) { + GlobalContext* globalCtx = (GlobalContext*)thisx; + D_8012D1F8 = &globalCtx->state.input[0]; DebugDisplay_Init(); diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c index 678e393b0..8de5bd213 100644 --- a/src/code/z_prenmi.c +++ b/src/code/z_prenmi.c @@ -1,30 +1,30 @@ #include "global.h" #include "vt.h" -void func_80092320(PreNMIContext* prenmiCtx) { - prenmiCtx->state.running = false; - prenmiCtx->state.init = NULL; - prenmiCtx->state.size = 0; +void func_80092320(PreNMIContext* this) { + this->state.running = false; + this->state.init = NULL; + this->state.size = 0; } -void PreNMI_Update(PreNMIContext* prenmiCtx) { +void PreNMI_Update(PreNMIContext* this) { osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_move\n" VT_RST); // Strings existing only in rodata ("../z_prenmi.c"); ("(int)volume = %d\n"); - if (prenmiCtx->timer == 0) { + if (this->timer == 0) { ViConfig_UpdateVi(1); - func_80092320(prenmiCtx); + func_80092320(this); return; } - prenmiCtx->timer--; + this->timer--; } -void PreNMI_Draw(PreNMIContext* prenmiCtx) { - GraphicsContext* gfxCtx = prenmiCtx->state.gfxCtx; +void PreNMI_Draw(PreNMIContext* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_draw\n" VT_RST); @@ -34,26 +34,30 @@ void PreNMI_Draw(PreNMIContext* prenmiCtx) { func_80095248(gfxCtx, 0, 0, 0); func_800940B0(gfxCtx); gDPSetFillColor(oGfxCtx->polyOpa.p++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); - gDPFillRectangle(oGfxCtx->polyOpa.p++, 0, prenmiCtx->timer + 100, SCREEN_WIDTH - 1, prenmiCtx->timer + 100); + gDPFillRectangle(oGfxCtx->polyOpa.p++, 0, this->timer + 100, SCREEN_WIDTH - 1, this->timer + 100); CLOSE_DISPS(gfxCtx, "../z_prenmi.c", 112); } -void PreNMI_Main(PreNMIContext* prenmiCtx) { - PreNMI_Update(prenmiCtx); - PreNMI_Draw(prenmiCtx); +void PreNMI_Main(GameState* thisx) { + PreNMIContext* this = (PreNMIContext*)thisx; + + PreNMI_Update(this); + PreNMI_Draw(this); - prenmiCtx->state.unk_A0 = 1; + this->state.unk_A0 = 1; } -void PreNMI_Destroy(PreNMIContext* prenmiCtx) { +void PreNMI_Destroy(GameState* thisx) { } -void PreNMI_Init(PreNMIContext* prenmiCtx) { - prenmiCtx->state.main = PreNMI_Main; - prenmiCtx->state.destroy = PreNMI_Destroy; - prenmiCtx->timer = 30; - prenmiCtx->unk_A8 = 10; +void PreNMI_Init(GameState* thisx) { + PreNMIContext* this = (PreNMIContext*)thisx; + + this->state.main = PreNMI_Main; + this->state.destroy = PreNMI_Destroy; + this->timer = 30; + this->unk_A8 = 10; R_UPDATE_RATE = 1; } diff --git a/src/code/z_sample.c b/src/code/z_sample.c index d5383b373..7df885439 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -38,12 +38,14 @@ void Sample_Draw(SampleContext* this) { CLOSE_DISPS(gfxCtx, "../z_sample.c", 111); } -void Sample_Main(SampleContext* this) { +void Sample_Main(GameState* thisx) { + SampleContext* this = (SampleContext*)thisx; + Sample_Draw(this); Sample_HandleStateChange(this); } -void Sample_Destroy(SampleContext* this) { +void Sample_Destroy(GameState* thisx) { } void Sample_SetupView(SampleContext* this) { @@ -83,7 +85,9 @@ void Sample_LoadTitleStatic(SampleContext* this) { DmaMgr_SendRequest1(this->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164); } -void Sample_Init(SampleContext* this) { +void Sample_Init(GameState* thisx) { + SampleContext* this = (SampleContext*)thisx; + this->state.main = Sample_Main; this->state.destroy = Sample_Destroy; R_UPDATE_RATE = 1; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 9fe700d05..9c29d880b 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -19,16 +19,20 @@ void Opening_SetupTitleScreen(OpeningContext* this) { void func_80803C5C(OpeningContext* this) { } -void Opening_Main(OpeningContext* this) { +void Opening_Main(GameState* thisx) { + OpeningContext* this = (OpeningContext*)thisx; + func_80095248(this->state.gfxCtx, 0, 0, 0); Opening_SetupTitleScreen(this); func_80803C5C(this); } -void Opening_Destroy(OpeningContext* this) { +void Opening_Destroy(GameState* thisx) { } -void Opening_Init(OpeningContext* this) { +void Opening_Init(GameState* thisx) { + OpeningContext* this = (OpeningContext*)thisx; + R_UPDATE_RATE = 1; Matrix_Init(&this->state); View_Init(&this->view, this->state.gfxCtx); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index f858abf0f..2a7d03d4f 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -566,20 +566,23 @@ void Select_Draw(SelectContext* this) { CLOSE_DISPS(gfxCtx, "../z_select.c", 1037); } -void Select_Main(SelectContext* this) { +void Select_Main(GameState* thisx) { + SelectContext* this = (SelectContext*)thisx; + Select_UpdateMenu(this); Select_Draw(this); } -void Select_Destroy(SelectContext* this) { +void Select_Destroy(GameState* thisx) { osSyncPrintf("%c", 7); // "view_cleanup will hang, so it won't be called" osSyncPrintf("*** view_cleanupはハングアップするので、呼ばない ***\n"); } -void Select_Init(SelectContext* this) { +void Select_Init(GameState* thisx) { + SelectContext* this = (SelectContext*)thisx; u32 size; - s32 pad[2]; + s32 pad; this->state.main = Select_Main; this->state.destroy = Select_Destroy; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 72ce3e69a..0db9dbde5 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -124,8 +124,8 @@ void Title_Draw(TitleContext* this) { CLOSE_DISPS(this->state.gfxCtx, "../z_title.c", 483); } -void Title_Main(TitleContext* this) { - s32 pad; +void Title_Main(GameState* thisx) { + TitleContext* this = (TitleContext*)thisx; OPEN_DISPS(this->state.gfxCtx, "../z_title.c", 494); @@ -154,13 +154,15 @@ void Title_Main(TitleContext* this) { CLOSE_DISPS(this->state.gfxCtx, "../z_title.c", 541); } -void Title_Destroy(TitleContext* this) { +void Title_Destroy(GameState* thisx) { + TitleContext* this = (TitleContext*)thisx; + Sram_InitSram(this, &this->sramCtx); } -void Title_Init(TitleContext* this) { +void Title_Init(GameState* thisx) { u32 size = (u32)_nintendo_rogo_staticSegmentRomEnd - (u32)_nintendo_rogo_staticSegmentRomStart; - s32 pad; + TitleContext* this = (TitleContext*)thisx; this->staticSegment = GameState_Alloc(&this->state, size, "../z_title.c", 611); osSyncPrintf("z_title.c\n"); |
