X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Femu.c;h=df9faac8d6fc8bb5f20e08e5b53c5620e256aaf2;hb=ca69c3e5a0ecf407c02dc85c6f3282ebb1efc5a2;hp=625f481adfb6c66d91701f53aab1f4e11b8f8e00;hpb=902972d1c7f353aebb17a5ab587b2526e1a45d60;p=libpicofe.git diff --git a/gp2x/emu.c b/gp2x/emu.c index 625f481..df9faac 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -17,6 +17,7 @@ #include "plat_gp2x.h" #include "soc.h" +#include "soc_pollux.h" #include "../common/plat.h" #include "../common/menu.h" #include "../common/arm_utils.h" @@ -66,8 +67,10 @@ void pemu_prep_defconfig(void) soc = soc_detect(); if (soc == SOCID_MMSP2) defaultConfig.s_PicoOpt |= POPT_EXT_FM; - else if (soc == SOCID_POLLUX) + else if (soc == SOCID_POLLUX) { defaultConfig.EmuOpt |= EOPT_WIZ_TEAR_FIX|EOPT_SHOW_RTC; + defaultConfig.s_PicoOpt |= POPT_EN_MCD_GFX; + } } void pemu_validate_config(void) @@ -709,18 +712,13 @@ void plat_update_volume(int has_changed, int is_up) } } -static void updateSound(int len) +static void oss_write_nonblocking(int len) { - len <<= 1; - if (PicoOpt & POPT_EN_STEREO) - len <<= 1; - + // sndout_oss_can_write() is not reliable, only use with no_frmlimit if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len)) return; - /* avoid writing audio when lagging behind to prevent audio lag */ - if (PicoSkipFrame != 2) - sndout_oss_write(PsndOut, len); + sndout_oss_write_nb(PsndOut, len); } void pemu_sound_start(void) @@ -733,21 +731,22 @@ void pemu_sound_start(void) if (currentConfig.EmuOpt & EOPT_EN_SOUND) { int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0; - int target_fps = Pico.m.pal ? 50 : 60; - int frame_samples, snd_excess_add; int snd_rate_oss = PsndRate; gp2x_soc_t soc; + memset(sndBuffer, 0, sizeof(sndBuffer)); + PsndOut = sndBuffer; + PicoWriteSound = oss_write_nonblocking; + plat_update_volume(0, 0); + + printf("starting audio: %i len: %i stereo: %i, pal: %i\n", + PsndRate, PsndLen, is_stereo, Pico.m.pal); + sndout_oss_start(snd_rate_oss, is_stereo, 1); + sndout_oss_setvol(currentConfig.volume, currentConfig.volume); + soc = soc_detect(); - if (soc == SOCID_POLLUX) { - /* POLLUX pain: DPLL1 / mclk_div / bitclk_div / 4 */ - switch (PsndRate) { - case 44100: PsndRate = 44171; break; // 44170.673077 - case 22050: PsndRate = 22086; break; // 22085.336538 - case 11025: PsndRate = 11043; break; // 11042.668269 - default: break; - } - } + if (soc == SOCID_POLLUX) + PsndRate = pollux_get_real_snd_rate(PsndRate); #define SOUND_RERATE_FLAGS (POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO|POPT_EXT_FM|POPT_EN_MCD_CDDA) if (PsndRate != PsndRate_old || Pico.m.pal != pal_old || ((PicoOpt & POPT_EXT_FM) && crashed_940) || @@ -755,40 +754,25 @@ void pemu_sound_start(void) PsndRerate(Pico.m.frame_count ? 1 : 0); } - memset(sndBuffer, 0, sizeof(sndBuffer)); - PsndOut = sndBuffer; - PicoWriteSound = updateSound; PsndRate_old = PsndRate; PicoOpt_old = PicoOpt; pal_old = Pico.m.pal; - plat_update_volume(0, 0); - - frame_samples = PsndLen; - snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps; - if (snd_excess_add != 0) - frame_samples++; - if (soc == SOCID_POLLUX) - frame_samples *= 2; /* force larger buffer */ - - printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", - PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal); - sndout_oss_setvol(currentConfig.volume, currentConfig.volume); - sndout_oss_start(snd_rate_oss, frame_samples, is_stereo); - - /* Wiz's sound hardware needs more prebuffer */ - if (soc == SOCID_POLLUX) - updateSound(frame_samples); } } +static const int sound_rates[] = { 44100, 32000, 22050, 16000, 11025, 8000 }; + void pemu_sound_stop(void) { - /* get back from Wiz pain */ - switch (PsndRate) { - case 44171: PsndRate = 44100; break; - case 22086: PsndRate = 22050; break; - case 11043: PsndRate = 11025; break; - default: break; + int i; + + /* get back from Pollux pain */ + PsndRate += 1000; + for (i = 0; i < ARRAY_SIZE(sound_rates); i++) { + if (PsndRate >= sound_rates[i]) { + PsndRate = sound_rates[i]; + break; + } } } @@ -799,30 +783,16 @@ void pemu_sound_wait(void) void pemu_forced_frame(int no_scale, int do_emu) { - int po_old = PicoOpt; - doing_bg_frame = 1; - PicoOpt &= ~POPT_ALT_RENDERER; - PicoOpt |= POPT_ACC_SPRITES; - if (!no_scale) - PicoOpt |= POPT_EN_SOFTSCALE; - - memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4); - - PicoDrawSetOutFormat(PDF_RGB555, 1); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); PicoDraw32xSetFrameMode(0, 0); PicoDrawSetCallbacks(NULL, NULL); Pico.m.dirtyPal = 1; - if (do_emu) - PicoFrame(); - else - PicoFrameDrawOnly(); + emu_cmn_forced_frame(no_scale, do_emu); g_menubg_src_ptr = g_screen_ptr; doing_bg_frame = 0; - PicoOpt = po_old; } void plat_debug_cat(char *str) @@ -943,24 +913,3 @@ void pemu_loop_end(void) pemu_forced_frame(0, 1); } -const char *plat_get_credits(void) -{ - return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n" - "Credits:\n" - "fDave: Cyclone 68000 core,\n" - " base code of PicoDrive\n" - "Reesy & FluBBa: DrZ80 core\n" - "MAME devs: YM2612 and SN76496 cores\n" - "rlyeh and others: minimal SDK\n" - "Squidge: mmuhack\n" - "Dzz: ARM940 sample\n" - "GnoStiC / Puck2099: USB joy code\n" - "craigix: GP2X hardware\n" - "ketchupgun: skin design\n" - "\n" - "special thanks (for docs, ideas):\n" - " Charles MacDonald, Haze,\n" - " Stephane Dallongeville,\n" - " Lordus, Exophase, Rokas,\n" - " Nemesis, Tasco Deluxe"; -}