mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-28 15:56:51 +00:00
Make Gamestates use thisx for entry point functions (#437)
* fix colliderinit typo * fix initchain * reloc * thisx * sample * review * forgot sample main
This commit is contained in:
parent
b010db7c19
commit
ed719f3da0
7 changed files with 74 additions and 54 deletions
|
@ -1210,7 +1210,7 @@ void Player_DrawGetItem(GlobalContext* globalCtx, Player* player);
|
||||||
u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime);
|
u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime);
|
||||||
void func_8009214C(GlobalContext* globalCtx, u8* segment, struct_80091A24_arg3* arg2, Vec3f* pos, Vec3s* rot, f32 scale,
|
void func_8009214C(GlobalContext* globalCtx, u8* segment, struct_80091A24_arg3* arg2, Vec3f* pos, Vec3s* rot, f32 scale,
|
||||||
s32 sword, s32 tunic, s32 shield, s32 boots);
|
s32 sword, s32 tunic, s32 shield, s32 boots);
|
||||||
void PreNMI_Init(PreNMIContext* prenmiCtx);
|
void PreNMI_Init(GameState* thisx);
|
||||||
Vec3f* Quake_AddVec(Vec3f* dst, Vec3f* arg1, VecSph* arg2);
|
Vec3f* Quake_AddVec(Vec3f* dst, Vec3f* arg1, VecSph* arg2);
|
||||||
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x);
|
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x);
|
||||||
s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake);
|
s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake);
|
||||||
|
@ -1282,8 +1282,8 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum);
|
||||||
s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx);
|
s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx);
|
||||||
void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags);
|
void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags);
|
||||||
void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx);
|
void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx);
|
||||||
void Sample_Destroy(SampleContext* this);
|
void Sample_Destroy(GameState* thisx);
|
||||||
void Sample_Init(SampleContext* this);
|
void Sample_Init(GameState* thisx);
|
||||||
void Inventory_ChangeEquipment(s16 equipment, u16 value);
|
void Inventory_ChangeEquipment(s16 equipment, u16 value);
|
||||||
u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment);
|
u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment);
|
||||||
void Inventory_ChangeUpgrade(s16 upgrade, s16 value);
|
void Inventory_ChangeUpgrade(s16 upgrade, s16 value);
|
||||||
|
@ -1583,9 +1583,9 @@ s32 func_800BC56C(GlobalContext* globalCtx, s16 arg1);
|
||||||
void func_800BC590(GlobalContext* globalCtx);
|
void func_800BC590(GlobalContext* globalCtx);
|
||||||
void func_800BC5E0(GlobalContext* globalCtx, s32 arg1);
|
void func_800BC5E0(GlobalContext* globalCtx, s32 arg1);
|
||||||
Gfx* func_800BC8A0(GlobalContext* globalCtx, Gfx* gfx);
|
Gfx* func_800BC8A0(GlobalContext* globalCtx, Gfx* gfx);
|
||||||
void Gameplay_Destroy(GlobalContext* globalCtx);
|
void Gameplay_Destroy(GameState* thisx);
|
||||||
void Gameplay_Init(GlobalContext* globalCtx);
|
void Gameplay_Init(GameState* thisx);
|
||||||
void Gameplay_Main(GlobalContext* globalCtx);
|
void Gameplay_Main(GameState* thisx);
|
||||||
s32 Gameplay_InCsMode(GlobalContext* globalCtx);
|
s32 Gameplay_InCsMode(GlobalContext* globalCtx);
|
||||||
f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec);
|
f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec);
|
||||||
void* Gameplay_LoadFile(GlobalContext* globalCtx, RomFile* file);
|
void* Gameplay_LoadFile(GlobalContext* globalCtx, RomFile* file);
|
||||||
|
@ -2626,14 +2626,14 @@ void func_801109B0(GlobalContext* globalCtx);
|
||||||
void func_80110F68(GlobalContext* globalCtx);
|
void func_80110F68(GlobalContext* globalCtx);
|
||||||
void func_80112098(GlobalContext* globalCtx);
|
void func_80112098(GlobalContext* globalCtx);
|
||||||
|
|
||||||
void Title_Init(TitleContext*);
|
void Title_Init(GameState* thisx);
|
||||||
void Title_Destroy(TitleContext* this);
|
void Title_Destroy(GameState* thisx);
|
||||||
void Select_Init(SelectContext*);
|
void Select_Init(GameState* thisx);
|
||||||
void Select_Destroy(SelectContext*);
|
void Select_Destroy(GameState* thisx);
|
||||||
void Opening_Init(OpeningContext* this);
|
void Opening_Init(GameState* thisx);
|
||||||
void Opening_Destroy(OpeningContext* this);
|
void Opening_Destroy(GameState* thisx);
|
||||||
void func_80811A20(GameState*); // FileChoose_Init
|
void func_80811A20(GameState* thisx); // FileChoose_Init
|
||||||
void func_80811A18(GameState*); // FileChoose_Destroy
|
void func_80811A18(GameState* thisx); // FileChoose_Destroy
|
||||||
|
|
||||||
void func_80823994(PauseContext*, f32, f32, f32);
|
void func_80823994(PauseContext*, f32, f32, f32);
|
||||||
void func_800949A8(GraphicsContext*);
|
void func_800949A8(GraphicsContext*);
|
||||||
|
|
|
@ -146,8 +146,8 @@ Gfx* func_800BC8A0(GlobalContext* globalCtx, Gfx* gfx) {
|
||||||
globalCtx->lightCtx.unk_0A, 1000);
|
globalCtx->lightCtx.unk_0A, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gameplay_Destroy(GlobalContext* globalCtx) {
|
void Gameplay_Destroy(GameState* thisx) {
|
||||||
s32 pad;
|
GlobalContext* globalCtx = (GlobalContext*)thisx;
|
||||||
Player* player = PLAYER;
|
Player* player = PLAYER;
|
||||||
|
|
||||||
globalCtx->state.gfxCtx->callback = NULL;
|
globalCtx->state.gfxCtx->callback = NULL;
|
||||||
|
@ -191,7 +191,8 @@ void Gameplay_Destroy(GlobalContext* globalCtx) {
|
||||||
#ifdef NON_MATCHING
|
#ifdef NON_MATCHING
|
||||||
// regalloc and stack usage differences
|
// regalloc and stack usage differences
|
||||||
// also missing some extra duplicated instructions
|
// also missing some extra duplicated instructions
|
||||||
void Gameplay_Init(GlobalContext* globalCtx) {
|
void Gameplay_Init(GameState* thisx) {
|
||||||
|
GlobalContext* globalCtx = (GlobalContext*)thisx;
|
||||||
GraphicsContext* gfxCtx;
|
GraphicsContext* gfxCtx;
|
||||||
void* zAlloc; // 0x84
|
void* zAlloc; // 0x84
|
||||||
void* zAllocAligned;
|
void* zAllocAligned;
|
||||||
|
@ -1329,7 +1330,9 @@ void Gameplay_Draw(GlobalContext* globalCtx) {
|
||||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Gameplay_Draw.s")
|
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Gameplay_Draw.s")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Gameplay_Main(GlobalContext* globalCtx) {
|
void Gameplay_Main(GameState* thisx) {
|
||||||
|
GlobalContext* globalCtx = (GlobalContext*)thisx;
|
||||||
|
|
||||||
D_8012D1F8 = &globalCtx->state.input[0];
|
D_8012D1F8 = &globalCtx->state.input[0];
|
||||||
|
|
||||||
DebugDisplay_Init();
|
DebugDisplay_Init();
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
|
||||||
void func_80092320(PreNMIContext* prenmiCtx) {
|
void func_80092320(PreNMIContext* this) {
|
||||||
prenmiCtx->state.running = false;
|
this->state.running = false;
|
||||||
prenmiCtx->state.init = NULL;
|
this->state.init = NULL;
|
||||||
prenmiCtx->state.size = 0;
|
this->state.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreNMI_Update(PreNMIContext* prenmiCtx) {
|
void PreNMI_Update(PreNMIContext* this) {
|
||||||
osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_move\n" VT_RST);
|
osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_move\n" VT_RST);
|
||||||
|
|
||||||
// Strings existing only in rodata
|
// Strings existing only in rodata
|
||||||
("../z_prenmi.c");
|
("../z_prenmi.c");
|
||||||
("(int)volume = %d\n");
|
("(int)volume = %d\n");
|
||||||
|
|
||||||
if (prenmiCtx->timer == 0) {
|
if (this->timer == 0) {
|
||||||
ViConfig_UpdateVi(1);
|
ViConfig_UpdateVi(1);
|
||||||
func_80092320(prenmiCtx);
|
func_80092320(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prenmiCtx->timer--;
|
this->timer--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreNMI_Draw(PreNMIContext* prenmiCtx) {
|
void PreNMI_Draw(PreNMIContext* this) {
|
||||||
GraphicsContext* gfxCtx = prenmiCtx->state.gfxCtx;
|
GraphicsContext* gfxCtx = this->state.gfxCtx;
|
||||||
|
|
||||||
osSyncPrintf(VT_COL(YELLOW, BLACK) "prenmi_draw\n" VT_RST);
|
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_80095248(gfxCtx, 0, 0, 0);
|
||||||
func_800940B0(gfxCtx);
|
func_800940B0(gfxCtx);
|
||||||
gDPSetFillColor(oGfxCtx->polyOpa.p++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1));
|
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);
|
CLOSE_DISPS(gfxCtx, "../z_prenmi.c", 112);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreNMI_Main(PreNMIContext* prenmiCtx) {
|
void PreNMI_Main(GameState* thisx) {
|
||||||
PreNMI_Update(prenmiCtx);
|
PreNMIContext* this = (PreNMIContext*)thisx;
|
||||||
PreNMI_Draw(prenmiCtx);
|
|
||||||
|
|
||||||
prenmiCtx->state.unk_A0 = 1;
|
PreNMI_Update(this);
|
||||||
|
PreNMI_Draw(this);
|
||||||
|
|
||||||
|
this->state.unk_A0 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreNMI_Destroy(PreNMIContext* prenmiCtx) {
|
void PreNMI_Destroy(GameState* thisx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreNMI_Init(PreNMIContext* prenmiCtx) {
|
void PreNMI_Init(GameState* thisx) {
|
||||||
prenmiCtx->state.main = PreNMI_Main;
|
PreNMIContext* this = (PreNMIContext*)thisx;
|
||||||
prenmiCtx->state.destroy = PreNMI_Destroy;
|
|
||||||
prenmiCtx->timer = 30;
|
this->state.main = PreNMI_Main;
|
||||||
prenmiCtx->unk_A8 = 10;
|
this->state.destroy = PreNMI_Destroy;
|
||||||
|
this->timer = 30;
|
||||||
|
this->unk_A8 = 10;
|
||||||
|
|
||||||
R_UPDATE_RATE = 1;
|
R_UPDATE_RATE = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,14 @@ void Sample_Draw(SampleContext* this) {
|
||||||
CLOSE_DISPS(gfxCtx, "../z_sample.c", 111);
|
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_Draw(this);
|
||||||
Sample_HandleStateChange(this);
|
Sample_HandleStateChange(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sample_Destroy(SampleContext* this) {
|
void Sample_Destroy(GameState* thisx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sample_SetupView(SampleContext* this) {
|
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);
|
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.main = Sample_Main;
|
||||||
this->state.destroy = Sample_Destroy;
|
this->state.destroy = Sample_Destroy;
|
||||||
R_UPDATE_RATE = 1;
|
R_UPDATE_RATE = 1;
|
||||||
|
|
|
@ -19,16 +19,20 @@ void Opening_SetupTitleScreen(OpeningContext* this) {
|
||||||
void func_80803C5C(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);
|
func_80095248(this->state.gfxCtx, 0, 0, 0);
|
||||||
Opening_SetupTitleScreen(this);
|
Opening_SetupTitleScreen(this);
|
||||||
func_80803C5C(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;
|
R_UPDATE_RATE = 1;
|
||||||
Matrix_Init(&this->state);
|
Matrix_Init(&this->state);
|
||||||
View_Init(&this->view, this->state.gfxCtx);
|
View_Init(&this->view, this->state.gfxCtx);
|
||||||
|
|
|
@ -566,20 +566,23 @@ void Select_Draw(SelectContext* this) {
|
||||||
CLOSE_DISPS(gfxCtx, "../z_select.c", 1037);
|
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_UpdateMenu(this);
|
||||||
Select_Draw(this);
|
Select_Draw(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Select_Destroy(SelectContext* this) {
|
void Select_Destroy(GameState* thisx) {
|
||||||
osSyncPrintf("%c", 7);
|
osSyncPrintf("%c", 7);
|
||||||
// "view_cleanup will hang, so it won't be called"
|
// "view_cleanup will hang, so it won't be called"
|
||||||
osSyncPrintf("*** view_cleanupはハングアップするので、呼ばない ***\n");
|
osSyncPrintf("*** view_cleanupはハングアップするので、呼ばない ***\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Select_Init(SelectContext* this) {
|
void Select_Init(GameState* thisx) {
|
||||||
|
SelectContext* this = (SelectContext*)thisx;
|
||||||
u32 size;
|
u32 size;
|
||||||
s32 pad[2];
|
s32 pad;
|
||||||
|
|
||||||
this->state.main = Select_Main;
|
this->state.main = Select_Main;
|
||||||
this->state.destroy = Select_Destroy;
|
this->state.destroy = Select_Destroy;
|
||||||
|
|
|
@ -124,8 +124,8 @@ void Title_Draw(TitleContext* this) {
|
||||||
CLOSE_DISPS(this->state.gfxCtx, "../z_title.c", 483);
|
CLOSE_DISPS(this->state.gfxCtx, "../z_title.c", 483);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Title_Main(TitleContext* this) {
|
void Title_Main(GameState* thisx) {
|
||||||
s32 pad;
|
TitleContext* this = (TitleContext*)thisx;
|
||||||
|
|
||||||
OPEN_DISPS(this->state.gfxCtx, "../z_title.c", 494);
|
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);
|
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);
|
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;
|
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);
|
this->staticSegment = GameState_Alloc(&this->state, size, "../z_title.c", 611);
|
||||||
osSyncPrintf("z_title.c\n");
|
osSyncPrintf("z_title.c\n");
|
||||||
|
|
Loading…
Reference in a new issue