diff --git a/.gitignore b/.gitignore index 1664a29..187fe7a 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ bld/ [Oo]bj/ [Ll]og/ [Ll]ogs/ +out/ # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/lib/RT64-HLE b/lib/RT64-HLE index 0ff404a..12bf0ef 160000 --- a/lib/RT64-HLE +++ b/lib/RT64-HLE @@ -1 +1 @@ -Subproject commit 0ff404a589d478e9e644b1f97b7f3d1cb8183d4f +Subproject commit 12bf0efad21fb7cc1f27a630ae6dbcb90ddd1433 diff --git a/lib/RmlUi b/lib/RmlUi index d3876e6..bb25b88 160000 --- a/lib/RmlUi +++ b/lib/RmlUi @@ -1 +1 @@ -Subproject commit d3876e62fb7a0aa0630272f27ac83ef1c67b01c5 +Subproject commit bb25b881791bc77805b30b22fea01ae42b619bd7 diff --git a/patches/input.h b/patches/input.h index 9b0ae4b..3b24ab4 100644 --- a/patches/input.h +++ b/patches/input.h @@ -45,8 +45,9 @@ DECLARE_FUNC(u32, recomp_get_digital_input, u32 which); DECLARE_FUNC(float, recomp_get_analog_input, u32 which); DECLARE_FUNC(void, recomp_get_item_inputs, u32* buttons); DECLARE_FUNC(void, recomp_get_camera_inputs, float* x_out, float* y_out); -// TODO move this +// TODO move these DECLARE_FUNC(void, recomp_puts, const char* data, u32 size); +DECLARE_FUNC(void, recomp_exit); #ifdef __cplusplus } diff --git a/patches/options.c b/patches/options.c new file mode 100644 index 0000000..d7db2de --- /dev/null +++ b/patches/options.c @@ -0,0 +1,56 @@ +#include "patches.h" +#include "input.h" +#include "z64shrink_window.h" +#include "overlays/gamestates/ovl_file_choose/z_file_select.h" + +extern u64 gFileSelOptionsButtonENGTex[]; +extern u64 gFileSelQuitButtonENGTex[]; + +void FileSelect_Main(GameState* thisx); +void FileSelect_InitContext(GameState* thisx); + +// @recomp The options button is now the quit button, so close recomp instead of opening the options. +void FileSelect_RotateToOptions(GameState* thisx) { + recomp_exit(); +} + +void FileSelect_Init(GameState* thisx) { + s32 pad; + FileSelectState* this = (FileSelectState*)thisx; + size_t size; + + GameState_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); + ShrinkWindow_Init(); + View_Init(&this->view, this->state.gfxCtx); + + // @recomp manually relocate these symbols as the recompiler doesn't do this automatically for patches yet. + GameStateOverlay* ovl = &gGameStateOverlayTable[GAMESTATE_FILE_SELECT]; + this->state.main = (void*)((u32)FileSelect_Main - (u32)ovl->vramStart + (u32)ovl->loadedRamAddr); + this->state.destroy = (void*)((u32)FileSelect_Destroy - (u32)ovl->vramStart + (u32)ovl->loadedRamAddr); + + FileSelect_InitContext(&this->state); + Font_LoadOrderedFont(&this->font); + + size = SEGMENT_ROM_SIZE(title_static); + this->staticSegment = THA_AllocTailAlign16(&this->state.tha, size); + DmaMgr_SendRequest0(this->staticSegment, SEGMENT_ROM_START(title_static), size); + + size = SEGMENT_ROM_SIZE(parameter_static); + this->parameterSegment = THA_AllocTailAlign16(&this->state.tha, size); + DmaMgr_SendRequest0(this->parameterSegment, SEGMENT_ROM_START(parameter_static), size); + + size = gObjectTable[OBJECT_MAG].vromEnd - gObjectTable[OBJECT_MAG].vromStart; + this->titleSegment = THA_AllocTailAlign16(&this->state.tha, size); + DmaMgr_SendRequest0(this->titleSegment, gObjectTable[OBJECT_MAG].vromStart, size); + + Audio_SetSpec(0xA); + // Setting ioData to 1 and writing it to ioPort 7 will skip the harp intro + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); + + // @recomp Replace the contents of the options button's texture with the quit button texture. + // Lower impact than replacing the entire `FileSelect_DrawWindowContents` function. + void* options_button_texture = (void*)(this->staticSegment + (u32)gFileSelOptionsButtonENGTex - 0x01000000); + void* quit_button_texture = (void*)(this->staticSegment + (u32)gFileSelQuitButtonENGTex - 0x01000000); + Lib_MemCpy(options_button_texture, quit_button_texture, 64 * 16 * sizeof(u16)); +} diff --git a/patches/syms.ld b/patches/syms.ld index 3449416..ad8c801 100644 --- a/patches/syms.ld +++ b/patches/syms.ld @@ -4,3 +4,4 @@ __start = 0x80000000; recomp_get_item_inputs = 0x81000000; recomp_puts = 0x81000004; recomp_get_camera_inputs = 0x81000008; +recomp_exit = 0x8100000C; diff --git a/src/game/controls.cpp b/src/game/controls.cpp index d91c0f6..ce91d9b 100644 --- a/src/game/controls.cpp +++ b/src/game/controls.cpp @@ -115,7 +115,7 @@ extern "C" void recomp_get_camera_inputs(uint8_t* rdram, recomp_context* ctx) { *y_out = y_val; } -// TODO move this +// TODO move these extern "C" void recomp_puts(uint8_t* rdram, recomp_context* ctx) { PTR(char) cur_str = _arg<0, PTR(char)>(rdram, ctx); u32 length = _arg<1, u32>(rdram, ctx); @@ -124,3 +124,7 @@ extern "C" void recomp_puts(uint8_t* rdram, recomp_context* ctx) { fputc(MEM_B(i, (gpr)cur_str), stdout); } } + +extern "C" void recomp_exit(uint8_t* rdram, recomp_context* ctx) { + ultramodern::quit(); +}