NZ0 EntityFloorSpikes & func_801C3F9C (#198)

NONMATCHING because of assembler nop skipping
This commit is contained in:
Alejandro Asenjo Nitti 2023-04-21 04:48:12 -03:00 committed by GitHub
parent aff1db2091
commit aeda88ff6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 142 additions and 4 deletions

View File

@ -97,6 +97,7 @@ EntitySkeleton = 0x801C5FC4;
EntitySpittleBone = 0x801C672C;
EntitySpittleBoneSpit = 0x801C6C6C;
EntityTableWithGlobe = 0x801B3534;
EntityFloorSpikes = 0x801B3294;
EntitySubWeaponContainer = 0x801C7048;
EntityCloseBossRoom = 0x801B3FCC;
EntityBossRoomBlock = 0x801B4518;

View File

@ -261,3 +261,17 @@ typedef struct {
s32 unk8;
s32 unkC;
} Unkstruct_800FDB18;
typedef struct Unkstruct_801C3F9C {
/* 0x00 */ char pad0[0xA];
/* 0x0A */ s16 unk0A;
/* 0x0C */ s32 unk0C;
/* 0x10 */ s32 unk10;
/* 0x14 */ s16 unk14;
/* 0x16 */ char pad16[0x8];
/* 0x1E */ s16 unk1E;
/* 0x20 */ char pad20[0x4];
/* 0x24 */ u8 unk24;
/* 0x25 */ char pad25[0x7];
/* 0x2C */ s16 unk2C;
} Unkstruct_801C3F9C;

View File

@ -907,7 +907,85 @@ INCLUDE_ASM("asm/us/st/nz0/nonmatchings/30958", func_801B2D08);
INCLUDE_ASM("asm/us/st/nz0/nonmatchings/30958", func_801B2FD8);
INCLUDE_ASM("asm/us/st/nz0/nonmatchings/30958", func_801B3294);
// Aspatch skips a nop. TODO: Fix compiler
// Matching in decompme: https://decomp.me/scratch/Swhgi
#ifndef NON_MATCHING
INCLUDE_ASM("asm/us/st/nz0/nonmatchings/30958", EntityFloorSpikes);
#else
void EntityFloorSpikes(Entity* self) {
Primitive* prim;
s16 firstPrimIndex;
s32 var_v1;
s32 tilePos;
s32 new_var;
u8 temp; // !FAKE
volatile int pad[3];
switch (self->step) {
case 0:
InitializeEntity(D_80180BF8);
self->hitboxWidth = 12;
self->hitboxHeight = 12;
self->attackElement = 1;
self->attack = 7;
self->unk3C = 1;
self->unk80.modeS32 = self->posY.i.hi + g_Camera.posY.i.hi;
temp = 4;
new_var = self->posY.i.hi - 4;
new_var += g_Camera.posY.i.hi;
tilePos = ((self->posX.i.hi - temp + g_Camera.posX.i.hi) >> 4) +
(((new_var >> 4) * g_CurrentRoom.hSize) * 16);
g_CurrentRoomTileLayout.fg[tilePos] = 0x102;
g_CurrentRoomTileLayout.fg[tilePos + 1] = 0x103;
firstPrimIndex = g_api.AllocPrimitives(4, 1);
if (firstPrimIndex == (-1)) {
DestroyEntity(self);
return;
}
prim = &g_PrimBuf[firstPrimIndex];
self->firstPolygonIndex = firstPrimIndex;
*((s32*)(&self->unk7C)) = prim;
self->flags |= 0x800000;
prim->type = 6;
prim->tpage = 0xF;
prim->clut = 9;
prim->u0 = 0x28;
prim->v0 = 0xC8;
prim->v1 = prim->u1 = 0x20;
prim->priority = 0x5F;
prim->blendMode = 2;
self->posY.i.hi -= 28;
case 1:
self->unk3C = 1;
if (self->unk84.unk != 0) {
self->posY.val += 0x10000;
new_var = g_Camera.posY.i.hi + self->posY.i.hi;
var_v1 = g_Camera.posY.i.hi;
if (new_var > self->unk80.modeS32) {
self->unk3C = 0;
self->posY.i.hi = self->unk80.modeS16.unk0 - var_v1;
}
} else {
self->posY.val += 0xFFFF0000;
new_var = g_Camera.posY.i.hi + self->posY.i.hi;
var_v1 = g_Camera.posY.i.hi;
if (new_var < (self->unk80.modeS32 - 28)) {
self->posY.i.hi = self->unk80.modeS16.unk0 - 28 - var_v1;
}
}
}
if (self->unk88.U8.unk0 != 0) {
func_801C29B0(0x69D);
self->unk88.S8.unk0 = 0;
}
prim = *((s32*)(&self->unk7C));
prim->x0 = self->posX.i.hi - 16;
prim->y0 = self->posY.i.hi - 16;
}
#endif
// table with globe on it that can be broken
void EntityTableWithGlobe(Entity* self) {

View File

@ -1085,10 +1085,55 @@ void EntityFallingDebris(Entity* entity) {
}
}
// Unique
// aspatch skips a nop. TODO: fix compiler
// matching in decomp.me: https://decomp.me/scratch/oDgqZ
#ifndef NON_MATCHING
INCLUDE_ASM("asm/us/st/nz0/nonmatchings/3E30C", func_801C3F9C);
#else
void func_801C3F9C(Unkstruct_801C3F9C** self) {
Collider collider;
Entity* newEntity;
s16 temp;
// Unique
func_801C9930();
switch ((*self)->unk24) {
case 0:
(*self)->unk0C = 0;
(*self)->unk10 = -0x10000;
(*self)->unk24 = 1;
(*self)->unk2C = 0x100;
break;
case 1:
temp = (*self)->unk0A + ((*self)->unk1E / 3);
g_api.CheckCollision((*self)->unk14, temp, &collider, 0);
if (collider.unk0 % 2) {
(*self)->unk0A = (*self)->unk0A + collider.unk18;
if ((*self)->unk10 < 0x4000) {
(*self)->unk2C = 1;
}
(*self)->unk10 = -(*self)->unk10;
(*self)->unk10 -= (*self)->unk10 / 2;
}
(*self)->unk10 += 0x1800;
(*self)->unk2C--;
if ((*self)->unk2C == 0) {
newEntity = AllocEntity(D_8007D858, &D_8007D858[32]);
if (newEntity != NULL) {
CreateEntityFromCurrentEntity(ENTITY_EXPLOSION, newEntity);
newEntity->posX.i.hi = (*self)->unk14;
newEntity->posY.i.hi = (*self)->unk0A;
newEntity->subId = 0;
}
func_801C29B0(0x655);
func_801CA0D0(self);
}
return;
}
}
#endif
// Called by EntityAxeKnight
INCLUDE_ASM("asm/us/st/nz0/nonmatchings/3E30C", func_801C4198);
void func_801C4550(void) {

View File

@ -8,7 +8,7 @@ s32 func_801BCF74(s32*);
s32 func_801BD720(u16* hitSensors, s16 sensorCount);
s32 func_801BD9A0(Entity* entity, s32 arg1, s32 arg2, s32 arg3);
void EntityExplosion(Entity*);
void func_801C29B0(s32);
void func_801C29B0(s32); // sfx
void func_801C33D8(const u32*, s32);
void func_801C0B24(Entity* entity);
void func_801C4CC0(void);