From b1c0c05bd3201cd0058325331a9d1e28951c5dac Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Mon, 16 May 2022 21:46:07 -0400 Subject: [PATCH] Identify some Actor count variables (#202) * Identify some Actor count variables * Match place_all_item_boxes Also more accurately define the UknownRock struct. Some of the track specific data is spawning points for the "permanent" actors (stuff like falling rocks, shrubbery, item boxes, etc.) Signed-off-by: Taggerung --- asm/bss_800029B0.s | 2 +- .../code_80005FD0/func_8001AC10.s | 12 +- .../code_80290C20/func_80295D88.s | 4 +- asm/non_matchings/code_actors/func_80296A50.s | 4 +- asm/non_matchings/code_actors/func_8029ABD4.s | 4 +- asm/non_matchings/code_actors/func_8029DAB8.s | 4 +- asm/non_matchings/code_actors/func_8029DB44.s | 12 +- asm/non_matchings/code_actors/func_8029E854.s | 4 +- asm/non_matchings/code_actors/func_8029E890.s | 4 +- .../code_actors/place_all_item_boxes.s | 118 ------ asm/non_matchings/memory/func_802AF314.s | 4 +- include/actor_types.h | 15 +- src/code_800029B0.c | 8 +- src/code_80005FD0.c | 6 +- src/code_80290C20.c | 2 +- src/code_80296A50.c | 353 +++++++----------- src/main.c | 2 +- src/memory.c | 4 +- 18 files changed, 173 insertions(+), 389 deletions(-) delete mode 100644 asm/non_matchings/code_actors/place_all_item_boxes.s diff --git a/asm/bss_800029B0.s b/asm/bss_800029B0.s index 21ee41a2b..e8cc412a5 100644 --- a/asm/bss_800029B0.s +++ b/asm/bss_800029B0.s @@ -241,7 +241,7 @@ glabel D_8015F8F4 glabel D_8015F8F6 .skip 10 -glabel D_8015F900 +glabel gNumPermanentActors .skip 184 glabel gActorList diff --git a/asm/non_matchings/code_80005FD0/func_8001AC10.s b/asm/non_matchings/code_80005FD0/func_8001AC10.s index 9f06b93e0..f8eb27ccb 100644 --- a/asm/non_matchings/code_80005FD0/func_8001AC10.s +++ b/asm/non_matchings/code_80005FD0/func_8001AC10.s @@ -580,8 +580,8 @@ glabel L8001B3B4 /* 01C0A4 8001B4A4 10000263 */ b .L8001BE34 /* 01C0A8 8001B4A8 86020004 */ lh $v0, 4($s0) glabel L8001B4AC -/* 01C0AC 8001B4AC 3C0E8015 */ lui $t6, %hi(D_80150110) # $t6, 0x8015 -/* 01C0B0 8001B4B0 95CE0110 */ lhu $t6, %lo(D_80150110)($t6) +/* 01C0AC 8001B4AC 3C0E8015 */ lui $t6, %hi(gNumActors) # $t6, 0x8015 +/* 01C0B0 8001B4B0 95CE0110 */ lhu $t6, %lo(gNumActors)($t6) /* 01C0B4 8001B4B4 29C10050 */ slti $at, $t6, 0x50 /* 01C0B8 8001B4B8 50200019 */ beql $at, $zero, .L8001B520 /* 01C0BC 8001B4BC A6000000 */ sh $zero, ($s0) @@ -687,8 +687,8 @@ glabel L8001B5B8 /* 01C228 8001B628 10000202 */ b .L8001BE34 /* 01C22C 8001B62C 86020004 */ lh $v0, 4($s0) glabel L8001B630 -/* 01C230 8001B630 3C0B8015 */ lui $t3, %hi(D_80150110) # $t3, 0x8015 -/* 01C234 8001B634 956B0110 */ lhu $t3, %lo(D_80150110)($t3) +/* 01C230 8001B630 3C0B8015 */ lui $t3, %hi(gNumActors) # $t3, 0x8015 +/* 01C234 8001B634 956B0110 */ lhu $t3, %lo(gNumActors)($t3) /* 01C238 8001B638 29610050 */ slti $at, $t3, 0x50 /* 01C23C 8001B63C 50200019 */ beql $at, $zero, .L8001B6A4 /* 01C240 8001B640 A6000000 */ sh $zero, ($s0) @@ -796,8 +796,8 @@ glabel L8001B738 /* 01C3B4 8001B7B4 1000019F */ b .L8001BE34 /* 01C3B8 8001B7B8 86020004 */ lh $v0, 4($s0) glabel L8001B7BC -/* 01C3BC 8001B7BC 3C0D8015 */ lui $t5, %hi(D_80150110) # $t5, 0x8015 -/* 01C3C0 8001B7C0 95AD0110 */ lhu $t5, %lo(D_80150110)($t5) +/* 01C3BC 8001B7BC 3C0D8015 */ lui $t5, %hi(gNumActors) # $t5, 0x8015 +/* 01C3C0 8001B7C0 95AD0110 */ lhu $t5, %lo(gNumActors)($t5) /* 01C3C4 8001B7C4 29A10050 */ slti $at, $t5, 0x50 /* 01C3C8 8001B7C8 50200019 */ beql $at, $zero, .L8001B830 /* 01C3CC 8001B7CC A6000000 */ sh $zero, ($s0) diff --git a/asm/non_matchings/code_80290C20/func_80295D88.s b/asm/non_matchings/code_80290C20/func_80295D88.s index 49c8cd591..78a5c81b4 100644 --- a/asm/non_matchings/code_80290C20/func_80295D88.s +++ b/asm/non_matchings/code_80290C20/func_80295D88.s @@ -1,6 +1,6 @@ glabel func_80295D88 -/* 0FF398 80295D88 3C018015 */ lui $at, %hi(D_80150110) # $at, 0x8015 -/* 0FF39C 80295D8C A4200110 */ sh $zero, %lo(D_80150110)($at) +/* 0FF398 80295D88 3C018015 */ lui $at, %hi(gNumActors) # $at, 0x8015 +/* 0FF39C 80295D8C A4200110 */ sh $zero, %lo(gNumActors)($at) /* 0FF3A0 80295D90 3C018016 */ lui $at, %hi(D_8015F6EA) # $at, 0x8016 /* 0FF3A4 80295D94 A420F6EA */ sh $zero, %lo(D_8015F6EA)($at) /* 0FF3A8 80295D98 3C018016 */ lui $at, %hi(D_8015F6EE) # $at, 0x8016 diff --git a/asm/non_matchings/code_actors/func_80296A50.s b/asm/non_matchings/code_actors/func_80296A50.s index 045af49fb..890f6076c 100644 --- a/asm/non_matchings/code_actors/func_80296A50.s +++ b/asm/non_matchings/code_actors/func_80296A50.s @@ -1,6 +1,6 @@ glabel func_80296A50 -/* 100060 80296A50 3C098016 */ lui $t1, %hi(D_8015F900) # $t1, 0x8016 -/* 100064 80296A54 9529F900 */ lhu $t1, %lo(D_8015F900)($t1) +/* 100060 80296A50 3C098016 */ lui $t1, %hi(gNumPermanentActors) # $t1, 0x8016 +/* 100064 80296A54 9529F900 */ lhu $t1, %lo(gNumPermanentActors)($t1) /* 100068 80296A58 27BDFFD0 */ addiu $sp, $sp, -0x30 /* 10006C 80296A5C AFBF0014 */ sw $ra, 0x14($sp) /* 100070 80296A60 29210064 */ slti $at, $t1, 0x64 diff --git a/asm/non_matchings/code_actors/func_8029ABD4.s b/asm/non_matchings/code_actors/func_8029ABD4.s index 4d759ef2e..33dde6665 100644 --- a/asm/non_matchings/code_actors/func_8029ABD4.s +++ b/asm/non_matchings/code_actors/func_8029ABD4.s @@ -2,8 +2,8 @@ glabel func_8029ABD4 /* 1041E4 8029ABD4 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 1041E8 8029ABD8 AFBF0014 */ sw $ra, 0x14($sp) /* 1041EC 8029ABDC AFA5001C */ sw $a1, 0x1c($sp) -/* 1041F0 8029ABE0 3C018015 */ lui $at, %hi(D_80150110) # $at, 0x8015 -/* 1041F4 8029ABE4 A4200110 */ sh $zero, %lo(D_80150110)($at) +/* 1041F0 8029ABE0 3C018015 */ lui $at, %hi(gNumActors) # $at, 0x8015 +/* 1041F4 8029ABE4 A4200110 */ sh $zero, %lo(gNumActors)($at) /* 1041F8 8029ABE8 0C0A7B4E */ jal func_8029ED38 /* 1041FC 8029ABEC 24050014 */ li $a1, 20 /* 104200 8029ABF0 000278C0 */ sll $t7, $v0, 3 diff --git a/asm/non_matchings/code_actors/func_8029DAB8.s b/asm/non_matchings/code_actors/func_8029DAB8.s index fcda29105..cd00b8069 100644 --- a/asm/non_matchings/code_actors/func_8029DAB8.s +++ b/asm/non_matchings/code_actors/func_8029DAB8.s @@ -1,9 +1,9 @@ glabel func_8029DAB8 -/* 1070C8 8029DAB8 3C018015 */ lui $at, %hi(D_80150110) # $at, 0x8015 +/* 1070C8 8029DAB8 3C018015 */ lui $at, %hi(gNumActors) # $at, 0x8015 /* 1070CC 8029DABC 3C038016 */ lui $v1, %hi(gActorList) # $v1, 0x8016 /* 1070D0 8029DAC0 3C028016 */ lui $v0, %hi(D_80162578) # $v0, 0x8016 /* 1070D4 8029DAC4 44800000 */ mtc1 $zero, $f0 -/* 1070D8 8029DAC8 A4200110 */ sh $zero, %lo(D_80150110)($at) +/* 1070D8 8029DAC8 A4200110 */ sh $zero, %lo(gNumActors)($at) /* 1070DC 8029DACC 24422578 */ addiu $v0, %lo(D_80162578) # addiu $v0, $v0, 0x2578 /* 1070E0 8029DAD0 2463F9B8 */ addiu $v1, %lo(gActorList) # addiu $v1, $v1, -0x648 .L8029DAD4: diff --git a/asm/non_matchings/code_actors/func_8029DB44.s b/asm/non_matchings/code_actors/func_8029DB44.s index f4072fa96..b8362ab69 100644 --- a/asm/non_matchings/code_actors/func_8029DB44.s +++ b/asm/non_matchings/code_actors/func_8029DB44.s @@ -19,8 +19,8 @@ glabel func_8029DB44 /* 107198 8029DB88 95410004 */ lhu $at, 4($t2) /* 10719C 8029DB8C A5210004 */ sh $at, 4($t1) /* 1071A0 8029DB90 9739C5A0 */ lhu $t9, %lo(gCurrentCourseId)($t9) -/* 1071A4 8029DB94 3C018016 */ lui $at, %hi(D_8015F900) # $at, 0x8016 -/* 1071A8 8029DB98 A420F900 */ sh $zero, %lo(D_8015F900)($at) +/* 1071A4 8029DB94 3C018016 */ lui $at, %hi(gNumPermanentActors) # $at, 0x8016 +/* 1071A8 8029DB98 A420F900 */ sh $zero, %lo(gNumPermanentActors)($at) /* 1071AC 8029DB9C 2F210014 */ sltiu $at, $t9, 0x14 /* 1071B0 8029DBA0 10200166 */ beqz $at, .L8029E13C /* 1071B4 8029DBA4 0019C880 */ sll $t9, $t9, 2 @@ -405,9 +405,9 @@ glabel L8029E130 .L8029E13C: /* 10774C 8029E13C 8FBF0014 */ lw $ra, 0x14($sp) .L8029E140: -/* 107750 8029E140 3C0E8015 */ lui $t6, %hi(D_80150110) # $t6, 0x8015 -/* 107754 8029E144 95CE0110 */ lhu $t6, %lo(D_80150110)($t6) -/* 107758 8029E148 3C018016 */ lui $at, %hi(D_8015F900) # 0x8016 +/* 107750 8029E140 3C0E8015 */ lui $t6, %hi(gNumActors) # $t6, 0x8015 +/* 107754 8029E144 95CE0110 */ lhu $t6, %lo(gNumActors)($t6) +/* 107758 8029E148 3C018016 */ lui $at, %hi(gNumPermanentActors) # 0x8016 /* 10775C 8029E14C 27BD0050 */ addiu $sp, $sp, 0x50 /* 107760 8029E150 03E00008 */ jr $ra -/* 107764 8029E154 A42EF900 */ sh $t6, %lo(D_8015F900)($at) # -0x700($at) +/* 107764 8029E154 A42EF900 */ sh $t6, %lo(gNumPermanentActors)($at) # -0x700($at) diff --git a/asm/non_matchings/code_actors/func_8029E854.s b/asm/non_matchings/code_actors/func_8029E854.s index 836a8b150..adbbc2d9b 100644 --- a/asm/non_matchings/code_actors/func_8029E854.s +++ b/asm/non_matchings/code_actors/func_8029E854.s @@ -4,8 +4,8 @@ glabel func_8029E854 /* 107E6C 8029E85C 0C0A79F7 */ jal func_8029E7DC /* 107E70 8029E860 AFA40018 */ sw $a0, 0x18($sp) /* 107E74 8029E864 8FA40018 */ lw $a0, 0x18($sp) -/* 107E78 8029E868 3C028015 */ lui $v0, %hi(D_80150110) # $v0, 0x8015 -/* 107E7C 8029E86C 24420110 */ addiu $v0, %lo(D_80150110) # addiu $v0, $v0, 0x110 +/* 107E78 8029E868 3C028015 */ lui $v0, %hi(gNumActors) # $v0, 0x8015 +/* 107E7C 8029E86C 24420110 */ addiu $v0, %lo(gNumActors) # addiu $v0, $v0, 0x110 /* 107E80 8029E870 A4800002 */ sh $zero, 2($a0) /* 107E84 8029E874 A4800000 */ sh $zero, ($a0) /* 107E88 8029E878 944E0000 */ lhu $t6, ($v0) diff --git a/asm/non_matchings/code_actors/func_8029E890.s b/asm/non_matchings/code_actors/func_8029E890.s index c98a0d729..667c7c162 100644 --- a/asm/non_matchings/code_actors/func_8029E890.s +++ b/asm/non_matchings/code_actors/func_8029E890.s @@ -1,7 +1,7 @@ glabel func_8029E890 /* 107EA0 8029E890 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 107EA4 8029E894 3C0B8016 */ lui $t3, %hi(D_8015F900) # $t3, 0x8016 -/* 107EA8 8029E898 956BF900 */ lhu $t3, %lo(D_8015F900)($t3) +/* 107EA4 8029E894 3C0B8016 */ lui $t3, %hi(gNumPermanentActors) # $t3, 0x8016 +/* 107EA8 8029E898 956BF900 */ lhu $t3, %lo(gNumPermanentActors)($t3) /* 107EAC 8029E89C AFB10020 */ sw $s1, 0x20($sp) /* 107EB0 8029E8A0 AFBF0024 */ sw $ra, 0x24($sp) /* 107EB4 8029E8A4 29610064 */ slti $at, $t3, 0x64 diff --git a/asm/non_matchings/code_actors/place_all_item_boxes.s b/asm/non_matchings/code_actors/place_all_item_boxes.s deleted file mode 100644 index e5cfb5e9d..000000000 --- a/asm/non_matchings/code_actors/place_all_item_boxes.s +++ /dev/null @@ -1,118 +0,0 @@ -glabel place_all_item_boxes -/* 106E40 8029D830 27BDFF78 */ addiu $sp, $sp, -0x88 -/* 106E44 8029D834 00047602 */ srl $t6, $a0, 0x18 -/* 106E48 8029D838 000E7880 */ sll $t7, $t6, 2 -/* 106E4C 8029D83C 3C188015 */ lui $t8, %hi(gSegmentTable) -/* 106E50 8029D840 030FC021 */ addu $t8, $t8, $t7 -/* 106E54 8029D844 3C0100FF */ lui $at, (0x00FFFFFF >> 16) # lui $at, 0xff -/* 106E58 8029D848 8F180258 */ lw $t8, %lo(gSegmentTable)($t8) -/* 106E5C 8029D84C 3421FFFF */ ori $at, (0x00FFFFFF & 0xFFFF) # ori $at, $at, 0xffff -/* 106E60 8029D850 0081C824 */ and $t9, $a0, $at -/* 106E64 8029D854 AFB00028 */ sw $s0, 0x28($sp) -/* 106E68 8029D858 3C08800E */ lui $t0, %hi(gModeSelection) # $t0, 0x800e -/* 106E6C 8029D85C 8D08C53C */ lw $t0, %lo(gModeSelection)($t0) -/* 106E70 8029D860 3C018000 */ lui $at, 0x8000 -/* 106E74 8029D864 03198021 */ addu $s0, $t8, $t9 -/* 106E78 8029D868 02018021 */ addu $s0, $s0, $at -/* 106E7C 8029D86C 24010001 */ li $at, 1 -/* 106E80 8029D870 AFBF004C */ sw $ra, 0x4c($sp) -/* 106E84 8029D874 AFBE0048 */ sw $fp, 0x48($sp) -/* 106E88 8029D878 AFB70044 */ sw $s7, 0x44($sp) -/* 106E8C 8029D87C AFB60040 */ sw $s6, 0x40($sp) -/* 106E90 8029D880 AFB5003C */ sw $s5, 0x3c($sp) -/* 106E94 8029D884 AFB40038 */ sw $s4, 0x38($sp) -/* 106E98 8029D888 AFB30034 */ sw $s3, 0x34($sp) -/* 106E9C 8029D88C AFB20030 */ sw $s2, 0x30($sp) -/* 106EA0 8029D890 AFB1002C */ sw $s1, 0x2c($sp) -/* 106EA4 8029D894 F7B60020 */ sdc1 $f22, 0x20($sp) -/* 106EA8 8029D898 11010049 */ beq $t0, $at, .L8029D9C0 -/* 106EAC 8029D89C F7B40018 */ sdc1 $f20, 0x18($sp) -/* 106EB0 8029D8A0 3C09800E */ lui $t1, %hi(gPlaceItemBoxes) # $t1, 0x800e -/* 106EB4 8029D8A4 8529C648 */ lh $t1, %lo(gPlaceItemBoxes)($t1) -/* 106EB8 8029D8A8 51200046 */ beql $t1, $zero, .L8029D9C4 -/* 106EBC 8029D8AC 8FBF004C */ lw $ra, 0x4c($sp) -/* 106EC0 8029D8B0 44800000 */ mtc1 $zero, $f0 -/* 106EC4 8029D8B4 27B20060 */ addiu $s2, $sp, 0x60 -/* 106EC8 8029D8B8 02402025 */ move $a0, $s2 -/* 106ECC 8029D8BC 44050000 */ mfc1 $a1, $f0 -/* 106ED0 8029D8C0 44060000 */ mfc1 $a2, $f0 -/* 106ED4 8029D8C4 44070000 */ mfc1 $a3, $f0 -/* 106ED8 8029D8C8 0C0AD4A7 */ jal vec3f_set -/* 106EDC 8029D8CC 00000000 */ nop -/* 106EE0 8029D8D0 86030000 */ lh $v1, ($s0) -/* 106EE4 8029D8D4 24138000 */ li $s3, -32768 -/* 106EE8 8029D8D8 3C0141A0 */ li $at, 0x41A00000 # 20.000000 -/* 106EEC 8029D8DC 12630038 */ beq $s3, $v1, .L8029D9C0 -/* 106EF0 8029D8E0 241E0070 */ li $fp, 112 -/* 106EF4 8029D8E4 4481B000 */ mtc1 $at, $f22 -/* 106EF8 8029D8E8 3C014120 */ li $at, 0x41200000 # 10.000000 -/* 106EFC 8029D8EC 3C178016 */ lui $s7, %hi(gActorList) # $s7, 0x8016 -/* 106F00 8029D8F0 3C148016 */ lui $s4, %hi(gCourseDirection) # $s4, 0x8016 -/* 106F04 8029D8F4 4481A000 */ mtc1 $at, $f20 -/* 106F08 8029D8F8 2694F784 */ addiu $s4, %lo(gCourseDirection) # addiu $s4, $s4, -0x87c -/* 106F0C 8029D8FC 26F7F9B8 */ addiu $s7, %lo(gActorList) # addiu $s7, $s7, -0x648 -/* 106F10 8029D900 27B60058 */ addiu $s6, $sp, 0x58 -/* 106F14 8029D904 27B5006C */ addiu $s5, $sp, 0x6c -/* 106F18 8029D908 44832000 */ mtc1 $v1, $f4 -.L8029D90C: -/* 106F1C 8029D90C C6880000 */ lwc1 $f8, ($s4) -/* 106F20 8029D910 468021A0 */ cvt.s.w $f6, $f4 -/* 106F24 8029D914 46083282 */ mul.s $f10, $f6, $f8 -/* 106F28 8029D918 E7AA006C */ swc1 $f10, 0x6c($sp) -/* 106F2C 8029D91C 860A0002 */ lh $t2, 2($s0) -/* 106F30 8029D920 448A8000 */ mtc1 $t2, $f16 -/* 106F34 8029D924 00000000 */ nop -/* 106F38 8029D928 468084A0 */ cvt.s.w $f18, $f16 -/* 106F3C 8029D92C E7B20070 */ swc1 $f18, 0x70($sp) -/* 106F40 8029D930 860B0004 */ lh $t3, 4($s0) -/* 106F44 8029D934 448B2000 */ mtc1 $t3, $f4 -/* 106F48 8029D938 00000000 */ nop -/* 106F4C 8029D93C 468021A0 */ cvt.s.w $f6, $f4 -/* 106F50 8029D940 0C0ADF65 */ jal random_u16 -/* 106F54 8029D944 E7A60074 */ swc1 $f6, 0x74($sp) -/* 106F58 8029D948 0C0ADF65 */ jal random_u16 -/* 106F5C 8029D94C A7A20058 */ sh $v0, 0x58($sp) -/* 106F60 8029D950 0C0ADF65 */ jal random_u16 -/* 106F64 8029D954 A7A2005A */ sh $v0, 0x5a($sp) -/* 106F68 8029D958 A7A2005C */ sh $v0, 0x5c($sp) -/* 106F6C 8029D95C 02A02025 */ move $a0, $s5 -/* 106F70 8029D960 02C02825 */ move $a1, $s6 -/* 106F74 8029D964 02403025 */ move $a2, $s2 -/* 106F78 8029D968 0C0A7B22 */ jal func_8029EC88 -/* 106F7C 8029D96C 2407000C */ li $a3, 12 -/* 106F80 8029D970 C7A80070 */ lwc1 $f8, 0x70($sp) -/* 106F84 8029D974 00028C00 */ sll $s1, $v0, 0x10 -/* 106F88 8029D978 00116403 */ sra $t4, $s1, 0x10 -/* 106F8C 8029D97C 01808825 */ move $s1, $t4 -/* 106F90 8029D980 C7AC006C */ lwc1 $f12, 0x6c($sp) -/* 106F94 8029D984 8FA60074 */ lw $a2, 0x74($sp) -/* 106F98 8029D988 0C0AB870 */ jal func_802AE1C0 -/* 106F9C 8029D98C 46144380 */ add.s $f14, $f8, $f20 -/* 106FA0 8029D990 023E0019 */ multu $s1, $fp -/* 106FA4 8029D994 46160401 */ sub.s $f16, $f0, $f22 -/* 106FA8 8029D998 C7AA0070 */ lwc1 $f10, 0x70($sp) -/* 106FAC 8029D99C 26100008 */ addiu $s0, $s0, 8 -/* 106FB0 8029D9A0 00006812 */ mflo $t5 -/* 106FB4 8029D9A4 02ED1021 */ addu $v0, $s7, $t5 -/* 106FB8 8029D9A8 E4400008 */ swc1 $f0, 8($v0) -/* 106FBC 8029D9AC E450001C */ swc1 $f16, 0x1c($v0) -/* 106FC0 8029D9B0 E44A0024 */ swc1 $f10, 0x24($v0) -/* 106FC4 8029D9B4 86030000 */ lh $v1, ($s0) -/* 106FC8 8029D9B8 5663FFD4 */ bnel $s3, $v1, .L8029D90C -/* 106FCC 8029D9BC 44832000 */ mtc1 $v1, $f4 -.L8029D9C0: -/* 106FD0 8029D9C0 8FBF004C */ lw $ra, 0x4c($sp) -.L8029D9C4: -/* 106FD4 8029D9C4 D7B40018 */ ldc1 $f20, 0x18($sp) -/* 106FD8 8029D9C8 D7B60020 */ ldc1 $f22, 0x20($sp) -/* 106FDC 8029D9CC 8FB00028 */ lw $s0, 0x28($sp) -/* 106FE0 8029D9D0 8FB1002C */ lw $s1, 0x2c($sp) -/* 106FE4 8029D9D4 8FB20030 */ lw $s2, 0x30($sp) -/* 106FE8 8029D9D8 8FB30034 */ lw $s3, 0x34($sp) -/* 106FEC 8029D9DC 8FB40038 */ lw $s4, 0x38($sp) -/* 106FF0 8029D9E0 8FB5003C */ lw $s5, 0x3c($sp) -/* 106FF4 8029D9E4 8FB60040 */ lw $s6, 0x40($sp) -/* 106FF8 8029D9E8 8FB70044 */ lw $s7, 0x44($sp) -/* 106FFC 8029D9EC 8FBE0048 */ lw $fp, 0x48($sp) -/* 107000 8029D9F0 03E00008 */ jr $ra -/* 107004 8029D9F4 27BD0088 */ addiu $sp, $sp, 0x88 diff --git a/asm/non_matchings/memory/func_802AF314.s b/asm/non_matchings/memory/func_802AF314.s index 3feea7146..4f08c6577 100644 --- a/asm/non_matchings/memory/func_802AF314.s +++ b/asm/non_matchings/memory/func_802AF314.s @@ -9,7 +9,7 @@ glabel func_802AF314 /* 118940 802AF330 8739F6F2 */ lh $t9, %lo(D_8015F6F2)($t9) /* 118944 802AF334 8718F6F0 */ lh $t8, %lo(D_8015F6F0)($t8) /* 118948 802AF338 3C028015 */ lui $v0, %hi(D_8014F110) # $v0, 0x8015 -/* 11894C 802AF33C 3C038015 */ lui $v1, %hi(D_80150110) # $v1, 0x8015 +/* 11894C 802AF33C 3C038015 */ lui $v1, %hi(gNumActors) # $v1, 0x8015 /* 118950 802AF340 AFBF0044 */ sw $ra, 0x44($sp) /* 118954 802AF344 AFBE0040 */ sw $fp, 0x40($sp) /* 118958 802AF348 AFB7003C */ sw $s7, 0x3c($sp) @@ -20,7 +20,7 @@ glabel func_802AF314 /* 11896C 802AF35C AFB20028 */ sw $s2, 0x28($sp) /* 118970 802AF360 AFB10024 */ sw $s1, 0x24($sp) /* 118974 802AF364 AFB00020 */ sw $s0, 0x20($sp) -/* 118978 802AF368 24630110 */ addiu $v1, %lo(D_80150110) # addiu $v1, $v1, 0x110 +/* 118978 802AF368 24630110 */ addiu $v1, %lo(gNumActors) # addiu $v1, $v1, 0x110 /* 11897C 802AF36C 2442F110 */ addiu $v0, %lo(D_8014F110) # addiu $v0, $v0, -0xef0 /* 118980 802AF370 01CF2023 */ subu $a0, $t6, $t7 /* 118984 802AF374 03192823 */ subu $a1, $t8, $t9 diff --git a/include/actor_types.h b/include/actor_types.h index 0d6186f0c..8791adc2f 100644 --- a/include/actor_types.h +++ b/include/actor_types.h @@ -118,20 +118,11 @@ struct FallingRock { /* 0x30 */ UnkActorInner unk30; }; // size = 0x70 -// Data in course_choco_mountain_dl.bin -// 7230? -// func_8029CF0C -struct innerFR { - Vec3s data; - u16 unk2; +struct ActorSpawnData { + /* 0x00 */ Vec3s pos; + /* 0x06 */ u16 someId; // Usually populated, but not necessarily used by all actors types }; -typedef union { - struct innerFR unk; - s32 unk2; - s32 unk3; -} UnknownFallingRock; - struct YoshiValleyEgg { /* 0x00 */ s16 type; /* 0x02 */ s16 flags; diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 6c5426978..7c54da4aa 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -75,10 +75,10 @@ extern u32 *D_06014330; extern f32 gCourseDirection; -extern u16 D_8015F900; +extern u16 gNumPermanentActors; extern s16 D_800DC5BC, D_800DC5C8; -extern u16 D_80150110; +extern u16 gNumActors; s32 D_800DC5E0 = 32; @@ -245,7 +245,7 @@ void func_80003040(void) { D_800DC5BC = 0; D_800DC5C8 = 0; - D_80150110 = 0; + gNumActors = 0; gIsMirrorMode = 0; gCourseDirection = 1.0f; @@ -314,5 +314,5 @@ void func_80003040(void) { default: break; } - D_8015F900 = D_80150110; + gNumPermanentActors = gNumActors; } diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index c02eb54f9..2cbfc6d71 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -13504,7 +13504,7 @@ block_194: temp_s0->unk0 = 0; goto block_194; case 4: /* switch 1 */ - if (D_80150110 < 0x50) { + if (gNumActors < 0x50) { temp_s0->unk2 = func_802B1C9C(sp2C, temp_a1); temp_v1_5 = temp_s0->unk2; if ((temp_v1_5 >= 0) && (temp_v1_5 < 0x64)) { @@ -13545,7 +13545,7 @@ block_71: } goto block_194; case 7: /* switch 1 */ - if (D_80150110 < 0x50) { + if (gNumActors < 0x50) { temp_s0->unk2 = func_802B1E48(sp2C, temp_a1); temp_v1_6 = temp_s0->unk2; if ((temp_v1_6 >= 0) && (temp_v1_6 < 0x64)) { @@ -13586,7 +13586,7 @@ block_92: } goto block_194; case 10: /* switch 1 */ - if (D_80150110 < 0x50) { + if (gNumActors < 0x50) { temp_s0->unk2 = func_802B17F4(sp2C, temp_a1); temp_v1_7 = temp_s0->unk2; if ((temp_v1_7 >= 0) && (temp_v1_7 < 0x64)) { diff --git a/src/code_80290C20.c b/src/code_80290C20.c index 0619f470b..36c061c5a 100644 --- a/src/code_80290C20.c +++ b/src/code_80290C20.c @@ -2280,7 +2280,7 @@ void func_80295D88(void) { u16 temp_t7; f32 phi_f10; - D_80150110 = 0; + gNumActors = 0; D_8015F6EA = 0; D_8015F6EE = 0; D_8015F6F2 = 0; diff --git a/src/code_80296A50.c b/src/code_80296A50.c index f7983a868..1ab4c176f 100644 --- a/src/code_80296A50.c +++ b/src/code_80296A50.c @@ -56,7 +56,7 @@ u16 D_802BA260; ? func_8000EE58(u16, void *, u16, s32); /* extern */ ? func_8029E854(void *, void *); /* extern */ extern u16 D_8015F6FE; -extern u16 D_8015F900; +extern u16 gNumPermanentActors; extern ? gActorList; void func_80296A50(s32 arg0, s32 arg3) { @@ -81,7 +81,7 @@ void func_80296A50(s32 arg0, s32 arg3) { u16 phi_a2_6; s32 phi_a3; - temp_t1 = D_8015F900; + temp_t1 = gNumPermanentActors; phi_a2 = temp_t1; phi_a3 = arg3; if (temp_t1 < 0x64) { @@ -105,10 +105,10 @@ loop_2: goto loop_2; } block_10: - phi_a2_2 = D_8015F900; - phi_a2_3 = D_8015F900; - if (D_8015F900 < 0x64) { - phi_a1_2 = (D_8015F900 * 0x70) + &gActorList; + phi_a2_2 = gNumPermanentActors; + phi_a2_3 = gNumPermanentActors; + if (gNumPermanentActors < 0x64) { + phi_a1_2 = (gNumPermanentActors * 0x70) + &gActorList; loop_12: if ((arg0 != phi_a1_2) && ((phi_a1_2->unk2 & 0xF) == 0) && (phi_a1_2->unk0 == 8)) { temp_t3 = phi_a1_2->unk6; @@ -454,11 +454,11 @@ void func_80297340(Camera *arg0) { s16 temp = D_8015F8D0[2]; if (D_800DC50C == CREDITS_SEQUENCE) { return; } - + mtxf_translate(sp38, D_8015F8D0); - + if (func_802B4FF8(sp38, 0) == 0) { return; } - + if (temp < arg0->pos[2]) { if (D_800DC5BC != 0) { @@ -572,7 +572,6 @@ void func_80297818(void) { temp_a0_5 = temp_a0 & 0x1; *phi_v0 = (temp_a0_2 >> 5) | (temp_a0_3 << 5) | temp_a0_4 | temp_a0_5; - phi_v1++; phi_v0++; } @@ -623,11 +622,11 @@ void func_80297A50(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp = func_802B80D0(camera->pos, arg2->unk18, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B95F8); if (temp < 0.0f) { return; } - + arg1[3][0] = arg2->unk18[0]; arg1[3][1] = arg2->unk18[1]; arg1[3][2] = arg2->unk18[2]; - + if (func_802B4FF8(arg1, 0) != 0) { return; } temp_t0 = arg2->unk6; switch (temp_t0) { @@ -999,7 +998,7 @@ void func_80298328(Camera *arg0, Mat4 arg1, struct PiranhaPlant *arg2) { if (temp & 0x800) { return; } temp_f0 = func_802B80D0(arg0->pos, arg2->pos, arg0->rotX[1], 0, D_80150130[arg0 - camera1], D_802B9624); - + if (temp_f0 < 0.0f) { switch(temp_lo) { @@ -1023,9 +1022,9 @@ void func_80298328(Camera *arg0, Mat4 arg1, struct PiranhaPlant *arg2) { arg1[3][1] = arg2->pos[1]; arg1[3][2] = arg2->pos[2]; if (func_802B4FF8(arg1, 0) == 0) { return; } - + if (D_802B9628 < temp_f0) { - + switch(temp_lo) { case 0: arg2->visibilityStates[0] = 0; @@ -1546,7 +1545,7 @@ extern Gfx D_06015B48[]; void func_8029930C(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B9660); @@ -1573,7 +1572,7 @@ extern Gfx D_0600D4A0[]; void func_802994D4(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B9668); @@ -1599,7 +1598,7 @@ extern Gfx D_06013F20[]; void func_8029969C(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B9670); @@ -1626,7 +1625,7 @@ extern Gfx D_0600FC70[]; void func_80299864(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B9674); @@ -1653,7 +1652,7 @@ extern Gfx D_0600D578[]; void func_80299A2C(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B967C); @@ -1680,7 +1679,7 @@ extern Gfx D_060090C8[]; void func_80299BF4(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B9684); @@ -1706,7 +1705,7 @@ extern Gfx D_060075A0[]; void func_80299DBC(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B968C); @@ -1732,7 +1731,7 @@ extern Gfx D_06008528[]; void func_80299EDC(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B9694); @@ -1758,7 +1757,7 @@ extern Gfx D_06008628[]; void func_80299FFC(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B969C); @@ -1784,7 +1783,7 @@ extern Gfx D_06008728[]; void func_8029A11C(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; s16 temp_v0 = arg2->flags; - + if ((temp_v0 & 0x800) != 0) { return; } temp_f0 = func_802B80D0(camera->pos, arg2->pos, camera->rotX[1], 0, D_80150130[camera - camera1], D_802B96A4); @@ -1807,7 +1806,7 @@ extern Gfx D_06013BB8[]; void func_8029A23C(Camera *camera, Mat4 arg1, struct Actor *actor) { uintptr_t addr; - + if (actor->state == 0) { return; } arg1[3][0] = actor->pos[0]; @@ -1870,7 +1869,6 @@ void func_8029A3AC(Camera *camera, Mat4 arg1, struct ShellActor *shell) { if (temp_t8 < 8) { gSPDisplayList(gDisplayListHead++, D_0D005338); - } else { gSPDisplayList(gDisplayListHead++, D_0D005368); } @@ -1989,12 +1987,12 @@ void update_obj_mario_raceway_sign(struct Actor *arg0) { #ifdef MIPS_TO_C //generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd -extern s16 D_80150110; +extern s16 gNumActors; extern ? D_8015F9BE; void func_8029ABD4(s16 arg1, s32 arg1) { arg1 = M2C_ERROR(Read from unset register $a1); - D_80150110 = 0; + gNumActors = 0; *(&D_8015F9BE + (func_8029ED38((f32 *) arg1, (s16 *)0x00000014) * 0x70)) = (s16) arg1; } #else @@ -2178,7 +2176,7 @@ void func_8029B2E4(Camera *arg0, struct Actor *arg1) { temp_f0 = func_802B80D0(arg0->pos, arg1->pos, arg0->rotX[1], 2500.0f, D_80150130[arg0 - camera1], D_802B96F0); if (temp_f0 < 0.0f) { return; } - + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); @@ -2393,7 +2391,7 @@ void func_8029B8E8(Camera *camera, struct TrainCar *actor) { gSPDisplayList(gDisplayListHead++, D_06022D70); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - + func_802B59DC(sp120, (s16) (actor->wheelRot + 0x2D8)); vec3f_set(&sp160, 17.0f, 12.0f, -34.0f); mtxf_translate(spE0, &sp160); @@ -2600,7 +2598,7 @@ void func_8029C3CC(Camera *camera, struct TrainCar *actor) { gSPDisplayList(gDisplayListHead++, D_06022DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - + func_802B59DC(sp120, (s16) (actor->wheelRot + 0x16C)); vec3f_set(&sp160, 17.0f, 6.0f, -24.0f); mtxf_translate(spE0, &sp160); @@ -2641,7 +2639,7 @@ void func_8029CA90(Camera *camera, struct FallingRock *rock) { temp_f0 = func_802B80D0(camera->pos, rock->pos, camera->rotX[1], 400.0f, D_80150130[camera - camera1], D_802B9750); if (temp_f0 < 0.0f) { return; } - + if ((temp_f0 < D_802B9754) && (rock->unk30.unk34 == 1)) { sp8C[0] = rock->pos[0]; sp8C[2] = rock->pos[2]; @@ -2664,25 +2662,25 @@ block_6: } } -void place_piranha_plants(Gfx *displaylist) { - s32 segment = SEGMENT_NUMBER2(displaylist); - s32 offset = SEGMENT_OFFSET(displaylist); - UnknownFallingRock *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); +void place_piranha_plants(struct ActorSpawnData *spawnData) { + s32 segment = SEGMENT_NUMBER2(spawnData); + s32 offset = SEGMENT_OFFSET(spawnData); + struct ActorSpawnData *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); struct PiranhaPlant *temp_v1; s32 pad; - Vec3f sp60; - Vec3f sp54; - Vec3s sp4C; + Vec3f startingPos; + Vec3f startingVelocity; + Vec3s startingRot; s32 temp; - - vec3f_set(sp54, 0, 0, 0); - vec3s_set(sp4C, 0, 0, 0); - - while (temp_s0->unk.data[0] != -0x8000) { - sp60[0] = temp_s0->unk.data[0] * gCourseDirection; - sp60[1] = temp_s0->unk.data[1]; - sp60[2] = temp_s0->unk.data[2]; - temp = func_8029EC88(sp60, sp4C, sp54, ACTOR_PIRANHA_PLANT); + + vec3f_set(startingVelocity, 0, 0, 0); + vec3s_set(startingRot, 0, 0, 0); + + while (temp_s0->pos[0] != -0x8000) { + startingPos[0] = temp_s0->pos[0] * gCourseDirection; + startingPos[1] = temp_s0->pos[1]; + startingPos[2] = temp_s0->pos[2]; + temp = func_8029EC88(startingPos, startingRot, startingVelocity, ACTOR_PIRANHA_PLANT); temp_v1 = (struct PiranhaPlant *) &gActorList[temp]; temp_v1->visibilityStates[0] = 0; temp_v1->visibilityStates[1] = 0; @@ -2696,126 +2694,74 @@ void place_piranha_plants(Gfx *displaylist) { } } -void place_palm_trees(Gfx *displaylist) { - s32 segment = SEGMENT_NUMBER2(displaylist); - s32 offset = SEGMENT_OFFSET(displaylist); - UnknownFallingRock *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); +void place_palm_trees(struct ActorSpawnData *spawnData) { + s32 segment = SEGMENT_NUMBER2(spawnData); + s32 offset = SEGMENT_OFFSET(spawnData); + struct ActorSpawnData *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); struct PalmTree *temp_v1; - Vec3f sp60; - Vec3f sp54; - Vec3s sp4C; + Vec3f startingPos; + Vec3f startingVelocity; + Vec3s startingRot; s32 temp; - - vec3f_set(sp54, 0, 0, 0); - vec3s_set(sp4C, 0, 0, 0); - - while (temp_s0->unk.data[0] != -0x8000) { - sp60[0] = temp_s0->unk.data[0] * gCourseDirection; - sp60[1] = temp_s0->unk.data[1]; - sp60[2] = temp_s0->unk.data[2]; - temp = func_8029EC88(sp60, sp4C, sp54, ACTOR_PALM_TREE); + + vec3f_set(startingVelocity, 0, 0, 0); + vec3s_set(startingRot, 0, 0, 0); + + while (temp_s0->pos[0] != -0x8000) { + startingPos[0] = temp_s0->pos[0] * gCourseDirection; + startingPos[1] = temp_s0->pos[1]; + startingPos[2] = temp_s0->pos[2]; + temp = func_8029EC88(startingPos, startingRot, startingVelocity, ACTOR_PALM_TREE); temp_v1 = (struct PalmTree *) &gActorList[temp]; - temp_v1->visibilityStates[0] = temp_s0->unk.unk2; + temp_v1->visibilityStates[0] = temp_s0->someId; func_802ADDC8((UnkActorInner *) &temp_v1->unk30, 5.0f, temp_v1->pos[0], temp_v1->pos[1], temp_v1->pos[2]); func_802976EC((UnkActorInner *) &temp_v1->unk30, temp_v1->unk10); temp_s0++; } } -void func_8029CF0C(Gfx *displaylist, struct FallingRock *rock) { - s32 segment = SEGMENT_NUMBER2(displaylist); - s32 offset = SEGMENT_OFFSET(displaylist); - UnknownFallingRock *temp_v0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); // + (temp_v1 * 8); +void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { + s32 segment = SEGMENT_NUMBER2(spawnData); + s32 offset = SEGMENT_OFFSET(spawnData); + struct ActorSpawnData *temp_v0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); // + (temp_v1 * 8); Vec3s sp24 = {60, 120, 180}; temp_v0 += rock->unk_06; rock->respawnTimer = sp24[rock->unk_06]; // * 2 - rock->pos[0] = (f32) temp_v0->unk.data[0] * gCourseDirection; - rock->pos[1] = (f32) temp_v0->unk.data[1] + 10.0f; - rock->pos[2] = (f32) temp_v0->unk.data[2]; + rock->pos[0] = (f32) temp_v0->pos[0] * gCourseDirection; + rock->pos[1] = (f32) temp_v0->pos[1] + 10.0f; + rock->pos[2] = (f32) temp_v0->pos[2]; vec3f_set(rock->velocity, 0, 0, 0); vec3s_set(rock->rot, 0, 0, 0); } void func_802AAAAC(UnkActorInner*); -void place_falling_rocks(Gfx *displaylist) { - s32 addr = SEGMENT_NUMBER2(displaylist); - s32 offset = SEGMENT_OFFSET(displaylist); - UnknownFallingRock *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr]) + offset; +void place_falling_rocks(struct ActorSpawnData *spawnData) { + s32 addr = SEGMENT_NUMBER2(spawnData); + s32 offset = SEGMENT_OFFSET(spawnData); + struct ActorSpawnData *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr]) + offset; struct FallingRock *temp_v1; - Vec3f sp60; - Vec3f sp54; - Vec3s sp4C; + Vec3f startingPos; + Vec3f startingVelocity; + Vec3s startingRot; s16 temp; - - - while (temp_s0->unk.data[0] != -0x8000) { - sp60[0] = temp_s0->unk.data[0] * gCourseDirection; - sp60[1] = temp_s0->unk.data[1] + 10.0f; - sp60[2] = temp_s0->unk.data[2]; - vec3f_set(sp54, 0, 0, 0); - vec3s_set(sp4C, 0, 0, 0); - temp = func_8029EC88(sp60, sp4C, sp54, ACTOR_FALLING_ROCK); + + while (temp_s0->pos[0] != -0x8000) { + startingPos[0] = temp_s0->pos[0] * gCourseDirection; + startingPos[1] = temp_s0->pos[1] + 10.0f; + startingPos[2] = temp_s0->pos[2]; + vec3f_set(startingVelocity, 0, 0, 0); + vec3s_set(startingRot, 0, 0, 0); + temp = func_8029EC88(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK); temp_v1 = (struct FallingRock *) &gActorList[temp]; - temp_v1->unk_06 = temp_s0->unk.unk2; + temp_v1->unk_06 = temp_s0->someId; func_802AAAAC((UnkActorInner *) &temp_v1->unk30); temp_s0++; } } -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_8029EC88(f32 *, ? *, ? *, ?); // extern -? func_802AAAAC(void *); // extern -? vec3s_set(? *, ?, ?, ?); // extern -? vec3f_set(? *, ?, ?, ?); // extern -extern ? gActorList; -extern f32 gCourseDirection; -extern ? gSegmentTable; - -void place_falling_rocks(u32 arg0) { - f32 sp6C; - f32 sp68; - f32 sp64; - ? sp58; - ? sp50; - f32 *temp_s4; - s16 *temp_s0; - s16 temp_v0; - s16 temp_v0_2; - void *temp_a0; - void *temp_v1; - s16 phi_v0; - s16 *phi_s0; - - temp_s0 = *(&gSegmentTable + ((arg0 >> 0x18) * 4)) + (arg0 & 0xFFFFFF) + 0x80000000; - temp_v0 = *temp_s0; - phi_v0 = temp_v0; - phi_s0 = temp_s0; - if (temp_v0 != -0x8000) { - temp_s4 = &sp64; - do { - sp64 = phi_v0 * gCourseDirection; - sp68 = phi_s0->unk2 + 10.0f; - sp6C = phi_s0->unk_04; - vec3f_set(&sp58, 0, 0, 0); - vec3s_set(&sp50, 0, 0, 0); - temp_v1 = &gActorList + (func_8029EC88(temp_s4, &sp50, &sp58, 5) * 0x70); - temp_a0 = temp_v1 + 0x30; - temp_v1->unk6 = phi_s0->unk6; - func_802AAAAC(temp_a0); - temp_v0_2 = phi_s0->unk_08; - phi_v0 = temp_v0_2; - phi_s0 += 8; - } while (temp_v0_2 != -0x8000); - } -} -#else -//GLOBAL_ASM("asm/non_matchings/code_actors/place_falling_rocks.s") -#endif - #ifdef MIPS_TO_C //generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd ? func_800C98B8(f32 *, f32 *, ?); /* extern */ @@ -3059,70 +3005,38 @@ void place_segment_06(u32 arg0) { GLOBAL_ASM("asm/non_matchings/code_actors/place_segment_06.s") #endif -#ifdef MIPS_TO_C -//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd -s16 func_8029EC88(f32 *, s16 *, ? *, ?); /* extern */ -f32 func_802AE1C0(f32, f32, f32); /* extern */ -? vec3f_set(? *, ?, ?, ?); /* extern */ -s16 random_u16(); /* extern */ -extern f32 gCourseDirection; +extern u16 random_u16(); /* extern */ +extern f32 func_802AE1C0(f32, f32, f32); extern s16 gPlaceItemBoxes; -void place_all_item_boxes(u32 arg0) { - f32 sp74; - f32 sp70; - f32 sp6C; - ? sp60; - s16 sp5C; - s16 sp5A; - s16 sp58; - f32 *temp_s5; - f32 temp_f0; - f32 temp_f16; - s16 *temp_s0; - s16 *temp_s0_2; - s16 *temp_s6; +void place_all_item_boxes(struct ActorSpawnData *spawnData) { s16 temp_s1; - s16 temp_v1; - s16 temp_v1_2; + f32 temp_f0; struct ItemBox *temp_v0; - s16 phi_v1; - s16 *phi_s0; + struct ActorSpawnData *temp_s0 = VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(spawnData)]) + SEGMENT_OFFSET(spawnData); + Vec3f startingPos; + Vec3f startingVelocity; + Vec3s startingRot; - temp_s0 = gSegmentTable[arg0 >> 0x18] + (arg0 & 0xFFFFFF) + 0x80000000; - phi_s0 = temp_s0; - if ((gModeSelection != 1) && (gPlaceItemBoxes != 0)) { - vec3f_set(&sp60, 0, 0, 0); - temp_v1 = *temp_s0; - phi_v1 = temp_v1; - if (temp_v1 != -0x8000) { - temp_s6 = &sp58; - temp_s5 = &sp6C; - do { - sp6C = (f32) phi_v1 * gCourseDirection; - sp70 = (f32) phi_s0->unk2; - sp74 = (f32) phi_s0->unk_04; - sp58 = random_u16(); - sp5A = random_u16(); - sp5C = random_u16(); - temp_s1 = func_8029EC88(temp_s5, temp_s6, &sp60, 0xC); - temp_f0 = func_802AE1C0(sp6C, sp70 + 10.0f, sp74); - temp_f16 = temp_f0 - 20.0f; - temp_s0_2 = phi_s0 + 8; - temp_v0 = &gActorList[temp_s1]; - temp_v0->resetDistance = temp_f0; - temp_v0->pos[1] = temp_f16; - temp_v0->origY = sp70; - temp_v1_2 = *temp_s0_2; - phi_v1 = temp_v1_2; - phi_s0 = temp_s0_2; - } while (temp_v1_2 != -0x8000); + if ((gModeSelection != TIME_TRIALS) && (gPlaceItemBoxes != 0)) { + vec3f_set(startingVelocity, 0, 0, 0); + while(temp_s0->pos[0] != -0x8000) { + startingPos[0] = temp_s0->pos[0] * gCourseDirection; + startingPos[1] = temp_s0->pos[1]; + startingPos[2] = temp_s0->pos[2]; + startingRot[0] = random_u16(); + startingRot[1] = random_u16(); + startingRot[2] = random_u16(); + temp_s1 = func_8029EC88(startingPos, startingRot, startingVelocity, ACTOR_ITEM_BOX); + temp_f0 = func_802AE1C0(startingPos[0], startingPos[1] + 10.0f, startingPos[2]); + temp_v0 = (struct ItemBox *) &gActorList[temp_s1]; + temp_v0->resetDistance = temp_f0; + temp_v0->origY = startingPos[1]; + temp_v0->pos[1] = temp_f0 - 20.0f; + temp_s0++; } } } -#else -GLOBAL_ASM("asm/non_matchings/code_actors/place_all_item_boxes.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 @@ -3157,14 +3071,14 @@ GLOBAL_ASM("asm/non_matchings/code_actors/func_8029D9F8.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern s16 D_80150110; +extern s16 gNumActors; //extern ? gActorList; extern s32 D_80162578; extern struct Actor gActorList[112]; void func_8029DAB8(void) { struct Actor *temp_v1; s32 i; - D_80150110 = 0; + gNumActors = 0; for (i = 0; i < ACTOR_LIST_SIZE; i++) { temp_v1 = &gActorList[i]; temp_v1->unk2 = 0; @@ -3224,8 +3138,8 @@ extern ? D_06018F70; extern ? D_06022E88; extern ? D_06022F08; extern ? D_06023AE0; -extern u16 D_80150110; -extern u16 D_8015F900; +extern u16 gNumActors; +extern u16 gNumPermanentActors; extern ? gActorList; extern ? D_8015F9BE; extern f32 gCourseDirection; @@ -3258,7 +3172,7 @@ void func_8029DB44(void) { sp2C.unk0 = D_802B885C.unk0; sp2C.unk4 = D_802B885C.unk4; temp_t9 = gCurrentCourseId; - D_8015F900 = 0; + gNumPermanentActors = 0; switch (temp_t9) { case COURSE_MARIO_RACEWAY: place_segment_06(&D_06009570); @@ -3386,7 +3300,7 @@ void func_8029DB44(void) { place_all_item_boxes(&D_06000058); break; } - D_8015F900 = D_80150110; + gNumPermanentActors = gNumActors; } #else GLOBAL_ASM("asm/non_matchings/code_actors/func_8029DB44.s") @@ -3600,13 +3514,13 @@ GLOBAL_ASM("asm/non_matchings/code_actors/func_8029E7DC.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 ? func_8029E7DC(); // extern -extern u16 D_80150110; +extern u16 gNumActors; void func_8029E854(void *arg0) { func_8029E7DC(); arg0->unk2 = 0; arg0->unk0 = 0; - D_80150110 = D_80150110 - 1; + gNumActors = gNumActors - 1; } #else GLOBAL_ASM("asm/non_matchings/code_actors/func_8029E854.s") @@ -3617,7 +3531,7 @@ GLOBAL_ASM("asm/non_matchings/code_actors/func_8029E854.s") ? func_8000EE58(s16, s16, s32, s32); /* extern */ ? func_80296D10(struct Actor *, s32, s16 *, f32 *, s32); /* extern */ ? func_8029E7DC(struct Actor *, s16, s32, s32); /* extern */ -extern u16 D_8015F900; +extern u16 gNumPermanentActors; s16 func_8029E890(s32 arg0, s16 *arg1, f32 *arg2, s16 actorType) { s16 temp_s1; @@ -3638,7 +3552,7 @@ s16 func_8029E890(s32 arg0, s16 *arg1, f32 *arg2, s16 actorType) { struct Actor *phi_s0_2; s16 phi_s1_2; - temp_t3 = D_8015F900; + temp_t3 = gNumPermanentActors; phi_s1 = (s16) temp_t3; if ((s32) temp_t3 < 0x64) { phi_s0 = &gActorList[temp_t3]; @@ -3705,9 +3619,9 @@ block_24: } } else { block_26: - phi_s1_2 = (s16) D_8015F900; - if ((s16) D_8015F900 < 0x64) { - phi_s0_2 = &gActorList[(s16) D_8015F900]; + phi_s1_2 = (s16) gNumPermanentActors; + if ((s16) gNumPermanentActors < 0x64) { + phi_s0_2 = &gActorList[(s16) gNumPermanentActors]; loop_28: temp_v0_5 = phi_s0_2->type; switch (temp_v0_5) { /* switch 3; irregular */ @@ -3779,17 +3693,17 @@ GLOBAL_ASM("asm/non_matchings/code_actors/func_8029E890.s") void func_80296D10(struct Actor *, f32 *, s16 *, f32 *, s32); /* extern */ s16 func_8029E890(f32 *, s16 *, f32 *, s16); /* extern */ -extern u16 D_80150110; +extern u16 gNumActors; s16 func_8029EC88(Vec3f pos, Vec3s rot, Vec3f velocity, s16 actorType) { s32 index; - if (D_80150110 >= ACTOR_LIST_SIZE) { + if (gNumActors >= ACTOR_LIST_SIZE) { return func_8029E890(pos, rot, velocity, actorType); } for(index = 0; index < ACTOR_LIST_SIZE; index++){ if (gActorList[index].flags == 0) { - D_80150110++; + gNumActors++; func_80296D10(&gActorList[index], pos, rot, velocity, actorType); return index; } @@ -4870,7 +4784,7 @@ void func_802A0D54(void) { } } -extern u16 D_8015F900; +extern u16 gNumPermanentActors; void func_802A0350(struct Actor*, struct Actor*); void func_802A0E44(void) { @@ -4879,7 +4793,7 @@ void func_802A0E44(void) { s32 i, j; s32 pad; - for (i = D_8015F900; i < (ACTOR_LIST_SIZE - 1); i++) { + for (i = gNumPermanentActors; i < (ACTOR_LIST_SIZE - 1); i++) { phi_s0 = &gActorList[i]; if ((phi_s0->flags & 0x8000) == 0) { continue; } @@ -4911,7 +4825,6 @@ void func_802A0E44(void) { if (phi_s0->rot[2] == temp_a1->rot[2]) { continue; } } func_802A0350(phi_s0, temp_a1); - break; case ACTOR_RED_SHELL: if (phi_s0->type == ACTOR_RED_SHELL) { @@ -5722,7 +5635,7 @@ void func_802A269C(Camera *arg0, struct Actor *arg1) { if (!(unk < 0.0f)) { gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); - + func_802B5F74(sp38, arg1->pos, arg1->rot); if (func_802B4FF8(sp38, 0) != 0) { @@ -5770,11 +5683,10 @@ void func_802A27A0(Camera *arg0, Mat4 arg1, struct YoshiValleyEgg *egg, u16 arg3 gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING); gSPDisplayList(gDisplayListHead++, D_06016D70); } else { - arg1[3][0] = egg->pos[0]; arg1[3][1] = egg->pos[1]; arg1[3][2] = egg->pos[2]; - + if (func_802B4FF8(arg1, 0) != 0) { gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gSPDisplayList(gDisplayListHead++, D_06017FA8); @@ -5835,7 +5747,6 @@ void func_802A2AD0(Camera *arg0, struct Actor *arg1) { gSPDisplayList(gDisplayListHead++, D_06010D38); } gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); - } extern s8 D_060185F8[]; @@ -5856,7 +5767,7 @@ void func_802A2C78(Camera *arg0, Mat4 arg1, struct Actor *arg2) { } temp_f0 = func_802B80D0(arg0->pos, arg2->pos, arg0->rotX[1], 0.0f, D_80150130[arg0 - camera1], 4000000.0f); - + if (!(temp_f0 < 0.0f)) { if (((temp_v0 & 0x400) == 0) && (temp_f0 < 250000.0f)) { func_8029794C(arg2->pos, arg2->rot, 2.0f); diff --git a/src/main.c b/src/main.c index 75bd92628..96a33caba 100644 --- a/src/main.c +++ b/src/main.c @@ -107,7 +107,7 @@ OSContPad gControllerPads[4]; u8 gControllerBits; u8 D_8014F110[4096]; -u16 D_80150110; +u16 gNumActors; u16 D_80150112; s32 D_80150114; f32 D_80150118; diff --git a/src/memory.c b/src/memory.c index c182a5549..aaafd507a 100644 --- a/src/memory.c +++ b/src/memory.c @@ -3961,7 +3961,7 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802AF0FC.s") //generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 s32 func_802AF0FC(s16, s16, s16, s16, s32); /* extern */ extern ? D_8014F110; -extern ? D_80150110; +extern ? gNumActors; extern s32 D_8015F584; extern u16 D_8015F58A; extern s16 D_8015F6E8; @@ -4001,7 +4001,7 @@ void func_802AF314(void) { temp_v0->unk-2 = 0; temp_v0->unk-E = 0; phi_v0 = temp_v0; - } while (temp_v0 != &D_80150110); + } while (temp_v0 != &gNumActors); D_8015F58A = 0; D_8015F584 = gPrevLoadedAddress; temp_s6 = (s32) (D_8015F6E8 - D_8015F6EA) / 32;