Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompile st/no3 EntityUnkId31 #1626

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 115 additions & 1 deletion src/st/no3/48A84.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,121 @@ void EntityUnkId30(Entity* self) {
}
}

INCLUDE_ASM("st/no3/nonmatchings/48A84", EntityUnkId31);
void EntityUnkId31(Entity* self) {
Entity* entity;
u16* hitboxPtr;
u16 animFrameIdx;
u16 animCurFrame;
s16 i;

entity = self - 2;
if (self->step == 0) {
InitializeEntity(D_80180B24);
self->zPriority++;
CreateEntityFromCurrentEntity(E_ID_30, self + 1);
(self + 1)->params = 1;
}
if (self->ext.prim) {
animFrameIdx = (self->animFrameIdx - 1) * 2;
if (entity->step_s == 1) {
hitboxPtr = D_80182FC8 + animFrameIdx;
} else {
hitboxPtr = D_80182FE8 + animFrameIdx;
}

if (self->facingLeft) {
self->posX.i.hi = entity->posX.i.hi - *hitboxPtr++;
} else {
self->posX.i.hi = entity->posX.i.hi + *hitboxPtr++;
}
self->posY.i.hi = entity->posY.i.hi + *hitboxPtr++;
} else {
self->posX.i.hi = entity->posX.i.hi;
self->posY.i.hi = entity->posY.i.hi;
}
self->facingLeft = entity->facingLeft;
animCurFrame = entity->animCurFrame;
if (self->flags & FLAG_DEAD) {
hitboxPtr = D_80182F9C;
PlaySfxPositional(0x684);

for (i = 0; i < 3; i++) {
entity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (entity) {
CreateEntityFromCurrentEntity(E_ID_32, entity);
if (self->facingLeft != 0) {
entity->posX.i.hi -= *hitboxPtr++;
} else {
entity->posX.i.hi += *hitboxPtr++;
}
entity->posY.i.hi += *hitboxPtr++;
entity->params = i;
entity->facingLeft = self->facingLeft;
}
}

hitboxPtr = D_80182FA8;
for (i = 0; i < 8; i++) {
entity = AllocEntity(&g_Entities[224], &g_Entities[256]);

if (!entity) {
break;
}

CreateEntityFromCurrentEntity(E_EXPLOSION, entity);
JoshSchreuder marked this conversation as resolved.
Show resolved Hide resolved
entity->params = ((self->zPriority + 1) << 8) + 1;
if (self->facingLeft != 0) {
entity->posX.i.hi -= *hitboxPtr++;
} else {
entity->posX.i.hi += *hitboxPtr++;
}
entity->posY.i.hi += *hitboxPtr++;
}

DestroyEntity(self);
DestroyEntity(self + 1);
return;
}

if (!self->ext.prim) {
if (animCurFrame >= 86) {
animCurFrame -= 10;
} else if (animCurFrame > 72) {
animCurFrame -= 3;
} else if (animCurFrame < 57) {
animCurFrame = 49;
} else {
animCurFrame -= 6;
}

if (animCurFrame != 78) {
if ((entity->step == 3) && ((u8)entity->ext.timer.t != 0)) {
self->animCurFrame = animCurFrame + 58;
} else {
self->animCurFrame = animCurFrame;
}
}
} else {
animCurFrame = self->animCurFrame;
}

if (animCurFrame > 81) {
animCurFrame -= 62;
} else if (animCurFrame > 75) {
animCurFrame -= 59;
} else if (animCurFrame > 62) {
animCurFrame -= 56;
} else if (animCurFrame > 50) {
animCurFrame -= 50;
} else {
animCurFrame -= 49;
}
hitboxPtr = &D_80182E1C[animCurFrame * 8];
self->hitboxOffX = *hitboxPtr++;
self->hitboxOffY = *hitboxPtr++;
self->hitboxWidth = *hitboxPtr++;
self->hitboxHeight = *hitboxPtr++;
}

// some sort of explosion
INCLUDE_ASM("st/no3/nonmatchings/48A84", EntityExplosion3);
Expand Down
6 changes: 6 additions & 0 deletions src/st/no3/no3.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ typedef enum EntityIDs {
/* 0x15 */ E_ID_15 = 0x15,
/* 0x17 */ E_BG_LIGHTNING = 0x17,
/* 0x27 */ E_FALLING_ROCK_2 = 0x27,
/* 0x30 */ E_ID_30 = 0x30,
/* 0x32 */ E_ID_32 = 0x32,
/* 0x35 */ E_SPLASH_WATER = 0x35,
/* 0x36 */ E_SURFACING_WATER,
/* 0x37 */ E_SIDE_WATER_SPLASH,
Expand Down Expand Up @@ -88,6 +90,10 @@ extern s16 D_80182A38[];
extern u8 D_80182A48[];
extern u16 D_80182A4C[];
extern u16 D_80182E1C[];
extern u16 D_80182F9C[];
extern u16 D_80182FA8[];
extern u16 D_80182FC8[];
extern u16 D_80182FE8[];
extern u16 D_80180AD0[];
extern u16 g_EInitGeneric[];
extern u16 D_80180AF4[];
Expand Down
Loading