UnkMusicFunc

This commit is contained in:
Ethan Roseman 2020-11-20 09:44:08 -05:00
parent fb85b1d269
commit 26417ed814
9 changed files with 81 additions and 28 deletions

View File

@ -13,7 +13,7 @@ glabel func_80240F50_8017D0
/* 8017F0 80240F70 0000902D */ daddu $s2, $zero, $zero
/* 8017F4 80240F74 8C450000 */ lw $a1, ($v0)
/* 8017F8 80240F78 0C0B1EAF */ jal get_variable
/* 8017FC 80240F7C 00000000 */ nop
/* 8017FC 80240F7C 00000000 */ nop
/* 801800 80240F80 AE020070 */ sw $v0, 0x70($s0)
/* 801804 80240F84 AE000074 */ sw $zero, 0x74($s0)
/* 801808 80240F88 8C420014 */ lw $v0, 0x14($v0)
@ -27,7 +27,7 @@ glabel func_80240F50_8017D0
/* 801824 80240FA4 24030002 */ addiu $v1, $zero, 2
/* 801828 80240FA8 8E020074 */ lw $v0, 0x74($s0)
/* 80182C 80240FAC 10430027 */ beq $v0, $v1, .L8024104C
/* 801830 80240FB0 00000000 */ nop
/* 801830 80240FB0 00000000 */ nop
/* 801834 80240FB4 08090412 */ j .L80241048
/* 801838 80240FB8 AE030074 */ sw $v1, 0x74($s0)
.L80240FBC:
@ -46,34 +46,34 @@ glabel func_80240F50_8017D0
/* 80186C 80240FEC 50400005 */ beql $v0, $zero, .L80241004
/* 801870 80240FF0 24020002 */ addiu $v0, $zero, 2
/* 801874 80240FF4 10600007 */ beqz $v1, .L80241014
/* 801878 80240FF8 00000000 */ nop
/* 801878 80240FF8 00000000 */ nop
/* 80187C 80240FFC 08090413 */ j .L8024104C
/* 801880 80241000 00000000 */ nop
/* 801880 80241000 00000000 */ nop
.L80241004:
/* 801884 80241004 50620010 */ beql $v1, $v0, .L80241048
/* 801888 80241008 AE040074 */ sw $a0, 0x74($s0)
/* 80188C 8024100C 08090413 */ j .L8024104C
/* 801890 80241010 00000000 */ nop
/* 801890 80241010 00000000 */ nop
.L80241014:
/* 801894 80241014 C6200008 */ lwc1 $f0, 8($s1)
/* 801898 80241018 4600103C */ c.lt.s $f2, $f0
/* 80189C 8024101C 00000000 */ nop
/* 80189C 8024101C 00000000 */ nop
/* 8018A0 80241020 4500000A */ bc1f .L8024104C
/* 8018A4 80241024 00000000 */ nop
/* 8018A4 80241024 00000000 */ nop
/* 8018A8 80241028 08090412 */ j .L80241048
/* 8018AC 8024102C AE040074 */ sw $a0, 0x74($s0)
.L80241030:
/* 8018B0 80241030 C620000C */ lwc1 $f0, 0xc($s1)
/* 8018B4 80241034 4602003C */ c.lt.s $f0, $f2
/* 8018B8 80241038 00000000 */ nop
/* 8018B8 80241038 00000000 */ nop
/* 8018BC 8024103C 45000003 */ bc1f .L8024104C
/* 8018C0 80241040 00000000 */ nop
/* 8018C0 80241040 00000000 */ nop
/* 8018C4 80241044 AE000074 */ sw $zero, 0x74($s0)
.L80241048:
/* 8018C8 80241048 24120001 */ addiu $s2, $zero, 1
.L8024104C:
/* 8018CC 8024104C 12400005 */ beqz $s2, .L80241064
/* 8018D0 80241050 00000000 */ nop
/* 8018D0 80241050 00000000 */ nop
/* 8018D4 80241054 8E250010 */ lw $a1, 0x10($s1)
/* 8018D8 80241058 86060076 */ lh $a2, 0x76($s0)
/* 8018DC 8024105C 0C052A95 */ jal func_8014AA54

View File

@ -13,7 +13,7 @@ glabel func_802433F0_8266B0
/* 8266D0 80243410 0000902D */ daddu $s2, $zero, $zero
/* 8266D4 80243414 8C450000 */ lw $a1, ($v0)
/* 8266D8 80243418 0C0B1EAF */ jal get_variable
/* 8266DC 8024341C 00000000 */ nop
/* 8266DC 8024341C 00000000 */ nop
/* 8266E0 80243420 AE020070 */ sw $v0, 0x70($s0)
/* 8266E4 80243424 AE000074 */ sw $zero, 0x74($s0)
/* 8266E8 80243428 8C420014 */ lw $v0, 0x14($v0)
@ -27,7 +27,7 @@ glabel func_802433F0_8266B0
/* 826704 80243444 24030002 */ addiu $v1, $zero, 2
/* 826708 80243448 8E020074 */ lw $v0, 0x74($s0)
/* 82670C 8024344C 10430027 */ beq $v0, $v1, .L802434EC
/* 826710 80243450 00000000 */ nop
/* 826710 80243450 00000000 */ nop
/* 826714 80243454 08090D3A */ j .L802434E8
/* 826718 80243458 AE030074 */ sw $v1, 0x74($s0)
.L8024345C:
@ -46,34 +46,34 @@ glabel func_802433F0_8266B0
/* 82674C 8024348C 50400005 */ beql $v0, $zero, .L802434A4
/* 826750 80243490 24020002 */ addiu $v0, $zero, 2
/* 826754 80243494 10600007 */ beqz $v1, .L802434B4
/* 826758 80243498 00000000 */ nop
/* 826758 80243498 00000000 */ nop
/* 82675C 8024349C 08090D3B */ j .L802434EC
/* 826760 802434A0 00000000 */ nop
/* 826760 802434A0 00000000 */ nop
.L802434A4:
/* 826764 802434A4 50620010 */ beql $v1, $v0, .L802434E8
/* 826768 802434A8 AE040074 */ sw $a0, 0x74($s0)
/* 82676C 802434AC 08090D3B */ j .L802434EC
/* 826770 802434B0 00000000 */ nop
/* 826770 802434B0 00000000 */ nop
.L802434B4:
/* 826774 802434B4 C6200008 */ lwc1 $f0, 8($s1)
/* 826778 802434B8 4600103C */ c.lt.s $f2, $f0
/* 82677C 802434BC 00000000 */ nop
/* 82677C 802434BC 00000000 */ nop
/* 826780 802434C0 4500000A */ bc1f .L802434EC
/* 826784 802434C4 00000000 */ nop
/* 826784 802434C4 00000000 */ nop
/* 826788 802434C8 08090D3A */ j .L802434E8
/* 82678C 802434CC AE040074 */ sw $a0, 0x74($s0)
.L802434D0:
/* 826790 802434D0 C620000C */ lwc1 $f0, 0xc($s1)
/* 826794 802434D4 4602003C */ c.lt.s $f0, $f2
/* 826798 802434D8 00000000 */ nop
/* 826798 802434D8 00000000 */ nop
/* 82679C 802434DC 45000003 */ bc1f .L802434EC
/* 8267A0 802434E0 00000000 */ nop
/* 8267A0 802434E0 00000000 */ nop
/* 8267A4 802434E4 AE000074 */ sw $zero, 0x74($s0)
.L802434E8:
/* 8267A8 802434E8 24120001 */ addiu $s2, $zero, 1
.L802434EC:
/* 8267AC 802434EC 12400005 */ beqz $s2, .L80243504
/* 8267B0 802434F0 00000000 */ nop
/* 8267B0 802434F0 00000000 */ nop
/* 8267B4 802434F4 8E250010 */ lw $a1, 0x10($s1)
/* 8267B8 802434F8 86060076 */ lh $a2, 0x76($s0)
/* 8267BC 802434FC 0C052A95 */ jal func_8014AA54

View File

@ -210,6 +210,11 @@ typedef struct Trigger {
typedef Trigger* TriggerList[MAX_TRIGGERS];
typedef union X32 {
s32 s;
f32 f;
} X32;
typedef struct ScriptInstance {
/* 0x000 */ u8 state;
/* 0x001 */ u8 currentArgc;
@ -227,10 +232,7 @@ typedef struct ScriptInstance {
/* 0x064 */ struct ScriptInstance* blockingParent; /* parent? */
/* 0x068 */ struct ScriptInstance* childScript;
/* 0x06C */ struct ScriptInstance* parentScript; /* brother? */
/* 0x070 */ union {
s32 s;
f32 f;
} functionTemp[4];
/* 0x070 */ X32 functionTemp[4];
/* 0x080 */ ApiFunc callFunction;
/* 0x084 */ s32 varTable[16];
/* 0x0C4 */ s32 varFlags[3];

View File

@ -133,6 +133,7 @@ void add_vec2D_polar(f32* x, f32* y, f32 r, f32 theta);
s32 func_801499EC(s32 soundID, s32 arg1, f32 arg2, f32 arg3, f32 arg4);
s32 play_sound_at_position(s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ);
s32 set_music_track(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume);
s32 func_8014AA54(s32 playerIndex, s32 arg1, s16 arg2);
ScriptInstance* get_script_by_index(s32 index);

View File

@ -1,5 +1,5 @@
#include "mac_00.h"
INCLUDE_ASM(s32, "world/area_mac/mac_00/7ECFD0", func_802422C0_7ECFD0);
#include "world/common/UnkMusicFunc.inc.c"
INCLUDE_ASM(s32, "world/area_mac/mac_00/7ECFD0", func_802423F0_7ED100);

View File

@ -1,6 +1,6 @@
#include "mac_01.h"
INCLUDE_ASM(s32, "world/area_mac/mac_01/8017D0", func_80240F50_8017D0);
#include "world/common/UnkMusicFunc.inc.c"
INCLUDE_ASM(s32, "world/area_mac/mac_01/8017D0", func_80241080_801900);

View File

@ -106,4 +106,4 @@ INCLUDE_ASM(s32, "world/area_mac/mac_02/823BF0", func_80243380_826640);
INCLUDE_ASM(s32, "world/area_mac/mac_02/823BF0", func_802433C4_826684);
INCLUDE_ASM(s32, "world/area_mac/mac_02/823BF0", func_802433F0_8266B0);
#include "world/common/UnkMusicFunc.inc.c"

View File

@ -1,3 +1,3 @@
#include "mac_04.h"
INCLUDE_ASM(s32, "world/area_mac/mac_04/844AC0", func_80241EF0_844AC0);
#include "world/common/UnkMusicFunc.inc.c"

View File

@ -0,0 +1,50 @@
#include "common.h"
static ApiStatus UnkMusicFunc(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
X32* something;
s32 cond = 0;
f32 dist;
if (isInitialCall) {
script->functionTemp[0].s = get_variable(script, *args);
script->functionTemp[1].s = 0;
script->functionTemp[2].s = ((s32*)(script->functionTemp[0].s))[5];
}
something = script->functionTemp[0].s;
if (get_variable(script, script->functionTemp[2].s)) {
if (script->functionTemp[1].s != 2) {
script->functionTemp[1].s = 2;
cond = TRUE;
}
} else {
dist = dist2D(gPlayerStatusPtr->position.x, gPlayerStatusPtr->position.z, something[0].f, something[1].f);
switch (script->functionTemp[1].s) {
case 0:
if (dist < something[2].f) {
script->functionTemp[1].s = 1;
cond = TRUE;
}
break;
case 1:
if (dist > something[3].f) {
script->functionTemp[1].s = 0;
cond = TRUE;
}
break;
case 2:
script->functionTemp[1].s = 1;
cond = TRUE;
break;
}
}
if (cond) {
func_8014AA54(0, something[4].s, script->functionTemp[1].s);
}
return ApiStatus_BLOCK;
}