diff --git a/src/config.c b/src/config.c index 9ec8b272a..5d870d8cd 100644 --- a/src/config.c +++ b/src/config.c @@ -37,6 +37,8 @@ T1MConfigStruct T1MConfig = { 0 }; +static const char *T1MGlobalSettingsPath = "cfg/Tomb1Main.json5"; + static int8_t ReadBarShowingMode( struct json_object_s *obj, const char *name, int8_t default_value) { diff --git a/src/config.h b/src/config.h index 531b9c58b..b921cdcd1 100644 --- a/src/config.h +++ b/src/config.h @@ -86,6 +86,11 @@ typedef struct { uint32_t fps_counter : 1; } render_flags; + struct { + double text_scale; + double bar_scale; + } ui; + int32_t sound_volume; int32_t music_volume; } T1MConfigStruct; diff --git a/src/game/demo.c b/src/game/demo.c index 4d3e71b4c..566e09fef 100644 --- a/src/game/demo.c +++ b/src/game/demo.c @@ -13,6 +13,8 @@ #include +static int32_t DemoLevel = -1; + int32_t StartDemo() { TEXTSTRING *txt; diff --git a/src/game/draw.c b/src/game/draw.c index e3d2b79cf..15de3a310 100644 --- a/src/game/draw.c +++ b/src/game/draw.c @@ -19,6 +19,7 @@ static PHD_MATRIX *IMMatrixPtr = NULL; static PHD_MATRIX IMMatrixStack[MAX_NESTED_MATRICES] = { 0 }; static int32_t IMRate = 0; static int32_t IMFrac = 0; +static bool CameraUnderwater = false; int32_t DrawPhaseCinematic() { diff --git a/src/game/inventry.c b/src/game/inventry.c index 0c623979c..d51947355 100644 --- a/src/game/inventry.c +++ b/src/game/inventry.c @@ -54,7 +54,7 @@ int32_t Display_Inventory(int inv_mode) int32_t pass_mode_open = 0; if (AmmoText) { T_RemovePrint(AmmoText); - AmmoText = 0; + AmmoText = NULL; } AlterFOV(T1MConfig.fov_value * PHD_DEGREE); @@ -126,7 +126,7 @@ int32_t Display_Inventory(int inv_mode) if (IDCount) { IDCount--; } else { - IDelay = 0; + IDelay = false; } } Inv_RingDoMotions(&ring); diff --git a/src/game/lot.c b/src/game/lot.c index e97d4778b..92abb46fb 100644 --- a/src/game/lot.c +++ b/src/game/lot.c @@ -6,6 +6,9 @@ #include +static int32_t SlotsUsed = 0; +static CREATURE_INFO *BaddieSlots = NULL; + void InitialiseLOTArray() { BaddieSlots = diff --git a/src/game/option.c b/src/game/option.c index 9c0a7623c..009d68e88 100644 --- a/src/game/option.c +++ b/src/game/option.c @@ -74,6 +74,10 @@ typedef struct TEXT_COLUMN_PLACEMENT { int col_num; } TEXT_COLUMN_PLACEMENT; +static int32_t PassportMode = 0; +static int32_t KeyMode = 0; +static int32_t KeyChange = 0; + static TEXTSTRING *PassportText = NULL; static TEXTSTRING *DetailTextHW[DETAIL_HW_NUMBER_OF] = { 0 }; static TEXTSTRING *SoundText[4] = { 0 }; @@ -140,9 +144,6 @@ static const TEXT_COLUMN_PLACEMENT CtrlTextPlacementCheats[] = { { -1, -1 }, }; -static int32_t PassportMode = 0; -static int32_t KeyMode = 0; - static char NewGameStrings[MAX_GAME_MODES][MAX_GAME_MODE_LENGTH] = { 0 }; REQUEST_INFO NewGameRequester = { MAX_GAME_MODES, // items @@ -669,11 +670,15 @@ void DoDetailOption(INVENTORY_ITEM *inv_item) DetailTextHW[DETAIL_HW_BILINEAR] = T_Print(0, y, buf); y += DETAIL_HW_ROW_HEIGHT; - sprintf(buf, GF.strings[GS_DETAIL_UI_TEXT_SCALE_FMT], UITextScale); + sprintf( + buf, GF.strings[GS_DETAIL_UI_TEXT_SCALE_FMT], + T1MConfig.ui.text_scale); DetailTextHW[DETAIL_HW_UI_TEXT_SCALE] = T_Print(0, y, buf); y += DETAIL_HW_ROW_HEIGHT; - sprintf(buf, GF.strings[GS_DETAIL_UI_BAR_SCALE_FMT], UIBarScale); + sprintf( + buf, GF.strings[GS_DETAIL_UI_BAR_SCALE_FMT], + T1MConfig.ui.bar_scale); DetailTextHW[DETAIL_HW_UI_BAR_SCALE] = T_Print(0, y, buf); y += DETAIL_HW_ROW_HEIGHT; @@ -747,15 +752,15 @@ void DoDetailOption(INVENTORY_ITEM *inv_item) break; case DETAIL_HW_UI_TEXT_SCALE: - if (UITextScale < MAX_UI_SCALE) { - UITextScale += 0.1; + if (T1MConfig.ui.text_scale < MAX_UI_SCALE) { + T1MConfig.ui.text_scale += 0.1; reset = 1; } break; case DETAIL_HW_UI_BAR_SCALE: - if (UIBarScale < MAX_UI_SCALE) { - UIBarScale += 0.1; + if (T1MConfig.ui.bar_scale < MAX_UI_SCALE) { + T1MConfig.ui.bar_scale += 0.1; reset = 1; } break; @@ -785,15 +790,15 @@ void DoDetailOption(INVENTORY_ITEM *inv_item) break; case DETAIL_HW_UI_TEXT_SCALE: - if (UITextScale > MIN_UI_SCALE) { - UITextScale -= 0.1; + if (T1MConfig.ui.text_scale > MIN_UI_SCALE) { + T1MConfig.ui.text_scale -= 0.1; reset = 1; } break; case DETAIL_HW_UI_BAR_SCALE: - if (UIBarScale > MIN_UI_SCALE) { - UIBarScale -= 0.1; + if (T1MConfig.ui.bar_scale > MIN_UI_SCALE) { + T1MConfig.ui.bar_scale -= 0.1; reset = 1; } break; @@ -871,14 +876,14 @@ void DoSoundOption(INVENTORY_ITEM *inv_item) case SOUND_MUSIC_VOLUME: if (Input.left && T1MConfig.music_volume > 0) { T1MConfig.music_volume--; - IDelay = 1; + IDelay = true; IDCount = 10; sprintf(buf, "| %2d", T1MConfig.music_volume); T_ChangeText(SoundText[SOUND_MUSIC_VOLUME], buf); S_WriteUserSettings(); } else if (Input.right && T1MConfig.music_volume < 10) { T1MConfig.music_volume++; - IDelay = 1; + IDelay = true; IDCount = 10; sprintf(buf, "| %2d", T1MConfig.music_volume); T_ChangeText(SoundText[SOUND_MUSIC_VOLUME], buf); @@ -898,14 +903,14 @@ void DoSoundOption(INVENTORY_ITEM *inv_item) case SOUND_SOUND_VOLUME: if (Input.left && T1MConfig.sound_volume > 0) { T1MConfig.sound_volume--; - IDelay = 1; + IDelay = true; IDCount = 10; sprintf(buf, "} %2d", T1MConfig.sound_volume); T_ChangeText(SoundText[SOUND_SOUND_VOLUME], buf); S_WriteUserSettings(); } else if (Input.right && T1MConfig.sound_volume < 10) { T1MConfig.sound_volume++; - IDelay = 1; + IDelay = true; IDCount = 10; sprintf(buf, "} %2d", T1MConfig.sound_volume); T_ChangeText(SoundText[SOUND_SOUND_VOLUME], buf); diff --git a/src/game/settings.c b/src/game/settings.c index 77f02ee15..8c3ccded5 100644 --- a/src/game/settings.c +++ b/src/game/settings.c @@ -17,6 +17,9 @@ #include #include +static const char *ATIUserSettingsPath = "atiset.dat"; +static const char *T1MUserSettingsPath = "cfg/Tomb1Main_runtime.json5"; + static int32_t S_ReadUserSettingsATI(); static int32_t S_ReadUserSettingsT1M(); static int32_t S_ReadUserSettingsT1MFromJson(const char *cfg_data); @@ -56,8 +59,8 @@ static int32_t S_ReadUserSettingsATI() FileRead(&T1MConfig.input.layout, sizeof(int32_t), 1, fp); - UITextScale = DEFAULT_UI_SCALE; - UIBarScale = DEFAULT_UI_SCALE; + T1MConfig.ui.text_scale = DEFAULT_UI_SCALE; + T1MConfig.ui.bar_scale = DEFAULT_UI_SCALE; FileClose(fp); return 1; @@ -109,13 +112,13 @@ static int32_t S_ReadUserSettingsT1MFromJson(const char *cfg_data) json_object_get_number_int(root_obj, "layout_num", 0); CLAMP(T1MConfig.input.layout, 0, 1); - UITextScale = json_object_get_number_double( + T1MConfig.ui.text_scale = json_object_get_number_double( root_obj, "ui_text_scale", DEFAULT_UI_SCALE); - CLAMP(UITextScale, MIN_UI_SCALE, MAX_UI_SCALE); + CLAMP(T1MConfig.ui.text_scale, MIN_UI_SCALE, MAX_UI_SCALE); - UIBarScale = json_object_get_number_double( + T1MConfig.ui.bar_scale = json_object_get_number_double( root_obj, "ui_bar_scale", DEFAULT_UI_SCALE); - CLAMP(UIBarScale, MIN_UI_SCALE, MAX_UI_SCALE); + CLAMP(T1MConfig.ui.bar_scale, MIN_UI_SCALE, MAX_UI_SCALE); struct json_array_s *layout_arr = json_object_get_array(root_obj, "layout"); for (int i = 0; i < KEY_NUMBER_OF; i++) { @@ -188,8 +191,10 @@ static int32_t S_WriteUserSettingsT1M() root_obj, "sound_volume", T1MConfig.sound_volume); json_object_append_number_int( root_obj, "layout_num", T1MConfig.input.layout); - json_object_append_number_double(root_obj, "ui_text_scale", UITextScale); - json_object_append_number_double(root_obj, "ui_bar_scale", UIBarScale); + json_object_append_number_double( + root_obj, "ui_text_scale", T1MConfig.ui.text_scale); + json_object_append_number_double( + root_obj, "ui_bar_scale", T1MConfig.ui.bar_scale); struct json_array_s *layout_arr = json_array_new(); for (int i = 0; i < KEY_NUMBER_OF; i++) { diff --git a/src/global/vars.c b/src/global/vars.c index 635a3eaf8..ec11014b1 100644 --- a/src/global/vars.c +++ b/src/global/vars.c @@ -15,16 +15,7 @@ #include "game/effects/turn_180.h" #include "global/vars.h" -const char *ATIUserSettingsPath = "atiset.dat"; -const char *T1MUserSettingsPath = "cfg/Tomb1Main_runtime.json5"; -const char *T1MGlobalSettingsPath = "cfg/Tomb1Main.json5"; -const char *T1MGameflowPath = "cfg/Tomb1Main_gameflow.json5"; -const char *T1MGameflowGoldPath = "cfg/Tomb1Main_gameflow_ub.json5"; - char *GameMemoryPointer = NULL; -int8_t IsGameWindowActive = 1; -double UITextScale = 1.0; -double UIBarScale = 1.0; TEXTSTRING *AmmoText = NULL; TEXTSTRING *FPSText = NULL; int32_t FPSCounter = 0; @@ -39,20 +30,17 @@ void (*EffectRoutines[])(ITEM_INFO *item) = { bool SoundIsActive = true; int16_t SampleLUT[MAX_SAMPLES] = { 0 }; SAMPLE_INFO *SampleInfos = NULL; -SAMPLE_DATA **SampleData = NULL; int32_t NumSampleData = 0; int16_t MusicTrack = 0; -int16_t MusicTrackLooped = 0; bool MusicLoop = false; uint16_t MusicTrackFlags[MAX_CD_TRACKS] = { 0 }; int32_t MnSoundMasterVolume = 32; int32_t NoInputCount = 0; -int32_t IDelay = 0; +bool IDelay = false; int32_t IDCount = 0; INPUT_STATE Input = { 0 }; INPUT_STATE InputDB = { 0 }; -int32_t KeyChange = 0; int32_t OptionSelected = 0; int32_t PhdWinMaxX = 0; @@ -87,12 +75,10 @@ GAMEFLOW GF = { 0 }; LARA_INFO Lara = { 0 }; ITEM_INFO *LaraItem = NULL; CAMERA_INFO Camera = { 0 }; -bool CameraUnderwater = false; SAVEGAME_INFO SaveGame = { 0 }; int32_t SavedGamesCount = 0; int32_t SaveCounter = 0; int32_t CurrentLevel = -1; -int32_t DemoLevel = -1; uint32_t *DemoPtr = NULL; int32_t DemoCount = 0; int32_t LevelComplete = 0; @@ -125,8 +111,6 @@ uint16_t *Overlap = NULL; int16_t *GroundZone[2] = { NULL }; int16_t *GroundZone2[2] = { NULL }; int16_t *FlyZone[2] = { NULL }; -int32_t SlotsUsed = 0; -CREATURE_INFO *BaddieSlots = NULL; ANIM_STRUCT *Anims = NULL; ANIM_CHANGE_STRUCT *AnimChanges = NULL; ANIM_RANGE_STRUCT *AnimRanges = NULL; diff --git a/src/global/vars.h b/src/global/vars.h index e97bc1fec..b10f4ab7a 100644 --- a/src/global/vars.h +++ b/src/global/vars.h @@ -37,33 +37,20 @@ extern RGB888 GamePalette[256]; extern bool ModeLock; extern int32_t NoInputCount; -extern int32_t IDelay; +extern bool IDelay; extern int32_t IDCount; extern INPUT_STATE Input; extern INPUT_STATE InputDB; -extern int32_t KeyChange; extern int32_t OptionSelected; extern bool SoundIsActive; extern int16_t SampleLUT[MAX_SAMPLES]; extern SAMPLE_INFO *SampleInfos; -extern SAMPLE_DATA **SampleData; -extern int32_t NumSampleData; extern int16_t MusicTrack; -extern int16_t MusicTrackLooped; extern bool MusicLoop; extern uint16_t MusicTrackFlags[MAX_CD_TRACKS]; extern int32_t MnSoundMasterVolume; -extern const char *ATIUserSettingsPath; -extern const char *T1MUserSettingsPath; -extern const char *T1MGlobalSettingsPath; -extern const char *T1MGameflowPath; -extern const char *T1MGameflowGoldPath; - -extern int8_t IsGameWindowActive; -extern double UITextScale; -extern double UIBarScale; extern TEXTSTRING *AmmoText; extern TEXTSTRING *FPSText; extern int32_t FPSCounter; @@ -74,12 +61,10 @@ extern GAMEFLOW GF; extern LARA_INFO Lara; extern ITEM_INFO *LaraItem; extern CAMERA_INFO Camera; -extern bool CameraUnderwater; extern SAVEGAME_INFO SaveGame; extern int32_t SavedGamesCount; extern int32_t SaveCounter; extern int32_t CurrentLevel; -extern int32_t DemoLevel; extern uint32_t *DemoPtr; extern int32_t DemoCount; extern int32_t LevelComplete; @@ -109,8 +94,6 @@ extern uint16_t *Overlap; extern int16_t *GroundZone[2]; extern int16_t *GroundZone2[2]; extern int16_t *FlyZone[2]; -extern int32_t SlotsUsed; -extern CREATURE_INFO *BaddieSlots; extern ANIM_STRUCT *Anims; extern ANIM_CHANGE_STRUCT *AnimChanges; extern ANIM_RANGE_STRUCT *AnimRanges; diff --git a/src/specific/output.c b/src/specific/output.c index 17779e72c..df7b72b7c 100644 --- a/src/specific/output.c +++ b/src/specific/output.c @@ -109,11 +109,11 @@ int32_t GetRenderScale(int32_t unit) int32_t baseWidth = 640; int32_t baseHeight = 480; int32_t scale_x = PhdWinWidth > baseWidth - ? ((double)PhdWinWidth * unit * UITextScale) / baseWidth - : unit * UITextScale; + ? ((double)PhdWinWidth * unit * T1MConfig.ui.text_scale) / baseWidth + : unit * T1MConfig.ui.text_scale; int32_t scale_y = PhdWinHeight > baseHeight - ? ((double)PhdWinHeight * unit * UITextScale) / baseHeight - : unit * UITextScale; + ? ((double)PhdWinHeight * unit * T1MConfig.ui.text_scale) / baseHeight + : unit * T1MConfig.ui.text_scale; return MIN(scale_x, scale_y); } @@ -129,7 +129,8 @@ void BarLocation( } else if ( bar_location == T1M_BL_TOP_RIGHT || bar_location == T1M_BL_BOTTOM_RIGHT) { - *x = GetRenderWidthDownscaled() - width * UIBarScale - screen_margin_h; + *x = GetRenderWidthDownscaled() - width * T1MConfig.ui.bar_scale + - screen_margin_h; } else { *x = (GetRenderWidthDownscaled() - width) / 2; } @@ -138,8 +139,8 @@ void BarLocation( || bar_location == T1M_BL_TOP_RIGHT) { *y = screen_margin_v + BarOffsetY[bar_location]; } else { - *y = GetRenderHeightDownscaled() - height * UIBarScale - screen_margin_v - - BarOffsetY[bar_location]; + *y = GetRenderHeightDownscaled() - height * T1MConfig.ui.bar_scale + - screen_margin_v - BarOffsetY[bar_location]; } BarOffsetY[bar_location] += height + bar_spacing; @@ -182,8 +183,8 @@ void RenderBar(int32_t value, int32_t value_max, int32_t bar_type) int32_t border = 1; int32_t sx = GetRenderScale(x) - padding; int32_t sy = GetRenderScale(y) - padding; - int32_t sw = GetRenderScale(width) * UIBarScale + padding * 2; - int32_t sh = GetRenderScale(height) * UIBarScale + padding * 2; + int32_t sw = GetRenderScale(width) * T1MConfig.ui.bar_scale + padding * 2; + int32_t sh = GetRenderScale(height) * T1MConfig.ui.bar_scale + padding * 2; // border S_DrawScreenFlatQuad( @@ -204,8 +205,8 @@ void RenderBar(int32_t value, int32_t value_max, int32_t bar_type) sx = GetRenderScale(x); sy = GetRenderScale(y); - sw = GetRenderScale(width) * UIBarScale; - sh = GetRenderScale(height) * UIBarScale; + sw = GetRenderScale(width) * T1MConfig.ui.bar_scale; + sh = GetRenderScale(height) * T1MConfig.ui.bar_scale; if (T1MConfig.enable_smooth_bars) { for (int i = 0; i < COLOR_STEPS - 1; i++) { diff --git a/src/specific/shell.c b/src/specific/shell.c index c0eb41a31..10e206dec 100644 --- a/src/specific/shell.c +++ b/src/specific/shell.c @@ -27,6 +27,9 @@ #include #include +static const char *T1MGameflowPath = "cfg/Tomb1Main_gameflow.json5"; +static const char *T1MGameflowGoldPath = "cfg/Tomb1Main_gameflow_ub.json5"; + void GameMain() { SoundIsActive = true; diff --git a/src/specific/smain.c b/src/specific/smain.c index 80f3470b1..d1a46b8a1 100644 --- a/src/specific/smain.c +++ b/src/specific/smain.c @@ -20,6 +20,7 @@ static const char *ClassName = "TRClass"; static const char *WindowName = "Tomb Raider"; static UINT CloseMsg = 0; +static bool IsGameWindowActive = true; static void WinGameFinish(); static LRESULT CALLBACK diff --git a/src/specific/sndpc.c b/src/specific/sndpc.c index b89a35200..ec204c91f 100644 --- a/src/specific/sndpc.c +++ b/src/specific/sndpc.c @@ -48,6 +48,9 @@ typedef struct WAVE_FILE_HEADER { static DUPE_SOUND_BUFFER *DupeSoundBufferList = NULL; static int32_t DecibelLUT[DECIBEL_LUT_SIZE] = { 0 }; static int32_t MusicNumTracks = 0; +static int16_t MusicTrackLooped = 0; +extern int32_t NumSampleData; +static SAMPLE_DATA **SampleData = NULL; int32_t ConvertVolumeToDecibel(int32_t volume) {