aboutsummaryrefslogtreecommitdiff
path: root/plat_sdl.c
diff options
context:
space:
mode:
authorneonloop2021-08-07 20:28:34 +0000
committerneonloop2021-08-07 20:28:34 +0000
commit8ad26356f5e92bd396e58290217da55858345a4e (patch)
tree8c08b9e62f36170e36514a4d1f397990e881104e /plat_sdl.c
parentb148bcce05254c7ebe0ad855e5f1e958968a0bb9 (diff)
downloadpicoarch-8ad26356f5e92bd396e58290217da55858345a4e.tar.gz
picoarch-8ad26356f5e92bd396e58290217da55858345a4e.tar.bz2
picoarch-8ad26356f5e92bd396e58290217da55858345a4e.zip
Adds generic nearest and smooth scalers
Smooth is slower (10-15%) than a scaler built for a specific resolution. Works well for downscaling and for odd screen ratios until a custom scaler is built. Replaces the snes smooth scaler (outperforms it) and the gba smooth scaler (looks better)
Diffstat (limited to 'plat_sdl.c')
-rw-r--r--plat_sdl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/plat_sdl.c b/plat_sdl.c
index 7223a0d..9467f5d 100644
--- a/plat_sdl.c
+++ b/plat_sdl.c
@@ -9,9 +9,9 @@
static SDL_Surface* screen;
struct audio_state {
- int buf_w;
- int max_buf_w;
- int buf_r;
+ unsigned buf_w;
+ unsigned max_buf_w;
+ unsigned buf_r;
size_t buf_len;
struct audio_frame *buf;
int freq;
@@ -37,14 +37,14 @@ static int audio_resample_nearest(struct audio_frame data) {
static int diff = 0;
int consumed = 0;
- if (diff <= 0) {
+ if (diff < audio.out_sample_rate) {
audio.buf[audio.buf_w++] = data;
if (audio.buf_w >= audio.buf_len) audio.buf_w = 0;
diff += audio.in_sample_rate;
}
- if (diff > 0) {
+ if (diff >= audio.out_sample_rate) {
consumed++;
diff -= audio.out_sample_rate;
}