Rename and document room mtx functions
This commit is contained in:
parent
2b661d2bb4
commit
3248fa9849
|
|
@ -1279,7 +1279,7 @@ Gfx *bgRenderRoomInXray(Gfx *gdl, s32 roomnum)
|
|||
return gdl;
|
||||
}
|
||||
|
||||
room0f166df0(roomnum, &globaldrawworldoffset);
|
||||
roomGetPos(roomnum, &globaldrawworldoffset);
|
||||
|
||||
sp54.x = player->eraserpos.x - globaldrawworldoffset.x;
|
||||
sp54.y = player->eraserpos.y - globaldrawworldoffset.y;
|
||||
|
|
@ -1289,7 +1289,7 @@ Gfx *bgRenderRoomInXray(Gfx *gdl, s32 roomnum)
|
|||
sp40[1] = sp54.f[1];
|
||||
sp40[2] = sp54.f[2];
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
gdl = bgRenderRoomXrayPass(gdl, roomnum, g_Rooms[roomnum].gfxdata->opablocks, true, sp40);
|
||||
gdl = bgRenderRoomXrayPass(gdl, roomnum, g_Rooms[roomnum].gfxdata->xlublocks, true, sp40);
|
||||
|
||||
|
|
@ -4764,7 +4764,7 @@ Gfx *bgRenderRoomOpaque(Gfx *gdl, s32 roomnum)
|
|||
return gdl;
|
||||
}
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
|
||||
gdl = lightsSetForRoom(gdl, roomnum);
|
||||
gdl = bgRenderRoomPass(gdl, roomnum, g_Rooms[roomnum].gfxdata->opablocks, true);
|
||||
|
|
@ -4796,7 +4796,7 @@ Gfx *bgRenderRoomXlu(Gfx *gdl, s32 roomnum)
|
|||
if (g_Rooms[roomnum].gfxdata);
|
||||
if (g_Rooms[roomnum].gfxdata);
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
gdl = bgRenderRoomPass(gdl, roomnum, g_Rooms[roomnum].gfxdata->xlublocks, true);
|
||||
|
||||
g_Rooms[roomnum].loaded240 = 1;
|
||||
|
|
|
|||
|
|
@ -1825,7 +1825,7 @@ Gfx *creditsDraw(Gfx *gdl)
|
|||
}
|
||||
|
||||
mtx4LoadIdentity(&sp68);
|
||||
mtx00016054(&sp68, matrix);
|
||||
mtxF2L(&sp68, matrix);
|
||||
camSetWorldToScreenMtxf(&sp68);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(matrix), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
|
|
|||
|
|
@ -1288,7 +1288,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass)
|
|||
|
||||
if (roomnum != -1) {
|
||||
struct screenbox screenbox;
|
||||
struct coord *coord = roomGetPos(roomnum);
|
||||
struct coord *coord = roomGetPosPtr(roomnum);
|
||||
u32 *colour;
|
||||
s32 tmp;
|
||||
|
||||
|
|
@ -1301,7 +1301,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass)
|
|||
gSPClearGeometryMode(gdl++, G_CULL_BOTH | G_FOG);
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
|
||||
gSPDisplayList(gdl++, g_TexGdl2);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ void menuTickTimers(void)
|
|||
#if PIRACYCHECKS
|
||||
{
|
||||
u32 *ptr = (u32 *)&mtxGetObfuscatedRomBase;
|
||||
u32 *end = (u32 *)&mtx00016054;
|
||||
u32 *end = (u32 *)&mtxF2L;
|
||||
u32 checksum = 0;
|
||||
|
||||
while (ptr < end) {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ void artifactsCalculateGlaresForRoom(s32 roomnum)
|
|||
roomlights = (struct light *)&g_BgLightsFileData[g_Rooms[roomnum].gfxdata->lightsindex * 0x22];
|
||||
s1 = &var800a41a0[g_Rooms[roomnum].gfxdata->lightsindex * 3];
|
||||
|
||||
room0f166a6c(&sp138, roomnum);
|
||||
roomPopulateMtx(&sp138, roomnum);
|
||||
mtx00015f88(currentPlayerGetScaleBg2Gfx(), &sp138);
|
||||
mtx4MultMtx4(camGetMtxF006c(), &sp138, &spf8);
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ Gfx *beamRenderGeneric(Gfx *gdl, struct textureconfig *texconfig,
|
|||
|
||||
mtx00015f04(1.0f / arg2, &sp84);
|
||||
mtx00015be0(worldtoscreenmtx, &sp84);
|
||||
mtx00016054(&sp84, spc8);
|
||||
mtxF2L(&sp84, spc8);
|
||||
|
||||
mult = arg5 * arg2;
|
||||
|
||||
|
|
@ -788,7 +788,7 @@ glabel var7f1accf4
|
|||
/* f0ad1e4: 00001025 */ or $v0,$zero,$zero
|
||||
/* f0ad1e8: 1100026e */ beqz $t0,.L0f0adba4
|
||||
/* f0ad1ec: 27a40148 */ addiu $a0,$sp,0x148
|
||||
/* f0ad1f0: 0c005815 */ jal mtx00016054
|
||||
/* f0ad1f0: 0c005815 */ jal mtxF2L
|
||||
/* f0ad1f4: 8fa50188 */ lw $a1,0x188($sp)
|
||||
/* f0ad1f8: 82230001 */ lb $v1,0x1($s1)
|
||||
/* f0ad1fc: 2401fffe */ addiu $at,$zero,-2
|
||||
|
|
@ -1585,7 +1585,7 @@ Gfx *beamRender(Gfx *gdl, struct beam *beam, bool arg2, u8 arg3)
|
|||
}
|
||||
|
||||
if (spd8) {
|
||||
mtx00016054(&sp148, sp188);
|
||||
mtxF2L(&sp148, sp188);
|
||||
|
||||
if (beam->weaponnum);
|
||||
|
||||
|
|
@ -2239,7 +2239,7 @@ Gfx *lasersightRenderDot(Gfx *gdl)
|
|||
mtx00015f88(0.2f, &sp1b0);
|
||||
|
||||
mtx = gfxAllocateMatrix();
|
||||
mtx00016054(&sp1b0, mtx);
|
||||
mtxF2L(&sp1b0, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
@ -2425,7 +2425,7 @@ Gfx *lasersightRenderBeam(Gfx *gdl)
|
|||
|
||||
mtx00015f88(0.2f, &sp198);
|
||||
mtx = gfxAllocateMatrix();
|
||||
mtx00016054(&sp198, mtx);
|
||||
mtxF2L(&sp198, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -2326,7 +2326,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2)
|
|||
for (i = 0; i < thing->bodymodeldef->nummatrices; i++) {
|
||||
Mtxf sp70;
|
||||
mtx4Copy((Mtxf *)((u32)thing->bodymodel.matrices + i * sizeof(Mtxf)), &sp70);
|
||||
mtx00016054(&sp70, &thing->bodymodel.matrices[i]);
|
||||
mtxF2L(&sp70, &thing->bodymodel.matrices[i]);
|
||||
}
|
||||
|
||||
mtx00016784();
|
||||
|
|
|
|||
|
|
@ -1845,7 +1845,7 @@ Gfx *menugfxRenderBgSuccess(Gfx *gdl)
|
|||
|
||||
modelmtx = gfxAllocateMatrix();
|
||||
|
||||
mtx00016054(&sp110, modelmtx);
|
||||
mtxF2L(&sp110, modelmtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(modelmtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ Gfx *func0f0073ac(Gfx *gdl, struct coord *pos, f32 arg2)
|
|||
mtx4LoadIdentity(&sp104);
|
||||
mtx4LoadTranslation(pos, &sp104);
|
||||
mtx00015be0(camGetWorldToScreenMtxf(), &sp104);
|
||||
mtx00016054(&sp104, modelmtx);
|
||||
mtxF2L(&sp104, modelmtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(modelmtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ Gfx *nbombRender(Gfx *gdl, struct nbomb *nbomb, Gfx *subgdl)
|
|||
mtx4MultMtx4(&sp48, &sp88, &spc8);
|
||||
|
||||
mtx00015be0(camGetWorldToScreenMtxf(), &spc8);
|
||||
mtx00016054(&spc8, mtx);
|
||||
mtxF2L(&spc8, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -2676,7 +2676,7 @@ Gfx *playerRenderHealthBar(Gfx *gdl)
|
|||
Mtxf *addr = gfxAllocateMatrix();
|
||||
|
||||
mtx00016ae4(&matrix, 0, 370, 0, 0, 0, 0, 0, 0, -1);
|
||||
mtx00016054(&matrix, addr);
|
||||
mtxF2L(&matrix, addr);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical((void *)addr), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gDPPipeSync(gdl++);
|
||||
|
|
@ -4180,7 +4180,7 @@ struct var80070ba4 var80070ba4[4][7] = { // [wieldmode][turnmode]
|
|||
|
||||
void playerSetGlobalDrawWorldOffset(s32 room)
|
||||
{
|
||||
room0f166df0(room, &g_Vars.currentplayer->globaldrawworldoffset);
|
||||
roomGetPos(room, &g_Vars.currentplayer->globaldrawworldoffset);
|
||||
|
||||
g_Vars.currentplayer->globaldrawworldbgoffset.x = g_Vars.currentplayer->globaldrawworldoffset.x;
|
||||
g_Vars.currentplayer->globaldrawworldbgoffset.y = g_Vars.currentplayer->globaldrawworldoffset.y;
|
||||
|
|
@ -5709,6 +5709,6 @@ void player0f0c3320(Mtxf *matrices, s32 count)
|
|||
sp40.m[3][1] -= g_Vars.currentplayer->globaldrawworldoffset.y;
|
||||
sp40.m[3][2] -= g_Vars.currentplayer->globaldrawworldoffset.z;
|
||||
|
||||
mtx00016054(&sp40, matrices + i);
|
||||
mtxF2L(&sp40, matrices + i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13487,7 +13487,7 @@ Gfx *gfxRenderRadialShadow(Gfx *gdl, f32 x, f32 y, f32 z, f32 angle, f32 radius,
|
|||
mtx = gfxAllocateMatrix();
|
||||
mtx4LoadYRotationWithTranslation(&pos, angle, &spc0);
|
||||
mtx4MultMtx4(camGetWorldToScreenMtxf(), &spc0, &sp80);
|
||||
mtx00016054(&sp80, mtx);
|
||||
mtxF2L(&sp80, mtx);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
vertices[i].y = 0;
|
||||
|
|
|
|||
140
src/game/room.c
140
src/game/room.c
|
|
@ -6,48 +6,88 @@
|
|||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
u8 *var800a6660;
|
||||
s16 *var800a6664; // room numbers
|
||||
s16 *var800a6668;
|
||||
f32 *var800a666c;
|
||||
Mtxf *var800a6670;
|
||||
/**
|
||||
* Room matrices
|
||||
*
|
||||
* Each room that is rendered needs to have a modelview matrix. The matrix can
|
||||
* be pushed onto the displaylist multiple times per frame, even in single player.
|
||||
*
|
||||
* A simple approach would be to allocate these matrices out of graphics memory
|
||||
* as needed, populating and converting them to the RSP's matrix format each time.
|
||||
*
|
||||
* The solution used here keeps a cache of these matrices. This allows the same
|
||||
* matrix to be reused instead of having to allocate, calculate and convert them
|
||||
* each time which saves CPU time and memory. However, the game has to spend
|
||||
* CPU time keeping track of cache usage so it can free slots, and the cache
|
||||
* allocation uses more total memory than on-demand allocations would require,
|
||||
* so this system is perhaps not as beneficial as it seems.
|
||||
*
|
||||
* The cache is implemented using 5 parallel arrays:
|
||||
*
|
||||
* g_RoomMtxAges
|
||||
* - The number of frames since each cache slot was last used.
|
||||
* - When it reaches 2 the slot is freed.
|
||||
* g_RoomMtxLinkedRooms
|
||||
* - The linked room number per cache slot, or -1 if free.
|
||||
* g_RoomMtxBaseRooms
|
||||
* - The room that each matrix's position is relative to.
|
||||
* - This is the player's room, as the world is drawn relative to this.
|
||||
* g_RoomMtxScales
|
||||
* - The scale that is applied to the matrix. Usually 1.
|
||||
* g_RoomMtxMatrices
|
||||
* - The matrices themselves, in the RSP's matrix format.
|
||||
*
|
||||
* Each room can have at most one matrix slot. When multiplayer is in use, the
|
||||
* same room matrix can be used for both players, but only if they have the same
|
||||
* global draw offset (ie. are in the same room).
|
||||
*
|
||||
* When players are not in the same room but can see the same rooms, each
|
||||
* player's matrix cache invalidates the other's until they move into the same
|
||||
* room or stop looking at each other's rooms.
|
||||
*/
|
||||
|
||||
s32 var80082050 = 0;
|
||||
u8 *g_RoomMtxAges;
|
||||
s16 *g_RoomMtxLinkedRooms;
|
||||
s16 *g_RoomMtxBaseRooms;
|
||||
f32 *g_RoomMtxScales;
|
||||
Mtxf *g_RoomMtxMatrices;
|
||||
|
||||
s32 g_RoomMtxNumSlots = 0;
|
||||
|
||||
void roomSetLastForOffset(s32 room)
|
||||
{
|
||||
g_Vars.currentplayer->lastroomforoffset = room;
|
||||
}
|
||||
|
||||
void room0f1668f0(s32 index, s32 roomnum)
|
||||
void roomLinkMtx(s32 index, s32 roomnum)
|
||||
{
|
||||
g_Rooms[roomnum].unk10 = index;
|
||||
var800a6664[index] = roomnum;
|
||||
g_Rooms[roomnum].roommtxindex = index;
|
||||
g_RoomMtxLinkedRooms[index] = roomnum;
|
||||
}
|
||||
|
||||
void room0f16692c(s32 index, s32 roomnum)
|
||||
void roomUnlinkMtx(s32 index, s32 roomnum)
|
||||
{
|
||||
g_Rooms[roomnum].unk10 = -1;
|
||||
var800a6664[index] = -1;
|
||||
g_Rooms[roomnum].roommtxindex = -1;
|
||||
g_RoomMtxLinkedRooms[index] = -1;
|
||||
}
|
||||
|
||||
void room0f16696c(s32 index)
|
||||
void roomFreeMtx(s32 index)
|
||||
{
|
||||
if (var800a6664[index] != -1) {
|
||||
room0f16692c(index, var800a6664[index]);
|
||||
if (g_RoomMtxLinkedRooms[index] != -1) {
|
||||
roomUnlinkMtx(index, g_RoomMtxLinkedRooms[index]);
|
||||
}
|
||||
|
||||
var800a6660[index] = 2;
|
||||
var800a6668[index] = -1;
|
||||
var800a666c[index] = 1;
|
||||
g_RoomMtxAges[index] = 2;
|
||||
g_RoomMtxBaseRooms[index] = -1;
|
||||
g_RoomMtxScales[index] = 1;
|
||||
}
|
||||
|
||||
s32 room0f1669fc(void)
|
||||
s32 roomAllocateMtx(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < var80082050; i++) {
|
||||
if (var800a6660[i] > 1 && var800a6668[i] == -1) {
|
||||
for (i = 0; i < g_RoomMtxNumSlots; i++) {
|
||||
if (g_RoomMtxAges[i] >= 2 && g_RoomMtxBaseRooms[i] == -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +95,7 @@ s32 room0f1669fc(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void room0f166a6c(Mtxf *mtx, s32 roomnum)
|
||||
void roomPopulateMtx(Mtxf *mtx, s32 roomnum)
|
||||
{
|
||||
s32 stagenum = g_Vars.stagenum;
|
||||
|
||||
|
|
@ -88,53 +128,67 @@ void room0f166a6c(Mtxf *mtx, s32 roomnum)
|
|||
}
|
||||
}
|
||||
|
||||
s32 room0f166c20(s32 roomnum)
|
||||
/**
|
||||
* "Touch" a room's modelview matrix in the cache.
|
||||
*
|
||||
* The function is named after Unix's touch command, which creates a file if
|
||||
* missing and updates the modification time. The function creates the cache
|
||||
* entry if missing and resets the cache entry's age to 0.
|
||||
*/
|
||||
s32 roomTouchMtx(s32 roomnum)
|
||||
{
|
||||
s32 index = g_Rooms[roomnum].unk10;
|
||||
s32 index = g_Rooms[roomnum].roommtxindex;
|
||||
Mtxf mtx;
|
||||
|
||||
if (index == -1
|
||||
|| g_Vars.currentplayer->lastroomforoffset != var800a6668[index]
|
||||
|| var800a666c[index] != var8005ef10[0]) {
|
||||
|| g_Vars.currentplayer->lastroomforoffset != g_RoomMtxBaseRooms[index]
|
||||
|| g_RoomMtxScales[index] != var8005ef10[0]) {
|
||||
// There's no cache for this room or it's invalid.
|
||||
// Unlink the old cache item if any and create a new one.
|
||||
if (index != -1) {
|
||||
room0f16692c(index, roomnum);
|
||||
roomUnlinkMtx(index, roomnum);
|
||||
}
|
||||
|
||||
index = room0f1669fc();
|
||||
index = roomAllocateMtx();
|
||||
|
||||
room0f1668f0(index, roomnum);
|
||||
var800a6660[index] = 0;
|
||||
roomLinkMtx(index, roomnum);
|
||||
g_RoomMtxAges[index] = 0;
|
||||
} else {
|
||||
var800a6660[index] = 0;
|
||||
// The room has an existing, valid cache entry.
|
||||
g_RoomMtxAges[index] = 0;
|
||||
return index;
|
||||
}
|
||||
|
||||
var800a6668[index] = g_Vars.currentplayer->lastroomforoffset;
|
||||
var800a666c[index] = var8005ef10[0];
|
||||
g_RoomMtxBaseRooms[index] = g_Vars.currentplayer->lastroomforoffset;
|
||||
g_RoomMtxScales[index] = var8005ef10[0];
|
||||
|
||||
room0f166a6c(&mtx, roomnum);
|
||||
mtx00016054(&mtx, &var800a6670[index]);
|
||||
roomPopulateMtx(&mtx, roomnum);
|
||||
mtxF2L(&mtx, &g_RoomMtxMatrices[index]);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
Gfx *roomPushMtx(Gfx *gdl, s32 roomnum)
|
||||
/**
|
||||
* Retrieve a room's modelview matrix from cache, or create a new one and cache
|
||||
* it, and apply it to the displaylist.
|
||||
*/
|
||||
Gfx *roomApplyMtx(Gfx *gdl, s32 roomnum)
|
||||
{
|
||||
s32 index = room0f166c20(roomnum);
|
||||
s32 index = roomTouchMtx(roomnum);
|
||||
|
||||
gSPMatrix(gdl++, &var800a6670[index], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPMatrix(gdl++, &g_RoomMtxMatrices[index], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
return gdl;
|
||||
}
|
||||
|
||||
struct coord *roomGetPos(s32 room)
|
||||
struct coord *roomGetPosPtr(s32 room)
|
||||
{
|
||||
return &g_BgRooms[room].pos;
|
||||
}
|
||||
|
||||
void room0f166df0(s32 room, struct coord *globaldrawworldoffset)
|
||||
void roomGetPos(s32 room, struct coord *pos)
|
||||
{
|
||||
globaldrawworldoffset->x = g_BgRooms[room].pos.x;
|
||||
globaldrawworldoffset->y = g_BgRooms[room].pos.y;
|
||||
globaldrawworldoffset->z = g_BgRooms[room].pos.z;
|
||||
pos->x = g_BgRooms[room].pos.x;
|
||||
pos->y = g_BgRooms[room].pos.y;
|
||||
pos->z = g_BgRooms[room].pos.z;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,26 +12,26 @@ void roomsReset(void)
|
|||
{
|
||||
s32 i;
|
||||
|
||||
var80082050 = PLAYERCOUNT() >= 2 ? 200 : 120;
|
||||
g_RoomMtxNumSlots = PLAYERCOUNT() >= 2 ? 200 : 120;
|
||||
|
||||
var800a6660 = mempAlloc(ALIGN16(var80082050), MEMPOOL_STAGE);
|
||||
var800a6664 = mempAlloc(ALIGN16(var80082050 * sizeof(s16)), MEMPOOL_STAGE);
|
||||
var800a6668 = mempAlloc(ALIGN16(var80082050 * sizeof(s16)), MEMPOOL_STAGE);
|
||||
var800a666c = mempAlloc(ALIGN16(var80082050 * sizeof(f32)), MEMPOOL_STAGE);
|
||||
var800a6670 = mempAlloc(ALIGN16(var80082050 * sizeof(Mtxf)), MEMPOOL_STAGE);
|
||||
g_RoomMtxAges = mempAlloc(ALIGN16(g_RoomMtxNumSlots), MEMPOOL_STAGE);
|
||||
g_RoomMtxLinkedRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(s16)), MEMPOOL_STAGE);
|
||||
g_RoomMtxBaseRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(s16)), MEMPOOL_STAGE);
|
||||
g_RoomMtxScales = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(f32)), MEMPOOL_STAGE);
|
||||
g_RoomMtxMatrices = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(Mtxf)), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < PLAYERCOUNT(); i++) {
|
||||
g_Vars.players[i]->lastroomforoffset = -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < var80082050; i++) {
|
||||
var800a6664[i] = -1;
|
||||
var800a6660[i] = 2;
|
||||
var800a6668[i] = -1;
|
||||
var800a666c[i] = 1;
|
||||
for (i = 0; i < g_RoomMtxNumSlots; i++) {
|
||||
g_RoomMtxLinkedRooms[i] = -1;
|
||||
g_RoomMtxAges[i] = 2;
|
||||
g_RoomMtxBaseRooms[i] = -1;
|
||||
g_RoomMtxScales[i] = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < g_Vars.roomcount; i++) {
|
||||
g_Rooms[i].unk10 = -1;
|
||||
g_Rooms[i].roommtxindex = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ void roomsTick(void)
|
|||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < var80082050; i++) {
|
||||
if (var800a6668[i] >= 0) {
|
||||
var800a6660[i]++;
|
||||
for (i = 0; i < g_RoomMtxNumSlots; i++) {
|
||||
if (g_RoomMtxBaseRooms[i] >= 0) {
|
||||
g_RoomMtxAges[i]++;
|
||||
|
||||
if (var800a6660[i] > 1) {
|
||||
room0f16696c(i);
|
||||
if (g_RoomMtxAges[i] > 1) {
|
||||
roomFreeMtx(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ Gfx *func0f0d479c(Gfx *gdl)
|
|||
|
||||
mtx00016760();
|
||||
func0f0d475c(&mtx);
|
||||
mtx00016054(&mtx, mtx2);
|
||||
mtxF2L(&mtx, mtx2);
|
||||
mtx4LoadIdentity(&mtx);
|
||||
|
||||
guFrustumF(mtx.m,
|
||||
|
|
@ -72,7 +72,7 @@ Gfx *func0f0d479c(Gfx *gdl)
|
|||
-(f32) viGetHeight() * 0.5f, viGetHeight() * 0.5f,
|
||||
10, 10000, 1);
|
||||
|
||||
mtx00016054(&mtx, mtx1);
|
||||
mtxF2L(&mtx, mtx1);
|
||||
mtx00016784();
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx2), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
|
@ -160,7 +160,7 @@ Gfx *func0f0d4a3c(Gfx *gdl, s32 arg1)
|
|||
gDPSetTexturePersp(gdl++, G_TP_PERSP);
|
||||
|
||||
func0f0d4690(&mtx);
|
||||
mtx00016054(&mtx, mtxptr);
|
||||
mtxF2L(&mtx, mtxptr);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtxptr), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ Gfx *func0f0d4c80(Gfx *gdl)
|
|||
func0f0d4690(&mtx);
|
||||
mtx00015df0(0.1f, &mtx);
|
||||
mtx00015e4c(0.1f, &mtx);
|
||||
mtx00016054(&mtx, mtxptr);
|
||||
mtxF2L(&mtx, mtxptr);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtxptr), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ Gfx *shardsRenderWood(Gfx *gdl)
|
|||
&& shardmtx.m[3][2] < 10000 && shardmtx.m[3][2] > -10000)
|
||||
#endif
|
||||
{
|
||||
mtx00016054(&shardmtx, mtx);
|
||||
mtxF2L(&shardmtx, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ Gfx *shardsRenderGlass(Gfx *gdl)
|
|||
&& shardmtx.m[3][2] < 10000 && shardmtx.m[3][2] > -10000)
|
||||
#endif
|
||||
{
|
||||
mtx00016054(&shardmtx, mtx);
|
||||
mtxF2L(&shardmtx, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -632,9 +632,9 @@ Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool xlupass)
|
|||
}
|
||||
|
||||
if (roomnum != -1) {
|
||||
coord = roomGetPos(roomnum);
|
||||
coord = roomGetPosPtr(roomnum);
|
||||
|
||||
room0f166df0(roomnum, &worldoffset);
|
||||
roomGetPos(roomnum, &worldoffset);
|
||||
|
||||
if (smoke->parts[0].size > 0) {
|
||||
f32 x = smoke->parts[0].pos.x - worldoffset.x;
|
||||
|
|
@ -655,7 +655,7 @@ Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool xlupass)
|
|||
gSPClearGeometryMode(gdl++, G_CULL_BOTH | G_FOG);
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(camGetOrthogonalMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
|
||||
if (near) {
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(&var800a3448), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ Gfx *sparksRender(Gfx *gdl)
|
|||
mtx00015be0(camGetWorldToScreenMtxf(), &spd4);
|
||||
|
||||
mtx = gfxAllocateMatrix();
|
||||
mtx00016054(&spd4, mtx);
|
||||
mtxF2L(&spd4, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -898,7 +898,7 @@ Gfx *titleRenderPdLogoModel(Gfx *gdl, struct model *model, bool arg2, f32 arg3,
|
|||
|
||||
for (j = 0, k = 0; j < model->filedata->nummatrices; j++, k += sizeof(Mtxf)) {
|
||||
mtx4Copy((Mtxf *)((u32)model->matrices + k), &sp6c);
|
||||
mtx00016054(&sp6c, model->matrices + j);
|
||||
mtxF2L(&sp6c, model->matrices + j);
|
||||
}
|
||||
|
||||
return gdl;
|
||||
|
|
@ -2560,7 +2560,7 @@ glabel var7f1a8ff4jf
|
|||
/* f01952c: 27a40158 */ addiu $a0,$sp,0x158
|
||||
/* f019530: 8dd9000c */ lw $t9,0xc($t6)
|
||||
/* f019534: 0002c180 */ sll $t8,$v0,0x6
|
||||
/* f019538: 0c0057fd */ jal mtx00016054
|
||||
/* f019538: 0c0057fd */ jal mtxF2L
|
||||
/* f01953c: 03382821 */ addu $a1,$t9,$t8
|
||||
/* f019540: 3c038006 */ lui $v1,%hi(g_TitleModelJpnLogo2)
|
||||
/* f019544: 8c6323f8 */ lw $v1,%lo(g_TitleModelJpnLogo2)($v1)
|
||||
|
|
@ -2862,7 +2862,7 @@ glabel var7f1a8ff4jf
|
|||
/* f0199a0: 27a400f4 */ addiu $a0,$sp,0xf4
|
||||
/* f0199a4: 8dd9000c */ lw $t9,0xc($t6)
|
||||
/* f0199a8: 0002c180 */ sll $t8,$v0,0x6
|
||||
/* f0199ac: 0c0057fd */ jal mtx00016054
|
||||
/* f0199ac: 0c0057fd */ jal mtxF2L
|
||||
/* f0199b0: 03382821 */ addu $a1,$t9,$t8
|
||||
/* f0199b4: 3c038006 */ lui $v1,%hi(g_TitleModelJpnPd)
|
||||
/* f0199b8: 8c6323fc */ lw $v1,%lo(g_TitleModelJpnPd)($v1)
|
||||
|
|
@ -2966,7 +2966,7 @@ glabel var7f1a8ff4jf
|
|||
/* f019b38: 27a4005c */ addiu $a0,$sp,0x5c
|
||||
/* f019b3c: 8dee000c */ lw $t6,0xc($t7)
|
||||
/* f019b40: 0002c980 */ sll $t9,$v0,0x6
|
||||
/* f019b44: 0c0057fd */ jal mtx00016054
|
||||
/* f019b44: 0c0057fd */ jal mtxF2L
|
||||
/* f019b48: 01d92821 */ addu $a1,$t6,$t9
|
||||
/* f019b4c: 3c038006 */ lui $v1,%hi(g_TitleModelJpnLogo1)
|
||||
/* f019b50: 8c6323f4 */ lw $v1,%lo(g_TitleModelJpnLogo1)($v1)
|
||||
|
|
@ -7589,7 +7589,7 @@ Gfx *titleRenderPdLogo(Gfx *gdl)
|
|||
|
||||
for (sp19c = 0, j = 0; sp19c < g_TitleModelJpnLogo2->filedata->nummatrices; sp19c++, j += sizeof(Mtxf)) {
|
||||
mtx4Copy((Mtxf *)((u32)g_TitleModelJpnLogo2->matrices + j), &sp158);
|
||||
mtx00016054(&sp158, g_TitleModelJpnLogo2->matrices + sp19c);
|
||||
mtxF2L(&sp158, g_TitleModelJpnLogo2->matrices + sp19c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7650,7 +7650,7 @@ Gfx *titleRenderPdLogo(Gfx *gdl)
|
|||
|
||||
for (sp14c = 0, j = 0; sp14c < g_TitleModelJpnPd->filedata->nummatrices; sp14c++, j += sizeof(Mtxf)) {
|
||||
mtx4Copy((Mtxf *)((u32)g_TitleModelJpnPd->matrices + j), &spf4);
|
||||
mtx00016054(&spf4, g_TitleModelJpnPd->matrices + sp14c);
|
||||
mtxF2L(&spf4, g_TitleModelJpnPd->matrices + sp14c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7684,7 +7684,7 @@ Gfx *titleRenderPdLogo(Gfx *gdl)
|
|||
|
||||
for (sp9c = 0, j = 0; sp9c < g_TitleModelJpnLogo1->filedata->nummatrices; sp9c++, j += sizeof(Mtxf)) {
|
||||
mtx4Copy((Mtxf *)((u32)g_TitleModelJpnLogo1->matrices + j), &sp5c);
|
||||
mtx00016054(&sp5c, g_TitleModelJpnLogo1->matrices + sp9c);
|
||||
mtxF2L(&sp5c, g_TitleModelJpnLogo1->matrices + sp9c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8010,7 +8010,7 @@ Gfx *titleRenderNintendoLogo(Gfx *gdl)
|
|||
|
||||
for (i = 0, j = 0; i < g_TitleModel->filedata->nummatrices; i++, j += sizeof(Mtxf)) {
|
||||
mtx4Copy((Mtxf *)((u32)g_TitleModel->matrices + j), &sp54);
|
||||
mtx00016054(&sp54, g_TitleModel->matrices + i);
|
||||
mtxF2L(&sp54, g_TitleModel->matrices + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -8257,7 +8257,7 @@ Gfx *titleRenderRareLogo(Gfx *gdl)
|
|||
for (i = 0, j = 0; i < g_TitleModel->filedata->nummatrices; i++, j += sizeof(Mtxf)) {
|
||||
Mtxf sp58;
|
||||
mtx4Copy((Mtxf *)((u32)g_TitleModel->matrices + j), &sp58);
|
||||
mtx00016054(&sp58, g_TitleModel->matrices + i);
|
||||
mtxF2L(&sp58, g_TitleModel->matrices + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1587,7 +1587,7 @@ void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct co
|
|||
obj->hidden2 |= OBJH2FLAG_HASOPA;
|
||||
}
|
||||
} else {
|
||||
struct coord *roompos = roomGetPos(room);
|
||||
struct coord *roompos = roomGetPosPtr(room);
|
||||
|
||||
if (arg2 != NULL) {
|
||||
f32 xdist = arg2->x - relpos->x;
|
||||
|
|
@ -1841,7 +1841,7 @@ Gfx *wallhitRenderOpaBgHits(s32 roomnum, Gfx *gdl)
|
|||
prevtexturenum = -1;
|
||||
prev6b = -1;
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
|
||||
wallhit = g_Rooms[roomnum].opawallhits;
|
||||
|
||||
|
|
@ -1903,7 +1903,7 @@ Gfx *wallhitRenderXluBgHits(s32 roomnum, Gfx *gdl)
|
|||
prevtexturenum = -1;
|
||||
prev6b = -1;
|
||||
|
||||
gdl = roomPushMtx(gdl, roomnum);
|
||||
gdl = roomApplyMtx(gdl, roomnum);
|
||||
|
||||
wallhit = g_Rooms[roomnum].xluwallhits;
|
||||
|
||||
|
|
|
|||
|
|
@ -967,7 +967,7 @@ glabel var7f1b5780
|
|||
/* f1330a4: e7b40200 */ swc1 $f20,0x200($sp)
|
||||
/* f1330a8: 00408825 */ or $s1,$v0,$zero
|
||||
/* f1330ac: 02002025 */ or $a0,$s0,$zero
|
||||
/* f1330b0: 0c005815 */ jal mtx00016054
|
||||
/* f1330b0: 0c005815 */ jal mtxF2L
|
||||
/* f1330b4: 00402825 */ or $a1,$v0,$zero
|
||||
/* f1330b8: 8fb00de8 */ lw $s0,0xde8($sp)
|
||||
/* f1330bc: 3c0d0102 */ lui $t5,0x102
|
||||
|
|
@ -2605,7 +2605,7 @@ Gfx *weatherRenderRain(Gfx *gdl, struct weatherdata *weather, s32 arg2)
|
|||
|
||||
mtx = gfxAllocateMatrix();
|
||||
|
||||
mtx00016054(&sp1c8, mtx);
|
||||
mtxF2L(&sp1c8, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
@ -3240,7 +3240,7 @@ glabel var7f1b5790
|
|||
/* f1348ac: e7b40204 */ swc1 $f20,0x204($sp)
|
||||
/* f1348b0: 00408825 */ or $s1,$v0,$zero
|
||||
/* f1348b4: 02002025 */ or $a0,$s0,$zero
|
||||
/* f1348b8: 0c005815 */ jal mtx00016054
|
||||
/* f1348b8: 0c005815 */ jal mtxF2L
|
||||
/* f1348bc: 00402825 */ or $a1,$v0,$zero
|
||||
/* f1348c0: 8fb01398 */ lw $s0,0x1398($sp)
|
||||
/* f1348c4: 3c190102 */ lui $t9,0x102
|
||||
|
|
@ -4660,7 +4660,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2)
|
|||
|
||||
mtx = gfxAllocateMatrix();
|
||||
|
||||
mtx00016054(&sp1cc, mtx);
|
||||
mtxF2L(&sp1cc, mtx);
|
||||
|
||||
gSPMatrix(gdl++, osVirtualToPhysical(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
|
|
|
|||
|
|
@ -231,11 +231,11 @@ extern s32 g_BgLightsOffsetChecksum;
|
|||
extern u32 g_FogEnabled;
|
||||
extern u32 var800a65e4;
|
||||
extern struct coord *var800a65e8;
|
||||
extern u8 *var800a6660;
|
||||
extern s16 *var800a6664;
|
||||
extern s16 *var800a6668;
|
||||
extern f32 *var800a666c;
|
||||
extern Mtxf *var800a6670;
|
||||
extern u8 *g_RoomMtxAges;
|
||||
extern s16 *g_RoomMtxLinkedRooms;
|
||||
extern s16 *g_RoomMtxBaseRooms;
|
||||
extern f32 *g_RoomMtxScales;
|
||||
extern Mtxf *g_RoomMtxMatrices;
|
||||
extern struct fileinfo g_FileInfo[NUM_FILES];
|
||||
extern u8 *g_VtxBuffers[3];
|
||||
extern u8 *g_GfxMemPos;
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ extern u16 var8007fc3c;
|
|||
extern s32 g_NumPortalThings;
|
||||
extern f32 var8007fcb4;
|
||||
extern struct stagetableentry g_Stages[61];
|
||||
extern s32 var80082050;
|
||||
extern s32 g_RoomMtxNumSlots;
|
||||
extern u32 g_GfxNumSwaps;
|
||||
extern s32 g_NumReasonsToEndMpMatch;
|
||||
extern s32 g_MusicEventQueueLength;
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ void roomsReset(void);
|
|||
void roomsTick(void);
|
||||
|
||||
void roomSetLastForOffset(s32 room);
|
||||
void room0f1668f0(s32 index, s32 roomnum);
|
||||
void room0f16692c(s32 index, s32 roomnum);
|
||||
void room0f16696c(s32 index);
|
||||
s32 room0f1669fc(void);
|
||||
void room0f166a6c(Mtxf *matrix, s32 roomnum);
|
||||
s32 room0f166c20(s32 roomnum);
|
||||
Gfx *roomPushMtx(Gfx *gdl, s32 roomnum);
|
||||
struct coord *roomGetPos(s32 room);
|
||||
void room0f166df0(s32 room, struct coord *globaldrawworldoffset);
|
||||
void roomLinkMtx(s32 index, s32 roomnum);
|
||||
void roomUnlinkMtx(s32 index, s32 roomnum);
|
||||
void roomFreeMtx(s32 index);
|
||||
s32 roomAllocateMtx(void);
|
||||
void roomPopulateMtx(Mtxf *matrix, s32 roomnum);
|
||||
s32 roomTouchMtx(s32 roomnum);
|
||||
Gfx *roomApplyMtx(Gfx *gdl, s32 roomnum);
|
||||
struct coord *roomGetPosPtr(s32 room);
|
||||
void roomGetPos(s32 room, struct coord *pos);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void mtx00015f04(f32 scale, Mtxf *arg1);
|
|||
void mtx00015f4c(f32 scale, Mtxf *arg1);
|
||||
void mtx00015f88(f32 arg0, Mtxf *arg1);
|
||||
u32 mtxGetObfuscatedRomBase(void);
|
||||
void mtx00016054(Mtxf *mtx, Mtxf *arg1);
|
||||
void mtxF2L(Mtxf *src, Mtxf *dst);
|
||||
void mtx00016110(f32 mtx1[3][3], f32 mtx2[3][3]);
|
||||
void mtx00016140(f32 mtx1[3][3], f32 mtx2[3][3], f32 dst[3][3]);
|
||||
void mtx000161b0(f32 arg0[3][3], f32 src[3], f32 dest[3]);
|
||||
|
|
|
|||
|
|
@ -3597,7 +3597,7 @@ struct room {
|
|||
/*0x0a*/ u16 lightindex; // index of start of this room's lights in data file
|
||||
/*0x0c*/ u16 firstwaypoint; // offset into g_Vars.waypoints
|
||||
/*0x0e*/ s16 roomportallistoffset;
|
||||
/*0x10*/ s16 unk10;
|
||||
/*0x10*/ s16 roommtxindex;
|
||||
/*0x14*/ struct roomgfxdata *gfxdata;
|
||||
/*0x18*/ f32 bbmin[3];
|
||||
/*0x24*/ f32 bbmax[3];
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ glabel mtxGetObfuscatedRomBase
|
|||
jr $ra
|
||||
addiu $sp, $sp, 0x20
|
||||
|
||||
glabel mtx00016054
|
||||
glabel mtxF2L
|
||||
lui $t2, %hi(var8005ef10)
|
||||
addiu $t2, $t2, %lo(var8005ef10)
|
||||
addiu $t0, $zero, 0x4
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ u32 mtxGetObfuscatedRomBase(void)
|
|||
return value;
|
||||
}
|
||||
|
||||
void mtx00016054(Mtxf *src, Mtxf *dst)
|
||||
void mtxF2L(Mtxf *src, Mtxf *dst)
|
||||
{
|
||||
u32 src00 = (s32) (src->m[0][0] * var8005ef10[0]);
|
||||
u32 src01 = (s32) (src->m[0][1] * var8005ef10[0]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue