Eliminate ET_Generic, and ext.stub (#1825)
Some checks are pending
Format code / format (push) Waiting to run
Build C code / extract-assets (push) Waiting to run
Build C code / build-linux (i686, Debug, clang, custom) (push) Blocked by required conditions
Build C code / build-linux (i686, Debug, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (i686, Debug, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (i686, Debug, gcc, lle) (push) Blocked by required conditions
Build C code / build-linux (i686, RelWithDebInfo, clang, custom) (push) Blocked by required conditions
Build C code / build-linux (i686, RelWithDebInfo, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (i686, RelWithDebInfo, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (i686, RelWithDebInfo, gcc, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, clang, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, Debug, gcc, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, clang, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, clang, lle) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, gcc, custom) (push) Blocked by required conditions
Build C code / build-linux (x86_64, RelWithDebInfo, gcc, lle) (push) Blocked by required conditions
Build C code / build-macos (Debug, custom) (push) Blocked by required conditions
Build C code / build-macos (Debug, lle) (push) Blocked by required conditions
Build C code / build-macos (RelWithDebInfo, custom) (push) Blocked by required conditions
Build C code / build-macos (RelWithDebInfo, lle) (push) Blocked by required conditions
Build C code / build-windows (Debug, custom) (push) Blocked by required conditions
Build C code / build-windows (Debug, lle) (push) Blocked by required conditions
Build C code / build-windows (RelWithDebInfo, custom) (push) Blocked by required conditions
Build C code / build-windows (RelWithDebInfo, lle) (push) Blocked by required conditions
Build Saturn version / build-and-test-saturn (push) Waiting to run
Build Saturn version / function-finder-saturn (push) Waiting to run
Build Debug Module tool / build (push) Waiting to run
Build PSX and PSP version / build-and-test (pspeu, hd) (push) Waiting to run
Build PSX and PSP version / build-and-test (pspeu, pspeu) (push) Waiting to run
Build PSX and PSP version / build-and-test (us, us) (push) Waiting to run
Build PSX and PSP version / generate-progress-report (pspeu, hd) (push) Blocked by required conditions
Build PSX and PSP version / generate-progress-report (pspeu, pspeu) (push) Blocked by required conditions
Build PSX and PSP version / generate-progress-report (us, us) (push) Blocked by required conditions
Build PSX and PSP version / generate-duplicates-report (us, us) (push) Blocked by required conditions
Build PSX and PSP version / generate-duplicates-report-psp (pspeu, pspeu) (push) Blocked by required conditions

The quest is done!

This eliminates the ET_Generic, and as a bonus, stub, from the Entity
struct. This means no future code will be able to use these as defaults
and will have to choose a particular extension, which is nice.

As usual, while doing these cleanups I found various duplications to
solve and file splits to normalize. Overall the code becomes more and
more readable.
This commit is contained in:
bismurphy 2024-10-25 18:56:41 -04:00 committed by GitHub
parent e690f00952
commit f05601f103
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 387 additions and 565 deletions

View File

@ -40,7 +40,7 @@ segments:
- [0x128, data]
- [0x220, .data, e_laydef] # layout entries header
- [0x3C8, data]
- [0x590, data]
- [0x580, .data, st_debug]
- [0x610, data]
- [0x630, data]
- [0x640, data]
@ -71,7 +71,7 @@ segments:
- [0xB548, .data, tile_data] # tile data
- [0xBD48, .data, tile_data] # tile definitions
- [0x10168, .data, sprites]
- [0x1171C, .rodata, 11A64]
- [0x1171C, .rodata, 11E34]
- [0x11728, .rodata, succubus] # EntitySuccubus
- [0x11808, .rodata, cutscene]
- [0x1181C, .rodata, cutscene] #D_80180938, names
@ -85,8 +85,10 @@ segments:
- [0x11A14, .rodata, e_misc]
- [0x11A28, .rodata, 20734] # EntityStageNamePopup
- [0x11A5C, .rodata, prim_helpers]
- [0x11A64, c]
- [0x11A64, c, succubus]
- [0x11A64, c, st_debug]
- [0x11D00, c, e_breakable]
- [0x11E34, c]
- [0x12104, c, succubus]
- [0x14774, c, cutscene]
- [0x161DC, c]
- [0x1697C, c]

View File

@ -39,6 +39,8 @@ segments:
subsegments:
- [0x0, .data, header]
- [0xB8, data]
- [0x5B4, .data, st_debug]
- [0x634, data]
- [0x6B4, .data, st_update]
- [0x6DC, .data, collision]
- [0x9D4, .data, e_red_door]
@ -82,6 +84,8 @@ segments:
- [0xD8AC, rodata]
- [0xD8C0, .rodata, prim_helpers]
- [0xD8C8, c]
- [0xE5AC, c, st_debug]
- [0xE830, c, e_breakable]
- [0xE964, c, st_update]
- [0xEDB8, c, collision]
- [0x10544, c, create_entity]

View File

@ -67,7 +67,8 @@ segments:
- [0x3AF0, data]
- [0x3B30, data]
- [0x3B50, .data, e_bone_scimitar]
- [0x3C44, data]
- [0x3C44, .data, e_bat]
- [0x3C7C, data]
- [0x3CC4, .data, rooms]
- [0x3DC8, .data, e_layout] # layout entries data
- [0x4CE0, .data, cutscene_data]
@ -104,7 +105,7 @@ segments:
- [0x37738, .rodata, e_merman2]
- [0x3775C, .rodata, 53F38]
- [0x37784, .rodata, e_bone_scimitar]
- [0x377A4, .rodata, 56264] # EntityBat
- [0x377A4, .rodata, e_bat] # EntityBat
- [0x377B8, .rodata, 564B0] # EntityZombie
- [0x377CC, .rodata, prim_helpers]
- [0x377D4, c]
@ -130,7 +131,7 @@ segments:
- [0x516B4, c, e_merman2]
- [0x53F38, c]
- [0x559d0, c, e_bone_scimitar]
- [0x56264, c]
- [0x56264, c, e_bat]
- [0x564B0, c]
- [0x56880, c, prim_helpers]
- [0x570B0, .bss, create_entity]

View File

@ -58,7 +58,8 @@ segments:
- [0x2400, data]
- [0x2440, data]
- [0x2460, .data, e_bone_scimitar]
- [0x2554, data]
- [0x2554, .data, e_bat]
- [0x258C, data]
- [0x25D4, .data, e_bloody_zombie]
- [0x26CC, data]
- [0x2720, data]
@ -91,7 +92,7 @@ segments:
- [0x32020, .rodata, e_merman2] # EntityMerman2
- [0x32044, .rodata, 48238] # EntityMerman
- [0x3206C, .rodata, e_bone_scimitar] # EntityBoneScimitar data
- [0x3208C, .rodata, 4997C] # EntityBat
- [0x3208C, .rodata, e_bat] # EntityBat
- [0x320A0, .rodata, 49BC8] # EntityZombie
- [0x320B4, .rodata, e_bloody_zombie] # EntityBloodyZombie data
- [0x320DC, .rodata, 4B018] # Shared charal string for owl and owl knight
@ -126,7 +127,7 @@ segments:
- [0x44DCC, c, e_merman2] # Merman Entities
- [0x48238, c] # Merman Entities (2)
- [0x490E8, c, e_bone_scimitar] # EntityBoneScimitar
- [0x4997C, c]
- [0x4997C, c, e_bat]
- [0x49BC8, c]
- [0x49F98, c, e_bloody_zombie] # EntityBloodyZombie
- [0x4B018, c]

View File

@ -5,6 +5,7 @@ MAD_pStObjLayoutVertical = 0x801803C8;
MAD_EntityUpdates = 0x8018049C;
g_EInitBreakable = 0x801804F0;
g_EInitUnkId13 = 0x8018052C;
g_EInitUnkId12 = 0x80180538;
g_EInitCommon = 0x80180544;
g_EInitDamageNum = 0x80180550;
g_eBreakableAnimations = 0x80180644;
@ -36,6 +37,7 @@ g_pStrObjLayout18 = 0x80181AF8;
g_pStrObjLayout19 = 0x80181BA2;
g_pStrObjLayout20 = 0x80181C4C;
g_pStrObjLayout21 = 0x80181CF6;
EntityUnkId12 = 0x8018E674;
EntityBreakable = 0x8018E830;
EntityDamageDisplay = 0x8018FEA0;
EntityRedDoor = 0x80191120;

View File

@ -5,6 +5,7 @@ g_EInitObtainable = 0x80180464;
g_EInitParticle = 0x80180470;
g_EInitInteractable = 0x80180488;
g_EInitUnkId13 = 0x80180494;
g_EInitUnkId12 = 0x801804A0;
g_EInitCommon = 0x801804AC;
g_EInitDamageNum = 0x801804B8;
DRE_RedDoorTiles = 0x80180550;
@ -19,6 +20,7 @@ g_ESoulStealOrbAngles = 0x8018138C;
g_ESoulStealOrbSprt = 0x8018139C;
g_ESoulStealOrbAnim = 0x801813FC;
EntityUnkId11 = 0x80191A64;
EntityUnkId12 = 0x80191B44;
EntityBreakable = 0x80191D00;
EntityBackgroundClouds = 0x80191E34;
EntitySuccubus = 0x80192104;

View File

@ -13,6 +13,7 @@ g_EInitWaterObject = 0x80180B48;
g_EInitWaterSplash = 0x80180B54;
g_EInitBoneScimitar = 0x80180B78;
g_EInitScimitarParts = 0x80180B84;
g_EInitBat = 0x80180B90;
NO3_RedDoorTiles = 0x80180DA0;
g_eBreakableAnimations = 0x80180E50;
g_eBreakableHitboxes = 0x80180E70;
@ -102,7 +103,7 @@ NO3_EntityCutscene = 0x801BEEB0;
EntityRoomTransition2 = 0x801BFF00;
EntityDeathStolenItem = 0x801C033C;
EntityDeath = 0x801C083C;
EntityUnkId5B = 0x801C11A4;
EntityDeathScythe = 0x801C11A4;
EntityDeathScytheShadow = 0x801C12E8;
CreateExplosionPuff = 0x801C13F8;
Random = 0x801C184C;

View File

@ -4,22 +4,15 @@
struct Entity;
typedef void (*PfnEntityUpdate)(struct Entity*);
// Placeholders for M2C to use. No code should be merged which uses them.
typedef union {
s16 s;
u16 u;
struct {
s8 unk0, unk1;
} S8;
struct {
u8 unk0, unk1;
} U8;
} Multi16;
struct Entity;
typedef struct ET_Generic {
/* 0x7C */ Multi16 unk7C; // posX
} ET_Generic;
u8 u8[0x3C];
s8 s8[0x3C];
u16 u16[0x1E];
s16 s16[0x1E];
u32 u32[0xF];
s32 s32[0xF];
} ET_Placeholder;
typedef struct {
/* 0x7C */ u16 timer;
@ -851,7 +844,7 @@ typedef struct {
} ET_EntitySlot16;
typedef struct {
/* 0x7C */ s16 unk7C;
/* 0x7C */ u16 unk7C;
} ET_Entity12;
typedef struct {
@ -865,6 +858,11 @@ typedef struct {
s16 t;
} ET_TimerOnly;
// silly unsigned alternative needed in ST0 EntityCutscene
typedef struct {
u16 t;
} ET_UTimerOnly;
typedef struct {
/* 0x7C */ s8 unk7C;
/* 0x7D */ s8 unk7D;
@ -1486,13 +1484,6 @@ typedef struct {
s16 unk84;
} ET_DracFinal;
// To be used for EntityEquipItemDrop and/or EntityPrizeDrop, when they are
// moved off of Generic.
typedef struct {
byte pad[0x18];
s32 unk94;
} ET_Drop;
typedef struct {
/* 0x7C */ byte pad[4];
/* 0x80 */ s16 angle;
@ -1841,11 +1832,12 @@ typedef struct {
} ET_Warg;
typedef struct {
/* 0x7C */ s32 : 32;
/* 0x7C */ u16 extStep;
/* 0x80 */ s32 : 32;
/* 0x84 */ u16 timer;
} ET_DeathScythe;
// A couple entities in MAD and ST0 which exist, but are not referenced
typedef struct {
/* 0x7C */ u8 animframe;
/* 0x7D */ s32 : 24;
@ -1901,16 +1893,24 @@ typedef struct {
s16 boolDidSound;
} ET_RicMaria;
// This is the Bat enemy, seen in the Entrance and elsewhere.
// ET_Bat is already taken by the familiar. Perhaps that should be
// ET_BatFam and this be ET_Bat? Seems familiars should all be labeled since
// there are fewer of those than there are enemies.
typedef struct {
s32 accelY;
} ET_BatEnemy;
// ====== RIC ENTITIES ======
// ==========================
typedef union { // offset=0x7C
struct Primitive* prim;
char stub[0x3C];
ET_Placeholder ILLEGAL;
ET_TimerOnly timer;
ET_UTimerOnly utimer;
ET_EntFactory factory;
ET_Generic generic;
ET_EntitySlot1 entSlot1; // g_Entities[1], not entityID 1
ET_EntitySlot16 entSlot16;
ET_Entity12 ent12; // entityID 12
@ -2021,7 +2021,6 @@ typedef union { // offset=0x7C
ET_SpittleBone spittleBone;
ET_Player player;
ET_801AF774 et_801AF774;
ET_Drop drop;
ET_BigRedFireball bigredfireball;
ET_SummonSpirit summonspirit;
ET_3DBackgroundhouse bghouse;
@ -2068,6 +2067,7 @@ typedef union { // offset=0x7C
ET_ExpandingCircle circleExpand;
ET_RicMariaPower ricMariaPower;
ET_RicMaria ricMaria;
ET_BatEnemy batEnemy;
} Ext;
#define SYNC_FIELD(struct1, struct2, field) \

View File

@ -2051,19 +2051,19 @@ void EntityGiantSpinningCross(Entity* self) {
func_8011A290(self);
self->hitboxHeight = 0x50;
self->hitboxWidth = 0xC;
self->facingLeft = 0;
self->posY.i.hi = 0x160;
self->velocityY = FIX(-6);
self->flags = FLAG_KEEP_ALIVE_OFFCAMERA | FLAG_HAS_PRIMS;
self->facingLeft = 0;
self->ext.giantcross.unk7C = 0;
self->ext.giantcross.unk7E = 0x400;
PlaySfx(SFX_FIREBALL_SHOT_B);
self->step++;
primUVCoords = &D_800B0F94[0][0];
prim = &g_PrimBuf[self->primIndex];
primUVCoords = &D_800B0F94[0][0];
for (i = 0; i < LEN(D_800B0CB4); i++, prim = prim->next,
primUVCoords += 5) {
prim->clut = (primUVCoords[4] & 0xF) | 0x1A0;
prim->clut = (primUVCoords[4] & 0xF) + 0x1A0;
switch (primUVCoords[4] & 0xF0) {
case 0x10:
prim->u0 = primUVCoords[0] + primUVCoords[2];
@ -2175,7 +2175,7 @@ void EntityGiantSpinningCross(Entity* self) {
gte_ldv0(&pos);
gte_rtps();
prim = &g_PrimBuf[self->primIndex];
vectors_ptr = &D_800B0CB4;
vectors_ptr = (SVECTOR**)&D_800B0CB4;
gte_stsxy2(&prim->x0);
gte_stszotz(&z);
self->hitboxOffX = prim->x0 - self->posX.i.hi;

View File

@ -584,7 +584,8 @@ void HitDetection(void) {
CreateEntityFromEntity(
3, iterEnt1, otherEntity);
}
otherEntity->ext.drop.unk94 = miscVar1;
otherEntity->ext.equipItemDrop.castleFlag =
miscVar1;
otherEntity->params = miscVar3;
// item pops up in the air a bit when spawned
otherEntity->velocityY = FIX(-3.5);

View File

@ -1,199 +0,0 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "dre.h"
#include "sfx.h"
// puts garbled hp max up text on screen
void EntityUnkId11(Entity* entity) {
ObjInit* obj = (ObjInit*)&D_80180528[entity->params * 10];
if (entity->step == 0) {
InitializeEntity(g_EInitCommon);
entity->animSet = obj->animSet;
entity->zPriority = obj->zPriority;
entity->unk5A = obj->unk5A;
entity->palette = obj->palette;
entity->drawFlags = obj->drawFlags;
entity->drawMode = obj->drawMode;
if (obj->unkC != 0) {
entity->flags = obj->unkC;
}
if (entity->params == 1) {
entity->rotY = 0x200;
entity->rotX = 0x200;
}
}
AnimateEntity(obj->animFrames, entity);
}
void func_80191B44(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->hitParams) {
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_80180590[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_801804A0);
entity->ext.generic.unk7C.s = D_80180588[temp_s1];
if (entity->ext.generic.unk7C.s != 0) {
entity->hitboxWidth = D_80180580[temp_s1];
entity->hitboxHeight = 16;
} else {
entity->hitboxWidth = 16;
entity->hitboxHeight = D_80180580[temp_s1];
}
}
}
extern u16 g_EInitBreakable[];
extern u8* g_eBreakableAnimations[];
extern u8 g_eBreakableHitboxes[];
extern u8 g_eBreakableExplosionTypes[];
extern u16 g_eBreakableanimSets[];
extern u8 g_eBreakableDrawModes[];
void EntityBreakable(Entity* entity) {
Entity* temp_v0;
u16 temp_s0 = entity->params >> 0xC;
if (entity->step != 0) {
AnimateEntity(g_eBreakableAnimations[temp_s0], entity);
if (entity->hitParams) {
g_api.PlaySfx(SFX_CANDLE_HIT);
temp_v0 = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (temp_v0 != NULL) {
CreateEntityFromCurrentEntity(E_EXPLOSION, temp_v0);
temp_v0->params = g_eBreakableExplosionTypes[temp_s0];
}
ReplaceBreakableWithItemDrop(entity);
}
} else {
InitializeEntity(g_EInitBreakable);
entity->zPriority = g_unkGraphicsStruct.g_zEntityCenter - 20;
entity->drawMode = g_eBreakableDrawModes[temp_s0];
entity->hitboxHeight = g_eBreakableHitboxes[temp_s0];
entity->animSet = g_eBreakableanimSets[temp_s0];
}
}
// clouds in the background ID 0x18
void EntityBackgroundClouds(Entity* self) {
Primitive* prim;
s16 primIndex;
s32 camX, camY;
switch (self->step) {
case 0:
InitializeEntity(g_EInitInteractable);
primIndex = g_api.AllocPrimitives(PRIM_GT4, 5);
if (primIndex == -1) {
DestroyEntity(self);
return;
}
prim = &g_PrimBuf[primIndex];
self->primIndex = primIndex;
self->ext.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
prim->type = PRIM_G4;
prim->x0 = prim->x2 = 0;
prim->x1 = prim->x3 = 0x100;
prim->y0 = prim->y1 = 0x6E - g_Tilemap.scrollY.i.hi;
prim->y2 = prim->y3 = 0xF0;
setRGB0(prim, 16, 16, 16);
prim->priority = 0x20;
prim->drawMode = DRAW_DEFAULT;
LOW(prim->r1) = LOW(prim->r0);
LOW(prim->r2) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r0);
prim = prim->next;
camX = -g_Tilemap.scrollX.i.hi;
camY = 32 - g_Tilemap.scrollY.i.hi;
while (prim != 0) {
prim->x0 = prim->x2 = camX;
camX += 95;
prim->x1 = prim->x3 = camX;
prim->tpage = 0xF;
prim->clut = 5;
prim->u0 = prim->u2 = 0x84;
prim->u1 = prim->u3 = 0xE3;
prim->v0 = prim->v1 = 1;
prim->v2 = prim->v3 = 0x4F;
prim->y0 = prim->y1 = camY;
prim->y2 = prim->y3 = camY + 0x4E;
prim->priority = 0x20;
prim->drawMode = DRAW_DEFAULT;
prim = prim->next;
}
break;
case 255:
/**
* Debug: Press SQUARE / CIRCLE on the second controller
* to advance/rewind current animation frame
*/
FntPrint("charal %x\n", self->animCurFrame);
if (g_pads[1].pressed & PAD_SQUARE) {
if (self->params == 0) {
self->animCurFrame++;
self->params |= 1;
} else {
break;
}
} else {
self->params = 0;
}
if (g_pads[1].pressed & PAD_CIRCLE) {
if (self->step_s == 0) {
self->animCurFrame--;
self->step_s |= 1;
}
} else {
self->step_s = 0;
}
break;
}
g_GpuBuffers[0].draw.r0 = 40;
g_GpuBuffers[0].draw.g0 = 24;
g_GpuBuffers[0].draw.b0 = 24;
g_GpuBuffers[1].draw.r0 = 40;
g_GpuBuffers[1].draw.g0 = 24;
g_GpuBuffers[1].draw.b0 = 24;
}

87
src/st/dre/11E34.c Normal file
View File

@ -0,0 +1,87 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "dre.h"
#include "sfx.h"
// clouds in the background ID 0x18
void EntityBackgroundClouds(Entity* self) {
Primitive* prim;
s16 primIndex;
s32 camX, camY;
switch (self->step) {
case 0:
InitializeEntity(g_EInitInteractable);
primIndex = g_api.AllocPrimitives(PRIM_GT4, 5);
if (primIndex == -1) {
DestroyEntity(self);
return;
}
prim = &g_PrimBuf[primIndex];
self->primIndex = primIndex;
self->ext.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
prim->type = PRIM_G4;
prim->x0 = prim->x2 = 0;
prim->x1 = prim->x3 = 0x100;
prim->y0 = prim->y1 = 0x6E - g_Tilemap.scrollY.i.hi;
prim->y2 = prim->y3 = 0xF0;
setRGB0(prim, 16, 16, 16);
prim->priority = 0x20;
prim->drawMode = DRAW_DEFAULT;
LOW(prim->r1) = LOW(prim->r0);
LOW(prim->r2) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r0);
prim = prim->next;
camX = -g_Tilemap.scrollX.i.hi;
camY = 32 - g_Tilemap.scrollY.i.hi;
while (prim != 0) {
prim->x0 = prim->x2 = camX;
camX += 95;
prim->x1 = prim->x3 = camX;
prim->tpage = 0xF;
prim->clut = 5;
prim->u0 = prim->u2 = 0x84;
prim->u1 = prim->u3 = 0xE3;
prim->v0 = prim->v1 = 1;
prim->v2 = prim->v3 = 0x4F;
prim->y0 = prim->y1 = camY;
prim->y2 = prim->y3 = camY + 0x4E;
prim->priority = 0x20;
prim->drawMode = DRAW_DEFAULT;
prim = prim->next;
}
break;
case 255:
/**
* Debug: Press SQUARE / CIRCLE on the second controller
* to advance/rewind current animation frame
*/
FntPrint("charal %x\n", self->animCurFrame);
if (g_pads[1].pressed & PAD_SQUARE) {
if (self->params == 0) {
self->animCurFrame++;
self->params |= 1;
} else {
break;
}
} else {
self->params = 0;
}
if (g_pads[1].pressed & PAD_CIRCLE) {
if (self->step_s == 0) {
self->animCurFrame--;
self->step_s |= 1;
}
} else {
self->step_s = 0;
}
break;
}
g_GpuBuffers[0].draw.r0 = 40;
g_GpuBuffers[0].draw.g0 = 24;
g_GpuBuffers[0].draw.b0 = 24;
g_GpuBuffers[1].draw.r0 = 40;
g_GpuBuffers[1].draw.g0 = 24;
g_GpuBuffers[1].draw.b0 = 24;
}

View File

@ -31,16 +31,16 @@ void EntityCSMoveAlucard(Entity* self) {
g_Player.padSim = 0;
g_Player.D_80072EFC = 1;
if (g_DemoMode != Demo_None) {
self->ext.generic.unk7C.s = 64;
self->ext.utimer.t = 64;
} else {
self->ext.generic.unk7C.s = 128;
self->ext.utimer.t = 128;
}
break;
case 1:
g_Player.padSim = 0;
if (self->ext.generic.unk7C.u != 0) {
self->ext.generic.unk7C.u--;
if (self->ext.utimer.t != 0) {
self->ext.utimer.t--;
}
if (g_Player.status & PLAYER_STATUS_TRANSFORM) {
if (g_Timer & 1) {
@ -52,7 +52,7 @@ void EntityCSMoveAlucard(Entity* self) {
g_Player.padSim = 2;
}
}
} else if (self->ext.generic.unk7C.u == 0) {
} else if (self->ext.utimer.t == 0) {
self->step++;
g_Player.padSim = 0x2000;
}

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "stage.h"
#define STAGE_DRE_H
#define STAGE_IS_DRE
#define OVL_EXPORT(x) DRE_##x
@ -58,7 +58,6 @@ void EntityGreyPuff(Entity* entity);
extern u16 g_EInitObtainable[];
extern u16 D_8018047C[];
extern u16 g_EInitInteractable[];
extern u16 D_801804A0[];
extern u16 D_801804D0[]; // EntitySuccubus
extern u16 D_801804DC[];
extern u16 D_80180500[];

12
src/st/dre/e_breakable.c Normal file
View File

@ -0,0 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "dre.h"
#include "sfx.h"
extern u16 g_EInitBreakable[];
extern u8* g_eBreakableAnimations[];
extern u8 g_eBreakableHitboxes[];
extern u8 g_eBreakableExplosionTypes[];
extern u16 g_eBreakableanimSets[];
extern u8 g_eBreakableDrawModes[];
#include "../e_breakable.h"

31
src/st/dre/st_debug.c Normal file
View File

@ -0,0 +1,31 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "dre.h"
#include "sfx.h"
// puts garbled hp max up text on screen
void EntityUnkId11(Entity* entity) {
ObjInit* obj = (ObjInit*)&D_80180528[entity->params * 10];
if (entity->step == 0) {
InitializeEntity(g_EInitCommon);
entity->animSet = obj->animSet;
entity->zPriority = obj->zPriority;
entity->unk5A = obj->unk5A;
entity->palette = obj->palette;
entity->drawFlags = obj->drawFlags;
entity->drawMode = obj->drawMode;
if (obj->unkC != 0) {
entity->flags = obj->unkC;
}
if (entity->params == 1) {
entity->rotY = 0x200;
entity->rotX = 0x200;
}
}
AnimateEntity(obj->animFrames, entity);
}
#include "../entity_unk_id12.h"

77
src/st/e_bat.h Normal file
View File

@ -0,0 +1,77 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
static u8 bat_anim_fly[] = {4, 21, 1, 22, 1, 23, 1, 30, 1, 24, 1, 25, 4, 26,
2, 27, 2, 28, 2, 29, 1, 30, 2, 23, 2, 22, 0, 0};
static u8 bat_anim_drop[] = {5, 31, 5, 32, 5, 31, 5, 32, 5, 31, 5, 32, 4, 31,
4, 32, 3, 31, 3, 32, 2, 31, 12, 32, 255, 0, 0, 0};
void EntityBat(Entity* self) {
Entity* newEntity;
s16 xDistance;
s16 yDistance;
if (self->flags & FLAG_DEAD) {
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEntity != NULL) {
CreateEntityFromEntity(E_EXPLOSION, self, newEntity);
newEntity->params = 1;
}
PlaySfxPositional(SFX_BAT_SCREECH_SWISH);
DestroyEntity(self);
return;
}
switch (self->step) {
case 0:
InitializeEntity(g_EInitBat);
self->animCurFrame = 31;
break;
case 1:
xDistance = GetDistanceToPlayerX();
yDistance = GetDistanceToPlayerY();
if ((xDistance < 0x60) && (yDistance < 0x60) &&
!(GetSideToPlayer() & 2)) {
self->step++;
}
break;
case 2:
if (AnimateEntity(bat_anim_drop, self) == 0) {
self->facingLeft = (GetSideToPlayer() & 1) ^ 1;
self->velocityY = FIX(0.875);
if (self->facingLeft) {
self->velocityX = FIX(0.25);
} else {
self->velocityX = FIX(-0.25);
}
self->animFrameIdx = (Random() & 3) * 3;
self->animFrameDuration = 0;
self->step++;
}
break;
case 3:
AnimateEntity(bat_anim_fly, self);
MoveEntity();
if (GetDistanceToPlayerY() < 0x20) {
if (self->facingLeft) {
self->velocityX = FIX(1);
} else {
self->velocityX = FIX(-1);
}
self->ext.batEnemy.accelY = 0x800;
self->step++;
}
break;
case 4:
AnimateEntity(bat_anim_fly, self);
MoveEntity();
if (self->velocityY < FIX(-1) || self->velocityY > FIX(1)) {
self->ext.batEnemy.accelY = -self->ext.batEnemy.accelY;
}
// accelY is already an s32, but psp needs the cast. I dunno.
self->velocityY += (s32)self->ext.batEnemy.accelY;
break;
}
}

View File

@ -18,20 +18,20 @@ static u16 g_EntityUnkId12TilemapProps[] = {
0x0000, 0x0000, 0x0500, 0x0400, 0x0000, 0x0000, 0x0500, 0x0400, 0x0000,
0x01FC, 0x0500, 0x02FC, 0x00F0, 0x01FC, 0x0310, 0x02FC, 0x00F0, 0x01FC,
0x0310, 0x02FC,
#if defined(STAGE_IS_NO3)
#if defined(STAGE_IS_NO3) || defined(STAGE_IS_DRE)
0x0104, 0x0204, 0x0000, 0x0000, 0x0004, 0x0004, 0x0000, 0x0000
#endif
};
extern u16 g_EInitUnkId12[];
void EntityUnkId12(Entity* entity) {
void EntityUnkId12(Entity* self) {
u16 var_s0;
u16 params;
u16* tilemapProps;
entity->unk6D[0] = 0;
params = entity->params;
if (entity->step) {
self->unk6D[0] = 0;
params = self->params;
if (self->step) {
switch (params) {
case 4:
case 5:
@ -43,15 +43,15 @@ void EntityUnkId12(Entity* entity) {
if (g_pads->pressed & PAD_TRIANGLE) {
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
entity->step++;
self->step++;
return;
}
break;
}
if (entity->hitParams) {
if (self->hitParams) {
var_s0 = GetSideToPlayer();
if (entity->ext.generic.unk7C.u) {
if (self->ext.ent12.unk7C) {
var_s0 &= 2;
var_s0 *= 2;
} else {
@ -67,13 +67,13 @@ void EntityUnkId12(Entity* entity) {
}
} else {
InitializeEntity(g_EInitUnkId12);
var_s0 = entity->ext.generic.unk7C.u = g_EntityUnkId12Data[params];
var_s0 = self->ext.ent12.unk7C = g_EntityUnkId12Data[params];
if (var_s0) {
entity->hitboxWidth = g_EntityUnkId12Hitbox[params];
entity->hitboxHeight = 16;
self->hitboxWidth = g_EntityUnkId12Hitbox[params];
self->hitboxHeight = 16;
} else {
entity->hitboxWidth = 16;
entity->hitboxHeight = g_EntityUnkId12Hitbox[params];
self->hitboxWidth = 16;
self->hitboxHeight = g_EntityUnkId12Hitbox[params];
}
}
}

View File

@ -414,10 +414,10 @@ static SVECTOR* doorColorNormalVectors[] = {
static u8 castleDoorUCoords[] = {
0x3A, 0x46, 0x01, 0x35, 0x35, 0x01, 0x00, 0x00};
static s16 castleDoorTilesOpen[] = {
static u16 castleDoorTilesOpen[] = {
0x06D1, 0x06D2, 0x06D3, 0x06D4, 0x06D5, 0x06D6, 0x06D3, 0x06D4,
};
static s16 castleDoorTilesShut[] = {
static u16 castleDoorTilesShut[] = {
0x010F, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x114, 0x116,
};

View File

@ -92,100 +92,3 @@ void func_8018E13C(u16* tilemap) {
void func_8018E1D4(void);
INCLUDE_ASM("asm/us/st/mad/nonmatchings/D8C8", func_8018E1D4);
void func_8018E5AC(Entity* self) {
s32 temp_v0;
ObjInit* objInit = &D_8018056C[self->params];
if (self->step == 0) {
InitializeEntity(g_EInitCommon);
self->animSet = objInit->animSet;
self->zPriority = objInit->zPriority;
self->unk5A = objInit->unk5A;
self->palette = objInit->palette;
self->drawFlags = objInit->drawFlags;
self->drawMode = objInit->drawMode;
temp_v0 = objInit->unkC;
if (temp_v0 != 0) {
self->flags = temp_v0;
}
}
AnimateEntity(objInit->animFrames, self);
}
void func_8018E674(Entity* self) {
u16 var_s0;
u16 params;
u16* tilemapProps;
self->unk6D[0] = 0;
params = self->params;
if (self->step) {
switch (params) {
case 4:
case 5:
if (g_Tilemap.x) {
return;
}
break;
case 6:
if (g_pads->pressed & PAD_TRIANGLE) {
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
self->step++;
return;
}
break;
}
if (self->hitParams) {
var_s0 = GetSideToPlayer();
if (self->ext.generic.unk7C.u) {
var_s0 &= 2;
var_s0 *= 2;
} else {
var_s0 &= 1;
var_s0 *= 4;
}
params = (params << 3) + var_s0;
tilemapProps = &D_801805C4[params];
g_Tilemap.x = *tilemapProps++;
g_Tilemap.y = *tilemapProps++;
g_Tilemap.width = *tilemapProps++;
g_Tilemap.height = *tilemapProps;
}
} else {
InitializeEntity(D_80180538);
var_s0 = self->ext.timer.t = D_801805BC[params];
if (var_s0) {
self->hitboxWidth = D_801805B4[params];
self->hitboxHeight = 16;
return;
}
self->hitboxWidth = 16;
self->hitboxHeight = D_801805B4[params];
}
}
void EntityBreakable(Entity* entity) {
u16 breakableType = entity->params >> 0xC;
if (entity->step) {
AnimateEntity(g_eBreakableAnimations[breakableType], entity);
if (entity->hitParams) { // If the candle is destroyed
Entity* entityDropItem;
g_api.PlaySfx(SFX_CANDLE_HIT);
entityDropItem = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (entityDropItem != NULL) {
CreateEntityFromCurrentEntity(E_EXPLOSION, entityDropItem);
entityDropItem->params =
g_eBreakableExplosionTypes[breakableType];
}
ReplaceBreakableWithItemDrop(entity);
}
} else {
InitializeEntity(g_EInitBreakable);
entity->zPriority = g_unkGraphicsStruct.g_zEntityCenter - 0x14;
entity->drawMode = g_eBreakableDrawModes[breakableType];
entity->hitboxHeight = g_eBreakableHitboxes[breakableType];
entity->animSet = g_eBreakableanimSets[breakableType];
}
}

5
src/st/mad/e_breakable.c Normal file
View File

@ -0,0 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "mad.h"
#include "sfx.h"
#include "../e_breakable.h"

25
src/st/mad/st_debug.c Normal file
View File

@ -0,0 +1,25 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "mad.h"
#include "sfx.h"
void func_8018E5AC(Entity* self) {
s32 temp_v0;
ObjInit* objInit = &D_8018056C[self->params];
if (self->step == 0) {
InitializeEntity(g_EInitCommon);
self->animSet = objInit->animSet;
self->zPriority = objInit->zPriority;
self->unk5A = objInit->unk5A;
self->palette = objInit->palette;
self->drawFlags = objInit->drawFlags;
self->drawMode = objInit->drawMode;
temp_v0 = objInit->unkC;
if (temp_v0 != 0) {
self->flags = temp_v0;
}
}
AnimateEntity(objInit->animFrames, self);
}
#include "../entity_unk_id12.h"

View File

@ -32,13 +32,13 @@ void EntityFlyingOwlAndLeaves(Entity* entity) {
case 1:
if (entity->posX.i.hi < 224) {
entity->ext.generic.unk7C.s = 0;
entity->ext.timer.t = 0;
entity->step++;
}
break;
case 2:
if (!(entity->ext.generic.unk7C.s++ & 7)) {
if (!(entity->ext.timer.t++ & 7)) {
g_api.PlaySfx(SE_TREE_BRANCH);
}
if (entity->posX.i.hi < 192) {

View File

@ -243,7 +243,7 @@ void EntityDeathStolenItem(Entity* self) {
}
void EntityDeath(Entity* self) {
Entity* newEntity = &self[1];
Entity* newEntity = self + 1;
Primitive* prim;
s16 left, right;
s32 primIndex;
@ -301,7 +301,7 @@ void EntityDeath(Entity* self) {
self->ext.death.unk7C = 0;
self->flags |= FLAG_HAS_PRIMS;
DestroyEntity(newEntity);
CreateEntityFromCurrentEntity(E_DEATH_5B, newEntity);
CreateEntityFromCurrentEntity(E_DEATH_SCYTHE, newEntity);
prim = &g_PrimBuf[primIndex];
for (i = 0; prim != NULL; i++) {
@ -562,46 +562,51 @@ void EntityDeath(Entity* self) {
}
}
void EntityUnkId5B(Entity* entity) {
Entity* newEntity;
// Not 100% sure about this entity, but since it's making scythe shadows,
// going to guess it's the scythe.
void EntityDeathScythe(Entity* self) {
u16 tempstep;
// this is Death.
Entity* otherEntity = self - 1;
self->posX.i.hi = otherEntity->posX.i.hi;
self->posY.i.hi = otherEntity->posY.i.hi;
entity->posX.i.hi = entity[-1].posX.i.hi;
entity->posY.i.hi = entity[-1].posY.i.hi;
switch (entity->step) {
switch (self->step) {
case 0:
InitializeEntity(g_EInitCommon);
entity->animSet = ANIMSET_OVL(8);
entity->palette = 0x2D6;
entity->animCurFrame = 0;
entity->unk5A = 0x44;
self->animSet = ANIMSET_OVL(8);
self->animCurFrame = 0;
self->palette = 0x2D6;
self->unk5A = 0x44;
break;
case 1:
if (entity->ext.generic.unk7C.u != 0) {
switch (entity->ext.generic.unk7C.u) {
tempstep = self->ext.deathScythe.extStep;
if (tempstep) {
switch (tempstep) {
case 1:
AnimateEntity(D_80181B40, entity);
AnimateEntity(D_80181B40, self);
break;
case 2:
AnimateEntity(D_80181B4C, entity);
AnimateEntity(D_80181B4C, self);
break;
case 3:
AnimateEntity(D_80181B4C, entity);
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEntity == NULL) {
AnimateEntity(D_80181B4C, self);
otherEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (otherEntity == NULL) {
break;
}
CreateEntityFromCurrentEntity(E_DEATH_SCYTHE_SHADOW, newEntity);
newEntity->animCurFrame = entity->animCurFrame;
newEntity->params = 1;
CreateEntityFromCurrentEntity(
E_DEATH_SCYTHE_SHADOW, otherEntity);
otherEntity->animCurFrame = self->animCurFrame;
otherEntity->params = 1;
break;
}
} else {
entity->animCurFrame = 0;
self->animCurFrame = 0;
}
}
entity->ext.generic.unk7C.s = 0;
self->ext.deathScythe.extStep = 0;
}
// When meeting Death, the scythe spins around, leaving behind semi-transparent

View File

@ -1,75 +0,0 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "no3.h"
#include "sfx.h"
void EntityBat(Entity* entity) {
Entity* newEntity;
s16 xDistance;
s16 yDistance;
if (entity->flags & FLAG_DEAD) {
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEntity != NULL) {
CreateEntityFromEntity(E_EXPLOSION, entity, newEntity);
newEntity->params = 1;
}
PlaySfxPositional(SFX_BAT_SCREECH_SWISH);
DestroyEntity(entity);
return;
}
switch (entity->step) {
case 0:
InitializeEntity(D_80180B90);
entity->animCurFrame = 31;
break;
case 1:
xDistance = GetDistanceToPlayerX();
yDistance = GetDistanceToPlayerY();
if ((xDistance < 0x60) && (yDistance < 0x60) &&
!(GetSideToPlayer() & 2)) {
entity->step++;
}
break;
case 2:
if (AnimateEntity(D_80183C60, entity) == 0) {
entity->facingLeft = (GetSideToPlayer() & 1) ^ 1;
entity->velocityY = FIX(0.875);
if (entity->facingLeft != 0) {
entity->velocityX = FIX(0.25);
} else {
entity->velocityX = FIX(-0.25);
}
entity->animFrameIdx = (Random() & 3) * 3;
entity->animFrameDuration = 0;
entity->step++;
}
break;
case 3:
AnimateEntity(D_80183C44, entity);
MoveEntity();
if (GetDistanceToPlayerY() < 0x20) {
if (entity->facingLeft == 0) {
entity->velocityX = FIX(-1);
} else {
entity->velocityX = FIX(1);
}
*(s32*)&entity->ext.generic.unk7C.s = 0x800;
entity->step++;
}
break;
case 4:
AnimateEntity(D_80183C44, entity);
MoveEntity();
if ((u32)(entity->velocityY + 0x10000) > 0x20000U) {
*(s32*)&entity->ext.generic.unk7C.s =
(s32) - *(s32*)&entity->ext.generic.unk7C.s;
}
entity->velocityY += *(s32*)&entity->ext.generic.unk7C.u;
break;
}
}

4
src/st/no3/e_bat.c Normal file
View File

@ -0,0 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "no3.h"
#include "../e_bat.h"

View File

@ -91,7 +91,7 @@ void NO3_EntityCutscene(Entity* self);
void EntityRoomTransition2(Entity* self);
void EntityDeathStolenItem(Entity* self);
void EntityDeath(Entity* self);
void EntityUnkId5B(Entity* self);
void EntityDeathScythe(Entity* self);
void EntityStairwayPiece(Entity* self);
void EntityFallingRock(Entity* self);
void EntityDeathScytheShadow(Entity* self);
@ -191,7 +191,7 @@ PfnEntityUpdate OVL_EXPORT(EntityUpdates)[] = {
EntityRoomTransition2,
EntityDeathStolenItem,
EntityDeath,
EntityUnkId5B,
EntityDeathScythe,
EntityStairwayPiece,
EntityFallingRock,
EntityDeathScytheShadow,

View File

@ -78,7 +78,7 @@ typedef enum EntityIDs {
/* 0x4B */ E_ID_4B = 0x4B,
/* 0x4C */ E_ZOMBIE,
/* 0x59 */ E_ID_59 = 0x59,
/* 0x5B */ E_DEATH_5B = 0x5B,
/* 0x5B */ E_DEATH_SCYTHE = 0x5B,
/* 0x5D */ E_FALLING_ROCK = 0x5D,
/* 0x5E */ E_DEATH_SCYTHE_SHADOW,
/* 0x60 */ E_FLYING_OWL_UNK60 = 0x60,
@ -111,7 +111,7 @@ extern u16 D_80180B30[];
extern u16 g_EInitWaterObject[];
extern u16 g_EInitWaterSplash[];
extern u16 D_80180B6C[];
extern u16 D_80180B90[];
extern u16 g_EInitBat[];
extern u16 D_80180BA8[];
extern ObjInit2 D_80180BFC[];
extern u8 D_80180DC0[];

View File

@ -1,74 +0,0 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "np3.h"
#include "sfx.h"
void EntityBat(Entity* entity) {
Entity* newEntity;
s16 xDistance;
s16 yDistance;
if (entity->flags & FLAG_DEAD) {
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEntity != NULL) {
CreateEntityFromEntity(E_EXPLOSION, entity, newEntity);
newEntity->params = 1;
}
PlaySfxPositional(SFX_BAT_SCREECH_SWISH);
DestroyEntity(entity);
return;
}
switch (entity->step) {
case 0:
InitializeEntity(g_EInitBat);
entity->animCurFrame = 31;
break;
case 1:
xDistance = GetDistanceToPlayerX();
yDistance = GetDistanceToPlayerY();
if ((xDistance < 96) && (yDistance < 96) && !(GetSideToPlayer() & 2)) {
entity->step++;
}
break;
case 2:
if (AnimateEntity(D_80182570, entity) == 0) {
entity->facingLeft = (GetSideToPlayer() & 1) ^ 1;
entity->velocityY = FIX(0.875);
if (entity->facingLeft != 0) {
entity->velocityX = FIX(0.25);
} else {
entity->velocityX = FIX(-0.25);
}
entity->animFrameIdx = (Random() & 3) * 3;
entity->animFrameDuration = 0;
entity->step++;
}
break;
case 3:
AnimateEntity(D_80182554, entity);
MoveEntity();
if (GetDistanceToPlayerY() < 0x20) {
if (entity->facingLeft == 0) {
entity->velocityX = FIX(-1);
} else {
entity->velocityX = FIX(1);
}
*(s32*)&entity->ext.generic.unk7C.s = 0x800;
entity->step++;
}
break;
case 4:
AnimateEntity(D_80182554, entity);
MoveEntity();
if ((u32)(entity->velocityY + 0x10000) > 0x20000U) {
*(s32*)&entity->ext.generic.unk7C.s =
(s32) - *(s32*)&entity->ext.generic.unk7C.s;
}
entity->velocityY += *(s32*)&entity->ext.generic.unk7C.u;
break;
}
}

4
src/st/np3/e_bat.c Normal file
View File

@ -0,0 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "np3.h"
#include "../e_bat.h"

View File

@ -112,7 +112,6 @@ extern u16 g_EInitMerman[];
extern u16 g_EInitMermanFireball[];
extern u16 D_80180AF0[];
extern u16 g_EInitBat[];
extern u16 g_EInitBat[];
extern u16 g_EInitZombie[];
extern u16 D_80180B20[];
extern u16 g_EInitSlograSpearNP3[];
@ -221,8 +220,6 @@ extern u8 D_80182414[];
extern s32 D_80182440[];
extern u8 D_80182454[];
extern u16 D_80182458[];
extern u8 D_80182554[];
extern u8 D_80182570[];
extern u8 D_8018258C[];
extern u8 D_80182594[];
extern u8 D_801825A8[];

View File

@ -1002,9 +1002,9 @@ void EntityFloorButton(Entity* self) {
if ((self->ext.nz0311c0.unk80 + 4) < posY) {
self->posY.i.hi =
(self->ext.nz0311c0.unk80 + 4) - g_Tilemap.scrollY.i.hi;
self[1].ext.stub[0xC] = 1;
(self + 1)->ext.nz0311c0.unk88 = 1;
self->step++;
LOW(self[1].ext.stub[0x8]) ^= 1;
(self + 1)->ext.nz0311c0.unk84 ^= 1;
}
}

View File

@ -187,7 +187,7 @@ void func_801A8328(Entity* self) {
if (firstPrimIndex != -1) {
prim = &g_PrimBuf[firstPrimIndex];
self->primIndex = firstPrimIndex;
LOW(self->ext.generic.unk7C.s) = prim;
self->ext.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
UnkPolyFunc2(prim);
prim->tpage = 0x16;
@ -218,7 +218,7 @@ void func_801A8328(Entity* self) {
case 1:
MoveEntity();
prim = LOW(self->ext.generic.unk7C.s);
prim = self->ext.prim;
self->velocityY += FIX(0.125);
prim->next->x1 = self->posX.i.hi;
prim->next->y0 = self->posY.i.hi;

View File

@ -23,7 +23,7 @@ void EntityCutscene(Entity* self) {
self->posY.i.hi = player->posY.i.hi - 1;
if ((self->step != 14) && g_SkipCutscene && g_IsCutsceneDone &&
(self->step >= 5)) {
(self->step > 4)) {
self->step = 15;
self->animSet = ANIMSET_DRA(0);
self->animCurFrame = 0;
@ -37,8 +37,8 @@ void EntityCutscene(Entity* self) {
break;
case 1:
if (self->step_s != 0) {
if ((player->step < 3) || (player->step == 25)) {
if (self->step_s) {
if ((player->step <= 2) || (player->step == 25)) {
posX = player->posX.i.hi + tilemap->scrollX.i.hi;
if (posX > 0x8000) {
posX = 0;
@ -48,7 +48,7 @@ void EntityCutscene(Entity* self) {
} else {
g_Player.padSim = PAD_RIGHT;
}
g_Entities[1].ext.generic.unk7C.S8.unk0 = 1;
g_Entities[1].ext.entSlot1.unk0 = 1;
g_Player.D_80072EFC = 0xFF;
func_801AA218(posX);
SetStep(2);
@ -67,11 +67,11 @@ void EntityCutscene(Entity* self) {
posX = 0;
}
if ((g_Player.padSim == 0x8000) && (posX <= 0xA0) ||
(g_Player.padSim == 0x2000) && (posX >= 0x9F)) {
if ((g_Player.padSim == PAD_LEFT) && (posX <= 0xA0) ||
(g_Player.padSim == PAD_RIGHT) && (posX >= 0x9F)) {
g_Player.D_80072EFC = 1;
g_Player.padSim = PAD_LEFT;
self->ext.generic.unk7C.s = 0x18;
self->ext.utimer.t = 0x18;
g_CutsceneFlags |= 1;
self->step++;
}
@ -86,7 +86,7 @@ void EntityCutscene(Entity* self) {
func_801AA218(posX);
g_Player.D_80072EFC = 1;
g_Player.padSim = 0;
if (!--self->ext.generic.unk7C.u) {
if (!--self->ext.utimer.t) {
SetStep(4);
}
break;

View File

@ -705,6 +705,7 @@ u32 func_801ABBBC(s32 step, Entity* dracula) {
return step;
}
// This function is not called from anywhere. Don't know what it's for.
s32 func_801AC458(s16 arg0) {
s32 ret = arg0;
Entity* e;
@ -728,7 +729,8 @@ s32 func_801AC458(s16 arg0) {
ret++;
}
if (e2->animFrameIdx == 6 && e2->animFrameDuration == 0) {
g_CurrentEntity->ext.stub[0x24] = 1;
// Using dracula ext since this function is right after dracula.
g_CurrentEntity->ext.dracula.unkA0 = 1;
}
break;

View File

@ -160,8 +160,6 @@ extern u32 D_80181CF0[];
extern s8 D_801A7B7C;
extern Point32 D_801BEB64[];
extern s32 D_801C2578;
extern u32 g_CutsceneFlags;
extern s32 D_801C2578;
// *** EntityDracula properties END ***
@ -177,9 +175,7 @@ extern u8 D_801824CC[];
extern s8 D_801A7BDC;
extern Point32 D_801BEB64[];
extern s32 g_SkipCutscene;
extern s32 D_801C2578;
extern s32 g_IsCutsceneDone;
// *** EntitySoulStealOrb properties START ***

View File

@ -1,4 +1,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// Notably, this is completely unused.
// The use of the 0xBB offset in the entity, which does not match the current
// entity struct, suggests that this was for an older form of Entity.
// When the Entity was changed, this function was already unused, so was never
// updated. This is just a theory though.
#define SELF_BB (*((u8*)&self->unkB8 + 3))
u8 UnkAnimFunc(u8 frames[], Entity* self, u8 arg2) {
u16 animFrameStart = self->animFrameIdx * 2;
u8* var_s1 = &frames[animFrameStart];
@ -9,7 +18,7 @@ u8 UnkAnimFunc(u8 frames[], Entity* self, u8 arg2) {
if (*var_s1 == 0xFF) {
return 0;
}
self->animFrameDuration = *var_s1++ + (u8)self->ext.stub[0x3F];
self->animFrameDuration = *var_s1++ + SELF_BB;
self->animCurFrame = *var_s1++;
self->animFrameIdx++;
var_a1 = 128;
@ -17,8 +26,8 @@ u8 UnkAnimFunc(u8 frames[], Entity* self, u8 arg2) {
var_s1 = frames;
self->animFrameIdx = 0;
self->animFrameDuration = 0;
self->ext.stub[0x3F] = (arg2 * Random()) >> 8;
self->animFrameDuration = *var_s1++ + (u8)self->ext.stub[0x3F];
SELF_BB = (arg2 * Random()) >> 8;
self->animFrameDuration = *var_s1++ + SELF_BB;
self->animCurFrame = *var_s1;
self->animFrameIdx++;
return 0;

View File

@ -117,7 +117,7 @@ s32 func_ptr_80170004(Entity* self) {
self->flags = FLAG_POS_CAMERA_LOCKED;
self->palette = self->ext.weapon.parent->palette;
self->unk5A = self->ext.weapon.parent->unk5A;
self->ext.generic.unk7C.s = 10;
self->ext.timer.t = 10;
self->drawMode = DRAW_TPAGE;
self->drawFlags = FLAG_DRAW_UNK8;
self->unk6C = 0x80;
@ -127,7 +127,7 @@ s32 func_ptr_80170004(Entity* self) {
self->unk6C += 0xF8;
}
if (--self->ext.generic.unk7C.s == 0) {
if (--self->ext.timer.t == 0) {
DestroyEntity(self);
}
}