mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-23 21:19:55 +00:00
Decompile RIC func_80167A70 (#989)
As noted in the comment, I don't know what this actually is and how it corresponds to DRA, but hopefully the comment will help track it down in the future. In the entity extension, this function just has a timer at offset 7C. The gravity boot beam entity had the same. I decided to create an extension called TimerOnly to handle these multiple entities that just have a timer there. I think finding patterns like these in the entities will be nice to try to slim down entity.h.
This commit is contained in:
parent
6837cbfedc
commit
f0cc19e766
@ -499,8 +499,8 @@ typedef struct {
|
|||||||
} ET_Entity16;
|
} ET_Entity16;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
s16 timer;
|
s16 t;
|
||||||
} ET_GravBootsBeam;
|
} ET_TimerOnly;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x7C */ s16 unk7C;
|
/* 0x7C */ s16 unk7C;
|
||||||
@ -712,11 +712,11 @@ typedef struct {
|
|||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
/* 0x7C */ struct Primitive* prim;
|
/* 0x7C */ struct Primitive* prim;
|
||||||
|
/* 0x7C */ ET_TimerOnly timer;
|
||||||
/* 0x7C */ ET_EntFactory factory;
|
/* 0x7C */ ET_EntFactory factory;
|
||||||
/* 0x7C */ ET_Generic generic;
|
/* 0x7C */ ET_Generic generic;
|
||||||
/* 0x7C */ ET_EntitySlot1 entSlot1; // g_Entities[1], not entityID 1
|
/* 0x7C */ ET_EntitySlot1 entSlot1; // g_Entities[1], not entityID 1
|
||||||
/* 0x7C */ ET_Entity16 ent16;
|
/* 0x7C */ ET_Entity16 ent16;
|
||||||
/* 0x7C */ ET_GravBootsBeam bootBeam;
|
|
||||||
/* 0x7C */ ET_8011E4BC et_8011E4BC;
|
/* 0x7C */ ET_8011E4BC et_8011E4BC;
|
||||||
/* 0x7C */ ET_HellfireHandler hellfireHandler;
|
/* 0x7C */ ET_HellfireHandler hellfireHandler;
|
||||||
/* 0x7C */ ET_ReboundStone reboundStone;
|
/* 0x7C */ ET_ReboundStone reboundStone;
|
||||||
|
@ -601,7 +601,7 @@ void EntityGravityBootBeam(Entity* self) {
|
|||||||
switch (self->step) {
|
switch (self->step) {
|
||||||
case 0:
|
case 0:
|
||||||
self->posY.i.hi = PLAYER.posY.i.hi + 37;
|
self->posY.i.hi = PLAYER.posY.i.hi + 37;
|
||||||
self->ext.bootBeam.timer = 1536;
|
self->ext.timer.t = 1536;
|
||||||
self->primIndex = func_800EDB58(PRIM_G4_ALT, 4);
|
self->primIndex = func_800EDB58(PRIM_G4_ALT, 4);
|
||||||
if (self->primIndex == -1) {
|
if (self->primIndex == -1) {
|
||||||
DestroyEntity(self);
|
DestroyEntity(self);
|
||||||
@ -634,10 +634,10 @@ void EntityGravityBootBeam(Entity* self) {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// note that with the fallthrough these decrements stack
|
// note that with the fallthrough these decrements stack
|
||||||
self->ext.bootBeam.timer -= 160;
|
self->ext.timer.t -= 160;
|
||||||
case 2:
|
case 2:
|
||||||
self->ext.bootBeam.timer -= 96;
|
self->ext.timer.t -= 96;
|
||||||
if (self->ext.bootBeam.timer < 0) {
|
if (self->ext.timer.t < 0) {
|
||||||
DestroyEntity(self);
|
DestroyEntity(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -646,7 +646,7 @@ void EntityGravityBootBeam(Entity* self) {
|
|||||||
for (i = 0, prim = &g_PrimBuf[self->primIndex]; prim != NULL; i++,
|
for (i = 0, prim = &g_PrimBuf[self->primIndex]; prim != NULL; i++,
|
||||||
prim = prim->next) {
|
prim = prim->next) {
|
||||||
// As timer counts down, beam gets narrower.
|
// As timer counts down, beam gets narrower.
|
||||||
halfWidth = (self->ext.bootBeam.timer >> 8) - i;
|
halfWidth = (self->ext.timer.t >> 8) - i;
|
||||||
if (halfWidth << 16 < 0) {
|
if (halfWidth << 16 < 0) {
|
||||||
halfWidth = 0;
|
halfWidth = 0;
|
||||||
}
|
}
|
||||||
|
101
src/ric/26C84.c
101
src/ric/26C84.c
@ -856,7 +856,106 @@ void func_80167A60(Entity* self) {}
|
|||||||
|
|
||||||
void func_80167A68(Entity* self) {}
|
void func_80167A68(Entity* self) {}
|
||||||
|
|
||||||
INCLUDE_ASM("ric/nonmatchings/26C84", func_80167A70);
|
// Entity ID #35. Created by blueprint 40. No known FACTORY calls with
|
||||||
|
// blueprint 40. No known DRA match.
|
||||||
|
void func_80167A70(Entity* self) {
|
||||||
|
s16_pair sp10[8];
|
||||||
|
Primitive* prim;
|
||||||
|
FakePrim* fakeprim;
|
||||||
|
s32 velX;
|
||||||
|
s32 i;
|
||||||
|
u16 posY;
|
||||||
|
u16 posX;
|
||||||
|
u8 arrIndex;
|
||||||
|
u8 randbit;
|
||||||
|
|
||||||
|
switch (self->step) {
|
||||||
|
case 0:
|
||||||
|
self->primIndex = g_api.AllocPrimitives(PRIM_GT4, 16);
|
||||||
|
if (self->primIndex == -1) {
|
||||||
|
DestroyEntity(self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prim = &g_PrimBuf[self->primIndex];
|
||||||
|
posX = self->posX.i.hi;
|
||||||
|
posY = self->posY.i.hi;
|
||||||
|
for (i = 0; prim != NULL; i++, prim = prim->next) {
|
||||||
|
if (i < 8) {
|
||||||
|
fakeprim = (FakePrim*)prim;
|
||||||
|
fakeprim->x0 = posX;
|
||||||
|
fakeprim->posX.i.hi = posX;
|
||||||
|
sp10[i].unk0 = posX;
|
||||||
|
fakeprim->y0 = posY;
|
||||||
|
fakeprim->posY.i.hi = posY;
|
||||||
|
sp10[i].unk2 = posY;
|
||||||
|
// Random velocity from 0.25 to 0.5
|
||||||
|
velX = (rand() & 0x3FFF) + FIX(0.25);
|
||||||
|
fakeprim->velocityX = velX;
|
||||||
|
if (i & 1) {
|
||||||
|
fakeprim->velocityX = -velX;
|
||||||
|
}
|
||||||
|
fakeprim->velocityY = -((rand() * 2) + FIX(2.5));
|
||||||
|
fakeprim->blendMode = 0xA;
|
||||||
|
fakeprim->type = 1;
|
||||||
|
} else {
|
||||||
|
prim->r0 = prim->r1 = prim->r2 = prim->r3 =
|
||||||
|
(rand() & 0xF) | 0x30;
|
||||||
|
prim->b0 = prim->b1 = prim->b2 = prim->b3 = rand() | 0x80;
|
||||||
|
prim->g0 = prim->g1 = prim->g2 = prim->g3 =
|
||||||
|
(rand() & 0x1F) + 0x30;
|
||||||
|
randbit = rand() & 1;
|
||||||
|
prim->blendMode = !(randbit) ? 6 : 0x37;
|
||||||
|
posX = sp10[i - 8].unk0;
|
||||||
|
posY = sp10[i - 8].unk2;
|
||||||
|
arrIndex = i & 3;
|
||||||
|
prim->u0 = arrIndex;
|
||||||
|
prim->x0 = posX + D_80155D64[arrIndex][0];
|
||||||
|
prim->y0 = posY + D_80155D64[arrIndex][1];
|
||||||
|
prim->x1 = posX + D_80155D64[arrIndex][2];
|
||||||
|
prim->y1 = posY + D_80155D64[arrIndex][3];
|
||||||
|
prim->x3 = prim->x2 = posX + D_80155D64[arrIndex][4];
|
||||||
|
prim->y3 = prim->y2 = posY + D_80155D64[arrIndex][5];
|
||||||
|
prim->type = 3;
|
||||||
|
prim->priority = PLAYER.zPriority + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self->flags = FLAG_UNK_08000000 | FLAG_HAS_PRIMS;
|
||||||
|
self->ext.timer.t = 20;
|
||||||
|
self->step++;
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (--self->ext.timer.t == 0) {
|
||||||
|
DestroyEntity(self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prim = &g_PrimBuf[self->primIndex];
|
||||||
|
for (i = 0; prim != NULL; i++, prim = prim->next) {
|
||||||
|
if (i < 8) {
|
||||||
|
fakeprim = (FakePrim*)prim;
|
||||||
|
fakeprim->posX.i.hi = fakeprim->x0;
|
||||||
|
fakeprim->posY.i.hi = fakeprim->y0;
|
||||||
|
fakeprim->posX.val += fakeprim->velocityX.val;
|
||||||
|
fakeprim->posY.val += fakeprim->velocityY.val;
|
||||||
|
fakeprim->velocityY.val += FIX(36.0 / 128);
|
||||||
|
sp10[i].unk0 = fakeprim->posX.i.hi;
|
||||||
|
sp10[i].unk2 = fakeprim->posY.i.hi;
|
||||||
|
fakeprim->x0 = fakeprim->posX.i.hi;
|
||||||
|
fakeprim->y0 = fakeprim->posY.i.hi;
|
||||||
|
} else {
|
||||||
|
posX = sp10[i - 8].unk0;
|
||||||
|
posY = sp10[i - 8].unk2;
|
||||||
|
arrIndex = prim->u0;
|
||||||
|
prim->x0 = posX + D_80155D64[arrIndex][0];
|
||||||
|
prim->y0 = posY + D_80155D64[arrIndex][1];
|
||||||
|
prim->x1 = posX + D_80155D64[arrIndex][2];
|
||||||
|
prim->y1 = posY + D_80155D64[arrIndex][3];
|
||||||
|
prim->x3 = prim->x2 = posX + D_80155D64[arrIndex][4];
|
||||||
|
prim->y3 = prim->y2 = posY + D_80155D64[arrIndex][5];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
INCLUDE_ASM("ric/nonmatchings/26C84", func_80167EC4);
|
INCLUDE_ASM("ric/nonmatchings/26C84", func_80167EC4);
|
||||||
|
|
||||||
|
@ -243,6 +243,7 @@ extern s16 D_80155CF4[];
|
|||||||
extern s16 D_80155D08[];
|
extern s16 D_80155D08[];
|
||||||
extern s16 D_80155D1C[];
|
extern s16 D_80155D1C[];
|
||||||
extern s16 D_80155D30;
|
extern s16 D_80155D30;
|
||||||
|
extern s16 D_80155D64[4][6];
|
||||||
extern s16 D_80155E68[];
|
extern s16 D_80155E68[];
|
||||||
extern AnimationFrame* D_80155EA8;
|
extern AnimationFrame* D_80155EA8;
|
||||||
extern s16 D_80155EF0[];
|
extern s16 D_80155EF0[];
|
||||||
|
Loading…
Reference in New Issue
Block a user