From 42cf7ea569adb8ab8851b856740deb7985034e30 Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 30 Mar 2022 19:27:53 -0700 Subject: sub_08064B88 ok --- src/npc/sturgeon.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 90903566..89e06fbb 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -14,6 +14,8 @@ void sub_08064CC0(Entity* this); extern void (*const gUnk_0810FA44[])(Entity*); void sub_08064C9C(Entity* this); +void sub_08064CD8(Entity* this); + void Sturgeon(Entity* this) { if ((this->flags & ENT_SCRIPTED) == 0) { gUnk_0810FA44[this->action](this); @@ -57,7 +59,43 @@ void sub_08064B44(Entity* this) { } } -ASM_FUNC("asm/non_matching/sturgeon/sub_08064B88.inc", void sub_08064B88(Entity* this)) +void sub_08064B88(Entity* this) { + s32 temp; + s32 temp2; + + switch (this->interactType) { + case 0: + temp = sub_0806EE20(this); + this->animationState = this->knockbackDirection; + if (temp != 0) { + InitializeAnimation(this, temp & 0x7f); + } + GetNextFrame(this); + break; + case 2: + this->action = 3; + temp2 = GetAnimationState(this); + if (temp2 < 0) { + temp2 = this->animationState; + } + this->subtimer = this->animIndex; + InitializeAnimation(this, temp2); + this->interactType = 0; + sub_0806F118(this); + break; + case 1: + default: + this->action = 2; + temp2 = GetAnimationState(this); + if (temp2 < 0) { + temp2 = this->animationState; + } + this->subtimer = this->animIndex; + InitializeAnimation(this, temp2); + this->interactType = 0; + sub_08064CD8(this); + } +} void sub_08064C2C(Entity* this) { if ((gMessage.doTextBox & 0x7f) == 0) { -- cgit v1.2.3 From 12e5608104c4fa141858715bc1e4c1fa912b44c0 Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 30 Mar 2022 19:31:09 -0700 Subject: sub_080385CC ok --- src/enemy/cloudPiranha.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/enemy/cloudPiranha.c b/src/enemy/cloudPiranha.c index 5f4eb371..9e519d4b 100644 --- a/src/enemy/cloudPiranha.c +++ b/src/enemy/cloudPiranha.c @@ -128,7 +128,7 @@ void CloudPiranha_Action1(CloudPiranhaEntity* this) { } } -NONMATCH("asm/non_matching/cloudPiranha/sub_080385CC.inc", void sub_080385CC(CloudPiranhaEntity* this)) { +void sub_080385CC(CloudPiranhaEntity* this) { u32 tmp; sub_080387F0(this); if (sub_0803872C(this, 0x60)) { @@ -145,18 +145,13 @@ NONMATCH("asm/non_matching/cloudPiranha/sub_080385CC.inc", void sub_080385CC(Clo super->animationState = sub_0806FCAC(super, super->child); } else { tmp = super->animationState; - if ((Random() & 0x10) != 0) { - super->animationState = (tmp + 2) & 7; - } else { - super->animationState = (tmp + 6) & 7; - } + super->animationState = (Random() & 0x10) ? ((tmp + 2) & 7) : ((tmp + 6) & 7); } super->direction = super->animationState << 2; InitializeAnimation(super, super->animationState); } } } -END_NONMATCH void CloudPiranha_Action3(CloudPiranhaEntity* this) { s32 tmp; -- cgit v1.2.3 From 3d2577eddf3b336a5664ee2089e6c8ade2c15716 Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 30 Mar 2022 20:32:34 -0700 Subject: postman matching attempts --- src/npc/postman.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/npc/postman.c b/src/npc/postman.c index d8c61312..bced68a9 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -9,6 +9,8 @@ extern void sub_080604DC(Entity*); extern void sub_080606D8(Entity*); extern void sub_080606C0(Entity*); +extern const s8 gUnk_0810AA70[]; + typedef struct { s16 x; s16 y; @@ -192,9 +194,81 @@ void sub_0806075C(Entity* this) { this->field_0x68.HALF.HI = 0xff; } -ASM_FUNC("asm/non_matching/postman/sub_0806076C.inc", void sub_0806076C(Entity* this, ScriptExecutionContext* context)) +NONMATCH("asm/non_matching/postman/sub_0806076C.inc", + void sub_0806076C(Entity* this, ScriptExecutionContext* context)) { + s8* p; + u32 tmp, size; + int i; + + if (this->z.WORD < 0) { + gActiveScriptInfo.commandSize = 0; + return; + } -ASM_FUNC("asm/non_matching/postman/sub_080608E4.inc", void sub_080608E4(Entity* this, ScriptExecutionContext* context)) + this->field_0x68.HALF.HI++; + this->collisionLayer = 1; + sub_080606C0(this); + p = &gUnk_0810A918[this->field_0x68.HALF.LO][this->field_0x68.HALF.HI]; + do { + switch (p[0] + 5) { + case 5: + this->field_0x68.HALF.LO = p[(s32)Random() % p[1] + 2]; + this->field_0x68.HALF.HI = 0; + return; + case 4: + this->field_0x6a.HWORD = 300; + break; + case 3: + this->collisionLayer = 1; + break; + case 2: + this->collisionLayer = 2; + break; + case 1: + context->wait = 30; + this->spriteSettings.draw = 0; + break; + case 0: + size = p[1]; + tmp = Random() % size; + for (i = 0; i < size; ++i) { + this->field_0x68.HALF.HI = p[i + 2]; + this->x.HALF.HI = + gUnk_0810A66C[gUnk_0810A918[this->field_0x68.HALF.LO][0]].x + gRoomControls.origin_x; + this->y.HALF.HI = + gUnk_0810A66C[gUnk_0810A918[this->field_0x68.HALF.LO][0]].y + gRoomControls.origin_y; + if (!CheckOnScreen(this)) { + break; + } + tmp = (tmp + 1) % size; + } + this->field_0x68.HALF.LO = 0; + return; + default: + return; + } + this->field_0x68.HALF.LO++; + p++; + } while (1); +} +END_NONMATCH + +NONMATCH("asm/non_matching/postman/sub_080608E4.inc", + void sub_080608E4(Entity* this, ScriptExecutionContext* context)) { + context->condition = 0; + if (this->z.WORD >= 0) { + if ((this->collisionLayer != 1 || gPlayerEntity.collisionLayer != 2) && + (this->collisionLayer != 2 || gPlayerEntity.collisionLayer != 1)) { + const s8* ptr = &gUnk_0810AA70[context->intVariable * 16 + (this->animationState >> 1) * 4]; + if (ptr[0] + gPlayerEntity.x.HALF.HI + ptr[2] - this->x.HALF.HI < ptr[2] * 2 && + ptr[1] + gPlayerEntity.y.HALF.HI + ptr[3] - this->y.HALF.HI < ptr[3] * 2) { + context->condition = 1; + this->field_0x6a.HWORD += 2; + } + } + } +} +END_NONMATCH void Postman_Fusion(Entity* this) { if (this->action == 0) { -- cgit v1.2.3 From 00b400a26f81b86643aae37714d8dcc5d526711a Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 30 Mar 2022 21:09:58 -0700 Subject: npc23 match attempt --- src/npc/npc23.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/npc/npc23.c b/src/npc/npc23.c index c0b01efb..c684da71 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -101,6 +101,51 @@ void sub_08066474(void) { ASM_FUNC("asm/non_matching/npc23/sub_08066490.inc", void sub_08066490(Entity* this, Entity* entity)) -ASM_FUNC("asm/non_matching/npc23/sub_0806650C.inc", bool32 sub_0806650C(Entity* this)) +// px needs to be used in both r5 and r7 +NONMATCH("asm/non_matching/npc23/sub_0806650C.inc", bool32 sub_0806650C(Entity* this)) { + u32 dir = 0; + s32 px = gPlayerEntity.x.HALF_U.HI; + s32 py = gPlayerEntity.y.HALF_U.HI; -ASM_FUNC("asm/non_matching/npc23/sub_08066570.inc", void sub_08066570(Entity* this)) + if (py < this->field_0x80.HWORD + 16) { + dir = 4; + } else { + if (px < this->field_0x7c.HALF_U.HI + 2) { + dir = 2; + } + if (px > this->field_0x7c.HALF_U.HI + 6) { + dir = 6; + } + if (dir == 0) { + gPlayerEntity.speed = 0; + } + } + + if (gPlayerEntity.action != PLAYER_ROOM_EXIT) { + if (dir == 0) { + return 0; + } + sub_08078AC0(8, 0, 0); + gPlayerEntity.animationState = dir; + gPlayerEntity.direction = Direction8FromAnimationState(dir); + } + return 1; +} +END_NONMATCH + +NONMATCH("asm/non_matching/npc23/sub_08066570.inc", void sub_08066570(Entity* this)) { + if (this->frame & ANIM_DONE) { + return; + } + + if (this->action == 3 && sub_0806FC80(this, &gPlayerEntity, 0x50)) { + u32 direction = GetFacingDirection(this, &gPlayerEntity); + bool32 cond = (this->direction & 0x18) == (direction & 0x18) && ((this->direction + 5) & 7) < 3 && + ((direction + 5) & 7) < 3; + if (!cond) { + this->direction = direction; + InitializeAnimation(this, ((u32)(this->direction + 4) & 0x18) >> 3); + } + } +} +END_NONMATCH -- cgit v1.2.3 From 5fedcc4e27d42be05644cbba29a793ad60a6dec8 Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 30 Mar 2022 21:17:53 -0700 Subject: cf --- src/npc/sturgeon.c | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 89e06fbb..a181b50c 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -64,36 +64,36 @@ void sub_08064B88(Entity* this) { s32 temp2; switch (this->interactType) { - case 0: - temp = sub_0806EE20(this); - this->animationState = this->knockbackDirection; - if (temp != 0) { - InitializeAnimation(this, temp & 0x7f); - } - GetNextFrame(this); - break; - case 2: - this->action = 3; - temp2 = GetAnimationState(this); - if (temp2 < 0) { - temp2 = this->animationState; - } - this->subtimer = this->animIndex; - InitializeAnimation(this, temp2); - this->interactType = 0; - sub_0806F118(this); - break; - case 1: - default: - this->action = 2; - temp2 = GetAnimationState(this); - if (temp2 < 0) { - temp2 = this->animationState; - } - this->subtimer = this->animIndex; - InitializeAnimation(this, temp2); - this->interactType = 0; - sub_08064CD8(this); + case 0: + temp = sub_0806EE20(this); + this->animationState = this->knockbackDirection; + if (temp != 0) { + InitializeAnimation(this, temp & 0x7f); + } + GetNextFrame(this); + break; + case 2: + this->action = 3; + temp2 = GetAnimationState(this); + if (temp2 < 0) { + temp2 = this->animationState; + } + this->subtimer = this->animIndex; + InitializeAnimation(this, temp2); + this->interactType = 0; + sub_0806F118(this); + break; + case 1: + default: + this->action = 2; + temp2 = GetAnimationState(this); + if (temp2 < 0) { + temp2 = this->animationState; + } + this->subtimer = this->animIndex; + InitializeAnimation(this, temp2); + this->interactType = 0; + sub_08064CD8(this); } } -- cgit v1.2.3