Moved core1 overlay load into boot___osInitialize_common and reset inverse view matrix for ortho view matrices

This commit is contained in:
Mr-Wiseguy
2025-07-09 14:59:39 -04:00
parent 71dfde0270
commit 07998cb006
4 changed files with 30 additions and 37 deletions
-1
View File
@@ -32,7 +32,6 @@ ignored = [
"boot___ull_divremi",
"boot___ull_rem",
"boot___ull_rshift",
"boot___osInitialize_common",
"boot_osPiRawStartDma",
"boot_osPiGetStatus",
"boot___osSetSR",
+5 -34
View File
@@ -54,37 +54,8 @@ MAKE_OVERLAYS()
#define OVERLAY_END(ovl) boot_##ovl##_rzip_ROM_END
// @recomp Patched to load overlays, prefixed with boot_ to account for the decomp build system.
RECOMP_PATCH void boot_overlay_table_init(void) {
gOverlayTable[ 0].start = OVERLAY_START(core2);
gOverlayTable[ 0].end = OVERLAY_END(core2);
gOverlayTable[ 1].start = OVERLAY_START(emptyLvl);
gOverlayTable[ 1].end = OVERLAY_END(emptyLvl);
gOverlayTable[ 2].start = OVERLAY_START(CC);
gOverlayTable[ 2].end = OVERLAY_END(CC);
gOverlayTable[ 3].start = OVERLAY_START(MMM);
gOverlayTable[ 3].end = OVERLAY_END(MMM);
gOverlayTable[ 4].start = OVERLAY_START(GV);
gOverlayTable[ 4].end = OVERLAY_END(GV);
gOverlayTable[ 5].start = OVERLAY_START(TTC);
gOverlayTable[ 5].end = OVERLAY_END(TTC);
gOverlayTable[ 6].start = OVERLAY_START(MM);
gOverlayTable[ 6].end = OVERLAY_END(MM);
gOverlayTable[ 7].start = OVERLAY_START(BGS);
gOverlayTable[ 7].end = OVERLAY_END(BGS);
gOverlayTable[ 8].start = OVERLAY_START(RBB);
gOverlayTable[ 8].end = OVERLAY_END(RBB);
gOverlayTable[ 9].start = OVERLAY_START(FP);
gOverlayTable[ 9].end = OVERLAY_END(FP);
gOverlayTable[10].start = OVERLAY_START(CCW);
gOverlayTable[10].end = OVERLAY_END(CCW);
gOverlayTable[11].start = OVERLAY_START(SM);
gOverlayTable[11].end = OVERLAY_END(SM);
gOverlayTable[12].start = OVERLAY_START(cutscenes);
gOverlayTable[12].end = OVERLAY_END(cutscenes);
gOverlayTable[13].start = OVERLAY_START(lair);
gOverlayTable[13].end = OVERLAY_END(lair);
gOverlayTable[14].start = OVERLAY_START(fight);
gOverlayTable[14].end = OVERLAY_END(fight);
RECOMP_PATCH void boot___osInitialize_common(void) {
// Nothing of the original function needs to happen, so the body can be empty besides the overlay load.
// @recomp Load core1.
recomp_load_overlays_by_rom((u32)core1_ROM_START, core1_VRAM, core1_ROM_END - core1_ROM_START);
@@ -113,7 +84,7 @@ RECOMP_PATCH void overlay_load(
u32 uncompressed_rom_start = rom_start;
u32 uncompressed_rom_size = rom_end - rom_start;
u32 overlay_vram_start = ram_start;
void* sp34;
u8* sp34;
u32 sp30;
u32 sp2C;
u32 *tmp;
@@ -137,10 +108,10 @@ RECOMP_PATCH void overlay_load(
sp34 = &D_8002D500;
}
piMgr_read(sp34, rom_start, rom_end - rom_start);
rarezip_uncompress(&sp34, &ram_start);
rarezip_uncompress(&sp34, (u8**)&ram_start);
sp2C = D_8027BF2C;
sp30 = D_8027BF30;
rarezip_uncompress(&sp34, &ram_start);
rarezip_uncompress(&sp34, (u8**)&ram_start);
if(bss_start){
bzero((void*)bss_start, bss_end - bss_start);
+25
View File
@@ -71,6 +71,10 @@ void ml_vec3f_copy(f32 dst[3], f32 src[3]);
// sViewportPosition[2] = z;
// }
extern Vp sViewportStack[];
extern s32 sViewportStackIndex;
// @recomp Patched to set up an inverse view matrix for better transform interpolation.
RECOMP_PATCH void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32 near, f32 far) {
u16 perspNorm;
@@ -105,6 +109,27 @@ RECOMP_PATCH void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32
gEXSetInvViewMatrixFloat((*gfx)++, invView->m);
}
float identity_matrix[4][4] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
};
// @recomp Patched to set up an identity inverse view matrix to prevent bleeding the perspective projection's inverse view matrix.
RECOMP_PATCH void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx) {
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
guOrtho(*mtx, -(2*(f32)gFramebufferWidth), (2*(f32)gFramebufferWidth), -(2*(f32)gFramebufferHeight), (2*(f32)gFramebufferHeight), 1.0f, 20.0f, 1.0f);
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
// @recomp Set an identity inverse view matrix.
gEXSetInvViewMatrixFloat((*gfx)++, identity_matrix);
}
typedef void (*GeoListFunc)(Gfx **, Mtx **, void *);
typedef struct {
-2
View File
@@ -215,8 +215,6 @@ extern "C" void osPiReadIo_recomp(RDRAM_ARG recomp_context * ctx) {
ctx->r2 = 0;
}
extern "C" void boot___osInitialize_common(uint8_t* rdram, recomp_context* ctx) {}
extern "C" void boot_osPiGetStatus(uint8_t* rdram, recomp_context* ctx) {
// PI not busy
ctx->r2 = 0;