match: func_80066CDC (#552)

This commit is contained in:
Dominik Peters
2025-05-05 23:12:32 +02:00
committed by GitHub
parent b88bd4366e
commit de04669992
15 changed files with 77 additions and 89 deletions
+4 -4
View File
@@ -121,10 +121,10 @@ As of May 5, 2025, this is our current score:
```
========================================================
ADVENTURE ONE (ASM -> C Decompilation)
-------- 84.89% Complete (86.44% NON_MATCHING) ---------
# Decompiled functions: 1880
# GLOBAL_ASM remaining: 71
# NON_MATCHING functions: 8
-------- 84.89% Complete (86.05% NON_MATCHING) ---------
# Decompiled functions: 1881
# GLOBAL_ASM remaining: 70
# NON_MATCHING functions: 7
# NON_EQUIVALENT WIP functions: 25
--------------------- Game Status ----------------------
Balloons: 39/47, Keys: 4/4, Trophies: 4/5
+1 -2
View File
@@ -775,8 +775,7 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
if (arg3 != 1) {
gRacerSound->unk91[0] = 64;
}
sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_PAN_EVT,
gRacerSound->unk91[0]);
sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_PAN_EVT, gRacerSound->unk91[0]);
}
}
}
+5 -4
View File
@@ -857,10 +857,11 @@ u16 sndp_get_group_volume(u8 groupID) {
/**
* Sets the volume for the specified group and updates the volume of all sounds in that group.
*
* !@bug: No bounds checking is performed on the group index. In DKR, only one group is defined and memory is allocated for a single group.
* This leads to out-of-bounds access, which can cause undefined behavior, including potential crashes.
*
*
* !@bug: No bounds checking is performed on the group index. In DKR, only one group is defined and memory is allocated
* for a single group. This leads to out-of-bounds access, which can cause undefined behavior, including potential
* crashes.
*
* Official Name: gsSndpSetMasterVolume
*/
void sndp_set_group_volume(u8 groupID, u16 volume) {
+55 -65
View File
@@ -28,6 +28,8 @@ s8 gAntiPiracyViewport = FALSE;
0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH_HALF, SCREEN_HEIGHT_HALF, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, \
SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0
#define SCISSOR_INTERLACE G_SC_NON_INTERLACE
ScreenViewport gScreenViewports[4] = {
{ DEFAULT_VIEWPORT },
{ DEFAULT_VIEWPORT },
@@ -261,7 +263,7 @@ void camera_init_tracks_menu(Gfx **dList, MatrixS **mtxS) {
cam->trans.y_position = 0.0f;
cam->trans.z_position = 0.0f;
update_envmap_position(0.0f, 0.0f, -1.0f);
func_80066CDC(dList, mtxS);
viewport_main(dList, mtxS);
cam->camera.unk38 = sp24;
cam->trans.rotation.y_rotation = angleY;
cam->trans.rotation.x_rotation = angleX;
@@ -605,27 +607,22 @@ UNUSED void copy_framebuffer_size_to_coords(s32 *x1, s32 *y1, s32 *x2, s32 *y2)
*y2 = GET_VIDEO_HEIGHT(widthAndHeight);
}
#ifdef NON_MATCHING
#define SCISSOR_INTERLACE G_SC_NON_INTERLACE
// viewport_main
void func_80066CDC(Gfx **dList, MatrixS **mats) {
void viewport_main(Gfx **dlist, MatrixS **mats) {
u32 y;
u32 x;
u32 pad0;
u32 tempX;
u32 sp58_height;
u32 sp54_width;
u32 posY;
u32 posX; // sp4C
u32 pad1;
u32 posX;
u32 tempY;
u32 videoHeight;
u32 videoWidth;
u32 widthAndHeight;
s32 viewports;
s32 originalCameraID; // sp34
s32 savedCameraID; // sp30
s32 tempCameraID; // sp2C
s32 originalCameraID;
s32 savedCameraID;
s32 tempCameraID;
originalCameraID = gActiveCameraID;
savedCameraID = gActiveCameraID;
@@ -640,13 +637,13 @@ void func_80066CDC(Gfx **dList, MatrixS **mats) {
if (gScreenViewports[savedCameraID].flags & VIEWPORT_EXTRA_BG) {
tempCameraID = gActiveCameraID;
gActiveCameraID = savedCameraID;
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, gScreenViewports[gActiveCameraID].scissorX1,
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, gScreenViewports[gActiveCameraID].scissorX1,
gScreenViewports[gActiveCameraID].scissorY1, gScreenViewports[gActiveCameraID].scissorX2,
gScreenViewports[gActiveCameraID].scissorY2);
viewport_rsp_set(dList, 0, 0, 0, 0);
viewport_rsp_set(dlist, 0, 0, 0, 0);
gActiveCameraID = tempCameraID;
if (mats != NULL) {
func_80067D3C(dList, mats);
if (mats != 0) {
func_80067D3C(dlist, mats);
}
gActiveCameraID = originalCameraID;
return;
@@ -655,46 +652,45 @@ void func_80066CDC(Gfx **dList, MatrixS **mats) {
viewports = gNumberOfViewports;
if (viewports == VIEWPORTS_COUNT_3_PLAYERS) {
viewports = VIEWPORTS_COUNT_4_PLAYERS;
// Fake match
if ((x && x) && x) {}
}
y = (videoHeight >> 1) & 0xFFFFFFFFFFFFFFFF;
x = videoWidth >> 1;
sp54_width = x;
y = videoHeight >> 1;
sp58_height = y;
if (osTvType == OS_TV_TYPE_PAL) {
if (osTvType == 0) {
sp58_height = 145;
}
switch (viewports ^ 0) {
switch (viewports) {
case VIEWPORTS_COUNT_1_PLAYER:
posX = sp54_width;
posY = sp58_height;
if (osTvType == OS_TV_TYPE_PAL) {
posY -= 18;
// Fake match
if (!gScreenViewports[gActiveCameraID].scissorX2) {}
}
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, 0, 0, videoWidth, videoHeight);
posX = x;
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, videoWidth, videoHeight);
break;
case VIEWPORTS_COUNT_2_PLAYERS:
// 2 players = split screen horizontally
// first player has top half
if (gActiveCameraID == 0) {
posX = sp54_width;
posY = gActiveCameraID;
if (posY == 0) {
posY = videoHeight >> 2;
if (osTvType == OS_TV_TYPE_PAL) {
posY -= 12;
}
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, 0, 0, videoWidth, y - (videoHeight >> 7));
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, videoWidth, y - (videoHeight >> 7));
} else {
// second player has bottom half
posY = sp58_height;
posY = y;
posY += videoHeight >> 2;
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, 0, y + (videoHeight >> 7), videoWidth,
videoHeight - (videoHeight >> 7));
tempY = y;
tempY += (videoHeight >> 7);
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, tempY, videoWidth, videoHeight - (videoHeight >> 7));
}
posX = x;
break;
// this is probably never reached because of an if above that sets the viewport to 4 players if its currently 3
// players
@@ -704,78 +700,72 @@ void func_80066CDC(Gfx **dList, MatrixS **mats) {
// bottom right has map of race track
if (gActiveCameraID == 0) {
posX = videoWidth >> 2;
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, 0, 0, x - (videoWidth >> 8), videoHeight);
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, x - (videoWidth >> 8), videoHeight);
} else {
posX = x + (videoWidth >> 2);
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, x + (videoWidth >> 8), 0, videoWidth - (videoWidth >> 8),
videoHeight);
posX = x;
posX += (videoWidth >> 2);
tempX = x;
tempX += (videoWidth >> 8);
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, tempX, 0, videoWidth - (videoWidth >> 8), videoHeight);
}
break;
case VIEWPORTS_COUNT_4_PLAYERS:
sp58_height >>= 1;
sp54_width >>= 1;
posX = 0;
posY = 0;
tempY = 0;
tempX = 0;
switch (gActiveCameraID) {
case 0:
// Using posX and posY here is not smart since IDO can't optimize out the zero now.
// Using tempX and tempY here is not smart since IDO can't optimize out the zero now.
// Why here of all places did they do this instead of just setting zero like everywhere else?
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, posX, posY, x - (videoWidth >> 8),
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, tempX, tempY, x - (videoWidth >> 8),
y - (videoHeight >> 7));
break;
case 1:
tempY = x;
posX = x;
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, x + (videoWidth >> 8), 0, (x + x) - (videoWidth >> 8),
posX += (videoWidth >> 8);
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, posX, 0, (x + x) - (videoWidth >> 8),
y - (videoHeight >> 7));
// Fake
if (1) {}
if (1) {}
if (1) {}
if (1) {}
break;
case 2:
tempX = y;
posY = y;
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, 0, y + (videoHeight >> 7), x - (videoWidth >> 8),
(y + y) - (videoHeight >> 7));
posY += (videoHeight >> 7);
posX = x;
posX -= (videoWidth >> 8);
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, posY, posX, (y + y) - (videoHeight >> 7));
break;
case 3:
tempY = x;
tempX = y;
posX = x;
posY = y;
gDPSetScissor((*dList)++, SCISSOR_INTERLACE, x + (videoWidth >> 8), y + (videoHeight >> 7),
posX += (videoWidth >> 8);
gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, posX, y + (videoHeight >> 7),
(x + x) - (videoWidth >> 8), (y + y) - (videoHeight >> 7));
break;
}
// This should probably assign to a temp variable first?
posY += sp58_height;
posX += sp54_width;
posY = tempX + sp58_height;
posX = tempY + sp54_width;
if (osTvType == OS_TV_TYPE_PAL) {
if (gActiveCameraID <= 3) {
if (gActiveCameraID < 2) {
posY -= 20;
} else {
posY -= 6;
}
}
break;
default:
posY = sp58_height;
posX = x;
break;
}
if (osTvType == OS_TV_TYPE_PAL) {
posX -= 4;
}
viewport_rsp_set(dList, sp54_width, sp58_height, posX, posY);
viewport_rsp_set(dlist, sp54_width, sp58_height, posX, posY);
if (mats != NULL) {
func_80067D3C(dList, mats);
func_80067D3C(dlist, mats);
}
gActiveCameraID = originalCameraID;
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/camera/func_80066CDC.s")
#endif
/**
* Takes the size of the screen as depicted by the active menu viewport, then sets the RDP scissor to match it.
+1 -3
View File
@@ -129,9 +129,7 @@ void apply_matrix_from_stack(Gfx **dList);
void copy_viewports_to_stack(void);
void apply_head_turning_matrix(Gfx **dList, MatrixS **mtx, Object_68 *objGfx, s16 headAngle);
void apply_object_shear_matrix(Gfx **dList, MatrixS **mtx, Object *arg2, Object *arg3, f32 shear);
// Non Matching
void camera_init(void);
void func_80066CDC(Gfx **dList, MatrixS **mats);
void viewport_main(Gfx **dList, MatrixS **mats);
#endif
+1 -1
View File
@@ -343,7 +343,7 @@ void transition_render(Gfx **dList, MatrixS **mtx, Vertex **vtx) {
break;
}
func_80066CDC(dList, mtx);
viewport_main(dList, mtx);
}
}
+1 -1
View File
@@ -3060,7 +3060,7 @@ void hud_magnet_reticle(Object *racerObj) {
return;
}
gAssetHudElementStaleCounter[hud->spriteID] = 0;
func_80066CDC(&gHudDL, &gHudMtx);
viewport_main(&gHudDL, &gHudMtx);
matrix_world_origin(&gHudDL, &gHudMtx);
render_sprite_billboard(&gHudDL, &gHudMtx, &gHudVtx, (Object *) hud, entry, RENDER_Z_UPDATE);
}
+1 -1
View File
@@ -13377,7 +13377,7 @@ void menu_camera_centre(void) {
cam->trans.z_position = -32.0f;
update_envmap_position(0, 0, -1);
func_80066CDC(&sMenuCurrDisplayList, &sMenuCurrHudMat);
viewport_main(&sMenuCurrDisplayList, &sMenuCurrHudMat);
cam->trans.rotation.y_rotation = angleY;
cam->trans.rotation.x_rotation = angleX;
+2 -2
View File
@@ -367,7 +367,7 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, Triangle **tris, s32
apply_fog(gSceneCurrentPlayerID);
gDPPipeSync(gSceneCurrDisplayList++);
set_active_camera(gSceneCurrentPlayerID);
func_80066CDC(&gSceneCurrDisplayList, &gSceneCurrMatrix);
viewport_main(&gSceneCurrDisplayList, &gSceneCurrMatrix);
func_8002A31C();
// Show detailed skydome in single player.
if (numViewports < 2) {
@@ -409,7 +409,7 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, Triangle **tris, s32
set_active_camera(PLAYER_FOUR);
disable_cutscene_camera();
func_800278E8(updateRate);
func_80066CDC(&gSceneCurrDisplayList, &gSceneCurrMatrix);
viewport_main(&gSceneCurrDisplayList, &gSceneCurrMatrix);
func_8002A31C();
func_8006807C(&gSceneCurrDisplayList, &gSceneCurrMatrix);
draw_gradient_background();
+1 -1
View File
@@ -658,7 +658,7 @@ void lensflare_render(Gfx **dList, MatrixS **mats, Vertex **verts, ObjectSegment
f32_matrix_dot(get_projection_matrix_f32(), (Matrix *) &pos[1].x, (Matrix *) &pos[1].x);
magnitude = ((gLensFlarePos.x * pos[1].x) + (gLensFlarePos.y * pos[1].y)) + (gLensFlarePos.z * pos[1].z);
if (magnitude > 0.0f) {
func_80066CDC(dList, mats);
viewport_main(dList, mats);
matrix_world_origin(dList, mats);
pos[0].x = (gLensFlarePos.x * 256.0f) + segment->trans.x_position;
pos[0].y = (gLensFlarePos.y * 256.0f) + segment->trans.y_position;
+1 -1
View File
@@ -904,7 +904,7 @@ set_viewport_properties = 0x80066B78;
copy_viewport_background_size_to_coords = 0x80066C78;
copy_viewport_frame_size_to_coords = 0x80066CFC;
copy_framebuffer_size_to_coords = 0x80066D50;
func_80066CDC = 0x80066DAC;
viewport_main = 0x80066DAC;
viewport_scissor = 0x80067B0C;
func_80067D3C = 0x80067E0C;
set_ortho_matrix_height = 0x80067FF0;
+1 -1
View File
@@ -902,7 +902,7 @@ set_viewport_properties = 0x80066AA8;
copy_viewport_background_size_to_coords = 0x80066BA8;
copy_viewport_frame_size_to_coords = 0x80066C2C;
copy_framebuffer_size_to_coords = 0x80066C80;
func_80066CDC = 0x80066CDC;
viewport_main = 0x80066CDC;
viewport_scissor = 0x80067A3C;
func_80067D3C = 0x80067D3C;
set_ortho_matrix_height = 0x80067F20;
+1 -1
View File
@@ -848,7 +848,7 @@ set_viewport_properties = 0x80066CE8;
copy_viewport_background_size_to_coords = 0x80066DE8;
copy_viewport_frame_size_to_coords = 0x80066E6C;
copy_framebuffer_size_to_coords = 0x80066EC0;
func_80066CDC = 0x80066F1C;
viewport_main = 0x80066F1C;
viewport_scissor = 0x80067C7C;
func_80067D3C = 0x80067F7C;
set_ortho_matrix_height = 0x80068160;
+1 -1
View File
@@ -902,7 +902,7 @@ set_viewport_properties = 0x80066AA8;
copy_viewport_background_size_to_coords = 0x80066BA8;
copy_viewport_frame_size_to_coords = 0x80066C2C;
copy_framebuffer_size_to_coords = 0x80066C80;
func_80066CDC = 0x80066CDC;
viewport_main = 0x80066CDC;
viewport_scissor = 0x80067A3C;
func_80067D3C = 0x80067D3C;
set_ortho_matrix_height = 0x80067F20;
+1 -1
View File
@@ -848,7 +848,7 @@ set_viewport_properties = 0x80066CE8;
copy_viewport_background_size_to_coords = 0x80066DE8;
copy_viewport_frame_size_to_coords = 0x80066E6C;
copy_framebuffer_size_to_coords = 0x80066EC0;
func_80066CDC = 0x80066F1C;
viewport_main = 0x80066F1C;
viewport_scissor = 0x80067C7C;
func_80067D3C = 0x80067F7C;
set_ortho_matrix_height = 0x80068160;