diff --git a/src/game/bg.c b/src/game/bg.c index 13505786c..454e4a0fd 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -1865,7 +1865,7 @@ glabel func0f158d9c ); GLOBAL_ASM( -glabel func0f1598b4 +glabel bg0f1598b4 .late_rodata glabel var7f1b75c4 .word 0x3f333333 @@ -2295,6 +2295,102 @@ glabel var7f1b75c4 /* f159f18: 27bd03d8 */ addiu $sp,$sp,0x3d8 ); +// Mismatch: Regalloc and some reordered instructions +//Gfx *bg0f1598b4(Gfx *gdl, Gfx *gdl2, struct gfxvtx *vertices, s16 arg3[3]) +//{ +// s32 i; +// s32 stack; +// struct bgthing thing; +// struct stagetableentry *stage = stageGetCurrent(); +// s16 sp120[16][3]; +// s32 spe0[16]; +// s32 spa0[16]; +// +// thing.unk00c = g_Vars.currentplayer->eraserbgdist; +// thing.unk010 = thing.unk00c * thing.unk00c; +// thing.unk018 = thing.unk00c * 0.25f; +// thing.unk01c = g_Vars.currentplayer->eraserpropdist / thing.unk00c; +// +// if (thing.unk01c > 0.7f) { +// thing.unk01c = 0.7f; +// } +// +// thing.unk014 = 0.250f; +// thing.unk020 = stage->unk2c; +// thing.unk024 = thing.unk020 * thing.unk020; +// thing.unk000 = arg3[0]; +// thing.unk004 = arg3[1]; +// thing.unk008 = arg3[2]; +// thing.unk24a = 0; +// thing.unk248 = 0; +// +// while (true) { +// if (gdl2->dma.cmd == G_ENDDL) { +// break; +// } +// +// if (gdl2->dma.cmd == G_MTX) { +// // empty +// } else if (gdl2->dma.cmd == G_VTX) { +// s32 index = gdl2->bytes[1] & 0xf; +// s32 numvertices = (((u32)gdl2->bytes[1] >> 4)) + 1; +// s32 offset = (gdl2->words.w1 & 0xffffff); +// struct gfxvtx *vtx = (struct gfxvtx *)((u32)vertices + offset); +// u32 stack[4]; +// +// for (i = 0; i < numvertices; i++) { +// sp120[index + i][0] = vtx->x; +// sp120[index + i][1] = vtx->y; +// sp120[index + i][2] = vtx->z; +// +// func0f158884(&spa0[i], sp120[index + i], &spe0[index + i], &thing); +// +// vtx++; +// } +// } else if (gdl2->dma.cmd == G_TRI1) { +// s16 x = gdl2->tri.tri.v[0] / 10; +// s16 y = gdl2->tri.tri.v[1] / 10; +// s16 z = gdl2->tri.tri.v[2] / 10; +// +// gdl = func0f158d9c(gdl, &thing, sp120[x], sp120[y], sp120[z], spe0[x], spe0[y], spe0[z], spa0[x], spa0[y], spa0[z]); +// } else if (gdl2->dma.cmd == G_TRI4) { +// s16 x; +// s16 y; +// s16 z; +// +// x = gdl2->tri4.x1; +// y = gdl2->tri4.y1; +// z = gdl2->tri4.z1; +// +// gdl = func0f158d9c(gdl, &thing, sp120[x], sp120[y], sp120[z], spe0[x], spe0[y], spe0[z], spa0[x], spa0[y], spa0[z]); +// +// x = gdl2->tri4.x2; +// y = gdl2->tri4.y2; +// z = gdl2->tri4.z2; +// +// gdl = func0f158d9c(gdl, &thing, sp120[x], sp120[y], sp120[z], spe0[x], spe0[y], spe0[z], spa0[x], spa0[y], spa0[z]); +// +// x = gdl2->tri4.x3; +// y = gdl2->tri4.y3; +// z = gdl2->tri4.z3; +// +// gdl = func0f158d9c(gdl, &thing, sp120[x], sp120[y], sp120[z], spe0[x], spe0[y], spe0[z], spa0[x], spa0[y], spa0[z]); +// +// x = gdl2->tri4.x4; +// y = gdl2->tri4.y4; +// z = gdl2->tri4.z4; +// +// gdl = func0f158d9c(gdl, &thing, sp120[x], sp120[y], sp120[z], spe0[x], spe0[y], spe0[z], spa0[x], spa0[y], spa0[z]); +// } +// +// gdl2++; +// } +// +// gdl = func0f158184(gdl, &thing); +// +// return gdl; +//} + Gfx *bgRenderRoomXrayPass(Gfx *gdl, s32 roomnum, struct roomgfxdata18 *arg2, bool recurse, s16 arg4[3]) { struct player *player = g_Vars.currentplayer; @@ -2305,7 +2401,7 @@ Gfx *bgRenderRoomXrayPass(Gfx *gdl, s32 roomnum, struct roomgfxdata18 *arg2, boo switch (arg2->type) { case 0: - gdl = func0f1598b4(gdl, arg2->gdl, arg2->vertices, arg4); + gdl = bg0f1598b4(gdl, arg2->gdl, arg2->vertices, arg4); if (recurse) { gdl = bgRenderRoomXrayPass(gdl, roomnum, arg2->next, true, arg4); diff --git a/src/include/game/bg.h b/src/include/game/bg.h index cceff91c5..a7955d15b 100644 --- a/src/include/game/bg.h +++ b/src/include/game/bg.h @@ -8,11 +8,11 @@ void roomUnpauseProps(u32 roomnum, bool tintedglassonly); void roomSetOnscreen(s32 room, s32 draworder, struct screenbox *arg2); void func0f158108(s32 roomnum, u8 *arg1, u8 *arg2); struct var800a4640_00 *func0f158140(s32 roomnum); -u32 func0f158184(void); +Gfx *func0f158184(Gfx *gdl, struct bgthing *arg1); u32 func0f158400(void); -u32 func0f158884(void); -u32 func0f158d9c(void); -Gfx *func0f1598b4(Gfx *gdl, Gfx *gdl2, struct gfxvtx *vertices, s16 arg3[3]); +void func0f158884(s32 *arg0, s16 arg1[3], s32 *arg2, struct bgthing *arg3); +Gfx *func0f158d9c(Gfx *gdl, struct bgthing *arg1, s16 arg2[3], s16 arg3[3], s16 arg4[3], s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, s32 arg10); +Gfx *bg0f1598b4(Gfx *gdl, Gfx *gdl2, struct gfxvtx *vertices, s16 arg3[3]); Gfx *bgRenderRoomXrayPass(Gfx *gdl, s32 roomnum, struct roomgfxdata18 *arg2, bool recurse, s16 arg4[3]); Gfx *bgRenderRoomInXray(Gfx *gdl, s32 roomnum); Gfx *bgRenderSceneInXray(Gfx *gdl); diff --git a/src/include/gbiex.h b/src/include/gbiex.h index 13c5a47fb..e9ff8496d 100644 --- a/src/include/gbiex.h +++ b/src/include/gbiex.h @@ -5,7 +5,7 @@ #include "types.h" #define G_SETCOLOR 0x07 -#define G_TRI4 0xb1 +#define G_TRI4 -79 /** * 04 rsp_uc05_vertex diff --git a/src/include/types.h b/src/include/types.h index c289ca888..b52d982e6 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2353,7 +2353,7 @@ struct player { /*0x0014*/ s32 memcamroom; /*0x0018*/ struct coord eraserpos; /*0x0024*/ f32 eraserpropdist; - /*0x0028*/ u32 eraserbgdist; + /*0x0028*/ f32 eraserbgdist; /*0x002c*/ u32 eraserdepth; /*0x0030*/ bool isfalling; /*0x0034*/ s32 fallstart; // lvframe60 when player started falling @@ -6350,4 +6350,20 @@ struct var800a6538 { f32 unk04; }; +struct bgthing { + s32 unk000; + s32 unk004; + s32 unk008; + f32 unk00c; + f32 unk010; + f32 unk014; + f32 unk018; + f32 unk01c; + s32 unk020; + s32 unk024; + u8 unk028[0x220]; + s16 unk248; + s16 unk24a; +}; + #endif