EntityWarpSmallRocks matching but jtbl not imported

This commit is contained in:
Luciano Ciccariello 2023-01-20 22:16:10 +00:00
parent e06a69f0eb
commit d337730a94
5 changed files with 97 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -133,7 +133,7 @@ typedef struct Entity {
} modeS8;
} unk80; // size = 0x4
/* 0x84 */ Multi unk84;
/* 0x88 */ s8 unk88;
/* 0x88 */ s8 unk88; // this is a Multi: refer to EntityWarpSmallRocks
/* 0x89 */ s8 unk89;
/* 0x8A */ s16 unk8A;
union {
@ -710,7 +710,7 @@ extern u32 D_80073068; // ev0
extern u32 D_8007306C; // ev1
extern u32 D_80073070; // ev2
extern u32 D_80073078; // ev3
extern u16 D_80073092;
extern s16 D_80073092;
extern RoomDimensions g_CurrentRoom;
extern s32 g_CurrentRoomHSize;
extern s32 g_CurrentRoomVSize;

View File

@ -18,6 +18,7 @@ void PadInit(s32 arg0);
int VSync(s32);
s32 rcos(s32);
s32 rsin(s32);
s32 SquareRoot0(s32);
s32 ratan2(s32, s32);
void* DMACallback(int dma, void (*func)());
void func_800192DC(s32 arg0, s32 arg1);

View File

@ -3044,7 +3044,101 @@ void EntityWarpRoom(Entity* arg0) {
}
#endif
// TODO this is matching, but EntityWarpRoom needs to match first due to the
// jump table.
#ifndef NON_MATCHING
INCLUDE_ASM("asm/st/wrp/nonmatchings/6FD0", EntityWarpSmallRocks);
#else
void EntityWarpSmallRocks(Entity* entity) {
s32 x;
s32 y;
s16* y_unk;
s32 distance;
s16 radians;
u32* unk;
switch (entity->step) {
case 0:
unk = D_80180648;
InitializeEntity(D_801804C4);
entity->unk19 = 4;
entity->unk1E = Random() * 0x10;
entity->animationFrame = (Random() % 5) + 1;
if (*unk != 0) {
entity->posY.i.hi = (Random() & 0x1F) + 0x90;
entity->step = 4;
}
break;
case 1:
if (*D_80180648 != 0) {
*(u32*)(&entity->unk88) = Random() & 0x3F;
entity->accelerationY = -0x40000;
entity->step++;
}
break;
case 2:
if (*(u32*)&entity->unk88 != 0) {
*(u32*)&entity->unk88 = *(u32*)&entity->unk88 - 1;
} else {
MoveEntity();
entity->accelerationY += 0x4000;
if (entity->accelerationY > ((s32)0xFFFF0000)) {
entity->unk19 = 3;
entity->unk1C = 0x100;
distance = 0x100;
entity->unk1A = distance;
entity->step++;
}
}
break;
case 3:
x = 0x80 - entity->posX.i.hi;
y = 0x80 - entity->posY.i.hi;
radians = ratan2(y, x);
entity->accelerationX = rcos(radians) << 5;
entity->accelerationY = rsin(radians) << 5;
MoveEntity();
distance = SquareRoot0(x * x + y * y) * 2;
if (distance >= 0x101) {
distance = 0x100;
}
entity->unk1A = entity->unk1C = distance;
if (distance < 8) {
DestroyEntity(entity);
}
break;
case 4:
unk = D_80180648;
entity->unk1E += 0x20;
entity->accelerationY = rsin(entity->unk1E) * 4;
if (*unk == 0) {
*(u32*)&entity->unk88 = 0x10;
entity->step++;
}
break;
case 5:
y_unk = &D_80073092;
*(u32*)&entity->unk88 = *(u32*)&entity->unk88 - 1;
if (*(u32*)&entity->unk88 == 0) {
func_801916C4(0x644);
}
MoveEntity();
entity->accelerationY += 0x3000;
y = entity->posY.i.hi + *y_unk + 5;
if (y >= 209) {
entity->posY.i.hi = 203 - (*y_unk);
entity->step = 1;
}
break;
}
}
#endif
s32 Random(void) {
g_randomNext = (g_randomNext * 0x01010101) + 1;