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

Commit

Permalink
port Camera_Initialise
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 2, 2023
1 parent 488d0ae commit e0fbe19
Show file tree
Hide file tree
Showing 10 changed files with 338 additions and 38 deletions.
44 changes: 22 additions & 22 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.
139 changes: 130 additions & 9 deletions docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,122 @@ typedef struct CREATURE_INFO {
struct ITEM_INFO *enemy;
} CREATURE_INFO;

typedef enum CAMERA_TYPE {
CAM_CHASE = 0,
CAM_FIXED = 1,
CAM_LOOK = 2,
CAM_COMBAT = 3,
CAM_CINEMATIC = 4,
CAM_HEAVY = 5,
} CAMERA_TYPE;

typedef struct GAME_VECTOR {
int32_t x;
int32_t y;
int32_t z;
int16_t room_num;
int16_t box_num;
} GAME_VECTOR;

typedef struct __unaligned CAMERA_INFO {
struct GAME_VECTOR pos;
struct GAME_VECTOR target;
enum CAMERA_TYPE type;
int32_t shift;
uint32_t flags;
int32_t fixed_camera;
int32_t num_frames;
int32_t bounce;
int32_t underwater;
int32_t target_distance;
int32_t target_square;
int16_t target_angle;
int16_t actual_angle;
int16_t target_elevation;
int16_t box;
int16_t num;
int16_t last;
int16_t timer;
int16_t speed;
struct ITEM_INFO *item;
struct ITEM_INFO *last_item;
struct OBJECT_VECTOR *fixed;
bool is_lara_mic;
struct PHD_VECTOR mic_pos;
} CAMERA_INFO;

typedef struct __unaligned LARA_ARM {
int16_t *frame_base;
int16_t frame_num;
int16_t anim_num;
int16_t lock;
int16_t y_rot;
int16_t x_rot;
int16_t z_rot;
int16_t flash_gun;
} LARA_ARM;

typedef struct __unaligned AMMO_INFO {
int32_t ammo;
} AMMO_INFO;

typedef struct __unaligned LARA_INFO {
int16_t item_num;
int16_t gun_status;
int16_t gun_type;
int16_t request_gun_type;
int16_t last_gun_type;
int16_t calc_fallspeed;
int16_t water_status;
int16_t climb_status;
int16_t pose_count;
int16_t hit_frame;
int16_t hit_direction;
int16_t air;
int16_t dive_count;
int16_t death_count;
int16_t current_active;
int16_t spaz_effect_count;
int16_t flare_age;
int16_t skidoo;
int16_t weapon_item;
int16_t back_gun;
int16_t flare_frame;
uint16_t flare_control_left : 1;
uint16_t flare_control_right : 1;
uint16_t extra_anim : 1;
uint16_t look : 1;
uint16_t burn : 1;
uint16_t keep_ducked : 1;
uint16_t can_monkey_swing : 1;
uint16_t pad : 9;
int32_t water_surface_dist;
struct PHD_VECTOR last_pos;
struct FX_INFO *spaz_effect;
uint32_t mesh_effects;
int16_t *mesh_ptrs[15];
struct ITEM_INFO *target;
int16_t target_angles[2];
int16_t turn_rate;
int16_t move_angle;
int16_t head_y_rot;
int16_t head_x_rot;
int16_t head_z_rot;
int16_t torso_y_rot;
int16_t torso_x_rot;
int16_t torso_z_rot;
struct LARA_ARM left_arm;
struct LARA_ARM right_arm;
struct AMMO_INFO pistol_ammo;
struct AMMO_INFO magnum_ammo;
struct AMMO_INFO uzi_ammo;
struct AMMO_INFO shotgun_ammo;
struct AMMO_INFO harpoon_ammo;
struct AMMO_INFO grenade_ammo;
struct AMMO_INFO m16_ammo;
struct CREATURE_INFO *creature;
} LARA_INFO;

# FUNCTIONS
# Flags:
# - to do
Expand Down Expand Up @@ -737,7 +853,7 @@ typedef struct CREATURE_INFO {
00402430 00000033 - void __cdecl Output_SortPolyList(void);
00402470 000000C5 - void __cdecl Output_QuickSort(int32_t left, int32_t right);
00402540 00000036 - void __cdecl Output_PrintPolyList(uint8_t *surface_ptr);
00402580 000000A1 - void __cdecl Viewport_AlterFOV(int16_t fov);
00402580 000000A1 * void __cdecl Viewport_AlterFOV(int16_t fov);
00402690 00000095 - void __cdecl Output_SetNearZ(int32_t near_z);
004026E0 0000006B - void __cdecl Output_SetFarZ(int32_t far_z);
00402700 00000266 - void __cdecl Viewport_Init(int16_t x, int16_t y, int32_t width, int32_t height, int32_t near_z, int32_t far_z, int16_t view_angle, int32_t screen_width, int32_t screen_height);
Expand Down Expand Up @@ -851,7 +967,7 @@ typedef struct CREATURE_INFO {
004103C0 000001DB - void __cdecl Creature_GetBaddieTarget(int16_t item_num, int32_t goody);

# game/camera.c
004105A0 000000B0 - void __cdecl Camera_Initialise(void);
004105A0 000000B0 + void __cdecl Camera_Initialise(void);
00410650 00000372 - void __cdecl Camera_Move(struct GAME_VECTOR *ideal, int32_t speed);
004109D0 000000D7 - void __cdecl Camera_Clip(int32_t *x, int32_t *y, int32_t *h, int32_t target_x, int32_t target_y, int32_t target_h, int32_t left, int32_t top, int32_t right, int32_t bottom);
00410AB0 00000154 - void __cdecl Camera_Shift(int32_t *x, int32_t *y, int32_t *h, int32_t target_x, int32_t target_y, int32_t target_h, int32_t left, int32_t top, int32_t right, int32_t bottom);
Expand All @@ -862,7 +978,7 @@ typedef struct CREATURE_INFO {
00411680 0000018E - void __cdecl Camera_Combat(struct ITEM_INFO *item);
00411810 000001E2 - void __cdecl Camera_Look(struct ITEM_INFO *item);
00411A00 00000099 - void __cdecl Camera_Fixed(void);
00411AA0 000004A9 - void __cdecl Camera_Update(void);
00411AA0 000004A9 * void __cdecl Camera_Update(void);
00411F50 0000000A - void __cdecl Camera_SetCutsceneTrack(int32_t track);
00411F60 00000112 - int32_t __cdecl Game_Cutscene_Start(int32_t level_num);
00412080 00000093 -R void __cdecl Misc_InitCinematicRooms(void);
Expand Down Expand Up @@ -1802,8 +1918,8 @@ typedef struct CREATURE_INFO {
0044CA20 0000004C -R void __cdecl GetSavedGamesList(REQUEST_INFO *req);
0044CA70 00000233 -R void __cdecl DisplayCredits(void);
0044CCB0 00000165 -R BOOL __cdecl S_FrontEndCheck(void);
0044CE20 00000114 -R BOOL __cdecl S_SaveGame(LPCVOID saveData, DWORD saveSize, int32_t slotNumber);
0044CF40 00000096 -R BOOL __cdecl S_LoadGame(LPVOID saveData, DWORD saveSize, int32_t slotNumber);
0044CE20 00000114 -R int32_t __cdecl S_SaveGame(const void *save_data, uint32_t save_size, int32_t slot_num);
0044CF40 00000096 -R int32_t __cdecl S_LoadGame(void *save_data, uint32_t save_size, int32_t slot_num);
0044CFE0 00000128 -R void __cdecl HWR_InitState(void);
0044D110 00000029 -R void __cdecl HWR_ResetTexSource(void);
0044D140 0000002B -R void __cdecl HWR_ResetColorKey(void);
Expand Down Expand Up @@ -1863,7 +1979,7 @@ typedef struct CREATURE_INFO {
00450CC0 00000270 -R int32_t __cdecl S_GetObjectBounds(int16_t *bPtr);
00450F30 00000046 -R void __cdecl S_InsertBackPolygon(int32_t x0, int32_t y0, int32_t x1, int32_t y1);
00450F80 000001F1 -R void __cdecl S_PrintShadow(int16_t radius, int16_t *bPtr, ITEM_INFO *item);
00451180 000002F6 -R void __cdecl S_CalculateLight(int32_t x, int32_t y, int32_t z, int16_t roomNumber);
00451180 000002F6 -R void __cdecl S_CalculateLight(int32_t x, int32_t y, int32_t z, int16_t room_num);
00451480 00000031 -R void __cdecl S_CalculateStaticLight(int16_t adder);
004514C0 00000124 -R void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM_INFO *room);
004515F0 00000206 -R void __cdecl S_LightRoom(ROOM_INFO *room);
Expand Down Expand Up @@ -1921,13 +2037,13 @@ typedef struct CREATURE_INFO {
00454950 0000000E -R void __cdecl SE_AdvancedDlgInit(HWND hwndDlg);
00454960 00000011 -R HWND __cdecl SE_FindSetupDialog(void);
00454980 000002D0 -R BOOL __cdecl GameMain(void);
00454C50 00000110 -R __int16 __cdecl TitleSequence(void);
00454C50 00000110 -R int16_t __cdecl TitleSequence(void);
00454D60 0000032D -R void __cdecl CheckCheatMode(void);
004550C0 0000007D -R void __cdecl S_SaveSettings(void);
00455140 000000DB -R void __cdecl S_LoadSettings(void);
00455220 00000046 -R int32_t __cdecl S_SoundPlaySample(int32_t channel, UINT16 volume, int32_t pitch, int32_t pan);
00455270 0000002A -R int32_t __cdecl S_Sound_CalculateSampleVolume(DWORD volume);
004552A0 00000026 -R int32_t __cdecl S_Sound_CalculateSamplePan(__int16 pan);
004552A0 00000026 -R int32_t __cdecl S_Sound_CalculateSamplePan(int16_t pan);
004552D0 00000046 -R int32_t __cdecl S_SoundPlaySampleLooped(int32_t channel, UINT16 volume, DWORD pitch, int32_t pan);
00455320 00000039 -R void __cdecl S_SoundSetPanAndVolume(int32_t channel, int32_t pan, UINT16 volume);
00455360 0000001C -R void __cdecl S_SoundSetPitch(int32_t channel, DWORD pitch);
Expand All @@ -1937,7 +2053,7 @@ typedef struct CREATURE_INFO {
004553C0 0000001F -R BOOL __cdecl S_SoundSampleIsPlaying(int32_t channel);
004553E0 00000077 -R bool __cdecl CD_Init(void);
00455460 00000051 -R void __cdecl CD_Cleanup(void);
00455500 0000006F -R void __cdecl S_CDPlay(__int16 trackID, BOOL isLooped);
00455500 0000006F -R void __cdecl S_CDPlay(int16_t trackID, BOOL isLooped);
00455570 00000039 -R void __cdecl S_CDStop(void);
004555B0 00000084 -R BOOL __cdecl StartSyncedAudio(int32_t trackID);
00455640 00000061 -R DWORD __cdecl S_CDGetLoc(void);
Expand Down Expand Up @@ -2050,5 +2166,10 @@ typedef struct CREATURE_INFO {
004BF3E0 - struct PHD_VBUF g_PhdVBuf[1500];
004D6B60 - float g_FltWinRight;
004D6BF8 - int32_t g_PhdWinRight;
004D778C - int32_t g_IsChunkyCamera;
0051BD20 - char g_ErrorMessage[128];
005206E0 - struct LARA_INFO g_Lara;
005207BC - struct ITEM_INFO *g_LaraItem;
005262F0 - struct ITEM_INFO g_Items[];
00526320 - struct CAMERA_INFO g_Camera;
005263CC - struct BOX_INFO *g_Boxes;
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ exe_sources = [

dll_sources = [
'src/filesystem.c',
'src/game/camera.c',
'src/game/math.c',
'src/game/matrix.c',
'src/game/shell.c',
Expand Down
37 changes: 37 additions & 0 deletions src/game/camera.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "game/camera.h"

#include "global/const.h"
#include "global/funcs.h"
#include "global/vars.h"

void __cdecl Camera_Initialise(void)
{
g_Camera.shift = g_LaraItem->pos.y - WALL_L;

g_Camera.target.x = g_LaraItem->pos.x;
g_Camera.target.y = g_Camera.shift;
g_Camera.target.z = g_LaraItem->pos.z;
g_Camera.target.room_num = g_LaraItem->room_num;

g_Camera.pos.x = g_Camera.target.x;
g_Camera.pos.y = g_Camera.shift;
g_Camera.pos.z = g_Camera.target.z - 100;
g_Camera.pos.room_num = g_LaraItem->room_num;

g_Camera.target_distance = WALL_L * 3 / 2;
g_Camera.item = NULL;

g_Camera.num_frames = 1;
if (!g_Lara.extra_anim) {
g_Camera.type = CAM_CHASE;
}

g_Camera.speed = 1;
g_Camera.flags = 0;
g_Camera.bounce = 0;
g_Camera.num = -1;
g_Camera.fixed_camera = 0;

Viewport_AlterFOV(GAME_FOV * PHD_DEGREE);
Camera_Update();
}
5 changes: 5 additions & 0 deletions src/game/camera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "global/types.h"

void __cdecl Camera_Initialise(void);
2 changes: 2 additions & 0 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
#define PHD_135 (PHD_45 * 3) // = 24576 = 0x6000

#define W2V_MATRIX 14
#define WALL_L 1024
#define GAME_FOV 80
13 changes: 6 additions & 7 deletions src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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_Initialise ((void __cdecl (*)(void))0x004105A0)
#define Camera_Move ((void __cdecl (*)(struct GAME_VECTOR *ideal, int32_t speed))0x00410650)
#define Camera_Clip ((void __cdecl (*)(int32_t *x, int32_t *y, int32_t *h, int32_t target_x, int32_t target_y, int32_t target_h, int32_t left, int32_t top, int32_t right, int32_t bottom))0x004109D0)
#define Camera_Shift ((void __cdecl (*)(int32_t *x, int32_t *y, int32_t *h, int32_t target_x, int32_t target_y, int32_t target_h, int32_t left, int32_t top, int32_t right, int32_t bottom))0x00410AB0)
Expand Down Expand Up @@ -955,8 +954,8 @@
#define GetSavedGamesList ((void __cdecl (*)(REQUEST_INFO *req))0x0044CA20)
#define DisplayCredits ((void __cdecl (*)(void))0x0044CA70)
#define S_FrontEndCheck ((BOOL __cdecl (*)(void))0x0044CCB0)
#define S_SaveGame ((BOOL __cdecl (*)(LPCVOID saveData, DWORD saveSize, int32_t slotNumber))0x0044CE20)
#define S_LoadGame ((BOOL __cdecl (*)(LPVOID saveData, DWORD saveSize, int32_t slotNumber))0x0044CF40)
#define S_SaveGame ((int32_t __cdecl (*)(const void *save_data, uint32_t save_size, int32_t slot_num))0x0044CE20)
#define S_LoadGame ((int32_t __cdecl (*)(void *save_data, uint32_t save_size, int32_t slot_num))0x0044CF40)
#define HWR_InitState ((void __cdecl (*)(void))0x0044CFE0)
#define HWR_ResetTexSource ((void __cdecl (*)(void))0x0044D110)
#define HWR_ResetColorKey ((void __cdecl (*)(void))0x0044D140)
Expand Down Expand Up @@ -1012,7 +1011,7 @@
#define S_GetObjectBounds ((int32_t __cdecl (*)(int16_t *bPtr))0x00450CC0)
#define S_InsertBackPolygon ((void __cdecl (*)(int32_t x0, int32_t y0, int32_t x1, int32_t y1))0x00450F30)
#define S_PrintShadow ((void __cdecl (*)(int16_t radius, int16_t *bPtr, ITEM_INFO *item))0x00450F80)
#define S_CalculateLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t roomNumber))0x00451180)
#define S_CalculateLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t room_num))0x00451180)
#define S_CalculateStaticLight ((void __cdecl (*)(int16_t adder))0x00451480)
#define S_CalculateStaticMeshLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM_INFO *room))0x004514C0)
#define S_LightRoom ((void __cdecl (*)(ROOM_INFO *room))0x004515F0)
Expand Down Expand Up @@ -1068,13 +1067,13 @@
#define SE_AdvancedDlgInit ((void __cdecl (*)(HWND hwndDlg))0x00454950)
#define SE_FindSetupDialog ((HWND __cdecl (*)(void))0x00454960)
#define GameMain ((BOOL __cdecl (*)(void))0x00454980)
#define TitleSequence ((__int16 __cdecl (*)(void))0x00454C50)
#define TitleSequence ((int16_t __cdecl (*)(void))0x00454C50)
#define CheckCheatMode ((void __cdecl (*)(void))0x00454D60)
#define S_SaveSettings ((void __cdecl (*)(void))0x004550C0)
#define S_LoadSettings ((void __cdecl (*)(void))0x00455140)
#define S_SoundPlaySample ((int32_t __cdecl (*)(int32_t channel, UINT16 volume, int32_t pitch, int32_t pan))0x00455220)
#define S_Sound_CalculateSampleVolume ((int32_t __cdecl (*)(DWORD volume))0x00455270)
#define S_Sound_CalculateSamplePan ((int32_t __cdecl (*)(__int16 pan))0x004552A0)
#define S_Sound_CalculateSamplePan ((int32_t __cdecl (*)(int16_t pan))0x004552A0)
#define S_SoundPlaySampleLooped ((int32_t __cdecl (*)(int32_t channel, UINT16 volume, DWORD pitch, int32_t pan))0x004552D0)
#define S_SoundSetPanAndVolume ((void __cdecl (*)(int32_t channel, int32_t pan, UINT16 volume))0x00455320)
#define S_SoundSetPitch ((void __cdecl (*)(int32_t channel, DWORD pitch))0x00455360)
Expand All @@ -1084,7 +1083,7 @@
#define S_SoundSampleIsPlaying ((BOOL __cdecl (*)(int32_t channel))0x004553C0)
#define CD_Init ((bool __cdecl (*)(void))0x004553E0)
#define CD_Cleanup ((void __cdecl (*)(void))0x00455460)
#define S_CDPlay ((void __cdecl (*)(__int16 trackID, BOOL isLooped))0x00455500)
#define S_CDPlay ((void __cdecl (*)(int16_t trackID, BOOL isLooped))0x00455500)
#define S_CDStop ((void __cdecl (*)(void))0x00455570)
#define StartSyncedAudio ((BOOL __cdecl (*)(int32_t trackID))0x004555B0)
#define S_CDGetLoc ((DWORD __cdecl (*)(void))0x00455640)
Expand Down
Loading

0 comments on commit e0fbe19

Please sign in to comment.