NP3 NO3 EntityShuttingWindow (#460)

This commit is contained in:
Alejandro Asenjo Nitti 2023-08-11 02:29:32 -03:00 committed by GitHub
parent 06afe4f9ba
commit ebe5b67cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 200 additions and 3 deletions

View File

@ -287,6 +287,13 @@ typedef struct ET_801B2F30 {
/* 0x84 */ s16 unk84;
} ET_801B2F30;
typedef struct {
/* 0x7C */ struct Primitive* prim;
/* 0x80 */ s16 unk80; // angle?
/* 0x82 */ s16 unk82;
/* 0x84 */ s16 timer;
} ET_ShuttingWindow;
typedef union {
/* 0x7C */ struct Primitive* prim;
/* 0x7C */ ET_Generic generic;
@ -305,6 +312,7 @@ typedef union {
/* 0x7C */ ET_RoomTransition2 roomTransition2;
/* 0x7C */ ET_801B3C38 et38;
/* 0x7C */ ET_801BCC4C et_801BCC4C;
/* 0x7C */ ET_ShuttingWindow shuttingWindow;
/* 0x7C */ ET_801B2F30 et_801B2F30;
/* 0x7C */ char stub[0x40];
} Ext;

View File

@ -257,4 +257,7 @@ typedef enum { MONO_SOUND, STEREO_SOUND } soundMode;
#define NA_VO_SU_CRYSTAL_1 0x87C
#define NA_VO_SU_SUCK_YOU_DRY 0x876
#define NA_VO_SU_NO_SCREAM 0x87B
#define NA_VO_SU_DELICIOUS 0x8D1
#define NA_VO_SU_DELICIOUS 0x8D1
// STAGE NO3 / NP3
#define NA_SE_EV_WINDOW_LATCH 0x79D

View File

@ -85,7 +85,99 @@ void EntityUnkId16(Entity* self) {
INCLUDE_ASM("asm/us/st/no3/nonmatchings/377D4", EntityBackgroundLightning);
// window that opens and shuts in the background
INCLUDE_ASM("asm/us/st/no3/nonmatchings/377D4", EntityShuttingWindow);
void EntityShuttingWindow(Entity* self) {
Primitive* prim;
s16 primIndex;
SVECTOR svec;
SVEC4* svec4;
VECTOR vec;
MATRIX mtx;
s32 flag;
s32 p;
s32 i;
switch (self->step) {
case 0:
InitializeEntity(D_80180AC4);
primIndex = g_api.AllocPrimitives(PRIM_GT4, 2);
if (primIndex == -1) {
DestroyEntity(self);
return;
}
prim = &g_PrimBuf[primIndex];
self->primIndex = primIndex;
self->ext.shuttingWindow.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
while (prim != NULL) {
prim->tpage = 0xF;
prim->clut = 0xD;
prim->u0 = prim->u2 = 0x9C;
prim->u1 = prim->u3 = 0x84;
prim->v1 = 4;
prim->v0 = 4;
prim->v2 = prim->v3 = 0x7C;
prim->priority = 0x5F;
prim->blendMode = 2;
prim = prim->next;
}
case 1:
self->ext.shuttingWindow.unk80 += 8;
if (self->ext.shuttingWindow.unk80 > 0x300) {
self->ext.shuttingWindow.unk80 = 0x300;
self->ext.shuttingWindow.unk82 = 0;
self->step++;
}
break;
case 2:
self->ext.shuttingWindow.unk80 += self->ext.shuttingWindow.unk82;
self->ext.shuttingWindow.unk82 -= 4;
if (self->ext.shuttingWindow.unk80 < 0) {
func_801CAD28(NA_SE_EV_WINDOW_LATCH);
self->ext.shuttingWindow.unk80 = 0;
self->ext.shuttingWindow.timer = 32;
self->step++;
}
break;
case 3:
if (--self->ext.shuttingWindow.timer == 0) {
self->step = 1;
}
break;
}
SetGeomScreen(0x400);
SetGeomOffset(self->posX.i.hi, self->posY.i.hi);
svec4 = D_80181024;
prim = self->ext.shuttingWindow.prim;
for (i = 0; i < 2; svec4++, i++) {
svec.vx = 0;
if (i != 0) {
svec.vy = self->ext.shuttingWindow.unk80;
} else {
svec.vy = -self->ext.shuttingWindow.unk80;
}
svec.vz = 0;
RotMatrix(&svec, &mtx);
if (i == 0) {
vec.vx = -0x18;
} else {
vec.vx = 0x19;
}
vec.vy = 0;
vec.vz = 0x400;
TransMatrix(&mtx, &vec);
SetRotMatrix(&mtx);
SetTransMatrix(&mtx);
RotTransPers4(svec4->v0, svec4->v1, svec4->v2, svec4->v3,
(long*)&prim->x0, (long*)&prim->x1, (long*)&prim->x2,
(long*)&prim->x3, (long*)&p, (long*)&flag);
prim = prim->next;
}
}
// main door to the castle that closes during intro
INCLUDE_ASM("asm/us/st/no3/nonmatchings/377D4", EntityCastleDoor);

View File

@ -45,6 +45,7 @@ extern u16 D_80180B84[];
extern u16 D_80180B90[];
extern u16 D_80180BA8[];
extern ObjInit2 D_80180BFC[];
extern SVEC4 D_80181024[];
extern u16 D_80181230[];
extern s32 g_TrapDoorFlag; // 0 = Closed, 1 = Open
extern u8 D_80181240[];

View File

@ -130,7 +130,99 @@ void func_801B2830(Entity* self) {
INCLUDE_ASM("asm/us/st/np3/nonmatchings/3246C", func_801B28E4);
INCLUDE_ASM("asm/us/st/np3/nonmatchings/3246C", EntityShuttingWindow);
void EntityShuttingWindow(Entity* self) {
Primitive* prim;
s16 primIndex;
SVECTOR svec;
SVEC4* svec4;
VECTOR vec;
MATRIX mtx;
s32 flag;
s32 p;
s32 i;
switch (self->step) {
case 0:
InitializeEntity(D_80180A54);
primIndex = g_api.AllocPrimitives(PRIM_GT4, 2);
if (primIndex == -1) {
DestroyEntity(self);
return;
}
prim = &g_PrimBuf[primIndex];
self->primIndex = primIndex;
self->ext.shuttingWindow.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
while (prim != NULL) {
prim->tpage = 0xF;
prim->clut = 0xD;
prim->u0 = prim->u2 = 0x9C;
prim->u1 = prim->u3 = 0x84;
prim->v1 = 4;
prim->v0 = 4;
prim->v2 = prim->v3 = 0x7C;
prim->priority = 0x5F;
prim->blendMode = 2;
prim = prim->next;
}
case 1:
self->ext.shuttingWindow.unk80 += 8;
if (self->ext.shuttingWindow.unk80 > 0x300) {
self->ext.shuttingWindow.unk80 = 0x300;
self->ext.shuttingWindow.unk82 = 0;
self->step++;
}
break;
case 2:
self->ext.shuttingWindow.unk80 += self->ext.shuttingWindow.unk82;
self->ext.shuttingWindow.unk82 -= 4;
if (self->ext.shuttingWindow.unk80 < 0) {
func_801C2598(NA_SE_EV_WINDOW_LATCH);
self->ext.shuttingWindow.unk80 = 0;
self->ext.shuttingWindow.timer = 32;
self->step++;
}
break;
case 3:
if (--self->ext.shuttingWindow.timer == 0) {
self->step = 1;
}
break;
}
SetGeomScreen(0x400);
SetGeomOffset(self->posX.i.hi, self->posY.i.hi);
svec4 = D_80180EEC;
prim = self->ext.shuttingWindow.prim;
for (i = 0; i < 2; svec4++, i++) {
svec.vx = 0;
if (i != 0) {
svec.vy = self->ext.shuttingWindow.unk80;
} else {
svec.vy = -self->ext.shuttingWindow.unk80;
}
svec.vz = 0;
RotMatrix(&svec, &mtx);
if (i == 0) {
vec.vx = -0x18;
} else {
vec.vx = 0x19;
}
vec.vy = 0;
vec.vz = 0x400;
TransMatrix(&mtx, &vec);
SetRotMatrix(&mtx);
SetTransMatrix(&mtx);
RotTransPers4(svec4->v0, svec4->v1, svec4->v2, svec4->v3,
(long*)&prim->x0, (long*)&prim->x1, (long*)&prim->x2,
(long*)&prim->x3, (long*)&p, (long*)&flag);
prim = prim->next;
}
}
// Entity ID: 0x19
void func_801B2F30(Entity* self) {

View File

@ -81,6 +81,7 @@ extern ObjInit2 D_80180C10[];
extern u8 D_80180D98[];
extern u8 D_80180DA0[];
extern u16 D_80180DA8[];
extern SVEC4 D_80180EEC[];
extern SVEC4 D_80180F6C;
extern MATRIX D_80180F9C;
extern SVECTOR* D_80180FD4[];