Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
port Camera_UpdateCutscene
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 2, 2023
1 parent 3ee6fdd commit 210dd9e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 18 deletions.
20 changes: 10 additions & 10 deletions docs/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
40 changes: 36 additions & 4 deletions src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}
1 change: 1 addition & 0 deletions src/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
3 changes: 1 addition & 2 deletions src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 210dd9e

Please sign in to comment.