From 124a5170b7553d4fb2be26f20d9afbe349fbf420 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Thu, 12 Nov 2020 00:18:35 -0500 Subject: [PATCH] more pause decomp --- .../code_138CC0/pause_badges_comparator.s | 39 -------- .../code_138CC0/pause_badges_draw_contents.s | 8 +- .../code_138CC0/pause_badges_handle_input.s | 20 ++--- .../code_138CC0/pause_badges_load_badges.s | 20 ++--- .../code_138CC0/pause_badges_update.s | 90 ------------------- include/common_structs.h | 2 +- include/functions.h | 4 + include/variables.h | 12 ++- src/code_135EE0.c | 4 +- src/code_138CC0.c | 54 ++++++++++- undefined_syms.txt | 11 +++ 11 files changed, 104 insertions(+), 160 deletions(-) delete mode 100644 asm/nonmatchings/code_138CC0/pause_badges_comparator.s delete mode 100644 asm/nonmatchings/code_138CC0/pause_badges_update.s diff --git a/asm/nonmatchings/code_138CC0/pause_badges_comparator.s b/asm/nonmatchings/code_138CC0/pause_badges_comparator.s deleted file mode 100644 index 71523184a5..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_comparator.s +++ /dev/null @@ -1,39 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_comparator -/* 13A320 80246FE0 84820000 */ lh $v0, ($a0) -/* 13A324 80246FE4 14400003 */ bnez $v0, .L80246FF4 -/* 13A328 80246FE8 00021140 */ sll $v0, $v0, 5 -/* 13A32C 80246FEC 08091C00 */ j .L80247000 -/* 13A330 80246FF0 24037FFF */ addiu $v1, $zero, 0x7fff -.L80246FF4: -/* 13A334 80246FF4 3C038008 */ lui $v1, %hi(gItemTable+0x6) -/* 13A338 80246FF8 00621821 */ addu $v1, $v1, $v0 -/* 13A33C 80246FFC 946378E6 */ lhu $v1, %lo(gItemTable+0x6)($v1) -.L80247000: -/* 13A340 80247000 84A20000 */ lh $v0, ($a1) -/* 13A344 80247004 14400003 */ bnez $v0, .L80247014 -/* 13A348 80247008 00021140 */ sll $v0, $v0, 5 -/* 13A34C 8024700C 08091C08 */ j .L80247020 -/* 13A350 80247010 24047FFF */ addiu $a0, $zero, 0x7fff -.L80247014: -/* 13A354 80247014 3C048008 */ lui $a0, %hi(gItemTable+0x6) -/* 13A358 80247018 00822021 */ addu $a0, $a0, $v0 -/* 13A35C 8024701C 948478E6 */ lhu $a0, %lo(gItemTable+0x6)($a0) -.L80247020: -/* 13A360 80247020 00031400 */ sll $v0, $v1, 0x10 -/* 13A364 80247024 00021C03 */ sra $v1, $v0, 0x10 -/* 13A368 80247028 00041400 */ sll $v0, $a0, 0x10 -/* 13A36C 8024702C 00022403 */ sra $a0, $v0, 0x10 -/* 13A370 80247030 10640005 */ beq $v1, $a0, .L80247048 -/* 13A374 80247034 0064182A */ slt $v1, $v1, $a0 -/* 13A378 80247038 14600004 */ bnez $v1, .L8024704C -/* 13A37C 8024703C 2402FFFF */ addiu $v0, $zero, -1 -/* 13A380 80247040 03E00008 */ jr $ra -/* 13A384 80247044 24020001 */ addiu $v0, $zero, 1 -.L80247048: -/* 13A388 80247048 0000102D */ daddu $v0, $zero, $zero -.L8024704C: -/* 13A38C 8024704C 03E00008 */ jr $ra -/* 13A390 80247050 00000000 */ nop diff --git a/asm/nonmatchings/code_138CC0/pause_badges_draw_contents.s b/asm/nonmatchings/code_138CC0/pause_badges_draw_contents.s index 278f61d7a3..3dd1a70d41 100644 --- a/asm/nonmatchings/code_138CC0/pause_badges_draw_contents.s +++ b/asm/nonmatchings/code_138CC0/pause_badges_draw_contents.s @@ -42,8 +42,8 @@ glabel pause_badges_draw_contents /* 13A8DC 8024759C AFA30044 */ sw $v1, 0x44($sp) /* 13A8E0 802475A0 240300F0 */ addiu $v1, $zero, 0xf0 /* 13A8E4 802475A4 AFA30048 */ sw $v1, 0x48($sp) -/* 13A8E8 802475A8 3C038027 */ lui $v1, 0x8027 -/* 13A8EC 802475AC 8C630378 */ lw $v1, 0x378($v1) +/* 13A8E8 802475A8 3C038027 */ lui $v1, %hi(gBadgeMenuSelectedIndex) +/* 13A8EC 802475AC 8C630378 */ lw $v1, %lo(gBadgeMenuSelectedIndex)($v1) /* 13A8F0 802475B0 AFAB0018 */ sw $t3, 0x18($sp) /* 13A8F4 802475B4 15200002 */ bnez $t1, .L802475C0 /* 13A8F8 802475B8 0069001A */ div $zero, $v1, $t1 @@ -1490,8 +1490,8 @@ glabel pause_badges_draw_contents /* 13BE54 80248B14 90430001 */ lbu $v1, 1($v0) /* 13BE58 80248B18 90420002 */ lbu $v0, 2($v0) /* 13BE5C 80248B1C 00620018 */ mult $v1, $v0 -/* 13BE60 80248B20 3C108027 */ lui $s0, 0x8027 -/* 13BE64 80248B24 26100378 */ addiu $s0, $s0, 0x378 +/* 13BE60 80248B20 3C108027 */ lui $s0, %hi(gBadgeMenuSelectedIndex) +/* 13BE64 80248B24 26100378 */ addiu $s0, $s0, %lo(gBadgeMenuSelectedIndex) /* 13BE68 80248B28 8E050000 */ lw $a1, ($s0) /* 13BE6C 80248B2C 00005012 */ mflo $t2 /* 13BE70 80248B30 0C091C43 */ jal pause_badges_get_pos_x diff --git a/asm/nonmatchings/code_138CC0/pause_badges_handle_input.s b/asm/nonmatchings/code_138CC0/pause_badges_handle_input.s index 725d458a3d..79b3ac964b 100644 --- a/asm/nonmatchings/code_138CC0/pause_badges_handle_input.s +++ b/asm/nonmatchings/code_138CC0/pause_badges_handle_input.s @@ -4,8 +4,8 @@ glabel pause_badges_handle_input /* 13C3E8 802490A8 3C038027 */ lui $v1, %hi(gBadgeMenuCurrentPage) /* 13C3EC 802490AC 8C630280 */ lw $v1, %lo(gBadgeMenuCurrentPage)($v1) -/* 13C3F0 802490B0 3C098027 */ lui $t1, 0x8027 -/* 13C3F4 802490B4 8D290378 */ lw $t1, 0x378($t1) +/* 13C3F0 802490B0 3C098027 */ lui $t1, %hi(gBadgeMenuSelectedIndex) +/* 13C3F4 802490B4 8D290378 */ lw $t1, %lo(gBadgeMenuSelectedIndex)($t1) /* 13C3F8 802490B8 27BDFFE0 */ addiu $sp, $sp, -0x20 /* 13C3FC 802490BC AFBF001C */ sw $ra, 0x1c($sp) /* 13C400 802490C0 AFB20018 */ sw $s2, 0x18($sp) @@ -115,8 +115,8 @@ glabel pause_badges_handle_input /* 13C574 80249234 3C018027 */ lui $at, 0x8027 /* 13C578 80249238 AC2003A0 */ sw $zero, 0x3a0($at) .L8024923C: -/* 13C57C 8024923C 3C028027 */ lui $v0, 0x8027 -/* 13C580 80249240 84420384 */ lh $v0, 0x384($v0) +/* 13C57C 8024923C 3C028027 */ lui $v0, %hi(gBadgeMenuNumItems) +/* 13C580 80249240 84420384 */ lh $v0, %lo(gBadgeMenuNumItems)($v0) /* 13C584 80249244 104000B1 */ beqz $v0, .L8024950C /* 13C588 80249248 00000000 */ nop /* 13C58C 8024924C 3C028027 */ lui $v0, 0x8027 @@ -292,8 +292,8 @@ glabel pause_badges_handle_input /* 13C804 802494C4 00220821 */ addu $at, $at, $v0 /* 13C808 802494C8 9022028A */ lbu $v0, 0x28a($at) /* 13C80C 802494CC 00A20018 */ mult $a1, $v0 -/* 13C810 802494D0 3C108027 */ lui $s0, 0x8027 -/* 13C814 802494D4 26100378 */ addiu $s0, $s0, 0x378 +/* 13C810 802494D0 3C108027 */ lui $s0, %hi(gBadgeMenuSelectedIndex) +/* 13C814 802494D4 26100378 */ addiu $s0, $s0, %lo(gBadgeMenuSelectedIndex) /* 13C818 802494D8 00005012 */ mflo $t2 /* 13C81C 802494DC 010A1021 */ addu $v0, $t0, $t2 /* 13C820 802494E0 10490003 */ beq $v0, $t1, .L802494F0 @@ -306,16 +306,16 @@ glabel pause_badges_handle_input /* 13C838 802494F8 3C018027 */ lui $at, %hi(gBadgeMenuItemIDs) /* 13C83C 802494FC 00220821 */ addu $at, $at, $v0 /* 13C840 80249500 84220180 */ lh $v0, %lo(gBadgeMenuItemIDs)($at) -/* 13C844 80249504 3C018027 */ lui $at, 0x8027 -/* 13C848 80249508 AC220380 */ sw $v0, 0x380($at) +/* 13C844 80249504 3C018027 */ lui $at, %hi(gBadgeMenuSelectedItemID) +/* 13C848 80249508 AC220380 */ sw $v0, %lo(gBadgeMenuSelectedItemID)($at) .L8024950C: /* 13C84C 8024950C 3C038027 */ lui $v1, 0x8027 /* 13C850 80249510 8C630398 */ lw $v1, 0x398($v1) /* 13C854 80249514 24020001 */ addiu $v0, $zero, 1 /* 13C858 80249518 14620014 */ bne $v1, $v0, .L8024956C /* 13C85C 8024951C 00000000 */ nop -/* 13C860 80249520 3C038027 */ lui $v1, 0x8027 -/* 13C864 80249524 8C630380 */ lw $v1, 0x380($v1) +/* 13C860 80249520 3C038027 */ lui $v1, %hi(gBadgeMenuSelectedItemID) +/* 13C864 80249524 8C630380 */ lw $v1, %lo(gBadgeMenuSelectedItemID)($v1) /* 13C868 80249528 24628002 */ addiu $v0, $v1, -0x7ffe /* 13C86C 8024952C 2C420002 */ sltiu $v0, $v0, 2 /* 13C870 80249530 1440000A */ bnez $v0, .L8024955C diff --git a/asm/nonmatchings/code_138CC0/pause_badges_load_badges.s b/asm/nonmatchings/code_138CC0/pause_badges_load_badges.s index c01fb56fa6..9100708353 100644 --- a/asm/nonmatchings/code_138CC0/pause_badges_load_badges.s +++ b/asm/nonmatchings/code_138CC0/pause_badges_load_badges.s @@ -8,8 +8,8 @@ glabel pause_badges_load_badges /* 13C0D8 80248D98 3C118011 */ lui $s1, %hi(gPlayerData) /* 13C0DC 80248D9C 2631F290 */ addiu $s1, $s1, %lo(gPlayerData) /* 13C0E0 80248DA0 AFBF0018 */ sw $ra, 0x18($sp) -/* 13C0E4 80248DA4 3C018027 */ lui $at, 0x8027 -/* 13C0E8 80248DA8 AC200388 */ sw $zero, 0x388($at) +/* 13C0E4 80248DA4 3C018027 */ lui $at, %hi(D_80270388) +/* 13C0E8 80248DA8 AC200388 */ sw $zero, %lo(D_80270388)($at) /* 13C0EC 80248DAC 14800014 */ bnez $a0, .L80248E00 /* 13C0F0 80248DB0 0000802D */ daddu $s0, $zero, $zero /* 13C0F4 80248DB4 0200202D */ daddu $a0, $s0, $zero @@ -59,8 +59,8 @@ glabel pause_badges_load_badges /* 13C18C 80248E4C A4220180 */ sh $v0, %lo(gBadgeMenuItemIDs)($at) /* 13C190 80248E50 24100001 */ addiu $s0, $zero, 1 .L80248E54: -/* 13C194 80248E54 3C018027 */ lui $at, 0x8027 -/* 13C198 80248E58 A4300384 */ sh $s0, 0x384($at) +/* 13C194 80248E54 3C018027 */ lui $at, %hi(gBadgeMenuNumItems) +/* 13C198 80248E58 A4300384 */ sh $s0, %lo(gBadgeMenuNumItems)($at) /* 13C19C 80248E5C 0200202D */ daddu $a0, $s0, $zero /* 13C1A0 80248E60 28820080 */ slti $v0, $a0, 0x80 /* 13C1A4 80248E64 1040000A */ beqz $v0, .L80248E90 @@ -79,16 +79,16 @@ glabel pause_badges_load_badges /* 13C1D0 80248E90 3C058027 */ lui $a1, %hi(gBadgeMenuPages) /* 13C1D4 80248E94 24A50288 */ addiu $a1, $a1, %lo(gBadgeMenuPages) /* 13C1D8 80248E98 0000202D */ daddu $a0, $zero, $zero -/* 13C1DC 80248E9C 3C078027 */ lui $a3, 0x8027 -/* 13C1E0 80248EA0 24E70384 */ addiu $a3, $a3, 0x384 +/* 13C1DC 80248E9C 3C078027 */ lui $a3, %hi(gBadgeMenuNumItems) +/* 13C1E0 80248EA0 24E70384 */ addiu $a3, $a3, %lo(gBadgeMenuNumItems) /* 13C1E4 80248EA4 24060001 */ addiu $a2, $zero, 1 /* 13C1E8 80248EA8 24090008 */ addiu $t1, $zero, 8 /* 13C1EC 80248EAC 24080008 */ addiu $t0, $zero, 8 /* 13C1F0 80248EB0 00A81821 */ addu $v1, $a1, $t0 -/* 13C1F4 80248EB4 3C018027 */ lui $at, 0x8027 -/* 13C1F8 80248EB8 AC200378 */ sw $zero, 0x378($at) -/* 13C1FC 80248EBC 3C018027 */ lui $at, 0x8027 -/* 13C200 80248EC0 AC200380 */ sw $zero, 0x380($at) +/* 13C1F4 80248EB4 3C018027 */ lui $at, %hi(gBadgeMenuSelectedIndex) +/* 13C1F8 80248EB8 AC200378 */ sw $zero, %lo(gBadgeMenuSelectedIndex)($at) +/* 13C1FC 80248EBC 3C018027 */ lui $at, %hi(gBadgeMenuSelectedItemID) +/* 13C200 80248EC0 AC200380 */ sw $zero, %lo(gBadgeMenuSelectedItemID)($at) /* 13C204 80248EC4 3C018027 */ lui $at, 0x8027 /* 13C208 80248EC8 AC20037C */ sw $zero, 0x37c($at) /* 13C20C 80248ECC 3C018027 */ lui $at, 0x8027 diff --git a/asm/nonmatchings/code_138CC0/pause_badges_update.s b/asm/nonmatchings/code_138CC0/pause_badges_update.s deleted file mode 100644 index 13f8001375..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_update.s +++ /dev/null @@ -1,90 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_update -/* 13C95C 8024961C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 13C960 80249620 3C038027 */ lui $v1, %hi(gBadgeMenuCurrentPage) -/* 13C964 80249624 8C630280 */ lw $v1, %lo(gBadgeMenuCurrentPage)($v1) -/* 13C968 80249628 3C048027 */ lui $a0, %hi(gBadgeMenuPages) -/* 13C96C 8024962C 24840288 */ addiu $a0, $a0, %lo(gBadgeMenuPages) -/* 13C970 80249630 AFBF0014 */ sw $ra, 0x14($sp) -/* 13C974 80249634 AFB00010 */ sw $s0, 0x10($sp) -/* 13C978 80249638 00031040 */ sll $v0, $v1, 1 -/* 13C97C 8024963C 00431021 */ addu $v0, $v0, $v1 -/* 13C980 80249640 00021080 */ sll $v0, $v0, 2 -/* 13C984 80249644 00443021 */ addu $a2, $v0, $a0 -/* 13C988 80249648 90C30002 */ lbu $v1, 2($a2) -/* 13C98C 8024964C 3C028027 */ lui $v0, 0x8027 -/* 13C990 80249650 8C420378 */ lw $v0, 0x378($v0) -/* 13C994 80249654 14600002 */ bnez $v1, .L80249660 -/* 13C998 80249658 0043001A */ div $zero, $v0, $v1 -/* 13C99C 8024965C 0007000D */ break 7 -.L80249660: -/* 13C9A0 80249660 2401FFFF */ addiu $at, $zero, -1 -/* 13C9A4 80249664 14610004 */ bne $v1, $at, .L80249678 -/* 13C9A8 80249668 3C018000 */ lui $at, 0x8000 -/* 13C9AC 8024966C 14410002 */ bne $v0, $at, .L80249678 -/* 13C9B0 80249670 00000000 */ nop -/* 13C9B4 80249674 0006000D */ break 6 -.L80249678: -/* 13C9B8 80249678 00001012 */ mflo $v0 -/* 13C9BC 8024967C 90C30001 */ lbu $v1, 1($a2) -/* 13C9C0 80249680 00432023 */ subu $a0, $v0, $v1 -/* 13C9C4 80249684 28820002 */ slti $v0, $a0, 2 -/* 13C9C8 80249688 14400005 */ bnez $v0, .L802496A0 -/* 13C9CC 8024968C 00000000 */ nop -/* 13C9D0 80249690 90C20003 */ lbu $v0, 3($a2) -/* 13C9D4 80249694 2C420009 */ sltiu $v0, $v0, 9 -/* 13C9D8 80249698 10400005 */ beqz $v0, .L802496B0 -/* 13C9DC 8024969C 00000000 */ nop -.L802496A0: -/* 13C9E0 802496A0 3C018027 */ lui $at, 0x8027 -/* 13C9E4 802496A4 AC200394 */ sw $zero, 0x394($at) -/* 13C9E8 802496A8 080925BF */ j .L802496FC -/* 13C9EC 802496AC 00000000 */ nop -.L802496B0: -/* 13C9F0 802496B0 90C30003 */ lbu $v1, 3($a2) -/* 13C9F4 802496B4 2462FFFE */ addiu $v0, $v1, -2 -/* 13C9F8 802496B8 0082102A */ slt $v0, $a0, $v0 -/* 13C9FC 802496BC 14400005 */ bnez $v0, .L802496D4 -/* 13CA00 802496C0 2462FFF8 */ addiu $v0, $v1, -8 -/* 13CA04 802496C4 3C018027 */ lui $at, 0x8027 -/* 13CA08 802496C8 AC220394 */ sw $v0, 0x394($at) -/* 13CA0C 802496CC 080925BF */ j .L802496FC -/* 13CA10 802496D0 00000000 */ nop -.L802496D4: -/* 13CA14 802496D4 3C058027 */ lui $a1, 0x8027 -/* 13CA18 802496D8 24A50394 */ addiu $a1, $a1, 0x394 -/* 13CA1C 802496DC 8CA20000 */ lw $v0, ($a1) -/* 13CA20 802496E0 00821823 */ subu $v1, $a0, $v0 -/* 13CA24 802496E4 28620007 */ slti $v0, $v1, 7 -/* 13CA28 802496E8 10400003 */ beqz $v0, .L802496F8 -/* 13CA2C 802496EC 2482FFFA */ addiu $v0, $a0, -6 -/* 13CA30 802496F0 1C600002 */ bgtz $v1, .L802496FC -/* 13CA34 802496F4 2482FFFF */ addiu $v0, $a0, -1 -.L802496F8: -/* 13CA38 802496F8 ACA20000 */ sw $v0, ($a1) -.L802496FC: -/* 13CA3C 802496FC 90C20002 */ lbu $v0, 2($a2) -/* 13CA40 80249700 3C058027 */ lui $a1, 0x8027 -/* 13CA44 80249704 8CA50394 */ lw $a1, 0x394($a1) -/* 13CA48 80249708 00A20018 */ mult $a1, $v0 -/* 13CA4C 8024970C 3C048027 */ lui $a0, %hi(gBadgeMenuCurrentPage) -/* 13CA50 80249710 8C840280 */ lw $a0, %lo(gBadgeMenuCurrentPage)($a0) -/* 13CA54 80249714 00002812 */ mflo $a1 -/* 13CA58 80249718 0C091C5A */ jal pause_badges_get_pos_y -/* 13CA5C 8024971C 00000000 */ nop -/* 13CA60 80249720 3C108027 */ lui $s0, %hi(gBadgeMenuCurrentScrollPos) -/* 13CA64 80249724 2610038C */ addiu $s0, $s0, %lo(gBadgeMenuCurrentScrollPos) -/* 13CA68 80249728 8E040000 */ lw $a0, ($s0) -/* 13CA6C 8024972C 3C018027 */ lui $at, %hi(gBadgeMenuTargetScrollPos) -/* 13CA70 80249730 AC220390 */ sw $v0, %lo(gBadgeMenuTargetScrollPos)($at) -/* 13CA74 80249734 0C090D1B */ jal pause_interp_vertical_scroll -/* 13CA78 80249738 00442023 */ subu $a0, $v0, $a0 -/* 13CA7C 8024973C 8E030000 */ lw $v1, ($s0) -/* 13CA80 80249740 00621821 */ addu $v1, $v1, $v0 -/* 13CA84 80249744 AE030000 */ sw $v1, ($s0) -/* 13CA88 80249748 8FBF0014 */ lw $ra, 0x14($sp) -/* 13CA8C 8024974C 8FB00010 */ lw $s0, 0x10($sp) -/* 13CA90 80249750 03E00008 */ jr $ra -/* 13CA94 80249754 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/include/common_structs.h b/include/common_structs.h index 55c0498715..1a9f77a631 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1537,7 +1537,7 @@ typedef struct { /* 0x00 */ s8 enabled; /* 0x01 */ u8 listStart; /* 0x02 */ u8 numCols; - /* 0x03 */ s8 numRows; + /* 0x03 */ u8 numRows; /* 0x04 */ s32 startIndex; /* 0x08 */ s32 count; } PauseItemPage; // size = 0xC diff --git a/include/functions.h b/include/functions.h index ecbedf85a7..8681adcc8f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -79,6 +79,10 @@ s32 func_800EB168(s32); PlayerData* get_player_data(void); +// Pause +s32 pause_interp_vertical_scroll(s32 deltaBefore); +void pause_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileDescriptor, s32 uls, s32 ult, s32 dsdx, s32 dtdy); + // Partner void func_800EBA3C(Npc* partner); void func_800EBB40(Npc* partner); diff --git a/include/variables.h b/include/variables.h index 161014267a..e18ae7a35d 100644 --- a/include/variables.h +++ b/include/variables.h @@ -141,11 +141,21 @@ extern u8 gPauseMenuTextScrollInterpEasingLUT[16]; extern u8 gPauseMenuPageScrollInterpEasingLUT[16]; // Badges -extern PauseItemPage gBadgeMenuPages[20]; extern s32 gBadgeMenuCurrentScrollPos; extern s32 gBadgeMenuTargetScrollPos; extern ItemId gBadgeMenuItemIDs[128]; extern s32 gBadgeMenuCurrentPage; +extern PauseItemPage gBadgeMenuPages[20]; +extern s32 gBadgeMenuSelectedIndex; +extern s32 gBadgeMenuSelectedItemID; +extern s16 gBadgeMenuNumItems; +extern s32 D_80270388; +extern s32 D_80270394; +extern s32 gBadgeMenuLevel; +extern s32 gBadgeMenuCurrentTab; +extern s32 gBadgeMenuBShowNotEnoughBP; +extern s32 D_802703A4; +extern s32 D_802703A8; // Stats extern s32 gStatsMenuIconIDs[12]; diff --git a/src/code_135EE0.c b/src/code_135EE0.c index 90f19f5fc9..b04277de28 100644 --- a/src/code_135EE0.c +++ b/src/code_135EE0.c @@ -114,7 +114,7 @@ s32 pause_interp_vertical_scroll(s32 deltaBefore) { return val * s; } #else -INCLUDE_ASM(s32, "code_135EE0", pause_interp_vertical_scroll); +INCLUDE_ASM(s32, "code_135EE0", pause_interp_vertical_scroll, s32 deltaBefore); #endif void pause_update_cursor(s32 arg0, s32 offsetX, s32 offsetY) { @@ -149,7 +149,7 @@ INCLUDE_ASM(s32, "code_135EE0", pause_cleanup); INCLUDE_ASM(s32, "code_135EE0", pause_get_total_equipped_bp_cost); -INCLUDE_ASM(s32, "code_135EE0", pause_draw_rect); +INCLUDE_ASM(void, "code_135EE0", pause_draw_rect, s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileDescriptor, s32 uls, s32 ult, s32 dsdx, s32 dtdy); INCLUDE_ASM(s32, "code_135EE0", pause_sort_item_list); diff --git a/src/code_138CC0.c b/src/code_138CC0.c index 4818d3286c..a41cb78856 100644 --- a/src/code_138CC0.c +++ b/src/code_138CC0.c @@ -15,13 +15,36 @@ void pause_stats_cleanup(void) { } } -INCLUDE_ASM(s32, "code_138CC0", pause_badges_comparator); +s32 pause_badges_comparator(s16* a, s16* b) { + s16 aVal; + s16 bVal; + + if (*a == 0) { + aVal = ~0x8000; + } else { + aVal = gItemTable[*a].badgeSortPriority; + } + + if (*b == 0) { + bVal = ~0x8000; + } else { + bVal = gItemTable[*b].badgeSortPriority; + } + + if (aVal == bVal) { + return 0; + } else if (aVal < bVal) { + return -1; + } else { + return 1; + } +} s32 pause_badges_count_all(void) { PlayerData* playerData = PLAYER_DATA; s32 i; - pause_sort_item_list(playerData->badges, ARRAY_COUNT(playerData->badges), &pause_badges_comparator); + pause_sort_item_list(playerData->badges, ARRAY_COUNT(playerData->badges), pause_badges_comparator); for (i = 0; i < ARRAY_COUNT(playerData->badges); i++) { if (playerData->badges[i] == 0) { @@ -94,6 +117,31 @@ INCLUDE_ASM(s32, "code_138CC0", pause_badges_init); INCLUDE_ASM(s32, "code_138CC0", pause_badges_handle_input); -INCLUDE_ASM(s32, "code_138CC0", pause_badges_update); +void pause_badges_update(void) { + PauseItemPage* menuPages = gBadgeMenuPages; + PauseItemPage* currentMenuPage = &menuPages[gBadgeMenuCurrentPage]; + s32 temp = (gBadgeMenuSelectedIndex / currentMenuPage->numCols) - currentMenuPage->listStart; + s32* currentScrollPos; + + if ((temp < 2) || currentMenuPage->numRows < 9) { + D_80270394 = 0; + } else if (temp >= currentMenuPage->numRows - 2) { + D_80270394 = currentMenuPage->numRows - 8; + } else { + s32* unkSym = &D_80270394; + + if (temp - *unkSym >= 7) { + *unkSym = temp - 6; + } else { + if (temp - *unkSym <= 0) { + *unkSym = temp - 1; + } + } + } + + currentScrollPos = &gBadgeMenuCurrentScrollPos; + gBadgeMenuTargetScrollPos = pause_badges_get_pos_y(gBadgeMenuCurrentPage, D_80270394 * currentMenuPage->numCols); + *currentScrollPos += pause_interp_vertical_scroll(gBadgeMenuTargetScrollPos - *currentScrollPos); +} INCLUDE_ASM(s32, "code_138CC0", pause_badges_cleanup); diff --git a/undefined_syms.txt b/undefined_syms.txt index 347c7102d8..d0b1dfad47 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -170,8 +170,19 @@ gStatsMenuIconIDs = 0x80270150; gBadgeMenuItemIDs = 0x80270180; gBadgeMenuCurrentPage = 0x80270280; gBadgeMenuPages = 0x80270288; +gBadgeMenuSelectedIndex = 0x80270378; +gBadgeMenuSelectedItemID = 0x80270380; +gBadgeMenuNumItems = 0x80270384; +D_80270388 = 0x80270388; gBadgeMenuCurrentScrollPos = 0x8027038C; gBadgeMenuTargetScrollPos = 0x80270390; +D_80270394 = 0x80270394; +gBadgeMenuLevel = 0x80270398; +gBadgeMenuCurrentTab = 0x8027039C; +gBadgeMenuBShowNotEnoughBP = 0x802703A0; +D_802703A4 = 0x802703A4; +D_802703A8 = 0x802703A8; + gPauseItemPages = 0x802704D0; D_802C3000 = 0x802C3000;