Decompile RIC EntityEntFactory (#912)

Found this function in RIC, it's very similar to the one in DRA, which
is nice.

Patterns of zeros in the rodata indicated that this should be the start
of a new file, which also makes sense since CreateEntFactoryFromEntity
comes with it.

RIC has its own array of blueprints, I'll probably add that to the splat
later on but that seems like material for a separate PR. For now we
focus on the entity function.
This commit is contained in:
bismurphy 2023-12-29 20:09:52 -05:00 committed by GitHub
parent abad025e80
commit 65a9a413bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 501 additions and 347 deletions

View File

@ -46,7 +46,8 @@ segments:
- [0x1A800, .rodata, 20920]
- [0x1A80C, .rodata, 21250]
- [0x1A904, .rodata, 22380]
- [0x1A918, rodata]
- [0x1A918, .rodata, 24788]
- [0x1A968, rodata]
- [0x1A9D0, .rodata, 26C84]
- [0x1A9E8, rodata]
- [0x1AB04, rodata]
@ -61,6 +62,7 @@ segments:
- [0x20920, c, 20920]
- [0x21250, c, 21250]
- [0x22380, c, 22380]
- [0x24788, c, 24788]
- [0x26C84, c, 26C84]
- [0x32324, c, 32324]
- [0x345EC, c, 345EC]

View File

@ -1,4 +1,5 @@
g_richter_spritesheet = 0x8013C020;
g_RicFactoryBlueprints = 0x80154A6C;
DestroyEntity = 0x80156C60;
GetTeleportToOtherCastle = 0x80156CCC;
CheckBladeDashInput = 0x80157894;
@ -6,9 +7,8 @@ CheckHighJumpInput = 0x80157A50;
UpdateEntityRichter = 0x80157BFC;
SetPlayerStep = 0x8015C908;
SetSpeedX = 0x8015CA84;
GetFreeEntity = 0x8015F8F8;
GetFreeEntityReverse = 0x8015F96C;
CreateEntFactoryFromEntity = 0x801606BC;
EntityEntFactory = 0x80160788;
EntitySubwpnBible = 0x80172D00;
EntityGiantSpinningCross = 0x8017328C;
g_DebugWaitInfoTimer = 0x80174F7C;

View File

@ -966,347 +966,3 @@ Entity* CreateEntFactoryFromEntity(
}
return entity;
}
INCLUDE_ASM("asm/us/ric/nonmatchings/22380", func_80160788);
void func_80160C38(Entity* entity) {
if (PLAYER.step != 23) {
DestroyEntity(entity);
} else {
entity->posX.i.hi = PLAYER.posX.i.hi;
entity->posY.i.hi = PLAYER.posY.i.hi;
entity->facingLeft = PLAYER.facingLeft;
if (entity->step == 0) {
entity->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
entity->hitboxOffX = 0x14;
entity->hitboxOffY = 0xC;
entity->hitboxHeight = 9;
entity->hitboxWidth = 9;
entity->ext.generic.unkB0 = 0x12;
func_8015FAB8(entity);
entity->ext.generic.unk7C.s = entity->hitboxState;
entity->step++;
}
entity->hitboxState = entity->ext.generic.unk7C.s;
if (PLAYER.animFrameIdx < 2) {
entity->hitboxState = 0;
}
if (PLAYER.animFrameIdx >= 8) {
DestroyEntity(entity);
}
}
}
void func_80160D2C(Entity* self) {
if (PLAYER.step != 26) {
DestroyEntity(self);
return;
}
self->posX.i.hi = PLAYER.posX.i.hi;
self->posY.i.hi = PLAYER.posY.i.hi;
self->facingLeft = PLAYER.facingLeft;
if (self->step == 0) {
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
self->hitboxOffX = 0x14;
self->hitboxHeight = 9;
self->hitboxWidth = 9;
self->ext.generic.unkB0 = 0x17;
func_8015FAB8(self);
self->step++;
}
if (PLAYER.animCurFrame == 140) {
self->hitboxOffY = 0;
}
if (PLAYER.animCurFrame == 141) {
self->hitboxOffY = 12;
}
if (self->hitFlags != 0) {
g_Player.unk44 |= 0x80;
} else {
g_Player.unk44 &= ~0x80;
}
self->hitFlags = 0;
}
void func_80160E4C(Entity* self) {
if (PLAYER.step != 24) {
DestroyEntity(self);
} else {
self->posX.i.hi = PLAYER.posX.i.hi;
self->posY.i.hi = PLAYER.posY.i.hi;
self->facingLeft = PLAYER.facingLeft;
if (self->step == 0) {
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
self->hitboxHeight = 20;
self->hitboxWidth = 20;
self->hitboxOffY = 0;
self->hitboxOffX = 0;
self->ext.generic.unkB0 = 0x11;
func_8015FAB8(self);
self->step++;
}
if (PLAYER.animFrameIdx >= 19) {
DestroyEntity(self);
}
}
}
void func_80160F0C(Entity* self) {
if (PLAYER.step != 8) {
DestroyEntity(self);
return;
}
self->posX.i.hi = PLAYER.posX.i.hi;
self->posY.i.hi = PLAYER.posY.i.hi;
self->facingLeft = PLAYER.facingLeft;
if (self->step == 0) {
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
self->hitboxOffX = 0xC;
self->hitboxOffY = -0x1A;
self->hitboxWidth = 12;
self->hitboxHeight = 12;
self->ext.generic.unkB0 = 0x16;
func_8015FAB8(self);
self->step++;
}
}
INCLUDE_ASM("asm/us/ric/nonmatchings/22380", func_80160FC4);
INCLUDE_ASM("asm/us/ric/nonmatchings/22380", func_8016147C);
void func_80161C2C(Entity* self) {
u16 params = self->params;
s16 paramsHi = self->params >> 8;
s32 step = self->step;
s32 rnd;
switch (step) {
case 0:
if (paramsHi == 1) {
self->rotX = 0xC0;
self->rotY = 0xC0;
self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTY;
self->animSet = ANIMSET_DRA(2);
self->unk4C = D_80154E04;
}
if ((paramsHi == 0) || (paramsHi == 2)) {
if (params & 3) {
self->unk4C = D_80154DC8;
self->rotX = 0x120;
self->rotY = 0x120;
self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTY;
self->animSet = ANIMSET_DRA(2);
} else {
self->animSet = ANIMSET_DRA(5);
self->unk4C = D_80154C80;
self->palette = 0x8170;
}
}
self->flags = FLAG_UNK_20000 | FLAG_UNK_100000 | FLAG_UNK_08000000;
if (rand() % 4) {
self->zPriority = PLAYER.zPriority + 2;
} else {
self->zPriority = PLAYER.zPriority - 2;
}
if (paramsHi == 2) {
self->posX.i.hi = PLAYER.posX.i.hi + (rand() % 44) - 22;
} else {
self->posX.i.hi = PLAYER.posX.i.hi + (rand() & 15) - 8;
}
rnd = rand() & 31;
self->posY.i.hi = PLAYER.posY.i.hi + PLAYER.hitboxOffY + rnd - 16;
self->velocityY = FIX(-0.5);
self->velocityX = PLAYER.velocityX >> 2;
self->step++;
break;
case 1:
self->rotX -= 4;
self->rotY -= 4;
self->posY.val += self->velocityY;
self->posX.val += self->velocityX;
if ((self->animFrameIdx == 8) && (self->unk4C != D_80154C80)) {
self->blendMode = 0x10;
if (!(params & 1) && (self->animFrameDuration == step)) {
CreateEntFactoryFromEntity(self, 0x40004, 0);
}
}
if ((self->animFrameIdx == 16) && (self->unk4C == D_80154C80)) {
self->blendMode = 0x10;
}
if (self->animFrameDuration < 0) {
DestroyEntity(self);
}
break;
}
}
void func_80161EF8(Entity* self) {
switch (self->step) {
case 0:
self->animSet = ANIMSET_DRA(2);
self->unk4C = &D_80154E38;
self->flags =
FLAG_UNK_20000 | FLAG_UNK_100000 | FLAG_UNK_10000 | FLAG_UNK_40000;
self->zPriority = PLAYER.zPriority + 4;
self->velocityY = (rand() & 0x3FFF) - 0x10000;
self->step++;
break;
case 1:
if ((self->animFrameIdx == 6) &&
(self->animFrameDuration == self->step) && (rand() & 1)) {
CreateEntFactoryFromEntity(self, 4, 0);
}
self->posY.val += self->velocityY;
if (self->animFrameDuration < 0) {
DestroyEntity(self);
}
break;
}
}
INCLUDE_ASM("asm/us/ric/nonmatchings/22380", func_80161FF0);
void func_801623E0(Entity* entity) {
POLY_GT4* poly;
s16 primIndex;
entity->posX.val = g_Entities->posX.val;
entity->posY.val = PLAYER.posY.val;
switch (entity->step) {
case 0:
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
entity->primIndex = primIndex;
if (primIndex == -1) {
DestroyEntity(entity);
return;
}
entity->ext.generic.unk7E.modeU16 = 32;
entity->ext.generic.unk7C.s = 32;
poly = &g_PrimBuf[entity->primIndex];
poly->u2 = 64;
poly->u0 = 64;
poly->v1 = 192;
poly->v0 = 192;
poly->u3 = 127;
poly->u1 = 127;
poly->v3 = 255;
poly->v2 = 255;
poly->tpage = 0x1A;
poly->clut = 0x13E;
poly->pad2 = PLAYER.zPriority + 8;
poly->pad3 = 0;
entity->flags = FLAG_UNK_10000 | FLAG_UNK_40000 | FLAG_UNK_04000000 |
FLAG_HAS_PRIMS;
entity->step++;
break;
case 1:
entity->ext.generic.unk7C.s++;
entity->ext.generic.unk7E.modeU16++;
if (entity->ext.generic.unk7C.s >= 45) {
DestroyEntity(entity);
return;
}
break;
}
poly = &g_PrimBuf[entity->primIndex];
poly->x0 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y0 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x1 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y1 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x2 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y2 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
poly->x3 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y3 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
poly->clut = (LOH(g_Timer) & 1) + 0x13E;
}
void func_80162604(Entity* entity) {
POLY_GT4* poly;
s16 primIndex;
entity->posX.val = g_Entities->posX.val;
entity->posY.val = PLAYER.posY.val;
switch (entity->step) {
case 0:
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
entity->primIndex = primIndex;
if (primIndex != -1) {
entity->ext.generic.unk7E.modeU16 = 0;
entity->ext.generic.unk7C.s = 0;
poly = &g_PrimBuf[entity->primIndex];
poly->v1 = 192;
poly->v0 = 192;
poly->u3 = 63;
poly->u1 = 63;
poly->v3 = 255;
poly->v2 = 255;
poly->tpage = 0x1A;
poly->u2 = 0;
poly->u0 = 0;
poly->clut = 0x162;
poly->pad2 = PLAYER.zPriority - 4;
poly->pad3 = 0;
entity->flags = FLAG_UNK_10000 | FLAG_UNK_40000 |
FLAG_UNK_04000000 | FLAG_HAS_PRIMS;
entity->step++;
goto def;
} else {
DestroyEntity(entity);
break;
}
case 1:
entity->ext.generic.unk7C.s += 8;
entity->ext.generic.unk7E.modeU16 += 8;
if (entity->ext.generic.unk7C.s < 0x20) {
goto def;
}
case 2:
entity->step++;
goto def;
case 3:
entity->ext.generic.unk7C.s -= 8;
entity->ext.generic.unk7E.modeU16 -= 8;
if (entity->ext.generic.unk7C.s >= 5) {
goto def;
} else {
DestroyEntity(entity);
}
break;
def:
default:
poly = &g_PrimBuf[entity->primIndex];
poly->x0 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y0 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x1 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y1 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x2 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y2 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
poly->x3 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y3 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
break;
}
}
INCLUDE_ASM("asm/us/ric/nonmatchings/22380", func_80162870);
void func_80162C7C(void) {}

494
src/ric/24788.c Normal file
View File

@ -0,0 +1,494 @@
#include "ric.h"
// Similar to same function in DRA
void EntityEntFactory(Entity* self) {
Entity* newEntity;
s16 unk96Copy;
s16 i;
u8 endIndex;
s16 startIndex;
u8* data_idx;
if (self->step == 0) {
data_idx = &g_RicFactoryBlueprints[self->params];
self->ext.factory.childId = *data_idx++;
self->ext.factory.unk94 = *data_idx++; // index 1
self->ext.factory.unk96 = *data_idx & 0x3F; // index 2, lower 6 bits
self->ext.factory.unk9E = *data_idx >> 7; // index 2, top bit
self->ext.factory.unkA2 = *data_idx++ >> 6 & 1; // index 2, 2nd-top bit
self->ext.factory.unk98 = *data_idx++; // index 3
self->ext.factory.unk9C = *data_idx & 0x7; // index 4, lower 4 bits
self->ext.factory.unkA4 = *data_idx++ >> 3; // index 4, upper 4 bits
self->ext.factory.unk9A = *data_idx; // index 5
self->flags |= FLAG_UNK_04000000;
self->step++;
switch (self->ext.factory.unkA4) {
case 0:
self->flags |= FLAG_UNK_08000000;
break;
case 4:
self->flags |= FLAG_UNK_20000;
case 2:
case 9:
self->flags |= FLAG_UNK_40000;
case 3:
case 7:
self->posX.val = PLAYER.posX.val;
self->posY.val = PLAYER.posY.val;
break;
case 8:
self->flags |= FLAG_UNK_40000;
self->posX.val = self->ext.factory.parent->posX.val;
self->posY.val = self->ext.factory.parent->posY.val;
break;
}
} else {
switch (self->ext.factory.unkA4) {
case 0:
break;
case 9:
if (g_Player.unk4E != 0) {
DestroyEntity(self);
return;
}
case 2:
self->posX.val = g_Entities->posX.val;
self->posY.val = PLAYER.posY.val;
break;
case 4:
self->posX.val = g_Entities->posX.val;
self->posY.val = PLAYER.posY.val;
if (PLAYER.step != 25) {
self->entityId = 0;
return;
}
break;
case 3:
self->posX.val = g_Entities->posX.val;
self->posY.val = PLAYER.posY.val;
if (PLAYER.step == 0xA) {
self->entityId = 0;
return;
}
break;
case 7:
self->posX.val = g_Entities->posX.val;
self->posY.val = PLAYER.posY.val;
if (PLAYER.step != 10) {
setIdZeroAndReturn:
self->entityId = 0;
return;
}
break;
case 8:
self->posX.val = self->ext.factory.parent->posX.val;
self->posY.val = self->ext.factory.parent->posY.val;
break;
}
}
if (self->ext.factory.unk9A != 0) {
self->ext.factory.unk9A--;
if (self->ext.factory.unk9A != 0) {
return;
}
self->ext.factory.unk9A = self->ext.factory.unk98;
}
// Save this value so we don't have to re-fetch on every for-loop cycle
unk96Copy = self->ext.factory.unk96;
for (i = 0; i < unk96Copy; i++) {
// !FAKE, this should probably be &D_80154C40[unk9C] or similar,
// instead of doing &D_80154C40 followed by +=
data_idx = &D_80154C40[0];
data_idx += self->ext.factory.unk9C * 2;
startIndex = *data_idx;
endIndex = *(data_idx + 1);
if (self->ext.factory.unk9C == 0) {
newEntity = GetFreeEntityReverse(startIndex, endIndex + 1);
} else if (self->ext.factory.unk9C == 4) {
newEntity = &g_Entities[31];
} else if (self->ext.factory.unk9C == 5) {
newEntity = &g_Entities[48];
} else {
newEntity = GetFreeEntity(startIndex, endIndex + 1);
}
if (newEntity == NULL) {
if (self->ext.factory.unk9E == 1) {
goto setIdZeroAndReturn;
}
break;
}
DestroyEntity(newEntity);
// unkA8 never gets set so is always zero
newEntity->entityId =
self->ext.factory.childId + self->ext.factory.unkA8;
newEntity->params = self->ext.factory.unkA0;
// The child (newEntity) is not an ent factory, but because the
// factory creates many entities, we can't pick a particular extension.
// But we're not allowed to use generic, so i'll just reuse entFactory.
newEntity->ext.factory.parent = self->ext.factory.parent;
newEntity->posX.val = self->posX.val;
newEntity->posY.val = self->posY.val;
newEntity->facingLeft = self->facingLeft;
newEntity->zPriority = self->zPriority;
if (self->flags & FLAG_UNK_10000) {
newEntity->flags |= FLAG_UNK_10000;
}
if (self->ext.factory.unkA2 != 0) {
newEntity->params += self->ext.factory.unkA6;
} else {
newEntity->params += i;
}
if (++self->ext.factory.unkA6 == self->ext.factory.unk94) {
self->entityId = 0;
return;
}
}
self->ext.factory.unk9A = self->ext.factory.unk98;
}
void func_80160C38(Entity* entity) {
if (PLAYER.step != 23) {
DestroyEntity(entity);
} else {
entity->posX.i.hi = PLAYER.posX.i.hi;
entity->posY.i.hi = PLAYER.posY.i.hi;
entity->facingLeft = PLAYER.facingLeft;
if (entity->step == 0) {
entity->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
entity->hitboxOffX = 0x14;
entity->hitboxOffY = 0xC;
entity->hitboxHeight = 9;
entity->hitboxWidth = 9;
entity->ext.generic.unkB0 = 0x12;
func_8015FAB8(entity);
entity->ext.generic.unk7C.s = entity->hitboxState;
entity->step++;
}
entity->hitboxState = entity->ext.generic.unk7C.s;
if (PLAYER.animFrameIdx < 2) {
entity->hitboxState = 0;
}
if (PLAYER.animFrameIdx >= 8) {
DestroyEntity(entity);
}
}
}
void func_80160D2C(Entity* self) {
if (PLAYER.step != 26) {
DestroyEntity(self);
return;
}
self->posX.i.hi = PLAYER.posX.i.hi;
self->posY.i.hi = PLAYER.posY.i.hi;
self->facingLeft = PLAYER.facingLeft;
if (self->step == 0) {
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
self->hitboxOffX = 0x14;
self->hitboxHeight = 9;
self->hitboxWidth = 9;
self->ext.generic.unkB0 = 0x17;
func_8015FAB8(self);
self->step++;
}
if (PLAYER.animCurFrame == 140) {
self->hitboxOffY = 0;
}
if (PLAYER.animCurFrame == 141) {
self->hitboxOffY = 12;
}
if (self->hitFlags != 0) {
g_Player.unk44 |= 0x80;
} else {
g_Player.unk44 &= ~0x80;
}
self->hitFlags = 0;
}
void func_80160E4C(Entity* self) {
if (PLAYER.step != 24) {
DestroyEntity(self);
} else {
self->posX.i.hi = PLAYER.posX.i.hi;
self->posY.i.hi = PLAYER.posY.i.hi;
self->facingLeft = PLAYER.facingLeft;
if (self->step == 0) {
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
self->hitboxHeight = 20;
self->hitboxWidth = 20;
self->hitboxOffY = 0;
self->hitboxOffX = 0;
self->ext.generic.unkB0 = 0x11;
func_8015FAB8(self);
self->step++;
}
if (PLAYER.animFrameIdx >= 19) {
DestroyEntity(self);
}
}
}
void func_80160F0C(Entity* self) {
if (PLAYER.step != 8) {
DestroyEntity(self);
return;
}
self->posX.i.hi = PLAYER.posX.i.hi;
self->posY.i.hi = PLAYER.posY.i.hi;
self->facingLeft = PLAYER.facingLeft;
if (self->step == 0) {
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000 | FLAG_UNK_04000000;
self->hitboxOffX = 0xC;
self->hitboxOffY = -0x1A;
self->hitboxWidth = 12;
self->hitboxHeight = 12;
self->ext.generic.unkB0 = 0x16;
func_8015FAB8(self);
self->step++;
}
}
INCLUDE_ASM("asm/us/ric/nonmatchings/24788", func_80160FC4);
INCLUDE_ASM("asm/us/ric/nonmatchings/24788", func_8016147C);
void func_80161C2C(Entity* self) {
u16 params = self->params;
s16 paramsHi = self->params >> 8;
s32 step = self->step;
s32 rnd;
switch (step) {
case 0:
if (paramsHi == 1) {
self->rotX = 0xC0;
self->rotY = 0xC0;
self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTY;
self->animSet = ANIMSET_DRA(2);
self->unk4C = D_80154E04;
}
if ((paramsHi == 0) || (paramsHi == 2)) {
if (params & 3) {
self->unk4C = D_80154DC8;
self->rotX = 0x120;
self->rotY = 0x120;
self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTY;
self->animSet = ANIMSET_DRA(2);
} else {
self->animSet = ANIMSET_DRA(5);
self->unk4C = D_80154C80;
self->palette = 0x8170;
}
}
self->flags = FLAG_UNK_20000 | FLAG_UNK_100000 | FLAG_UNK_08000000;
if (rand() % 4) {
self->zPriority = PLAYER.zPriority + 2;
} else {
self->zPriority = PLAYER.zPriority - 2;
}
if (paramsHi == 2) {
self->posX.i.hi = PLAYER.posX.i.hi + (rand() % 44) - 22;
} else {
self->posX.i.hi = PLAYER.posX.i.hi + (rand() & 15) - 8;
}
rnd = rand() & 31;
self->posY.i.hi = PLAYER.posY.i.hi + PLAYER.hitboxOffY + rnd - 16;
self->velocityY = FIX(-0.5);
self->velocityX = PLAYER.velocityX >> 2;
self->step++;
break;
case 1:
self->rotX -= 4;
self->rotY -= 4;
self->posY.val += self->velocityY;
self->posX.val += self->velocityX;
if ((self->animFrameIdx == 8) && (self->unk4C != D_80154C80)) {
self->blendMode = 0x10;
if (!(params & 1) && (self->animFrameDuration == step)) {
CreateEntFactoryFromEntity(self, 0x40004, 0);
}
}
if ((self->animFrameIdx == 16) && (self->unk4C == D_80154C80)) {
self->blendMode = 0x10;
}
if (self->animFrameDuration < 0) {
DestroyEntity(self);
}
break;
}
}
void func_80161EF8(Entity* self) {
switch (self->step) {
case 0:
self->animSet = ANIMSET_DRA(2);
self->unk4C = &D_80154E38;
self->flags =
FLAG_UNK_20000 | FLAG_UNK_100000 | FLAG_UNK_10000 | FLAG_UNK_40000;
self->zPriority = PLAYER.zPriority + 4;
self->velocityY = (rand() & 0x3FFF) - 0x10000;
self->step++;
break;
case 1:
if ((self->animFrameIdx == 6) &&
(self->animFrameDuration == self->step) && (rand() & 1)) {
CreateEntFactoryFromEntity(self, 4, 0);
}
self->posY.val += self->velocityY;
if (self->animFrameDuration < 0) {
DestroyEntity(self);
}
break;
}
}
INCLUDE_ASM("asm/us/ric/nonmatchings/24788", func_80161FF0);
void func_801623E0(Entity* entity) {
POLY_GT4* poly;
s16 primIndex;
entity->posX.val = g_Entities->posX.val;
entity->posY.val = PLAYER.posY.val;
switch (entity->step) {
case 0:
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
entity->primIndex = primIndex;
if (primIndex == -1) {
DestroyEntity(entity);
return;
}
entity->ext.generic.unk7E.modeU16 = 32;
entity->ext.generic.unk7C.s = 32;
poly = &g_PrimBuf[entity->primIndex];
poly->u2 = 64;
poly->u0 = 64;
poly->v1 = 192;
poly->v0 = 192;
poly->u3 = 127;
poly->u1 = 127;
poly->v3 = 255;
poly->v2 = 255;
poly->tpage = 0x1A;
poly->clut = 0x13E;
poly->pad2 = PLAYER.zPriority + 8;
poly->pad3 = 0;
entity->flags = FLAG_UNK_10000 | FLAG_UNK_40000 | FLAG_UNK_04000000 |
FLAG_HAS_PRIMS;
entity->step++;
break;
case 1:
entity->ext.generic.unk7C.s++;
entity->ext.generic.unk7E.modeU16++;
if (entity->ext.generic.unk7C.s >= 45) {
DestroyEntity(entity);
return;
}
break;
}
poly = &g_PrimBuf[entity->primIndex];
poly->x0 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y0 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x1 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y1 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x2 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y2 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
poly->x3 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y3 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
poly->clut = (LOH(g_Timer) & 1) + 0x13E;
}
void func_80162604(Entity* entity) {
POLY_GT4* poly;
s16 primIndex;
entity->posX.val = g_Entities->posX.val;
entity->posY.val = PLAYER.posY.val;
switch (entity->step) {
case 0:
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
entity->primIndex = primIndex;
if (primIndex != -1) {
entity->ext.generic.unk7E.modeU16 = 0;
entity->ext.generic.unk7C.s = 0;
poly = &g_PrimBuf[entity->primIndex];
poly->v1 = 192;
poly->v0 = 192;
poly->u3 = 63;
poly->u1 = 63;
poly->v3 = 255;
poly->v2 = 255;
poly->tpage = 0x1A;
poly->u2 = 0;
poly->u0 = 0;
poly->clut = 0x162;
poly->pad2 = PLAYER.zPriority - 4;
poly->pad3 = 0;
entity->flags = FLAG_UNK_10000 | FLAG_UNK_40000 |
FLAG_UNK_04000000 | FLAG_HAS_PRIMS;
entity->step++;
goto def;
} else {
DestroyEntity(entity);
break;
}
case 1:
entity->ext.generic.unk7C.s += 8;
entity->ext.generic.unk7E.modeU16 += 8;
if (entity->ext.generic.unk7C.s < 0x20) {
goto def;
}
case 2:
entity->step++;
goto def;
case 3:
entity->ext.generic.unk7C.s -= 8;
entity->ext.generic.unk7E.modeU16 -= 8;
if (entity->ext.generic.unk7C.s >= 5) {
goto def;
} else {
DestroyEntity(entity);
}
break;
def:
default:
poly = &g_PrimBuf[entity->primIndex];
poly->x0 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y0 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x1 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y1 = entity->posY.i.hi - entity->ext.generic.unk7E.modeU16;
poly->x2 = entity->posX.i.hi - entity->ext.generic.unk7C.s;
poly->y2 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
poly->x3 = entity->posX.i.hi + entity->ext.generic.unk7C.s;
poly->y3 = entity->posY.i.hi + entity->ext.generic.unk7E.modeU16;
break;
}
}
INCLUDE_ASM("asm/us/ric/nonmatchings/24788", func_80162870);
void func_80162C7C(void) {}

View File

@ -107,6 +107,8 @@ extern PfnEntityUpdate D_8015495C[];
extern s32 D_80154ED4;
extern s32 D_80154EF8;
extern s32 D_80155368[];
extern FactoryBlueprint g_RicFactoryBlueprints[];
extern u8 D_80154C40[];
extern AnimationFrame D_80154C80[];
extern AnimationFrame D_80154DC8[];
extern AnimationFrame D_80154E04[];