Decompile no0 EntityCtulhuDeath (#1907)

Little'un

PSX: https://decomp.me/scratch/qOMdH
PSP: https://decomp.me/scratch/wgU6e
This commit is contained in:
Josh Schreuder 2024-11-16 11:05:06 +11:00 committed by GitHub
parent fa08821104
commit d646cd1a17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 66 additions and 40 deletions

View File

@ -2041,7 +2041,7 @@ typedef struct {
/* 0x9C */ s32 y;
/* 0xA0 */ s32 : 32;
/* 0xA4 */ struct Primitive* unkA4;
} ET_801D9264;
} ET_Ctulhu;
typedef struct {
/* 0x7C */ s32 : 32;
@ -2257,7 +2257,7 @@ typedef union { // offset=0x7C
ET_OuijaTable ouijaTable;
ET_OuijaTableContents ouijaTableContents;
ET_FleaMan fleaMan;
ET_801D9264 et_801D9264;
ET_Ctulhu ctulhu;
ET_StoneRose stoneRose;
ET_GhostEnemy ghostEnemy;
ET_GhostEnemySpawner ghostEnemySpawner;

View File

@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "no0.h"
extern u16 D_us_80180BD8[];
extern u16 D_us_80180BDE[];
extern u16 D_us_8018234C[];
extern u16 D_us_80182354[];
@ -15,9 +14,9 @@ extern u8 D_us_801823E4[];
extern u8 D_us_801823F4[];
extern u8 D_us_8018243C[];
extern u16 D_us_80182454[];
extern u8 D_us_8018245C[]; // anim_death
// Main Cthulu entity
void func_us_801D9264(Entity* self) {
void EntityCtulhu(Entity* self) {
RECT clipRect;
DRAWENV drawEnv;
DR_ENV* dr_env;
@ -42,7 +41,7 @@ void func_us_801D9264(Entity* self) {
}
switch (self->step) {
case 0:
InitializeEntity(&D_us_80180BD8);
InitializeEntity(g_EInitCtulhu);
self->animCurFrame = 1;
/* fallthrough */
case 1:
@ -53,18 +52,18 @@ void func_us_801D9264(Entity* self) {
break;
case 2:
if (self->step_s == 0) {
self->ext.et_801D9264.timer = 0x40;
self->ext.ctulhu.timer = 0x40;
self->step_s++;
}
AnimateEntity(D_us_80182390, self);
if (self->ext.et_801D9264.timer == 0x20) {
if (self->ext.ctulhu.timer == 0x20) {
self->facingLeft ^= 1;
}
if ((self->facingLeft == ((GetSideToPlayer() & 1) ^ 1)) &&
(GetDistanceToPlayerX() < 0x48)) {
SetStep(5);
}
if (!--self->ext.et_801D9264.timer) {
if (!--self->ext.ctulhu.timer) {
SetStep(3);
}
break;
@ -72,7 +71,7 @@ void func_us_801D9264(Entity* self) {
switch (self->step_s) {
case 0:
if (!AnimateEntity(D_us_801823E4, self)) {
self->ext.et_801D9264.y =
self->ext.ctulhu.y =
self->posY.i.hi + g_Tilemap.scrollY.i.hi - 0x20;
SetSubStep(1);
}
@ -87,7 +86,7 @@ void func_us_801D9264(Entity* self) {
MoveEntity();
self->velocityY += FIX(3.0 / 16);
posY = self->posY.i.hi + g_Tilemap.scrollY.i.hi;
posY -= self->ext.et_801D9264.y;
posY -= self->ext.ctulhu.y;
if ((posY <= 0) || (self->velocityY > 0)) {
self->step_s++;
}
@ -98,9 +97,9 @@ void func_us_801D9264(Entity* self) {
PlaySfxPositional(SFX_WING_FLAP_A);
}
posY = self->posY.i.hi + g_Tilemap.scrollY.i.hi;
posY -= self->ext.et_801D9264.y;
posY -= self->ext.ctulhu.y;
if (posY == 0) {
self->ext.et_801D9264.timer = 0x80;
self->ext.ctulhu.timer = 0x80;
self->velocityY = 0;
self->step_s++;
} else if (posY < 0) {
@ -124,12 +123,12 @@ void func_us_801D9264(Entity* self) {
self->velocityX = FIX(-0.75);
}
if (self->ext.et_801D9264.timer == 0) {
if (self->ext.ctulhu.timer == 0) {
if (colRet == 1) {
SetSubStep(5);
}
} else {
self->ext.et_801D9264.timer--;
self->ext.ctulhu.timer--;
}
break;
case 5:
@ -163,11 +162,11 @@ void func_us_801D9264(Entity* self) {
self->velocityY += FIX(3.0 / 16);
if (self->velocityY > 0) {
self->step_s++;
if (self->ext.et_801D9264.unk84 == 0) {
self->ext.et_801D9264.unk84 = 2;
if (self->ext.ctulhu.unk84 == 0) {
self->ext.ctulhu.unk84 = 2;
SetStep(7);
} else {
self->ext.et_801D9264.unk84--;
self->ext.ctulhu.unk84--;
}
}
break;
@ -185,15 +184,15 @@ void func_us_801D9264(Entity* self) {
}
SetSubStep(0);
if (self->ext.et_801D9264.unk84 == 1) {
if (self->ext.ctulhu.unk84 == 1) {
SetStep(6);
posX = self->posX.i.hi + g_Tilemap.scrollX.i.hi;
if (posX > 0x400) {
self->facingLeft = 1;
self->ext.et_801D9264.unk85 = 3;
self->ext.ctulhu.unk85 = 3;
}
if (++self->ext.et_801D9264.unk85 > 2) {
self->ext.et_801D9264.unk85 = 0;
if (++self->ext.ctulhu.unk85 > 2) {
self->ext.ctulhu.unk85 = 0;
SetStep(8);
}
} else {
@ -369,7 +368,7 @@ void func_us_801D9264(Entity* self) {
prim->drawMode = DRAW_UNK_800;
prim = prim->next;
self->ext.et_801D9264.unkA4 = prim;
self->ext.ctulhu.unkA4 = prim;
posY = self->params ? 0xFF : 0x7F;
prim->type = PRIM_GT4;
prim->tpage = 0x110;
@ -449,17 +448,17 @@ void func_us_801D9264(Entity* self) {
}
prim->drawMode = DRAW_DEFAULT;
self->ext.et_801D9264.y = 0x28;
self->ext.et_801D9264.timer = 0x10;
self->ext.ctulhu.y = 0x28;
self->ext.ctulhu.timer = 0x10;
self->step_s++;
/* fallthrough */
case 2:
if (!(g_Timer & 7)) {
PlaySfxPositional(SFX_FM_EXPLODE_B);
}
prim = self->ext.et_801D9264.unkA4;
prim = self->ext.ctulhu.unkA4;
posX = Random() & 0x3F;
posY = self->ext.et_801D9264.y;
posY = self->ext.ctulhu.y;
if (!(g_Timer & 0xF)) {
newEntity = AllocEntity(&g_Entities[STAGE_ENTITY_START],
&g_Entities[TOTAL_ENTITY_COUNT]);
@ -483,17 +482,17 @@ void func_us_801D9264(Entity* self) {
newEntity->zPriority += 4;
}
}
if (!--self->ext.et_801D9264.timer) {
self->ext.et_801D9264.timer = 2;
self->ext.et_801D9264.y -= 2;
if (self->ext.et_801D9264.y < -0x28) {
self->ext.et_801D9264.timer = 0x40;
if (!--self->ext.ctulhu.timer) {
self->ext.ctulhu.timer = 2;
self->ext.ctulhu.y -= 2;
if (self->ext.ctulhu.y < -0x28) {
self->ext.ctulhu.timer = 0x40;
self->step_s++;
}
}
break;
case 3:
if (!--self->ext.et_801D9264.timer) {
if (!--self->ext.ctulhu.timer) {
DestroyEntity(self);
return;
}
@ -521,5 +520,29 @@ INCLUDE_ASM("st/no0/nonmatchings/e_ctulhu", func_us_801DA488);
// Ice shockwave attack
INCLUDE_ASM("st/no0/nonmatchings/e_ctulhu", func_us_801DA6B4);
// Death
INCLUDE_ASM("st/no0/nonmatchings/e_ctulhu", func_us_801DADD0);
void EntityCtulhuDeath(Entity* self) {
switch (self->step) {
case 0:
InitializeEntity(g_EInitInteractable);
self->animSet = 14;
self->unk5A = 121;
self->palette = PAL_OVL(0x2CE);
self->drawFlags = FLAG_DRAW_UNK8;
self->unk6C = 16;
if (self->params) {
self->unk6C = 16;
self->drawMode = DRAW_UNK_40 | DRAW_TPAGE;
self->flags &= ~FLAG_POS_CAMERA_LOCKED;
} else {
self->zPriority += 2;
self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE;
}
// fallthrough
case 1:
self->posY.val += 0xFFFF0000;
if (!AnimateEntity(D_us_8018245C, self)) {
DestroyEntity(self);
}
break;
}
}

View File

@ -67,10 +67,10 @@ void func_us_801D8FFC(Entity*);
void func_us_801D91C4(Entity*);
void func_us_801D7DAC(Entity*);
void func_us_801C2B24(Entity*);
void func_us_801D9264(Entity*);
void EntityCtulhu(Entity*);
void func_us_801DA488(Entity*);
void func_us_801DA6B4(Entity*);
void func_us_801DADD0(Entity*);
void EntityCtulhuDeath(Entity*);
void EntityAxeKnight(Entity*);
void EntityAxeKnightThrowingAxe(Entity*);
void EntityExplosionPuffOpaque(Entity*);
@ -150,10 +150,10 @@ PfnEntityUpdate OVL_EXPORT(EntityUpdates)[] = {
func_us_801D91C4,
func_us_801D7DAC,
func_us_801C2B24,
func_us_801D9264,
EntityCtulhu,
func_us_801DA488,
func_us_801DA6B4,
func_us_801DADD0,
EntityCtulhuDeath,
EntityAxeKnight,
EntityAxeKnightThrowingAxe,
EntityExplosionPuffOpaque,
@ -198,7 +198,7 @@ EInit D_us_80180BA8 = {ANIMSET_OVL(0x08), 0x00, 0x48, 0x201, 0x031};
EInit g_EInitSlinger = {ANIMSET_OVL(0x0A), 0x01, 0x49, 0x203, 0x0B2};
EInit g_EInitSlingerPieces = {ANIMSET_OVL(0x0A), 0x00, 0x49, 0x203, 0x002};
EInit g_EInitSlingerRib = {ANIMSET_OVL(0x0A), 0x16, 0x49, 0x203, 0x0B3};
EInit D_us_80180BD8 = {ANIMSET_OVL(0x0E), 0x00, 0x50, 0x238, 0x0E9};
EInit g_EInitCtulhu = {ANIMSET_OVL(0x0E), 0x00, 0x50, 0x238, 0x0E9};
EInit D_us_80180BE4 = {ANIMSET_OVL(0x0E), 0x00, 0x50, 0x238, 0x0EA};
EInit D_us_80180BF0 = {ANIMSET_OVL(0x0E), 0x2C, 0x50, 0x238, 0x0EB};
EInit g_EInitAxeKnight = {ANIMSET_OVL(0x07), 0x01, 0x48, 0x23F, 0x0F6};

View File

@ -84,6 +84,9 @@ extern EInit g_EInitGhostEnemy;
extern EInit g_EInitSkelerang;
extern EInit g_EInitSkelerangBoomerang;
// Ctulhu
extern EInit g_EInitCtulhu;
// Clock room
extern EInit g_Statues;