Various funcs

This commit is contained in:
Ethan Roseman 2020-09-06 11:53:48 -04:00
parent 66cc5a1ee6
commit 290a7426a5
22 changed files with 125 additions and 350 deletions

View File

@ -1,29 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel GetCamLookAtObjVector
/* 01A798 8003F398 3C038007 */ lui $v1, 0x8007
/* 01A79C 8003F39C 8C637410 */ lw $v1, 0x7410($v1)
/* 01A7A0 8003F3A0 3C05800B */ lui $a1, 0x800b
/* 01A7A4 8003F3A4 24A51D80 */ addiu $a1, $a1, 0x1d80
/* 01A7A8 8003F3A8 00031080 */ sll $v0, $v1, 2
/* 01A7AC 8003F3AC 00431021 */ addu $v0, $v0, $v1
/* 01A7B0 8003F3B0 00021080 */ sll $v0, $v0, 2
/* 01A7B4 8003F3B4 00431023 */ subu $v0, $v0, $v1
/* 01A7B8 8003F3B8 000218C0 */ sll $v1, $v0, 3
/* 01A7BC 8003F3BC 00431021 */ addu $v0, $v0, $v1
/* 01A7C0 8003F3C0 000210C0 */ sll $v0, $v0, 3
/* 01A7C4 8003F3C4 00451021 */ addu $v0, $v0, $a1
/* 01A7C8 8003F3C8 C4400048 */ lwc1 $f0, 0x48($v0)
/* 01A7CC 8003F3CC 4600008D */ trunc.w.s $f2, $f0
/* 01A7D0 8003F3D0 E4820084 */ swc1 $f2, 0x84($a0)
/* 01A7D4 8003F3D4 C440004C */ lwc1 $f0, 0x4c($v0)
/* 01A7D8 8003F3D8 4600008D */ trunc.w.s $f2, $f0
/* 01A7DC 8003F3DC E4820088 */ swc1 $f2, 0x88($a0)
/* 01A7E0 8003F3E0 C4400050 */ lwc1 $f0, 0x50($v0)
/* 01A7E4 8003F3E4 4600008D */ trunc.w.s $f2, $f0
/* 01A7E8 8003F3E8 E482008C */ swc1 $f2, 0x8c($a0)
/* 01A7EC 8003F3EC 03E00008 */ jr $ra
/* 01A7F0 8003F3F0 24020002 */ addiu $v0, $zero, 2

View File

@ -1,66 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel OnFleeBattleDrops
/* 01AAE8 8003F6E8 27BDFFD0 */ addiu $sp, $sp, -0x30
/* 01AAEC 8003F6EC AFB00020 */ sw $s0, 0x20($sp)
/* 01AAF0 8003F6F0 0080802D */ daddu $s0, $a0, $zero
/* 01AAF4 8003F6F4 AFB10024 */ sw $s1, 0x24($sp)
/* 01AAF8 8003F6F8 3C118011 */ lui $s1, 0x8011
/* 01AAFC 8003F6FC 2631EFC8 */ addiu $s1, $s1, -0x1038
/* 01AB00 8003F700 AFB20028 */ sw $s2, 0x28($sp)
/* 01AB04 8003F704 3C128011 */ lui $s2, 0x8011
/* 01AB08 8003F708 2652F290 */ addiu $s2, $s2, -0xd70
/* 01AB0C 8003F70C 10A00005 */ beqz $a1, .L8003F724
/* 01AB10 8003F710 AFBF002C */ sw $ra, 0x2c($sp)
/* 01AB14 8003F714 24020028 */ addiu $v0, $zero, 0x28
/* 01AB18 8003F718 AE000070 */ sw $zero, 0x70($s0)
/* 01AB1C 8003F71C AE020074 */ sw $v0, 0x74($s0)
/* 01AB20 8003F720 AE000078 */ sw $zero, 0x78($s0)
.L8003F724:
/* 01AB24 8003F724 8E020078 */ lw $v0, 0x78($s0)
/* 01AB28 8003F728 24420001 */ addiu $v0, $v0, 1
/* 01AB2C 8003F72C AE020078 */ sw $v0, 0x78($s0)
/* 01AB30 8003F730 28420005 */ slti $v0, $v0, 5
/* 01AB34 8003F734 1440001B */ bnez $v0, .L8003F7A4
/* 01AB38 8003F738 00000000 */ nop
/* 01AB3C 8003F73C 0C00A67F */ jal rand_int
/* 01AB40 8003F740 24040064 */ addiu $a0, $zero, 0x64
/* 01AB44 8003F744 28420032 */ slti $v0, $v0, 0x32
/* 01AB48 8003F748 50400016 */ beql $v0, $zero, .L8003F7A4
/* 01AB4C 8003F74C AE000078 */ sw $zero, 0x78($s0)
/* 01AB50 8003F750 8642000C */ lh $v0, 0xc($s2)
/* 01AB54 8003F754 9643000C */ lhu $v1, 0xc($s2)
/* 01AB58 8003F758 10400011 */ beqz $v0, .L8003F7A0
/* 01AB5C 8003F75C 2462FFFF */ addiu $v0, $v1, -1
/* 01AB60 8003F760 A642000C */ sh $v0, 0xc($s2)
/* 01AB64 8003F764 862300B0 */ lh $v1, 0xb0($s1)
/* 01AB68 8003F768 24020003 */ addiu $v0, $zero, 3
/* 01AB6C 8003F76C AFA20010 */ sw $v0, 0x10($sp)
/* 01AB70 8003F770 C620002C */ lwc1 $f0, 0x2c($s1)
/* 01AB74 8003F774 44831000 */ mtc1 $v1, $f2
/* 01AB78 8003F778 00000000 */ nop
/* 01AB7C 8003F77C 468010A0 */ cvt.s.w $f2, $f2
/* 01AB80 8003F780 46020000 */ add.s $f0, $f0, $f2
/* 01AB84 8003F784 8E250028 */ lw $a1, 0x28($s1)
/* 01AB88 8003F788 8E270030 */ lw $a3, 0x30($s1)
/* 01AB8C 8003F78C 44060000 */ mfc1 $a2, $f0
/* 01AB90 8003F790 24040157 */ addiu $a0, $zero, 0x157
/* 01AB94 8003F794 AFA00014 */ sw $zero, 0x14($sp)
/* 01AB98 8003F798 0C04C6B2 */ jal make_item_entity_delayed
/* 01AB9C 8003F79C AFA00018 */ sw $zero, 0x18($sp)
.L8003F7A0:
/* 01ABA0 8003F7A0 AE000078 */ sw $zero, 0x78($s0)
.L8003F7A4:
/* 01ABA4 8003F7A4 8E030074 */ lw $v1, 0x74($s0)
/* 01ABA8 8003F7A8 2463FFFF */ addiu $v1, $v1, -1
/* 01ABAC 8003F7AC AE030074 */ sw $v1, 0x74($s0)
/* 01ABB0 8003F7B0 8FBF002C */ lw $ra, 0x2c($sp)
/* 01ABB4 8003F7B4 8FB20028 */ lw $s2, 0x28($sp)
/* 01ABB8 8003F7B8 8FB10024 */ lw $s1, 0x24($sp)
/* 01ABBC 8003F7BC 8FB00020 */ lw $s0, 0x20($sp)
/* 01ABC0 8003F7C0 2C620001 */ sltiu $v0, $v1, 1
/* 01ABC4 8003F7C4 03E00008 */ jr $ra
/* 01ABC8 8003F7C8 27BD0030 */ addiu $sp, $sp, 0x30

View File

@ -1,8 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_8004135C
/* 01C75C 8004135C 03E00008 */ jr $ra
/* 01C760 80041360 00000000 */ nop

View File

@ -1,27 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_8004304C
/* 01E44C 8004304C 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 01E450 80043050 3C03800B */ lui $v1, 0x800b
/* 01E454 80043054 24630F10 */ addiu $v1, $v1, 0xf10
/* 01E458 80043058 AFBF0010 */ sw $ra, 0x10($sp)
/* 01E45C 8004305C 8C620098 */ lw $v0, 0x98($v1)
/* 01E460 80043060 1040000B */ beqz $v0, .L80043090
/* 01E464 80043064 00000000 */ nop
/* 01E468 80043068 C4600090 */ lwc1 $f0, 0x90($v1)
/* 01E46C 8004306C 46800020 */ cvt.s.w $f0, $f0
/* 01E470 80043070 44050000 */ mfc1 $a1, $f0
/* 01E474 80043074 0C04DF62 */ jal func_80137D88
/* 01E478 80043078 0000202D */ daddu $a0, $zero, $zero
/* 01E47C 8004307C 0000202D */ daddu $a0, $zero, $zero
/* 01E480 80043080 0080282D */ daddu $a1, $a0, $zero
/* 01E484 80043084 0080302D */ daddu $a2, $a0, $zero
/* 01E488 80043088 0C04DF84 */ jal func_80137E10
/* 01E48C 8004308C 0080382D */ daddu $a3, $a0, $zero
.L80043090:
/* 01E490 80043090 8FBF0010 */ lw $ra, 0x10($sp)
/* 01E494 80043094 03E00008 */ jr $ra
/* 01E498 80043098 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,8 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_800431D4
/* 01E5D4 800431D4 03E00008 */ jr $ra
/* 01E5D8 800431D8 00000000 */ nop

View File

@ -1,8 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80044140
/* 01F540 80044140 03E00008 */ jr $ra
/* 01F544 80044144 00000000 */ nop

View File

@ -1,23 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80044148
/* 01F548 80044148 3C02800A */ lui $v0, 0x800a
/* 01F54C 8004414C 8C42A600 */ lw $v0, -0x5a00($v0)
/* 01F550 80044150 3C03800B */ lui $v1, 0x800b
/* 01F554 80044154 80630F15 */ lb $v1, 0xf15($v1)
/* 01F558 80044158 38420003 */ xori $v0, $v0, 3
/* 01F55C 8004415C 2C440001 */ sltiu $a0, $v0, 1
/* 01F560 80044160 24020005 */ addiu $v0, $zero, 5
/* 01F564 80044164 50620001 */ beql $v1, $v0, .L8004416C
/* 01F568 80044168 24040001 */ addiu $a0, $zero, 1
.L8004416C:
/* 01F56C 8004416C 03E00008 */ jr $ra
/* 01F570 80044170 0080102D */ daddu $v0, $a0, $zero
/* 01F574 80044174 00000000 */ nop
/* 01F578 80044178 00000000 */ nop
/* 01F57C 8004417C 00000000 */ nop

View File

@ -1,40 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel bind_trigger
/* 0E8BD0 802C4220 27BDFFB8 */ addiu $sp, $sp, -0x48
/* 0E8BD4 802C4224 AFB20038 */ sw $s2, 0x38($sp)
/* 0E8BD8 802C4228 0080902D */ daddu $s2, $a0, $zero
/* 0E8BDC 802C422C 3C020100 */ lui $v0, 0x100
/* 0E8BE0 802C4230 00A22825 */ or $a1, $a1, $v0
/* 0E8BE4 802C4234 AFB3003C */ sw $s3, 0x3c($sp)
/* 0E8BE8 802C4238 8FB30058 */ lw $s3, 0x58($sp)
/* 0E8BEC 802C423C 3C02802C */ lui $v0, 0x802c
/* 0E8BF0 802C4240 2442667C */ addiu $v0, $v0, 0x667c
/* 0E8BF4 802C4244 AFB00030 */ sw $s0, 0x30($sp)
/* 0E8BF8 802C4248 00E0802D */ daddu $s0, $a3, $zero
/* 0E8BFC 802C424C AFB10034 */ sw $s1, 0x34($sp)
/* 0E8C00 802C4250 8FB1005C */ lw $s1, 0x5c($sp)
/* 0E8C04 802C4254 8FA30060 */ lw $v1, 0x60($sp)
/* 0E8C08 802C4258 27A40010 */ addiu $a0, $sp, 0x10
/* 0E8C0C 802C425C AFBF0040 */ sw $ra, 0x40($sp)
/* 0E8C10 802C4260 AFA50010 */ sw $a1, 0x10($sp)
/* 0E8C14 802C4264 AFA60018 */ sw $a2, 0x18($sp)
/* 0E8C18 802C4268 AFA00024 */ sw $zero, 0x24($sp)
/* 0E8C1C 802C426C AFA2001C */ sw $v0, 0x1c($sp)
/* 0E8C20 802C4270 0C0515DB */ jal create_trigger
/* 0E8C24 802C4274 AFA30028 */ sw $v1, 0x28($sp)
/* 0E8C28 802C4278 AC520010 */ sw $s2, 0x10($v0)
/* 0E8C2C 802C427C AC400014 */ sw $zero, 0x14($v0)
/* 0E8C30 802C4280 AC510018 */ sw $s1, 0x18($v0)
/* 0E8C34 802C4284 AC50001C */ sw $s0, 0x1c($v0)
/* 0E8C38 802C4288 AC530020 */ sw $s3, 0x20($v0)
/* 0E8C3C 802C428C 8FBF0040 */ lw $ra, 0x40($sp)
/* 0E8C40 802C4290 8FB3003C */ lw $s3, 0x3c($sp)
/* 0E8C44 802C4294 8FB20038 */ lw $s2, 0x38($sp)
/* 0E8C48 802C4298 8FB10034 */ lw $s1, 0x34($sp)
/* 0E8C4C 802C429C 8FB00030 */ lw $s0, 0x30($sp)
/* 0E8C50 802C42A0 03E00008 */ jr $ra
/* 0E8C54 802C42A4 27BD0048 */ addiu $sp, $sp, 0x48

View File

@ -1,18 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel bind_trigger_1
/* 0E8C58 802C42A8 27BDFFD8 */ addiu $sp, $sp, -0x28
/* 0E8C5C 802C42AC 8FA20038 */ lw $v0, 0x38($sp)
/* 0E8C60 802C42B0 8FA8003C */ lw $t0, 0x3c($sp)
/* 0E8C64 802C42B4 24030001 */ addiu $v1, $zero, 1
/* 0E8C68 802C42B8 AFBF0020 */ sw $ra, 0x20($sp)
/* 0E8C6C 802C42BC AFA30018 */ sw $v1, 0x18($sp)
/* 0E8C70 802C42C0 AFA20010 */ sw $v0, 0x10($sp)
/* 0E8C74 802C42C4 0C0B1088 */ jal bind_trigger
/* 0E8C78 802C42C8 AFA80014 */ sw $t0, 0x14($sp)
/* 0E8C7C 802C42CC 8FBF0020 */ lw $ra, 0x20($sp)
/* 0E8C80 802C42D0 03E00008 */ jr $ra
/* 0E8C84 802C42D4 27BD0028 */ addiu $sp, $sp, 0x28

View File

@ -1,51 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel clear_script_flags
/* 0E9230 802C4880 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0E9234 802C4884 AFB10014 */ sw $s1, 0x14($sp)
/* 0E9238 802C4888 0080882D */ daddu $s1, $a0, $zero
/* 0E923C 802C488C AFB20018 */ sw $s2, 0x18($sp)
/* 0E9240 802C4890 00A0902D */ daddu $s2, $a1, $zero
/* 0E9244 802C4894 00121827 */ nor $v1, $zero, $s2
/* 0E9248 802C4898 AFBF001C */ sw $ra, 0x1c($sp)
/* 0E924C 802C489C AFB00010 */ sw $s0, 0x10($sp)
/* 0E9250 802C48A0 92220000 */ lbu $v0, ($s1)
/* 0E9254 802C48A4 8E240068 */ lw $a0, 0x68($s1)
/* 0E9258 802C48A8 00431024 */ and $v0, $v0, $v1
/* 0E925C 802C48AC 10800003 */ beqz $a0, .L802C48BC
/* 0E9260 802C48B0 A2220000 */ sb $v0, ($s1)
/* 0E9264 802C48B4 0C0B1220 */ jal clear_script_flags
/* 0E9268 802C48B8 00000000 */ nop
.L802C48BC:
/* 0E926C 802C48BC 0000802D */ daddu $s0, $zero, $zero
.L802C48C0:
/* 0E9270 802C48C0 3C03802E */ lui $v1, 0x802e
/* 0E9274 802C48C4 8C63A890 */ lw $v1, -0x5770($v1)
/* 0E9278 802C48C8 00101080 */ sll $v0, $s0, 2
/* 0E927C 802C48CC 00431021 */ addu $v0, $v0, $v1
/* 0E9280 802C48D0 8C440000 */ lw $a0, ($v0)
/* 0E9284 802C48D4 50800007 */ beql $a0, $zero, .L802C48F4
/* 0E9288 802C48D8 26100001 */ addiu $s0, $s0, 1
/* 0E928C 802C48DC 8C82006C */ lw $v0, 0x6c($a0)
/* 0E9290 802C48E0 54510004 */ bnel $v0, $s1, .L802C48F4
/* 0E9294 802C48E4 26100001 */ addiu $s0, $s0, 1
/* 0E9298 802C48E8 0C0B1220 */ jal clear_script_flags
/* 0E929C 802C48EC 0240282D */ daddu $a1, $s2, $zero
/* 0E92A0 802C48F0 26100001 */ addiu $s0, $s0, 1
.L802C48F4:
/* 0E92A4 802C48F4 2A020080 */ slti $v0, $s0, 0x80
/* 0E92A8 802C48F8 1440FFF1 */ bnez $v0, .L802C48C0
/* 0E92AC 802C48FC 00000000 */ nop
/* 0E92B0 802C4900 8FBF001C */ lw $ra, 0x1c($sp)
/* 0E92B4 802C4904 8FB20018 */ lw $s2, 0x18($sp)
/* 0E92B8 802C4908 8FB10014 */ lw $s1, 0x14($sp)
/* 0E92BC 802C490C 8FB00010 */ lw $s0, 0x10($sp)
/* 0E92C0 802C4910 03E00008 */ jr $ra
/* 0E92C4 802C4914 27BD0020 */ addiu $sp, $sp, 0x20
/* 0E92C8 802C4918 00000000 */ nop
/* 0E92CC 802C491C 00000000 */ nop

View File

@ -1,34 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel restart_script
/* 0E86B4 802C3D04 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0E86B8 802C3D08 AFB00010 */ sw $s0, 0x10($sp)
/* 0E86BC 802C3D0C 0080802D */ daddu $s0, $a0, $zero
/* 0E86C0 802C3D10 2402FFFF */ addiu $v0, $zero, -1
/* 0E86C4 802C3D14 AFBF0014 */ sw $ra, 0x14($sp)
/* 0E86C8 802C3D18 A2020006 */ sb $v0, 6($s0)
/* 0E86CC 802C3D1C A2020007 */ sb $v0, 7($s0)
/* 0E86D0 802C3D20 8E02015C */ lw $v0, 0x15c($s0)
/* 0E86D4 802C3D24 3C013F80 */ lui $at, 0x3f80
/* 0E86D8 802C3D28 44810000 */ mtc1 $at, $f0
/* 0E86DC 802C3D2C A2000002 */ sb $zero, 2($s0)
/* 0E86E0 802C3D30 3C01802E */ lui $at, 0x802e
/* 0E86E4 802C3D34 C4229CA8 */ lwc1 $f2, -0x6358($at)
/* 0E86E8 802C3D38 AE000154 */ sw $zero, 0x154($s0)
/* 0E86EC 802C3D3C AE000154 */ sw $zero, 0x154($s0)
/* 0E86F0 802C3D40 AE000158 */ sw $zero, 0x158($s0)
/* 0E86F4 802C3D44 AE020008 */ sw $v0, 8($s0)
/* 0E86F8 802C3D48 AE020164 */ sw $v0, 0x164($s0)
/* 0E86FC 802C3D4C E6000150 */ swc1 $f0, 0x150($s0)
/* 0E8700 802C3D50 0C0B0C52 */ jal find_script_labels
/* 0E8704 802C3D54 E6020150 */ swc1 $f2, 0x150($s0)
/* 0E8708 802C3D58 0C0B0CE4 */ jal func_802C3390
/* 0E870C 802C3D5C 0200202D */ daddu $a0, $s0, $zero
/* 0E8710 802C3D60 0200102D */ daddu $v0, $s0, $zero
/* 0E8714 802C3D64 8FBF0014 */ lw $ra, 0x14($sp)
/* 0E8718 802C3D68 8FB00010 */ lw $s0, 0x10($sp)
/* 0E871C 802C3D6C 03E00008 */ jr $ra
/* 0E8720 802C3D70 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1031,16 +1031,19 @@ typedef struct FontRasterSet {
/* 0x02 */ char unk_02[10];
} FontRasterSet; // size = 0x0C
typedef struct TriggerBp {
typedef s32(*TriggerHandlerFunc)(struct Trigger*);
typedef struct TriggerDefinition {
/* 0x00 */ s32 flags;
/* 0x04 */ s16 colliderIndex;
/* 0x06 */ char unk_06[2];
/* 0x08 */ s32 flagIndex;
/* 0x0C */ UNK_FUN_PTR(function);
/* 0x10 */ char unk_10[8];
/* 0x0C */ TriggerHandlerFunc function;
/* 0x10 */ char unk_10[4];
/* 0x14 */ s32 unk_14;
/* 0x18 */ s32 inputArg3;
/* 0x1C */ char unk_1C[4];
} TriggerBp; // size = 0x20
} TriggerDefinition; // size = 0x20
typedef struct CollisionStatus {
/* 0x00 */ s16 pushingAgainstWall; /* FFFF = none for all below VVV */
@ -1389,7 +1392,7 @@ typedef struct AnimatedModelNode {
typedef struct EncounterStatus {
/* 0x00 */ s32 flags;
/* 0x04 */ u8 eFirstStrike; /* 0 = none, 1 = player, 2 = enemy */
/* 0x05 */ u8 hitType; /* 1 = none/enemy, 2 = jump */
/* 0x05 */ s8 hitType; /* 1 = none/enemy, 2 = jump */
/* 0x06 */ u8 hitTier; /* 0 = normal, 1 = super, 2 = ultra */
/* 0x07 */ char unk_07[2];
/* 0x09 */ u8 battleOutcome; /* 0 = won, 1 = lost */
@ -1410,10 +1413,11 @@ typedef struct EncounterStatus {
/* 0x21 */ char unk_21[3];
/* 0x24 */ s32* npcGroupList;
/* 0x28 */ struct Encounter* enounterList[24];
/* 0x2C */ char unk_2C[92];
/* 0x88 */ struct Encounter* currentEncounter;
/* 0x8C */ struct Enemy* currentEnemy;
/* 0x90 */ char unk_90[4];
} EncounterStatus; // size = 0x94
/* 0x90 */ s32 unk_90;
/* 0x94 */ char unk_94[4];
/* 0x98 */ s32 unk_98;
} EncounterStatus; // size = 0x9C
#endif

View File

@ -14,6 +14,9 @@ void clone_model(u16 srcModelID, u16 newModelID);
void update_collider_transform(s16 colliderID);
void get_collider_center(s32 colliderID, f32* x, f32* y, f32* z);
Trigger* create_trigger(TriggerDefinition* def);
s32 _bound_script_trigger_handler(Trigger* trigger);
s32 get_variable(ScriptInstance* script, Bytecode var);
s32 set_variable(ScriptInstance* script, Bytecode var, s32 value);
f32 get_float_variable(ScriptInstance* script, Bytecode var);
@ -31,13 +34,15 @@ s32 func_800555E4(s32);
void func_8011B7C0(u16, s32, s32);
void func_80137D88(s32, f32);
void func_80137DA4(s32, f32);
void func_80137E10(s32, u8, u8, u8);
s32 func_80137E10(s32, u8, u8, u8);
void func_80137E4C(s32, s32, s32, s32);
s32 rand_int(s32);
void sort_items(void);
s32 is_ability_active(s32 arg0);
f32 update_lerp(Easing easing, f32 start, f32 end, s32 elapsed, s32 duration);
void make_item_entity_delayed(s32 itemID, f32 x, f32 y, f32 z, s32 unk1, s32 unk2, s32 unk3);
void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height);
Npc* get_npc_safe(NpcId npcId);

View File

@ -20,6 +20,8 @@ extern ScriptInstance* gWorldScriptList[128];
extern ScriptInstance* gBattleScriptList[128];
extern ScriptInstance** gCurrentScriptListPtr[128];
extern s32 gListCount;
extern s32 gScriptIdList[128];
extern s32 gScriptIndexList[128];
@ -44,12 +46,14 @@ extern Shadow* gBattleShadowList[60];
extern Shadow** gCurrentShadowListPtr[60];
extern Camera gCameras[4];
extern s32 gCurrentCameraID;
extern f32 gGlobalTimeSpace;
extern Npc* gPlayerNpcPtr;
extern s8 D_800A0900;
extern EncounterStatus gCurrentEncounter;
extern s16* D_80151328;
extern s16 D_8010CD10;
extern s16 D_8010CD12;
@ -74,6 +78,7 @@ extern s16 D_800A0944;
extern s16 D_80151308;
extern s32 gGameState;
extern s32 D_8009A650[1];
extern s16 gCurrentDoorSoundsSet;

View File

@ -4,17 +4,49 @@ INCLUDE_ASM("code_1a1f0_len_5390", get_defeated);
INCLUDE_ASM("code_1a1f0_len_5390", set_defeated);
INCLUDE_API_ASM("code_1a1f0_len_5390", GetCamLookAtObjVector);
ApiStatus GetCamLookAtObjVector(ScriptInstance* script, s32 isInitialCall) {
// Almost certainly a CURRENT_CAM macro
script->varTable[0] = (&gCameras[gCurrentCameraID])->lookAt_obj[0];
script->varTable[1] = (&gCameras[gCurrentCameraID])->lookAt_obj[1];
script->varTable[2] = (&gCameras[gCurrentCameraID])->lookAt_obj[2];
return ApiStatus_DONE2;
}
INCLUDE_API_ASM("code_1a1f0_len_5390", HasMerleeCasts);
INCLUDE_API_ASM("code_1a1f0_len_5390", OnDefeatEnemy);
INCLUDE_API_ASM("code_1a1f0_len_5390", OnFleeBattleDrops);
ApiStatus OnFleeBattleDrops(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerData* playerData = &gPlayerData;
if (isInitialCall) {
script->functionTemp[0] = 0;
script->functionTemp[1] = 40;
script->functionTemp[2] = 0;
}
script->functionTemp[2]++;
if (script->functionTemp[2] >= 5) {
if (rand_int(100) < 50) {
if (playerData->coins != 0) {
playerData->coins--;
make_item_entity_delayed(ItemId_COIN, playerStatus->position.x, playerStatus->position.y + playerStatus->colliderHeight,
playerStatus->position.z, 3, 0, 0);
}
}
script->functionTemp[2] = 0;
}
script->functionTemp[1]--;
return script->functionTemp[1] == 0;
}
INCLUDE_ASM("code_1a1f0_len_5390", func_8003F7CC);
INCLUDE_ASM("code_1a1f0_len_5390", func_8004135C);
void func_8004135C() {
}
INCLUDE_ASM("code_1a1f0_len_5390", func_80041364);
@ -24,16 +56,35 @@ INCLUDE_ASM("code_1a1f0_len_5390", show_first_strike_message);
INCLUDE_ASM("code_1a1f0_len_5390", func_80041F10);
INCLUDE_ASM("code_1a1f0_len_5390", func_8004304C);
s32 func_8004304C(void) {
EncounterStatus* currentEncounter = &gCurrentEncounter;
s32 ret = currentEncounter->unk_98;
if (ret != 0) {
func_80137D88(0, currentEncounter->unk_90);
ret = func_80137E10(0, 0, 0, 0);
}
return ret;
}
INCLUDE_ASM("code_1a1f0_len_5390", func_8004309C);
INCLUDE_ASM("code_1a1f0_len_5390", func_800431D4);
void func_800431D4() {
}
INCLUDE_ASM("code_1a1f0_len_5390", func_800431DC);
INCLUDE_ASM("code_1a1f0_len_5390", create_npcs);
INCLUDE_ASM("code_1a1f0_len_5390", func_80044140);
void func_80044140() {
}
INCLUDE_ASM("code_1a1f0_len_5390", func_80044148);
s32 func_80044148(void) {
s32 ret = gGameState == 3;
if (gCurrentEncounter.hitType == 5) {
ret = 1;
}
return ret;
}

View File

@ -64,9 +64,9 @@ s32 collision_heap_malloc(s32 size) {
}
s32 collision_heap_free(void* data) {
if (!(*gGameStatusPtr)->isBattle) {
_heap_free(&D_80268000, data);
if ((*gGameStatusPtr)->isBattle) {
return _heap_free(&D_803DA800, data);
} else {
_heap_free(&D_803DA800, data);
return _heap_free(&D_80268000, data);
}
}

View File

@ -170,7 +170,8 @@ INCLUDE_ASM("code_b72b0_len_15ed0", make_item_entity);
INCLUDE_ASM("code_b72b0_len_15ed0", make_item_entity_nodelay);
INCLUDE_ASM("code_b72b0_len_15ed0", make_item_entity_delayed);
void INCLUDE_ASM("code_b72b0_len_15ed0", make_item_entity_delayed, s32 itemID, f32 x, f32 y, f32 z, s32 unk1, s32 unk2,
s32 unk3);
INCLUDE_ASM("code_b72b0_len_15ed0", init_got_item);

View File

@ -8,7 +8,7 @@ void INCLUDE_ASM("code_cd180_len_38f0", func_80137DA4, s32 arg0, f32 arg1);
INCLUDE_ASM("code_cd180_len_38f0", func_80137DC0);
void INCLUDE_ASM("code_cd180_len_38f0", func_80137E10, s32 arg0, u8 arg1, u8 arg2, u8 arg3);
s32 INCLUDE_ASM("code_cd180_len_38f0", func_80137E10, s32 arg0, u8 arg1, u8 arg2, u8 arg3);
void INCLUDE_ASM("code_cd180_len_38f0", func_80137E4C, s32 arg0, s32 arg1, s32 arg2, s32 arg3);

View File

@ -16,7 +16,7 @@ void init_trigger_list(void) {
gTriggerCount = 0;
}
INCLUDE_ASM("code_dbd70_len_700", create_trigger);
Trigger* INCLUDE_ASM("code_dbd70_len_700", create_trigger, TriggerDefinition* def);
INCLUDE_ASM("code_dbd70_len_700", update_triggers);

View File

@ -18,18 +18,21 @@ INCLUDE_ASM("code_e79b0_len_1920", start_child_script);
INCLUDE_ASM("code_e79b0_len_1920", func_802C39F8);
#ifdef NON_MATCHING
ScriptInstance* restart_script(ScriptInstance* script) {
Bytecode* ptrFirstLine = script->ptrFirstLine;
// frameCounter gets set to 0 twice which makes me think a macro is being used here
script->loopDepth = -1;
script->switchDepth = -1;
script->frameCounter = 0;
script->currentOpcode = 0;
script->frameCounter = 0; // TODO: force compiler to not optimise away this
script->frameCounter = 0;
script->unk_158 = 0;
script->ptrNextLine = script->ptrFirstLine;
script->ptrCurrentLine = script->ptrFirstLine;
script->ptrNextLine = ptrFirstLine;
script->ptrCurrentLine = ptrFirstLine;
// ???
script->timeScale = 1.0f;
script->timeScale = gGlobalTimeSpace;
@ -38,9 +41,6 @@ ScriptInstance* restart_script(ScriptInstance* script) {
return script;
}
#else
INCLUDE_ASM("code_e79b0_len_1920", restart_script);
#endif
INCLUDE_ASM("code_e79b0_len_1920", update_scripts);
@ -126,9 +126,30 @@ void set_script_group(ScriptInstance* script, s8 groupFlags) {
script->groupFlags = groupFlags;
}
INCLUDE_ASM("code_e79b0_len_1920", bind_trigger);
Trigger* bind_trigger(Bytecode* script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1,
s32 priority, s32 arg6) {
Trigger* trigger;
TriggerDefinition def;
INCLUDE_ASM("code_e79b0_len_1920", bind_trigger_1);
def.flags = flags | 0x1000000;
def.flagIndex = triggerFlagIndex;
def.unk_14 = 0;
def.function = _bound_script_trigger_handler;
def.inputArg3 = arg6;
trigger = create_trigger(&def);
trigger->scriptStart = script;
trigger->runningScript = NULL;
trigger->priority = priority;
trigger->scriptVars[0] = triggerVar0;
trigger->scriptVars[1] = triggerVar1;
return trigger;
}
Trigger* bind_trigger_1(Bytecode* script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1,
s32 priority) {
return bind_trigger(script, flags, triggerFlagIndex, triggerVar0, triggerVar1, priority, 1);
}
void suspend_group_script(ScriptInstance* script, s32 groupFlags) {
int i;
@ -305,8 +326,7 @@ void set_script_flags(ScriptInstance* script, s32 flags) {
}
}
#ifdef NON_MATCHING
// TODO: Really close but some weirdness is going on
void clear_script_flags(ScriptInstance* script, s32 flags) {
int i;
ScriptInstance* scriptContextPtr;
@ -320,10 +340,7 @@ void clear_script_flags(ScriptInstance* script, s32 flags) {
for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) {
clear_script_flags(script->parentScript, flags);
clear_script_flags(scriptContextPtr, flags);
}
}
}
#else
INCLUDE_ASM("code_e79b0_len_1920", clear_script_flags);
#endif

View File

@ -594,7 +594,7 @@ ApiStatus si_handle_jump(ScriptInstance* script) {
return ApiStatus_DONE2;
}
INCLUDE_ASM("code_e92d0_len_5da0", _bound_script_trigger_handler);
s32 INCLUDE_ASM("code_e92d0_len_5da0", _bound_script_trigger_handler, Trigger* trigger);
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_bind);

View File

@ -39,9 +39,12 @@ D_0010CC10_end = 0x0010F1B0;
D_80074021 = 0x80074021;
D_800959D4 = 0x800959D4;
D_8009A5D8 = 0x8009A5D8;
gGameState = 0x8009A600;
D_8009A650 = 0x8009A650;
D_800A0900 = 0x800A0900;
gCurrentEncounter = 0x800B0F10;
gCameras = 0x800B1D80;
gCurrentCameraID = 0x80077410;
D_800DC500 = 0x800DC500;
D_8010F6D0 = 0x8010F6D0;
gBackgroundImage = 0x80200000;
@ -104,6 +107,7 @@ gCurrentDynamicEntityListPtr = 0x80154420;
gScriptIdList = 0x802D1898;
gScriptIndexList = 0x802DAA98;
gListCount = 0x802DAC98;
func_802A91F8 = 0x802A91F8;
func_802A9208 = 0x802A9208;