diff --git a/README.md b/README.md index 8296b846..619e7dc4 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/audio_vehicle.c b/src/audio_vehicle.c index 8c37ab7e..b3e5bf85 100644 --- a/src/audio_vehicle.c +++ b/src/audio_vehicle.c @@ -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]); } } } diff --git a/src/audiosfx.c b/src/audiosfx.c index e77fc950..6412baff 100644 --- a/src/audiosfx.c +++ b/src/audiosfx.c @@ -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) { diff --git a/src/camera.c b/src/camera.c index 2b350f0a..4ad40005 100644 --- a/src/camera.c +++ b/src/camera.c @@ -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. diff --git a/src/camera.h b/src/camera.h index 915478a3..a7f303f8 100644 --- a/src/camera.h +++ b/src/camera.h @@ -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 diff --git a/src/fade_transition.c b/src/fade_transition.c index 5f7578bd..7b7b5c8c 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -343,7 +343,7 @@ void transition_render(Gfx **dList, MatrixS **mtx, Vertex **vtx) { break; } - func_80066CDC(dList, mtx); + viewport_main(dList, mtx); } } diff --git a/src/game_ui.c b/src/game_ui.c index f8df1840..8d8546ff 100644 --- a/src/game_ui.c +++ b/src/game_ui.c @@ -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); } diff --git a/src/menu.c b/src/menu.c index 804a8e99..0f8905a3 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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; diff --git a/src/tracks.c b/src/tracks.c index aa673415..6bee3b9e 100644 --- a/src/tracks.c +++ b/src/tracks.c @@ -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(); diff --git a/src/weather.c b/src/weather.c index 67d334a7..21de1a9f 100644 --- a/src/weather.c +++ b/src/weather.c @@ -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; diff --git a/ver/symbols/symbol_addrs.jpn.v79.txt b/ver/symbols/symbol_addrs.jpn.v79.txt index 3c9582db..c5e2a1f0 100644 --- a/ver/symbols/symbol_addrs.jpn.v79.txt +++ b/ver/symbols/symbol_addrs.jpn.v79.txt @@ -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; diff --git a/ver/symbols/symbol_addrs.pal.v77.txt b/ver/symbols/symbol_addrs.pal.v77.txt index 2de0dce3..dda79c5c 100644 --- a/ver/symbols/symbol_addrs.pal.v77.txt +++ b/ver/symbols/symbol_addrs.pal.v77.txt @@ -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; diff --git a/ver/symbols/symbol_addrs.pal.v80.txt b/ver/symbols/symbol_addrs.pal.v80.txt index d3ee8273..3a472a35 100644 --- a/ver/symbols/symbol_addrs.pal.v80.txt +++ b/ver/symbols/symbol_addrs.pal.v80.txt @@ -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; diff --git a/ver/symbols/symbol_addrs.us.v77.txt b/ver/symbols/symbol_addrs.us.v77.txt index e86b3a28..4189f0e5 100644 --- a/ver/symbols/symbol_addrs.us.v77.txt +++ b/ver/symbols/symbol_addrs.us.v77.txt @@ -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; diff --git a/ver/symbols/symbol_addrs.us.v80.txt b/ver/symbols/symbol_addrs.us.v80.txt index 62426e8b..64408c8c 100644 --- a/ver/symbols/symbol_addrs.us.v80.txt +++ b/ver/symbols/symbol_addrs.us.v80.txt @@ -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;