diff --git a/asm/nonmatchings/code_181810/PlayLoopingSoundAtActor.s b/asm/nonmatchings/code_181810/PlayLoopingSoundAtActor.s deleted file mode 100644 index 37e7d78811..0000000000 --- a/asm/nonmatchings/code_181810/PlayLoopingSoundAtActor.s +++ /dev/null @@ -1,46 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel PlayLoopingSoundAtActor -/* 182254 80253974 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 182258 80253978 AFB20020 */ sw $s2, 0x20($sp) -/* 18225C 8025397C 0080902D */ daddu $s2, $a0, $zero -/* 182260 80253980 AFBF0028 */ sw $ra, 0x28($sp) -/* 182264 80253984 AFB30024 */ sw $s3, 0x24($sp) -/* 182268 80253988 AFB1001C */ sw $s1, 0x1c($sp) -/* 18226C 8025398C AFB00018 */ sw $s0, 0x18($sp) -/* 182270 80253990 8E50000C */ lw $s0, 0xc($s2) -/* 182274 80253994 8E050000 */ lw $a1, ($s0) -/* 182278 80253998 0C0B1EAF */ jal get_variable -/* 18227C 8025399C 26100004 */ addiu $s0, $s0, 4 -/* 182280 802539A0 0040882D */ daddu $s1, $v0, $zero -/* 182284 802539A4 8E050000 */ lw $a1, ($s0) -/* 182288 802539A8 26100004 */ addiu $s0, $s0, 4 -/* 18228C 802539AC 0C0B1EAF */ jal get_variable -/* 182290 802539B0 0240202D */ daddu $a0, $s2, $zero -/* 182294 802539B4 0040982D */ daddu $s3, $v0, $zero -/* 182298 802539B8 2402FF81 */ addiu $v0, $zero, -0x7f -/* 18229C 802539BC 16220002 */ bne $s1, $v0, .L802539C8 -/* 1822A0 802539C0 8E100000 */ lw $s0, ($s0) -/* 1822A4 802539C4 8E510148 */ lw $s1, 0x148($s2) -.L802539C8: -/* 1822A8 802539C8 0C09A75B */ jal get_actor -/* 1822AC 802539CC 0220202D */ daddu $a0, $s1, $zero -/* 1822B0 802539D0 00131880 */ sll $v1, $s3, 2 -/* 1822B4 802539D4 00431821 */ addu $v1, $v0, $v1 -/* 1822B8 802539D8 AC700438 */ sw $s0, 0x438($v1) -/* 1822BC 802539DC C440014C */ lwc1 $f0, 0x14c($v0) -/* 1822C0 802539E0 0200202D */ daddu $a0, $s0, $zero -/* 1822C4 802539E4 E7A00010 */ swc1 $f0, 0x10($sp) -/* 1822C8 802539E8 8C460144 */ lw $a2, 0x144($v0) -/* 1822CC 802539EC 8C470148 */ lw $a3, 0x148($v0) -/* 1822D0 802539F0 0C052757 */ jal play_sound_at_position -/* 1822D4 802539F4 0000282D */ daddu $a1, $zero, $zero -/* 1822D8 802539F8 8FBF0028 */ lw $ra, 0x28($sp) -/* 1822DC 802539FC 8FB30024 */ lw $s3, 0x24($sp) -/* 1822E0 80253A00 8FB20020 */ lw $s2, 0x20($sp) -/* 1822E4 80253A04 8FB1001C */ lw $s1, 0x1c($sp) -/* 1822E8 80253A08 8FB00018 */ lw $s0, 0x18($sp) -/* 1822EC 80253A0C 24020002 */ addiu $v0, $zero, 2 -/* 1822F0 80253A10 03E00008 */ jr $ra -/* 1822F4 80253A14 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/asm/nonmatchings/code_181810/PlaySoundAtPart.s b/asm/nonmatchings/code_181810/PlaySoundAtPart.s deleted file mode 100644 index ad8fcd970c..0000000000 --- a/asm/nonmatchings/code_181810/PlaySoundAtPart.s +++ /dev/null @@ -1,46 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel PlaySoundAtPart -/* 1821B0 802538D0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 1821B4 802538D4 AFB20020 */ sw $s2, 0x20($sp) -/* 1821B8 802538D8 0080902D */ daddu $s2, $a0, $zero -/* 1821BC 802538DC AFBF0028 */ sw $ra, 0x28($sp) -/* 1821C0 802538E0 AFB30024 */ sw $s3, 0x24($sp) -/* 1821C4 802538E4 AFB1001C */ sw $s1, 0x1c($sp) -/* 1821C8 802538E8 AFB00018 */ sw $s0, 0x18($sp) -/* 1821CC 802538EC 8E50000C */ lw $s0, 0xc($s2) -/* 1821D0 802538F0 8E050000 */ lw $a1, ($s0) -/* 1821D4 802538F4 0C0B1EAF */ jal get_variable -/* 1821D8 802538F8 26100004 */ addiu $s0, $s0, 4 -/* 1821DC 802538FC 0040882D */ daddu $s1, $v0, $zero -/* 1821E0 80253900 8E050000 */ lw $a1, ($s0) -/* 1821E4 80253904 26100004 */ addiu $s0, $s0, 4 -/* 1821E8 80253908 0C0B1EAF */ jal get_variable -/* 1821EC 8025390C 0240202D */ daddu $a0, $s2, $zero -/* 1821F0 80253910 0040982D */ daddu $s3, $v0, $zero -/* 1821F4 80253914 2402FF81 */ addiu $v0, $zero, -0x7f -/* 1821F8 80253918 16220002 */ bne $s1, $v0, .L80253924 -/* 1821FC 8025391C 8E100000 */ lw $s0, ($s0) -/* 182200 80253920 8E510148 */ lw $s1, 0x148($s2) -.L80253924: -/* 182204 80253924 0C09A75B */ jal get_actor -/* 182208 80253928 0220202D */ daddu $a0, $s1, $zero -/* 18220C 8025392C 0040202D */ daddu $a0, $v0, $zero -/* 182210 80253930 0C099117 */ jal get_actor_part -/* 182214 80253934 0260282D */ daddu $a1, $s3, $zero -/* 182218 80253938 C4400060 */ lwc1 $f0, 0x60($v0) -/* 18221C 8025393C 0200202D */ daddu $a0, $s0, $zero -/* 182220 80253940 E7A00010 */ swc1 $f0, 0x10($sp) -/* 182224 80253944 8C460058 */ lw $a2, 0x58($v0) -/* 182228 80253948 8C47005C */ lw $a3, 0x5c($v0) -/* 18222C 8025394C 0C052757 */ jal play_sound_at_position -/* 182230 80253950 0000282D */ daddu $a1, $zero, $zero -/* 182234 80253954 8FBF0028 */ lw $ra, 0x28($sp) -/* 182238 80253958 8FB30024 */ lw $s3, 0x24($sp) -/* 18223C 8025395C 8FB20020 */ lw $s2, 0x20($sp) -/* 182240 80253960 8FB1001C */ lw $s1, 0x1c($sp) -/* 182244 80253964 8FB00018 */ lw $s0, 0x18($sp) -/* 182248 80253968 24020002 */ addiu $v0, $zero, 2 -/* 18224C 8025396C 03E00008 */ jr $ra -/* 182250 80253970 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/asm/nonmatchings/code_181810/func_802537C0.s b/asm/nonmatchings/code_181810/func_802537C0.s deleted file mode 100644 index 755ed5b6c7..0000000000 --- a/asm/nonmatchings/code_181810/func_802537C0.s +++ /dev/null @@ -1,44 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802537C0 -/* 1820A0 802537C0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 1820A4 802537C4 AFB1001C */ sw $s1, 0x1c($sp) -/* 1820A8 802537C8 0080882D */ daddu $s1, $a0, $zero -/* 1820AC 802537CC AFBF0028 */ sw $ra, 0x28($sp) -/* 1820B0 802537D0 AFB30024 */ sw $s3, 0x24($sp) -/* 1820B4 802537D4 AFB20020 */ sw $s2, 0x20($sp) -/* 1820B8 802537D8 AFB00018 */ sw $s0, 0x18($sp) -/* 1820BC 802537DC 8E22000C */ lw $v0, 0xc($s1) -/* 1820C0 802537E0 8C520000 */ lw $s2, ($v0) -/* 1820C4 802537E4 8C530004 */ lw $s3, 4($v0) -/* 1820C8 802537E8 24040001 */ addiu $a0, $zero, 1 -/* 1820CC 802537EC 27A50010 */ addiu $a1, $sp, 0x10 -/* 1820D0 802537F0 0C04DF70 */ jal func_80137DC0 -/* 1820D4 802537F4 27A60014 */ addiu $a2, $sp, 0x14 -/* 1820D8 802537F8 C7A20014 */ lwc1 $f2, 0x14($sp) -/* 1820DC 802537FC 3C014300 */ lui $at, 0x4300 -/* 1820E0 80253800 44810000 */ mtc1 $at, $f0 -/* 1820E4 80253804 00000000 */ nop -/* 1820E8 80253808 4600103C */ c.lt.s $f2, $f0 -/* 1820EC 8025380C 00000000 */ nop -/* 1820F0 80253810 45000002 */ bc1f .L8025381C -/* 1820F4 80253814 24100001 */ addiu $s0, $zero, 1 -/* 1820F8 80253818 0000802D */ daddu $s0, $zero, $zero -.L8025381C: -/* 1820FC 8025381C 0220202D */ daddu $a0, $s1, $zero -/* 182100 80253820 0240282D */ daddu $a1, $s2, $zero -/* 182104 80253824 0C0B2026 */ jal set_variable -/* 182108 80253828 24060001 */ addiu $a2, $zero, 1 -/* 18210C 8025382C 0220202D */ daddu $a0, $s1, $zero -/* 182110 80253830 0260282D */ daddu $a1, $s3, $zero -/* 182114 80253834 0C0B2026 */ jal set_variable -/* 182118 80253838 0200302D */ daddu $a2, $s0, $zero -/* 18211C 8025383C 8FBF0028 */ lw $ra, 0x28($sp) -/* 182120 80253840 8FB30024 */ lw $s3, 0x24($sp) -/* 182124 80253844 8FB20020 */ lw $s2, 0x20($sp) -/* 182128 80253848 8FB1001C */ lw $s1, 0x1c($sp) -/* 18212C 8025384C 8FB00018 */ lw $s0, 0x18($sp) -/* 182130 80253850 24020002 */ addiu $v0, $zero, 2 -/* 182134 80253854 03E00008 */ jr $ra -/* 182138 80253858 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/include/functions.h b/include/functions.h index 47d33e6b70..9ba981802d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -109,6 +109,7 @@ void func_8011B7C0(u16, s32, s32); AnimatedMesh* get_anim_mesh(s32 arg0); void func_80137D88(s32, f32); void func_80137DA4(s32, f32); +void func_80137DC0(s32, f32*, f32*); s32 func_80137E10(s32, u8, u8, u8); void func_80137E4C(s32, s32, s32, s32); s32 rand_int(s32); diff --git a/src/code_181810.c b/src/code_181810.c index 5ecd951741..a913394226 100644 --- a/src/code_181810.c +++ b/src/code_181810.c @@ -191,7 +191,28 @@ ApiStatus func_80253734(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "code_181810", func_802537C0); +ApiStatus func_802537C0(ScriptInstance *script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 a0 = *args++; + s32 a1 = *args++; + f32 t1; + f32 t2; + s32 t3; + + // While loop may not be necessary in the future + do { func_80137DC0(1, &t1, &t2); } while (0); + + if (t2 < 128.0f) { + t3 = 0; + } else { + t3 = 1; + } + + set_variable(script, a0, 1); + set_variable(script, a1, t3); + + return ApiStatus_DONE2; +} ApiStatus PlaySoundAtActor(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; @@ -209,9 +230,40 @@ ApiStatus PlaySoundAtActor(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "code_181810", PlaySoundAtPart); +ApiStatus PlaySoundAtPart(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + ActorID actorID = get_variable(script, *args++); + s32 partIndex = get_variable(script, *args++); + Bytecode soundID = *args++; + ActorPart* part; -INCLUDE_ASM(s32, "code_181810", PlayLoopingSoundAtActor); + if (actorID == ActorID_SELF) { + actorID = script->owner1.actorID; + } + + part = get_actor_part(get_actor(actorID), partIndex); + play_sound_at_position(soundID, 0, part->currentPos.x, part->currentPos.y, part->currentPos.z); + + return ApiStatus_DONE2; +} + +ApiStatus PlayLoopingSoundAtActor(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + ActorID actorID = get_variable(script, *args++); + s32 idx = get_variable(script, *args++); + Bytecode soundID = *args++; + Actor* actor; + + if (actorID == ActorID_SELF) { + actorID = script->owner1.actorID; + } + + actor = get_actor(actorID); + actor->x[idx] = soundID; + play_sound_at_position(soundID, 0, actor->currentPos.x, actor->currentPos.y, actor->currentPos.z); + + return ApiStatus_DONE2; +} ApiStatus StopLoopingSoundAtActor(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; diff --git a/src/code_cd180_len_38f0.c b/src/code_cd180_len_38f0.c index 232183687d..2f933f7171 100644 --- a/src/code_cd180_len_38f0.c +++ b/src/code_cd180_len_38f0.c @@ -6,7 +6,7 @@ INCLUDE_ASM(void, "code_cd180_len_38f0", func_80137D88, s32 arg0, f32 arg1); INCLUDE_ASM(void, "code_cd180_len_38f0", func_80137DA4, s32 arg0, f32 arg1); -INCLUDE_ASM(s32, "code_cd180_len_38f0", func_80137DC0); +INCLUDE_ASM(void, "code_cd180_len_38f0", func_80137DC0, s32 arg0, f32* arg1, f32* arg2); INCLUDE_ASM(s32, "code_cd180_len_38f0", func_80137E10, s32 arg0, u8 arg1, u8 arg2, u8 arg3);