Patch options button in file select to be a quit button instead, update RT64 and RmlUi

This commit is contained in:
Mr-Wiseguy 2023-12-27 17:56:26 -05:00
parent fd29131b02
commit c0abf1a203
7 changed files with 67 additions and 4 deletions

1
.gitignore vendored
View File

@ -41,6 +41,7 @@ bld/
[Oo]bj/
[Ll]og/
[Ll]ogs/
out/
# Visual Studio 2015/2017 cache/options directory
.vs/

@ -1 +1 @@
Subproject commit 0ff404a589d478e9e644b1f97b7f3d1cb8183d4f
Subproject commit 12bf0efad21fb7cc1f27a630ae6dbcb90ddd1433

@ -1 +1 @@
Subproject commit d3876e62fb7a0aa0630272f27ac83ef1c67b01c5
Subproject commit bb25b881791bc77805b30b22fea01ae42b619bd7

View File

@ -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
}

56
patches/options.c Normal file
View File

@ -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));
}

View File

@ -4,3 +4,4 @@ __start = 0x80000000;
recomp_get_item_inputs = 0x81000000;
recomp_puts = 0x81000004;
recomp_get_camera_inputs = 0x81000008;
recomp_exit = 0x8100000C;

View File

@ -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();
}