Remove unnecessary physical address conversions to allow extended addressing (#33)

This commit is contained in:
Wiseguy
2025-12-29 18:52:45 -05:00
committed by GitHub
parent 2e675d5865
commit 7b9f13819f
6 changed files with 67 additions and 13 deletions
+46
View File
@@ -0,0 +1,46 @@
#include "patches.h"
#include "core1/mlmtx.h"
typedef struct {
s32 cmd_0;
s32 size_4;
s16 unk8[];
}GeoCmd5;
typedef struct {
s32 cmd_0;
s32 size_4;
u8 pad8;
s16 unkA;
}GeoCmd7;
extern s32 D_80370990;
extern BKGfxList *modelRenderDisplayList;
// @recomp Patched to remove unnecessary osVirtualToPhysical use to allow extended addresses.
RECOMP_PATCH void func_80338970(Gfx **gfx, Mtx **mtx, void *arg2){
GeoCmd5 *cmd = (GeoCmd5 *)arg2;
int i;
if(D_80370990){
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPDisplayList((*gfx)++, /*osVirtualToPhysical*/(modelRenderDisplayList->list + cmd->unk8[0]));
}
if(D_80370990){
for(i = 1; cmd->unk8[i]; i++){
mlMtxApply(*mtx);
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList((*gfx)++, /*osVirtualToPhysical*/(modelRenderDisplayList->list + cmd->unk8[i]));
}
}
}
// @recomp Patched to remove unnecessary osVirtualToPhysical use to allow extended addresses.
RECOMP_PATCH void func_80338AE8(Gfx **gfx, Mtx **mtx, void *arg2){
if(D_80370990){
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPDisplayList((*gfx)++, /*osVirtualToPhysical*/(modelRenderDisplayList->list + ((GeoCmd7*)arg2)->unkA));
}
}
+2 -1
View File
@@ -315,7 +315,8 @@ RECOMP_PATCH void func_8033F7F0(u8 indx, Gfx **gfx, Mtx **mtx, Vtx **vtx){
mlMtxRotatePYR(sp54->rotation[0], sp54->rotation[1], sp54->rotation[2]);
func_80252330(sp30[0], sp30[1], sp30[2]);
mlMtxApply(*mtx);
gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
// @recomp Remove unnecessary usage of OS_PHYSICAL_TO_K0 (which should actually be OS_K0_TO_PHYSICAL) to allow extended addresses.
gSPMatrix((*gfx)++, /*OS_PHYSICAL_TO_K0*/((*mtx)++), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
func_803382E4(sp54->unk28_21);
func_80338338(sp54->color[0], sp54->color[1],sp54->color[2]);
func_803382FC(sp54->unk27);
+2 -2
View File
@@ -13,9 +13,9 @@ RECOMP_PATCH void func_80314BB0(Gfx **gfx, Mtx **mtx, Vtx **vtx, void *frame_buf
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_PHYSICAL_TO_K0(frame_buffer_1));
#if 1
// @recomp New implementation that uses rows instead of tiles.
// @recomp New implementation that uses rows instead of tiles. Remove unnecessary usage of osVirtualToPhysical.
for (y = 0; y < gFramebufferHeight / 7 + 1; y++) {
gDPLoadTextureTile((*gfx)++, osVirtualToPhysical(frame_buffer_2), G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, gFramebufferHeight,
gDPLoadTextureTile((*gfx)++, /*osVirtualToPhysical*/(frame_buffer_2), G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, gFramebufferHeight,
0, y * 7, gFramebufferWidth - 1, MIN((y + 1) * 7, gFramebufferHeight) - 1,
NULL, G_TX_CLAMP, G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, 0, 0
);
+6 -3
View File
@@ -120,7 +120,8 @@ RECOMP_PATCH Actor *chBottlesBonus_draw(ActorMarker *marker, Gfx **gfx, Mtx **mt
func_80253190(gfx);
gDPSetTextureFilter((*gfx)++, G_TF_POINT);
gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp50));
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPSegment((*gfx)++, 0x04, /*osVirtualToPhysical*/(sp50));
modelRender_preDraw((GenFunction_1)actor_predrawMethod, (s32)sp6C);
modelRender_postDraw((GenFunction_1)actor_postdrawMethod, (s32)marker);
@@ -145,7 +146,8 @@ RECOMP_PATCH Actor *func_802DF160(Gfx **gfx, Mtx **mtx, Vtx **vtx) {
sp38 = func_8030C704();
modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL);
gDPSetTextureFilter((*gfx)++, G_TF_POINT);
gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp38));
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPSegment((*gfx)++, 0x04, /*osVirtualToPhysical*/(sp38));
modelRender_preDraw((GenFunction_1)actor_predrawMethod, (s32)this);
modelRender_postDraw((GenFunction_1)actor_postdrawMethod, (s32)D_8037E000);
@@ -188,7 +190,8 @@ RECOMP_PATCH Actor *func_802DEC00(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx
modelRender_draw(gfx, mtx, sp58, NULL, 1.0f, sp4C, D_8037DFE8);
gDPSetColorDither((*gfx)++, G_CD_DISABLE);
func_80253190(gfx);
gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp48));
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPSegment((*gfx)++, 0x04, /*osVirtualToPhysical*/(sp48));
modelRender_preDraw((GenFunction_1)actor_predrawMethod, (s32)this);
modelRender_postDraw((GenFunction_1)actor_postdrawMethod, (s32)marker);
+2 -1
View File
@@ -218,7 +218,8 @@ RECOMP_PATCH bool func_802F989C(Gfx **gfx, Mtx **mtx, f32 arg2[3]) {
}
gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList((*gfx)++, osVirtualToPhysical(D_80381090));
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPDisplayList((*gfx)++, /*osVirtualToPhysical*/(D_80381090));
gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);
// @recomp Clear the matrix group.
+9 -6
View File
@@ -256,7 +256,8 @@ RECOMP_PATCH void func_80338904(Gfx **gfx, Mtx **mtx, void *arg2){
pushed_matrix_group = set_model_matrix_group(gfx, arg2, FALSE);
vptr = &modelRenderDisplayList->list[cmd->unk8];
gSPDisplayList((*gfx)++, osVirtualToPhysical(vptr));
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPDisplayList((*gfx)++, /*osVirtualToPhysical*/(vptr));
// @recomp Pop the matrix and pop the matrix group if one was created.
gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);
@@ -651,8 +652,8 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
}
// Set up segments 1 and 2 to point to vertices and textures respectively
gSPSegment((*gfx)++, 0x01, osVirtualToPhysical(&modelRendervertexList->vtx_18));
gSPSegment((*gfx)++, 0x02, osVirtualToPhysical(&modelRenderTextureList->tex_8[modelRenderTextureList->cnt_4]));
gSPSegment((*gfx)++, 0x01, &modelRendervertexList->vtx_18);
gSPSegment((*gfx)++, 0x02, &modelRenderTextureList->tex_8[modelRenderTextureList->cnt_4]);
//segments 11 to 15 contain animated textures
if(modelRenderAnimatedTexturesCacheId){
@@ -660,8 +661,10 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
s32 texture_offset;
for(i_segment = 0; i_segment < 4; i_segment++){
if(AnimTextureListCache_tryGetTextureOffset(modelRenderAnimatedTexturesCacheId, i_segment, &texture_offset))
gSPSegment((*gfx)++, 15 - i_segment, osVirtualToPhysical((u8*)&modelRenderTextureList->tex_8[modelRenderTextureList->cnt_4] + texture_offset));
if(AnimTextureListCache_tryGetTextureOffset(modelRenderAnimatedTexturesCacheId, i_segment, &texture_offset)) {
// @recomp Remove unnecessary usage of osVirtualToPhysical to allow extended addresses.
gSPSegment((*gfx)++, 15 - i_segment, /*osVirtualToPhysical*/((u8*)&modelRenderTextureList->tex_8[modelRenderTextureList->cnt_4] + texture_offset));
}
}
}
@@ -769,7 +772,7 @@ RECOMP_PATCH BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3],
// @recomp Do the skinning again on a high precision version of the vertex buffer. Force its usage for any subsequent display lists.
f32 *skinned_pos = recomp_apply_cpu_skinning((u8 *)modelRenderModelBin + modelRenderModelBin->unk28, modelRendervertexList, D_8038371C);
if (skinned_pos != NULL) {
gEXSetVertexSegment((*gfx)++, G_EX_VERTEX_POSITION, G_EX_ENABLED, osVirtualToPhysical(skinned_pos), osVirtualToPhysical(&modelRendervertexList->vtx_18));
gEXSetVertexSegment((*gfx)++, G_EX_VERTEX_POSITION, G_EX_ENABLED, skinned_pos, &modelRendervertexList->vtx_18);
ex_vertex_components_used = TRUE;
}
}