From 373dc7d2d82eea591e11d9a7917b72814799f539 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Wed, 18 Mar 2020 21:21:45 +0100 Subject: [PATCH 1/2] Fix ovl_Demo_Go non matchings (2/3 matched) `z_demo_go.c` is now functionally equivalent and almost fully matched. Note that I added a Vec3i struct in `z64actor.h` now used in `CsCmdActorAction`. Also fixed some missing VT codes in various actor strings. --- .../actors/ovl_Demo_Go/func_8097CB0C.s | 67 ------------- .../actors/ovl_Demo_Go/func_8097D29C.s | 95 ------------------- include/z64actor.h | 14 +-- include/z64cutscene.h | 6 +- src/overlays/actors/ovl_Demo_Go/z_demo_go.c | 79 +++++++-------- .../ovl_En_Anubice_Tag/z_en_anubice_tag.c | 4 +- .../z_en_okarina_effect.c | 4 +- 7 files changed, 58 insertions(+), 211 deletions(-) delete mode 100644 asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097CB0C.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097D29C.s diff --git a/asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097CB0C.s b/asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097CB0C.s deleted file mode 100644 index d3cd52a91b..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097CB0C.s +++ /dev/null @@ -1,67 +0,0 @@ -glabel func_8097CB0C -/* 0029C 8097CB0C 27BDFFC0 */ addiu $sp, $sp, 0xFFC0 ## $sp = FFFFFFC0 -/* 002A0 8097CB10 AFBF0014 */ sw $ra, 0x0014($sp) -/* 002A4 8097CB14 AFA40040 */ sw $a0, 0x0040($sp) -/* 002A8 8097CB18 90AE1D6C */ lbu $t6, 0x1D6C($a1) ## 00001D6C -/* 002AC 8097CB1C 51C00037 */ beql $t6, $zero, .L8097CBFC -/* 002B0 8097CB20 8FBF0014 */ lw $ra, 0x0014($sp) -/* 002B4 8097CB24 0C25F21C */ jal func_8097C870 -/* 002B8 8097CB28 AFA50044 */ sw $a1, 0x0044($sp) -/* 002BC 8097CB2C 8FA50044 */ lw $a1, 0x0044($sp) -/* 002C0 8097CB30 00027880 */ sll $t7, $v0, 2 -/* 002C4 8097CB34 24A71D64 */ addiu $a3, $a1, 0x1D64 ## $a3 = 00001D64 -/* 002C8 8097CB38 00EFC021 */ addu $t8, $a3, $t7 -/* 002CC 8097CB3C 8F030028 */ lw $v1, 0x0028($t8) ## 00000028 -/* 002D0 8097CB40 5060002E */ beql $v1, $zero, .L8097CBFC -/* 002D4 8097CB44 8FBF0014 */ lw $ra, 0x0014($sp) -/* 002D8 8097CB48 94640004 */ lhu $a0, 0x0004($v1) ## 00000004 -/* 002DC 8097CB4C 94650002 */ lhu $a1, 0x0002($v1) ## 00000002 -/* 002E0 8097CB50 94E60010 */ lhu $a2, 0x0010($a3) ## 00001D74 -/* 002E4 8097CB54 0C01BE4F */ jal func_8006F93C -/* 002E8 8097CB58 AFA30030 */ sw $v1, 0x0030($sp) -/* 002EC 8097CB5C 8FA30030 */ lw $v1, 0x0030($sp) -/* 002F0 8097CB60 8FA50040 */ lw $a1, 0x0040($sp) -/* 002F4 8097CB64 8C680010 */ lw $t0, 0x0010($v1) ## 00000010 -/* 002F8 8097CB68 8C79000C */ lw $t9, 0x000C($v1) ## 0000000C -/* 002FC 8097CB6C 8C6A0018 */ lw $t2, 0x0018($v1) ## 00000018 -/* 00300 8097CB70 8C690014 */ lw $t1, 0x0014($v1) ## 00000014 -/* 00304 8097CB74 44883000 */ mtc1 $t0, $f6 ## $f6 = 0.00 -/* 00308 8097CB78 8C6C0020 */ lw $t4, 0x0020($v1) ## 00000020 -/* 0030C 8097CB7C 44992000 */ mtc1 $t9, $f4 ## $f4 = 0.00 -/* 00310 8097CB80 8C6B001C */ lw $t3, 0x001C($v1) ## 0000001C -/* 00314 8097CB84 448A5000 */ mtc1 $t2, $f10 ## $f10 = 0.00 -/* 00318 8097CB88 46803320 */ cvt.s.w $f12, $f6 -/* 0031C 8097CB8C 44894000 */ mtc1 $t1, $f8 ## $f8 = 0.00 -/* 00320 8097CB90 448C3000 */ mtc1 $t4, $f6 ## $f6 = 0.00 -/* 00324 8097CB94 24A20024 */ addiu $v0, $a1, 0x0024 ## $v0 = 00000024 -/* 00328 8097CB98 468020A0 */ cvt.s.w $f2, $f4 -/* 0032C 8097CB9C 448B2000 */ mtc1 $t3, $f4 ## $f4 = 0.00 -/* 00330 8097CBA0 46805420 */ cvt.s.w $f16, $f10 -/* 00334 8097CBA4 468043A0 */ cvt.s.w $f14, $f8 -/* 00338 8097CBA8 46803220 */ cvt.s.w $f8, $f6 -/* 0033C 8097CBAC 468024A0 */ cvt.s.w $f18, $f4 -/* 00340 8097CBB0 E7A80018 */ swc1 $f8, 0x0018($sp) -/* 00344 8097CBB4 46028281 */ sub.s $f10, $f16, $f2 -/* 00348 8097CBB8 460C9201 */ sub.s $f8, $f18, $f12 -/* 0034C 8097CBBC 46005102 */ mul.s $f4, $f10, $f0 -/* 00350 8097CBC0 00000000 */ nop -/* 00354 8097CBC4 46004282 */ mul.s $f10, $f8, $f0 -/* 00358 8097CBC8 46022180 */ add.s $f6, $f4, $f2 -/* 0035C 8097CBCC 460C5100 */ add.s $f4, $f10, $f12 -/* 00360 8097CBD0 E4460000 */ swc1 $f6, 0x0000($v0) ## 00000024 -/* 00364 8097CBD4 E4440004 */ swc1 $f4, 0x0004($v0) ## 00000028 -/* 00368 8097CBD8 C7A60018 */ lwc1 $f6, 0x0018($sp) -/* 0036C 8097CBDC 460E3201 */ sub.s $f8, $f6, $f14 -/* 00370 8097CBE0 46004282 */ mul.s $f10, $f8, $f0 -/* 00374 8097CBE4 460E5100 */ add.s $f4, $f10, $f14 -/* 00378 8097CBE8 E4440008 */ swc1 $f4, 0x0008($v0) ## 0000002C -/* 0037C 8097CBEC 84640008 */ lh $a0, 0x0008($v1) ## 00000008 -/* 00380 8097CBF0 A4A400B6 */ sh $a0, 0x00B6($a1) ## 000000B6 -/* 00384 8097CBF4 A444000E */ sh $a0, 0x000E($v0) ## 00000032 -/* 00388 8097CBF8 8FBF0014 */ lw $ra, 0x0014($sp) -.L8097CBFC: -/* 0038C 8097CBFC 27BD0040 */ addiu $sp, $sp, 0x0040 ## $sp = 00000000 -/* 00390 8097CC00 03E00008 */ jr $ra -/* 00394 8097CC04 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097D29C.s b/asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097D29C.s deleted file mode 100644 index c0cb0a0e49..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097D29C.s +++ /dev/null @@ -1,95 +0,0 @@ -.rdata - -glabel D_8097D4CC - .asciz "../z_demo_go.c" - .balign 4 - -glabel D_8097D4DC - .asciz "../z_demo_go.c" - .balign 4 - -.text - -glabel func_8097D29C -/* 00A2C 8097D29C 27BDFFA0 */ addiu $sp, $sp, 0xFFA0 ## $sp = FFFFFFA0 -/* 00A30 8097D2A0 AFBF0024 */ sw $ra, 0x0024($sp) -/* 00A34 8097D2A4 AFA40060 */ sw $a0, 0x0060($sp) -/* 00A38 8097D2A8 AFA50064 */ sw $a1, 0x0064($sp) -/* 00A3C 8097D2AC 84820190 */ lh $v0, 0x0190($a0) ## 00000190 -/* 00A40 8097D2B0 3C188098 */ lui $t8, %hi(D_8097D440) ## $t8 = 80980000 -/* 00A44 8097D2B4 3C068098 */ lui $a2, %hi(D_8097D4CC) ## $a2 = 80980000 -/* 00A48 8097D2B8 00027880 */ sll $t7, $v0, 2 -/* 00A4C 8097D2BC 030FC021 */ addu $t8, $t8, $t7 -/* 00A50 8097D2C0 8F18D440 */ lw $t8, %lo(D_8097D440)($t8) -/* 00A54 8097D2C4 24C6D4CC */ addiu $a2, $a2, %lo(D_8097D4CC) ## $a2 = 8097D4CC -/* 00A58 8097D2C8 27A40038 */ addiu $a0, $sp, 0x0038 ## $a0 = FFFFFFD8 -/* 00A5C 8097D2CC AFB80050 */ sw $t8, 0x0050($sp) -/* 00A60 8097D2D0 8CA50000 */ lw $a1, 0x0000($a1) ## 00000000 -/* 00A64 8097D2D4 240702DC */ addiu $a3, $zero, 0x02DC ## $a3 = 000002DC -/* 00A68 8097D2D8 0C031AB1 */ jal func_800C6AC4 -/* 00A6C 8097D2DC AFA50048 */ sw $a1, 0x0048($sp) -/* 00A70 8097D2E0 8FA90064 */ lw $t1, 0x0064($sp) -/* 00A74 8097D2E4 0C024F46 */ jal func_80093D18 -/* 00A78 8097D2E8 8D240000 */ lw $a0, 0x0000($t1) ## 00000000 -/* 00A7C 8097D2EC 8FA80048 */ lw $t0, 0x0048($sp) -/* 00A80 8097D2F0 8FA40050 */ lw $a0, 0x0050($sp) -/* 00A84 8097D2F4 3C058016 */ lui $a1, 0x8016 ## $a1 = 80160000 -/* 00A88 8097D2F8 8D0302C0 */ lw $v1, 0x02C0($t0) ## 000002C0 -/* 00A8C 8097D2FC 00046100 */ sll $t4, $a0, 4 -/* 00A90 8097D300 000C6F02 */ srl $t5, $t4, 28 -/* 00A94 8097D304 3C0BDB06 */ lui $t3, 0xDB06 ## $t3 = DB060000 -/* 00A98 8097D308 246A0008 */ addiu $t2, $v1, 0x0008 ## $t2 = 00000008 -/* 00A9C 8097D30C 356B0020 */ ori $t3, $t3, 0x0020 ## $t3 = DB060020 -/* 00AA0 8097D310 000D7080 */ sll $t6, $t5, 2 -/* 00AA4 8097D314 24A56FA8 */ addiu $a1, $a1, 0x6FA8 ## $a1 = 80166FA8 -/* 00AA8 8097D318 AD0A02C0 */ sw $t2, 0x02C0($t0) ## 000002C0 -/* 00AAC 8097D31C 00AE7821 */ addu $t7, $a1, $t6 -/* 00AB0 8097D320 AC6B0000 */ sw $t3, 0x0000($v1) ## 00000000 -/* 00AB4 8097D324 8DF80000 */ lw $t8, 0x0000($t7) ## 00000000 -/* 00AB8 8097D328 3C0600FF */ lui $a2, 0x00FF ## $a2 = 00FF0000 -/* 00ABC 8097D32C 34C6FFFF */ ori $a2, $a2, 0xFFFF ## $a2 = 00FFFFFF -/* 00AC0 8097D330 0086C824 */ and $t9, $a0, $a2 -/* 00AC4 8097D334 3C078000 */ lui $a3, 0x8000 ## $a3 = 80000000 -/* 00AC8 8097D338 03194821 */ addu $t1, $t8, $t9 -/* 00ACC 8097D33C 01275021 */ addu $t2, $t1, $a3 -/* 00AD0 8097D340 AC6A0004 */ sw $t2, 0x0004($v1) ## 00000004 -/* 00AD4 8097D344 8D0302C0 */ lw $v1, 0x02C0($t0) ## 000002C0 -/* 00AD8 8097D348 3C040601 */ lui $a0, 0x0601 ## $a0 = 06010000 -/* 00ADC 8097D34C 2484E680 */ addiu $a0, $a0, 0xE680 ## $a0 = 0600E680 -/* 00AE0 8097D350 00046900 */ sll $t5, $a0, 4 -/* 00AE4 8097D354 000D7702 */ srl $t6, $t5, 28 -/* 00AE8 8097D358 3C0CDB06 */ lui $t4, 0xDB06 ## $t4 = DB060000 -/* 00AEC 8097D35C 246B0008 */ addiu $t3, $v1, 0x0008 ## $t3 = 00000008 -/* 00AF0 8097D360 358C0024 */ ori $t4, $t4, 0x0024 ## $t4 = DB060024 -/* 00AF4 8097D364 000E7880 */ sll $t7, $t6, 2 -/* 00AF8 8097D368 AD0B02C0 */ sw $t3, 0x02C0($t0) ## 000002C0 -/* 00AFC 8097D36C 00AFC021 */ addu $t8, $a1, $t7 -/* 00B00 8097D370 AC6C0000 */ sw $t4, 0x0000($v1) ## 00000000 -/* 00B04 8097D374 8F190000 */ lw $t9, 0x0000($t8) ## 00000000 -/* 00B08 8097D378 00864824 */ and $t1, $a0, $a2 -/* 00B0C 8097D37C 03295021 */ addu $t2, $t9, $t1 -/* 00B10 8097D380 01475821 */ addu $t3, $t2, $a3 -/* 00B14 8097D384 AC6B0004 */ sw $t3, 0x0004($v1) ## 00000004 -/* 00B18 8097D388 8FA30060 */ lw $v1, 0x0060($sp) -/* 00B1C 8097D38C 8FA40064 */ lw $a0, 0x0064($sp) -/* 00B20 8097D390 2462014C */ addiu $v0, $v1, 0x014C ## $v0 = 0000014C -/* 00B24 8097D394 8C450004 */ lw $a1, 0x0004($v0) ## 00000150 -/* 00B28 8097D398 8C460020 */ lw $a2, 0x0020($v0) ## 0000016C -/* 00B2C 8097D39C 90470002 */ lbu $a3, 0x0002($v0) ## 0000014E -/* 00B30 8097D3A0 AFA00014 */ sw $zero, 0x0014($sp) -/* 00B34 8097D3A4 AFA00010 */ sw $zero, 0x0010($sp) -/* 00B38 8097D3A8 0C0286B2 */ jal func_800A1AC8 -/* 00B3C 8097D3AC AFA30018 */ sw $v1, 0x0018($sp) -/* 00B40 8097D3B0 8FAC0064 */ lw $t4, 0x0064($sp) -/* 00B44 8097D3B4 3C068098 */ lui $a2, %hi(D_8097D4DC) ## $a2 = 80980000 -/* 00B48 8097D3B8 24C6D4DC */ addiu $a2, $a2, %lo(D_8097D4DC) ## $a2 = 8097D4DC -/* 00B4C 8097D3BC 27A40038 */ addiu $a0, $sp, 0x0038 ## $a0 = FFFFFFD8 -/* 00B50 8097D3C0 240702EA */ addiu $a3, $zero, 0x02EA ## $a3 = 000002EA -/* 00B54 8097D3C4 0C031AD5 */ jal func_800C6B54 -/* 00B58 8097D3C8 8D850000 */ lw $a1, 0x0000($t4) ## 00000000 -/* 00B5C 8097D3CC 8FBF0024 */ lw $ra, 0x0024($sp) -/* 00B60 8097D3D0 27BD0060 */ addiu $sp, $sp, 0x0060 ## $sp = 00000000 -/* 00B64 8097D3D4 03E00008 */ jr $ra -/* 00B68 8097D3D8 00000000 */ nop - - diff --git a/include/z64actor.h b/include/z64actor.h index a20382856e..6f81f04475 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -13,6 +13,11 @@ struct GlobalContext; // From z64light.h struct LightMapper; +typedef struct +{ + f32 x, y; +} Vec2f; + typedef struct { f32 x, y, z; @@ -25,13 +30,8 @@ typedef struct typedef struct { - f32 x, y; -} Vec2f; - -typedef struct -{ - u32 x, y; -} Vec2i; + s32 x, y, z; +} Vec3i; typedef struct { diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 97abc805ef..d7d27481ad 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -83,9 +83,9 @@ typedef struct /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; /* 0x06 */ Vec3s rot; - /* 0x0C */ Vec3f startPos; - /* 0x18 */ Vec3f endPos; - /* 0x24 */ Vec3f normal; + /* 0x0C */ Vec3i startPos; + /* 0x18 */ Vec3i endPos; + /* 0x24 */ Vec3i normal; } CsCmdActorAction; // size = 0x30 typedef enum diff --git a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c index 4ed28c7486..caafd18e0e 100644 --- a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c +++ b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c @@ -6,6 +6,8 @@ #include "z_demo_go.h" +#include + #define ROOM 0x00 #define FLAGS 0x00000010 @@ -25,7 +27,7 @@ void func_8097D130(DemoGo* this, GlobalContext* globalCtx); void func_8097D290(DemoGo* this, GlobalContext* globalCtx); void func_8097D29C(DemoGo* this, GlobalContext* globalCtx); -u32 D_8097D440[] = {0x0600CE80, 0x0600D280, 0x0600D680}; +UNK_PTR D_8097D440[] = {0x0600CE80, 0x0600D280, 0x0600D680}; ActorFunc D_8097D44C[] = { @@ -58,9 +60,10 @@ const ActorInit Demo_Go_InitVars = (ActorFunc)DemoGo_Draw, }; -extern u32 D_060029A8; -extern u32 D_0600FEF0; -extern u32 D_06004930; +extern UNK_TYPE D_060029A8; +extern UNK_TYPE D_06004930; +extern UNK_TYPE D_0600E680; +extern UNK_TYPE D_0600FEF0; UNK_TYPE func_8097C870(DemoGo *this) { @@ -149,33 +152,36 @@ void func_8097CA78(DemoGo* this, GlobalContext* globalCtx) func_8097C9B8(this); } -// Not equivalent, I believe in part due to actorAction->endPos being the wrong type, holding floats instead of ints -#ifdef NON_MATCHING -void func_8097CB0C(DemoGo* this, GlobalContext* globalCtx) { +void func_8097CB0C(DemoGo* this, GlobalContext* globalCtx) +{ Actor* thisx = &this->actor; + PosRot* posRot = &thisx->posRot; CutsceneContext* csCtx = &globalCtx->csCtx; - Vec3f startPos; - f32 temp_ret; CsCmdActorAction* actorAction; + f32 temp_ret; + s32 pad; + Vec3f startPos; + Vec3f endPos; if (globalCtx->csCtx.state != 0) { actorAction = csCtx->actorActions[func_8097C870(this)]; - if (actorAction != 0) + if (actorAction != NULL) { temp_ret = func_8006F93C(actorAction->endFrame, actorAction->startFrame, csCtx->frames); - startPos = actorAction->startPos; - thisx->posRot.pos.x = (((actorAction->endPos.x - startPos.x) * temp_ret) + startPos.x); - thisx->posRot.pos.y = (((actorAction->endPos.y - startPos.y) * temp_ret) + startPos.y); - thisx->posRot.pos.z = (((actorAction->endPos.z - startPos.z) * temp_ret) + startPos.z); - thisx->shape.rot.y = actorAction->rot.y; - thisx->posRot.rot.y = actorAction->rot.y; + startPos.x = actorAction->startPos.x; + startPos.y = actorAction->startPos.y; + startPos.z = actorAction->startPos.z; + endPos.x = actorAction->endPos.x; + endPos.y = actorAction->endPos.y; + endPos.z = actorAction->endPos.z; + posRot->pos.x = (((endPos.x - startPos.x) * temp_ret) + startPos.x); + posRot->pos.y = (((endPos.y - startPos.y) * temp_ret) + startPos.y); + posRot->pos.z = (((endPos.z - startPos.z) * temp_ret) + startPos.z); + posRot->rot.y = thisx->shape.rot.y = actorAction->rot.y; } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097CB0C.s") -#endif void func_8097CC08(DemoGo* this) { @@ -207,7 +213,7 @@ void func_8097CCE0(DemoGo* this, GlobalContext* globalCtx) if (globalCtx->csCtx.state != 0) { actorAction = globalCtx->csCtx.actorActions[func_8097C870(this)]; - if (actorAction != 0) + if (actorAction != NULL) { thisRotY = thisx->posRot.rot.y; rotYDelta = actorAction->rot.y - thisRotY; @@ -234,15 +240,15 @@ UNK_TYPE DemoGo_FrameUpdateMatrix(DemoGo* this) return SkelAnime_FrameUpdateMatrix(&this->skelAnime); } -// This is probably at least close to equivalent but not necessarily so #ifdef NON_MATCHING -UNK_TYPE func_8097CDB0(DemoGo* this, GlobalContext* globalCtx, u16 csCmdActorAction) +// return value isn't produced in the same way +s32 func_8097CDB0(DemoGo* this, GlobalContext* globalCtx, u16 csCmdActorAction) { CutsceneContext* csCtx = &globalCtx->csCtx; CsCmdActorAction* actorAction = csCtx->actorActions[func_8097C870(this)]; if (csCtx->state != 0) { - if (actorAction != 0 && actorAction->action == csCmdActorAction) + if (actorAction != NULL && actorAction->action == csCmdActorAction) { return 1; } @@ -277,7 +283,7 @@ void func_8097CE78(DemoGo* this, GlobalContext* globalCtx) if (globalCtx->csCtx.state != 0) { actorAction = csCtx->actorActions[func_8097C870(this)]; - if (actorAction != 0 && csCtx->frames >= actorAction->endFrame) + if (actorAction != NULL && csCtx->frames >= actorAction->endFrame) { func_8097CA78(this, globalCtx); this->action = 3; @@ -369,7 +375,7 @@ void DemoGo_Update(DemoGo* this, GlobalContext* globalCtx) { if (this->action < 0 || this->action >= 7 || D_8097D44C[this->action] == 0) { - osSyncPrintf("メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } D_8097D44C[this->action](this, globalCtx); @@ -391,32 +397,31 @@ void func_8097D290(DemoGo* this, GlobalContext* globalCtx) } -// Not equivalent yet - the gSPSegment calls are probably the main issue -#ifdef NON_MATCHING -extern u32 D_0600E680; void func_8097D29C(DemoGo* this, GlobalContext* globalCtx) { - u32 addr = D_8097D440[this->unk_190]; - GraphicsContext* gfxCtx = &globalCtx->state.gfxCtx; + s32 pad; + s16 temp = this->unk_190; + SkelAnime* skelAnime = &this->skelAnime; + void* srcSegment8 = D_8097D440[temp]; + void* srcSegment9 = &D_0600E680; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; Gfx* gfxArr[4]; func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_demo_go.c", 732); + func_80093D18(globalCtx->state.gfxCtx); + gSPSegment(gfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(srcSegment8)); + gSPSegment(gfxCtx->polyOpa.p++, 0x09, SEGMENTED_TO_VIRTUAL(srcSegment9)); - gSPSegment(gfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(addr)); - gSPSegment(gfxCtx->polyOpa.p++, 0x09, SEGMENTED_TO_VIRTUAL(D_0600E680)); + func_800A1AC8(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, NULL, NULL, &this->actor); - func_800A1AC8(globalCtx, this->skelAnime.limbIndex, this->skelAnime.actorDrawTbl, this->skelAnime.dListCount, 0, 0, &this->actor); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_demo_go.c", 746); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097D29C.s") -#endif void DemoGo_Draw(DemoGo* this, GlobalContext* globalCtx) { if (this->drawConfig < 0 || this->drawConfig >= 2 || D_8097D468[this->drawConfig] == 0) { - osSyncPrintf("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST); return; } D_8097D468[this->drawConfig](this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c index 8ea7fe4b45..9fb9bed6b6 100644 --- a/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c +++ b/src/overlays/actors/ovl_En_Anubice_Tag/z_en_anubice_tag.c @@ -7,6 +7,8 @@ #include #include +#include + //temp struct until we can reference other actors outside of their file typedef struct { @@ -56,7 +58,7 @@ static void EnAnubiceTag_Init(EnAnubiceTag* this, GlobalContext* globalCtx) { osSyncPrintf("\n\n"); //"Anubis control tag generated" - osSyncPrintf("☆☆☆☆☆ アヌビス制御タグ発生 ☆☆☆☆☆ %d\n", this->actor.params); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ アヌビス制御タグ発生 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params); if (this->actor.params < (s16)0xFFFF) { diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 4812ca329e..4f1a2e58d4 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -7,6 +7,8 @@ #include #include +#include + typedef struct { /* 0x0000 */ Actor actor; @@ -58,7 +60,7 @@ static void EnOkarinaEffect_Init(EnOkarinaEffect* this, GlobalContext* globalCtx { osSyncPrintf("\n\n"); //"Ocarina Storm Effect" - osSyncPrintf("☆☆☆☆☆ オカリナあらし効果ビカビカビカ〜 ☆☆☆☆☆ \n"); + osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ オカリナあらし効果ビカビカビカ〜 ☆☆☆☆☆ \n" VT_RST); osSyncPrintf("\n\n"); if (globalCtx->unk_10B12[1] != 0) { From 85237605e20a1aa32bf7bc3e729a78b0e25258c7 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Wed, 18 Mar 2020 21:22:00 +0100 Subject: [PATCH 2/2] Fix and cleanup ovl_En_Tubo_Trap (4/7 matched) --- .../actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s | 57 --- ...stCollider.s => EnTuboTrap_HandleImpact.s} | 12 +- .../EnTuboTrap_InitializeAttack.s | 40 -- ...ragments.s => EnTuboTrap_SpawnFragments.s} | 13 +- ...ter.s => EnTuboTrap_SpawnWaterFragments.s} | 9 +- .../EnTuboTrap_TestLevitate.s | 119 ------ .../ovl_En_Tubo_Trap/EnTuboTrap_Update.s | 47 --- include/z64.h | 16 +- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 386 ++++++++---------- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h | 18 + undefined_syms.txt | 4 +- 11 files changed, 207 insertions(+), 514 deletions(-) delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s rename asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/{EnTuboTrap_TestCollider.s => EnTuboTrap_HandleImpact.s} (96%) delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s rename asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/{EnTuboTrap_Fragments.s => EnTuboTrap_SpawnFragments.s} (98%) rename asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/{EnTuboTrap_FragmentsWater.s => EnTuboTrap_SpawnWaterFragments.s} (99%) delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s create mode 100644 src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s deleted file mode 100644 index ed18906778..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s +++ /dev/null @@ -1,57 +0,0 @@ -glabel EnTuboTrap_Fly -/* 00A38 80B26328 27BDFFD0 */ addiu $sp, $sp, 0xFFD0 ## $sp = FFFFFFD0 -/* 00A3C 80B2632C AFBF001C */ sw $ra, 0x001C($sp) -/* 00A40 80B26330 AFB00018 */ sw $s0, 0x0018($sp) -/* 00A44 80B26334 AFA50034 */ sw $a1, 0x0034($sp) -/* 00A48 80B26338 C4920154 */ lwc1 $f18, 0x0154($a0) ## 00000154 -/* 00A4C 80B2633C C4900024 */ lwc1 $f16, 0x0024($a0) ## 00000024 -/* 00A50 80B26340 C48E0158 */ lwc1 $f14, 0x0158($a0) ## 00000158 -/* 00A54 80B26344 C48C0028 */ lwc1 $f12, 0x0028($a0) ## 00000028 -/* 00A58 80B26348 46109401 */ sub.s $f16, $f18, $f16 -/* 00A5C 80B2634C C492015C */ lwc1 $f18, 0x015C($a0) ## 0000015C -/* 00A60 80B26350 C48A002C */ lwc1 $f10, 0x002C($a0) ## 0000002C -/* 00A64 80B26354 460C7301 */ sub.s $f12, $f14, $f12 -/* 00A68 80B26358 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00A6C 80B2635C E7B0002C */ swc1 $f16, 0x002C($sp) -/* 00A70 80B26360 460A9281 */ sub.s $f10, $f18, $f10 -/* 00A74 80B26364 E7AC0028 */ swc1 $f12, 0x0028($sp) -/* 00A78 80B26368 24053037 */ addiu $a1, $zero, 0x3037 ## $a1 = 00003037 -/* 00A7C 80B2636C 0C00BE0A */ jal Audio_PlayActorSound2 - -/* 00A80 80B26370 E7AA0024 */ swc1 $f10, 0x0024($sp) -/* 00A84 80B26374 C7A2002C */ lwc1 $f2, 0x002C($sp) -/* 00A88 80B26378 C7AC0028 */ lwc1 $f12, 0x0028($sp) -/* 00A8C 80B2637C C7AE0024 */ lwc1 $f14, 0x0024($sp) -/* 00A90 80B26380 46021102 */ mul.s $f4, $f2, $f2 -/* 00A94 80B26384 3C014370 */ lui $at, 0x4370 ## $at = 43700000 -/* 00A98 80B26388 44818000 */ mtc1 $at, $f16 ## $f16 = 240.00 -/* 00A9C 80B2638C 460C6182 */ mul.s $f6, $f12, $f12 -/* 00AA0 80B26390 3C063E4C */ lui $a2, 0x3E4C ## $a2 = 3E4C0000 -/* 00AA4 80B26394 34C6CCCD */ ori $a2, $a2, 0xCCCD ## $a2 = 3E4CCCCD -/* 00AA8 80B26398 460E7282 */ mul.s $f10, $f14, $f14 -/* 00AAC 80B2639C 2604006C */ addiu $a0, $s0, 0x006C ## $a0 = 0000006C -/* 00AB0 80B263A0 3C05C040 */ lui $a1, 0xC040 ## $a1 = C0400000 -/* 00AB4 80B263A4 46062200 */ add.s $f8, $f4, $f6 -/* 00AB8 80B263A8 460A4000 */ add.s $f0, $f8, $f10 -/* 00ABC 80B263AC 46000004 */ sqrt.s $f0, $f0 -/* 00AC0 80B263B0 4600803C */ c.lt.s $f16, $f0 -/* 00AC4 80B263B4 00000000 */ nop -/* 00AC8 80B263B8 45020004 */ bc1fl .L80B263CC -/* 00ACC 80B263BC 860E00B6 */ lh $t6, 0x00B6($s0) ## 000000B6 -/* 00AD0 80B263C0 0C01E107 */ jal Math_SmoothScaleMaxF - -/* 00AD4 80B263C4 3C073F00 */ lui $a3, 0x3F00 ## $a3 = 3F000000 -/* 00AD8 80B263C8 860E00B6 */ lh $t6, 0x00B6($s0) ## 000000B6 -.L80B263CC: -/* 00ADC 80B263CC 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00AE0 80B263D0 25CF1388 */ addiu $t7, $t6, 0x1388 ## $t7 = 00001388 -/* 00AE4 80B263D4 A60F00B6 */ sh $t7, 0x00B6($s0) ## 000000B6 -/* 00AE8 80B263D8 0C2C97C2 */ jal EnTuboTrap_TestCollider -/* 00AEC 80B263DC 8FA50034 */ lw $a1, 0x0034($sp) -/* 00AF0 80B263E0 8FBF001C */ lw $ra, 0x001C($sp) -/* 00AF4 80B263E4 8FB00018 */ lw $s0, 0x0018($sp) -/* 00AF8 80B263E8 27BD0030 */ addiu $sp, $sp, 0x0030 ## $sp = 00000000 -/* 00AFC 80B263EC 03E00008 */ jr $ra -/* 00B00 80B263F0 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s similarity index 96% rename from asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s rename to asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s index 1c28df5022..fe7f9d108c 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s @@ -1,4 +1,4 @@ -glabel EnTuboTrap_TestCollider +glabel EnTuboTrap_HandleImpact /* 00618 80B25F08 27BDFFD0 */ addiu $sp, $sp, 0xFFD0 ## $sp = FFFFFFD0 /* 0061C 80B25F0C AFBF001C */ sw $ra, 0x001C($sp) /* 00620 80B25F10 AFB10018 */ sw $s1, 0x0018($sp) @@ -18,7 +18,7 @@ glabel EnTuboTrap_TestCollider /* 00658 80B25F48 00000000 */ nop /* 0065C 80B25F4C 45020010 */ bc1fl .L80B25F90 /* 00660 80B25F50 92020170 */ lbu $v0, 0x0170($s0) ## 00000170 -/* 00664 80B25F54 0C2C9723 */ jal EnTuboTrap_FragmentsWater +/* 00664 80B25F54 0C2C9723 */ jal EnTuboTrap_SpawnWaterFragments /* 00668 80B25F58 00000000 */ nop /* 0066C 80B25F5C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00670 80B25F60 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 @@ -41,7 +41,7 @@ glabel EnTuboTrap_TestCollider /* 006A8 80B25F98 30580004 */ andi $t8, $v0, 0x0004 ## $t8 = 00000000 /* 006AC 80B25F9C 13000015 */ beq $t8, $zero, .L80B25FF4 /* 006B0 80B25FA0 3059FFFB */ andi $t9, $v0, 0xFFFB ## $t9 = 00000000 -/* 006B4 80B25FA4 0C2C9686 */ jal EnTuboTrap_Fragments +/* 006B4 80B25FA4 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 006B8 80B25FA8 A2190170 */ sb $t9, 0x0170($s0) ## 00000170 /* 006BC 80B25FAC 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 /* 006C0 80B25FB0 AFA50024 */ sw $a1, 0x0024($sp) @@ -72,7 +72,7 @@ glabel EnTuboTrap_TestCollider /* 00714 80B26004 11000016 */ beq $t0, $zero, .L80B26060 /* 00718 80B26008 3069FFFD */ andi $t1, $v1, 0xFFFD ## $t1 = 00000000 /* 0071C 80B2600C A2090171 */ sb $t1, 0x0171($s0) ## 00000171 -/* 00720 80B26010 0C2C9686 */ jal EnTuboTrap_Fragments +/* 00720 80B26010 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 00724 80B26014 02202825 */ or $a1, $s1, $zero ## $a1 = 00000000 /* 00728 80B26018 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 /* 0072C 80B2601C AFA50024 */ sw $a1, 0x0024($sp) @@ -103,7 +103,7 @@ glabel EnTuboTrap_TestCollider /* 00780 80B26070 A20B0170 */ sb $t3, 0x0170($s0) ## 00000170 /* 00784 80B26074 14CC0015 */ bne $a2, $t4, .L80B260CC /* 00788 80B26078 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 0078C 80B2607C 0C2C9686 */ jal EnTuboTrap_Fragments +/* 0078C 80B2607C 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 00790 80B26080 02202825 */ or $a1, $s1, $zero ## $a1 = 00000000 /* 00794 80B26084 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00798 80B26088 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 @@ -136,7 +136,7 @@ glabel EnTuboTrap_TestCollider /* 007F0 80B260E0 51C0000E */ beql $t6, $zero, .L80B2611C /* 007F4 80B260E4 8FBF001C */ lw $ra, 0x001C($sp) .L80B260E8: -/* 007F8 80B260E8 0C2C9686 */ jal EnTuboTrap_Fragments +/* 007F8 80B260E8 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 007FC 80B260EC 02202825 */ or $a1, $s1, $zero ## $a1 = 00000000 /* 00800 80B260F0 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00804 80B260F4 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s deleted file mode 100644 index d71bf919a1..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s +++ /dev/null @@ -1,40 +0,0 @@ -glabel EnTuboTrap_InitializeAttack -/* 009AC 80B2629C 27BDFFE0 */ addiu $sp, $sp, 0xFFE0 ## $sp = FFFFFFE0 -/* 009B0 80B262A0 AFBF001C */ sw $ra, 0x001C($sp) -/* 009B4 80B262A4 AFB00018 */ sw $s0, 0x0018($sp) -/* 009B8 80B262A8 AFA50024 */ sw $a1, 0x0024($sp) -/* 009BC 80B262AC 848E00B6 */ lh $t6, 0x00B6($a0) ## 000000B6 -/* 009C0 80B262B0 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 009C4 80B262B4 3C063F4C */ lui $a2, 0x3F4C ## $a2 = 3F4C0000 -/* 009C8 80B262B8 25CF1388 */ addiu $t7, $t6, 0x1388 ## $t7 = 00001388 -/* 009CC 80B262BC A48F00B6 */ sh $t7, 0x00B6($a0) ## 000000B6 -/* 009D0 80B262C0 8E050150 */ lw $a1, 0x0150($s0) ## 00000150 -/* 009D4 80B262C4 34C6CCCD */ ori $a2, $a2, 0xCCCD ## $a2 = 3F4CCCCD -/* 009D8 80B262C8 24840028 */ addiu $a0, $a0, 0x0028 ## $a0 = 00000028 -/* 009DC 80B262CC 0C01E107 */ jal Math_SmoothScaleMaxF - -/* 009E0 80B262D0 3C074040 */ lui $a3, 0x4040 ## $a3 = 40400000 -/* 009E4 80B262D4 C6040028 */ lwc1 $f4, 0x0028($s0) ## 00000028 -/* 009E8 80B262D8 C6060150 */ lwc1 $f6, 0x0150($s0) ## 00000150 -/* 009EC 80B262DC 3C014120 */ lui $at, 0x4120 ## $at = 41200000 -/* 009F0 80B262E0 44811000 */ mtc1 $at, $f2 ## $f2 = 10.00 -/* 009F4 80B262E4 46062001 */ sub.s $f0, $f4, $f6 -/* 009F8 80B262E8 3C1980B2 */ lui $t9, %hi(EnTuboTrap_Fly) ## $t9 = 80B20000 -/* 009FC 80B262EC 27396328 */ addiu $t9, $t9, %lo(EnTuboTrap_Fly) ## $t9 = 80B26328 -/* 00A00 80B262F0 46000005 */ abs.s $f0, $f0 -/* 00A04 80B262F4 4602003C */ c.lt.s $f0, $f2 -/* 00A08 80B262F8 00000000 */ nop -/* 00A0C 80B262FC 45020006 */ bc1fl .L80B26318 -/* 00A10 80B26300 8FBF001C */ lw $ra, 0x001C($sp) -/* 00A14 80B26304 8618008A */ lh $t8, 0x008A($s0) ## 0000008A -/* 00A18 80B26308 E6020068 */ swc1 $f2, 0x0068($s0) ## 00000068 -/* 00A1C 80B2630C AE19014C */ sw $t9, 0x014C($s0) ## 0000014C -/* 00A20 80B26310 A6180032 */ sh $t8, 0x0032($s0) ## 00000032 -/* 00A24 80B26314 8FBF001C */ lw $ra, 0x001C($sp) -.L80B26318: -/* 00A28 80B26318 8FB00018 */ lw $s0, 0x0018($sp) -/* 00A2C 80B2631C 27BD0020 */ addiu $sp, $sp, 0x0020 ## $sp = 00000000 -/* 00A30 80B26320 03E00008 */ jr $ra -/* 00A34 80B26324 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s similarity index 98% rename from asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s rename to asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s index 26bfc1143e..3366b21942 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s @@ -1,12 +1,15 @@ .late_rodata +glabel D_80B265C0 + .float 0.23 -D_80B265C0: .float 0.23 -D_80B265C4: .float 0.2 -D_80B265C8: .float 0.6 +glabel D_80B265C4 + .float 0.2 + +glabel D_80B265C8 + .float 0.6 .text - -glabel EnTuboTrap_Fragments +glabel EnTuboTrap_SpawnFragments /* 00128 80B25A18 27BDFF20 */ addiu $sp, $sp, 0xFF20 ## $sp = FFFFFF20 /* 0012C 80B25A1C F7BE0070 */ sdc1 $f30, 0x0070($sp) /* 00130 80B25A20 3C0180B2 */ lui $at, %hi(D_80B265C0) ## $at = 80B20000 diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s similarity index 99% rename from asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s rename to asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s index c5d727def5..f50a18afcf 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s @@ -1,11 +1,12 @@ .late_rodata +glabel D_80B265CC + .float 0.2 -D_80B265CC: .float 0.2 -D_80B265D0: .float 0.2 +glabel D_80B265D0 + .float 0.2 .text - -glabel EnTuboTrap_FragmentsWater +glabel EnTuboTrap_SpawnWaterFragments /* 0039C 80B25C8C 27BDFF20 */ addiu $sp, $sp, 0xFF20 ## $sp = FFFFFF20 /* 003A0 80B25C90 AFB1007C */ sw $s1, 0x007C($sp) /* 003A4 80B25C94 AFBF009C */ sw $ra, 0x009C($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s deleted file mode 100644 index 3868ef1ad2..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s +++ /dev/null @@ -1,119 +0,0 @@ -.rdata - -D_80B26564: - .asciz "\x1b[32m☆☆☆☆☆ わて ☆☆☆☆☆ %f\n\x1b[m" - .balign 4 - -D_80B26590: - .asciz "\x1b[32m☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n\x1b[m" - .balign 4 - -D_80B265BC: - .asciz "\n\n" - .balign 4 - -.text - -glabel EnTuboTrap_TestLevitate -/* 0083C 80B2612C 27BDFFD8 */ addiu $sp, $sp, 0xFFD8 ## $sp = FFFFFFD8 -/* 00840 80B26130 AFBF001C */ sw $ra, 0x001C($sp) -/* 00844 80B26134 AFB00018 */ sw $s0, 0x0018($sp) -/* 00848 80B26138 AFA5002C */ sw $a1, 0x002C($sp) -/* 0084C 80B2613C 8CAF1C44 */ lw $t7, 0x1C44($a1) ## 00001C44 -/* 00850 80B26140 3C188016 */ lui $t8, 0x8016 ## $t8 = 80160000 -/* 00854 80B26144 8F18FA90 */ lw $t8, -0x0570($t8) ## 8015FA90 -/* 00858 80B26148 AFAF0024 */ sw $t7, 0x0024($sp) -/* 0085C 80B2614C 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00860 80B26150 871912D8 */ lh $t9, 0x12D8($t8) ## 801612D8 -/* 00864 80B26154 53200016 */ beql $t9, $zero, .L80B261B0 -/* 00868 80B26158 3C014348 */ lui $at, 0x4348 ## $at = 43480000 -/* 0086C 80B2615C C6040028 */ lwc1 $f4, 0x0028($s0) ## 00000028 -/* 00870 80B26160 3C0480B2 */ lui $a0, %hi(D_80B26564) ## $a0 = 80B20000 -/* 00874 80B26164 24846564 */ addiu $a0, $a0, %lo(D_80B26564) ## $a0 = 80B26564 -/* 00878 80B26168 460021A1 */ cvt.d.s $f6, $f4 -/* 0087C 80B2616C 44073000 */ mfc1 $a3, $f6 -/* 00880 80B26170 44063800 */ mfc1 $a2, $f7 -/* 00884 80B26174 0C00084C */ jal osSyncPrintf - -/* 00888 80B26178 00000000 */ nop -/* 0088C 80B2617C 8FA80024 */ lw $t0, 0x0024($sp) -/* 00890 80B26180 3C0480B2 */ lui $a0, %hi(D_80B26590) ## $a0 = 80B20000 -/* 00894 80B26184 24846590 */ addiu $a0, $a0, %lo(D_80B26590) ## $a0 = 80B26590 -/* 00898 80B26188 C5080028 */ lwc1 $f8, 0x0028($t0) ## 00000028 -/* 0089C 80B2618C 460042A1 */ cvt.d.s $f10, $f8 -/* 008A0 80B26190 44075000 */ mfc1 $a3, $f10 -/* 008A4 80B26194 44065800 */ mfc1 $a2, $f11 -/* 008A8 80B26198 0C00084C */ jal osSyncPrintf - -/* 008AC 80B2619C 00000000 */ nop -/* 008B0 80B261A0 3C0480B2 */ lui $a0, %hi(D_80B265BC) ## $a0 = 80B20000 -/* 008B4 80B261A4 0C00084C */ jal osSyncPrintf - -/* 008B8 80B261A8 248465BC */ addiu $a0, $a0, %lo(D_80B265BC) ## $a0 = 80B265BC -/* 008BC 80B261AC 3C014348 */ lui $at, 0x4348 ## $at = 43480000 -.L80B261B0: -/* 008C0 80B261B0 44819000 */ mtc1 $at, $f18 ## $f18 = 200.00 -/* 008C4 80B261B4 C6100090 */ lwc1 $f16, 0x0090($s0) ## 00000090 -/* 008C8 80B261B8 8FA90024 */ lw $t1, 0x0024($sp) -/* 008CC 80B261BC 4612803C */ c.lt.s $f16, $f18 -/* 008D0 80B261C0 00000000 */ nop -/* 008D4 80B261C4 45020031 */ bc1fl .L80B2628C -/* 008D8 80B261C8 8FBF001C */ lw $ra, 0x001C($sp) -/* 008DC 80B261CC C5240028 */ lwc1 $f4, 0x0028($t1) ## 00000028 -/* 008E0 80B261D0 C6060028 */ lwc1 $f6, 0x0028($s0) ## 00000028 -/* 008E4 80B261D4 8FA4002C */ lw $a0, 0x002C($sp) -/* 008E8 80B261D8 02003025 */ or $a2, $s0, $zero ## $a2 = 00000000 -/* 008EC 80B261DC 4604303E */ c.le.s $f6, $f4 -/* 008F0 80B261E0 24851C24 */ addiu $a1, $a0, 0x1C24 ## $a1 = 00001C24 -/* 008F4 80B261E4 45020029 */ bc1fl .L80B2628C -/* 008F8 80B261E8 8FBF001C */ lw $ra, 0x001C($sp) -/* 008FC 80B261EC 0C00CDD2 */ jal Actor_ChangeType - -/* 00900 80B261F0 24070005 */ addiu $a3, $zero, 0x0005 ## $a3 = 00000005 -/* 00904 80B261F4 8E0B0004 */ lw $t3, 0x0004($s0) ## 00000004 -/* 00908 80B261F8 3C0D8016 */ lui $t5, 0x8016 ## $t5 = 80160000 -/* 0090C 80B261FC 3C01C120 */ lui $at, 0xC120 ## $at = C1200000 -/* 00910 80B26200 356C0001 */ ori $t4, $t3, 0x0001 ## $t4 = 00000001 -/* 00914 80B26204 AE0C0004 */ sw $t4, 0x0004($s0) ## 00000004 -/* 00918 80B26208 8DADE664 */ lw $t5, -0x199C($t5) ## 8015E664 -/* 0091C 80B2620C 44818000 */ mtc1 $at, $f16 ## $f16 = -10.00 -/* 00920 80B26210 3C014220 */ lui $at, 0x4220 ## $at = 42200000 -/* 00924 80B26214 448D4000 */ mtc1 $t5, $f8 ## $f8 = -0.00 -/* 00928 80B26218 44812000 */ mtc1 $at, $f4 ## $f4 = 40.00 -/* 0092C 80B2621C 8FAE0024 */ lw $t6, 0x0024($sp) -/* 00930 80B26220 468042A0 */ cvt.s.w $f10, $f8 -/* 00934 80B26224 C6000028 */ lwc1 $f0, 0x0028($s0) ## 00000028 -/* 00938 80B26228 C5C60028 */ lwc1 $f6, 0x0028($t6) ## 00000028 -/* 0093C 80B2622C 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00940 80B26230 46105482 */ mul.s $f18, $f10, $f16 -/* 00944 80B26234 46049080 */ add.s $f2, $f18, $f4 -/* 00948 80B26238 46023200 */ add.s $f8, $f6, $f2 -/* 0094C 80B2623C E6080150 */ swc1 $f8, 0x0150($s0) ## 00000150 -/* 00950 80B26240 C60A0150 */ lwc1 $f10, 0x0150($s0) ## 00000150 -/* 00954 80B26244 4600503C */ c.lt.s $f10, $f0 -/* 00958 80B26248 00000000 */ nop -/* 0095C 80B2624C 45020004 */ bc1fl .L80B26260 -/* 00960 80B26250 8E180024 */ lw $t8, 0x0024($s0) ## 00000024 -/* 00964 80B26254 46020400 */ add.s $f16, $f0, $f2 -/* 00968 80B26258 E6100150 */ swc1 $f16, 0x0150($s0) ## 00000150 -/* 0096C 80B2625C 8E180024 */ lw $t8, 0x0024($s0) ## 00000024 -.L80B26260: -/* 00970 80B26260 8E0F0028 */ lw $t7, 0x0028($s0) ## 00000028 -/* 00974 80B26264 240528C4 */ addiu $a1, $zero, 0x28C4 ## $a1 = 000028C4 -/* 00978 80B26268 AE180154 */ sw $t8, 0x0154($s0) ## 00000154 -/* 0097C 80B2626C 8E18002C */ lw $t8, 0x002C($s0) ## 0000002C -/* 00980 80B26270 AE0F0158 */ sw $t7, 0x0158($s0) ## 00000158 -/* 00984 80B26274 0C00BE0A */ jal Audio_PlayActorSound2 - -/* 00988 80B26278 AE18015C */ sw $t8, 0x015C($s0) ## 0000015C -/* 0098C 80B2627C 3C1980B2 */ lui $t9, %hi(EnTuboTrap_InitializeAttack) ## $t9 = 80B20000 -/* 00990 80B26280 2739629C */ addiu $t9, $t9, %lo(EnTuboTrap_InitializeAttack) ## $t9 = 80B2629C -/* 00994 80B26284 AE19014C */ sw $t9, 0x014C($s0) ## 0000014C -/* 00998 80B26288 8FBF001C */ lw $ra, 0x001C($sp) -.L80B2628C: -/* 0099C 80B2628C 8FB00018 */ lw $s0, 0x0018($sp) -/* 009A0 80B26290 27BD0028 */ addiu $sp, $sp, 0x0028 ## $sp = 00000000 -/* 009A4 80B26294 03E00008 */ jr $ra -/* 009A8 80B26298 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s deleted file mode 100644 index f4076e815c..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s +++ /dev/null @@ -1,47 +0,0 @@ -glabel EnTuboTrap_Update -/* 00B04 80B263F4 27BDFFC8 */ addiu $sp, $sp, 0xFFC8 ## $sp = FFFFFFC8 -/* 00B08 80B263F8 AFB0001C */ sw $s0, 0x001C($sp) -/* 00B0C 80B263FC 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00B10 80B26400 AFBF0024 */ sw $ra, 0x0024($sp) -/* 00B14 80B26404 AFB10020 */ sw $s1, 0x0020($sp) -/* 00B18 80B26408 8E19014C */ lw $t9, 0x014C($s0) ## 0000014C -/* 00B1C 80B2640C 00A08825 */ or $s1, $a1, $zero ## $s1 = 00000000 -/* 00B20 80B26410 0320F809 */ jalr $ra, $t9 -/* 00B24 80B26414 00000000 */ nop -/* 00B28 80B26418 0C00B638 */ jal Actor_MoveForward -/* 00B2C 80B2641C 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B30 80B26420 3C014120 */ lui $at, 0x4120 ## $at = 41200000 -/* 00B34 80B26424 44810000 */ mtc1 $at, $f0 ## $f0 = 10.00 -/* 00B38 80B26428 3C0141A0 */ lui $at, 0x41A0 ## $at = 41A00000 -/* 00B3C 80B2642C 44812000 */ mtc1 $at, $f4 ## $f4 = 20.00 -/* 00B40 80B26430 240E001D */ addiu $t6, $zero, 0x001D ## $t6 = 0000001D -/* 00B44 80B26434 44060000 */ mfc1 $a2, $f0 -/* 00B48 80B26438 44070000 */ mfc1 $a3, $f0 -/* 00B4C 80B2643C AFAE0014 */ sw $t6, 0x0014($sp) -/* 00B50 80B26440 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00B54 80B26444 02002825 */ or $a1, $s0, $zero ## $a1 = 00000000 -/* 00B58 80B26448 0C00B92D */ jal func_8002E4B4 -/* 00B5C 80B2644C E7A40010 */ swc1 $f4, 0x0010($sp) -/* 00B60 80B26450 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B64 80B26454 0C00B56E */ jal Actor_SetHeight -/* 00B68 80B26458 24050000 */ addiu $a1, $zero, 0x0000 ## $a1 = 00000000 -/* 00B6C 80B2645C 26050160 */ addiu $a1, $s0, 0x0160 ## $a1 = 00000160 -/* 00B70 80B26460 AFA50028 */ sw $a1, 0x0028($sp) -/* 00B74 80B26464 0C0189B7 */ jal ActorCollider_Cylinder_Update -/* 00B78 80B26468 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B7C 80B2646C 3C010001 */ lui $at, 0x0001 ## $at = 00010000 -/* 00B80 80B26470 34211E60 */ ori $at, $at, 0x1E60 ## $at = 00011E60 -/* 00B84 80B26474 02212821 */ addu $a1, $s1, $at -/* 00B88 80B26478 AFA5002C */ sw $a1, 0x002C($sp) -/* 00B8C 80B2647C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00B90 80B26480 0C01767D */ jal Actor_CollisionCheck_SetAC ## CollisionCheck_setAC -/* 00B94 80B26484 8FA60028 */ lw $a2, 0x0028($sp) -/* 00B98 80B26488 8FA5002C */ lw $a1, 0x002C($sp) -/* 00B9C 80B2648C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00BA0 80B26490 0C0175E7 */ jal Actor_CollisionCheck_SetAT ## CollisionCheck_setAT -/* 00BA4 80B26494 8FA60028 */ lw $a2, 0x0028($sp) -/* 00BA8 80B26498 8FBF0024 */ lw $ra, 0x0024($sp) -/* 00BAC 80B2649C 8FB0001C */ lw $s0, 0x001C($sp) -/* 00BB0 80B264A0 8FB10020 */ lw $s1, 0x0020($sp) -/* 00BB4 80B264A4 03E00008 */ jr $ra -/* 00BB8 80B264A8 27BD0038 */ addiu $sp, $sp, 0x0038 ## $sp = 00000000 diff --git a/include/z64.h b/include/z64.h index bc9035b796..dc0baf5ee5 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1351,21 +1351,7 @@ typedef struct OverlayRelocationSection { /* 0x0C */ u32 bssSize; /* 0x10 */ u32 nRelocations; /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; /* size >= 0x18 */ - -#define VEC3_ADD( V3A0, V3A1 ) \ -{ \ - V3A0.x += V3A1.x; \ - V3A0.y += V3A1.y; \ - V3A0.z += V3A1.z; \ -} - -#define VEC3_SUB( V3DST, V3A0, V3A1 ) \ -{ \ - V3DST.x = V3A0.x - V3A1.x; \ - V3DST.y = V3A0.y - V3A1.y; \ - V3DST.z = V3A0.z - V3A1.z; \ -} +} OverlayRelocationSection; // size >= 0x18 typedef struct { diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 712272eed5..26431fc665 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -4,24 +4,16 @@ * Description: Flying pot enemy */ -#include -#include +#include "z_en_tubo_trap.h" -typedef struct -{ - /* 0x0000 */ Actor actor; - /* 0x014C */ ActorFunc playfunc; - /* 0x0150 */ f32 pos_y_seek; - /* 0x0154 */ Vec3f pos_init; - /* 0x0160 */ ColliderCylinderMain capsule; -} EnTuboTrap; // size = 0x01AC +#include void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx); +void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx); +void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx); #define ROOM 0x00 @@ -44,7 +36,7 @@ static ColliderCylinderInit cylinderInitData = 0x0000, 0x0000, 0x0000 }; -ActorInit En_Tubo_Trap_InitVars = +const ActorInit En_Tubo_Trap_InitVars = { ACTOR_EN_TUBO_TRAP, ACTORTYPE_PROP, @@ -58,321 +50,277 @@ ActorInit En_Tubo_Trap_InitVars = (ActorFunc)EnTuboTrap_Draw, }; -extern u32 DL_SHARD; -extern u32 DL_TUBO; +extern UNK_TYPE D_05017A60; +extern Gfx D_05017870[]; void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 2.0f); osSyncPrintf("\n\n"); - osSyncPrintf("\x1b[32m☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n\x1b[m", this->actor.params); - ActorCollider_AllocCylinder(globalCtx, &this->capsule); - ActorCollider_InitCylinder(globalCtx, &this->capsule, &this->actor, &cylinderInitData); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); // "Urn Trap" + ActorCollider_AllocCylinder(globalCtx, &this->collider); + ActorCollider_InitCylinder(globalCtx, &this->collider, &this->actor, &cylinderInitData); Actor_SetScale(&this->actor, 0.1f); - this->playfunc = (ActorFunc*)EnTuboTrap_TestLevitate; + this->actionFunc = (ActorFunc)EnTuboTrap_WaitForProximity; } void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx) { - ColliderCylinderMain* capsule = &this->capsule; - ActorCollider_FreeCylinder(globalCtx, capsule); + ColliderCylinderMain* collider = &this->collider; + ActorCollider_FreeCylinder(globalCtx, collider); } void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx) { s16 params = this->actor.params; - s16 param1 = (params >> 6) & 0x03FF; - if (param1 >= 0 && param1 < 0x1A) + s16 param3FF = (params >> 6) & 0x3FF; + if (param3FF >= 0 && param3FF < 0x1A) { - Item_DropCollectible(globalCtx, &this->actor.posRot, param1 | ((params & 0x03F) << 8)); + Item_DropCollectible(globalCtx, &this->actor.posRot, param3FF | ((params & 0x3F) << 8)); } } #ifdef NON_MATCHING -void EnTuboTrap_Fragments(EnTuboTrap* this, GlobalContext* globalCtx) +// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnWaterFragments +void EnTuboTrap_SpawnFragments(EnTuboTrap* this, GlobalContext* globalCtx) { - u32 uVar1; - s32 rando_seed = 0; - s32 shard_count = 0; + Vec3f* actorPos; + f32 rand; + f32 cos; + f32 sin; + u32 addr; + Vec3f spC8; + Vec3f spBC; + s16 var; + s32 temp; + s32 i; - /* spawn fragments */ - do + addr = &D_05017A60; + actorPos = &this->actor.posRot.pos; + + for (i = 0, var = 0; i < 15; i++, var += 20000) { - Vec3f burst_depth[2]; - f32 rng; + sin = Math_Sins(var); + cos = Math_Coss(var); + spC8.x = sin * 8.0f; + spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; + spC8.z = cos * 8.0f; - /* burst_depth_x */ - burst_depth[0].x = Math_Sins(rando_seed) * 8.0f; - burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[0].z = Math_Coss(rando_seed) * 8.0f; + spBC.x = spC8.x * 0.23f; + spBC.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; + spBC.z = spC8.z * 0.23f; - /* burst_depth_y */ - burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f); - burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f); + spC8.x += actorPos->x; + spC8.y += actorPos->y; + spC8.z += actorPos->z; - VEC3_ADD(burst_depth[0], this->actor.posRot.pos) - - rng = Math_Rand_ZeroOne(); - - if (rng < 0.2f) - { - uVar1 = 0x60; - } + rand = Math_Rand_ZeroOne(); + if (rand < 0.2f) + temp = 96; + else if (rand < 0.6f) + temp = 64; else - { - uVar1 = 0x20; + temp = 32; - if (rng < 0.6f) - { - uVar1 = 0x40; - } - } - - /* The Heavy Lifting */ - Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1, 10, 10, 0, - (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD); - - shard_count++; - rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10; + Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -240, temp, 10, 10, 0, + (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 60, -1, 3, addr); } - while(shard_count != 15); - func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0); + func_80033480(globalCtx, actorPos, 30.0f, 4, 20, 50, 0); } #else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s") #endif #ifdef NON_MATCHING -void EnTuboTrap_FragmentsWater(EnTuboTrap* this, GlobalContext* globalCtx) +// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnFragments +void EnTuboTrap_SpawnWaterFragments(EnTuboTrap* this, GlobalContext* globalCtx) { - u32 uVar1; - s32 rando_seed = 0; - s32 shard_count = 0; - Vec3f burst_depth[2]; - f32 rng; + Vec3f* actorPos; + f32 rand; + f32 cos; + f32 sin; + u32 addr; + Vec3f spC8; + Vec3f spBC; + s16 var; + s32 temp; + s32 i; - Math_Vec3f_Copy(&burst_depth[0], &this->actor.posRot.pos); - burst_depth[0].y += this->actor.waterSurfaceDist; + addr = &D_05017A60; + actorPos = &this->actor.posRot.pos; - /* spawn a small splash */ - func_8002949C(globalCtx, &burst_depth[0], 0, 0, 0, 0x190); + spC8 = *actorPos; + spC8.y += this->actor.unk_84; - /* spawn fragments */ - do + func_8002949C(globalCtx, &spC8, 0, 0, 0, 400); + + for (i = 0, var = 0; i < 15; i++, var += 20000) { - /* burst_depth_x */ - burst_depth[0].x = Math_Sins(rando_seed) * 8.0f; - burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[0].z = Math_Coss(rando_seed) * 8.0f; + sin = Math_Sins(var); + cos = Math_Coss(var); + spC8.x = sin * 8.0f; + spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; + spC8.z = cos * 8.0f; - /* burst_depth_y */ - burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f); - burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f); + spBC.x = spC8.x * 0.23f; + spBC.y = (Math_Rand_ZeroOne() * 4.0f) + 2.0f; + spBC.z = spC8.z * 0.23f; - VEC3_ADD(burst_depth[0], this->actor.posRot.pos) + spC8.x += actorPos->x; + spC8.y += actorPos->y; + spC8.z += actorPos->z; - rng = Math_Rand_ZeroOne(); - - if (rng < 0.2f) - { - uVar1 = 0x60; - } + rand = Math_Rand_ZeroOne(); + if (rand < 0.2f) + temp = 64; else - { - uVar1 = 0x20; + temp = 32; - if (rng < 0.6f) - { - uVar1 = 0x40; - } - } - - /* The Heavy Lifting */ - Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1, - 10, 10, 0, (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD); - shard_count++; - rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10; + Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -180, temp, 30, 30, 0, + (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 70, -1, 3, addr); } - while(shard_count != 15); - - func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0); } #else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s") #endif #ifdef NON_MATCHING -void EnTuboTrap_TestCollider(EnTuboTrap* this, GlobalContext* globalCtx) +void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { - u8 bVar1, bVar2; - u16 uVar3; - Actor* collided_this; + s32 pad; Player* player = PLAYER; - if (!(this->actor.bgCheckFlags & 20)) + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.unk_84 > 15.0f)) { - bVar1 = this->capsule.base.colliderFlags; + EnTuboTrap_SpawnWaterFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_DropCollectible(this, globalCtx); + Actor_Kill(&this->actor); + return; } - else + + if (this->collider.base.colliderFlags & 4) { - if (this->actor.waterSurfaceDist > 15.0f) + this->collider.base.colliderFlags &= ~4; + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, globalCtx); + Actor_Kill(&this->actor); + return; + } + + if (this->collider.base.collideFlags & 2) + { + this->collider.base.collideFlags &= ~2; + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_EXPLOSION); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, globalCtx); + Actor_Kill(&this->actor); + return; + } + + if (this->collider.base.colliderFlags & 2) + { + this->collider.base.colliderFlags &= ~2; + if (this->collider.base.at == &player->actor) { - EnTuboTrap_FragmentsWater(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); + Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 40, 0x83E); EnTuboTrap_DropCollectible(this, globalCtx); Actor_Kill(&this->actor); return; } - - bVar1 = this->capsule.base.collideFlags; } - if (!(bVar1 & 4)) + if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1)) { - bVar2 = this->capsule.base.collideFlags; - if (!(bVar2 & 2)) - { - if (!(bVar1 & 2)) - { - uVar3 = this->actor.bgCheckFlags; - } - else - { - collided_this = this->capsule.base.actor; - this->capsule.base.colliderFlags = bVar1 & 0xFD; - - if (collided_this == &player->actor) - { - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); - Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 0x28, NA_SE_PL_BODY_HIT); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } - uVar3 = this->actor.bgCheckFlags; - } - - if ((uVar3 & 8) || (uVar3 & 1)) - { - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } - } - else - { - this->capsule.base.collideFlags = bVar2 & 0xFD; - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_EXPLOSION); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } - } - else - { - this->capsule.base.colliderFlags = bVar1 & 0xFB; - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_IT_SHIELD_REFLECT_SW); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); EnTuboTrap_DropCollectible(this, globalCtx); Actor_Kill(&this->actor); + return; } } #else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s") #endif -#ifdef NON_MATCHING -void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx) +void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx) { Player* player = PLAYER; - f32 seekY; + f32 targetHeight; if (BREG(2) != 0) { - osSyncPrintf("[32m☆☆☆☆☆ わて ☆☆☆☆☆ %f\n", globalCtx, this->actor.posRot.pos.y); - osSyncPrintf("[32m☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n"); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わて ☆☆☆☆☆ %f\n" VT_RST, this->actor.posRot.pos.y); // "You" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n" VT_RST, player->actor.posRot.pos.y); // "Me" osSyncPrintf("\n\n"); } - if (this->actor.xzDistanceFromLink < 200.00000000 && this->actor.posRot.pos.y <= player->actor.posRot.pos.y) + if (this->actor.xzDistanceFromLink < 200.0f && this->actor.posRot.pos.y <= player->actor.posRot.pos.y) { Actor_ChangeType(globalCtx, &globalCtx->actorCtx, this, ACTORTYPE_ENEMY); this->actor.flags |= 1; - seekY = (f32)gSaveContext.link_age * -10.00000000 + 40.00000000; - this->pos_y_seek = player->actor.posRot.pos.y; + targetHeight = 40.0f + -10.0f * gSaveContext.link_age; - if (this->pos_y_seek < this->actor.posRot.pos.y) - this->pos_y_seek = this->actor.posRot.pos.y + seekY; - - this->actor.initPosRot.pos = this->actor.posRot.pos; + this->targetY = player->actor.posRot.pos.y + targetHeight; + if (this->targetY < this->actor.posRot.pos.y) + this->targetY = this->actor.posRot.pos.y + targetHeight; + this->originPos = this->actor.posRot.pos; Audio_PlayActorSound2(this, NA_SE_EV_POT_MOVE_START); - this->playfunc = (ActorFunc)EnTuboTrap_InitializeAttack; + this->actionFunc = (ActorFunc)EnTuboTrap_Levitate; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s") -#endif -#ifdef NON_MATCHING -void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx) +void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx) { - this->actor.posRot.rot.y += 5000; - Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->pos_y_seek, 0.8f, 3.0f); /* Tween levitation */ + this->actor.shape.rot.y += 5000; + Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->targetY, 0.8f, 3.0f); - if (ABS(this->actor.posRot.pos.y - this->pos_y_seek) < 10.0f) + if (fabsf(this->actor.posRot.pos.y - this->targetY) < 10.0f) { this->actor.speedXZ = 10.0f; this->actor.posRot.rot.y = this->actor.rotTowardsLinkY; - this->playfunc = (ActorFunc)EnTuboTrap_Fly; + this->actionFunc = (ActorFunc)EnTuboTrap_Fly; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s") -#endif -#ifdef NON_MATCHING void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx) { - Vec3f pos_delta; + f32 dx = this->originPos.x - this->actor.posRot.pos.x; + f32 dy = this->originPos.y - this->actor.posRot.pos.y; + f32 dz = this->originPos.z - this->actor.posRot.pos.z; - VEC3_SUB(pos_delta, this->pos_init, this->actor.posRot.pos); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TUBOOCK_FLY); + Audio_PlayActorSound2(&this->actor, 0x3037); - if (240.0f < sqrtf(SQ(pos_delta.x) + SQ(pos_delta.y) + SQ(pos_delta.z))) - Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); /* Tween to ground */ + if (240.0f < sqrtf(SQ(dx) + SQ(dy) + SQ(dz))) + Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); - this->actor.posRot.rot.y += 5000; - EnTuboTrap_TestCollider(this, globalCtx); + this->actor.shape.rot.y += 5000; + EnTuboTrap_HandleImpact(this, globalCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s") -#endif -#ifdef NON_MATCHING void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx) { - this->playfunc(this, globalCtx); - Actor_MoveForward(&this->actor); /* Probably to haul ass towards Link */ - func_8002E4B4(globalCtx, &this->actor, 10.0f, 10.0f, 20.0f, 0x1D); /* Necessary for drawing a shadow */ - Actor_SetHeight(&this->actor, 0.0f); - ActorCollider_Cylinder_Update(&this->actor, &this->capsule); - Actor_CollisionCheck_SetAC(globalCtx, &globalCtx->sub_11E60, &this->capsule); - Actor_CollisionCheck_SetAT(globalCtx, &globalCtx->sub_11E60, &this->capsule); + EnTuboTrap* tuboTrap = this; + SubGlobalContext11E60* sub_11E60 = &globalCtx->sub_11E60; + + tuboTrap->actionFunc(tuboTrap, globalCtx); + Actor_MoveForward(&tuboTrap->actor); + func_8002E4B4(globalCtx, &tuboTrap->actor, 10.0f, 10.0f, 20.0f, 0x1D); + Actor_SetHeight(&tuboTrap->actor, 0.0f); + ActorCollider_Cylinder_Update(&tuboTrap->actor, &tuboTrap->collider); + Actor_CollisionCheck_SetAC(globalCtx, sub_11E60, &tuboTrap->collider); + Actor_CollisionCheck_SetAT(globalCtx, sub_11E60, &tuboTrap->collider); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s") -#endif void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx) { - Draw_DListOpa(globalCtx, &DL_TUBO); + Draw_DListOpa(globalCtx, D_05017870); } diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h new file mode 100644 index 0000000000..55a3a5a937 --- /dev/null +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h @@ -0,0 +1,18 @@ +#ifndef _Z_EN_TUBO_TRAP_H_ +#define _Z_EN_TUBO_TRAP_H_ + +#include +#include + +typedef struct +{ + /* 0x0000 */ Actor actor; + /* 0x014C */ ActorFunc actionFunc; + /* 0x0150 */ f32 targetY; + /* 0x0154 */ Vec3f originPos; + /* 0x0160 */ ColliderCylinderMain collider; +} EnTuboTrap; // size = 0x01AC + +extern const ActorInit En_Tubo_Trap_InitVars; + +#endif diff --git a/undefined_syms.txt b/undefined_syms.txt index c2d7779fd5..102b185600 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -140,8 +140,8 @@ D_0703811C = 0x0703811C; D_080895C0 = 0x080895C0; // z_en_tubo_trap -DL_TUBO = 0x05017870; -DL_SHARD = 0x05017A60; +D_05017870 = 0x05017870; +D_05017A60 = 0x05017A60; // z_en_vase DL_VASE = 0x06000000;