summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-10-17 09:53:40 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-10-17 09:53:40 -0600
commit2cfbe01e50e65ff1ada5ba100eb73feac18524ae (patch)
tree039241c739eccbc456bedc54cd42061dab175dec /src
parentcd288a4c5b816ddad9a019d41ee2e442f169eba1 (diff)
Added frame interpolation markers
Diffstat (limited to 'src')
-rw-r--r--src/engine/fox_beam.c1
-rw-r--r--src/engine/fox_bg.c6
-rw-r--r--src/engine/fox_display.c9
-rw-r--r--src/engine/fox_edisplay.c17
-rw-r--r--src/engine/fox_effect.c1
-rw-r--r--src/engine/fox_std_lib.c2
-rw-r--r--src/overlays/ovl_menu/fox_i_menu.c1
-rw-r--r--src/port/interpolation/FrameInterpolation.cpp87
-rw-r--r--src/port/interpolation/FrameInterpolation.h19
-rw-r--r--src/sys/sys_lib.c2
-rw-r--r--src/sys/sys_main.c1
-rw-r--r--src/sys/sys_matrix.c31
12 files changed, 118 insertions, 59 deletions
diff --git a/src/engine/fox_beam.c b/src/engine/fox_beam.c
index 8a990226..62d2d39d 100644
--- a/src/engine/fox_beam.c
+++ b/src/engine/fox_beam.c
@@ -1504,6 +1504,7 @@ void PlayerShot_DrawShot(PlayerShot* shot) {
void PlayerShot_Draw(PlayerShot* shot) {
FrameInterpolation_RecordOpenChild(shot, 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
switch (shot->obj.status) {
case SHOT_ACTIVE:
PlayerShot_DrawShot(shot);
diff --git a/src/engine/fox_bg.c b/src/engine/fox_bg.c
index b377e4da..4f52fd11 100644
--- a/src/engine/fox_bg.c
+++ b/src/engine/fox_bg.c
@@ -258,6 +258,7 @@ void Background_DrawStarfield(void) {
if ((vx >= STAR_MARGIN) && (vx < currentScreenWidth - STAR_MARGIN) && (vy >= STAR_MARGIN) &&
(vy < currentScreenHeight - STAR_MARGIN)) {
FrameInterpolation_RecordOpenChild("Starfield", i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
// Translate to (vx, vy) in ortho coordinates
Matrix_Push(&gGfxMatrix);
@@ -368,6 +369,7 @@ void Background_DrawPartialStarfield(s32 yMin, s32 yMax) { // Stars that are in
if ((vx >= 0) && (vx < currentScreenWidth) && (yMin < vy) && (vy < yMax)) {
// Tag the transform. Assuming TAG_STARFIELD is a defined base tag value
FrameInterpolation_RecordOpenChild("SmallStarfield", i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
// Translate to (vx, vy) in ortho coordinates
Matrix_Push(&gGfxMatrix);
Matrix_Translate(gGfxMatrix, vx - (currentScreenWidth / 2.0f), -(vy - (currentScreenHeight / 2.0f)), 0.0f,
@@ -460,6 +462,7 @@ void Background_DrawBackdrop(void) {
// Render the textures across the screen (left to right)
for (int i = 0; i < 6; i++) {
FrameInterpolation_RecordOpenChild("Backdrop", i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
switch (gCurrentLevel) {
case LEVEL_VERSUS:
@@ -510,6 +513,7 @@ void Background_DrawBackdrop(void) {
// Render the textures across a wider range to cover the screen
for (int i = 0; i < 10; i++) {
FrameInterpolation_RecordOpenChild("Backdrop", i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
switch ((s32) gCurrentLevel) {
case LEVEL_CORNERIA:
@@ -533,6 +537,7 @@ void Background_DrawBackdrop(void) {
case LEVEL_VENOM_ANDROSS: // WIP
if (gDrawBackdrop != 6) {
FrameInterpolation_RecordOpenChild("Backdrop", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if ((gDrawBackdrop == 2) || (gDrawBackdrop == 7)) {
Matrix_RotateZ(gGfxMatrix, gPlayer[gPlayerNum].camRoll * M_DTOR, MTXF_APPLY);
Matrix_Translate(gGfxMatrix, 0.0f, -4000.0f, -7000.0f, MTXF_APPLY);
@@ -630,6 +635,7 @@ void Background_DrawBackdrop(void) {
// Render the textures across the screen (left to right)
for (int i = 0; i < 5; i++) {
FrameInterpolation_RecordOpenChild("Backdrop", i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if (gPlayer[0].state_1C8 == PLAYERSTATE_1C8_LEVEL_INTRO) {
gSPDisplayList(gMasterDisp++, D_AQ_601AFF0);
} else {
diff --git a/src/engine/fox_display.c b/src/engine/fox_display.c
index 3b73ab15..4095abb5 100644
--- a/src/engine/fox_display.c
+++ b/src/engine/fox_display.c
@@ -712,6 +712,7 @@ void Display_Reticle(Player* player) {
(gGameState == GSTATE_MENU))) {
for (i = 0; i < 2; i++) {
FrameInterpolation_RecordOpenChild("Reticle", i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
translate = &D_display_801613E0[i];
Matrix_Push(&gGfxMatrix);
Matrix_Translate(gGfxMatrix, translate->x, translate->y, translate->z, MTXF_APPLY);
@@ -1507,6 +1508,7 @@ void Display_ActorMarks(void) {
for (i = 0; i < ARRAY_COUNT(gTeamArrowsViewPos); i++) {
if (gTeamArrowsViewPos[i].z < 0.0f) {
FrameInterpolation_RecordOpenChild(&gTeamArrowsViewPos[i], i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
var_fs0 = (VEC3F_MAG(&gTeamArrowsViewPos[i])) * 0.0015f;
if (var_fs0 > 100.0f) {
var_fs0 = 100.0f;
@@ -1552,6 +1554,7 @@ void Display_LockOnIndicator(void) {
var_fs0 = VEC3F_MAG(&gLockOnTargetViewPos[i]);
if (var_fs0 < 20000.0f) {
FrameInterpolation_RecordOpenChild("LcckOnIndicator", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
var_fs0 *= 0.0015f;
if (var_fs0 > 100.0f) {
var_fs0 = 100.0f;
@@ -1751,10 +1754,9 @@ void Display_Update(void) {
Background_DrawStarfield();
}
- FrameInterpolation_RecordOpenChild("Backdrop", 0);
Background_DrawBackdrop();
- FrameInterpolation_RecordCloseChild();
FrameInterpolation_RecordOpenChild("Sun", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Background_DrawSun();
FrameInterpolation_RecordCloseChild();
Matrix_Push(&gGfxMatrix);
@@ -1773,6 +1775,7 @@ void Display_Update(void) {
} else if (gGroundSurface != SURFACE_WATER) {
D_bg_8015F964 = false;
FrameInterpolation_RecordOpenChild("Ground", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Background_DrawGround();
FrameInterpolation_RecordCloseChild();
}
@@ -1839,6 +1842,7 @@ void Display_Update(void) {
D_bg_8015F964 = true;
Effect_Draw(1);
FrameInterpolation_RecordOpenChild("Ground", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Background_DrawGround();
FrameInterpolation_RecordCloseChild();
}
@@ -1855,6 +1859,7 @@ void Display_Update(void) {
for (i = 0, player = &gPlayer[0]; i < gCamCount; i++, player++) {
if (sPlayersVisible[i]) {
FrameInterpolation_RecordOpenChild(player, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Display_PlayerShadow_Update(player);
Display_PlayerFeatures(player);
Display_ArwingWingTrail_Update(player);
diff --git a/src/engine/fox_edisplay.c b/src/engine/fox_edisplay.c
index db07a84a..88753517 100644
--- a/src/engine/fox_edisplay.c
+++ b/src/engine/fox_edisplay.c
@@ -828,6 +828,7 @@ void ItemCheckpoint_Draw(ItemCheckpoint* this) {
if (((gGameFrameCount & 0x18) != 0) && (this->state == 0)) {
FrameInterpolation_RecordOpenChild(this, 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Matrix_Push(&gGfxMatrix);
RCP_SetupDL(&gMasterDisp, SETUPDL_64);
gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 0, 255);
@@ -840,6 +841,7 @@ void ItemCheckpoint_Draw(ItemCheckpoint* this) {
FrameInterpolation_RecordCloseChild();
}
FrameInterpolation_RecordOpenChild(this, 1);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
RCP_SetupDL(&gMasterDisp, SETUPDL_29);
gSPTexture(gMasterDisp++, 2000, 2000, 0, G_TX_RENDERTILE, G_ON);
gSPSetGeometryMode(gMasterDisp++, G_TEXTURE_GEN);
@@ -1705,6 +1707,7 @@ void Object_DrawAll(s32 arg0) {
for (i = 0, scenery360 = gScenery360; i < 200; i++, scenery360++) {
FrameInterpolation_RecordOpenChild(scenery360, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if ((scenery360->obj.status == OBJ_ACTIVE) && (scenery360->obj.id != OBJ_SCENERY_LEVEL_OBJECTS)) {
if (gCurrentLevel == LEVEL_BOLSE) {
spAC.x = scenery360->sfxSource[0];
@@ -1723,15 +1726,16 @@ void Object_DrawAll(s32 arg0) {
RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
for (i = 0, scenery = gScenery; i < ARRAY_COUNT(gScenery); i++, scenery++) {
if (scenery->obj.status >= OBJ_ACTIVE) {
+ FrameInterpolation_RecordOpenChild(scenery, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if (arg0 > 0) {
Display_SetSecondLight(&scenery->obj.pos);
}
Matrix_Push(&gGfxMatrix);
- FrameInterpolation_RecordOpenChild(scenery, i);
Scenery_Draw(scenery, arg0);
- FrameInterpolation_RecordCloseChild();
Matrix_Pop(&gGfxMatrix);
Object_UpdateSfxSource(scenery->sfxSource);
+ FrameInterpolation_RecordCloseChild();
}
}
}
@@ -1739,6 +1743,7 @@ void Object_DrawAll(s32 arg0) {
for (i = 0, boss = gBosses; i < ARRAY_COUNT(gBosses); i++, boss++) {
if ((boss->obj.status >= OBJ_ACTIVE) && (boss->obj.id != OBJ_BOSS_BO_BASE_SHIELD)) {
FrameInterpolation_RecordOpenChild(boss, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if ((boss->timer_05C % 2) == 0) {
RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
} else {
@@ -1764,6 +1769,7 @@ void Object_DrawAll(s32 arg0) {
for (i = 0, sprite = gSprites; i < ARRAY_COUNT(gSprites); i++, sprite++) {
if ((sprite->obj.status >= OBJ_ACTIVE) && func_enmy_80060FE4(&sprite->obj.pos, -12000.0f)) {
FrameInterpolation_RecordOpenChild(sprite, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Matrix_Push(&gGfxMatrix);
if ((sprite->obj.id == OBJ_SPRITE_CO_RUIN1) || (sprite->obj.id == OBJ_SPRITE_CO_RUIN2)) {
@@ -1781,6 +1787,7 @@ void Object_DrawAll(s32 arg0) {
for (i = 0, actor = &gActors[0]; i < ARRAY_COUNT(gActors); i++, actor++) {
if (actor->obj.status >= OBJ_ACTIVE) {
FrameInterpolation_RecordOpenChild(actor, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if ((actor->timer_0C6 % 2) == 0) {
if (gCurrentLevel == LEVEL_UNK_15) {
RCP_SetupDL_23();
@@ -1829,7 +1836,7 @@ void Object_DrawAll(s32 arg0) {
}
break;
}
- FrameInterpolation_RecordCloseChild();
+ FrameInterpolation_RecordCloseChild();
}
}
@@ -1841,6 +1848,7 @@ void Object_DrawAll(s32 arg0) {
for (i = 0, item = &gItems[0]; i < ARRAY_COUNT(gItems); i++, item++) {
if (item->obj.status >= OBJ_ACTIVE) {
FrameInterpolation_RecordOpenChild(item, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Matrix_Push(&gGfxMatrix);
RCP_SetupDL(&gMasterDisp, SETUPDL_29);
Object_SetCullDirection(arg0);
@@ -1864,6 +1872,7 @@ void Effect_DrawAll(s32 arg0) {
for (i = 0, effect = &gEffects[0]; i < ARRAY_COUNT(gEffects); i++, effect++) {
if (effect->obj.status >= OBJ_ACTIVE) {
FrameInterpolation_RecordOpenChild(effect, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if (effect->info.unk_14 == 1) {
effect->obj.rot.y = RAD_TO_DEG(-gPlayer[gPlayerNum].camYaw);
effect->obj.rot.x = RAD_TO_DEG(gPlayer[gPlayerNum].camPitch);
@@ -1891,6 +1900,7 @@ void Effect_DrawAll(s32 arg0) {
for (i = 0, boss = &gBosses[0]; i < ARRAY_COUNT(gBosses); i++, boss++) {
if ((boss->obj.status >= OBJ_ACTIVE) && (boss->obj.id == OBJ_BOSS_BO_BASE_SHIELD)) {
FrameInterpolation_RecordOpenChild(boss, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if ((boss->timer_05C % 2) == 0) {
RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
} else {
@@ -1962,6 +1972,7 @@ void TexturedLine_Draw(void) {
for (i = 0; i < ARRAY_COUNT(gTexturedLines); i++) {
TexturedLine* texLine = &gTexturedLines[i];
FrameInterpolation_RecordOpenChild(texLine, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
if (gTexturedLines[i].mode != 0) {
Matrix_Push(&gGfxMatrix);
diff --git a/src/engine/fox_effect.c b/src/engine/fox_effect.c
index 489ac82c..8b600457 100644
--- a/src/engine/fox_effect.c
+++ b/src/engine/fox_effect.c
@@ -140,6 +140,7 @@ void BonusText_DrawAll(void) {
for (i = 0, bonus = gBonusText; i < ARRAY_COUNT(gBonusText); i++, bonus++) {
if (bonus->hits != 0) {
FrameInterpolation_RecordOpenChild(bonus, i);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Matrix_Push(&gGfxMatrix);
BonusText_Draw(bonus);
Matrix_Pop(&gGfxMatrix);
diff --git a/src/engine/fox_std_lib.c b/src/engine/fox_std_lib.c
index b6e71ef1..b3c4e9c4 100644
--- a/src/engine/fox_std_lib.c
+++ b/src/engine/fox_std_lib.c
@@ -31,7 +31,7 @@ void Lib_Texture_Scroll(u16* texture, s32 width, s32 height, u8 mode) {
u16 tempPxl;
s32 u;
s32 v;
- // return;
+ return;
// LTodo: [HD-Textures] This is broken
switch (mode) {
diff --git a/src/overlays/ovl_menu/fox_i_menu.c b/src/overlays/ovl_menu/fox_i_menu.c
index 4e1afd69..02a69f2b 100644
--- a/src/overlays/ovl_menu/fox_i_menu.c
+++ b/src/overlays/ovl_menu/fox_i_menu.c
@@ -32,6 +32,7 @@ void OvlMenu_CallFunction(u32 mode, void* ptr) {
case OVLCALL_MAP_DRAW:
FrameInterpolation_RecordOpenChild("MapDraw", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
Map_Draw();
FrameInterpolation_RecordCloseChild();
break;
diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp
index 611e6cd3..19507094 100644
--- a/src/port/interpolation/FrameInterpolation.cpp
+++ b/src/port/interpolation/FrameInterpolation.cpp
@@ -47,6 +47,7 @@ using namespace std;
namespace {
enum class Op {
+ Marker,
OpenChild,
CloseChild,
@@ -72,41 +73,53 @@ union Data {
}
struct {
- MtxF src;
- } matrix_put;
+ Matrix** matrix;
+ } matrix_ptr;
+
+ struct {
+ const char* file;
+ int line;
+ } marker;
struct {
+ Matrix* matrix;
MtxF mf;
u8 mode;
} matrix_mult;
struct {
+ Matrix* matrix;
f32 x, y, z;
u8 mode;
} matrix_translate, matrix_scale;
struct {
+ Matrix* matrix;
u32 coord;
f32 value;
u8 mode;
} matrix_rotate_1_coord;
struct {
+ Matrix* matrix;
Vec3f src;
Vec3f dest;
} matrix_vec_translate;
struct {
+ Matrix* matrix;
Vec3f src;
Vec3f dest;
} matrix_vec_no_translate;
struct {
+ Matrix* matrix;
Vec3f translation;
Vec3s rotation;
} matrix_translate_rotate_zyx;
struct {
+ Matrix* matrix;
f32 translateX, translateY, translateZ;
Vec3s rot;
// MtxF mtx;
@@ -169,7 +182,7 @@ Data& append(Op op) {
}
MtxF* Matrix_GetCurrent(){
- return (MtxF*) gGfxMatrix;
+ return (MtxF*) gInterpolationMatrix;
}
struct InterpolateCtx {
@@ -290,16 +303,16 @@ struct InterpolateCtx {
Data& old_op = it->second[item.second];
switch (item.first) {
case Op::OpenChild:
- break;
case Op::CloseChild:
+ case Op::Marker:
break;
case Op::MatrixPush:
- Matrix_Push(&gGfxMatrix);
+ Matrix_Push(&gInterpolationMatrix);
break;
case Op::MatrixPop:
- Matrix_Pop(&gGfxMatrix);
+ Matrix_Pop(&gInterpolationMatrix);
break;
// Unused on SF64
@@ -310,18 +323,18 @@ struct InterpolateCtx {
case Op::MatrixMult:
interpolate_mtxf(&tmp_mtxf, &old_op.matrix_mult.mf, &new_op.matrix_mult.mf);
- Matrix_Mult(gGfxMatrix, (Matrix*) &tmp_mtxf, new_op.matrix_mult.mode);
+ Matrix_Mult(gInterpolationMatrix, (Matrix*) &tmp_mtxf, new_op.matrix_mult.mode);
break;
case Op::MatrixTranslate:
- Matrix_Translate(gGfxMatrix, lerp(old_op.matrix_translate.x, new_op.matrix_translate.x),
+ Matrix_Translate(gInterpolationMatrix, lerp(old_op.matrix_translate.x, new_op.matrix_translate.x),
lerp(old_op.matrix_translate.y, new_op.matrix_translate.y),
lerp(old_op.matrix_translate.z, new_op.matrix_translate.z),
new_op.matrix_translate.mode);
break;
case Op::MatrixScale:
- Matrix_Scale(gGfxMatrix, lerp(old_op.matrix_scale.x, new_op.matrix_scale.x),
+ Matrix_Scale(gInterpolationMatrix, lerp(old_op.matrix_scale.x, new_op.matrix_scale.x),
lerp(old_op.matrix_scale.y, new_op.matrix_scale.y),
lerp(old_op.matrix_scale.z, new_op.matrix_scale.z), new_op.matrix_scale.mode);
break;
@@ -332,15 +345,15 @@ struct InterpolateCtx {
u8 mode = new_op.matrix_rotate_1_coord.mode;
switch (new_op.matrix_rotate_1_coord.coord) {
case 0:
- Matrix_RotateX(gGfxMatrix, v, mode);
+ Matrix_RotateX(gInterpolationMatrix, v, mode);
break;
case 1:
- Matrix_RotateY(gGfxMatrix, v, mode);
+ Matrix_RotateY(gInterpolationMatrix, v, mode);
break;
case 2:
- Matrix_RotateZ(gGfxMatrix, v, mode);
+ Matrix_RotateZ(gInterpolationMatrix, v, mode);
break;
}
break;
@@ -348,13 +361,13 @@ struct InterpolateCtx {
case Op::MatrixMultVec3fNoTranslate: {
interpolate_vecs(&tmp_vec3f, &old_op.matrix_vec_no_translate.src, &new_op.matrix_vec_no_translate.src);
interpolate_vecs(&tmp_vec3f2, &old_op.matrix_vec_no_translate.dest, &new_op.matrix_vec_no_translate.dest);
- Matrix_MultVec3fNoTranslate(gCalcMatrix, &tmp_vec3f, &tmp_vec3f2);
+ Matrix_MultVec3fNoTranslate(gInterpolationMatrix, &tmp_vec3f, &tmp_vec3f2);
break;
}
case Op::MatrixMultVec3f: {
- interpolate_vecs(&tmp_vec3f, &old_op.matrix_vec_no_translate.src, &new_op.matrix_vec_no_translate.src);
- interpolate_vecs(&tmp_vec3f2, &old_op.matrix_vec_no_translate.dest, &new_op.matrix_vec_no_translate.dest);
- Matrix_MultVec3f(gCalcMatrix, &tmp_vec3f, &tmp_vec3f2);
+ interpolate_vecs(&tmp_vec3f, &old_op.matrix_vec_translate.src, &new_op.matrix_vec_translate.src);
+ interpolate_vecs(&tmp_vec3f2, &old_op.matrix_vec_translate.dest, &new_op.matrix_vec_translate.dest);
+ Matrix_MultVec3f(gInterpolationMatrix, &tmp_vec3f, &tmp_vec3f2);
break;
}
@@ -460,58 +473,66 @@ void FrameInterpolation_RecordActorPosRotMatrix(void) {
next_is_actor_pos_rot_matrix = true;
}
-void FrameInterpolation_RecordMatrixPush(void) {
+void FrameInterpolation_RecordMatrixPush(Matrix** matrix) {
if (!is_recording)
return;
- append(Op::MatrixPush);
+
+ append(Op::MatrixPush).matrix_ptr = { matrix };
+}
+
+void FrameInterpolation_RecordMarker(const char* file, int line) {
+ if (!is_recording)
+ return;
+
+ append(Op::Marker).marker = { file, line };
}
-void FrameInterpolation_RecordMatrixPop(void) {
+void FrameInterpolation_RecordMatrixPop(Matrix** matrix) {
if (!is_recording)
return;
- append(Op::MatrixPop);
+ append(Op::MatrixPop).matrix_ptr = { matrix };
}
void FrameInterpolation_RecordMatrixPut(MtxF* src) {
if (!is_recording)
return;
- append(Op::MatrixPut).matrix_put = { *src };
+// append(Op::MatrixPut).matrix_put = { matrix, *src };
}
-void FrameInterpolation_RecordMatrixMult(MtxF* mf, u8 mode) {
+void FrameInterpolation_RecordMatrixMult(Matrix* matrix, MtxF* mf, u8 mode) {
if (!is_recording)
return;
- append(Op::MatrixMult).matrix_mult = { *mf, mode };
+ append(Op::MatrixMult).matrix_mult = { matrix, *mf, mode };
}
-void FrameInterpolation_RecordMatrixTranslate(f32 x, f32 y, f32 z, u8 mode) {
+void FrameInterpolation_RecordMatrixTranslate(Matrix* matrix, f32 x, f32 y, f32 z, u8 mode) {
if (!is_recording)
return;
- append(Op::MatrixTranslate).matrix_translate = { x, y, z, mode };
+ append(Op::MatrixTranslate).matrix_translate = { matrix, x, y, z, mode };
}
-void FrameInterpolation_RecordMatrixScale(f32 x, f32 y, f32 z, u8 mode) {
+void FrameInterpolation_RecordMatrixScale(Matrix* matrix, f32 x, f32 y, f32 z, u8 mode) {
if (!is_recording)
return;
- append(Op::MatrixScale).matrix_scale = { x, y, z, mode };
+ append(Op::MatrixScale).matrix_scale = { matrix, x, y, z, mode };
}
-void FrameInterpolation_RecordMatrixMultVec3fNoTranslate(Vec3f src, Vec3f dest){
+void FrameInterpolation_RecordMatrixMultVec3fNoTranslate(Matrix* matrix, Vec3f src, Vec3f dest){
if (!is_recording)
return;
- append(Op::MatrixMultVec3fNoTranslate).matrix_vec_no_translate = { src, dest };
+ append(Op::MatrixMultVec3fNoTranslate).matrix_vec_no_translate = { matrix, src, dest };
}
-void FrameInterpolation_RecordMatrixMultVec3f(Vec3f src, Vec3f dest){
+void FrameInterpolation_RecordMatrixMultVec3f(Matrix* matrix, Vec3f src, Vec3f dest){
if (!is_recording)
return;
- append(Op::MatrixMultVec3f).matrix_vec_translate = { src, dest };
+ append(Op::MatrixMultVec3f).matrix_vec_translate = { matrix, src, dest };
}
-void FrameInterpolation_RecordMatrixRotate1Coord(u32 coord, f32 value, u8 mode) {
+void FrameInterpolation_RecordMatrixRotate1Coord(Matrix* matrix, u32 coord, f32 value, u8 mode) {
if (!is_recording)
return;
- append(Op::MatrixRotate1Coord).matrix_rotate_1_coord = { coord, value, mode };
+ append(Op::MatrixRotate1Coord).matrix_rotate_1_coord = { matrix, coord, value, mode };
}
void FrameInterpolation_RecordMatrixMtxFToMtx(MtxF* src, Mtx* dest) {
diff --git a/src/port/interpolation/FrameInterpolation.h b/src/port/interpolation/FrameInterpolation.h
index 77295716..7ba8c62a 100644
--- a/src/port/interpolation/FrameInterpolation.h
+++ b/src/port/interpolation/FrameInterpolation.h
@@ -19,6 +19,8 @@ void FrameInterpolation_StartRecord(void);
void FrameInterpolation_StopRecord(void);
+void FrameInterpolation_RecordMarker(const char* file, int line);
+
void FrameInterpolation_RecordOpenChild(const void* a, int b);
void FrameInterpolation_RecordCloseChild(void);
@@ -29,17 +31,17 @@ int FrameInterpolation_GetCameraEpoch(void);
void FrameInterpolation_RecordActorPosRotMatrix(void);
-void FrameInterpolation_RecordMatrixPush(void);
+void FrameInterpolation_RecordMatrixPush(Matrix** mtx);
-void FrameInterpolation_RecordMatrixPop(void);
+void FrameInterpolation_RecordMatrixPop(Matrix** mtx);
-void FrameInterpolation_RecordMatrixMult(MtxF* mf, u8 mode);
+void FrameInterpolation_RecordMatrixMult(Matrix* matrix, MtxF* mf, u8 mode);
-void FrameInterpolation_RecordMatrixTranslate(f32 x, f32 y, f32 z, u8 mode);
+void FrameInterpolation_RecordMatrixTranslate(Matrix* matrix, f32 x, f32 y, f32 z, u8 mode);
-void FrameInterpolation_RecordMatrixScale(f32 x, f32 y, f32 z, u8 mode);
+void FrameInterpolation_RecordMatrixScale(Matrix* matrix, f32 x, f32 y, f32 z, u8 mode);
-void FrameInterpolation_RecordMatrixRotate1Coord(u32 coord, f32 value, u8 mode);
+void FrameInterpolation_RecordMatrixRotate1Coord(Matrix* matrix, u32 coord, f32 value, u8 mode);
void FrameInterpolation_RecordMatrixMtxFToMtx(MtxF* src, Mtx* dest);
@@ -51,8 +53,9 @@ void FrameInterpolation_RecordMatrixRotateAxis(f32 angle, Vec3f* axis, u8 mode);
void FrameInterpolation_RecordSkinMatrixMtxFToMtx(MtxF* src, Mtx* dest);
-void FrameInterpolation_RecordMatrixMultVec3f(Vec3f src, Vec3f dest);
-void FrameInterpolation_RecordMatrixMultVec3fNoTranslate(Vec3f src, Vec3f dest);
+void FrameInterpolation_RecordMatrixMultVec3f(Matrix* matrix, Vec3f src, Vec3f dest);
+
+void FrameInterpolation_RecordMatrixMultVec3fNoTranslate(Matrix* matrix, Vec3f src, Vec3f dest);
#ifdef __cplusplus
}
diff --git a/src/sys/sys_lib.c b/src/sys/sys_lib.c
index 6d78cc77..91adbf39 100644
--- a/src/sys/sys_lib.c
+++ b/src/sys/sys_lib.c
@@ -86,6 +86,7 @@ void Lib_InitPerspective(Gfx** dList) {
u16 norm;
FrameInterpolation_RecordOpenChild("perspective", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
guPerspective(gGfxMtx, &norm, gFovY, (f32) SCREEN_WIDTH / SCREEN_HEIGHT, gProjectNear, gProjectFar, 1.0f);
gSPPerspNormalize((*dList)++, norm);
gSPMatrix((*dList)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
@@ -97,6 +98,7 @@ void Lib_InitPerspective(Gfx** dList) {
void Lib_InitOrtho(Gfx** dList) {
FrameInterpolation_RecordOpenChild("ortho", 0);
+ FrameInterpolation_RecordMarker(__FILE__, __LINE__);
guOrtho(gGfxMtx, -SCREEN_WIDTH / 2, SCREEN_WIDTH / 2, -SCREEN_HEIGHT / 2, SCREEN_HEIGHT / 2, gProjectNear,
gProjectFar, 1.0f);
gSPMatrix((*dList)++, gGfxMtx++, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c
index c9ef82f0..5f382966 100644
--- a/src/sys/sys_main.c
+++ b/src/sys/sys_main.c
@@ -168,6 +168,7 @@ void Graphics_InitializeTask(u32 frameCount) {
gGfxMatrix = &sGfxMatrixStack[0];
gCalcMatrix = &sCalcMatrixStack[0];
+ gInterpolationMatrix = &sInterpolationMatrixStack[0];
D_80178710 = &D_80178580[0];
}
diff --git a/src/sys/sys_matrix.c b/src/sys/sys_matrix.c
index 064ca7d0..b45cec76 100644
--- a/src/sys/sys_matrix.c
+++ b/src/sys/sys_matrix.c
@@ -29,9 +29,11 @@ Matrix gIdentityMatrix = { {
} };
Matrix* gGfxMatrix;
-Matrix sGfxMatrixStack[0x20];
+Matrix sGfxMatrixStack[0x1000];
Matrix* gCalcMatrix;
-Matrix sCalcMatrixStack[0x20];
+Matrix sCalcMatrixStack[0x1000];
+Matrix* gInterpolationMatrix;
+Matrix sInterpolationMatrixStack[0x1000];
// Copies src Matrix into dst
void Matrix_Copy(Matrix* dst, Matrix* src) {
@@ -47,14 +49,19 @@ void Matrix_Copy(Matrix* dst, Matrix* src) {
// Makes a copy of the stack's current matrix and puts it on the top of the stack
void Matrix_Push(Matrix** mtxStack) {
- FrameInterpolation_RecordMatrixPush();
+ FrameInterpolation_RecordMatrixPush(mtxStack);
+
+ if(mtxStack == NULL || *mtxStack == NULL){
+ int bp = 0;
+ }
+
Matrix_Copy(*mtxStack + 1, *mtxStack);
(*mtxStack)++;
}
// Removes the top matrix of the stack
void Matrix_Pop(Matrix** mtxStack) {
- FrameInterpolation_RecordMatrixPop();
+ FrameInterpolation_RecordMatrixPop(mtxStack);
(*mtxStack)--;
}
@@ -192,7 +199,7 @@ void Matrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest) {
// Copies tf into mtx (MTXF_NEW) or applies it to mtx (MTXF_APPLY)
void Matrix_Mult(Matrix* mtx, Matrix* tf, u8 mode) {
- FrameInterpolation_RecordMatrixMult(tf, mode);
+ FrameInterpolation_RecordMatrixMult(mtx, tf, mode);
f32 rx;
f32 ry;
f32 rz;
@@ -245,7 +252,7 @@ void Matrix_Mult(Matrix* mtx, Matrix* tf, u8 mode) {
// Creates a translation matrix in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY)
void Matrix_Translate(Matrix* mtx, f32 x, f32 y, f32 z, u8 mode) {
- FrameInterpolation_RecordMatrixTranslate(x, y, z, mode);
+ FrameInterpolation_RecordMatrixTranslate(mtx, x, y, z, mode);
f32 rx;
f32 ry;
s32 i;
@@ -269,7 +276,7 @@ void Matrix_Translate(Matrix* mtx, f32 x, f32 y, f32 z, u8 mode) {
// Creates a scale matrix in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY)
void Matrix_Scale(Matrix* mtx, f32 xScale, f32 yScale, f32 zScale, u8 mode) {
- FrameInterpolation_RecordMatrixScale(xScale, yScale, zScale, mode);
+ FrameInterpolation_RecordMatrixScale(mtx, xScale, yScale, zScale, mode);
f32 rx;
f32 ry;
s32 i;
@@ -295,7 +302,7 @@ void Matrix_Scale(Matrix* mtx, f32 xScale, f32 yScale, f32 zScale, u8 mode) {
// Creates rotation matrix about the X axis in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY)
void Matrix_RotateX(Matrix* mtx, f32 angle, u8 mode) {
- FrameInterpolation_RecordMatrixRotate1Coord(0, angle, mode);
+ FrameInterpolation_RecordMatrixRotate1Coord(mtx, 0, angle, mode);
f32 cs;
f32 sn;
f32 ry;
@@ -324,7 +331,7 @@ void Matrix_RotateX(Matrix* mtx, f32 angle, u8 mode) {
// Creates rotation matrix about the Y axis in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY)
void Matrix_RotateY(Matrix* mtx, f32 angle, u8 mode) {
- FrameInterpolation_RecordMatrixRotate1Coord(1, angle, mode);
+ FrameInterpolation_RecordMatrixRotate1Coord(mtx, 1, angle, mode);
f32 cs;
f32 sn;
f32 rx;
@@ -353,7 +360,7 @@ void Matrix_RotateY(Matrix* mtx, f32 angle, u8 mode) {
// Creates rotation matrix about the Z axis in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY)
void Matrix_RotateZ(Matrix* mtx, f32 angle, u8 mode) {
- FrameInterpolation_RecordMatrixRotate1Coord(2, angle, mode);
+ FrameInterpolation_RecordMatrixRotate1Coord(mtx, 2, angle, mode);
f32 cs;
f32 sn;
f32 rx;
@@ -491,7 +498,7 @@ void Matrix_FromMtx(Mtx* src, Matrix* dest) {
// Applies the transform matrix mtx to the vector src, putting the result in dest
void Matrix_MultVec3f(Matrix* mtx, Vec3f* src, Vec3f* dest) {
- FrameInterpolation_RecordMatrixMultVec3f(*src, *dest);
+ FrameInterpolation_RecordMatrixMultVec3f(mtx, *src, *dest);
dest->x = (mtx->m[0][0] * src->x) + (mtx->m[1][0] * src->y) + (mtx->m[2][0] * src->z) + mtx->m[3][0];
dest->y = (mtx->m[0][1] * src->x) + (mtx->m[1][1] * src->y) + (mtx->m[2][1] * src->z) + mtx->m[3][1];
dest->z = (mtx->m[0][2] * src->x) + (mtx->m[1][2] * src->y) + (mtx->m[2][2] * src->z) + mtx->m[3][2];
@@ -500,7 +507,7 @@ void Matrix_MultVec3f(Matrix* mtx, Vec3f* src, Vec3f* dest) {
// Applies the linear part of the transformation matrix mtx to the vector src, ignoring any translation that mtx might
// have. Puts the result in dest.
void Matrix_MultVec3fNoTranslate(Matrix* mtx, Vec3f* src, Vec3f* dest) {
- FrameInterpolation_RecordMatrixMultVec3fNoTranslate(*src, *dest);
+ FrameInterpolation_RecordMatrixMultVec3fNoTranslate(mtx, *src, *dest);
dest->x = (mtx->m[0][0] * src->x) + (mtx->m[1][0] * src->y) + (mtx->m[2][0] * src->z);
dest->y = (mtx->m[0][1] * src->x) + (mtx->m[1][1] * src->y) + (mtx->m[2][1] * src->z);
dest->z = (mtx->m[0][2] * src->x) + (mtx->m[1][2] * src->y) + (mtx->m[2][2] * src->z);