Decompile DRA EntitySummonSpirit (#1264)

This one is a nice surprise to get working! DRA is really getting slim
now.
This commit is contained in:
bismurphy 2024-06-05 16:48:32 -04:00 committed by GitHub
parent bc884aa3d9
commit 9a0ccbe43b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 132 additions and 3 deletions

View File

@ -64,6 +64,7 @@ D_800B07C8 = 0x800B088C;
D_800B0830 = 0x800B08F4;
D_800B083C = 0x800B0900;
D_800B0858 = 0x800B091C;
D_800B0860 = 0x800B0924;
D_800B08CC = 0x800B0990;
D_800B0914 = 0x800B09D8;
D_800B0918 = 0x800B09DC;
@ -408,6 +409,7 @@ D_8013808C = 0x80137C58;
D_80138094 = 0x80137C60;
D_8013839C = 0x80137F68;
D_8013841C = 0x80137FE8;
D_80138424 = 0x80137FF0;
D_8013842C = 0x80137FF8;
D_80138430 = 0x80137FFC;
D_80138438 = 0x80138004;

View File

@ -1,4 +1,5 @@
g_CheatCodes = 0x800A300C;
D_800B0860 = 0x800B0860;
aPbav = 0x800B107C;
aPbav_0 = 0x800B407C;
aPbav_2 = 0x800B607C;
@ -51,7 +52,6 @@ EntitySubwpnThrownAxe = 0x80125330;
EntityHolyWaterBreakGlass = 0x80125E68;
EntitySubwpnCrashCross = 0x801267B0;
EntityHellfireHandler = 0x80126ECC;
EntitySummonSpirit = 0x8012A0A4;
EntityStopWatch = 0x8012A89C;
EntityBatEcho = 0x8012BEF8;
CdSoundCommand4 = 0x80132F60;

View File

@ -1006,6 +1006,11 @@ typedef struct {
/* 0x85 */ u8 speed;
} ET_BigRedFireball;
typedef struct {
s16 timer;
s16 spawnTimer;
} ET_SummonSpirit;
typedef union { // offset=0x7C
struct Primitive* prim;
char stub[0x40];
@ -1100,4 +1105,5 @@ typedef union { // offset=0x7C
ET_801AF774 et_801AF774;
ET_Drop drop;
ET_BigRedFireball bigredfireball;
ET_SummonSpirit summonspirit;
} Ext;

View File

@ -86,6 +86,7 @@ typedef struct Prim {
#define DRAW_TPAGE 0x10 // use custom tpage
#define DRAW_TPAGE2 0x20 // use custom tpage
#define DRAW_MENU 0x80 // render only if D_800973EC is set
#define DRAW_UNK_100 0x100 // unknown
#define DRAW_UNK_400 0x400 // unknown
#define DRAW_UNK_800 0x800 // unknown
#define DRAW_UNK_1000 0x1000 // unknown

View File

@ -1994,7 +1994,124 @@ void EntityAguneaHitEnemy(Entity* self) {
INCLUDE_ASM("dra/nonmatchings/843B0", func_80129864);
// opens hole in backround and spirit comes out (ID 0x40)
INCLUDE_ASM("dra/nonmatchings/843B0", EntitySummonSpirit);
void EntitySummonSpirit(Entity* self) {
Primitive* prim;
s32 timer;
s32 selfX;
s32 selfY;
s32 i;
switch (self->step) {
case 0:
self->flags = FLAG_UNK_08000000 | FLAG_UNK_04000000 | FLAG_UNK_20000 |
FLAG_UNK_10000;
g_unkGraphicsStruct.unk20 = 3;
self->ext.summonspirit.spawnTimer = 10;
func_80118C28(13);
self->step++;
return;
case 1:
if (--self->ext.summonspirit.spawnTimer) {
return;
}
self->primIndex = AllocPrimitives(4, 9);
if (self->primIndex == -1) {
DestroyEntity(self);
return;
}
self->posX.i.hi = 0x80;
self->posY.i.hi = 0x60;
if (PLAYER.posY.i.hi - 0x30 > 0x40) {
self->posY.i.hi = PLAYER.posY.i.hi - 0x30;
} else {
self->posY.i.hi = PLAYER.posY.i.hi + 0x40;
}
selfX = self->posX.i.hi;
selfY = self->posY.i.hi;
prim = &g_PrimBuf[self->primIndex];
prim->type = 3;
prim->drawMode = 0x102;
prim->x2 = prim->x0 = selfX - 0x20;
prim->x3 = prim->x1 = selfX + 0x1F;
prim->y1 = prim->y0 = selfY - 0x20;
prim->y2 = prim->y3 = selfY + 0x1F;
D_80138424.x = prim->x0;
if (g_CurrentBuffer->disp.disp.x == 0) {
D_80138424.x += 0x100;
}
D_80138424.y = prim->y0;
D_80138424.w = 0x3F;
D_80138424.h = 0x3F;
MoveImage(&D_80138424, 0x200, 0x1C0);
prim->priority = 0x1C0;
prim = prim->next;
for (i = 0; i < 8; i++) {
// These should have been Point16 :(
prim->x1 = selfX + D_800B0860[(i + 1) * 2];
prim->y1 = selfY + D_800B0860[(i + 1) * 2 + 1];
prim->x3 = selfX + D_800B0860[i * 2];
prim->y3 = selfY + D_800B0860[i * 2 + 1];
prim->u1 = D_800B0860[(i + 1) * 2] + 0x20;
prim->v1 = D_800B0860[(i + 1) * 2 + 1] + 0xE0;
prim->u3 = D_800B0860[i * 2] + 0x20;
prim->v3 = D_800B0860[i * 2 + 1] + 0xE0;
prim->u0 = prim->u2 = 0x20;
prim->v0 = prim->v2 = 0xE0;
prim->priority = 0x1C1;
if (i >= 4) {
prim->priority += 3;
}
prim->drawMode = DRAW_UNK_100 | DRAW_UNK02;
prim->tpage = 0x118;
prim = prim->next;
}
self->ext.summonspirit.timer = 0;
// This just adds FLAG_HAS_PRIMS. Not sure why it wasn't an |=.
self->flags = FLAG_UNK_08000000 | FLAG_UNK_04000000 | FLAG_HAS_PRIMS |
FLAG_UNK_20000 | FLAG_UNK_10000;
self->step++;
break;
case 2:
self->ext.summonspirit.timer++;
if (self->ext.summonspirit.timer > 10) {
// Both blueprints have child 61, but 118 has a couple 4s in the
// other args. 61 is func_80129864. Not yet decompiled.
if (self->params) {
CreateEntFactoryFromEntity(self, FACTORY(0, 118), 0);
} else {
CreateEntFactoryFromEntity(self, FACTORY(0, 116), 0);
}
// Blueprint 44 is child 11. EntityPlayerBlinkWhite
CreateEntFactoryFromEntity(self, FACTORY(0x6700, 44), 0);
PlaySfx(0x67D);
self->step++;
}
break;
case 3:
self->ext.summonspirit.timer--;
if (self->ext.summonspirit.timer < 0) {
g_unkGraphicsStruct.unk20 = 0;
DestroyEntity(self);
return;
}
break;
}
timer = self->ext.summonspirit.timer;
selfX = self->posX.i.hi;
selfY = self->posY.i.hi;
prim = &g_PrimBuf[self->primIndex];
prim = prim->next;
for (i = 0; i < 8; i++) {
prim->x2 = selfX + (((rcos(i << 9) >> 4) * timer) >> 8);
prim->y2 = selfY - (((rsin(i << 9) >> 4) * timer) >> 8);
prim->x0 = selfX + (((rcos((i + 1) << 9) >> 4) * timer) >> 8);
prim->y0 = selfY - (((rsin((i + 1) << 9) >> 4) * timer) >> 8);
prim = prim->next;
}
}
// expanding circle effect when activating stopwatch
void EntityStopWatchExpandingCircle(Entity* self) {

View File

@ -423,6 +423,7 @@ extern AnimationFrame D_800B0798[];
extern s32 D_800B07C8;
extern s32 D_800B0830[];
extern s32 D_800B083C[];
extern s16 D_800B0860[];
extern unk_800B08CC D_800B08CC[];
extern s32 D_800B0914;
extern s32 D_800B0918;
@ -633,6 +634,7 @@ extern s32 D_8013808C;
extern Unkstruct_80138094 D_80138094[];
extern Point16 D_8013839C[];
extern s32 D_8013841C;
extern RECT D_80138424;
extern s32 D_8013842C;
extern s32 D_80138430;
extern s32 D_80138438;

View File

@ -170,6 +170,7 @@ s16 D_800ACF94[16]; // guessed size
u8 D_800ACFB4[20][4]; // TODO AnimationFrames*[], random size
s32 D_800B0830[99]; // random size to play safe
s32 D_800B083C[99]; // random size to play safe
s16 D_800B0860[99]; // random size to play safe
AnimationFrame D_800B0798[40]; // random size to play safe
u8 D_800B0F94[100][5]; // random size to play safe
SVECTOR stubbbbbbbb = {0};
@ -540,6 +541,7 @@ s32 g_CdCommandStatus;
const char* D_80138784[0x800];
s32 D_8013B65C;
s32 D_8013841C;
RECT D_80138424;
s32 D_8013842C;
s32 D_80138430;
s32 D_80138438;
@ -617,4 +619,3 @@ void func_80123B40(Entity* self) { NOT_IMPLEMENTED; }
void EntityBatEcho(Entity* self) { NOT_IMPLEMENTED; }
void func_8012F894(Entity* self) { NOT_IMPLEMENTED; }
void func_80129864(Entity* self) { NOT_IMPLEMENTED; }
void EntitySummonSpirit(Entity* self) { NOT_IMPLEMENTED; }