4 More matches, and large struct changes (#469)

* Match func_8005698C and fix func_8001B7A8

* Larger update to match func_80032424 and change a couple of structs

* format

* Fix many warnings

* Matxh func_80014B50

* Format func_80014B50

* Racing Smokey!

* Match func_80053750

* Update score

* Fix some explicit casts
This commit is contained in:
Ryan Myers
2025-03-02 17:18:23 -05:00
committed by GitHub
parent 3209990c94
commit db602828c3
29 changed files with 1081 additions and 2549 deletions
+62 -55
View File
@@ -60,11 +60,11 @@ Vp gViewportStack[20] = {
};
ObjectTransform D_800DD288 = {
0, 0, 0, 0, 1.0f, 0.0f, 0.0f, -281.0f,
{ { { 0, 0, 0 } } }, 0, 1.0f, 0.0f, 0.0f, -281.0f,
};
ObjectTransform D_800DD2A0 = {
0, 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f,
{ { { 0, 0, 0 } } }, 0, 1.0f, 0.0f, 0.0f, 0.0f,
};
Matrix gOrthoMatrixF = {
@@ -248,16 +248,16 @@ void camera_init_tracks_menu(Gfx **dList, MatrixS **mtxS) {
set_active_viewports_and_max(0);
set_active_camera(0);
cam = get_active_camera_segment();
angleY = cam->trans.y_rotation;
angleX = cam->trans.x_rotation;
angleZ = cam->trans.z_rotation;
angleY = cam->trans.rotation.y_rotation;
angleX = cam->trans.rotation.x_rotation;
angleZ = cam->trans.rotation.z_rotation;
posX = cam->trans.x_position;
posY = cam->trans.y_position;
posZ = cam->trans.z_position;
sp24 = cam->camera.unk38;
cam->trans.z_rotation = 0;
cam->trans.x_rotation = 0;
cam->trans.y_rotation = -0x8000;
cam->trans.rotation.z_rotation = 0;
cam->trans.rotation.x_rotation = 0;
cam->trans.rotation.y_rotation = -0x8000;
cam->camera.unk38 = 0;
cam->trans.x_position = 0.0f;
cam->trans.y_position = 0.0f;
@@ -265,9 +265,9 @@ void camera_init_tracks_menu(Gfx **dList, MatrixS **mtxS) {
update_envmap_position(0.0f, 0.0f, -1.0f);
func_80066CDC(dList, mtxS);
cam->camera.unk38 = sp24;
cam->trans.y_rotation = angleY;
cam->trans.x_rotation = angleX;
cam->trans.z_rotation = angleZ;
cam->trans.rotation.y_rotation = angleY;
cam->trans.rotation.x_rotation = angleX;
cam->trans.rotation.z_rotation = angleZ;
cam->trans.x_position = posX;
cam->trans.y_position = posY;
cam->trans.z_position = posZ;
@@ -297,18 +297,18 @@ f32 get_distance_to_active_camera(f32 xPos, f32 yPos, f32 zPos) {
* Also sets the other properties of the camera to a default.
*/
void camera_reset(s32 xPos, s32 yPos, s32 zPos, s32 angleZ, s32 angleX, s32 angleY) {
gCameraSegment[gActiveCameraID].trans.z_rotation = (s16) (angleZ * 0xB6);
gCameraSegment[gActiveCameraID].trans.rotation.z_rotation = (s16) (angleZ * 0xB6);
gCameraSegment[gActiveCameraID].trans.x_position = (f32) xPos;
gCameraSegment[gActiveCameraID].trans.y_position = (f32) yPos;
gCameraSegment[gActiveCameraID].trans.z_position = (f32) zPos;
gCameraSegment[gActiveCameraID].trans.x_rotation = (s16) (angleX * 0xB6);
gCameraSegment[gActiveCameraID].trans.rotation.x_rotation = (s16) (angleX * 0xB6);
gCameraSegment[gActiveCameraID].camera.unk38 = 0;
gCameraSegment[gActiveCameraID].z_velocity = 0.0f;
gCameraSegment[gActiveCameraID].unk28 = 0.0f;
gCameraSegment[gActiveCameraID].camera.unk2C = 0.0f;
gCameraSegment[gActiveCameraID].camera.distanceToCamera = 0.0f;
gCameraSegment[gActiveCameraID].x_velocity = 160.0f;
gCameraSegment[gActiveCameraID].trans.y_rotation = (s16) (angleY * 0xB6);
gCameraSegment[gActiveCameraID].trans.rotation.y_rotation = (s16) (angleY * 0xB6);
gCameraSegment[gActiveCameraID].object.animationID = gCameraZoomLevels[gActiveCameraID];
}
@@ -323,9 +323,9 @@ void write_to_object_render_stack(s32 stackPos, f32 xPos, f32 yPos, f32 zPos, s1
gCameraSegment[stackPos].trans.x_position = xPos;
gCameraSegment[stackPos].trans.y_position = yPos;
gCameraSegment[stackPos].trans.z_position = zPos;
gCameraSegment[stackPos].trans.y_rotation = arg4;
gCameraSegment[stackPos].trans.x_rotation = arg5;
gCameraSegment[stackPos].trans.z_rotation = arg6;
gCameraSegment[stackPos].trans.rotation.y_rotation = arg4;
gCameraSegment[stackPos].trans.rotation.x_rotation = arg5;
gCameraSegment[stackPos].trans.rotation.z_rotation = arg6;
gCameraSegment[stackPos].object.cameraSegmentID = get_level_segment_index_from_position(xPos, yPos, zPos);
gCutsceneCameraActive = TRUE;
}
@@ -868,10 +868,10 @@ void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) {
gActiveCameraID += 4;
}
gCameraTransform.y_rotation = 0x8000 + gCameraSegment[gActiveCameraID].trans.y_rotation;
gCameraTransform.x_rotation =
gCameraSegment[gActiveCameraID].trans.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38;
gCameraTransform.z_rotation = gCameraSegment[gActiveCameraID].trans.z_rotation;
gCameraTransform.rotation.y_rotation = 0x8000 + gCameraSegment[gActiveCameraID].trans.rotation.y_rotation;
gCameraTransform.rotation.x_rotation =
gCameraSegment[gActiveCameraID].trans.rotation.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38;
gCameraTransform.rotation.z_rotation = gCameraSegment[gActiveCameraID].trans.rotation.z_rotation;
gCameraTransform.x_position = -gCameraSegment[gActiveCameraID].trans.x_position;
gCameraTransform.y_position = -gCameraSegment[gActiveCameraID].trans.y_position;
@@ -883,10 +883,10 @@ void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) {
object_transform_to_matrix_2(gCameraMatrixF, &gCameraTransform);
f32_matrix_mult(&gCameraMatrixF, &gPerspectiveMatrixF, &gViewMatrixF);
gCameraTransform.y_rotation = -0x8000 - gCameraSegment[gActiveCameraID].trans.y_rotation;
gCameraTransform.x_rotation =
-(gCameraSegment[gActiveCameraID].trans.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38);
gCameraTransform.z_rotation = -gCameraSegment[gActiveCameraID].trans.z_rotation;
gCameraTransform.rotation.y_rotation = -0x8000 - gCameraSegment[gActiveCameraID].trans.rotation.y_rotation;
gCameraTransform.rotation.x_rotation =
-(gCameraSegment[gActiveCameraID].trans.rotation.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38);
gCameraTransform.rotation.z_rotation = -gCameraSegment[gActiveCameraID].trans.rotation.z_rotation;
gCameraTransform.scale = 1.0f;
gCameraTransform.x_position = gCameraSegment[gActiveCameraID].trans.x_position;
gCameraTransform.y_position = gCameraSegment[gActiveCameraID].trans.y_position;
@@ -1053,8 +1053,8 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj
diffX = gModelMatrixViewX[gCameraMatrixPos] - obj->segment.trans.x_position;
diffY = gModelMatrixViewY[gCameraMatrixPos] - obj->segment.trans.y_position;
diffZ = gModelMatrixViewZ[gCameraMatrixPos] - obj->segment.trans.z_position;
sineY = sins_f(obj->segment.trans.y_rotation);
cosY = coss_f(obj->segment.trans.y_rotation);
sineY = sins_f(obj->segment.trans.rotation.y_rotation);
cosY = coss_f(obj->segment.trans.rotation.y_rotation);
sp44 = (diffX * cosY) + (diffZ * sineY);
diffZ = (diffZ * cosY) - (diffX * sineY);
tanY = arctan2_f(sp44, sqrtf((diffY * diffY) + (diffZ * diffZ)));
@@ -1081,9 +1081,9 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj
diffY = gModelMatrixViewY[gCameraMatrixPos] - obj->segment.trans.y_position;
diffZ = gModelMatrixViewZ[gCameraMatrixPos] - obj->segment.trans.z_position;
lateralDist = sqrtf((diffX * diffX) + (diffZ * diffZ));
gCameraTransform.y_rotation = arctan2_f(diffX, diffZ);
gCameraTransform.x_rotation = -arctan2_f(diffY, lateralDist);
gCameraTransform.z_rotation = angleDiff;
gCameraTransform.rotation.y_rotation = arctan2_f(diffX, diffZ);
gCameraTransform.rotation.x_rotation = -arctan2_f(diffY, lateralDist);
gCameraTransform.rotation.z_rotation = angleDiff;
gCameraTransform.scale = obj->segment.trans.scale;
gCameraTransform.x_position = obj->segment.trans.x_position;
gCameraTransform.y_position = obj->segment.trans.y_position;
@@ -1109,9 +1109,11 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj
gSPVertexDKR((*dlist)++, OS_PHYSICAL_TO_K0(*vertexList), 1, 0);
(*vertexList)++;
if (gCutsceneCameraActive == 0) {
angleDiff = gCameraSegment[gActiveCameraID].trans.z_rotation + obj->segment.trans.z_rotation;
angleDiff =
gCameraSegment[gActiveCameraID].trans.rotation.z_rotation + obj->segment.trans.rotation.z_rotation;
} else {
angleDiff = gCameraSegment[gActiveCameraID + 4].trans.z_rotation + obj->segment.trans.z_rotation;
angleDiff =
gCameraSegment[gActiveCameraID + 4].trans.rotation.z_rotation + obj->segment.trans.rotation.z_rotation;
}
textureFrame = obj->segment.animFrame;
gModelMatrixStackPos++;
@@ -1172,9 +1174,10 @@ void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, Objec
(*vtx)++; // Can't be done in the macro?
index = segment->animFrame;
gModelMatrixStackPos++;
gCameraTransform.y_rotation = -segment->trans.y_rotation;
gCameraTransform.x_rotation = -segment->trans.x_rotation;
gCameraTransform.z_rotation = gCameraSegment[gActiveCameraID].trans.z_rotation + segment->trans.z_rotation;
gCameraTransform.rotation.y_rotation = -segment->trans.rotation.y_rotation;
gCameraTransform.rotation.x_rotation = -segment->trans.rotation.x_rotation;
gCameraTransform.rotation.z_rotation =
gCameraSegment[gActiveCameraID].trans.rotation.z_rotation + segment->trans.rotation.z_rotation;
gCameraTransform.x_position = 0.0f;
gCameraTransform.y_position = 0.0f;
gCameraTransform.z_position = 0.0f;
@@ -1236,19 +1239,19 @@ void apply_object_shear_matrix(Gfx **dList, MatrixS **mtx, Object *arg2, Object
f32 arg3_zPos;
Matrix matrix_mult;
cossf_x_arg2 = coss_f(arg2->segment.trans.x_rotation);
sinsf_x_arg2 = sins_f(arg2->segment.trans.x_rotation);
cossf_y_arg2 = coss_f(arg2->segment.trans.y_rotation);
sinsf_y_arg2 = sins_f(arg2->segment.trans.y_rotation);
cossf_x_arg2 = coss_f(arg2->segment.trans.rotation.x_rotation);
sinsf_x_arg2 = sins_f(arg2->segment.trans.rotation.x_rotation);
cossf_y_arg2 = coss_f(arg2->segment.trans.rotation.y_rotation);
sinsf_y_arg2 = sins_f(arg2->segment.trans.rotation.y_rotation);
arg2_xPos = arg2->segment.trans.x_position;
arg2_yPos = arg2->segment.trans.y_position;
arg2_zPos = arg2->segment.trans.z_position;
cossf_z_arg3 = coss_f(arg3->segment.trans.z_rotation);
sinsf_z_arg3 = sins_f(arg3->segment.trans.z_rotation);
cossf_x_arg3 = coss_f(arg3->segment.trans.x_rotation);
sinsf_x_arg3 = sins_f(arg3->segment.trans.x_rotation);
cossf_y_arg3 = coss_f(arg3->segment.trans.y_rotation);
sinsf_y_arg3 = sins_f(arg3->segment.trans.y_rotation);
cossf_z_arg3 = coss_f(arg3->segment.trans.rotation.z_rotation);
sinsf_z_arg3 = sins_f(arg3->segment.trans.rotation.z_rotation);
cossf_x_arg3 = coss_f(arg3->segment.trans.rotation.x_rotation);
sinsf_x_arg3 = sins_f(arg3->segment.trans.rotation.x_rotation);
cossf_y_arg3 = coss_f(arg3->segment.trans.rotation.y_rotation);
sinsf_y_arg3 = sins_f(arg3->segment.trans.rotation.y_rotation);
arg3_xPos = arg3->segment.trans.x_position;
arg3_yPos = arg3->segment.trans.y_position;
arg3_zPos = arg3->segment.trans.z_position;
@@ -1352,9 +1355,9 @@ void camera_push_model_mtx(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f
tempX = gCameraSegment[index].trans.x_position - tempX;
tempY = gCameraSegment[index].trans.y_position - tempY;
tempZ = gCameraSegment[index].trans.z_position - tempZ;
gCameraTransform.y_rotation = -trans->y_rotation;
gCameraTransform.x_rotation = -trans->x_rotation;
gCameraTransform.z_rotation = -trans->z_rotation;
gCameraTransform.rotation.y_rotation = -trans->rotation.y_rotation;
gCameraTransform.rotation.x_rotation = -trans->rotation.x_rotation;
gCameraTransform.rotation.z_rotation = -trans->rotation.z_rotation;
gCameraTransform.x_position = 0.0f;
gCameraTransform.y_position = 0.0f;
gCameraTransform.z_position = 0.0f;
@@ -1472,10 +1475,14 @@ UNUSED void translate_camera_segment(f32 x, f32 y, f32 z) {
* Also recalculates which block it's in.
*/
UNUSED void transform_camera_segment(f32 x, UNUSED f32 y, f32 z) {
gCameraSegment[gActiveCameraID].trans.x_position -= x * coss_f(gCameraSegment[gActiveCameraID].trans.y_rotation);
gCameraSegment[gActiveCameraID].trans.z_position -= x * sins_f(gCameraSegment[gActiveCameraID].trans.y_rotation);
gCameraSegment[gActiveCameraID].trans.x_position -= z * sins_f(gCameraSegment[gActiveCameraID].trans.y_rotation);
gCameraSegment[gActiveCameraID].trans.z_position += z * coss_f(gCameraSegment[gActiveCameraID].trans.y_rotation);
gCameraSegment[gActiveCameraID].trans.x_position -=
x * coss_f(gCameraSegment[gActiveCameraID].trans.rotation.y_rotation);
gCameraSegment[gActiveCameraID].trans.z_position -=
x * sins_f(gCameraSegment[gActiveCameraID].trans.rotation.y_rotation);
gCameraSegment[gActiveCameraID].trans.x_position -=
z * sins_f(gCameraSegment[gActiveCameraID].trans.rotation.y_rotation);
gCameraSegment[gActiveCameraID].trans.z_position +=
z * coss_f(gCameraSegment[gActiveCameraID].trans.rotation.y_rotation);
gCameraSegment[gActiveCameraID].object.cameraSegmentID = get_level_segment_index_from_position(
gCameraSegment[gActiveCameraID].trans.x_position, gCameraSegment[gActiveCameraID].trans.y_position,
gCameraSegment[gActiveCameraID].trans.z_position);
@@ -1485,9 +1492,9 @@ UNUSED void transform_camera_segment(f32 x, UNUSED f32 y, f32 z) {
* Rotate the camera with the given angles.
*/
UNUSED void rotate_camera_segment(s32 angleX, s32 angleY, s32 angleZ) {
gCameraSegment[gActiveCameraID].trans.y_rotation += angleX;
gCameraSegment[gActiveCameraID].trans.x_rotation += angleY;
gCameraSegment[gActiveCameraID].trans.z_rotation += angleZ;
gCameraSegment[gActiveCameraID].trans.rotation.y_rotation += angleX;
gCameraSegment[gActiveCameraID].trans.rotation.x_rotation += angleY;
gCameraSegment[gActiveCameraID].trans.rotation.z_rotation += angleZ;
}
/**