"Decompile" CEN Functions (#1274)

Several of the remaining ASM functions in CEN which already have
implementations in other stages.

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
This commit is contained in:
Jonathan Hohle 2024-06-07 10:10:59 -07:00 committed by GitHub
parent 267d697350
commit 0561f4d100
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 169 additions and 6 deletions

View File

@ -57,7 +57,6 @@ UpdateRoomPosition = 0x80193410;
EntityRedDoor = 0x8019362C;
DestroyEntity = 0x80194264;
AnimateEntity = 0x80194394;
GetSideToPlayer = 0x801945D4;
MoveEntity = 0x80194618;
FallEntity = 0x80194648;
SetStep = 0x80194EA4;

View File

@ -400,7 +400,44 @@ void func_80195714(void) {
}
}
INCLUDE_ASM("st/cen/nonmatchings/11280", func_80195798);
void func_80195798(u16 arg0) {
Collider collider;
if (g_CurrentEntity->velocityX < 0) {
g_api.CheckCollision(g_CurrentEntity->posX.i.hi,
g_CurrentEntity->posY.i.hi - 7, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH) {
g_CurrentEntity->velocityY = 0;
}
}
g_api.CheckCollision(g_CurrentEntity->posX.i.hi,
g_CurrentEntity->posY.i.hi + 7, &collider, 0);
if (arg0) {
if (!(collider.effects & EFFECT_NOTHROUGH)) {
MoveEntity();
FallEntity();
return;
}
g_CurrentEntity->velocityX = 0;
g_CurrentEntity->velocityY = 0;
if (collider.effects & EFFECT_QUICKSAND) {
g_CurrentEntity->posY.val += FIX(0.125);
return;
}
g_CurrentEntity->posY.i.hi += collider.unk18;
return;
}
if (!(collider.effects & EFFECT_NOTHROUGH)) {
MoveEntity();
func_80195714();
}
}
#include "../collect_heart.h"

View File

@ -14,7 +14,29 @@
#include "../entity_olrox_drool.h"
INCLUDE_ASM("st/cen/nonmatchings/18084", func_801988B0);
bool func_801988B0(Point16* unk) {
Collider collider;
FallEntity();
g_CurrentEntity->posX.val += g_CurrentEntity->velocityX;
g_CurrentEntity->posY.val += g_CurrentEntity->velocityY;
if (g_CurrentEntity->velocityY >= 0) {
s16 posX = g_CurrentEntity->posX.i.hi;
s16 posY = g_CurrentEntity->posY.i.hi;
posX += unk->x;
posY += unk->y;
g_api.CheckCollision(posX, posY, &collider, 0);
if (collider.effects & EFFECT_SOLID) {
g_CurrentEntity->posY.i.hi += collider.unk18;
g_CurrentEntity->velocityY = -g_CurrentEntity->velocityY / 2;
if (g_CurrentEntity->velocityY > FIX(-1.0)) {
return true;
}
}
}
return false;
}
u8 func_801989AC(s32 arg0) {
Collider collider;
@ -191,9 +213,54 @@ u8 func_801989AC(s32 arg0) {
// ID 06
#include "../entity_intense_explosion.h"
INCLUDE_ASM("st/cen/nonmatchings/18084", func_8019902C);
extern u8 D_80181174[];
INCLUDE_ASM("st/cen/nonmatchings/18084", func_801990F8);
void func_8019902C(Entity* entity) {
if (!entity->step) {
InitializeEntity(g_InitializeEntityData0);
entity->unk6C = 0xF0;
entity->rotX = 0x1A0;
entity->rotY = 0x1A0;
entity->animSet = ANIMSET_DRA(8);
entity->animCurFrame = 1;
entity->zPriority += 0x10;
if (entity->params != 0) {
entity->palette = entity->params;
} else {
entity->palette = 0x8160;
}
entity->step++;
return;
}
MoveEntity();
if (!AnimateEntity(D_80181174, entity)) {
DestroyEntity(entity);
}
}
void func_801990F8(u16 entityId, Entity* src, Entity* dst) {
DestroyEntity(dst);
dst->entityId = entityId;
dst->pfnUpdate = PfnEntityUpdates[entityId - 1];
dst->posX.i.hi = src->posX.i.hi;
dst->posY.i.hi = src->posY.i.hi;
dst->unk5A = src->unk5A;
dst->zPriority = src->zPriority;
dst->animSet = src->animSet;
dst->flags = FLAG_UNK_2000 | FLAG_UNK_01000000 | FLAG_UNK_04000000 |
FLAG_UNK_08000000 | FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA |
FLAG_DESTROY_IF_OUT_OF_CAMERA;
if (src->palette & 0x8000) {
dst->palette = src->hitEffect;
} else {
dst->palette = src->palette;
}
}
void func_801991C0(void) {
Entity* entity;

View File

@ -32,7 +32,67 @@ void EntityBackgroundBlock(Entity* self) {
AnimateEntity(obj->unk10, self);
}
INCLUDE_ASM("st/cen/nonmatchings/D600", EntityUnkId12);
extern u16 D_801804E4[];
extern u16 D_8018044C[];
extern u8 D_801804DC[];
extern u8 D_801804D4[];
void EntityUnkId12(Entity* entity) {
s32 ret;
u16* temp_v0_2;
u16 temp_s1 = entity->params;
u16 phi_v1;
u16 unk;
entity->unk6D[0] = 0;
if (entity->step != 0) {
switch (temp_s1) {
case 4:
case 5:
if (g_Tilemap.x != 0) {
return;
}
break;
case 6:
if (g_pads->pressed & PAD_TRIANGLE) {
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
entity->step++;
return;
}
break;
}
if (entity->unk44 != 0) {
ret = GetSideToPlayer();
phi_v1 = entity->ext.generic.unk7C.s;
if (phi_v1 != 0) {
phi_v1 = (ret & 2) * 2;
} else {
phi_v1 = (ret & 1) * 4;
}
unk = 8;
temp_s1 = (temp_s1 * unk) + phi_v1;
temp_v0_2 = &D_801804E4[temp_s1];
g_Tilemap.x = *(temp_v0_2++);
g_Tilemap.y = *(temp_v0_2++);
g_Tilemap.width = *(temp_v0_2++);
g_Tilemap.height = *(temp_v0_2++);
}
} else {
InitializeEntity(D_8018044C);
entity->ext.generic.unk7C.s = D_801804DC[temp_s1];
if (entity->ext.generic.unk7C.s != 0) {
entity->hitboxWidth = D_801804D4[temp_s1];
entity->hitboxHeight = 16;
} else {
entity->hitboxWidth = 16;
entity->hitboxHeight = D_801804D4[temp_s1];
}
}
}
void EntityUnkId01(Entity* self) {
Entity* newEntity;