Decompiling tt_001.func_us_8017246C (#1711)

Accurate for PSX and PSP

PSP scratch: https://decomp.me/scratch/lZHti

Some of these global variables I've figured out, but I am planning on
doing a refactor of tt_001 next and will rename the vars there.
This commit is contained in:
H.M. Burger 2024-10-02 13:04:56 -05:00 committed by GitHub
parent 11631e1475
commit ed33e90bd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,6 +19,19 @@ extern u16 D_us_80170580[48];
extern u16 D_us_80170448[48];
extern SpriteParts* D_us_80170040[];
extern Primitive*
D_us_801737FC; // Pointer to the current primitive being manipulated
extern s32 D_us_80173800; // Index for the current primitive being manipulated
extern s32 D_us_80173804; // Effect timer used to control steps and timing
extern s16 D_us_80173808; // Temporary storage for X position of the entity or
// primitive
extern s16 D_us_8017380C; // Temporary storage for Y position of the entity or
// primitive
extern s16
D_us_801705A0[]; // Array of X-axis offsets for positioning primitives
extern s16
D_us_801705A8[]; // Array of Y-axis offsets for positioning primitives
s32 ServantUnk0();
void ProcessEvent(Entity* self, bool resetEvent);
@ -33,7 +46,7 @@ void func_us_801720CC(void);
void func_us_801720D4(void);
void func_us_801720DC(void);
void func_us_801720E4(Entity* self);
void func_us_8017246C(void);
void func_us_8017246C(Entity* self);
void func_us_801728EC(void);
void func_us_801728F4(void);
void func_us_801728FC(void);
@ -522,7 +535,96 @@ void func_us_801720DC(void) {}
INCLUDE_ASM("servant/tt_001/nonmatchings/F84", func_us_801720E4);
INCLUDE_ASM("servant/tt_001/nonmatchings/F84", func_us_8017246C);
void func_us_8017246C(Entity* self) {
u16 temp;
if (self->params) {
DestroyEntity(self);
return;
}
switch (self->step) {
case 0:
self->primIndex = g_api.AllocPrimitives(PRIM_GT4, 3);
if (self->primIndex == -1) {
DestroyEntity(self);
return;
}
self->flags = FLAG_POS_CAMERA_LOCKED | FLAG_KEEP_ALIVE_OFFCAMERA |
FLAG_HAS_PRIMS | FLAG_UNK_20000;
D_us_801737FC = &g_PrimBuf[self->primIndex];
for (D_us_80173800 = 0; D_us_80173800 < 3; D_us_80173800++) {
D_us_801737FC->clut = 0x143;
D_us_801737FC->tpage = 0x1E;
D_us_801737FC->u0 = D_us_801737FC->u2 = 0x78;
D_us_801737FC->v0 = D_us_801737FC->v1 = 8;
D_us_801737FC->u1 = D_us_801737FC->u3 = 0x80;
D_us_801737FC->v2 = D_us_801737FC->v3 = 0x10;
D_us_801737FC->priority = self->zPriority + 1;
D_us_801737FC->drawMode = DRAW_UNK_100 | DRAW_UNK02;
if (D_us_80173800) {
D_us_801737FC->drawMode |= DRAW_HIDE;
}
D_us_801737FC = D_us_801737FC->next;
}
D_us_80173804 = 0;
self->step++;
break;
case 1:
D_us_80173804++;
if (D_us_80173804 > 0xA) {
D_us_801737FC = &g_PrimBuf[self->primIndex];
D_us_801737FC = D_us_801737FC->next;
D_us_801737FC->drawMode &= ~DRAW_HIDE;
D_us_80173804 = 0;
self->step++;
}
break;
case 2:
D_us_80173804++;
if (D_us_80173804 > 0xA) {
D_us_801737FC = &g_PrimBuf[self->primIndex];
D_us_801737FC = D_us_801737FC->next;
D_us_801737FC = D_us_801737FC->next;
D_us_801737FC->drawMode &= ~DRAW_HIDE;
D_us_80173804 = 0;
self->step++;
}
break;
case 3:
D_us_80173804++;
if (D_us_80173804 > 0x28) {
DestroyEntity(self);
return;
}
}
D_us_80173808 = self->posX.i.hi = self->ext.factory.parent->posX.i.hi;
D_us_8017380C = self->posY.i.hi = self->ext.factory.parent->posY.i.hi;
D_us_801737FC = &g_PrimBuf[self->primIndex];
for (D_us_80173800 = 0; D_us_80173800 < 3; D_us_80173800++) {
if (!self->facingLeft) {
D_us_801737FC->x0 = D_us_801737FC->x2 =
D_us_80173808 + D_us_801705A0[D_us_80173800];
D_us_801737FC->x1 = D_us_801737FC->x3 =
D_us_80173808 + (D_us_801705A0[D_us_80173800] + 8);
} else {
D_us_801737FC->x0 = D_us_801737FC->x2 =
D_us_80173808 - (D_us_801705A0[D_us_80173800] + 8);
D_us_801737FC->x1 = D_us_801737FC->x3 =
D_us_80173808 - D_us_801705A0[D_us_80173800];
}
D_us_801737FC->y0 = D_us_801737FC->y1 =
D_us_8017380C + D_us_801705A8[D_us_80173800];
D_us_801737FC->y2 = D_us_801737FC->y3 =
D_us_8017380C + (D_us_801705A8[D_us_80173800] + 8);
D_us_801737FC = D_us_801737FC->next;
}
return;
}
void func_us_801728EC(void) {}