ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit 23923f12dcb6b945dc9f54f5556bd4d7278181cd
parent 77dc3b3a6f9a1af96ee78511d5ddf485074b6157
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Mon,  3 Aug 2020 22:29:18 +0200

Fix some small scaling mistakes

Diffstat:
Msrc/ft2_audio.c | 5+----
Msrc/ft2_main.c | 11++++++-----
Msrc/ft2_replayer.c | 8++------
Msrc/ft2_sample_ed.c | 7+++++--
Msrc/ft2_scopes.c | 6+-----
5 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/src/ft2_audio.c b/src/ft2_audio.c @@ -1085,10 +1085,7 @@ static void calcAudioLatencyVars(int32_t audioBufferSize, int32_t audioFreq) audio.audLatencyPerfValInt = (int32_t)dInt; // fractional part (scaled to 0..2^32-1) - dFrac *= UINT32_MAX; - dFrac += 0.5; - if (dFrac > UINT32_MAX) - dFrac = UINT32_MAX; + dFrac *= UINT32_MAX+1.0; audio.audLatencyPerfValFrac = (uint32_t)dFrac; audio.dAudioLatencyMs = dAudioLatencySecs * 1000.0; diff --git a/src/ft2_main.c b/src/ft2_main.c @@ -97,6 +97,11 @@ int main(int argc, char *argv[]) #endif #ifdef _WIN32 + +#ifndef _MSC_VER + SetProcessDPIAware(); +#endif + if (!cpu.hasSSE) { showErrorMsgBox("Your computer's processor doesn't have the SSE instruction set\n" \ @@ -428,11 +433,7 @@ static void setupPerfFreq(void) video.vblankTimeLen = (int32_t)dInt; // fractional part scaled to 0..2^32-1 - dFrac *= UINT32_MAX; - dFrac += 0.5; - if (dFrac > UINT32_MAX) - dFrac = UINT32_MAX; - + dFrac *= UINT32_MAX+1.0; video.vblankTimeLenFrac = (uint32_t)dFrac; } diff --git a/src/ft2_replayer.c b/src/ft2_replayer.c @@ -370,16 +370,12 @@ void calcReplayRate(int32_t audioFreq) audio.dSpeedValTab[i] = dSamplesPerTick; - // number of samples per tick -> tick length for performance counter (syncing visuals to audio) + // BPM -> Hz -> tick length for performance counter (syncing visuals to audio) double dTimeInt; double dTimeFrac = modf(editor.dPerfFreq / dBpmHz, &dTimeInt); const int32_t timeInt = (int32_t)dTimeInt; - // - fractional part (scaled to 0..2^32-1) - - dTimeFrac *= UINT32_MAX; - dTimeFrac += 0.5; - if (dTimeFrac > UINT32_MAX) - dTimeFrac = UINT32_MAX; + dTimeFrac *= UINT32_MAX+1.0; // fractional part (scaled to 0..2^32-1) audio.tickTimeLengthTab[i] = ((uint64_t)timeInt << 32) | (uint32_t)dTimeFrac; diff --git a/src/ft2_sample_ed.c b/src/ft2_sample_ed.c @@ -10,6 +10,9 @@ #ifndef _WIN32 #include <unistd.h> // chdir() in UNICHAR_CHDIR() #endif +#if defined __APPLE__ || defined _WIN32 || defined __amd64__ || (defined __i386__ && defined __SSE2__) +#include <emmintrin.h> +#endif #include "ft2_header.h" #include "ft2_config.h" #include "ft2_audio.h" @@ -254,7 +257,7 @@ void restoreSample(sampleTyp *s) } } -inline int16_t getSampleValue(int8_t *ptr, uint8_t typ, int32_t pos) +int16_t getSampleValue(int8_t *ptr, uint8_t typ, int32_t pos) { assert(pos >= 0); if (ptr == NULL) @@ -271,7 +274,7 @@ inline int16_t getSampleValue(int8_t *ptr, uint8_t typ, int32_t pos) } } -inline void putSampleValue(int8_t *ptr, uint8_t typ, int32_t pos, int16_t val) +void putSampleValue(int8_t *ptr, uint8_t typ, int32_t pos, int16_t val) { assert(pos >= 0); if (ptr == NULL) diff --git a/src/ft2_scopes.c b/src/ft2_scopes.c @@ -648,11 +648,7 @@ bool initScopes(void) scopeTimeLen = (int32_t)dInt; // fractional part (scaled to 0..2^32-1) - dFrac *= UINT32_MAX; - dFrac += 0.5; - if (dFrac > UINT32_MAX) - dFrac = UINT32_MAX; - + dFrac *= UINT32_MAX+1.0; scopeTimeLenFrac = (uint32_t)dFrac; scopeThread = SDL_CreateThread(scopeThreadFunc, NULL, NULL);