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

Commit

Permalink
port Camera_Look
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 2, 2023
1 parent 458922f commit 744a884
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 10 deletions.
16 changes: 8 additions & 8 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.
2 changes: 1 addition & 1 deletion docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ typedef struct __unaligned LARA_INFO {
004113F0 000000ED + void __cdecl Camera_Chase(const struct ITEM_INFO *item);
004114E0 0000019E + int32_t __cdecl Camera_ShiftClamp(struct GAME_VECTOR *pos, int32_t clamp);
00411680 0000018E + void __cdecl Camera_Combat(const struct ITEM_INFO *item);
00411810 000001E2 - void __cdecl Camera_Look(struct ITEM_INFO *item);
00411810 000001E2 + void __cdecl Camera_Look(const struct ITEM_INFO *item);
00411A00 00000099 - void __cdecl Camera_Fixed(void);
00411AA0 000004A9 * void __cdecl Camera_Update(void);
00411F50 0000000A - void __cdecl Camera_SetCutsceneTrack(int32_t track);
Expand Down
56 changes: 56 additions & 0 deletions src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,3 +550,59 @@ void __cdecl Camera_Combat(const struct ITEM_INFO *item)
Camera_SmartShift(&target, Camera_Shift);
Camera_Move(&target, g_Camera.speed);
}

void __cdecl Camera_Look(const struct ITEM_INFO *item)
{
struct PHD_VECTOR old = {
.x = g_Camera.target.x,
.y = g_Camera.target.y,
.z = g_Camera.target.z,
};

g_Camera.target.z = item->pos.z;
g_Camera.target.x = item->pos.x;
g_Camera.target_angle =
item->pos.y_rot + g_Lara.torso_y_rot + g_Lara.head_y_rot;
g_Camera.target_distance = LOOK_DISTANCE;
g_Camera.target_elevation =
g_Lara.torso_x_rot + g_Lara.head_x_rot + item->pos.x_rot;

int32_t distance =
(LOOK_DISTANCE * Math_Cos(g_Camera.target_elevation)) >> W2V_SHIFT;

g_Camera.shift =
(-STEP_L * 2 * Math_Sin(g_Camera.target_elevation)) >> W2V_SHIFT;
g_Camera.target.z +=
(g_Camera.shift * Math_Cos(item->pos.y_rot)) >> W2V_SHIFT;
g_Camera.target.x +=
(g_Camera.shift * Math_Sin(item->pos.y_rot)) >> W2V_SHIFT;

if (!Camera_GoodPosition(
g_Camera.target.x, g_Camera.target.y, g_Camera.target.z,
g_Camera.target.room_num)) {
g_Camera.target.x = item->pos.x;
g_Camera.target.z = item->pos.z;
}

g_Camera.target.y += Camera_ShiftClamp(&g_Camera.target, STEP_L + 50);

const struct PHD_VECTOR offset = {
.y =
+((g_Camera.target_distance * Math_Sin(g_Camera.target_elevation))
>> W2V_SHIFT),
.x = -((distance * Math_Sin(g_Camera.target_angle)) >> W2V_SHIFT),
.z = -((distance * Math_Cos(g_Camera.target_angle)) >> W2V_SHIFT),
};

struct GAME_VECTOR target = {
.x = g_Camera.target.x + offset.x,
.y = g_Camera.target.y + offset.y,
.z = g_Camera.target.z + offset.z,
.room_num = g_Camera.pos.room_num,
};

Camera_SmartShift(&target, Camera_Clip);
g_Camera.target.z = old.z + (g_Camera.target.z - old.z) / g_Camera.speed;
g_Camera.target.x = old.x + (g_Camera.target.x - old.x) / g_Camera.speed;
Camera_Move(&target, g_Camera.speed);
}
1 change: 1 addition & 0 deletions src/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ void __cdecl Camera_SmartShift(
void __cdecl Camera_Chase(const struct ITEM_INFO *item);
int32_t __cdecl Camera_ShiftClamp(struct GAME_VECTOR *pos, int32_t clamp);
void __cdecl Camera_Combat(const struct ITEM_INFO *item);
void __cdecl Camera_Look(const struct ITEM_INFO *item);
1 change: 1 addition & 0 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
#define NO_CAMERA (-1)
#define MAX_ELEVATION (85 * PHD_DEGREE) // = 15470
#define COMBAT_DISTANCE (WALL_L * 5 / 2) // = 2560
#define LOOK_DISTANCE (WALL_L * 3 / 2) // = 1536
1 change: 0 additions & 1 deletion src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
#define Creature_Vault ((int32_t __cdecl (*)(int16_t item_num, int16_t angle, int32_t vault, int32_t shift))0x00410110)
#define Creature_Kill ((void __cdecl (*)(struct ITEM_INFO *item, int32_t kill_anim, int32_t kill_state, int32_t lara_kill_state))0x00410250)
#define Creature_GetBaddieTarget ((void __cdecl (*)(int16_t item_num, int32_t goody))0x004103C0)
#define Camera_Look ((void __cdecl (*)(struct ITEM_INFO *item))0x00411810)
#define Camera_Fixed ((void __cdecl (*)(void))0x00411A00)
#define Camera_Update ((void __cdecl (*)(void))0x00411AA0)
#define Camera_SetCutsceneTrack ((void __cdecl (*)(int32_t track))0x00411F50)
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static void Inject_Camera(void)
INJECT(0x004113F0, Camera_Chase);
INJECT(0x004114E0, Camera_ShiftClamp);
INJECT(0x00411680, Camera_Combat);
INJECT(0x00411810, Camera_Look);
}

static void Inject_Matrix(void)
Expand Down

0 comments on commit 744a884

Please sign in to comment.