From 868cb610953e5ee2fe75a8dcad7f2d89ec925098 Mon Sep 17 00:00:00 2001 From: gameblabla Date: Thu, 16 Jan 2020 12:28:58 +0100 Subject: [PATCH 1/3] Fix audio issues with it trying to refresh it more than 4 times... --- source/sound_output/alsa/sound_output_alsa.c | 6 ++++-- source/sound_output/libao/sound_libao.c | 2 +- source/sound_output/oss/sound_output_oss.c | 2 +- source/sound_output/portaudio/sound_portaudio.c | 2 +- source/sound_output/pulse/sound_output_pulse.c | 2 +- source/sound_output/sdl12/sound_output_sdl.c | 11 ++++++++--- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/sound_output/alsa/sound_output_alsa.c b/source/sound_output/alsa/sound_output_alsa.c index cf5cd5e..70ed369 100644 --- a/source/sound_output/alsa/sound_output_alsa.c +++ b/source/sound_output/alsa/sound_output_alsa.c @@ -128,9 +128,11 @@ void Sound_Init(void) void Sound_Update(void) { uint32_t i; - long len = (SOUND_FREQUENCY / snd.fps), ret; + long len = SOUND_FREQUENCY / snd.fps, ret; - for (i = 0; i < (4 * len); i++) + if (!handle) return; + + for (i = 0; i < (len); i++) { buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel; buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel; diff --git a/source/sound_output/libao/sound_libao.c b/source/sound_output/libao/sound_libao.c index 5a07fd0..945fe37 100644 --- a/source/sound_output/libao/sound_libao.c +++ b/source/sound_output/libao/sound_libao.c @@ -36,7 +36,7 @@ void Sound_Update() { int32_t i; - for (i = 0; i < (4 * (SOUND_FREQUENCY / snd.fps)); i++) + for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++) { buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel; buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel; diff --git a/source/sound_output/oss/sound_output_oss.c b/source/sound_output/oss/sound_output_oss.c index 980b38d..0f32385 100644 --- a/source/sound_output/oss/sound_output_oss.c +++ b/source/sound_output/oss/sound_output_oss.c @@ -66,7 +66,7 @@ void Sound_Update() if (!oss_audio_fd) return; - for (i = 0; i < (4 * (SOUND_FREQUENCY / snd.fps)); i++) + for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++) { buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel; buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel; diff --git a/source/sound_output/portaudio/sound_portaudio.c b/source/sound_output/portaudio/sound_portaudio.c index 91589bc..8355439 100644 --- a/source/sound_output/portaudio/sound_portaudio.c +++ b/source/sound_output/portaudio/sound_portaudio.c @@ -72,7 +72,7 @@ void Sound_Update() { #ifndef NONBLOCKING_AUDIO int32_t i; - for (i = 0; i < (4 * (SOUND_FREQUENCY / snd.fps)); i++) + for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++) { buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel; buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel; diff --git a/source/sound_output/pulse/sound_output_pulse.c b/source/sound_output/pulse/sound_output_pulse.c index bcc4144..054622e 100644 --- a/source/sound_output/pulse/sound_output_pulse.c +++ b/source/sound_output/pulse/sound_output_pulse.c @@ -38,7 +38,7 @@ void Sound_Init() void Sound_Update() { int32_t i; - for (i = 0; i < (4 * (SOUND_FREQUENCY / snd.fps)); i++) + for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++) { buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel; buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel; diff --git a/source/sound_output/sdl12/sound_output_sdl.c b/source/sound_output/sdl12/sound_output_sdl.c index 86f60c9..aa61d74 100644 --- a/source/sound_output/sdl12/sound_output_sdl.c +++ b/source/sound_output/sdl12/sound_output_sdl.c @@ -138,7 +138,7 @@ void Sound_Init() void Sound_Update() { int32_t i; - for (i = 0; i < (4 * (SOUND_FREQUENCY / snd.fps)); i++) + for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++) { buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel; buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel; @@ -158,11 +158,16 @@ void Sound_Close() buffered_bytes = BUFFSIZE; SDL_CondSignal(sound_cv); SDL_UnlockMutex(sound_mutex); - SDL_Delay(100); + SDL_Delay(25); SDL_DestroyCond(sound_cv); SDL_DestroyMutex(sound_mutex); } SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); - buffer = NULL; + + if (buffer) + { + free(buffer); + buffer = NULL; + } } From 4f2e4847d619bb86813dc214240b65d879fe600b Mon Sep 17 00:00:00 2001 From: gameblabla Date: Fri, 17 Jan 2020 20:40:53 +0100 Subject: [PATCH 2/3] Update GCW0 port. It should be working ok now. --- source/ports/gcw0/smsplus.c | 54 +++---------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/source/ports/gcw0/smsplus.c b/source/ports/gcw0/smsplus.c index 3fbaaa4..82cf9c5 100644 --- a/source/ports/gcw0/smsplus.c +++ b/source/ports/gcw0/smsplus.c @@ -990,7 +990,7 @@ static void Cleanup(void) uint32_t update_window_size(uint32_t w, uint32_t h) { - sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE); + sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_TRIPLEBUF); if (!sdl_screen) { @@ -1011,54 +1011,10 @@ static void Force_IPU_Mode() set_keep_aspect_ratio(0); } -/* -static void Controls_joystick() -{ - int16_t x_move = 0, y_move = 0; - - for(uint_fast8_t i=0;i<2;i++) - { - x_move = SDL_JoystickGetAxis(sdl_joy[i+1], 0); - y_move = SDL_JoystickGetAxis(sdl_joy[i+1], 1); - - if (x_move > joy_commit_range) - input.pad[i] |= INPUT_RIGHT; - else if (input.pad[i] & INPUT_RIGHT) - input.pad[i] &= ~INPUT_RIGHT; - - if (x_move < -joy_commit_range) - input.pad[i] |= INPUT_LEFT; - else if (input.pad[i] & INPUT_LEFT) - input.pad[i] &= ~INPUT_LEFT; - - if (y_move > joy_commit_range) - input.pad[i] |= INPUT_DOWN; - else if (input.pad[i] & INPUT_DOWN) - input.pad[i] &= ~INPUT_DOWN; - - if(y_move < -joy_commit_range) - input.pad[i] |= INPUT_UP; - else if (input.pad[i] & INPUT_UP) - input.pad[i] &= ~INPUT_UP; - - if(SDL_JoystickGetButton(sdl_joy[i+1], 2) == SDL_PRESSED) - input.pad[i] |= INPUT_BUTTON1; - else if (input.pad[i] & INPUT_BUTTON1) - input.pad[i] &= ~INPUT_BUTTON1; - - if(SDL_JoystickGetButton(sdl_joy[i+1], 1) == SDL_PRESSED) - input.pad[i] |= INPUT_BUTTON2; - else if (input.pad[i] & INPUT_BUTTON2) - input.pad[i] &= ~INPUT_BUTTON2; - } - - SDL_JoystickUpdate(); -} -*/ int main (int argc, char *argv[]) { - int joy_axis[2]; + int32_t joy_axis[2] = {0, 0}; uint_fast8_t i; SDL_Event event; @@ -1119,8 +1075,8 @@ int main (int argc, char *argv[]) SDL_JoystickEventState(SDL_ENABLE); - //joy_numb = SDL_NumJoysticks(); - //if (joy_numb > 3) joy_numb = 3; + joy_numb = SDL_NumJoysticks(); + if (joy_numb > 3) joy_numb = 3; for(i=0;i Date: Fri, 17 Jan 2020 20:45:51 +0100 Subject: [PATCH 3/3] Unfortunately triple buffering is still not working properly right now. --- source/ports/gcw0/smsplus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ports/gcw0/smsplus.c b/source/ports/gcw0/smsplus.c index 82cf9c5..69e6038 100644 --- a/source/ports/gcw0/smsplus.c +++ b/source/ports/gcw0/smsplus.c @@ -990,7 +990,7 @@ static void Cleanup(void) uint32_t update_window_size(uint32_t w, uint32_t h) { - sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_TRIPLEBUF); + sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE); if (!sdl_screen) {