Create functionally equivalent C for handwritten mtxF2LBulk

This commit is contained in:
Ryan Dwyer 2022-11-18 23:29:25 +10:00
parent 9c7ba4da9d
commit c77f81ace1
15 changed files with 82 additions and 33 deletions

View File

@ -117,7 +117,7 @@
build/ROMID/game/camera.o (section); \
build/ROMID/game/portal.o (section); \
build/ROMID/game/player.o (section); \
build/ROMID/game/game_0c33f0.o (section); \
build/ROMID/game/mtxf2lbulkasm.o (section); \
build/ROMID/game/bondcutscene.o (section); \
build/ROMID/game/bondwalk.o (section); \
build/ROMID/game/bondmove.o (section); \

View File

@ -117,7 +117,7 @@
build/ROMID/game/camera.o (section); \
build/ROMID/game/portal.o (section); \
build/ROMID/game/player.o (section); \
build/ROMID/game/game_0c33f0.o (section); \
build/ROMID/game/mtxf2lbulkasm.o (section); \
build/ROMID/game/bondcutscene.o (section); \
build/ROMID/game/bondwalk.o (section); \
build/ROMID/game/bondmove.o (section); \

View File

@ -117,7 +117,7 @@
build/ROMID/game/camera.o (section); \
build/ROMID/game/portal.o (section); \
build/ROMID/game/player.o (section); \
build/ROMID/game/game_0c33f0.o (section); \
build/ROMID/game/mtxf2lbulkasm.o (section); \
build/ROMID/game/bondcutscene.o (section); \
build/ROMID/game/bondwalk.o (section); \
build/ROMID/game/bondmove.o (section); \

View File

@ -117,7 +117,7 @@
build/ROMID/game/camera.o (section); \
build/ROMID/game/portal.o (section); \
build/ROMID/game/player.o (section); \
build/ROMID/game/game_0c33f0.o (section); \
build/ROMID/game/mtxf2lbulkasm.o (section); \
build/ROMID/game/bondcutscene.o (section); \
build/ROMID/game/bondwalk.o (section); \
build/ROMID/game/bondmove.o (section); \

View File

@ -117,7 +117,7 @@
build/ROMID/game/camera.o (section); \
build/ROMID/game/portal.o (section); \
build/ROMID/game/player.o (section); \
build/ROMID/game/game_0c33f0.o (section); \
build/ROMID/game/mtxf2lbulkasm.o (section); \
build/ROMID/game/bondcutscene.o (section); \
build/ROMID/game/bondwalk.o (section); \
build/ROMID/game/bondmove.o (section); \

View File

@ -21,7 +21,7 @@
#include "game/tex.h"
#include "game/camera.h"
#include "game/player.h"
#include "game/game_0c33f0.h"
#include "game/mtxf2lbulk.h"
#include "game/gfxmemory.h"
#include "game/sight.h"
#include "game/inv.h"
@ -8866,7 +8866,7 @@ glabel var7f1aca90
/* f0a7978: 8fa60098 */ lw $a2,0x98($sp)
/* f0a797c: 8ccb0008 */ lw $t3,0x8($a2)
/* f0a7980: 8cc4000c */ lw $a0,0xc($a2)
/* f0a7984: 0fc30cfc */ jal func0f0c33f0
/* f0a7984: 0fc30cfc */ jal mtxF2LBulk
/* f0a7988: 8565000e */ lh $a1,0xe($t3)
/* f0a798c: 8e0d021c */ lw $t5,0x21c($s0)
/* f0a7990: 51a00003 */ beqzl $t5,.L0f0a79a0
@ -9025,7 +9025,7 @@ glabel var7f1aca90
.L0f0a7bbc:
/* f0a7bbc: 8e18038c */ lw $t8,0x38c($s0)
/* f0a7bc0: 8e040390 */ lw $a0,0x390($s0)
/* f0a7bc4: 0fc30cfc */ jal func0f0c33f0
/* f0a7bc4: 0fc30cfc */ jal mtxF2LBulk
/* f0a7bc8: 8705000e */ lh $a1,0xe($t8)
/* f0a7bcc: 0c0059e1 */ jal mtx00016784
/* f0a7bd0: 00000000 */ nop
@ -9707,7 +9707,7 @@ glabel var7f1aca90
/* f0a7978: 8fa60098 */ lw $a2,0x98($sp)
/* f0a797c: 8ccb0008 */ lw $t3,0x8($a2)
/* f0a7980: 8cc4000c */ lw $a0,0xc($a2)
/* f0a7984: 0fc30cfc */ jal func0f0c33f0
/* f0a7984: 0fc30cfc */ jal mtxF2LBulk
/* f0a7988: 8565000e */ lh $a1,0xe($t3)
/* f0a798c: 8e0d021c */ lw $t5,0x21c($s0)
/* f0a7990: 51a00003 */ beqzl $t5,.L0f0a79a0
@ -9866,7 +9866,7 @@ glabel var7f1aca90
.L0f0a7bbc:
/* f0a7bbc: 8e18038c */ lw $t8,0x38c($s0)
/* f0a7bc0: 8e040390 */ lw $a0,0x390($s0)
/* f0a7bc4: 0fc30cfc */ jal func0f0c33f0
/* f0a7bc4: 0fc30cfc */ jal mtxF2LBulk
/* f0a7bc8: 8705000e */ lh $a1,0xe($t8)
/* f0a7bcc: 0c0059e1 */ jal mtx00016784
/* f0a7bd0: 00000000 */ nop
@ -10540,7 +10540,7 @@ glabel var7f1aca90
/* f0a56a4: 8fa60090 */ lw $a2,0x90($sp)
/* f0a56a8: 8cc80008 */ lw $t0,0x8($a2)
/* f0a56ac: 8cc4000c */ lw $a0,0xc($a2)
/* f0a56b0: 0fc303f0 */ jal func0f0c33f0
/* f0a56b0: 0fc303f0 */ jal mtxF2LBulk
/* f0a56b4: 8505000e */ lh $a1,0xe($t0)
/* f0a56b8: 8e0a021c */ lw $t2,0x21c($s0)
/* f0a56bc: 51400003 */ beqzl $t2,.NB0f0a56cc
@ -10698,7 +10698,7 @@ glabel var7f1aca90
.NB0f0a58e8:
/* f0a58e8: 8e0b038c */ lw $t3,0x38c($s0)
/* f0a58ec: 8e040390 */ lw $a0,0x390($s0)
/* f0a58f0: 0fc303f0 */ jal func0f0c33f0
/* f0a58f0: 0fc303f0 */ jal mtxF2LBulk
/* f0a58f4: 8565000e */ lh $a1,0xe($t3)
/* f0a58f8: 0c005dc5 */ jal mtx00016784
/* f0a58fc: 00000000 */ sll $zero,$zero,0x0
@ -10962,7 +10962,7 @@ void bgunRender(Gfx **gdlptr)
modelRender(&renderdata, rocketmodel);
func0f0c33f0(rocketmodel->matrices, rocketmodel->filedata->nummatrices);
mtxF2LBulk(rocketmodel->matrices, rocketmodel->filedata->nummatrices);
if (hand->firedrocket) {
hand->rocket = NULL;
@ -10973,7 +10973,7 @@ void bgunRender(Gfx **gdlptr)
#else
modelRender(&renderdata, rocketmodel);
func0f0c33f0(rocketmodel->matrices, rocketmodel->filedata->nummatrices);
mtxF2LBulk(rocketmodel->matrices, rocketmodel->filedata->nummatrices);
if (hand->firedrocket) {
hand->rocket = NULL;
@ -11039,7 +11039,7 @@ void bgunRender(Gfx **gdlptr)
gSPClearGeometryMode(gdl++, G_CULL_BOTH);
}
func0f0c33f0(hand->gunmodel.matrices, hand->gunmodel.filedata->nummatrices);
mtxF2LBulk(hand->gunmodel.matrices, hand->gunmodel.filedata->nummatrices);
mtx00016784();
gSPPerspNormalize(gdl++, viGetPerspScale());

View File

@ -18,7 +18,7 @@
#include "game/tex.h"
#include "game/camera.h"
#include "game/player.h"
#include "game/game_0c33f0.h"
#include "game/mtxf2lbulk.h"
#include "game/playermgr.h"
#include "game/rng2.h"
#include "game/vtxstore.h"
@ -3258,7 +3258,7 @@ void chrRenderAttachedObject(struct prop *prop, struct modelrenderdata *renderda
}
if (xlupass) {
func0f0c33f0(model->matrices, model->filedata->nummatrices);
mtxF2LBulk(model->matrices, model->filedata->nummatrices);
}
}
}
@ -3609,7 +3609,7 @@ Gfx *chrRender(struct prop *prop, Gfx *gdl, bool xlupass)
}
}
func0f0c33f0(model->matrices, model->filedata->nummatrices);
mtxF2LBulk(model->matrices, model->filedata->nummatrices);
if (USINGDEVICE(DEVICE_IRSCANNER)) {
gdl = chrRenderShield(gdl, chr, 0x80);

View File

@ -6,7 +6,7 @@
#include "game/game_0b0fd0.h"
#include "game/tex.h"
#include "game/camera.h"
#include "game/game_0c33f0.h"
#include "game/mtxf2lbulk.h"
#include "game/gfxmemory.h"
#include "game/file.h"
#include "bss.h"
@ -2015,7 +2015,7 @@ void casingRender(struct casing *casing, Gfx **gdlptr)
*gdlptr = renderdata.gdl;
func0f0c33f0(matrices, modeldef->nummatrices);
mtxF2LBulk(matrices, modeldef->nummatrices);
}
}

49
src/game/mtxf2lbulk.c Normal file
View File

@ -0,0 +1,49 @@
#include <ultra64.h>
#include "constants.h"
#include "bss.h"
#include "lib/rng.h"
#include "data.h"
#include "types.h"
void mtxF2LBulk(Mtxf *mtx, s32 count)
{
do {
u32 m00 = (s32) (mtx->m[0][0] * var8005ef10[0]);
u32 m01 = (s32) (mtx->m[0][1] * var8005ef10[0]);
u32 m02 = (s32) (mtx->m[0][2] * var8005ef10[0]);
u32 m03 = (s32) (mtx->m[0][3] * var8005ef10[1]);
u32 m10 = (s32) (mtx->m[1][0] * var8005ef10[0]);
u32 m11 = (s32) (mtx->m[1][1] * var8005ef10[0]);
u32 m12 = (s32) (mtx->m[1][2] * var8005ef10[0]);
u32 m13 = (s32) (mtx->m[1][3] * var8005ef10[1]);
u32 m20 = (s32) (mtx->m[2][0] * var8005ef10[0]);
u32 m21 = (s32) (mtx->m[2][1] * var8005ef10[0]);
u32 m22 = (s32) (mtx->m[2][2] * var8005ef10[0]);
u32 m23 = (s32) (mtx->m[2][3] * var8005ef10[1]);
u32 m30 = (s32) (mtx->m[3][0] * var8005ef10[0]);
u32 m31 = (s32) (mtx->m[3][1] * var8005ef10[0]);
u32 m32 = (s32) (mtx->m[3][2] * var8005ef10[0]);
u32 m33 = (s32) (mtx->m[3][3] * var8005ef10[1]);
mtx->l[0][0] = (m00 & 0xffff0000 | m01 >> 16);
mtx->l[0][1] = (m02 & 0xffff0000 | m03 >> 16);
mtx->l[0][2] = (m10 & 0xffff0000 | m11 >> 16);
mtx->l[0][3] = (m12 & 0xffff0000 | m13 >> 16);
mtx->l[1][0] = (m20 & 0xffff0000 | m21 >> 16);
mtx->l[1][1] = (m22 & 0xffff0000 | m23 >> 16);
mtx->l[1][2] = (m30 & 0xffff0000 | m31 >> 16);
mtx->l[1][3] = (m32 & 0xffff0000 | m33 >> 16);
mtx->l[2][0] = (m00 << 16 | m01 & 0xffff);
mtx->l[2][1] = (m02 << 16 | m03 & 0xffff);
mtx->l[2][2] = (m10 << 16 | m11 & 0xffff);
mtx->l[2][3] = (m12 << 16 | m13 & 0xffff);
mtx->l[3][0] = (m20 << 16 | m21 & 0xffff);
mtx->l[3][1] = (m22 << 16 | m23 & 0xffff);
mtx->l[3][2] = (m30 << 16 | m31 & 0xffff);
mtx->l[3][3] = (m32 << 16 | m33 & 0xffff);
mtx++;
count--;
} while (count);
}

View File

@ -5,7 +5,7 @@
.text
glabel func0f0c33f0
glabel mtxF2LBulk
lui $t0, %hi(var8005ef10)
addiu $t0, $t0, %lo(var8005ef10)
lui $t1, 0xffff

View File

@ -28,7 +28,7 @@
#include "game/camera.h"
#include "game/portal.h"
#include "game/player.h"
#include "game/game_0c33f0.h"
#include "game/mtxf2lbulk.h"
#include "game/hudmsg.h"
#include "game/menu.h"
#include "game/inv.h"
@ -14279,7 +14279,7 @@ void objRenderProp(struct prop *prop, struct modelrenderdata *renderdata, bool x
if (sp6c) {
player0f0c3320(model->matrices, model->filedata->nummatrices);
} else {
func0f0c33f0(model->matrices, model->filedata->nummatrices);
mtxF2LBulk(model->matrices, model->filedata->nummatrices);
}
if ((obj->flags3 & (OBJFLAG3_SHOWSHIELD | OBJFLAG3_SHIELDHIT)) && objIsHealthy(obj)) {

View File

@ -17,7 +17,6 @@
#include "game/tex.h"
#include "game/camera.h"
#include "game/player.h"
#include "game/game_0c33f0.h"
#include "game/playermgr.h"
#include "game/vtxstore.h"
#include "game/gfxmemory.h"

View File

@ -1,9 +0,0 @@
#ifndef _IN_GAME_GAME_0C33F0_H
#define _IN_GAME_GAME_0C33F0_H
#include <ultra64.h>
#include "data.h"
#include "types.h"
void func0f0c33f0(Mtxf *matrices, s32 count);
#endif

View File

@ -0,0 +1,9 @@
#ifndef _IN_GAME_MTXF2LBULK_H
#define _IN_GAME_MTXF2LBULK_H
#include <ultra64.h>
#include "data.h"
#include "types.h"
void mtxF2LBulk(Mtxf *matrices, s32 count);
#endif

View File

@ -21,6 +21,7 @@ typedef s32 PakErr2;
// aligned but still use the union for consistency with Mtx.
typedef union {
f32 m[4][4];
u32 l[4][4];
s32 unused;
} Mtxf;