X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Femu.c;h=659d3a719245e91a4a729c5670ef85cb9325e5dd;hb=9f6a4e907bc86412c9279809d133e6e2fb896c0c;hp=752007633e81cd1be0ad963984b8d099a6b308d3;hpb=f4750ee051b509a17bb940d6372a0c12faae18cd;p=picodrive.git diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 7520076..659d3a7 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -17,12 +17,14 @@ #include "plat_gp2x.h" #include "soc.h" +#include "soc_pollux.h" #include "../common/plat.h" #include "../common/menu.h" #include "../common/arm_utils.h" #include "../common/fonts.h" #include "../common/emu.h" #include "../common/config.h" +#include "../common/input.h" #include "../linux/sndout_oss.h" #include "version.h" @@ -60,6 +62,7 @@ void pemu_prep_defconfig(void) defaultConfig.CPUclock = default_cpu_clock; defaultConfig.renderer32x = RT_8BIT_FAST; + defaultConfig.analog_deadzone = 50; soc = soc_detect(); if (soc == SOCID_MMSP2) @@ -523,9 +526,10 @@ static void vid_reset_mode(void) } else { PicoDrawSetOutFormat(PDF_NONE, 0); - PicoDraw32xSetFrameMode(1, (renderer == RT_16BIT) ? 1 : 0); + PicoDraw32xSetFrameMode(1, 0); } PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); + gp2x_mode = 16; } if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) { @@ -548,12 +552,7 @@ static void vid_reset_mode(void) else osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text8_rot : osd_text8; - if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) - gp2x_mode = -gp2x_mode; - gp2x_video_wait_vsync(); - gp2x_video_changemode(gp2x_mode); - if (!is_16bit_mode()) { // setup pal for 8-bit modes localPal[0xc0] = 0x0000c000; // MCD LEDs @@ -566,6 +565,11 @@ static void vid_reset_mode(void) else gp2x_memset_all_buffers(0, 0, 320*240*2); + if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) + gp2x_mode = -gp2x_mode; + + gp2x_video_changemode(gp2x_mode); + Pico.m.dirtyPal = 1; PicoOpt &= ~POPT_EN_SOFTSCALE; @@ -730,21 +734,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 = updateSound; + 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) || @@ -752,40 +757,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; + } } } @@ -794,13 +784,14 @@ void pemu_sound_wait(void) // don't need to do anything, writes will block by themselves } -void pemu_forced_frame(int opts, int no_scale) +void pemu_forced_frame(int no_scale, int do_emu) { int po_old = PicoOpt; - doing_bg_frame = 1; PicoOpt &= ~POPT_ALT_RENDERER; - PicoOpt |= opts|POPT_ACC_SPRITES; + PicoOpt |= POPT_ACC_SPRITES; + if (!no_scale) + PicoOpt |= POPT_EN_SOFTSCALE; memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4); @@ -810,13 +801,14 @@ void pemu_forced_frame(int opts, int no_scale) PicoDrawSetCallbacks(NULL, NULL); Pico.m.dirtyPal = 1; - if (no_scale == -9) - // yes I'm lazy, see pemu_forced_frame call below + doing_bg_frame = 1; + if (do_emu) PicoFrame(); else PicoFrameDrawOnly(); - doing_bg_frame = 0; + + g_menubg_src_ptr = g_screen_ptr; PicoOpt = po_old; } @@ -909,6 +901,10 @@ void pemu_loop_prep(void) unset_lcd_custom_rate(); } + if (gp2x_dev_id == GP2X_DEV_CAANOO) + in_set_config_int(in_name_to_id("evdev:pollux-analog"), IN_CFG_ABS_DEAD_ZONE, + currentConfig.analog_deadzone); + if ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_MMUHACK) gp2x_make_fb_bufferable(currentConfig.EmuOpt & EOPT_MMUHACK); @@ -931,8 +927,7 @@ void pemu_loop_end(void) pemu_sound_stop(); /* do one more frame for menu bg */ - pemu_forced_frame(POPT_EN_SOFTSCALE, -9); - g_menubg_src_ptr = g_screen_ptr; + pemu_forced_frame(0, 1); } const char *plat_get_credits(void)