Skip to content

Commit

Permalink
Merge branch 'master' into Decompile/no1/func_us_801BF3F4
Browse files Browse the repository at this point in the history
  • Loading branch information
gamezter authored Jan 14, 2025
2 parents 7c13586 + 7b9069a commit ff10670
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,11 @@ typedef struct {
/* 0x80 */ s32 unk80;
} ET_801C10F4;

typedef struct {
/* 0x7C */ struct Primitive* unk7C;
/* 0x80 */ SVECTOR unk80;
} ET_801BFB40;

typedef struct {
/* 0x7C */ u8 unk7C;
/* 0x7D */ u8 : 8;
Expand Down Expand Up @@ -2675,6 +2680,7 @@ typedef union { // offset=0x7C
ET_SpearGuard spearGuard;
ET_SpearGuardUnk spearGuardUnk;
ET_801BF3F4 et_801BF3F4;
ET_801BFB40 et_801BFB40;
} Ext;

#define SYNC_FIELD(struct1, struct2, field) \
Expand Down
2 changes: 2 additions & 0 deletions src/st/no1/no1.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ typedef enum EntityIDs {
/* 0x22 */ E_AXE_KNIGHT_AXE_2, // func_us_801CBA30
/* 0x23 */ E_UNK_ENTITY, // InitializeUnkEntity
/* 0x2A */ E_ID_2A = 0x2A,
/* 0x2F */ E_ID_2F = 0x2F,
/* 0x31 */ E_ID_31 = 0x31,
/* 0x3E */ E_SKELETON = 0x3E,
/* 0x3F */ E_SKELETON_THROWN_BONE,
/* 0x40 */ E_SKELETON_PIECES,
Expand Down
225 changes: 222 additions & 3 deletions src/st/no1/unk_3FA34.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "no1.h"

extern u16 g_EInitParticle;
extern u16 g_EInitParticle[];

void func_us_801BFA34(Entity* self) {
if (self->step == 0) {
InitializeEntity(&g_EInitParticle);
InitializeEntity(g_EInitParticle);
self->palette = PAL_OVL(0x19E);
self->animSet = 2;
self->animCurFrame = 9;
Expand All @@ -32,7 +32,226 @@ void func_us_801BFA34(Entity* self) {
}
}

INCLUDE_ASM("st/no1/nonmatchings/unk_3FA34", func_us_801BFB40);
extern SVEC4 D_us_80181778[];
extern SVEC4 D_us_801817D8[];
extern SVEC4 D_us_801818C0[];
extern MATRIX D_us_80181920;
extern u32 D_psp_0929A6E8;
extern u32 D_psp_0929A6F8;

void func_us_801BFB40(Entity* self) {
long sxy2, sxy3, p;
Collider collider;
SVECTOR rot;
VECTOR trans;
MATRIX m;
u8 pad[16];
MATRIX lightMatrix;
CVECTOR color;
u8 pad2[2];
Primitive* prim;
Entity* tempEntity;
SVEC4* positions;
SVEC4* normals;
s32 primIndex;
s16 posX, posY;
s32 i;
s32 opz;

switch (self->step) {
case 0:
InitializeEntity(g_EInitParticle);
primIndex = g_api.AllocPrimitives(PRIM_GT4, 6);
if (primIndex != -1) {
self->flags |= FLAG_HAS_PRIMS;
self->primIndex = primIndex;
prim = &g_PrimBuf[primIndex];
self->ext.et_801BFB40.unk7C = prim;
while (prim != NULL) {
prim->tpage = 0xE;
prim->clut = 0;
prim->u0 = 0xE9;
prim->u1 = prim->u0 + 0xE;
prim->u2 = prim->u0;
prim->u3 = prim->u1;
prim->v0 = 0x31;
prim->v1 = prim->v0;
prim->v2 = prim->v0 + 0xE;
prim->v3 = prim->v2;
prim->r0 = prim->b0 = prim->g0 = 0x80;
LOW(prim->r1) = LOW(prim->r0);
LOW(prim->r2) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r0);
if (self->params) {
prim->priority = 0xC0;
} else {
prim->priority = 0xA0;
}
prim->drawMode = DRAW_UNK02;
prim = prim->next;
}
return;
}
DestroyEntity(self);
return;
case 1:
switch (self->step_s) {
case 0:
self->velocityX = FIX(1.0 / 16);
self->velocityY = 0;
self->step_s++;
if (self->params) {
self->velocityX = -(Random() & 7) * FIX(0.125);
self->velocityY = FIX(-2.25) - (Random() & 3) * FIX(0.25);
}
break;
case 1:
if (!self->params) {
self->ext.et_801BFB40.unk80.vx += 0x40;
self->ext.et_801BFB40.unk80.vy -= 0x10;
self->ext.et_801BFB40.unk80.vz -= 0x10;
} else {
self->ext.et_801BFB40.unk80.vx += 0x40;
self->ext.et_801BFB40.unk80.vy += 0x80;
self->ext.et_801BFB40.unk80.vz -= 0x20;
}
MoveEntity();
self->velocityY += FIX(0.125);
if (!self->params) {
if (self->velocityX > FIX(-1.5)) {
self->velocityX -= FIX(0.25 / 16);
}
}
posX = self->posX.i.hi;
posY = self->posY.i.hi;
if (!self->params) {
posY += 8;
} else {
posY += 4;
}
g_api.CheckCollision(posX, posY, &collider, 0);
if (!self->params && (self->velocityX > FIX(-1.0)) &&
(collider.effects & EFFECT_SOLID)) {
if ((g_Timer & 7) == 0) {
self->posY.i.hi += collider.unk18;
}
self->velocityY = 0;
self->ext.et_801BFB40.unk80.vx = 0;
self->ext.et_801BFB40.unk80.vy = 0;
self->ext.et_801BFB40.unk80.vz = 0;
} else if (collider.effects & EFFECT_SOLID) {
g_api.PlaySfx(SFX_STOMP_HARD_B);
self->posY.i.hi += collider.unk18;
self->velocityY = -self->velocityY / 2;
if (self->params) {
if (self->velocityY > FIX(-0.25)) {
tempEntity =
AllocEntity(&g_Entities[64], &g_Entities[256]);
if (tempEntity != NULL) {
CreateEntityFromEntity(
E_INTENSE_EXPLOSION, self, tempEntity);
tempEntity->params = 0x10;
}
DestroyEntity(self);
return;
}
} else {
for (i = 0; i < 4; i++) {
tempEntity =
AllocEntity(&g_Entities[64], &g_Entities[256]);
if (tempEntity != NULL) {
#ifdef VERSION_PSP
CreateEntityFromEntity(
D_psp_0929A6F8, self, tempEntity);
#else
CreateEntityFromEntity(E_ID_2F, self, tempEntity);
#endif
tempEntity->params = i;
}
}
if (self->velocityY > FIX(-1.25)) {
g_api.PlaySfx(SFX_WALL_DEBRIS_B);
for (i = 0; i < 3; i++) {
tempEntity =
AllocEntity(&g_Entities[64], &g_Entities[256]);
if (tempEntity != NULL) {
#ifdef VERSION_PSP
CreateEntityFromEntity(
D_psp_0929A6E8, self, tempEntity);
#else
CreateEntityFromEntity(
E_ID_31, self, tempEntity);
#endif
tempEntity->params = i + 1;
}
}
DestroyEntity(self);
return;
}
}
}
break;
}
prim = self->ext.et_801BFB40.unk7C;
SetGeomScreen(0x400);
rot.vx = self->ext.et_801BFB40.unk80.vx;
rot.vy = self->ext.et_801BFB40.unk80.vy;
rot.vz = self->ext.et_801BFB40.unk80.vz;
RotMatrix(&rot, &m);
trans.vx = 0;
trans.vy = 0;
trans.vz = 0x408;
if (self->params) {
trans.vz = 0x800;
}
TransMatrix(&m, &trans);
SetRotMatrix(&m);
SetTransMatrix(&m);
if (!self->params) {
color.r = 0xA0;
color.g = 0xA0;
color.b = 0xA0;
color.cd = prim->type;
} else {
color.r = 0x90;
color.g = 0x90;
color.b = 0x90;
color.cd = prim->type;
}
RotMatrix(&rot, &lightMatrix);
SetBackColor(0x40, 0x40, 0x40);
SetLightMatrix(&lightMatrix);
SetColorMatrix(&D_us_80181920);
SetFarColor(0x60, 0x60, 0x60);
SetGeomOffset(self->posX.i.hi, self->posY.i.hi);
if (!self->params) {
positions = D_us_801817D8;
} else {
positions = D_us_80181778;
}
normals = D_us_801818C0;
prim = self->ext.et_801BFB40.unk7C;
for (i = 0; i < 6; i++) {
opz = RotAverageNclip4(
positions->v0, positions->v1, positions->v2, positions->v3,
(long*)(&prim->x0), (long*)(&prim->x1), (long*)(&prim->x2),
(long*)(&prim->x3), &sxy2, &p, &sxy3);
if (opz <= 0) {
prim->drawMode = DRAW_HIDE;
} else {
prim->drawMode = DRAW_COLORS | DRAW_UNK02;
NormalColorCol(normals->v0, &color, (CVECTOR*)(&prim->r0));
NormalColorCol(normals->v1, &color, (CVECTOR*)(&prim->r1));
NormalColorCol(normals->v2, &color, (CVECTOR*)(&prim->r2));
NormalColorCol(normals->v3, &color, (CVECTOR*)(&prim->r3));
}
positions++;
normals++;
prim = prim->next;
}
break;
}
}

INCLUDE_ASM("st/no1/nonmatchings/unk_3FA34", func_us_801C01F0);

Expand Down
4 changes: 2 additions & 2 deletions src/st/st0/3AB08.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ void EntityCutscenePhotograph(Entity* self) {
} else {
dualFlag = 1;
}
otherEnt = AllocEntity(self, (Entity*)&g_EvHwCardEnd);
otherEnt = AllocEntity(self, &g_Entities[256]);
if (otherEnt != NULL) {
CreateEntityFromCurrentEntity(E_ID_2D, otherEnt);
otherEnt->posX.i.hi = newEntX;
Expand All @@ -658,7 +658,7 @@ void EntityCutscenePhotograph(Entity* self) {
otherEnt->params = 0;
}

otherEnt = AllocEntity(self, (Entity*)&g_EvHwCardEnd);
otherEnt = AllocEntity(self, &g_Entities[256]);
if (otherEnt != NULL) {
CreateEntityFromCurrentEntity(E_ID_2D, otherEnt);
otherEnt->posX.i.hi = newEntX;
Expand Down

0 comments on commit ff10670

Please sign in to comment.