From 3eb1d645852e3142d30b7bf1ce2b00d8d3b35041 Mon Sep 17 00:00:00 2001 From: kub Date: Wed, 14 Feb 2024 23:41:24 +0100 Subject: [PATCH] ps2, minor audio and gfx fixes --- platform/ps2/emu.c | 16 +++++++--------- platform/ps2/plat.c | 2 +- platform/psp/plat.c | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/platform/ps2/emu.c b/platform/ps2/emu.c index a5de6493..a423f6ec 100644 --- a/platform/ps2/emu.c +++ b/platform/ps2/emu.c @@ -78,7 +78,7 @@ static int32_t vsync_callback_id; static uint8_t vsync; /* 0 (Disabled), 1 (Enabled), 2 (Dynamic) */ /* sound stuff */ -#define SOUND_BLOCK_COUNT 8 +#define SOUND_BLOCK_COUNT 6 #define SOUND_BUFFER_SIZE (2*54000/50*SOUND_BLOCK_COUNT) // max.rate/min.frames static short __attribute__((aligned(4))) sndBuffer[SOUND_BUFFER_SIZE]; @@ -100,7 +100,7 @@ static void writeSound(int len) l = PicoIn.sndOut - sndBuffer; if (l > sizeof(sndBuffer)/2) lprintf("ovfl %d %d\n", len, PicoIn.sndOut - sndBuffer); - if (l > samples_block * 6) { + if (l > samples_block * (SOUND_BLOCK_COUNT-2)) { sndBuffer_endptr = PicoIn.sndOut; PicoIn.sndOut = sndBuffer; } @@ -111,11 +111,12 @@ static void writeSound(int len) samples_made += len / 2; // lprintf("signal, %i/%i\n", samples_done, samples_made); ret = SignalSema(sound_sem); -// if (ret < 0) lprintf("snd signal ret %08x\n", ret); + if (ret < 0) lprintf("snd signal ret %08x\n", ret); } static int sound_thread(void *argp) { + lprintf("sthr: start\n"); while (!sound_thread_exit) { int ret = 0; @@ -130,14 +131,13 @@ static int sound_thread(void *argp) } // lprintf("sthr: got data: %i\n", samples_made - samples_done); short *sndOut = PicoIn.sndOut, *sndEnd = sndBuffer_endptr; - int buflen = samples_block * 2; + int buflen = sndEnd - snd_playptr; if (sndOut >= snd_playptr) buflen = sndOut - snd_playptr; - else buflen = sndEnd - snd_playptr; if (buflen > samples_block) buflen = samples_block; ret = audsrv_play_audio((char *)snd_playptr, buflen*2); -// if (ret != buflen*2 && ret >= 0) lprintf("sthr: play ret: %i, buflen: %i\n", ret, buflen*2); + if (ret != buflen*2 && ret >= 0) lprintf("sthr: play ret: %i, buflen: %i\n", ret, buflen*2); if (ret < 0) lprintf("sthr: play: ret %08x; pos %i/%i\n", ret, samples_done, samples_made); samples_done += buflen; @@ -241,7 +241,7 @@ void pemu_sound_start(void) { void pemu_sound_stop(void) { samples_made = samples_done = 0; - plat_sleep_ms(100); + plat_sleep_ms(200); audsrv_stop_audio(); } @@ -336,8 +336,6 @@ void set_g_screen_values() { g_screens[i]->Width = 328; g_screens[i]->Height = 256; - g_screens[i]->PSM = GS_PSM_CT16; - g_screens[i]->Filter = GS_FILTER_LINEAR; g_screens[i]->Clut = g_screen_palette; g_screens[i]->ClutPSM = GS_PSM_CT16; diff --git a/platform/ps2/plat.c b/platform/ps2/plat.c index d645b5ef..17cfdc08 100644 --- a/platform/ps2/plat.c +++ b/platform/ps2/plat.c @@ -115,7 +115,7 @@ unsigned int plat_get_ticks_ms(void) ret = (unsigned)tv.tv_sec * 1000; /* approximate /= 1000 */ - ret += ((unsigned)tv.tv_usec * 4195) >> 22; + ret += ((unsigned)tv.tv_usec * 4194) >> 22; return ret; } diff --git a/platform/psp/plat.c b/platform/psp/plat.c index b23bc386..64ae0432 100644 --- a/platform/psp/plat.c +++ b/platform/psp/plat.c @@ -181,7 +181,7 @@ unsigned int plat_get_ticks_ms(void) ret = (unsigned)tv.tv_sec * 1000; /* approximate /= 1000 */ - ret += ((unsigned)tv.tv_usec * 4195) >> 22; + ret += ((unsigned)tv.tv_usec * 4194) >> 22; return ret; } -- 2.39.5