diff --git a/docs/progress.svg b/docs/progress.svg
index 0fd7b2ff..1896eb72 100644
--- a/docs/progress.svg
+++ b/docs/progress.svg
@@ -69,10 +69,10 @@
Tomb2.exe progress according to the physical function order:
-2.25% (27) · 95.33% (1144) · 0.67% (8) · 1.75% (21)
+2.33% (28) · 95.25% (1143) · 0.67% (8) · 1.75% (21)
-
-
+
+
@@ -216,8 +216,8 @@
int32_t __cdecl Game_Cutscene_Start(int32_t level_num);
void __cdecl Misc_InitCinematicRooms(void);
int32_t __cdecl Game_Cutscene_Control(int32_t nframes);
-void __cdecl Camera_UpdateCutscene(void);
-int32_t __cdecl GetCinematicRoom(int32_t x, int32_t y, int32_t z);
+void __cdecl Camera_UpdateCutscene(void);
+int32_t __cdecl Room_FindByPos(int32_t x, int32_t y, int32_t z);
void __cdecl CutscenePlayer_Control(int16_t item_num);
void __cdecl Lara_Control_Cutscene(int16_t item_num);
void __cdecl CutscenePlayer1_Initialise(int16_t item_num);
@@ -1281,10 +1281,10 @@
Tomb2.exe progress according to the function sizes:
-2.82% · 96.85% · 0.02% · 0.31%
+2.91% · 96.76% · 0.02% · 0.31%
-
-
+
+
@@ -1585,7 +1585,7 @@
void __cdecl Item_AlignPosition(struct PHD_VECTOR *vec, struct ITEM_INFO *src_item, struct ITEM_INFO *dst_item);
void __cdecl CreateScreenBuffers(void);
void __fastcall transA(int32_t y0, int32_t y1, BYTE depthQ);
-void __cdecl Camera_UpdateCutscene(void);
+void __cdecl Camera_UpdateCutscene(void);
void __cdecl ControlSpikeWall(int16_t item_num);
int32_t __cdecl Item_TestPosition(int16_t *bounds, struct ITEM_INFO *src_item, struct ITEM_INFO *dst_item);
int32_t __cdecl TestBlockPush(struct ITEM_INFO *item, int32_t blokhite, uint16_t quadrant);
@@ -1905,7 +1905,7 @@
void __cdecl lara_col_stop(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl lara_col_roll2(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl SkidmanCollision(int16_t item_num, struct ITEM_INFO *laraitem, struct COLL_INFO *coll);
-int32_t __cdecl GetCinematicRoom(int32_t x, int32_t y, int32_t z);
+int32_t __cdecl Room_FindByPos(int32_t x, int32_t y, int32_t z);
void __cdecl ControlExplosion1(int16_t fx_num);
int32_t __cdecl LaraDeflectEdge(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl InitialiseSkidman(int16_t item_num);
diff --git a/docs/progress.txt b/docs/progress.txt
index 5106e683..d89a08f0 100644
--- a/docs/progress.txt
+++ b/docs/progress.txt
@@ -1013,8 +1013,8 @@ typedef struct CINE_FRAME {
00411F60 00000112 - int32_t __cdecl Game_Cutscene_Start(int32_t level_num);
00412080 00000093 -R void __cdecl Misc_InitCinematicRooms(void);
00412120 0000016F - int32_t __cdecl Game_Cutscene_Control(int32_t nframes);
-00412290 00000138 - void __cdecl Camera_UpdateCutscene(void);
-004123D0 0000007F -R int32_t __cdecl GetCinematicRoom(int32_t x, int32_t y, int32_t z);
+00412290 00000138 + void __cdecl Camera_UpdateCutscene(void);
+004123D0 0000007F -R int32_t __cdecl Room_FindByPos(int32_t x, int32_t y, int32_t z);
00412450 000000DC - void __cdecl CutscenePlayer_Control(int16_t item_num);
00412530 00000096 - void __cdecl Lara_Control_Cutscene(int16_t item_num);
004125D0 0000008F -R void __cdecl CutscenePlayer1_Initialise(int16_t item_num);
diff --git a/src/game/camera.c b/src/game/camera.c
index 88b69177..24ea8e5d 100644
--- a/src/game/camera.c
+++ b/src/game/camera.c
@@ -812,12 +812,12 @@ void __cdecl Camera_LoadCutsceneFrame(void)
int32_t c = Math_Cos(g_CinePos.y_rot);
int32_t s = Math_Sin(g_CinePos.y_rot);
- g_Camera.target.x = g_CinePos.x + ((c * tx + s * tz) >> W2V_SHIFT);
+ g_Camera.target.x = g_CinePos.x + ((tx * c + tz * s) >> W2V_SHIFT);
g_Camera.target.y = g_CinePos.y + ty;
- g_Camera.target.z = g_CinePos.z + ((c * tz - s * tx) >> W2V_SHIFT);
- g_Camera.pos.x = g_CinePos.x + ((s * cz + c * cx) >> W2V_SHIFT);
+ g_Camera.target.z = g_CinePos.z + ((tz * c - tx * s) >> W2V_SHIFT);
+ g_Camera.pos.x = g_CinePos.x + ((cx * c + cz * s) >> W2V_SHIFT);
g_Camera.pos.y = g_CinePos.y + cy;
- g_Camera.pos.z = g_CinePos.z + ((c * cz - s * cx) >> W2V_SHIFT);
+ g_Camera.pos.z = g_CinePos.z + ((cz * c - cx * s) >> W2V_SHIFT);
Viewport_AlterFOV(fov);
Matrix_LookAt(
@@ -844,3 +844,35 @@ void __cdecl Camera_LoadCutsceneFrame(void)
g_Camera.mic_pos.y = g_Camera.pos.y;
}
}
+
+void __cdecl Camera_UpdateCutscene(void)
+{
+ const struct CINE_FRAME *frame = &g_CineData[g_CineFrame];
+ int32_t tx = frame->tx;
+ int32_t ty = frame->ty;
+ int32_t tz = frame->tz;
+ int32_t cx = frame->cx;
+ int32_t cy = frame->cy;
+ int32_t cz = frame->cz;
+ int32_t fov = frame->fov;
+ int32_t roll = frame->roll;
+ int32_t c = Math_Cos(g_Camera.target_angle);
+ int32_t s = Math_Sin(g_Camera.target_angle);
+ const struct PHD_VECTOR camtar = {
+ .x = g_LaraItem->pos.x + ((tx * c + tz * s) >> W2V_SHIFT),
+ .y = g_LaraItem->pos.y + ty,
+ .z = g_LaraItem->pos.z + ((tz * c - tx * s) >> W2V_SHIFT),
+ };
+ const struct PHD_VECTOR campos = {
+ .x = g_LaraItem->pos.x + ((cx * c + cz * s) >> W2V_SHIFT),
+ .y = g_LaraItem->pos.y + cy,
+ .z = g_LaraItem->pos.z + ((cz * c - cx * s) >> W2V_SHIFT),
+ };
+ int16_t room_num = Room_FindByPos(campos.x, campos.y, campos.z);
+ if (room_num >= 0) {
+ g_Camera.pos.room_num = room_num;
+ }
+ Viewport_AlterFOV(fov);
+ Matrix_LookAt(
+ campos.x, campos.y, campos.z, camtar.x, camtar.y, camtar.z, roll);
+}
diff --git a/src/game/camera.h b/src/game/camera.h
index db0b1657..8977e71a 100644
--- a/src/game/camera.h
+++ b/src/game/camera.h
@@ -25,3 +25,4 @@ void __cdecl Camera_Look(const struct ITEM_INFO *item);
void __cdecl Camera_Fixed(void);
void __cdecl Camera_Update(void);
void __cdecl Camera_LoadCutsceneFrame(void);
+void __cdecl Camera_UpdateCutscene(void);
diff --git a/src/global/funcs.h b/src/global/funcs.h
index f2c1c20b..2f40ca2a 100644
--- a/src/global/funcs.h
+++ b/src/global/funcs.h
@@ -124,8 +124,7 @@
#define Game_Cutscene_Start ((int32_t __cdecl (*)(int32_t level_num))0x00411F60)
#define Misc_InitCinematicRooms ((void __cdecl (*)(void))0x00412080)
#define Game_Cutscene_Control ((int32_t __cdecl (*)(int32_t nframes))0x00412120)
-#define Camera_UpdateCutscene ((void __cdecl (*)(void))0x00412290)
-#define GetCinematicRoom ((int32_t __cdecl (*)(int32_t x, int32_t y, int32_t z))0x004123D0)
+#define Room_FindByPos ((int32_t __cdecl (*)(int32_t x, int32_t y, int32_t z))0x004123D0)
#define CutscenePlayer_Control ((void __cdecl (*)(int16_t item_num))0x00412450)
#define Lara_Control_Cutscene ((void __cdecl (*)(int16_t item_num))0x00412530)
#define CutscenePlayer1_Initialise ((void __cdecl (*)(int16_t item_num))0x004125D0)
diff --git a/src/inject_exec.c b/src/inject_exec.c
index 8971e3e3..e3091f39 100644
--- a/src/inject_exec.c
+++ b/src/inject_exec.c
@@ -26,6 +26,7 @@ static void Inject_Camera(void)
INJECT(0x00411A00, Camera_Fixed);
INJECT(0x00411AA0, Camera_Update);
INJECT(0x004126A0, Camera_LoadCutsceneFrame);
+ INJECT(0x00412290, Camera_UpdateCutscene);
}
static void Inject_Matrix(void)