From 7392e2ca3b63d2c14acbf5b7e330dbc7ae2dfeed Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Tue, 10 Nov 2020 14:43:24 -0500 Subject: [PATCH] more progress --- asm/nonmatchings/code_135EE0/func_80242BAC.s | 16 +-- asm/nonmatchings/code_135EE0/func_80242D04.s | 24 ++--- .../code_135EE0/pause_interp_cursor.s | 24 ++--- .../code_135EE0/pause_update_cursor.s | 41 -------- .../dro_02/9694C0/func_80240C88_969E48.s | 4 +- .../dro_02/9694C0/func_80241364_96A524.s | 4 +- include/variables.h | 6 +- src/code_135EE0.c | 99 ++++++++++--------- undefined_syms.txt | 6 +- 9 files changed, 99 insertions(+), 125 deletions(-) delete mode 100644 asm/nonmatchings/code_135EE0/pause_update_cursor.s diff --git a/asm/nonmatchings/code_135EE0/func_80242BAC.s b/asm/nonmatchings/code_135EE0/func_80242BAC.s index fe54f18160..eb69024480 100644 --- a/asm/nonmatchings/code_135EE0/func_80242BAC.s +++ b/asm/nonmatchings/code_135EE0/func_80242BAC.s @@ -80,14 +80,14 @@ glabel func_80242BAC /* 135FFC 80242CBC 14400009 */ bnez $v0, .L80242CE4 /* 136000 80242CC0 00000000 */ nop .L80242CC4: -/* 136004 80242CC4 3C018025 */ lui $at, %hi(gPauseMenuTargetPos) -/* 136008 80242CC8 AC31EFA8 */ sw $s1, %lo(gPauseMenuTargetPos)($at) -/* 13600C 80242CCC 3C018025 */ lui $at, %hi(gPauseMenuCursorPos) -/* 136010 80242CD0 AC31EF9C */ sw $s1, %lo(gPauseMenuCursorPos)($at) -/* 136014 80242CD4 3C018025 */ lui $at, 0x8025 -/* 136018 80242CD8 AC33EFAC */ sw $s3, -0x1054($at) -/* 13601C 80242CDC 3C018025 */ lui $at, 0x8025 -/* 136020 80242CE0 AC33EFA0 */ sw $s3, -0x1060($at) +/* 136004 80242CC4 3C018025 */ lui $at, %hi(gPauseMenuTargetPosX) +/* 136008 80242CC8 AC31EFA8 */ sw $s1, %lo(gPauseMenuTargetPosX)($at) +/* 13600C 80242CCC 3C018025 */ lui $at, %hi(gPauseMenuCursorPosX) +/* 136010 80242CD0 AC31EF9C */ sw $s1, %lo(gPauseMenuCursorPosX)($at) +/* 136014 80242CD4 3C018025 */ lui $at, %hi(gPauseMenuTargetPosY) +/* 136018 80242CD8 AC33EFAC */ sw $s3, %lo(gPauseMenuTargetPosY)($at) +/* 13601C 80242CDC 3C018025 */ lui $at, %hi(gPauseMenuCursorPosY) +/* 136020 80242CE0 AC33EFA0 */ sw $s3, %lo(gPauseMenuCursorPosY)($at) .L80242CE4: /* 136024 80242CE4 8FBF0024 */ lw $ra, 0x24($sp) /* 136028 80242CE8 8FB40020 */ lw $s4, 0x20($sp) diff --git a/asm/nonmatchings/code_135EE0/func_80242D04.s b/asm/nonmatchings/code_135EE0/func_80242D04.s index 90ba1238ee..3179810463 100644 --- a/asm/nonmatchings/code_135EE0/func_80242D04.s +++ b/asm/nonmatchings/code_135EE0/func_80242D04.s @@ -66,15 +66,15 @@ glabel func_80242D04 /* 136120 80242DE0 3C018025 */ lui $at, 0x8025 /* 136124 80242DE4 AC20EFB4 */ sw $zero, -0x104c($at) .L80242DE8: -/* 136128 80242DE8 3C018025 */ lui $at, %hi(gPauseMenuTargetPos) -/* 13612C 80242DEC AC32EFA8 */ sw $s2, %lo(gPauseMenuTargetPos)($at) -/* 136130 80242DF0 3C018025 */ lui $at, %hi(gPauseMenuCursorPos) -/* 136134 80242DF4 AC32EF9C */ sw $s2, %lo(gPauseMenuCursorPos)($at) -/* 136138 80242DF8 3C018025 */ lui $at, 0x8025 -/* 13613C 80242DFC AC33EFAC */ sw $s3, -0x1054($at) -/* 136140 80242E00 3C018025 */ lui $at, 0x8025 +/* 136128 80242DE8 3C018025 */ lui $at, %hi(gPauseMenuTargetPosX) +/* 13612C 80242DEC AC32EFA8 */ sw $s2, %lo(gPauseMenuTargetPosX)($at) +/* 136130 80242DF0 3C018025 */ lui $at, %hi(gPauseMenuCursorPosX) +/* 136134 80242DF4 AC32EF9C */ sw $s2, %lo(gPauseMenuCursorPosX)($at) +/* 136138 80242DF8 3C018025 */ lui $at, %hi(gPauseMenuTargetPosY) +/* 13613C 80242DFC AC33EFAC */ sw $s3, %lo(gPauseMenuTargetPosY)($at) +/* 136140 80242E00 3C018025 */ lui $at, %hi(gPauseMenuCursorPosY) /* 136144 80242E04 08090B93 */ j .L80242E4C -/* 136148 80242E08 AC33EFA0 */ sw $s3, -0x1060($at) +/* 136148 80242E08 AC33EFA0 */ sw $s3, %lo(gPauseMenuCursorPosY)($at) .L80242E0C: /* 13614C 80242E0C 92020000 */ lbu $v0, ($s0) /* 136150 80242E10 30420008 */ andi $v0, $v0, 8 @@ -89,10 +89,10 @@ glabel func_80242D04 /* 136174 80242E34 14400005 */ bnez $v0, .L80242E4C /* 136178 80242E38 00000000 */ nop .L80242E3C: -/* 13617C 80242E3C 3C018025 */ lui $at, %hi(gPauseMenuTargetPos) -/* 136180 80242E40 AC32EFA8 */ sw $s2, %lo(gPauseMenuTargetPos)($at) -/* 136184 80242E44 3C018025 */ lui $at, 0x8025 -/* 136188 80242E48 AC33EFAC */ sw $s3, -0x1054($at) +/* 13617C 80242E3C 3C018025 */ lui $at, %hi(gPauseMenuTargetPosX) +/* 136180 80242E40 AC32EFA8 */ sw $s2, %lo(gPauseMenuTargetPosX)($at) +/* 136184 80242E44 3C018025 */ lui $at, %hi(gPauseMenuTargetPosY) +/* 136188 80242E48 AC33EFAC */ sw $s3, %lo(gPauseMenuTargetPosY)($at) .L80242E4C: /* 13618C 80242E4C 8FBF0024 */ lw $ra, 0x24($sp) /* 136190 80242E50 8FB40020 */ lw $s4, 0x20($sp) diff --git a/asm/nonmatchings/code_135EE0/pause_interp_cursor.s b/asm/nonmatchings/code_135EE0/pause_interp_cursor.s index 7511dfa480..8daf0e4558 100644 --- a/asm/nonmatchings/code_135EE0/pause_interp_cursor.s +++ b/asm/nonmatchings/code_135EE0/pause_interp_cursor.s @@ -2,10 +2,10 @@ .set noreorder # don't insert nops after branches glabel pause_interp_cursor -/* 1361AC 80242E6C 3C0A8025 */ lui $t2, %hi(gPauseMenuCursorPos) -/* 1361B0 80242E70 254AEF9C */ addiu $t2, $t2, %lo(gPauseMenuCursorPos) -/* 1361B4 80242E74 3C058025 */ lui $a1, %hi(gPauseMenuTargetPos) -/* 1361B8 80242E78 8CA5EFA8 */ lw $a1, %lo(gPauseMenuTargetPos)($a1) +/* 1361AC 80242E6C 3C0A8025 */ lui $t2, %hi(gPauseMenuCursorPosX) +/* 1361B0 80242E70 254AEF9C */ addiu $t2, $t2, %lo(gPauseMenuCursorPosX) +/* 1361B4 80242E74 3C058025 */ lui $a1, %hi(gPauseMenuTargetPosX) +/* 1361B8 80242E78 8CA5EFA8 */ lw $a1, %lo(gPauseMenuTargetPosX)($a1) /* 1361BC 80242E7C 8D430000 */ lw $v1, ($t2) /* 1361C0 80242E80 3C013FE0 */ lui $at, 0x3fe0 /* 1361C4 80242E84 44812800 */ mtc1 $at, $f5 @@ -16,10 +16,10 @@ glabel pause_interp_cursor /* 1361D8 80242E98 468010A1 */ cvt.d.w $f2, $f2 /* 1361DC 80242E9C 46241082 */ mul.d $f2, $f2, $f4 /* 1361E0 80242EA0 00000000 */ nop -/* 1361E4 80242EA4 3C098025 */ lui $t1, 0x8025 -/* 1361E8 80242EA8 2529EFA0 */ addiu $t1, $t1, -0x1060 -/* 1361EC 80242EAC 3C048025 */ lui $a0, 0x8025 -/* 1361F0 80242EB0 8C84EFAC */ lw $a0, -0x1054($a0) +/* 1361E4 80242EA4 3C098025 */ lui $t1, %hi(gPauseMenuCursorPosY) +/* 1361E8 80242EA8 2529EFA0 */ addiu $t1, $t1, %lo(gPauseMenuCursorPosY) +/* 1361EC 80242EAC 3C048025 */ lui $a0, %hi(gPauseMenuTargetPosY) +/* 1361F0 80242EB0 8C84EFAC */ lw $a0, %lo(gPauseMenuTargetPosY)($a0) /* 1361F4 80242EB4 8D260000 */ lw $a2, ($t1) /* 1361F8 80242EB8 00861023 */ subu $v0, $a0, $a2 /* 1361FC 80242EBC 44820000 */ mtc1 $v0, $f0 @@ -43,13 +43,13 @@ glabel pause_interp_cursor /* 136240 80242F00 AD450000 */ sw $a1, ($t2) /* 136244 80242F04 AD240000 */ sw $a0, ($t1) .L80242F08: -/* 136248 80242F08 3C038025 */ lui $v1, %hi(gPauseMenuCursorPos) -/* 13624C 80242F0C 2463EF9C */ addiu $v1, $v1, %lo(gPauseMenuCursorPos) +/* 136248 80242F08 3C038025 */ lui $v1, %hi(gPauseMenuCursorPosX) +/* 13624C 80242F0C 2463EF9C */ addiu $v1, $v1, %lo(gPauseMenuCursorPosX) /* 136250 80242F10 8C620000 */ lw $v0, ($v1) /* 136254 80242F14 00471021 */ addu $v0, $v0, $a3 /* 136258 80242F18 AC620000 */ sw $v0, ($v1) -/* 13625C 80242F1C 3C038025 */ lui $v1, 0x8025 -/* 136260 80242F20 2463EFA0 */ addiu $v1, $v1, -0x1060 +/* 13625C 80242F1C 3C038025 */ lui $v1, %hi(gPauseMenuCursorPosY) +/* 136260 80242F20 2463EFA0 */ addiu $v1, $v1, %lo(gPauseMenuCursorPosY) /* 136264 80242F24 8C620000 */ lw $v0, ($v1) /* 136268 80242F28 3C048025 */ lui $a0, %hi(gPauseMenuCursorTargetOpacity) /* 13626C 80242F2C 8C84EFB0 */ lw $a0, %lo(gPauseMenuCursorTargetOpacity)($a0) diff --git a/asm/nonmatchings/code_135EE0/pause_update_cursor.s b/asm/nonmatchings/code_135EE0/pause_update_cursor.s deleted file mode 100644 index 464327baf7..0000000000 --- a/asm/nonmatchings/code_135EE0/pause_update_cursor.s +++ /dev/null @@ -1,41 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_update_cursor -/* 13681C 802434DC 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 136820 802434E0 AFB10014 */ sw $s1, 0x14($sp) -/* 136824 802434E4 00A0882D */ daddu $s1, $a1, $zero -/* 136828 802434E8 AFB20018 */ sw $s2, 0x18($sp) -/* 13682C 802434EC 00C0902D */ daddu $s2, $a2, $zero -/* 136830 802434F0 AFBF001C */ sw $ra, 0x1c($sp) -/* 136834 802434F4 0C090B9B */ jal pause_interp_cursor -/* 136838 802434F8 AFB00010 */ sw $s0, 0x10($sp) -/* 13683C 802434FC 3C058025 */ lui $a1, %hi(gPauseMenuCursorOpacity) -/* 136840 80243500 8CA5EFA4 */ lw $a1, %lo(gPauseMenuCursorOpacity)($a1) -/* 136844 80243504 18A00012 */ blez $a1, .L80243550 -/* 136848 80243508 28A20100 */ slti $v0, $a1, 0x100 -/* 13684C 8024350C 50400001 */ beql $v0, $zero, .L80243514 -/* 136850 80243510 240500FF */ addiu $a1, $zero, 0xff -.L80243514: -/* 136854 80243514 3C108027 */ lui $s0, %hi(gPauseMenuCommonIconIDs) -/* 136858 80243518 261000E8 */ addiu $s0, $s0, %lo(gPauseMenuCommonIconIDs) -/* 13685C 8024351C 0C0513AC */ jal icon_set_opacity -/* 136860 80243520 8E040000 */ lw $a0, ($s0) -/* 136864 80243524 8E040000 */ lw $a0, ($s0) -/* 136868 80243528 3C058025 */ lui $a1, %hi(gPauseMenuCursorPos) -/* 13686C 8024352C 8CA5EF9C */ lw $a1, %lo(gPauseMenuCursorPos)($a1) -/* 136870 80243530 3C068025 */ lui $a2, 0x8025 -/* 136874 80243534 8CC6EFA0 */ lw $a2, -0x1060($a2) -/* 136878 80243538 02252821 */ addu $a1, $s1, $a1 -/* 13687C 8024353C 0C051261 */ jal set_icon_render_pos -/* 136880 80243540 02463021 */ addu $a2, $s2, $a2 -/* 136884 80243544 8E040000 */ lw $a0, ($s0) -/* 136888 80243548 0C0511F8 */ jal draw_icon_2 -/* 13688C 8024354C 00000000 */ nop -.L80243550: -/* 136890 80243550 8FBF001C */ lw $ra, 0x1c($sp) -/* 136894 80243554 8FB20018 */ lw $s2, 0x18($sp) -/* 136898 80243558 8FB10014 */ lw $s1, 0x14($sp) -/* 13689C 8024355C 8FB00010 */ lw $s0, 0x10($sp) -/* 1368A0 80243560 03E00008 */ jr $ra -/* 1368A4 80243564 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80240C88_969E48.s b/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80240C88_969E48.s index b04b4d2e2b..773104b695 100644 --- a/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80240C88_969E48.s +++ b/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80240C88_969E48.s @@ -41,8 +41,8 @@ glabel func_80240C88_969E48 .L80240D14: /* 969ED4 80240D14 0C016914 */ jal remove_effect /* 969ED8 80240D18 ACA00018 */ sw $zero, 0x18($a1) -/* 969EDC 80240D1C 3C048025 */ lui $a0, 0x8025 -/* 969EE0 80240D20 8C84EFA0 */ lw $a0, -0x1060($a0) +/* 969EDC 80240D1C 3C048025 */ lui $a0, %hi(gPauseMenuCursorPosY) +/* 969EE0 80240D20 8C84EFA0 */ lw $a0, %lo(gPauseMenuCursorPosY)($a0) /* 969EE4 80240D24 0C048D70 */ jal func_801235C0 /* 969EE8 80240D28 00000000 */ nop /* 969EEC 80240D2C 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80241364_96A524.s b/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80241364_96A524.s index 87ece7f871..f6624d8174 100644 --- a/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80241364_96A524.s +++ b/asm/nonmatchings/world/area_dro/dro_02/9694C0/func_80241364_96A524.s @@ -9,8 +9,8 @@ glabel func_80241364_96A524 /* 96A534 80241374 0C048C8F */ jal bind_dynamic_entity_7 /* 96A538 80241378 0000202D */ daddu $a0, $zero, $zero /* 96A53C 8024137C 8FBF0010 */ lw $ra, 0x10($sp) -/* 96A540 80241380 3C018025 */ lui $at, 0x8025 -/* 96A544 80241384 AC22EFA0 */ sw $v0, -0x1060($at) +/* 96A540 80241380 3C018025 */ lui $at, %hi(gPauseMenuCursorPosY) +/* 96A544 80241384 AC22EFA0 */ sw $v0, %lo(gPauseMenuCursorPosY)($at) /* 96A548 80241388 24020002 */ addiu $v0, $zero, 2 /* 96A54C 8024138C 03E00008 */ jr $ra /* 96A550 80241390 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/include/variables.h b/include/variables.h index b3db69fe8c..161014267a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -131,9 +131,11 @@ extern PauseItemPage gItemMenuPages[20]; extern s32 gPauseMenuStrings[348]; extern s32 gPauseMenuIconScripts[8]; extern MenuTab* gPauseMenuTabs[7]; -extern s32 gPauseMenuCursorPos[2]; +extern s32 gPauseMenuCursorPosX; +extern s32 gPauseMenuCursorPosY; extern s32 gPauseMenuCursorOpacity; -extern s32 gPauseMenuTargetPos[2]; +extern s32 gPauseMenuTargetPosX; +extern s32 gPauseMenuTargetPosY; extern s32 gPauseMenuCursorTargetOpacity; extern u8 gPauseMenuTextScrollInterpEasingLUT[16]; extern u8 gPauseMenuPageScrollInterpEasingLUT[16]; diff --git a/src/code_135EE0.c b/src/code_135EE0.c index 565a40f337..ee427836e6 100644 --- a/src/code_135EE0.c +++ b/src/code_135EE0.c @@ -13,47 +13,58 @@ INCLUDE_ASM(s32, "code_135EE0", func_80242BAC); INCLUDE_ASM(s32, "code_135EE0", func_80242D04); +// Delay slot issue with gPauseMenuCursorTargetOpacity (needs .data) +#ifdef NON_MATCHING +void pause_interp_cursor(void) { + s32* posX = &gPauseMenuCursorPosX; + s32* posY = &gPauseMenuCursorPosY; + s32* targetPosX = &gPauseMenuTargetPosX; + s32* targetPosY = &gPauseMenuTargetPosY; + s32 xDelta; + s32 yDelta; + s32* opacity; + + xDelta = (*targetPosX - *posX) * 0.5; + yDelta = (*targetPosY - *posY) * 0.5; + + if ((*targetPosX != *posX) || (*targetPosY != *posY)) { + if ((xDelta == 0) && (yDelta == 0)) { + *posX = *targetPosX; + *posY = *targetPosY; + } + } + + // Macros? something strange + { + s32* posX = &gPauseMenuCursorPosX; + *posX += xDelta; + } + + { + s32* posY = &gPauseMenuCursorPosY; + *posY += yDelta; + } + + if (gPauseMenuCursorTargetOpacity == 0) { + opacity= &gPauseMenuCursorOpacity; + + *opacity -= 128; + if (*opacity < 0) { + *opacity = 0; + } + } else { + opacity = &gPauseMenuCursorOpacity; + + *opacity += 32; + if (*opacity > 255) { + *opacity = 255; + } + } + gPauseMenuCursorTargetOpacity = 255; +} +#else INCLUDE_ASM(s32, "code_135EE0", pause_interp_cursor); -// void pause_interp_cursor(void) { -// s32 targetPosX; -// s32 posX; -// s32 targetPosY; -// s32 posY; -// s32 xDelta; -// s32 yDelta; -// s32 temp_v0; -// s32 temp_v0_2; - -// targetPosX = gPauseMenuTargetPos[0]; -// posX = gPauseMenuCursorPos[0]; -// targetPosY = gPauseMenuTargetPos[1]; -// posY = gPauseMenuCursorPos[1]; -// xDelta = (targetPosX - posX) * 0.5; -// yDelta = (targetPosY - posY) * 0.5; - -// if ((targetPosX != posX) || (targetPosY != posY)) { -// if ((xDelta == 0) && (yDelta == 0)) { -// gPauseMenuCursorPos[0] = targetPosX; -// gPauseMenuCursorPos[1] = targetPosY; -// } -// } - -// gPauseMenuCursorPos[0] += xDelta; -// gPauseMenuCursorPos[1] += yDelta; - -// if (gPauseMenuCursorTargetOpacity == 0) { -// gPauseMenuCursorOpacity -= 128; -// if (gPauseMenuCursorOpacity < 0) { -// gPauseMenuCursorOpacity = 0; -// } -// } else { -// gPauseMenuCursorOpacity += 32; -// if (gPauseMenuCursorOpacity > 255) { -// gPauseMenuCursorOpacity = 255; -// } -// } -// gPauseMenuCursorTargetOpacity = 255; -// } +#endif INCLUDE_ASM(s32, "code_135EE0", func_80242F90); @@ -106,8 +117,8 @@ s32 pause_interp_vertical_scroll(s32 deltaBefore) { INCLUDE_ASM(s32, "code_135EE0", pause_interp_vertical_scroll); #endif -INCLUDE_ASM(s32, "code_135EE0", pause_update_cursor); -/*void pause_update_cursor(s32 arg0, s32 offsetX, s32 offsetY) { +//INCLUDE_ASM(s32, "code_135EE0", pause_update_cursor); +void pause_update_cursor(s32 arg0, s32 offsetX, s32 offsetY) { s32 opacity; pause_interp_cursor(); @@ -117,10 +128,10 @@ INCLUDE_ASM(s32, "code_135EE0", pause_update_cursor); opacity = 255; } icon_set_opacity(gPauseMenuCommonIconIDs[0], opacity); - set_icon_render_pos(gPauseMenuCommonIconIDs[0], offsetX + gPauseMenuCursorPos[0], offsetY + gPauseMenuCursorPos[1]); + set_icon_render_pos(gPauseMenuCommonIconIDs[0], offsetX + gPauseMenuCursorPosX, offsetY + gPauseMenuCursorPosY); draw_icon_2(gPauseMenuCommonIconIDs[0]); } -}*/ +} void func_80243568(void) { } diff --git a/undefined_syms.txt b/undefined_syms.txt index ec059907f0..347c7102d8 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -148,9 +148,11 @@ gBackgroundImage = 0x80200000; gPauseMenuIconScripts = 0x8024EF60; gPauseMenuTabs = 0x8024EF80; -gPauseMenuCursorPos = 0x8024EF9C; +gPauseMenuCursorPosX = 0x8024EF9C; +gPauseMenuCursorPosY = 0x8024EFA0; gPauseMenuCursorOpacity = 0x8024EFA4; -gPauseMenuTargetPos = 0x8024EFA8; +gPauseMenuTargetPosX = 0x8024EFA8; +gPauseMenuTargetPosY = 0x8024EFAC; gPauseMenuCursorTargetOpacity = 0x8024EFB0; gPauseMenuTextScrollInterpEasingLUT = 0x8024F0AC;