diff --git a/src/emulator.c b/src/emulator.c index 7d06e66..6f21d5f 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -556,7 +556,7 @@ void emulateFrame(){ blip_end_frame(palmAudioResampler, AUDIO_END_OF_FRAME); //printf("There are %d audio samples available\n", blip_samples_avail(palmAudioResampler)); blip_read_samples(palmAudioResampler, palmAudio, AUDIO_SAMPLES_PER_FRAME, true); - for(uint32_t samples = 0; samples < AUDIO_SAMPLES_PER_FRAME * 2; samples += 2) + MULTITHREAD_LOOP for(uint32_t samples = 0; samples < AUDIO_SAMPLES_PER_FRAME * 2; samples += 2) palmAudio[samples + 1] = palmAudio[samples]; //video diff --git a/src/portability.h b/src/portability.h index 76c9f62..2ccc69c 100644 --- a/src/portability.h +++ b/src/portability.h @@ -18,6 +18,11 @@ static inline uint64_t uMax(uint64_t x, uint64_t y){ return x > y ? x : y; } +static inline uint64_t uClamp(uint64_t x, uint64_t y, uint64_t z){ + //x must always be less than z! + return (y < x ? x : y) > z ? z : y; +} + static inline int64_t sMin(int64_t x, int64_t y){ return x < y ? x : y; } @@ -26,6 +31,11 @@ static inline int64_t sMax(int64_t x, int64_t y){ return x > y ? x : y; } +static inline int64_t sClamp(int64_t x, int64_t y, int64_t z){ + //x must always be less than z! + return (y < x ? x : y) > z ? z : y; +} + static inline double dMin(double x, double y){ return x < y ? x : y; } @@ -34,6 +44,11 @@ static inline double dMax(double x, double y){ return x > y ? x : y; } +static inline double dClamp(double x, double y, double z){ + //x must always be less than z! + return (y < x ? x : y) > z ? z : y; +} + static inline uint64_t getUint64FromDouble(double data){ //1.32.31 fixed point