From cf8f817af2dd3f5b1cc7f8cb79d1b0fc2666d6fb Mon Sep 17 00:00:00 2001 From: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> Date: Sat, 4 Dec 2021 09:23:12 -0500 Subject: [PATCH] Match check_for_ispy and check_for_pulse_stone (#544) * Match check_for_ispy * Delete check_for_ispy.s * Match check_for_pulse_stone * Delete check_for_pulse_stone.s * Update 77480.c * Update 77480.c * Update variables.h * Update variables.h --- include/variables.h | 2 +- src/77480.c | 67 +++++++++++---- .../asm/nonmatchings/77480/check_for_ispy.s | 46 ---------- .../77480/check_for_pulse_stone.s | 86 ------------------- 4 files changed, 50 insertions(+), 151 deletions(-) delete mode 100644 ver/us/asm/nonmatchings/77480/check_for_ispy.s delete mode 100644 ver/us/asm/nonmatchings/77480/check_for_pulse_stone.s diff --git a/include/variables.h b/include/variables.h index a1a3bb8691..98162637df 100644 --- a/include/variables.h +++ b/include/variables.h @@ -278,7 +278,7 @@ extern s32 D_801083D8; extern s32 D_80108068; extern s32 D_80104BEC; -extern s32 D_8010C920; +extern UNK_FUN_PTR(D_8010C920); extern s32 D_8010C940; extern Entity* D_8010C954; extern s32 D_8010C958; diff --git a/src/77480.c b/src/77480.c index e8f156e857..7effeb270d 100644 --- a/src/77480.c +++ b/src/77480.c @@ -1,14 +1,19 @@ #include "common.h" #include "ld_addrs.h" -extern s32 D_8010C920; +#define E21870_VRAM_DEF 0x802B7000 +#define E225B0_VRAM_DEF 0x802B7000 + +extern UNK_FUN_PTR(D_8010C920); extern UNK_FUN_PTR(D_8010C93C); extern s32 D_8010C940; extern s32 D_8010C950; extern s32 D_8010C958; extern s32 D_802BDF60; +extern s8 D_8015A57A; +s32 func_802B7140(void); void func_802B72C0_E22870(void); s32 func_800E0208(void); @@ -492,30 +497,20 @@ void player_render_interact_prompts(void) { func_800E0330(); } -// Weird control flow / issue with loading linker addrs -#ifdef NON_EQUIVALENT -extern s8 D_8015A57A; void check_for_ispy(void) { PlayerStatus* playerStatus = &gPlayerStatus; - if (D_8015A57A != 0) { - if (D_8010C93C == 0) { - if (!(playerStatus->animFlags & 0x30)) { - dma_copy(E225B0_ROM_START, E225B0_ROM_END, E225B0_VRAM); - D_8010C93C = func_802B72C0_E22870; - } - } if (D_8010C93C == 0) { - return; + if (D_8015A57A != 0 && D_8010C93C == NULL) { + if (!(playerStatus->animFlags & 0x30)) { + dma_copy(E225B0_ROM_START, E225B0_ROM_END, E225B0_VRAM_DEF); + D_8010C93C = func_802B72C0_E22870; } } - if (D_8010C93C != 0) { + + if (D_8010C93C != NULL) { D_8010C93C(); } } -#else -INCLUDE_ASM(s32, "77480", check_for_ispy); -#endif - void func_800E0330(void) { if ((gPlayerStatusPtr->animFlags & PLAYER_STATUS_ANIM_FLAGS_100) && (D_8010C93C != NULL)) { func_802B7000_E225B0(); @@ -527,7 +522,43 @@ void func_800E0374(void) { gPlayerStatusPtr->animFlags &= ~PLAYER_STATUS_ANIM_FLAGS_100; } -INCLUDE_ASM(s32, "77480", check_for_pulse_stone); +void check_for_pulse_stone(void) { + PlayerStatus* playerStatus = &gPlayerStatus; + s32 dx, dy; + + if (D_8010C920 == NULL) { + if (gPlayerStatus.animFlags & PLAYER_STATUS_ANIM_FLAGS_100) { + return; + } + + if (gGameStatusPtr->areaID != AREA_SBK || gGameStatusPtr->isBattle) { + return; + } + + dx = abs(gGameStatusPtr->mapID % 7 - 2); + dy = gGameStatusPtr->mapID / 7; + if ((dx + dy) > 5) { + return; + } + + if (!(gPlayerStatus.animFlags & (PLAYER_STATUS_ANIM_FLAGS_USING_PULSE_STONE | PLAYER_STATUS_ANIM_FLAGS_40))) { + return; + } + + if (gPlayerStatus.flags & 0x20 || gPlayerStatus.statusMenuCounterinputEnabledCounter) { + return; + } + + if (!(gPlayerStatus.animFlags & (PLAYER_STATUS_ANIM_FLAGS_SPEECH_PROMPT_AVAILABLE | PLAYER_STATUS_ANIM_FLAGS_INTERACT_PROMPT_AVAILABLE))) { + dma_copy(E21870_ROM_START, E21870_ROM_END, E21870_VRAM_DEF); + D_8010C920 = &func_802B7140; + } + } + + if (D_8010C920 != NULL) { + D_8010C920(); + } +} void func_800E04D0(void) { if ((gPlayerStatusPtr->animFlags & 0x40) && (D_8010C920 != 0)) { diff --git a/ver/us/asm/nonmatchings/77480/check_for_ispy.s b/ver/us/asm/nonmatchings/77480/check_for_ispy.s deleted file mode 100644 index b6f7c30864..0000000000 --- a/ver/us/asm/nonmatchings/77480/check_for_ispy.s +++ /dev/null @@ -1,46 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel check_for_ispy -/* 79744 800E0294 3C028016 */ lui $v0, %hi(D_8015A57A) -/* 79748 800E0298 8042A57A */ lb $v0, %lo(D_8015A57A)($v0) -/* 7974C 800E029C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 79750 800E02A0 AFBF0014 */ sw $ra, 0x14($sp) -/* 79754 800E02A4 10400016 */ beqz $v0, .L800E0300 -/* 79758 800E02A8 AFB00010 */ sw $s0, 0x10($sp) -/* 7975C 800E02AC 3C108011 */ lui $s0, %hi(D_8010C93C) -/* 79760 800E02B0 2610C93C */ addiu $s0, $s0, %lo(D_8010C93C) -/* 79764 800E02B4 8E020000 */ lw $v0, ($s0) -/* 79768 800E02B8 14400015 */ bnez $v0, .L800E0310 -/* 7976C 800E02BC 00000000 */ nop -/* 79770 800E02C0 3C028011 */ lui $v0, %hi(gPlayerStatus) -/* 79774 800E02C4 2442EFC8 */ addiu $v0, $v0, %lo(gPlayerStatus) -/* 79778 800E02C8 8C420004 */ lw $v0, 4($v0) -/* 7977C 800E02CC 30420030 */ andi $v0, $v0, 0x30 -/* 79780 800E02D0 1440000B */ bnez $v0, .L800E0300 -/* 79784 800E02D4 00000000 */ nop -/* 79788 800E02D8 3C06802B */ lui $a2, 0x802b -/* 7978C 800E02DC 3C0400E2 */ lui $a0, 0xe2 -/* 79790 800E02E0 248425B0 */ addiu $a0, $a0, 0x25b0 -/* 79794 800E02E4 3C0500E2 */ lui $a1, 0xe2 -/* 79798 800E02E8 24A53260 */ addiu $a1, $a1, 0x3260 -/* 7979C 800E02EC 0C00A5CF */ jal dma_copy -/* 797A0 800E02F0 34C67000 */ ori $a2, $a2, 0x7000 -/* 797A4 800E02F4 3C02802B */ lui $v0, %hi(func_802B72C0_E22870) -/* 797A8 800E02F8 244272C0 */ addiu $v0, $v0, %lo(func_802B72C0_E22870) -/* 797AC 800E02FC AE020000 */ sw $v0, ($s0) -.L800E0300: -/* 797B0 800E0300 3C028011 */ lui $v0, %hi(D_8010C93C) -/* 797B4 800E0304 8C42C93C */ lw $v0, %lo(D_8010C93C)($v0) -/* 797B8 800E0308 10400005 */ beqz $v0, .L800E0320 -/* 797BC 800E030C 00000000 */ nop -.L800E0310: -/* 797C0 800E0310 3C028011 */ lui $v0, %hi(D_8010C93C) -/* 797C4 800E0314 8C42C93C */ lw $v0, %lo(D_8010C93C)($v0) -/* 797C8 800E0318 0040F809 */ jalr $v0 -/* 797CC 800E031C 00000000 */ nop -.L800E0320: -/* 797D0 800E0320 8FBF0014 */ lw $ra, 0x14($sp) -/* 797D4 800E0324 8FB00010 */ lw $s0, 0x10($sp) -/* 797D8 800E0328 03E00008 */ jr $ra -/* 797DC 800E032C 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/ver/us/asm/nonmatchings/77480/check_for_pulse_stone.s b/ver/us/asm/nonmatchings/77480/check_for_pulse_stone.s deleted file mode 100644 index 71556448d6..0000000000 --- a/ver/us/asm/nonmatchings/77480/check_for_pulse_stone.s +++ /dev/null @@ -1,86 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel check_for_pulse_stone -/* 79848 800E0398 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 7984C 800E039C AFB00010 */ sw $s0, 0x10($sp) -/* 79850 800E03A0 3C108011 */ lui $s0, %hi(D_8010C920) -/* 79854 800E03A4 2610C920 */ addiu $s0, $s0, %lo(D_8010C920) -/* 79858 800E03A8 AFBF0014 */ sw $ra, 0x14($sp) -/* 7985C 800E03AC 8E020000 */ lw $v0, ($s0) -/* 79860 800E03B0 3C078011 */ lui $a3, %hi(gPlayerStatus) -/* 79864 800E03B4 24E7EFC8 */ addiu $a3, $a3, %lo(gPlayerStatus) -/* 79868 800E03B8 1440003D */ bnez $v0, .L800E04B0 -/* 7986C 800E03BC 00000000 */ nop -/* 79870 800E03C0 8CE60004 */ lw $a2, 4($a3) -/* 79874 800E03C4 30C20100 */ andi $v0, $a2, 0x100 -/* 79878 800E03C8 1440003D */ bnez $v0, .L800E04C0 -/* 7987C 800E03CC 2402000A */ addiu $v0, $zero, 0xa -/* 79880 800E03D0 3C058007 */ lui $a1, %hi(gGameStatusPtr) -/* 79884 800E03D4 8CA5419C */ lw $a1, %lo(gGameStatusPtr)($a1) -/* 79888 800E03D8 84A30086 */ lh $v1, 0x86($a1) -/* 7988C 800E03DC 14620038 */ bne $v1, $v0, .L800E04C0 -/* 79890 800E03E0 00000000 */ nop -/* 79894 800E03E4 80A20070 */ lb $v0, 0x70($a1) -/* 79898 800E03E8 14400035 */ bnez $v0, .L800E04C0 -/* 7989C 800E03EC 3C049249 */ lui $a0, 0x9249 -/* 798A0 800E03F0 94A3008C */ lhu $v1, 0x8c($a1) -/* 798A4 800E03F4 34842493 */ ori $a0, $a0, 0x2493 -/* 798A8 800E03F8 00031C00 */ sll $v1, $v1, 0x10 -/* 798AC 800E03FC 00031403 */ sra $v0, $v1, 0x10 -/* 798B0 800E0400 00440018 */ mult $v0, $a0 -/* 798B4 800E0404 00031FC3 */ sra $v1, $v1, 0x1f -/* 798B8 800E0408 00004010 */ mfhi $t0 -/* 798BC 800E040C 01022021 */ addu $a0, $t0, $v0 -/* 798C0 800E0410 00042083 */ sra $a0, $a0, 2 -/* 798C4 800E0414 00832023 */ subu $a0, $a0, $v1 -/* 798C8 800E0418 000418C0 */ sll $v1, $a0, 3 -/* 798CC 800E041C 00641823 */ subu $v1, $v1, $a0 -/* 798D0 800E0420 00431023 */ subu $v0, $v0, $v1 -/* 798D4 800E0424 00021400 */ sll $v0, $v0, 0x10 -/* 798D8 800E0428 00021403 */ sra $v0, $v0, 0x10 -/* 798DC 800E042C 2442FFFE */ addiu $v0, $v0, -2 -/* 798E0 800E0430 04420001 */ bltzl $v0, .L800E0438 -/* 798E4 800E0434 00021023 */ negu $v0, $v0 -.L800E0438: -/* 798E8 800E0438 00042400 */ sll $a0, $a0, 0x10 -/* 798EC 800E043C 00042403 */ sra $a0, $a0, 0x10 -/* 798F0 800E0440 00441021 */ addu $v0, $v0, $a0 -/* 798F4 800E0444 28420006 */ slti $v0, $v0, 6 -/* 798F8 800E0448 1040001D */ beqz $v0, .L800E04C0 -/* 798FC 800E044C 30C200C0 */ andi $v0, $a2, 0xc0 -/* 79900 800E0450 1040001B */ beqz $v0, .L800E04C0 -/* 79904 800E0454 00000000 */ nop -/* 79908 800E0458 8CE20000 */ lw $v0, ($a3) -/* 7990C 800E045C 30420020 */ andi $v0, $v0, 0x20 -/* 79910 800E0460 14400017 */ bnez $v0, .L800E04C0 -/* 79914 800E0464 00000000 */ nop -/* 79918 800E0468 80E20015 */ lb $v0, 0x15($a3) -/* 7991C 800E046C 14400014 */ bnez $v0, .L800E04C0 -/* 79920 800E0470 30C20030 */ andi $v0, $a2, 0x30 -/* 79924 800E0474 1440000B */ bnez $v0, .L800E04A4 -/* 79928 800E0478 00000000 */ nop -/* 7992C 800E047C 3C06802B */ lui $a2, 0x802b -/* 79930 800E0480 3C0400E2 */ lui $a0, 0xe2 -/* 79934 800E0484 24841870 */ addiu $a0, $a0, 0x1870 -/* 79938 800E0488 3C0500E2 */ lui $a1, 0xe2 -/* 7993C 800E048C 24A525B0 */ addiu $a1, $a1, 0x25b0 -/* 79940 800E0490 0C00A5CF */ jal dma_copy -/* 79944 800E0494 34C67000 */ ori $a2, $a2, 0x7000 -/* 79948 800E0498 3C02802B */ lui $v0, %hi(func_802B7140) -/* 7994C 800E049C 24427140 */ addiu $v0, $v0, %lo(func_802B7140) -/* 79950 800E04A0 AE020000 */ sw $v0, ($s0) -.L800E04A4: -/* 79954 800E04A4 8E020000 */ lw $v0, ($s0) -/* 79958 800E04A8 10400005 */ beqz $v0, .L800E04C0 -/* 7995C 800E04AC 00000000 */ nop -.L800E04B0: -/* 79960 800E04B0 3C028011 */ lui $v0, %hi(D_8010C920) -/* 79964 800E04B4 8C42C920 */ lw $v0, %lo(D_8010C920)($v0) -/* 79968 800E04B8 0040F809 */ jalr $v0 -/* 7996C 800E04BC 00000000 */ nop -.L800E04C0: -/* 79970 800E04C0 8FBF0014 */ lw $ra, 0x14($sp) -/* 79974 800E04C4 8FB00010 */ lw $s0, 0x10($sp) -/* 79978 800E04C8 03E00008 */ jr $ra -/* 7997C 800E04CC 27BD0018 */ addiu $sp, $sp, 0x18