diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index 656123454..f74d3de45 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -2411,7 +2411,7 @@ void setupHov(struct defaultobj *obj, struct hov *hov) hov->unk04 = 0; hov->unk08 = 0; hov->unk0c = 0; - hov->unk10 = atan2f(obj->realrot[6], obj->realrot[8]); + hov->unk10 = atan2f(obj->realrot[2][0], obj->realrot[2][2]); hov->unk14 = 0; hov->unk18 = 0; hov->unk1c = 0; @@ -3150,7 +3150,7 @@ void setupParseObjects(s32 stagenum) // resolved. sp1a8 is really an Mtxf which doesn't fit // in its current location in the stack. f32 sp1a8[12]; - f32 sp184[9]; + f32 sp184[3][3]; setupGenericObject(obj, index); diff --git a/src/game/game_091e10.c b/src/game/game_091e10.c index 2b2ca9131..953492aef 100644 --- a/src/game/game_091e10.c +++ b/src/game/game_091e10.c @@ -160,7 +160,7 @@ bool modelLoad(s32 propnum) return false; } -bool func0f09220c(struct defaultobj *obj, struct coord *pos, f32 *realrot, struct coord *arg3, struct coord *arg4) +bool func0f09220c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], struct coord *arg3, struct coord *arg4) { struct modelrodata_bbox *bbox = objFindBboxRodata(obj); @@ -184,7 +184,7 @@ bool func0f092304(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 return func0f09220c(obj, &obj->prop->pos, obj->realrot, arg1, arg2); } -void func0f09233c(struct defaultobj *obj, struct coord *pos, f32 *realrot, s16 *rooms) +void func0f09233c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], s16 *rooms) { struct coord a; struct coord b; diff --git a/src/game/propobj.c b/src/game/propobj.c index 796c4b8a5..fd782d363 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -646,34 +646,34 @@ f32 func0f0668cc(struct modelrodata_bbox *bbox, Mtxf *matrix) return func0f066abc(bbox, matrix->m[0][2], matrix->m[1][2], matrix->m[2][2]); } -f32 func0f0668fc(struct modelrodata_bbox *bbox, f32 *realrot) +f32 func0f0668fc(struct modelrodata_bbox *bbox, f32 realrot[3][3]) { - return func0f066a1c(bbox, realrot[0], realrot[3], realrot[6]); + return func0f066a1c(bbox, realrot[0][0], realrot[1][0], realrot[2][0]); } -f32 func0f06692c(struct modelrodata_bbox *bbox, f32 *realrot) +f32 func0f06692c(struct modelrodata_bbox *bbox, f32 realrot[3][3]) { - return func0f066abc(bbox, realrot[0], realrot[3], realrot[6]); + return func0f066abc(bbox, realrot[0][0], realrot[1][0], realrot[2][0]); } -f32 func0f06695c(struct modelrodata_bbox *bbox, f32 *realrot) +f32 func0f06695c(struct modelrodata_bbox *bbox, f32 realrot[3][3]) { - return func0f066a1c(bbox, realrot[1], realrot[4], realrot[7]); + return func0f066a1c(bbox, realrot[0][1], realrot[1][1], realrot[2][1]); } -f32 func0f06698c(struct modelrodata_bbox *bbox, f32 *realrot) +f32 func0f06698c(struct modelrodata_bbox *bbox, f32 realrot[3][3]) { - return func0f066abc(bbox, realrot[1], realrot[4], realrot[7]); + return func0f066abc(bbox, realrot[0][1], realrot[1][1], realrot[2][1]); } -f32 func0f0669bc(struct modelrodata_bbox *bbox, f32 *realrot) +f32 func0f0669bc(struct modelrodata_bbox *bbox, f32 realrot[3][3]) { - return func0f066a1c(bbox, realrot[2], realrot[5], realrot[8]); + return func0f066a1c(bbox, realrot[0][2], realrot[1][2], realrot[2][2]); } -f32 func0f0669ec(struct modelrodata_bbox *bbox, f32 *realrot) +f32 func0f0669ec(struct modelrodata_bbox *bbox, f32 realrot[3][3]) { - return func0f066abc(bbox, realrot[2], realrot[5], realrot[8]); + return func0f066abc(bbox, realrot[0][2], realrot[1][2], realrot[2][2]); } f32 func0f066a1c(struct modelrodata_bbox *bbox, f32 arg1, f32 arg2, f32 arg3) @@ -17485,7 +17485,7 @@ f32 objGetHov04(struct defaultobj *obj) return result; } -void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, s16 *rooms, f32 *matrix) +void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, s16 *rooms, f32 matrix[3][3]) { f32 ground; s16 testrooms[8]; @@ -35264,8 +35264,8 @@ void fanUpdateModel(struct prop *prop) { struct fanobj *fan = (struct fanobj *) prop->obj; Mtxf sp6c; - f32 sp48[9]; - f32 sp24[9]; + f32 sp48[3][3]; + f32 sp24[3][3]; f32 angle = fan->yspeed * g_Vars.lvupdate240freal; while (angle >= M_BADTAU) { @@ -60759,10 +60759,10 @@ void glassDestroy(struct defaultobj *obj) if (obj->modelnum == MODEL_AIVILLABOT1 || obj->modelnum == MODEL_AIVILLABOT2 || obj->modelnum == MODEL_AIVILLABOT3) { - shardsCreate(&prop->pos, &obj->realrot[0], &obj->realrot[3], &obj->realrot[6], + shardsCreate(&prop->pos, &obj->realrot[0][0], &obj->realrot[1][0], &obj->realrot[2][0], bbox->xmin, bbox->xmax, bbox->ymin, bbox->ymax, SHARDTYPE_BOTTLE, prop); } else { - shardsCreate(&prop->pos, &obj->realrot[0], &obj->realrot[3], &obj->realrot[6], + shardsCreate(&prop->pos, &obj->realrot[0][0], &obj->realrot[1][0], &obj->realrot[2][0], bbox->xmin, bbox->xmax, bbox->ymin, bbox->ymax, SHARDTYPE_GLASS, prop); } diff --git a/src/game/training/training.c b/src/game/training/training.c index 5fccf430a..2fea4a238 100644 --- a/src/game/training/training.c +++ b/src/game/training/training.c @@ -2075,7 +2075,7 @@ void frInitTargets(void) struct defaultobj *obj; struct pospad pospad; Mtxf sp144; - f32 sp108[9]; + f32 sp108[3][3]; for (i = 0; i < ARRAYCOUNT(g_FrData.targets); i++) { prop = g_FrData.targets[i].prop; diff --git a/src/include/game/game_091e10.h b/src/include/game/game_091e10.h index ddeed6257..54617bf25 100644 --- a/src/include/game/game_091e10.h +++ b/src/include/game/game_091e10.h @@ -9,9 +9,9 @@ u32 *setupGetPtrToCommandByIndex(s32 cmdindex); s32 tagGetCommandIndex(struct tag *tag); u32 setupGetCommandIndexByProp(struct prop *prop); bool modelLoad(s32 propnum); -bool func0f09220c(struct defaultobj *obj, struct coord *pos, f32 *realrot, struct coord *arg3, struct coord *arg4); +bool func0f09220c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], struct coord *arg3, struct coord *arg4); bool func0f092304(struct defaultobj *obj, struct coord *arg1, struct coord *arg2); -void func0f09233c(struct defaultobj *obj, struct coord *pos, f32 *realrot, s16 *rooms); +void func0f09233c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], s16 *rooms); void func0f0923d4(struct defaultobj *obj); struct defaultobj *setupCommandGetObject(u32 cmdindex); u32 func0f092484(void); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 125ad35d6..77b3181c2 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -43,12 +43,12 @@ u32 func0f06683c(void); u32 func0f06686c(void); u32 func0f06689c(void); f32 func0f0668cc(struct modelrodata_bbox *bbox, Mtxf *matrix); -f32 func0f0668fc(struct modelrodata_bbox *bbox, f32 *realrot); -f32 func0f06692c(struct modelrodata_bbox *bbox, f32 *realrot); -f32 func0f06695c(struct modelrodata_bbox *bbox, f32 *realrot); -f32 func0f06698c(struct modelrodata_bbox *bbox, f32 *realrot); -f32 func0f0669bc(struct modelrodata_bbox *bbox, f32 *realrot); -f32 func0f0669ec(struct modelrodata_bbox *bbox, f32 *realrot); +f32 func0f0668fc(struct modelrodata_bbox *bbox, f32 realrot[3][3]); +f32 func0f06692c(struct modelrodata_bbox *bbox, f32 realrot[3][3]); +f32 func0f06695c(struct modelrodata_bbox *bbox, f32 realrot[3][3]); +f32 func0f06698c(struct modelrodata_bbox *bbox, f32 realrot[3][3]); +f32 func0f0669bc(struct modelrodata_bbox *bbox, f32 realrot[3][3]); +f32 func0f0669ec(struct modelrodata_bbox *bbox, f32 realrot[3][3]); f32 func0f066a1c(struct modelrodata_bbox *bbox, f32 arg1, f32 arg2, f32 arg3); f32 func0f066abc(struct modelrodata_bbox *bbox, f32 arg1, f32 arg2, f32 arg3); u32 func0f066b5c(void); @@ -90,7 +90,7 @@ void func0f069144(struct prop *prop, u8 *nextcol, u16 floorcol); void func0f069630(struct prop *prop, u8 *nextcol, u16 floorcol); void colourTween(u8 *col, u8 *nextcol); void func0f069750(s32 *arg0, s32 arg1, f32 *arg2); -void func0f069850(struct defaultobj *obj, struct coord *pos, f32 *realrot, struct tiletype3 *geo); +void func0f069850(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], struct tiletype3 *geo); void func0f069b4c(struct defaultobj *obj); void func0f069c1c(struct defaultobj *obj); void func0f069c70(struct defaultobj *obj, bool arg1, bool arg2); @@ -145,7 +145,7 @@ f32 liftGetY(struct liftobj *lift); void func0f070f08(struct liftobj *lift, bool arg0); void liftGoToStop(struct liftobj *lift, s32 stopnum); f32 objGetHov04(struct defaultobj *obj); -void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, s16 *rooms, f32 *matrix); +void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, s16 *rooms, f32 matrix[3][3]); void func0f0714b8(struct defaultobj *obj, struct hov *hov); s32 objIsHoverpropOrBike(struct defaultobj *obj); f32 hoverpropGetTurnAngle(struct defaultobj *obj); diff --git a/src/include/lib/mtx.h b/src/include/lib/mtx.h index 41f954db1..1a54ae2aa 100644 --- a/src/include/lib/mtx.h +++ b/src/include/lib/mtx.h @@ -13,10 +13,10 @@ void mtx00015b64(Mtxf *arg0, struct coord *coord); void mtx00015b68(Mtxf *matrix, struct coord *arg1, struct coord *arg2); void mtx00015be0(Mtxf *matrix1, Mtxf *matrix2); void mtx00015be4(Mtxf *arg0, Mtxf *arg1, Mtxf *arg2); -void mtx00015cd8(f32 *arg0, f32 *realrot); +void mtx00015cd8(f32 arg0[3][3], f32 arg1[3][3]); void mtx00015d18(Mtxf *matrix, Mtxf *arg1); -void mtx00015d54(f32 *realrot, Mtxf *matrix); -void mtx00015da0(Mtxf *arg0, f32 *arg1); +void mtx00015d54(f32 realrot[3][3], Mtxf *matrix); +void mtx00015da0(Mtxf *arg0, f32 arg1[3][3]); void mtx00015dd4(struct coord *pos, Mtxf *matrix); void mtx00015df0(f32 arg0, Mtxf *matrix); void mtx00015e24(f32 mult, f32 *matrix); @@ -29,10 +29,10 @@ void mtx00015f4c(f32 scale, Mtxf *arg1); void mtx00015f88(f32 arg0, Mtxf *arg1); u32 mtxGetObfuscatedRomBase(void); void mtx00016054(Mtxf *matrix, Mtxf *arg1); -void mtx00016110(f32 *matrix1, f32 *matrix2); -void mtx00016140(f32 *realrot, f32 *arg1, f32 *arg2); -void mtx000161b0(f32 *matrix, f32 src[3], f32 dest[3]); -void mtx00016208(f32 *matrix, struct coord *coord); +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]); +void mtx00016208(f32 mtx[3][3], struct coord *coord); void mtx00016248(struct coord *coord, f32 angle, Mtxf *matrix); void mtx000162e8(f32 angle, Mtxf *matrix); void mtx00016374(f32 angle, Mtxf *matrix); diff --git a/src/include/types.h b/src/include/types.h index a4fcc09a8..b151d7ad0 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -1616,7 +1616,7 @@ struct defaultobj { /*0x10*/ u32 flags3; /*0x14*/ struct prop *prop; /*0x18*/ struct model *model; - /*0x1c*/ f32 realrot[9]; + /*0x1c*/ f32 realrot[3][3]; /*0x40*/ u32 hidden; union { /*0x44*/ struct tiletype1 *geo1; diff --git a/src/lib/mtx.c b/src/lib/mtx.c index 1dadadb97..5e4105299 100644 --- a/src/lib/mtx.c +++ b/src/lib/mtx.c @@ -17,62 +17,40 @@ const char var70055998nb[] = " )\n"; const u32 var70054200[] = {0x42652ee0}; -void mtx00016110(f32 *mtx1, f32 *mtx2) +void mtx00016110(f32 mtx1[3][3], f32 mtx2[3][3]) { - f32 mtx3[9]; + f32 mtx3[3][3]; mtx00016140(mtx1, mtx2, mtx3); mtx00015cd8(mtx3, mtx2); } -GLOBAL_ASM( -glabel mtx00016140 -/* 16140: 00001825 */ or $v1,$zero,$zero -/* 16144: 00804025 */ or $t0,$a0,$zero -/* 16148: 240a000c */ addiu $t2,$zero,0xc -/* 1614c: 24090003 */ addiu $t1,$zero,0x3 -.L00016150: -/* 16150: 00001025 */ or $v0,$zero,$zero -/* 16154: 00c32021 */ addu $a0,$a2,$v1 -/* 16158: 00a03825 */ or $a3,$a1,$zero -.L0001615c: -/* 1615c: c5120000 */ lwc1 $f18,0x0($t0) -/* 16160: c4f00000 */ lwc1 $f16,0x0($a3) -/* 16164: c50e000c */ lwc1 $f14,0xc($t0) -/* 16168: c4ec0004 */ lwc1 $f12,0x4($a3) -/* 1616c: 46109402 */ mul.s $f16,$f18,$f16 -/* 16170: c4f20008 */ lwc1 $f18,0x8($a3) -/* 16174: c50a0018 */ lwc1 $f10,0x18($t0) -/* 16178: 460c7302 */ mul.s $f12,$f14,$f12 -/* 1617c: 24420001 */ addiu $v0,$v0,0x1 -/* 16180: 2484000c */ addiu $a0,$a0,0xc -/* 16184: 460a9282 */ mul.s $f10,$f18,$f10 -/* 16188: 24e7000c */ addiu $a3,$a3,0xc -/* 1618c: 460c8300 */ add.s $f12,$f16,$f12 -/* 16190: 460c5300 */ add.s $f12,$f10,$f12 -/* 16194: 1449fff1 */ bne $v0,$t1,.L0001615c -/* 16198: e48cfff4 */ swc1 $f12,-0xc($a0) -/* 1619c: 24630004 */ addiu $v1,$v1,0x4 -/* 161a0: 146affeb */ bne $v1,$t2,.L00016150 -/* 161a4: 25080004 */ addiu $t0,$t0,0x4 -/* 161a8: 03e00008 */ jr $ra -/* 161ac: 00000000 */ nop -); +void mtx00016140(f32 mtx1[3][3], f32 mtx2[3][3], f32 dst[3][3]) +{ + s32 i; + s32 j; -void mtx000161b0(f32 *matrix, f32 src[3], f32 dest[3]) + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + dst[j][i] = mtx1[0][i] * mtx2[j][0] + mtx1[1][i] * mtx2[j][1] + mtx1[2][i] * mtx2[j][2]; + } + } +} + +void mtx000161b0(f32 mtx[3][3], f32 src[3], f32 dest[3]) { s32 i; for (i = 0; i < 3; i++) { - dest[i] = matrix[i] * src[0] + matrix[3 + i] * src[1] + matrix[6 + i] * src[2]; + dest[i] = mtx[0][i] * src[0] + mtx[1][i] * src[1] + mtx[2][i] * src[2]; } } -void mtx00016208(f32 *matrix, struct coord *coord) +void mtx00016208(f32 mtx[3][3], struct coord *coord) { f32 tmp[3]; - mtx000161b0(matrix, (f32 *)coord, tmp); + mtx000161b0(mtx, (f32 *)coord, tmp); coord->x = tmp[0]; coord->y = tmp[1];