Skip to content

Commit

Permalink
const: rename FRAMES_PER_SECOND to LOGIC_FPS
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Mar 29, 2024
1 parent 0d59b24 commit d0ae12e
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void Camera_RefreshFromTrigger(int16_t type, int16_t *data)

void Camera_MoveManual(void)
{
int16_t camera_delta = (const int)PHD_90 / (const int)FRAMES_PER_SECOND
int16_t camera_delta = (const int)PHD_90 / (const int)LOGIC_FPS
* (double)m_ManualCameraMultiplier[g_Config.camera_speed];

if (g_Input.camera_left) {
Expand Down
7 changes: 3 additions & 4 deletions src/game/effect_routines/flood.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

void FX_Flood(ITEM_INFO *item)
{
if (g_FlipTimer > FRAMES_PER_SECOND * 4) {
if (g_FlipTimer > LOGIC_FPS * 4) {
g_FlipEffect = -1;
} else {
const int32_t timer = g_FlipTimer < FRAMES_PER_SECOND
? FRAMES_PER_SECOND - g_FlipTimer
: g_FlipTimer - FRAMES_PER_SECOND;
const int32_t timer = g_FlipTimer < LOGIC_FPS ? LOGIC_FPS - g_FlipTimer
: g_FlipTimer - LOGIC_FPS;
const XYZ_32 pos = {
.x = g_LaraItem->pos.x,
.y = g_Camera.target.y + timer * 100,
Expand Down
2 changes: 1 addition & 1 deletion src/game/effect_routines/powerup.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

void FX_PowerUp(ITEM_INFO *item)
{
if (g_FlipTimer > FRAMES_PER_SECOND * 4) {
if (g_FlipTimer > LOGIC_FPS * 4) {
g_FlipEffect = -1;
} else {
const XYZ_32 pos = {
Expand Down
2 changes: 1 addition & 1 deletion src/game/effect_routines/sand.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

void FX_DropSand(ITEM_INFO *item)
{
if (g_FlipTimer > FRAMES_PER_SECOND * 4) {
if (g_FlipTimer > LOGIC_FPS * 4) {
g_FlipEffect = -1;
} else {
if (!g_FlipTimer) {
Expand Down
2 changes: 1 addition & 1 deletion src/game/gameflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static bool GameFlow_LoadScriptMeta(struct json_object_s *obj)
LOG_ERROR("'demo_delay' must be a positive number");
return false;
}
g_GameFlow.demo_delay = tmp_d * FRAMES_PER_SECOND;
g_GameFlow.demo_delay = tmp_d * LOGIC_FPS;

g_GameFlow.force_game_modes =
GameFlow_ReadTristateBool(obj, "force_game_modes");
Expand Down
2 changes: 1 addition & 1 deletion src/game/lara/lara_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void Lara_HandleUnderwater(ITEM_INFO *item, COLL_INFO *coll)
if (m_OpenDoorsCheatCooldown) {
m_OpenDoorsCheatCooldown--;
} else if (g_Input.draw) {
m_OpenDoorsCheatCooldown = FRAMES_PER_SECOND;
m_OpenDoorsCheatCooldown = LOGIC_FPS;
Door_OpenNearest(g_LaraItem);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/objects/creatures/natla.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define NATLA_FLY_TURN (PHD_DEGREE * 5) // = 910
#define NATLA_RUN_TURN (PHD_DEGREE * 6) // = 1092
#define NATLA_LAND_CHANCE 256
#define NATLA_DIE_TIME (FRAMES_PER_SECOND * 16) // = 480
#define NATLA_DIE_TIME (LOGIC_FPS * 16) // = 480
#define NATLA_GUN_SPEED 400
#define NATLA_HITPOINTS 400
#define NATLA_RADIUS (WALL_L / 5) // = 204
Expand Down
2 changes: 1 addition & 1 deletion src/game/objects/general/scion.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void Scion_Control3(int16_t item_num)
}

counter++;
if (counter >= FRAMES_PER_SECOND * 3) {
if (counter >= LOGIC_FPS * 3) {
Item_Kill(item_num);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/objects/general/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool Switch_Trigger(int16_t item_num, int16_t timer)
if (item->current_anim_state == SWITCH_STATE_OFF && timer > 0) {
item->timer = timer;
if (timer != 1) {
item->timer *= FRAMES_PER_SECOND;
item->timer *= LOGIC_FPS;
}
item->status = IS_ACTIVE;
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/game/option/option_compass.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ void Option_Compass(INVENTORY_ITEM *inv_item)
Option_CompassInitText();
}

int32_t seconds = g_GameInfo.current[g_CurrentLevel].stats.timer / 30;
int32_t seconds =
g_GameInfo.current[g_CurrentLevel].stats.timer / LOGIC_FPS;
int32_t hours = seconds / 3600;
int32_t minutes = (seconds / 60) % 60;
seconds %= 60;
Expand Down
12 changes: 6 additions & 6 deletions src/game/option/option_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define UNBIND_SCANCODE 0
#define UNBIND_ENUM -1
#define BUTTON_HOLD_TIME 2
#define HOLD_DELAY_FRAMES 300 * FRAMES_PER_SECOND / 1000
#define HOLD_DELAY_FRAMES 300 * LOGIC_FPS / 1000

typedef enum KEYMODE {
KM_INACTIVE = 0,
Expand Down Expand Up @@ -561,7 +561,7 @@ static void Option_ControlProgressBar(TEXTSTRING *txt, int32_t timer)
y += Screen_GetResHeightDownscaled(RSR_TEXT);
}

int32_t percent = (timer * 100) / (FRAMES_PER_SECOND * BUTTON_HOLD_TIME);
int32_t percent = (timer * 100) / (LOGIC_FPS * BUTTON_HOLD_TIME);
CLAMP(percent, 0, 100);
Text_AddProgressBar(
txt, width, height, x, y, percent, g_Config.ui.menu_style);
Expand All @@ -577,7 +577,7 @@ static void Option_ControlCheckResetKeys(
if (m_ResetKeyDelay >= HOLD_DELAY_FRAMES) {
m_ResetKeyMode = KM_CHANGE;
m_ResetTimer++;
if (m_ResetTimer >= FRAMES_PER_SECOND * BUTTON_HOLD_TIME) {
if (m_ResetTimer >= LOGIC_FPS * BUTTON_HOLD_TIME) {
Sound_Effect(SFX_MENU_GAMEBOY, NULL, SPM_NORMAL);
Input_ResetLayout(mode, layout_num);
Input_CheckConflicts(mode, layout_num);
Expand All @@ -598,7 +598,7 @@ static void Option_ControlCheckResetKeys(
m_ResetKeyMode = KM_INACTIVE;
m_ResetKeyDelay = 0;
}
CLAMP(m_ResetTimer, 0, FRAMES_PER_SECOND * BUTTON_HOLD_TIME);
CLAMP(m_ResetTimer, 0, LOGIC_FPS * BUTTON_HOLD_TIME);
Option_ControlProgressBar(m_Text[TEXT_RESET], m_ResetTimer);
}

Expand All @@ -612,7 +612,7 @@ static void Option_ControlCheckUnbindKey(
if (m_UnbindKeyDelay >= HOLD_DELAY_FRAMES) {
m_UnbindKeyMode = KM_CHANGE;
m_UnbindTimer++;
if (m_UnbindTimer >= FRAMES_PER_SECOND * BUTTON_HOLD_TIME) {
if (m_UnbindTimer >= LOGIC_FPS * BUTTON_HOLD_TIME) {
Sound_Effect(SFX_MENU_GAMEBOY, NULL, SPM_NORMAL);
if (mode == CM_KEYBOARD) {
Input_AssignScancode(
Expand All @@ -639,7 +639,7 @@ static void Option_ControlCheckUnbindKey(
m_UnbindKeyMode = KM_INACTIVE;
m_UnbindKeyDelay = 0;
}
CLAMP(m_UnbindTimer, 0, FRAMES_PER_SECOND * BUTTON_HOLD_TIME);
CLAMP(m_UnbindTimer, 0, LOGIC_FPS * BUTTON_HOLD_TIME);
Option_ControlProgressBar(m_Text[TEXT_UNBIND], m_UnbindTimer);
}

Expand Down
6 changes: 3 additions & 3 deletions src/game/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

#define COLOR_STEPS 5
#define MAX_PICKUP_COLUMNS 4
#define MAX_PICKUP_DURATION_DISPLAY (FRAMES_PER_SECOND * 2)
#define MAX_PICKUP_DURATION_EASE_IN (FRAMES_PER_SECOND / 2)
#define MAX_PICKUP_DURATION_EASE_OUT FRAMES_PER_SECOND
#define MAX_PICKUP_DURATION_DISPLAY (LOGIC_FPS * 2)
#define MAX_PICKUP_DURATION_EASE_IN (LOGIC_FPS / 2)
#define MAX_PICKUP_DURATION_EASE_OUT LOGIC_FPS
#define MAX_PICKUPS 16
#define BLINK_THRESHOLD 20

Expand Down
4 changes: 2 additions & 2 deletions src/game/phase/phase_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void Phase_Stats_CreateTexts(int32_t level_num)
}

// time taken
int seconds = stats->timer / 30;
int seconds = stats->timer / LOGIC_FPS;
int hours = seconds / 3600;
int minutes = (seconds / 60) % 60;
seconds %= 60;
Expand Down Expand Up @@ -201,7 +201,7 @@ static void Phase_Stats_CreateTextsTotal(GAMEFLOW_LEVEL_TYPE level_type)
}

// time taken
int seconds = stats.timer / 30;
int seconds = stats.timer / LOGIC_FPS;
int hours = seconds / 3600;
int minutes = (seconds / 60) % 60;
seconds %= 60;
Expand Down
6 changes: 3 additions & 3 deletions src/game/room.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void Room_TriggerMusicTrack(int16_t track, int16_t flags, int16_t type)
if (g_MusicTrackFlags[track] & IF_ONESHOT) {
static int16_t gym_completion_counter = 0;
gym_completion_counter++;
if (gym_completion_counter == FRAMES_PER_SECOND * 4) {
if (gym_completion_counter == LOGIC_FPS * 4) {
g_LevelComplete = true;
gym_completion_counter = 0;
}
Expand Down Expand Up @@ -800,7 +800,7 @@ void Room_TestTriggers(int16_t *data, bool heavy)

item->timer = timer;
if (timer != 1) {
item->timer *= FRAMES_PER_SECOND;
item->timer *= LOGIC_FPS;
}

if (type == TT_SWITCH) {
Expand Down Expand Up @@ -873,7 +873,7 @@ void Room_TestTriggers(int16_t *data, bool heavy)

g_Camera.timer = camera_timer;
if (g_Camera.timer != 1) {
g_Camera.timer *= FRAMES_PER_SECOND;
g_Camera.timer *= LOGIC_FPS;
}

if (camera_flags & IF_ONESHOT) {
Expand Down
8 changes: 4 additions & 4 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#define MAX_BRIGHTNESS 2.0f
#define DEFAULT_BRIGHTNESS 1.0f

#define FRAMES_PER_SECOND 30
#define LOGIC_FPS 30
#define TICKS_PER_FRAME 2
#define TICKS_PER_SECOND (FRAMES_PER_SECOND * TICKS_PER_FRAME)
#define TICKS_PER_SECOND (LOGIC_FPS * TICKS_PER_FRAME)

#define MAX_MATRICES 40
#define MAX_NESTED_MATRICES 32
Expand Down Expand Up @@ -83,8 +83,8 @@
#define UZI_AMMO_QTY (UZI_AMMO_CLIP * 2)
#define SHOTGUN_AMMO_QTY (SHOTGUN_AMMO_CLIP * NUM_SG_SHELLS)
#define NUM_EFFECTS 1000
#define DEATH_WAIT (10 * FRAMES_PER_SECOND)
#define DEATH_WAIT_MIN (2 * FRAMES_PER_SECOND)
#define DEATH_WAIT (10 * LOGIC_FPS)
#define DEATH_WAIT_MIN (2 * LOGIC_FPS)
#define MAX_HEAD_ROTATION (50 * PHD_DEGREE) // = 9100
#define MAX_HEAD_TILT_LOOK (22 * PHD_DEGREE) // = 4004
#define MIN_HEAD_TILT_LOOK (-42 * PHD_DEGREE) // = -7644
Expand Down

0 comments on commit d0ae12e

Please sign in to comment.