diff --git a/asm/nonmatchings/code_138CC0/pause_badges_count_all.s b/asm/nonmatchings/code_138CC0/pause_badges_count_all.s deleted file mode 100644 index 1cfabf6433..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_count_all.s +++ /dev/null @@ -1,29 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_count_all -/* 13A394 80247054 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 13A398 80247058 AFB00010 */ sw $s0, 0x10($sp) -/* 13A39C 8024705C 3C108011 */ lui $s0, %hi(gPlayerData) -/* 13A3A0 80247060 2610F290 */ addiu $s0, $s0, %lo(gPlayerData) -/* 13A3A4 80247064 260400B4 */ addiu $a0, $s0, 0xb4 -/* 13A3A8 80247068 3C068024 */ lui $a2, %hi(pause_badges_comparator) -/* 13A3AC 8024706C 24C66FE0 */ addiu $a2, $a2, %lo(pause_badges_comparator) -/* 13A3B0 80247070 AFBF0014 */ sw $ra, 0x14($sp) -/* 13A3B4 80247074 0C091293 */ jal pause_sort_item_list -/* 13A3B8 80247078 24050080 */ addiu $a1, $zero, 0x80 -/* 13A3BC 8024707C 0000182D */ daddu $v1, $zero, $zero -.L80247080: -/* 13A3C0 80247080 860200B4 */ lh $v0, 0xb4($s0) -/* 13A3C4 80247084 10400005 */ beqz $v0, .L8024709C -/* 13A3C8 80247088 00000000 */ nop -/* 13A3CC 8024708C 24630001 */ addiu $v1, $v1, 1 -/* 13A3D0 80247090 28620080 */ slti $v0, $v1, 0x80 -/* 13A3D4 80247094 1440FFFA */ bnez $v0, .L80247080 -/* 13A3D8 80247098 26100002 */ addiu $s0, $s0, 2 -.L8024709C: -/* 13A3DC 8024709C 8FBF0014 */ lw $ra, 0x14($sp) -/* 13A3E0 802470A0 8FB00010 */ lw $s0, 0x10($sp) -/* 13A3E4 802470A4 0060102D */ daddu $v0, $v1, $zero -/* 13A3E8 802470A8 03E00008 */ jr $ra -/* 13A3EC 802470AC 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_138CC0/pause_badges_count_equipped.s b/asm/nonmatchings/code_138CC0/pause_badges_count_equipped.s deleted file mode 100644 index 64e295f392..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_count_equipped.s +++ /dev/null @@ -1,29 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_count_equipped -/* 13A3F0 802470B0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 13A3F4 802470B4 AFB00010 */ sw $s0, 0x10($sp) -/* 13A3F8 802470B8 3C108011 */ lui $s0, %hi(gPlayerData) -/* 13A3FC 802470BC 2610F290 */ addiu $s0, $s0, %lo(gPlayerData) -/* 13A400 802470C0 26040208 */ addiu $a0, $s0, 0x208 -/* 13A404 802470C4 3C068024 */ lui $a2, %hi(pause_badges_comparator) -/* 13A408 802470C8 24C66FE0 */ addiu $a2, $a2, %lo(pause_badges_comparator) -/* 13A40C 802470CC AFBF0014 */ sw $ra, 0x14($sp) -/* 13A410 802470D0 0C091293 */ jal pause_sort_item_list -/* 13A414 802470D4 24050040 */ addiu $a1, $zero, 0x40 -/* 13A418 802470D8 0000182D */ daddu $v1, $zero, $zero -.L802470DC: -/* 13A41C 802470DC 86020208 */ lh $v0, 0x208($s0) -/* 13A420 802470E0 10400005 */ beqz $v0, .L802470F8 -/* 13A424 802470E4 00000000 */ nop -/* 13A428 802470E8 24630001 */ addiu $v1, $v1, 1 -/* 13A42C 802470EC 28620040 */ slti $v0, $v1, 0x40 -/* 13A430 802470F0 1440FFFA */ bnez $v0, .L802470DC -/* 13A434 802470F4 26100002 */ addiu $s0, $s0, 2 -.L802470F8: -/* 13A438 802470F8 8FBF0014 */ lw $ra, 0x14($sp) -/* 13A43C 802470FC 8FB00010 */ lw $s0, 0x10($sp) -/* 13A440 80247100 0060102D */ daddu $v0, $v1, $zero -/* 13A444 80247104 03E00008 */ jr $ra -/* 13A448 80247108 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_138CC0/pause_badges_get_pos_x.s b/asm/nonmatchings/code_138CC0/pause_badges_get_pos_x.s deleted file mode 100644 index 0476d5b384..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_get_pos_x.s +++ /dev/null @@ -1,29 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_get_pos_x -/* 13A44C 8024710C 00041040 */ sll $v0, $a0, 1 -/* 13A450 80247110 00441021 */ addu $v0, $v0, $a0 -/* 13A454 80247114 00021080 */ sll $v0, $v0, 2 -/* 13A458 80247118 3C018027 */ lui $at, 0x8027 -/* 13A45C 8024711C 00220821 */ addu $at, $at, $v0 -/* 13A460 80247120 9022028A */ lbu $v0, 0x28a($at) -/* 13A464 80247124 14400002 */ bnez $v0, .L80247130 -/* 13A468 80247128 00A2001A */ div $zero, $a1, $v0 -/* 13A46C 8024712C 0007000D */ break 7 -.L80247130: -/* 13A470 80247130 2401FFFF */ addiu $at, $zero, -1 -/* 13A474 80247134 14410004 */ bne $v0, $at, .L80247148 -/* 13A478 80247138 3C018000 */ lui $at, 0x8000 -/* 13A47C 8024713C 14A10002 */ bne $a1, $at, .L80247148 -/* 13A480 80247140 00000000 */ nop -/* 13A484 80247144 0006000D */ break 6 -.L80247148: -/* 13A488 80247148 00001810 */ mfhi $v1 -/* 13A48C 8024714C 000310C0 */ sll $v0, $v1, 3 -/* 13A490 80247150 00431021 */ addu $v0, $v0, $v1 -/* 13A494 80247154 00021080 */ sll $v0, $v0, 2 -/* 13A498 80247158 00431023 */ subu $v0, $v0, $v1 -/* 13A49C 8024715C 00021080 */ sll $v0, $v0, 2 -/* 13A4A0 80247160 03E00008 */ jr $ra -/* 13A4A4 80247164 00431021 */ addu $v0, $v0, $v1 diff --git a/asm/nonmatchings/code_138CC0/pause_badges_get_pos_y.s b/asm/nonmatchings/code_138CC0/pause_badges_get_pos_y.s deleted file mode 100644 index 64c9d805a5..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_get_pos_y.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_get_pos_y -/* 13A4A8 80247168 3C028027 */ lui $v0, %hi(gBadgeMenuPages) -/* 13A4AC 8024716C 24420288 */ addiu $v0, $v0, %lo(gBadgeMenuPages) -/* 13A4B0 80247170 00041840 */ sll $v1, $a0, 1 -/* 13A4B4 80247174 00641821 */ addu $v1, $v1, $a0 -/* 13A4B8 80247178 00031880 */ sll $v1, $v1, 2 -/* 13A4BC 8024717C 00621821 */ addu $v1, $v1, $v0 -/* 13A4C0 80247180 90620002 */ lbu $v0, 2($v1) -/* 13A4C4 80247184 14400002 */ bnez $v0, .L80247190 -/* 13A4C8 80247188 00A2001A */ div $zero, $a1, $v0 -/* 13A4CC 8024718C 0007000D */ break 7 -.L80247190: -/* 13A4D0 80247190 2401FFFF */ addiu $at, $zero, -1 -/* 13A4D4 80247194 14410004 */ bne $v0, $at, .L802471A8 -/* 13A4D8 80247198 3C018000 */ lui $at, 0x8000 -/* 13A4DC 8024719C 14A10002 */ bne $a1, $at, .L802471A8 -/* 13A4E0 802471A0 00000000 */ nop -/* 13A4E4 802471A4 0006000D */ break 6 -.L802471A8: -/* 13A4E8 802471A8 00002812 */ mflo $a1 -/* 13A4EC 802471AC 24840001 */ addiu $a0, $a0, 1 -/* 13A4F0 802471B0 90630001 */ lbu $v1, 1($v1) -/* 13A4F4 802471B4 00041040 */ sll $v0, $a0, 1 -/* 13A4F8 802471B8 00441021 */ addu $v0, $v0, $a0 -/* 13A4FC 802471BC 00021080 */ sll $v0, $v0, 2 -/* 13A500 802471C0 00441023 */ subu $v0, $v0, $a0 -/* 13A504 802471C4 00031900 */ sll $v1, $v1, 4 -/* 13A508 802471C8 00431021 */ addu $v0, $v0, $v1 -/* 13A50C 802471CC 00052900 */ sll $a1, $a1, 4 -/* 13A510 802471D0 03E00008 */ jr $ra -/* 13A514 802471D4 00451021 */ addu $v0, $v0, $a1 diff --git a/asm/nonmatchings/code_138CC0/pause_badges_get_row.s b/asm/nonmatchings/code_138CC0/pause_badges_get_row.s deleted file mode 100644 index cc5019da62..0000000000 --- a/asm/nonmatchings/code_138CC0/pause_badges_get_row.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel pause_badges_get_row -/* 13A560 80247220 3C038027 */ lui $v1, %hi(gBadgeMenuPages) -/* 13A564 80247224 24630288 */ addiu $v1, $v1, %lo(gBadgeMenuPages) -/* 13A568 80247228 00041040 */ sll $v0, $a0, 1 -/* 13A56C 8024722C 00441021 */ addu $v0, $v0, $a0 -/* 13A570 80247230 00021080 */ sll $v0, $v0, 2 -/* 13A574 80247234 00431021 */ addu $v0, $v0, $v1 -/* 13A578 80247238 90430002 */ lbu $v1, 2($v0) -/* 13A57C 8024723C 14600002 */ bnez $v1, .L80247248 -/* 13A580 80247240 00A3001A */ div $zero, $a1, $v1 -/* 13A584 80247244 0007000D */ break 7 -.L80247248: -/* 13A588 80247248 2401FFFF */ addiu $at, $zero, -1 -/* 13A58C 8024724C 14610004 */ bne $v1, $at, .L80247260 -/* 13A590 80247250 3C018000 */ lui $at, 0x8000 -/* 13A594 80247254 14A10002 */ bne $a1, $at, .L80247260 -/* 13A598 80247258 00000000 */ nop -/* 13A59C 8024725C 0006000D */ break 6 -.L80247260: -/* 13A5A0 80247260 00002812 */ mflo $a1 -/* 13A5A4 80247264 90420001 */ lbu $v0, 1($v0) -/* 13A5A8 80247268 03E00008 */ jr $ra -/* 13A5AC 8024726C 00451021 */ addu $v0, $v0, $a1 diff --git a/include/common_structs.h b/include/common_structs.h index 0c76d0a20b..55c0498715 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1535,7 +1535,7 @@ typedef struct { typedef struct { /* 0x00 */ s8 enabled; - /* 0x01 */ s8 listStart; + /* 0x01 */ u8 listStart; /* 0x02 */ u8 numCols; /* 0x03 */ s8 numRows; /* 0x04 */ s32 startIndex; diff --git a/include/macros.h b/include/macros.h index 20d9536c34..5dc8a24c15 100644 --- a/include/macros.h +++ b/include/macros.h @@ -23,6 +23,8 @@ #define CAM(id) (&gCameras[id]) #define CURRENT_CAM (&gCameras[gCurrentCameraID]) +#define BADGE_MENU_PAGE(index) (&gBadgeMenuPages[index]) + #define MAX_MAPVARS 16 #define MAX_MAPFLAGS 3 diff --git a/src/code_135EE0.c b/src/code_135EE0.c index ee427836e6..7fc2605c1d 100644 --- a/src/code_135EE0.c +++ b/src/code_135EE0.c @@ -117,7 +117,6 @@ 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) { s32 opacity; diff --git a/src/code_138CC0.c b/src/code_138CC0.c index 43e3d02653..0947744d10 100644 --- a/src/code_138CC0.c +++ b/src/code_138CC0.c @@ -17,19 +17,51 @@ void pause_stats_cleanup(void) { INCLUDE_ASM(s32, "code_138CC0", pause_badges_comparator); -INCLUDE_ASM(s32, "code_138CC0", pause_badges_count_all); +s32 pause_badges_count_all(void) { + PlayerData* playerData = PLAYER_DATA; + s32 i; -INCLUDE_ASM(s32, "code_138CC0", pause_badges_count_equipped); + pause_sort_item_list(playerData->badges, ARRAY_COUNT(playerData->badges), &pause_badges_comparator); -INCLUDE_ASM(s32, "code_138CC0", pause_badges_get_pos_x); + for (i = 0; i < ARRAY_COUNT(playerData->badges); i++) { + if (playerData->badges[i] == 0) { + break; + } + } -INCLUDE_ASM(s32, "code_138CC0", pause_badges_get_pos_y); - -s32 pause_badges_get_column(s32 page, s32 itemIdx) { - return itemIdx % gBadgeMenuPages[page].numCols; + return i; } -INCLUDE_ASM(s32, "code_138CC0", pause_badges_get_row); +s32 pause_badges_count_equipped(void) { + PlayerData* playerData = PLAYER_DATA; + s32 i; + + pause_sort_item_list(playerData->equippedBadges, ARRAY_COUNT(playerData->equippedBadges), &pause_badges_comparator); + + for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) { + if (playerData->equippedBadges[i] == 0) { + break; + } + } + + return i; +} + +s32 pause_badges_get_pos_x(s32 page, s32 itemIndex) { + return (itemIndex % BADGE_MENU_PAGE(page)->numCols) * 141; +} + +s32 pause_badges_get_pos_y(s32 page, s32 itemIndex) { + return ((page + 1) * 11) + (BADGE_MENU_PAGE(page)->listStart * 16) + ((itemIndex / BADGE_MENU_PAGE(page)->numCols) * 16); +} + +s32 pause_badges_get_column(s32 page, s32 itemIdx) { + return itemIdx % BADGE_MENU_PAGE(page)->numCols; +} + +s32 pause_badges_get_row(s32 page, s32 itemIdx) { + return BADGE_MENU_PAGE(page)->listStart + (itemIdx / BADGE_MENU_PAGE(page)->numCols); +} s32 pause_badges_is_visible(s32 y) { if (y < gBadgeMenuCurrentScrollPos - 32) {