From a15a282a0879a15d3e2f43591d0571ac133bfe01 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Sun, 18 Oct 2020 17:04:40 -0400 Subject: [PATCH] Thy cornucopia hath return! --- .../code_181810/MultiplyByActorScale.s | 31 ------------ .../code_181810/PlaySoundAtActor.s | 34 ------------- asm/nonmatchings/code_181810/func_802535B4.s | 23 --------- src/code_181810.c | 48 +++++++++++++++---- tools/symbol_addrs.txt | 2 +- undefined_syms.txt | 2 +- 6 files changed, 42 insertions(+), 98 deletions(-) delete mode 100644 asm/nonmatchings/code_181810/MultiplyByActorScale.s delete mode 100644 asm/nonmatchings/code_181810/PlaySoundAtActor.s delete mode 100644 asm/nonmatchings/code_181810/func_802535B4.s diff --git a/asm/nonmatchings/code_181810/MultiplyByActorScale.s b/asm/nonmatchings/code_181810/MultiplyByActorScale.s deleted file mode 100644 index c594a02ba0..0000000000 --- a/asm/nonmatchings/code_181810/MultiplyByActorScale.s +++ /dev/null @@ -1,31 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel MultiplyByActorScale -/* 1828BC 80253FDC 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 1828C0 80253FE0 AFB10014 */ sw $s1, 0x14($sp) -/* 1828C4 80253FE4 0080882D */ daddu $s1, $a0, $zero -/* 1828C8 80253FE8 AFBF001C */ sw $ra, 0x1c($sp) -/* 1828CC 80253FEC AFB20018 */ sw $s2, 0x18($sp) -/* 1828D0 80253FF0 AFB00010 */ sw $s0, 0x10($sp) -/* 1828D4 80253FF4 8E240148 */ lw $a0, 0x148($s1) -/* 1828D8 80253FF8 0C09A75B */ jal get_actor -/* 1828DC 80253FFC 8E32000C */ lw $s2, 0xc($s1) -/* 1828E0 80254000 0220202D */ daddu $a0, $s1, $zero -/* 1828E4 80254004 8E450000 */ lw $a1, ($s2) -/* 1828E8 80254008 0C0B210B */ jal get_float_variable -/* 1828EC 8025400C 0040802D */ daddu $s0, $v0, $zero -/* 1828F0 80254010 C6020188 */ lwc1 $f2, 0x188($s0) -/* 1828F4 80254014 46020002 */ mul.s $f0, $f0, $f2 -/* 1828F8 80254018 00000000 */ nop -/* 1828FC 8025401C 8E450000 */ lw $a1, ($s2) -/* 182900 80254020 44060000 */ mfc1 $a2, $f0 -/* 182904 80254024 0C0B2190 */ jal set_float_variable -/* 182908 80254028 0220202D */ daddu $a0, $s1, $zero -/* 18290C 8025402C 8FBF001C */ lw $ra, 0x1c($sp) -/* 182910 80254030 8FB20018 */ lw $s2, 0x18($sp) -/* 182914 80254034 8FB10014 */ lw $s1, 0x14($sp) -/* 182918 80254038 8FB00010 */ lw $s0, 0x10($sp) -/* 18291C 8025403C 24020002 */ addiu $v0, $zero, 2 -/* 182920 80254040 03E00008 */ jr $ra -/* 182924 80254044 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_181810/PlaySoundAtActor.s b/asm/nonmatchings/code_181810/PlaySoundAtActor.s deleted file mode 100644 index fab8215f79..0000000000 --- a/asm/nonmatchings/code_181810/PlaySoundAtActor.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel PlaySoundAtActor -/* 18213C 8025385C 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 182140 80253860 AFB1001C */ sw $s1, 0x1c($sp) -/* 182144 80253864 0080882D */ daddu $s1, $a0, $zero -/* 182148 80253868 AFBF0020 */ sw $ra, 0x20($sp) -/* 18214C 8025386C AFB00018 */ sw $s0, 0x18($sp) -/* 182150 80253870 8E30000C */ lw $s0, 0xc($s1) -/* 182154 80253874 8E050000 */ lw $a1, ($s0) -/* 182158 80253878 0C0B1EAF */ jal get_variable -/* 18215C 8025387C 26100004 */ addiu $s0, $s0, 4 -/* 182160 80253880 0040202D */ daddu $a0, $v0, $zero -/* 182164 80253884 2402FF81 */ addiu $v0, $zero, -0x7f -/* 182168 80253888 14820002 */ bne $a0, $v0, .L80253894 -/* 18216C 8025388C 8E100000 */ lw $s0, ($s0) -/* 182170 80253890 8E240148 */ lw $a0, 0x148($s1) -.L80253894: -/* 182174 80253894 0C09A75B */ jal get_actor -/* 182178 80253898 00000000 */ nop -/* 18217C 8025389C C440014C */ lwc1 $f0, 0x14c($v0) -/* 182180 802538A0 0200202D */ daddu $a0, $s0, $zero -/* 182184 802538A4 E7A00010 */ swc1 $f0, 0x10($sp) -/* 182188 802538A8 8C460144 */ lw $a2, 0x144($v0) -/* 18218C 802538AC 8C470148 */ lw $a3, 0x148($v0) -/* 182190 802538B0 0C052757 */ jal play_sound_at_position -/* 182194 802538B4 0000282D */ daddu $a1, $zero, $zero -/* 182198 802538B8 8FBF0020 */ lw $ra, 0x20($sp) -/* 18219C 802538BC 8FB1001C */ lw $s1, 0x1c($sp) -/* 1821A0 802538C0 8FB00018 */ lw $s0, 0x18($sp) -/* 1821A4 802538C4 24020002 */ addiu $v0, $zero, 2 -/* 1821A8 802538C8 03E00008 */ jr $ra -/* 1821AC 802538CC 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/asm/nonmatchings/code_181810/func_802535B4.s b/asm/nonmatchings/code_181810/func_802535B4.s deleted file mode 100644 index 8b5702f18a..0000000000 --- a/asm/nonmatchings/code_181810/func_802535B4.s +++ /dev/null @@ -1,23 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802535B4 -/* 181E94 802535B4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 181E98 802535B8 AFBF0010 */ sw $ra, 0x10($sp) -/* 181E9C 802535BC 8C82000C */ lw $v0, 0xc($a0) -/* 181EA0 802535C0 0C0B1EAF */ jal get_variable -/* 181EA4 802535C4 8C450000 */ lw $a1, ($v0) -/* 181EA8 802535C8 10400005 */ beqz $v0, .L802535E0 -/* 181EAC 802535CC 00000000 */ nop -/* 181EB0 802535D0 0C03A6CC */ jal decrement_status_menu_disabled -/* 181EB4 802535D4 00000000 */ nop -/* 181EB8 802535D8 08094D7A */ j .L802535E8 -/* 181EBC 802535DC 00000000 */ nop -.L802535E0: -/* 181EC0 802535E0 0C03A6D5 */ jal increment_status_menu_disabled -/* 181EC4 802535E4 00000000 */ nop -.L802535E8: -/* 181EC8 802535E8 8FBF0010 */ lw $ra, 0x10($sp) -/* 181ECC 802535EC 24020002 */ addiu $v0, $zero, 2 -/* 181ED0 802535F0 03E00008 */ jr $ra -/* 181ED4 802535F4 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/src/code_181810.c b/src/code_181810.c index c976f6e42c..f9aab5c231 100644 --- a/src/code_181810.c +++ b/src/code_181810.c @@ -23,6 +23,7 @@ ApiStatus ActorSpeak(ScriptInstance* script, s32 isInitialCall) { f32 headX, headY, headZ; f32 screenX, screenY, screenZ; + s32 stringID2; if (isInitialCall) { stringID = get_variable(script, *args++); @@ -30,10 +31,12 @@ ApiStatus ActorSpeak(ScriptInstance* script, s32 isInitialCall) { partIndex = get_variable(script, *args++); gSpeakingActorTalkAnim = get_variable(script, *args++); gSpeakingActorIdleAnim = get_variable(script, *args++); + stringID2 = stringID; if (actorID == ActorId_SELF) { actorID = script->ownerActorID; } + actor = get_actor(actorID); part = get_actor_part(actor, partIndex); gSpeakingActor = actor; @@ -43,15 +46,16 @@ ApiStatus ActorSpeak(ScriptInstance* script, s32 isInitialCall) { if ((actor->flags & 0x8000) == 0) { headY = actor->size.y + (actor->currentPos.y + actor->headOffset.y); } else { - headY = actor->headOffset.y + actor->currentPos.y + (actor->size.y / 2); + headY = actor->headOffset.y; + headY = headY + actor->currentPos.y + (actor->size.y / 2); } - headZ = actor->headOffset.z + actor->currentPos.z; + headZ = actor->currentPos.z + actor->headOffset.z; get_screen_coords(Cam_BATTLE, headX, headY, headZ, &screenX, &screenY, &screenZ); { s32* isPrintDone = &gSpeakingActorPrintIsDone; *isPrintDone = FALSE; - gSpeakingActorPrintCtx = load_string(stringID, isPrintDone); + gSpeakingActorPrintCtx = load_string(stringID2, isPrintDone); } clamp_printer_coords(gSpeakingActorPrintCtx, screenX, screenY); @@ -71,9 +75,10 @@ ApiStatus ActorSpeak(ScriptInstance* script, s32 isInitialCall) { if ((actor->flags & 0x8000) == 0) { headY = actor->size.y + (actor->currentPos.y + actor->headOffset.y); } else { - headY = actor->headOffset.y + actor->currentPos.y + (actor->size.y / 2); + headY = actor->headOffset.y; + headY = headY + actor->currentPos.y + (actor->size.y / 2); } - headZ = actor->headOffset.z + actor->currentPos.z; + headZ = actor->currentPos.z + actor->headOffset.z; get_screen_coords(Cam_BATTLE, headX, headY, headZ, &screenX, &screenY, &screenZ); printContext = &gSpeakingActorPrintCtx; @@ -111,7 +116,14 @@ INCLUDE_ASM(s32, "code_181810", EndActorSpeech); INCLUDE_ASM(s32, "code_181810", ShowBattleChoice); -INCLUDE_ASM(s32, "code_181810", func_802535B4); +ApiStatus func_802535B4(ScriptInstance* script, s32 isInitialCall) { + if (get_variable(script, *script->ptrReadPos)) { + decrement_status_menu_disabled(); + } else { + increment_status_menu_disabled(); + } + return ApiStatus_DONE2; +} ApiStatus OverrideBattleDmaDest(ScriptInstance* script, s32 isInitialCall) { gBattleDmaDest = get_variable(script, *script->ptrReadPos); @@ -126,7 +138,21 @@ INCLUDE_ASM(s32, "code_181810", func_80253734); INCLUDE_ASM(s32, "code_181810", func_802537C0); -INCLUDE_ASM(s32, "code_181810", PlaySoundAtActor); +ApiStatus PlaySoundAtActor(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + ActorId actorID = get_variable(script, *args++); + Bytecode soundID = *args++; + Actor* actor; + + if (actorID == ActorId_SELF) { + actorID = script->ownerActorID; + } + + actor = get_actor(actorID); + play_sound_at_position(soundID, 0, actor->currentPos.x, actor->currentPos.y, actor->currentPos.z); + + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_181810", PlaySoundAtPart); @@ -174,7 +200,13 @@ INCLUDE_ASM(s32, "code_181810", load_tattle_flags); INCLUDE_ASM(s32, "code_181810", func_80253FB0); -INCLUDE_ASM(s32, "code_181810", MultiplyByActorScale); +ApiStatus MultiplyByActorScale(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + Actor* actor = get_actor(script->ownerActorID); + + set_float_variable(script, *args, get_float_variable(script, *args) * actor->scalingFactor); + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_181810", MultiplyVec2ByActorScale); diff --git a/tools/symbol_addrs.txt b/tools/symbol_addrs.txt index d7c1107d2a..f877e2dec5 100644 --- a/tools/symbol_addrs.txt +++ b/tools/symbol_addrs.txt @@ -1891,4 +1891,4 @@ gSpeakingActorPrintIsDone;0x8029FA68 gSpeakingActorTalkAnim;0x8029FA6C gSpeakingActorIdleAnim;0x8029FA70 gSpeakingActor;0x8029FA74 -gSpeakingActorPart;0x8029FA7C +gSpeakingActorPart;0x8029FA78 diff --git a/undefined_syms.txt b/undefined_syms.txt index 30720b287d..bd5a19029a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -61,7 +61,7 @@ gSpeakingActorPrintIsDone = 0x8029FA68; gSpeakingActorTalkAnim = 0x8029FA6C; gSpeakingActorIdleAnim = 0x8029FA70; gSpeakingActor = 0x8029FA74; -gSpeakingActorPart = 0x8029FA7C; +gSpeakingActorPart = 0x8029FA78; gBattleDmaDest = 0x80284000; gBattleState = 0x800DC068;