diff --git a/patches.toml b/patches.toml index 829dc19..c932812 100644 --- a/patches.toml +++ b/patches.toml @@ -5,5 +5,10 @@ elf_path = "patches/patches.elf" output_func_path = "RecompiledPatches" single_file_output = true -# Allow absolute symbols to be used as jump targets +# Allow absolute symbols to be used as jump targets. use_absolute_symbols = true +# Emit R_MIPS_32 relocations so they can be populated when loading the patch overlay. +emit_mips_32_relocs = true +# Point the recompiler at the symbol files so that it can resolve relocations during recompilation. +func_reference_syms_file = "us.rev1.syms.toml" +data_reference_syms_files = [ "us.rev1.datasyms.toml", "us.rev1.datasyms_static.toml" ] diff --git a/patches/Makefile b/patches/Makefile index 21363fe..925dcb5 100644 --- a/patches/Makefile +++ b/patches/Makefile @@ -8,8 +8,8 @@ CFLAGS := -target mips -mips2 -mabi=32 -O2 -G0 -mno-abicalls -mno-odd-spreg -m -fomit-frame-pointer -ffast-math -fno-unsafe-math-optimizations -fno-builtin-memset \ -Wall -Wextra -Wno-incompatible-library-redeclaration -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-variable -Wno-missing-braces -Wno-unsupported-floating-point-opt CPPFLAGS := -nostdinc -D_LANGUAGE_C -DMIPS -I dummy_headers -I ../lib/mm-decomp/include -I ../lib/mm-decomp/src -I ../lib/mm-decomp/assets -I../lib/rt64/include -LDFLAGS := -nostdlib -T patches.ld -T syms.ld --just-symbols=../mm.us.rev1.rom_uncompressed.elf --allow-multiple-definition -Map patches.map -BINFLAGS := -O binary --remove-section=.bss --remove-section=.pad --remove-section=.text +LDFLAGS := -nostdlib -T patches.ld -T syms.ld -Map patches.map --unresolved-symbols=ignore-all --emit-relocs +BINFLAGS := -O binary --only-section=.ctors --only-section=.dtors --only-section=.rodata --only-section=.data C_SRCS := $(wildcard *.c) C_OBJS := $(C_SRCS:.c=.o) diff --git a/patches/camera_patches.c b/patches/camera_patches.c index 2dbffd2..a5c6eda 100644 --- a/patches/camera_patches.c +++ b/patches/camera_patches.c @@ -1911,8 +1911,6 @@ void func_809EC568(Boss04* this, PlayState* play) { f32 y; f32 z; s32 pad; - // @recomp Manual relocation, TODO remove when automated. - u8* D_809EE4D0_relocated = (u8*)actor_relocate(&this->actor, &D_809EE4D0); u16 maxProjectedPosToStartFight; // @recomp Change the maximun projected position to start the fight depending on whether analog camera is enabled or not. @@ -2059,7 +2057,7 @@ void func_809EC568(Boss04* this, PlayState* play) { this->unk_2C8 = 300; this->unk_2D0 = 0.0f; - *D_809EE4D0_relocated = 1; + D_809EE4D0 = 1; this->unk_2E2 = 60; this->unk_2E0 = 93; } diff --git a/patches/cutscene_patches.c b/patches/cutscene_patches.c index 2bbefaa..361022a 100644 --- a/patches/cutscene_patches.c +++ b/patches/cutscene_patches.c @@ -63,17 +63,13 @@ void func_80884718(EnHorse* this, PlayState* play) { } this->cueId = cue->id; - // @recomp Manual relocation, TODO remove when automated. - EnHorseCsFunc* D_808890F0_reloc = actor_relocate(&this->actor, D_808890F0); - if (D_808890F0_reloc[this->cueId] != NULL) { - D_808890F0_reloc[this->cueId](this, play, cue); + if (D_808890F0[this->cueId] != NULL) { + D_808890F0[this->cueId](this, play, cue); } } - // @recomp Manual relocation, TODO remove when automated. - EnHorseCsFunc* D_8088911C_reloc = actor_relocate(&this->actor, D_8088911C); - if (D_8088911C_reloc[this->cueId] != NULL) { - D_8088911C_reloc[this->cueId](this, play, cue); + if (D_8088911C[this->cueId] != NULL) { + D_8088911C[this->cueId](this, play, cue); } } } diff --git a/patches/effect_patches.c b/patches/effect_patches.c index ed064b3..27f3d54 100644 --- a/patches/effect_patches.c +++ b/patches/effect_patches.c @@ -34,12 +34,7 @@ void TransitionWipe3_Draw(void* thisx, Gfx** gfxP) { guScale(modelView, scale, scale, 1.0f); gSPMatrix(gfx++, modelView, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } - // sTransWipe3DL is an overlay symbol, so its addresses need to be offset to get the actual loaded vram address. - // TODO remove this once the recompiler is able to handle overlay symbols automatically for patch functions. - ptrdiff_t reloc_offset; - TransitionOverlay* overlay_entry = &gTransitionOverlayTable[FBDEMO_WIPE3]; - reloc_offset = (uintptr_t)Lib_PhysicalToVirtual(overlay_entry->loadInfo.addr) - (uintptr_t)overlay_entry->vramStart; - gSPDisplayList(gfx++, (Gfx*)((u8*)sTransWipe3DL + reloc_offset)); + gSPDisplayList(gfx++, sTransWipe3DL); gDPPipeSync(gfx++); *gfxP = gfx; } diff --git a/patches/effect_transform_tagging.c b/patches/effect_transform_tagging.c index b33d6c3..405547e 100644 --- a/patches/effect_transform_tagging.c +++ b/patches/effect_transform_tagging.c @@ -178,15 +178,12 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) { spB4 = false; if (this->actor.params == 3) { - // @recomp Manual relocation, TODO remove when the recompiler handles this automatically. - f32* D_808DE5B0_ptr = actor_relocate(thisx, &D_808DE5B0); - temp_f0 = func_80173B48(&play->state) / 1.4e7f; temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); - Math_SmoothStepToF(D_808DE5B0_ptr, temp_f0, 0.2f, 0.1f, 0.001f); + Math_SmoothStepToF(&D_808DE5B0, temp_f0, 0.2f, 0.1f, 0.001f); sp68 = play->envCtx.precipitation[PRECIP_SNOW_CUR]; - sp68 *= *D_808DE5B0_ptr; + sp68 *= D_808DE5B0; if ((play->envCtx.precipitation[PRECIP_SNOW_CUR] >= 32) && (sp68 < 32)) { sp68 = 32; @@ -469,8 +466,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { // Apply the debris effect material if it has not already been applied. if (!isMaterialApplied) { isMaterialApplied++; - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_OPA_DISP++, actor_relocate(thisx, gClearTagDebrisEffectMaterialDL)); + gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectMaterialDL); } // Draw the debris effect. @@ -481,8 +477,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix. gEXMatrixGroupDecomposedNormal(POLY_OPA_DISP++, actor_transform_id(thisx) + i, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_OPA_DISP++, actor_relocate(thisx, gClearTagDebrisEffectDL)); + gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectDL); // @recomp Pop the matrix tag. gEXPopMatrixGroup(POLY_OPA_DISP++, G_MTX_MODELVIEW); } @@ -531,8 +526,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix. gEXMatrixGroupDecomposedNormal(POLY_XLU_DISP++, actor_transform_id(thisx) + i, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagFlashEffectGroundDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectGroundDL); // @recomp Pop the matrix tag. gEXPopMatrixGroup(POLY_XLU_DISP++, G_MTX_MODELVIEW); } @@ -546,8 +540,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { if ((effect->type == CLEAR_TAG_EFFECT_SMOKE) || (effect->type == CLEAR_TAG_EFFECT_ISOLATED_SMOKE)) { // Apply the smoke effect material if it has not already been applied. if (!isMaterialApplied) { - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagFireEffectMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectMaterialDL); isMaterialApplied++; } @@ -566,8 +559,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix. gEXMatrixGroupDecomposedNormal(POLY_XLU_DISP++, actor_transform_id(thisx) + i, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagFireEffectDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); // @recomp Pop the matrix tag. gEXPopMatrixGroup(POLY_XLU_DISP++, G_MTX_MODELVIEW); } @@ -580,8 +572,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { if (effect->type == CLEAR_TAG_EFFECT_FIRE) { // Apply the fire effect material if it has not already been applied. if (!isMaterialApplied) { - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagFireEffectMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); isMaterialApplied++; } @@ -596,8 +587,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix. gEXMatrixGroupDecomposedNormal(POLY_XLU_DISP++, actor_transform_id(thisx) + i, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagFireEffectDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); // @recomp Pop the matrix tag. gEXPopMatrixGroup(POLY_XLU_DISP++, G_MTX_MODELVIEW); } @@ -623,8 +613,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix. gEXMatrixGroupDecomposedNormal(POLY_XLU_DISP++, actor_transform_id(thisx) + i, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagFlashEffectDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectDL); // @recomp Pop the matrix tag. gEXPopMatrixGroup(POLY_XLU_DISP++, G_MTX_MODELVIEW); } @@ -640,8 +629,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, (u8)effect->envColor.r, (u8)effect->envColor.g, (u8)effect->envColor.b, 0); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagLightRayEffectMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectMaterialDL); isMaterialApplied++; } @@ -657,8 +645,7 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix. gEXMatrixGroupDecomposedNormal(POLY_XLU_DISP++, actor_transform_id(thisx) + i, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, actor_relocate(thisx, gClearTagLightRayEffectDL)); + gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectDL); // @recomp Pop the matrix tag. gEXPopMatrixGroup(POLY_XLU_DISP++, G_MTX_MODELVIEW); } diff --git a/patches/fixes.c b/patches/fixes.c index f46bb86..9643b4d 100644 --- a/patches/fixes.c +++ b/patches/fixes.c @@ -73,21 +73,14 @@ s16 KaleidoScope_SetPageVertices(PlayState* play, Vtx* vtx, s16 vtxPage, s16 num cur_y = next_y; } - - // These are overlay symbols, so their addresses need to be offset to get their actual loaded vram address. - // TODO remove this once the recompiler is able to handle overlay symbols automatically for patch functions. - s16** sVtxPageQuadsXRelocated = (s16**)KaleidoManager_GetRamAddr(sVtxPageQuadsX); - s16** sVtxPageQuadsWidthRelocated = (s16**)KaleidoManager_GetRamAddr(sVtxPageQuadsWidth); - s16** sVtxPageQuadsYRelocated = (s16**)KaleidoManager_GetRamAddr(sVtxPageQuadsY); - s16** sVtxPageQuadsHeightRelocated = (s16**)KaleidoManager_GetRamAddr(sVtxPageQuadsHeight); - + s16 k = 60; if (numQuads != 0) { - quadsX = sVtxPageQuadsXRelocated[vtxPage]; - quadsWidth = sVtxPageQuadsWidthRelocated[vtxPage]; - quadsY = sVtxPageQuadsYRelocated[vtxPage]; - quadsHeight = sVtxPageQuadsHeightRelocated[vtxPage]; + quadsX = sVtxPageQuadsX[vtxPage]; + quadsWidth = sVtxPageQuadsWidth[vtxPage]; + quadsY = sVtxPageQuadsY[vtxPage]; + quadsHeight = sVtxPageQuadsHeight[vtxPage]; s16 i; for (i = 0; i < numQuads; i++, k += 4) { @@ -185,10 +178,10 @@ void KaleidoUpdateWrapper(PlayState* play) { void KaleidoDrawWrapper(PlayState* play) { // @recomp Update the background image pointers to reflect the overlay's load address. - bg_pointers[0] = KaleidoManager_GetRamAddr(sMaskPageBgTextures); - bg_pointers[1] = KaleidoManager_GetRamAddr(sItemPageBgTextures); - bg_pointers[2] = KaleidoManager_GetRamAddr(sMapPageBgTextures); - bg_pointers[3] = KaleidoManager_GetRamAddr(sQuestPageBgTextures); + bg_pointers[0] = sMaskPageBgTextures; + bg_pointers[1] = sItemPageBgTextures; + bg_pointers[2] = sMapPageBgTextures; + bg_pointers[3] = sQuestPageBgTextures; KaleidoScope_Draw(play); @@ -202,10 +195,10 @@ void KaleidoDrawWrapper(PlayState* play) { uintptr_t old_segment_0D = gSegments[0x0D]; gSegments[0x08] = OS_K0_TO_PHYSICAL(play->pauseCtx.iconItemSegment); gSegments[0x0D] = OS_K0_TO_PHYSICAL(play->pauseCtx.iconItemLangSegment); - assemble_image(KaleidoManager_GetRamAddr(sMaskPageBgTextures), &bg_images[0]); - assemble_image(KaleidoManager_GetRamAddr(sItemPageBgTextures), &bg_images[1]); - assemble_image(KaleidoManager_GetRamAddr(sMapPageBgTextures), &bg_images[2]); - assemble_image(KaleidoManager_GetRamAddr(sQuestPageBgTextures), &bg_images[3]); + assemble_image(sMaskPageBgTextures, &bg_images[0]); + assemble_image(sItemPageBgTextures, &bg_images[1]); + assemble_image(sMapPageBgTextures, &bg_images[2]); + assemble_image(sQuestPageBgTextures, &bg_images[3]); gSegments[0x08] = old_segment_08; gSegments[0x0D] = old_segment_0D; } @@ -333,18 +326,6 @@ s32 DemoEffect_OverrideLimbDrawTimewarp(PlayState* play, SkelCurve* skelCurve, s return true; } -void* gamestate_relocate(void* addr, GameStateId id) { - GameStateOverlay* ovl = &gGameStateOverlayTable[id]; - if ((uintptr_t)addr >= 0x80800000) { - return (void*)((uintptr_t)addr - - (intptr_t)((uintptr_t)ovl->vramStart - (uintptr_t)ovl->loadedRamAddr)); - } - else { - recomp_printf("Not an overlay address!: 0x%08X 0x%08X 0x%08X\n", (u32)addr, (u32)ovl->vramStart, (u32)ovl->loadedRamAddr); - return addr; - } -} - void DayTelop_Main(GameState* thisx); void DayTelop_Destroy(GameState* thisx); void DayTelop_Noop(DayTelopState* this); @@ -358,9 +339,8 @@ void DayTelop_Init(GameState* thisx) { Matrix_Init(&this->state); ShrinkWindow_Destroy(); View_Init(&this->view, this->state.gfxCtx); - // @recomp Manual relocation, TODO remove when automated. - this->state.main = (GameStateFunc)gamestate_relocate(DayTelop_Main, GAMESTATE_DAYTELOP); - this->state.destroy = (GameStateFunc)gamestate_relocate(DayTelop_Destroy, GAMESTATE_DAYTELOP); + this->state.main = DayTelop_Main; + this->state.destroy = DayTelop_Destroy; // @recomp Add 120 extra frames (2 seconds with a frame divisor of 1) to account for faster loading. this->transitionCountdown = 260; this->fadeInState = DAYTELOP_HOURSTEXT_OFF; diff --git a/patches/input.c b/patches/input.c index 97adfc8..52a321f 100644 --- a/patches/input.c +++ b/patches/input.c @@ -181,9 +181,7 @@ void func_8083A98C(Actor* thisx, PlayState* play2) { Message_StartTextbox(play, (play->sceneId == SCENE_AYASHIISHOP) ? 0x2A00 : 0x5E6, NULL); } } else { - // @recomp Manual relocation, TODO remove when automated. - Input* player_control_input = play->state.input; - *(Input**)KaleidoManager_GetRamAddr(&sPlayerControlInput) = player_control_input; + sPlayerControlInput = play->state.input; if (play->view.fovy >= 25.0f) { s16 prevFocusX = thisx->focus.rot.x; s16 prevFocusY = thisx->focus.rot.y; @@ -193,7 +191,7 @@ void func_8083A98C(Actor* thisx, PlayState* play2) { // @recomp Add in the analog camera Y input. Clamp to prevent moving the camera twice as fast if both sticks are held. // Pitch: - inputY = CLAMP(player_control_input->rel.stick_y + analog_y, -60, 60) * 4; + inputY = CLAMP(sPlayerControlInput->rel.stick_y + analog_y, -60, 60) * 4; // @recomp Invert the Y axis accordingly (default is inverted, so negate if not inverted). if (!inverted_y) { inputY = -inputY; @@ -205,7 +203,7 @@ void func_8083A98C(Actor* thisx, PlayState* play2) { // @recomp Add in the analog camera X input. Clamp to prevent moving the camera twice as fast if both sticks are held. // Yaw: shape.rot.y is used as a fixed starting position - inputX = CLAMP(player_control_input->rel.stick_x + analog_x, -60, 60) * -4; + inputX = CLAMP(sPlayerControlInput->rel.stick_x + analog_x, -60, 60) * -4; // @recomp Invert the X axis accordingly. if (inverted_x) { inputX = -inputX; @@ -229,14 +227,14 @@ void func_8083A98C(Actor* thisx, PlayState* play2) { if (play->sceneId == SCENE_AYASHIISHOP) { camMode = CAM_MODE_DEKUHIDE; - } else if (CHECK_BTN_ALL(player_control_input->cur.button, BTN_A)) { // Zoom + } else if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) { // Zoom camMode = CAM_MODE_TARGET; } else { camMode = CAM_MODE_NORMAL; } // Exit - if (CHECK_BTN_ALL(player_control_input->press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) { Message_CloseTextbox(play); if (play->sceneId == SCENE_00KEIKOKU) { @@ -355,18 +353,15 @@ u8* get_button_item_equip_ptr(u32 form, u32 button) { // Return currently-pressed button, in order of priority D-Pad, B, CLEFT, CDOWN, CRIGHT. EquipSlot func_8082FDC4(void) { EquipSlot i; - - // @recomp Manually relocate, TODO remove this when the recompiler can relocate automatically. - Input* sPlayerControlInput_reloc = *(Input**)KaleidoManager_GetRamAddr(&sPlayerControlInput); for (int extra_slot_index = 0; extra_slot_index < ARRAY_COUNT(buttons_to_extra_slot); extra_slot_index++) { - if (CHECK_BTN_ALL(sPlayerControlInput_reloc->press.button, buttons_to_extra_slot[extra_slot_index].button)) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, buttons_to_extra_slot[extra_slot_index].button)) { return (EquipSlot)buttons_to_extra_slot[extra_slot_index].slot; } } for (i = 0; i < ARRAY_COUNT(sPlayerItemButtons); i++) { - if (CHECK_BTN_ALL(sPlayerControlInput_reloc->press.button, sPlayerItemButtons[i])) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, sPlayerItemButtons[i])) { break; } } @@ -454,8 +449,7 @@ void Player_Action_86(Player *this, PlayState *play) { s32 sp48 = false; func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_MASK_TRANSFORMATION]); - // @recomp Manual relocation, TODO remove when automated. - *(Input**)KaleidoManager_GetRamAddr(&sPlayerControlInput) = play->state.input; + sPlayerControlInput = play->state.input; Camera_ChangeMode(GET_ACTIVE_CAM(play), (this->transformation == PLAYER_FORM_HUMAN) ? CAM_MODE_NORMAL : CAM_MODE_JUMP); @@ -2569,16 +2563,9 @@ s32 func_80857950(PlayState* play, Player* this) { } wasOff = isOff; - // @recomp Manual relocation, TODO remove when automated. - Input* player_control_input = *(Input**)KaleidoManager_GetRamAddr(&sPlayerControlInput); - - if (((this->unk_B86[1] == 0) && !CHECK_BTN_ALL(player_control_input->cur.button, BTN_A)) || + if (((this->unk_B86[1] == 0) && !CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) || ((this->av1.actionVar1 == 3) && (this->actor.velocity.y < 0.0f))) { - - // @recomp Manual relocation, TODO remove when automated. - PlayerActionFunc Player_Action_4_reloc = KaleidoManager_GetRamAddr(Player_Action_4); - Player_SetAction(play, this, Player_Action_4_reloc, 1); - + Player_SetAction(play, this, Player_Action_4, 1); Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pg_maru_change, -2.0f / 3.0f, 7.0f, 0.0f, ANIMMODE_ONCE, 0.0f); @@ -2611,9 +2598,6 @@ extern void func_80836A5C(Player* this, PlayState* play); // @recomp Patch the shielding function to respect the aiming axis inversion setting. void Player_Action_18(Player* this, PlayState* play) { - //@recomp Manual relocation. TODO remove when automated - D_8085BE84_t* D_8085BE84_reloc = (D_8085BE84_t*)KaleidoManager_GetRamAddr(D_8085BE84); - Input* sPlayerControlInput_reloc = *(Input**)KaleidoManager_GetRamAddr(&sPlayerControlInput); func_80832F24(this); if (this->transformation == PLAYER_FORM_GORON) { @@ -2627,7 +2611,7 @@ void Player_Action_18(Player* this, PlayState* play) { func_80123C58(this); } - func_80836A98(this, D_8085BE84_reloc[PLAYER_ANIMGROUP_defense_end][this->modelAnimType], play); + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_defense_end][this->modelAnimType], play); func_80830B38(this); } else { this->stateFlags1 |= PLAYER_STATE1_400000; @@ -2639,7 +2623,7 @@ void Player_Action_18(Player* this, PlayState* play) { if (PlayerAnimation_Update(play, &this->skelAnime)) { if (!Player_IsGoronOrDeku(this)) { - Player_AnimationPlayLoop(play, this, D_8085BE84_reloc[PLAYER_ANIMGROUP_defense_wait][this->modelAnimType]); + Player_AnimationPlayLoop(play, this, D_8085BE84[PLAYER_ANIMGROUP_defense_wait][this->modelAnimType]); } this->av2.actionVar2 = 1; @@ -2656,8 +2640,8 @@ void Player_Action_18(Player* this, PlayState* play) { } if (this->av2.actionVar2 != 0) { - f32 yStick = sPlayerControlInput_reloc->rel.stick_y * 180; - f32 xStick = sPlayerControlInput_reloc->rel.stick_x * -120; + f32 yStick = sPlayerControlInput->rel.stick_y * 180; + f32 xStick = sPlayerControlInput->rel.stick_x * -120; s16 temp_a0 = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); s16 var_a1; s16 temp_ft5; @@ -2717,7 +2701,7 @@ void Player_Action_18(Player* this, PlayState* play) { func_80123C58(this); } - func_80836A98(this, D_8085BE84_reloc[PLAYER_ANIMGROUP_defense_end][this->modelAnimType], play); + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_defense_end][this->modelAnimType], play); } Player_PlaySfx(this, NA_SE_IT_SHIELD_REMOVE); diff --git a/patches/item_transform_tagging.c b/patches/item_transform_tagging.c index 57f183b..900807a 100644 --- a/patches/item_transform_tagging.c +++ b/patches/item_transform_tagging.c @@ -2,13 +2,12 @@ #include "transform_ids.h" #include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h" -// TODO replace these with externs when the recompiler can handle relocations in patches automatically. -Vec3f D_808C1C10 = { 0.0f, 0.0f, 0.0f }; -Vec3f D_808C1C1C = { 0.0f, 0.0f, 900.0f }; -Vec3f D_808C1C28 = { 0.0f, 500.0f, -3000.0f }; -Vec3f D_808C1C34 = { 0.0f, -500.0f, -3000.0f }; -Vec3f D_808C1C40 = { 0.0f, 500.0f, 0.0f }; -Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f }; +extern Vec3f D_808C1C10; +extern Vec3f D_808C1C1C; +extern Vec3f D_808C1C28; +extern Vec3f D_808C1C34; +extern Vec3f D_808C1C40; +extern Vec3f D_808C1C4C; extern Gfx object_link_child_DL_01D960[]; extern Gfx gHookshotChainDL[]; @@ -31,10 +30,7 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - - // @recomp Manually relocate ArmsHook_Shoot because it's an overlay symbol. - // TODO remove this when the recompiler handles relocations in patches automatically. - if (((ArmsHookActionFunc)actor_relocate(thisx, ArmsHook_Shoot) != this->actionFunc) || (this->timer <= 0)) { + if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { Matrix_MultVec3f(&D_808C1C10, &this->unk1E0); Matrix_MultVec3f(&D_808C1C28, &sp5C); Matrix_MultVec3f(&D_808C1C34, &sp50); diff --git a/patches/ocarina_effect_patches.c b/patches/ocarina_effect_patches.c index f7a9637..35d6410 100644 --- a/patches/ocarina_effect_patches.c +++ b/patches/ocarina_effect_patches.c @@ -1010,14 +1010,12 @@ void set_all_vertex_flags() { // Patches the given DL to replace a vertex command at the given position with a branch to the new DL. void patch_ocarina_effect(Actor* actor, Gfx* original_dl, u32 dl_offset, Gfx* override_dl) { - Gfx* reloc_dl = (Gfx*)actor_relocate(actor, original_dl); - set_all_vertex_flags(); // Check if the DL hasn't been patched yet. - if (reloc_dl[dl_offset].words.w0 >> 24 == G_VTX) { + if (original_dl[dl_offset].words.w0 >> 24 == G_VTX) { // Redirect the DL away from the original vertex command and to the override DL. - gSPBranchList(&reloc_dl[dl_offset], override_dl); + gSPBranchList(&original_dl[dl_offset], override_dl); } } @@ -1089,8 +1087,7 @@ void OceffWipe_Draw(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 100, 0, 255, 128); } - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, &sSongOfTimeFrustumMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0 - scroll, scroll * -2, 32, 32, 1, 0 - scroll, scroll * -2, 32, 32)); // @recomp Use the new DL instead of the original. @@ -1144,8 +1141,7 @@ void OceffWipe2_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, sEponaSongFrustumMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, sEponaSongFrustumMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 6, scroll * -6, 64, 64, 1, scroll * -6, 0, 64, 64)); // @recomp Use the new DL instead of the original. @@ -1198,8 +1194,7 @@ void OceffWipe3_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 128); - // @recomp Manual relocation, TODO remove when automated. - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, &sSariaSongFrustrumMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, sSariaSongFrustrumMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, scroll * 12, scroll * -12, 64, 64, 1, scroll * 8, scroll * -8, 64, 64)); // @recomp Use the new DL instead of the original. @@ -1253,17 +1248,16 @@ void OceffWipe4_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - // @recomp Manual relocations, TODO remove when automated. if (this->actor.params == OCEFF_WIPE4_UNUSED) { - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, sScarecrowSongUnusedMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongUnusedMaterialDL); } else { - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, sScarecrowSongMaterialDL)); + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongMaterialDL); } - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, sScarecrowSongModelDL)); + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongModelDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 2, scroll * -2, 32, 64, 1, scroll * -1, scroll, 32, 32)); - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, &sScarecrowSongModelDL[11])); + gSPDisplayList(POLY_XLU_DISP++, &sScarecrowSongModelDL[11]); CLOSE_DISPS(play->state.gfxCtx); } @@ -1339,9 +1333,8 @@ void OceffWipe5_Draw(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[colorIndex], sEnvColors[colorIndex + 1], sEnvColors[colorIndex + 2], 255); - // @recomp Manual relocations, TODO remove when automated. - AnimatedMat_Draw(play, (AnimatedMaterial*)actor_relocate(thisx, gOceff5TexAnim)); - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, gOceff5DL)); + AnimatedMat_Draw(play, gOceff5TexAnim); + gSPDisplayList(POLY_XLU_DISP++, gOceff5DL); CLOSE_DISPS(play->state.gfxCtx); } @@ -1392,9 +1385,8 @@ void OceffWipe6_Draw(Actor* thisx, PlayState* play) { Matrix_RotateXS(0x708, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - // @recomp Manual relocations, TODO remove these when automatic. - AnimatedMat_Draw(play, (AnimatedMaterial*)actor_relocate(thisx, ovl_Oceff_Wipe6_Matanimheader_000338)); - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, gOceff6DL)); + AnimatedMat_Draw(play, ovl_Oceff_Wipe6_Matanimheader_000338); + gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); CLOSE_DISPS(play->state.gfxCtx); } @@ -1443,9 +1435,8 @@ void OceffWipe7_Draw(Actor* thisx, PlayState* play) { Matrix_RotateXS(0x708, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - // @recomp Manual relocations, TODO remove when automated. - AnimatedMat_Draw(play, (AnimatedMaterial*)actor_relocate(thisx, sSongofHealingEffectTexAnim)); - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)actor_relocate(thisx, &sSongOfHealingEffectFrustumDL)); + AnimatedMat_Draw(play, sSongofHealingEffectTexAnim); + gSPDisplayList(POLY_XLU_DISP++, sSongOfHealingEffectFrustumDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/patches/options.c b/patches/options.c index 4273df6..ba89f87 100644 --- a/patches/options.c +++ b/patches/options.c @@ -40,63 +40,22 @@ extern u64 gFileSelCopyButtonENGTex[]; extern u64 gFileSelEraseButtonENGTex[]; extern u64 gFileSelYesButtonENGTex[]; extern u64 gFileSelQuitButtonENGTex[]; - -// TODO extern these when the recompiler handles relocations automatically. -s16 D_80814280[] = { - 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 0, 1, 1, 2, 1, 1, 4, 2, 2, 2, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1, 0, - 1, 1, 1, 2, 2, 2, 2, 2, 3, 2, 2, 4, 3, 2, 4, 1, 2, 2, 1, 1, 2, 2, 3, 2, 2, 0, 2, 2, 2, 0, 3, 1, 0, -}; - -s16 sWindowContentColors[] = { 100, 150, 255 }; - -TexturePtr sFileInfoBoxTextures[] = { - gFileSelFileInfoBox0Tex, gFileSelFileInfoBox1Tex, gFileSelFileInfoBox2Tex, gFileSelFileInfoBox3Tex, - gFileSelFileInfoBox4Tex, gFileSelFileExtraInfoBox0Tex, gFileSelFileExtraInfoBox1Tex, -}; - -TexturePtr sTitleLabels[] = { - gFileSelPleaseSelectAFileENGTex, gFileSelOpenThisFileENGTex, gFileSelCopyWhichFileENGTex, - gFileSelCopyToWhichFileENGTex, gFileSelAreYouSureCopyENGTex, gFileSelFileCopiedENGTex, - gFileSelEraseWhichFileENGTex, gFileSelAreYouSureEraseENGTex, gFileSelFileErasedENGTex, -}; - -TexturePtr sWarningLabels[] = { - gFileSelNoFileToCopyENGTex, gFileSelNoFileToEraseENGTex, gFileSelNoEmptyFileENGTex, - gFileSelFileEmptyENGTex, gFileSelFileInUseENGTex, -}; - -TexturePtr sFileButtonTextures[] = { - gFileSelFile1ButtonENGTex, - gFileSelFile2ButtonENGTex, - gFileSelFile3ButtonENGTex, -}; - -TexturePtr sActionButtonTextures[] = { - gFileSelCopyButtonENGTex, - gFileSelEraseButtonENGTex, - gFileSelYesButtonENGTex, - gFileSelQuitButtonENGTex, -}; - -s16 sFileInfoBoxPartWidths[] = { - 36, 36, 36, 36, 24, 28, 28, -}; - -s16 sWalletFirstDigit[] = { - 1, // tens (Default Wallet) - 0, // hundreds (Adult Wallet) - 0, // hundreds (Giant Wallet) -}; - -s16 D_80814620[] = { 8, 8, 8, 0 }; -s16 D_80814628[] = { 12, 12, 12, 0 }; -s16 D_80814630[] = { 12, 12, 12, 0 }; -s16 D_80814638[] = { - 88, 104, 120, 940, 944, 948, -}; -s16 D_80814644[] = { 88, 104, 120, 944 }; -s16 D_8081464C[] = { 940, 944 }; -s16 D_80814650[] = { 940, 944, 948 }; +extern s16 D_80814280[]; +extern s16 sWindowContentColors[]; +extern TexturePtr sFileInfoBoxTextures[]; +extern TexturePtr sTitleLabels[]; +extern TexturePtr sWarningLabels[]; +extern TexturePtr sFileButtonTextures[]; +extern TexturePtr sActionButtonTextures[]; +extern s16 sFileInfoBoxPartWidths[]; +extern s16 sWalletFirstDigit[]; +extern s16 D_80814620[]; +extern s16 D_80814628[]; +extern s16 D_80814630[]; +extern s16 D_80814638[]; +extern s16 D_80814644[]; +extern s16 D_8081464C[]; +extern s16 D_80814650[]; void FileSelect_Main(GameState* thisx); void FileSelect_InitContext(GameState* thisx); @@ -118,10 +77,8 @@ void FileSelect_Init(GameState* thisx) { 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); + this->state.main = FileSelect_Main; + this->state.destroy = FileSelect_Destroy; FileSelect_InitContext(&this->state); Font_LoadOrderedFont(&this->font); diff --git a/patches/particle_transform_tagging.c b/patches/particle_transform_tagging.c index 0f6a6a1..2afcb20 100644 --- a/patches/particle_transform_tagging.c +++ b/patches/particle_transform_tagging.c @@ -101,7 +101,7 @@ extern Gfx gSunSparkleModelDL[]; extern u8 D_80B23C40[]; extern u8 D_80B23C2C[]; -// @recomp Modified to take the actor as an argument for relocation and to tag firework transforms. +// @recomp Modified to tag firework transforms. void func_80B22FA8_patched(Actor* thisx, EnHanabiStruct* arg0, PlayState* play2) { PlayState* play = play2; GraphicsContext* gfxCtx = play->state.gfxCtx; @@ -119,10 +119,6 @@ void func_80B22FA8_patched(Actor* thisx, EnHanabiStruct* arg0, PlayState* play2) sp53 = 0xFF; - // @recomp Manually relocate, TODO remove when automated by recompiler. - u8* D_80B23C40_relocated = (u8*)actor_relocate(thisx, D_80B23C40); - u8* D_80B23C2C_relocated = (u8*)actor_relocate(thisx, D_80B23C2C); - for (i = 0; i < 400; i++, arg0++) { if (arg0->unk_00 != 1) { continue; @@ -145,18 +141,18 @@ void func_80B22FA8_patched(Actor* thisx, EnHanabiStruct* arg0, PlayState* play2) if (sp53 != arg0->unk_02) { gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40_relocated[arg0->unk_02], D_80B23C40_relocated[arg0->unk_02 + 1], - D_80B23C40_relocated[arg0->unk_02 + 2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], + D_80B23C40[arg0->unk_02 + 2], 255); sp53 = arg0->unk_02; } if (arg0->unk_01 < 6) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C_relocated[arg0->unk_02], D_80B23C2C_relocated[arg0->unk_02 + 1], - D_80B23C2C_relocated[arg0->unk_02 + 2], arg0->unk_01 * 50); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C_relocated[arg0->unk_02], D_80B23C2C_relocated[arg0->unk_02 + 1], - D_80B23C2C_relocated[arg0->unk_02 + 2], 255); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], 255); } gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); @@ -172,7 +168,7 @@ void EnHanabi_Draw(Actor* thisx, PlayState* play) { EnHanabi* this = (EnHanabi*)thisx; Matrix_Push(); - // @recomp Call a modified version of the function that takes the actor for relocation purposes. + // @recomp Call a modified version of the function that takes the actor for tagging purposes. func_80B22FA8_patched(thisx, this->unk_148, play); Matrix_Pop(); } diff --git a/patches/patches.h b/patches/patches.h index 9ad713b..23243ca 100644 --- a/patches/patches.h +++ b/patches/patches.h @@ -63,17 +63,6 @@ int recomp_printf(const char* fmt, ...); float recomp_powf(float, float); -static inline void* actor_relocate(Actor* actor, void* addr) { - if ((uintptr_t)addr >= 0x80800000) { - return (void*)((uintptr_t)addr - - (intptr_t)((uintptr_t)actor->overlayEntry->vramStart - (uintptr_t)actor->overlayEntry->loadedRamAddr)); - } - else { - recomp_printf("Not an overlay address!: 0x%08X 0x%08X 0x%08X\n", (u32)addr, (u32)actor->overlayEntry->vramStart, (u32)actor->overlayEntry->loadedRamAddr); - return addr; - } -} - typedef enum { /* 0 */ PICTO_BOX_STATE_OFF, // Not using the pictograph /* 1 */ PICTO_BOX_STATE_LENS, // Looking through the lens of the pictograph diff --git a/patches/patches.ld b/patches/patches.ld index 6734bab..c3b4839 100644 --- a/patches/patches.ld +++ b/patches/patches.ld @@ -20,6 +20,7 @@ SECTIONS { .pad : { . += 0x1000000; } >extram AT >rom .text : { *(.text*) } >extram AT >rom + .reloc 0 : { *(.reloc*) } .symtab 0 : { *(.symtab) } .strtab 0 : { *(.strtab) } .shstrtab 0 : { *(.shstrtab) } diff --git a/patches/song_transform_tagging.c b/patches/song_transform_tagging.c index 9c9bb8c..2325c8b 100644 --- a/patches/song_transform_tagging.c +++ b/patches/song_transform_tagging.c @@ -29,14 +29,10 @@ void EnTest7_Draw(Actor* thisx, PlayState* play) { if (mtx == NULL) { return; } - // func_80AF31D0 is an overlay symbol, so its addresses need to be offset to get the actual loaded vram address. - // TODO remove this once the recompiler is able to handle overlay symbols automatically for patch functions. - OverrideKeyframeDrawScaled func_80AF31D0_relocated = (OverrideKeyframeDrawScaled)actor_relocate(thisx, func_80AF31D0); - // @recomp Push the matrix group for the song of soaring's wings. gEXMatrixGroupDecomposedNormal(POLY_OPA_DISP++, SOARING_WINGS_TRANSFORM_ID, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_ALLOW); - func_8018450C(play, &this->skeletonInfo, mtx, func_80AF31D0_relocated, NULL, &this->actor); + func_8018450C(play, &this->skeletonInfo, mtx, func_80AF31D0, NULL, &this->actor); // @recomp Pop the wings matrix group. gEXPopMatrixGroup(POLY_OPA_DISP++, G_MTX_MODELVIEW); @@ -180,12 +176,9 @@ void EnTest6_DrawThreeDayResetSoTCutscene(EnTest6* this, PlayState* play) { POLY_OPA_DISP = this->gfx; - // @recomp Manual relocation, TODO remove when automated. - SoTCsAmmoDrops* sSoTCsAmmoDrops_reloc = (SoTCsAmmoDrops*)actor_relocate(&this->actor, sSoTCsAmmoDrops); - for (i = 0; i < ARRAY_COUNT(sSoTCsAmmoDrops); i++) { - if (sSoTCsAmmoDrops_reloc[i].scale > 0.0f) { - sSoTCsAmmoDrops_reloc[i].draw(this, play, &sSoTCsAmmoDrops_reloc[i]); + if (sSoTCsAmmoDrops[i].scale > 0.0f) { + sSoTCsAmmoDrops[i].draw(this, play, &sSoTCsAmmoDrops[i]); } } diff --git a/patches/specific_actor_transform_tagging.c b/patches/specific_actor_transform_tagging.c index 3c4341a..352619e 100644 --- a/patches/specific_actor_transform_tagging.c +++ b/patches/specific_actor_transform_tagging.c @@ -46,17 +46,14 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; - // @recomp Manual relocation, TODO remove this when the recompiler does it automatically. - EnTanron2** D_80BB8458_relocated = (EnTanron2**)actor_relocate(thisx, D_80BB8458); - for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { - D_80BB8458_relocated[i] = NULL; + D_80BB8458[i] = NULL; } found = 0; while (tanron2 != NULL) { if (tanron2->params < 100) { - D_80BB8458_relocated[found] = (EnTanron2*)tanron2; + D_80BB8458[found] = (EnTanron2*)tanron2; found++; } tanron2 = tanron2->next; @@ -64,26 +61,26 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { for (j = 0; j < found - 1; j++) { for (i = 0; i < found - 1; i++) { - if (D_80BB8458_relocated[i + 1] != NULL) { - if (D_80BB8458_relocated[i]->actor.projectedPos.z < D_80BB8458_relocated[i + 1]->actor.projectedPos.z) { - SWAP(EnTanron2*, D_80BB8458_relocated[i], D_80BB8458_relocated[i + 1]); + if (D_80BB8458[i + 1] != NULL) { + if (D_80BB8458[i]->actor.projectedPos.z < D_80BB8458[i + 1]->actor.projectedPos.z) { + SWAP(EnTanron2*, D_80BB8458[i], D_80BB8458[i + 1]); } } } } for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { - if (D_80BB8458_relocated[i] != NULL) { - Matrix_Translate(D_80BB8458_relocated[i]->actor.world.pos.x, D_80BB8458_relocated[i]->actor.world.pos.y, - D_80BB8458_relocated[i]->actor.world.pos.z, MTXMODE_NEW); + if (D_80BB8458[i] != NULL) { + Matrix_Translate(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, + D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(D_80BB8458_relocated[i]->actor.scale.x, D_80BB8458_relocated[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_RotateZS(D_80BB8458_relocated[i]->unk_14A, MTXMODE_APPLY); + Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); - Matrix_RotateZS(-D_80BB8458_relocated[i]->unk_14A, MTXMODE_APPLY); + Matrix_RotateZS(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); // @recomp Tag the transform. - gEXMatrixGroupSimple(POLY_XLU_DISP++, actor_transform_id(&D_80BB8458_relocated[i]->actor) + 0, + gEXMatrixGroupSimple(POLY_XLU_DISP++, actor_transform_id(&D_80BB8458[i]->actor) + 0, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, G_EX_EDIT_NONE); @@ -100,14 +97,11 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); gSPDisplayList(POLY_XLU_DISP++, gWartShadowMaterialDL); - - // @recomp Manual relocation, TODO remove this when the recompiler does it automatically. - Boss04** D_80BB8450_relocated = (Boss04**)actor_relocate(thisx, &D_80BB8450); tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { - Matrix_Translate(tanron2->world.pos.x, (*D_80BB8450_relocated)->actor.floorHeight, tanron2->world.pos.z, MTXMODE_NEW); + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); // @recomp Tag the transform. @@ -136,12 +130,9 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && (tanron2->world.pos.y <= tanron2->floorHeight)) { - Matrix_Translate(tanron2->world.pos.x, (*D_80BB8450_relocated)->actor.floorHeight + 2.0f, tanron2->world.pos.z, + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, MTXMODE_NEW); - - // @recomp Manual relocation, TODO remove this when the recompiler does it automatically. - f32 D_80BB8454_value = *(f32*)actor_relocate(thisx, &D_80BB8454); - Matrix_Scale(D_80BB8454_value, 0.0f, D_80BB8454_value, MTXMODE_APPLY); + Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); // @recomp Tag the transform. gEXMatrixGroupSimple(POLY_XLU_DISP++, actor_transform_id(tanron2) + 2, @@ -732,20 +723,15 @@ void EnOsn_Idle(EnOsn* this, PlayState* play); // @recomp Patched to skip interpolation when the Happy Mask Salesman changes animations. void EnOsn_ChooseAction(EnOsn* this, PlayState* play) { - // @recomp Manually relocate the static symbol. - AnimationInfo* sAnimationInfo = (AnimationInfo*)actor_relocate(&this->actor, sHappyMaskSalesmanAnimationInfo); - u32 isSwitchFlagSet = Flags_GetSwitch(play, 0); this->csId = this->actor.csId; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sHappyMaskSalesmanAnimationInfo, OSN_ANIM_IDLE); if (!isSwitchFlagSet) { - // @recomp No need to relocate as this function is replaced, so the patch compilation will pick the new address. this->actionFunc = EnOsn_HandleCsAction; } else { - // @recomp Manual relocation, TODO remove when automated by the recompiler. - this->actionFunc = (EnOsnActionFunc)actor_relocate(&this->actor, EnOsn_Idle); + this->actionFunc = EnOsn_Idle; } // @recomp Skip interpolation this frame. @@ -854,11 +840,8 @@ void EnOsn_HandleCsAction(EnOsn* this, PlayState* play) { default: this->animIndex = OSN_ANIM_IDLE; break; - } - // @recomp Manually relocate the static symbol. - AnimationInfo* sAnimationInfo = (AnimationInfo*)actor_relocate(&this->actor, sHappyMaskSalesmanAnimationInfo); - - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sHappyMaskSalesmanAnimationInfo, this->animIndex); // @recomp Skip interpolation this frame. actor_set_interpolation_skipped(&this->actor); @@ -981,10 +964,8 @@ void func_80A34B28(ObjEntotu* this, PlayState* play) { this->unk_1B8.x = CLAMP(this->unk_1B8.x, 0.0f, 1.0f); - // @recomp Manual relocation, TODO remove when automated. - Vtx* verts = (Vtx*)actor_relocate(&this->actor, ovl_Obj_Entotu_Vtx_000D10); for (i = 0; i < ARRAY_COUNT(ovl_Obj_Entotu_Vtx_000D10); i++) { - this->unk_148[i].v.cn[3] = verts[i].v.cn[3] * this->unk_1B8.x; + this->unk_148[i].v.cn[3] = ovl_Obj_Entotu_Vtx_000D10[i].v.cn[3] * this->unk_1B8.x; } if (this->unk_1B8.x > 0.0f) { diff --git a/patches/syms.ld b/patches/syms.ld index 3381c18..a0e5d7d 100644 --- a/patches/syms.ld +++ b/patches/syms.ld @@ -1,21 +1,5 @@ __start = 0x80000000; -/* Manual symbol overrides to work around recompiler ambiguity issue (TODO fix this) */ -_ovl_daytelopSegmentOvlEnd = 0x0; -_ovl_kaleido_scopeSegmentTextStart = 0x0; -_ovl_kaleido_scopeSegmentStart = 0x0; -_ovl_daytelopSegmentBssStart = 0x0; -_ovl_daytelopSegmentEnd = 0x0; -_ovl_daytelopSegmentBssEnd = 0x0; - -/* Static symbols that aren't in the elf */ -sSceneEntranceTable = 0x801C5720; -D_808DE5B0 = 0x808DE5B0; -sHappyMaskSalesmanAnimationInfo = 0x80AD22C0; -D_808890F0 = 0x808890F0; -D_8088911C = 0x8088911C; -D_809EE4D0 = 0x809EE4D0; - /* Dummy addresses that get recompiled into function calls */ recomp_puts = 0x8F000000; recomp_exit = 0x8F000004; diff --git a/patches/terrain_transform_tagging.c b/patches/terrain_transform_tagging.c index 3de96a4..6ad6acc 100644 --- a/patches/terrain_transform_tagging.c +++ b/patches/terrain_transform_tagging.c @@ -162,8 +162,7 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x96, 255, 255, 255, 255); - // @recomp Manual relocation, TODO remove when automated. - gSPSegment(POLY_OPA_DISP++, 0x0B, actor_relocate(thisx, gWoodfallSceneryDynamicPoisonWaterVtx)); + gSPSegment(POLY_OPA_DISP++, 0x0B, gWoodfallSceneryDynamicPoisonWaterVtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix to enable vertex interpolation. @@ -178,8 +177,7 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x96, 255, 255, 255, (u8)this->unk_348); - // @recomp Manual relocation, TODO remove when automated. - gSPSegment(POLY_XLU_DISP++, 0x0B, actor_relocate(thisx, gWoodfallSceneryDynamicPoisonWaterVtx)); + gSPSegment(POLY_XLU_DISP++, 0x0B, gWoodfallSceneryDynamicPoisonWaterVtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); // @recomp Tag the matrix to enable vertex interpolation. @@ -235,21 +233,16 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } - // @recomp Manual relocations, TODO remove when automated. - s16 D_80AAAE20_val = *(s16*)actor_relocate(thisx, &D_80AAAE20); - s16 D_80AAAE22_val = *(s16*)actor_relocate(thisx, &D_80AAAE22); - s16 D_80AAAE24_val = *(s16*)actor_relocate(thisx, &D_80AAAE24); - - if (D_80AAAE24_val != 0) { - if ((D_80AAAE22_val > -1800) && (D_80AAAE22_val < 3000)) { - temp_f12 = D_80AAAE22_val - 640.0f; - if ((D_80AAAE20_val == 380) && (D_80AAAE22_val > 640)) { + if (D_80AAAE24 != 0) { + if ((D_80AAAE22 > -1800) && (D_80AAAE22 < 3000)) { + temp_f12 = D_80AAAE22 - 640.0f; + if ((D_80AAAE20 == 380) && (D_80AAAE22 > 640)) { D_80AAAAC0 = 2; D_80AAAAC4 = 0; D_80AAAAC8 = 900; D_80AAAACC = 700; spB7 = true; - if (D_80AAAE22_val < 1350) { + if (D_80AAAE22 < 1350) { f32 temp_f0 = temp_f12 / 2000.0f; D_80AAAAB8 = 420.0f - (420.0f * temp_f0); diff --git a/patches/ui_patches.c b/patches/ui_patches.c index bd299c7..f40387c 100644 --- a/patches/ui_patches.c +++ b/patches/ui_patches.c @@ -540,10 +540,10 @@ void Interface_Draw(PlayState* play) { extern s16 sMaskEquipAnimTimer; extern s16 sEquipState; extern s16 sMaskEquipState; - s16 equip_timer = *(s16*)KaleidoManager_GetRamAddr(&sEquipAnimTimer); - s16 mask_equip_timer = *(s16*)KaleidoManager_GetRamAddr(&sMaskEquipAnimTimer); - s16 equip_state = *(s16*)KaleidoManager_GetRamAddr(&sEquipState); - s16 mask_equip_state = *(s16*)KaleidoManager_GetRamAddr(&sMaskEquipState); + s16 equip_timer = sEquipAnimTimer; + s16 mask_equip_timer = sMaskEquipAnimTimer; + s16 equip_state = sEquipState; + s16 mask_equip_state = sMaskEquipState; s16 timer = MIN(equip_timer, mask_equip_timer); s32 max_timer = 10; diff --git a/patches/ui_transform_tagging.c b/patches/ui_transform_tagging.c index e8a457d..0419223 100644 --- a/patches/ui_transform_tagging.c +++ b/patches/ui_transform_tagging.c @@ -54,14 +54,6 @@ extern TexturePtr sMapPageBgTextures[]; extern TexturePtr sQuestPageBgTextures[]; extern TexturePtr sMaskPageBgTextures[]; -s16 kaleido_s16(s16* addr) { - return *(s16*)KaleidoManager_GetRamAddr(addr); -} - -f32 kaleido_f32(f32* addr) { - return *(f32*)KaleidoManager_GetRamAddr(addr); -} - // @recomp Patched to set pageIndex to a dummy value when KaleidoScope_SetVertices is called to make it // allocate vertices for all pages at all times. This is simpler than patching KaleidoScope_SetVertices directly. void KaleidoScope_Draw(PlayState* play) { @@ -164,9 +156,8 @@ void KaleidoScope_DrawCursor(PlayState* play) { gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - // @recomp manual relocations, TODO remove when recompiler can handle this. - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, kaleido_s16(&sCursorPrimR), kaleido_s16(&sCursorPrimG), kaleido_s16(&sCursorPrimB), 255); - gDPSetEnvColor(POLY_OPA_DISP++, kaleido_s16(&sCursorEnvR), kaleido_s16(&sCursorEnvG), kaleido_s16(&sCursorEnvB), 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sCursorPrimR, sCursorPrimG, sCursorPrimB, 255); + gDPSetEnvColor(POLY_OPA_DISP++, sCursorEnvR, sCursorEnvG, sCursorEnvB, 255); Matrix_Translate(pauseCtx->cursorX, pauseCtx->cursorY, -50.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); @@ -181,8 +172,7 @@ void KaleidoScope_DrawCursor(PlayState* play) { for (i = 0; i < 4; i++) { Matrix_Push(); - // @recomp manual relocations, TODO remove when recompiler can handle this. - Matrix_Translate(kaleido_f32(&sCursorCirclesX[i]), kaleido_f32(&sCursorCirclesY[i]), -50.0f, MTXMODE_APPLY); + Matrix_Translate(sCursorCirclesX[i], sCursorCirclesY[i], -50.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_OPA_DISP++); @@ -242,11 +232,6 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { s16 i; s16 j; - // @recomp Manual relocations, TODO remove when done automatically by the recompiler. - s16* sPauseZRCursorColorTimerInits_reloc = KaleidoManager_GetRamAddr(&sPauseZRCursorColorTimerInits); - TexturePtr* D_8082B998_reloc = KaleidoManager_GetRamAddr(&D_8082B998); - TexturePtr* D_8082B9A8_reloc = KaleidoManager_GetRamAddr(&D_8082B9A8); - OPEN_DISPS(play->state.gfxCtx); stepR = @@ -288,7 +273,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { sPauseZRCursorGreen = sPauseZRCursorColorTargets[sPauseZRCursorColorIndex][1]; sPauseZRCursorBlue = sPauseZRCursorColorTargets[sPauseZRCursorColorIndex][2]; sPauseZRCursorAlpha = sPauseZRCursorColorTargets[sPauseZRCursorColorIndex][3]; - sPauseZRCursorColorTimer = sPauseZRCursorColorTimerInits_reloc[0]; + sPauseZRCursorColorTimer = sPauseZRCursorColorTimerInits[0]; sPauseZRCursorColorIndex ^= 1; } @@ -331,42 +316,42 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { pauseCtx->infoPanelVtx[5].v.ob[0] = pauseCtx->infoPanelVtx[7].v.ob[0] = pauseCtx->infoPanelVtx[4].v.ob[0] + 72; if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { - pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = kaleido_s16(&sPauseCursorLeftX); + pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = sPauseCursorLeftX; pauseCtx->infoPanelVtx[9].v.ob[0] = pauseCtx->infoPanelVtx[11].v.ob[0] = pauseCtx->infoPanelVtx[8].v.ob[0] + 24; - pauseCtx->infoPanelVtx[8].v.ob[1] = pauseCtx->infoPanelVtx[9].v.ob[1] = kaleido_s16(&D_8082B920); + pauseCtx->infoPanelVtx[8].v.ob[1] = pauseCtx->infoPanelVtx[9].v.ob[1] = D_8082B920; pauseCtx->infoPanelVtx[10].v.ob[1] = pauseCtx->infoPanelVtx[11].v.ob[1] = pauseCtx->infoPanelVtx[8].v.ob[1] - 32; } else { - pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = kaleido_s16(&sPauseCursorLeftX) + 3; + pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = sPauseCursorLeftX + 3; pauseCtx->infoPanelVtx[9].v.ob[0] = pauseCtx->infoPanelVtx[11].v.ob[0] = pauseCtx->infoPanelVtx[8].v.ob[0] + 18; - pauseCtx->infoPanelVtx[8].v.ob[1] = pauseCtx->infoPanelVtx[9].v.ob[1] = kaleido_s16(&D_8082B920) - 3; + pauseCtx->infoPanelVtx[8].v.ob[1] = pauseCtx->infoPanelVtx[9].v.ob[1] = D_8082B920 - 3; pauseCtx->infoPanelVtx[10].v.ob[1] = pauseCtx->infoPanelVtx[11].v.ob[1] = pauseCtx->infoPanelVtx[8].v.ob[1] - 26; } if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { - pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = kaleido_s16(&sPauseCursorRightX); + pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = sPauseCursorRightX; pauseCtx->infoPanelVtx[13].v.ob[0] = pauseCtx->infoPanelVtx[15].v.ob[0] = pauseCtx->infoPanelVtx[12].v.ob[0] + 24; - pauseCtx->infoPanelVtx[12].v.ob[1] = pauseCtx->infoPanelVtx[13].v.ob[1] = kaleido_s16(&D_8082B920); + pauseCtx->infoPanelVtx[12].v.ob[1] = pauseCtx->infoPanelVtx[13].v.ob[1] = D_8082B920; pauseCtx->infoPanelVtx[14].v.ob[1] = pauseCtx->infoPanelVtx[15].v.ob[1] = pauseCtx->infoPanelVtx[12].v.ob[1] - 32; } else { - pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = kaleido_s16(&sPauseCursorRightX) + 3; + pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = sPauseCursorRightX + 3; pauseCtx->infoPanelVtx[13].v.ob[0] = pauseCtx->infoPanelVtx[15].v.ob[0] = pauseCtx->infoPanelVtx[12].v.ob[0] + 18; - pauseCtx->infoPanelVtx[12].v.ob[1] = pauseCtx->infoPanelVtx[13].v.ob[1] = kaleido_s16(&D_8082B920) - 3; + pauseCtx->infoPanelVtx[12].v.ob[1] = pauseCtx->infoPanelVtx[13].v.ob[1] = D_8082B920 - 3; pauseCtx->infoPanelVtx[14].v.ob[1] = pauseCtx->infoPanelVtx[15].v.ob[1] = pauseCtx->infoPanelVtx[12].v.ob[1] - 26; @@ -512,10 +497,10 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { POLY_OPA_DISP = - Gfx_DrawTexQuad4b(POLY_OPA_DISP, D_8082B998_reloc[pauseCtx->pageIndex], G_IM_FMT_IA, 128, 16, 0); + Gfx_DrawTexQuad4b(POLY_OPA_DISP, D_8082B998[pauseCtx->pageIndex], G_IM_FMT_IA, 128, 16, 0); } else { POLY_OPA_DISP = - Gfx_DrawTexQuad4b(POLY_OPA_DISP, D_8082B9A8_reloc[pauseCtx->pageIndex], G_IM_FMT_IA, 128, 16, 0); + Gfx_DrawTexQuad4b(POLY_OPA_DISP, D_8082B9A8[pauseCtx->pageIndex], G_IM_FMT_IA, 128, 16, 0); } } } else if ((!pauseCtx->pageIndex || (pauseCtx->pageIndex == PAUSE_MASK)) && @@ -541,7 +526,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); POLY_OPA_DISP = Gfx_DrawTexQuad4b(POLY_OPA_DISP, gPauseToEquipENGTex, G_IM_FMT_IA, 64, 16, 4); - } else if ((pauseCtx->pageIndex == PAUSE_MAP) && kaleido_s16(&sInDungeonScene)) { + } else if ((pauseCtx->pageIndex == PAUSE_MAP) && sInDungeonScene) { // No code in this case } else if ((pauseCtx->pageIndex == PAUSE_QUEST) && (pauseCtx->cursorSlot[PAUSE_QUEST] == QUEST_BOMBERS_NOTEBOOK)) { @@ -608,87 +593,75 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { s16 stepG; s16 stepB; - // @recomp Manual relocation, TODO remove when recompiler handles it automatically. - TexturePtr* sItemPageBgTextures_reloc = KaleidoManager_GetRamAddr(&sItemPageBgTextures); - TexturePtr* sMapPageBgTextures_reloc = KaleidoManager_GetRamAddr(&sMapPageBgTextures); - TexturePtr* sQuestPageBgTextures_reloc = KaleidoManager_GetRamAddr(&sQuestPageBgTextures); - TexturePtr* sMaskPageBgTextures_reloc = KaleidoManager_GetRamAddr(&sMaskPageBgTextures); - s16* sCursorPrimR_reloc = KaleidoManager_GetRamAddr(&sCursorPrimR); - s16* sCursorPrimG_reloc = KaleidoManager_GetRamAddr(&sCursorPrimG); - s16* sCursorPrimB_reloc = KaleidoManager_GetRamAddr(&sCursorPrimB); - s16* sCursorEnvR_reloc = KaleidoManager_GetRamAddr(&sCursorEnvR); - s16* sCursorEnvG_reloc = KaleidoManager_GetRamAddr(&sCursorEnvG); - s16* sCursorEnvB_reloc = KaleidoManager_GetRamAddr(&sCursorEnvB); - OPEN_DISPS(gfxCtx); if (!IS_PAUSE_STATE_GAMEOVER) { if (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) { stepR = - ABS_ALT(*sCursorPrimR_reloc - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) / + ABS_ALT(sCursorPrimR - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) / sCursorColorTimer; stepG = - ABS_ALT(*sCursorPrimG_reloc - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) / + ABS_ALT(sCursorPrimG - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) / sCursorColorTimer; stepB = - ABS_ALT(*sCursorPrimB_reloc - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) / + ABS_ALT(sCursorPrimB - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) / sCursorColorTimer; - if (*sCursorPrimR_reloc >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) { - *sCursorPrimR_reloc -= stepR; + if (sCursorPrimR >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) { + sCursorPrimR -= stepR; } else { - *sCursorPrimR_reloc += stepR; + sCursorPrimR += stepR; } - if (*sCursorPrimG_reloc >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) { - *sCursorPrimG_reloc -= stepG; + if (sCursorPrimG >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) { + sCursorPrimG -= stepG; } else { - *sCursorPrimG_reloc += stepG; + sCursorPrimG += stepG; } - if (*sCursorPrimB_reloc >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) { - *sCursorPrimB_reloc -= stepB; + if (sCursorPrimB >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) { + sCursorPrimB -= stepB; } else { - *sCursorPrimB_reloc += stepB; + sCursorPrimB += stepB; } stepR = - ABS_ALT(*sCursorEnvR_reloc - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) / + ABS_ALT(sCursorEnvR - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) / sCursorColorTimer; stepG = - ABS_ALT(*sCursorEnvG_reloc - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) / + ABS_ALT(sCursorEnvG - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) / sCursorColorTimer; stepB = - ABS_ALT(*sCursorEnvB_reloc - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) / + ABS_ALT(sCursorEnvB - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) / sCursorColorTimer; - if (*sCursorEnvR_reloc >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) { - *sCursorEnvR_reloc -= stepR; + if (sCursorEnvR >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) { + sCursorEnvR -= stepR; } else { - *sCursorEnvR_reloc += stepR; + sCursorEnvR += stepR; } - if (*sCursorEnvG_reloc >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) { - *sCursorEnvG_reloc -= stepG; + if (sCursorEnvG >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) { + sCursorEnvG -= stepG; } else { - *sCursorEnvG_reloc += stepG; + sCursorEnvG += stepG; } - if (*sCursorEnvB_reloc >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) { - *sCursorEnvB_reloc -= stepB; + if (sCursorEnvB >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) { + sCursorEnvB -= stepB; } else { - *sCursorEnvB_reloc += stepB; + sCursorEnvB += stepB; } sCursorColorTimer--; if (sCursorColorTimer == 0) { - *sCursorPrimR_reloc = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]; - *sCursorPrimG_reloc = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]; - *sCursorPrimB_reloc = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]; - *sCursorEnvR_reloc = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]; - *sCursorEnvG_reloc = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]; - *sCursorEnvB_reloc = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]; + sCursorPrimR = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]; + sCursorPrimG = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]; + sCursorPrimB = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]; + sCursorEnvR = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]; + sCursorEnvG = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]; + sCursorEnvB = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]; sCursorColorTargetIndex ^= 1; sCursorColorTimer = 10; } @@ -704,14 +677,13 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(0.0f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->itemPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, sItemPageBgTextures_reloc); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, sItemPageBgTextures); KaleidoScope_DrawItemSelect(play); } @@ -726,16 +698,15 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(-1.57f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures_reloc); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures); - if (kaleido_s16(&sInDungeonScene)) { + if (sInDungeonScene) { KaleidoScope_DrawDungeonMap(play); Gfx_SetupDL42_Opa(gfxCtx); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -757,14 +728,13 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(-3.14f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->questPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, sQuestPageBgTextures_reloc); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, sQuestPageBgTextures); KaleidoScope_DrawQuestStatus(play); } @@ -781,14 +751,13 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(1.57f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->maskPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->maskPageVtx, sMaskPageBgTextures_reloc); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->maskPageVtx, sMaskPageBgTextures); KaleidoScope_DrawMaskSelect(play); } @@ -804,15 +773,14 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(0.0f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->itemPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); POLY_OPA_DISP = - KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, sItemPageBgTextures_reloc); + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, sItemPageBgTextures); KaleidoScope_DrawItemSelect(play); } @@ -827,16 +795,15 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(-1.57f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures_reloc); + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures); - if (kaleido_s16(&sInDungeonScene)) { + if (sInDungeonScene) { KaleidoScope_DrawDungeonMap(play); Gfx_SetupDL42_Opa(gfxCtx); @@ -878,15 +845,14 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); Matrix_RotateYF(-3.14f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->questPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); POLY_OPA_DISP = - KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, sQuestPageBgTextures_reloc); + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, sQuestPageBgTextures); KaleidoScope_DrawQuestStatus(play); break; @@ -900,15 +866,14 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); Matrix_RotateYF(1.57f, MTXMODE_NEW); - // @recomp Manual relocation, TODO remove when automated. - Matrix_Translate(0.0f, kaleido_f32(&sPauseMenuVerticalOffset) / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); Matrix_RotateXFApply(-pauseCtx->maskPageRoll / 100.0f); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); POLY_OPA_DISP = - KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->maskPageVtx, sMaskPageBgTextures_reloc); + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->maskPageVtx, sMaskPageBgTextures); KaleidoScope_DrawMaskSelect(play); break; diff --git a/src/main/rt64_render_context.cpp b/src/main/rt64_render_context.cpp index 497e504..9578251 100644 --- a/src/main/rt64_render_context.cpp +++ b/src/main/rt64_render_context.cpp @@ -268,7 +268,7 @@ zelda64::renderer::RT64Context::RT64Context(uint8_t* rdram, ultramodern::rendere // Check if the selected device actually supports MSAA sample positions and MSAA for for the formats that will be used // and downgrade the configuration accordingly. - if (app->device->getCapabilities().sampleLocations) { + if (true) {//app->device->getCapabilities().sampleLocations) { RT64::RenderSampleCounts color_sample_counts = app->device->getSampleCountsSupported(RT64::RenderFormat::R8G8B8A8_UNORM); RT64::RenderSampleCounts depth_sample_counts = app->device->getSampleCountsSupported(RT64::RenderFormat::D32_FLOAT); RT64::RenderSampleCounts common_sample_counts = color_sample_counts & depth_sample_counts;