2 * (c) Copyright 2006-2010 notaz, All rights reserved.
\r
4 * For performance reasons 3 renderers are exported for both MD and 32x modes:
\r
5 * - 16bpp line renderer
\r
6 * - 8bpp line renderer (slightly faster)
\r
7 * - 8bpp tile renderer
\r
9 * - 32x layer is overlayed on top of 16bpp one
\r
10 * - line internal one done on PicoDraw2FB, then mixed with 32x
\r
11 * - tile internal one done on PicoDraw2FB, then mixed with 32x
\r
18 #include "../libpicofe/gp2x/plat_gp2x.h"
\r
19 #include "../libpicofe/gp2x/soc.h"
\r
20 #include "../libpicofe/input.h"
\r
21 #include "../libpicofe/plat.h"
\r
22 #include "../libpicofe/gp2x/soc_pollux.h"
\r
23 #include "../common/menu_pico.h"
\r
24 #include "../common/arm_utils.h"
\r
25 #include "../common/emu.h"
\r
26 #include "../common/config_file.h"
\r
27 #include "../common/version.h"
\r
30 #include <pico/pico_int.h>
\r
31 #include <pico/patch.h>
\r
32 #include <pico/sound/mix.h>
\r
33 #include <zlib/zlib.h>
\r
36 #define OSD_FPS_X 220
\r
38 #define OSD_FPS_X 260
\r
42 //extern int crashed_940;
\r
44 static int osd_fps_x, osd_y, doing_bg_frame;
\r
45 const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };
\r
46 const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };
\r
47 enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };
\r
49 static int (*emu_scan_begin)(unsigned int num) = NULL;
\r
50 static int (*emu_scan_end)(unsigned int num) = NULL;
\r
53 void pemu_prep_defconfig(void)
\r
57 defaultConfig.CPUclock = default_cpu_clock;
\r
58 defaultConfig.renderer32x = RT_8BIT_FAST;
\r
59 defaultConfig.analog_deadzone = 50;
\r
62 if (soc == SOCID_MMSP2)
\r
63 defaultConfig.s_PicoOpt |= POPT_EXT_FM;
\r
64 else if (soc == SOCID_POLLUX) {
\r
65 defaultConfig.EmuOpt |= EOPT_WIZ_TEAR_FIX|EOPT_SHOW_RTC;
\r
66 defaultConfig.s_PicoOpt |= POPT_EN_MCD_GFX;
\r
70 void pemu_validate_config(void)
\r
72 if (gp2x_dev_id != GP2X_DEV_GP2X)
\r
73 PicoOpt &= ~POPT_EXT_FM;
\r
74 if (gp2x_dev_id != GP2X_DEV_WIZ)
\r
75 currentConfig.EmuOpt &= ~EOPT_WIZ_TEAR_FIX;
\r
77 if (currentConfig.gamma < 10 || currentConfig.gamma > 300)
\r
78 currentConfig.gamma = 100;
\r
80 if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 1024)
\r
81 currentConfig.CPUclock = default_cpu_clock;
\r
84 static int get_renderer(void)
\r
86 if (PicoAHW & PAHW_32X)
\r
87 return currentConfig.renderer32x;
\r
89 return currentConfig.renderer;
\r
92 static void change_renderer(int diff)
\r
95 if (PicoAHW & PAHW_32X)
\r
96 r = ¤tConfig.renderer32x;
\r
98 r = ¤tConfig.renderer;
\r
101 // 8bpp fast is not there (yet?)
\r
102 if ((PicoAHW & PAHW_SMS) && *r == RT_8BIT_FAST)
\r
105 if (*r >= RT_COUNT)
\r
111 #define is_16bit_mode() \
\r
112 (get_renderer() == RT_16BIT || (PicoAHW & PAHW_32X))
\r
114 static void (*osd_text)(int x, int y, const char *text);
\r
116 static void osd_text8(int x, int y, const char *text)
\r
118 int len = strlen(text)*8;
\r
119 int *p, i, h, offs;
\r
121 len = (len+3) >> 2;
\r
122 for (h = 0; h < 8; h++) {
\r
123 offs = (x + g_screen_width * (y+h)) & ~3;
\r
124 p = (int *) ((char *)g_screen_ptr + offs);
\r
125 for (i = len; i; i--, p++)
\r
128 emu_text_out8(x, y, text);
\r
131 static void osd_text16(int x, int y, const char *text)
\r
133 int len = strlen(text)*8;
\r
134 int *p, i, h, offs;
\r
136 len = (len+1) >> 1;
\r
137 for (h = 0; h < 8; h++) {
\r
138 offs = (x + g_screen_width * (y+h)) & ~1;
\r
139 p = (int *) ((short *)g_screen_ptr + offs);
\r
140 for (i = len; i; i--, p++)
\r
141 *p = (*p >> 2) & 0x39e7;
\r
143 emu_text_out16(x, y, text);
\r
146 static void osd_text8_rot(int x, int y, const char *text)
\r
148 int len = strlen(text) * 8;
\r
149 char *p = (char *)g_screen_ptr + 240*(320-x) + y;
\r
152 memset(p, 0xe0, 8);
\r
156 emu_text_out8_rot(x, y, text);
\r
159 static void osd_text16_rot(int x, int y, const char *text)
\r
161 int len = strlen(text) * 8;
\r
162 short *p = (short *)g_screen_ptr + 240*(320-x) + y;
\r
169 emu_text_out16_rot(x, y, text);
\r
172 static void draw_cd_leds(void)
\r
174 int led_reg, pitch, scr_offs, led_offs;
\r
175 led_reg = Pico_mcd->s68k_regs[0];
\r
177 if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
\r
179 led_offs = -pitch * 6;
\r
180 scr_offs = pitch * (320 - 4);
\r
184 scr_offs = pitch * 2 + 4;
\r
187 if (!is_16bit_mode()) {
\r
188 #define p(x) px[(x) >> 2]
\r
190 unsigned int *px = (unsigned int *)((char *)g_screen_ptr + scr_offs);
\r
191 unsigned int col_g = (led_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;
\r
192 unsigned int col_r = (led_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;
\r
193 p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;
\r
194 p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;
\r
197 #define p(x) px[(x)*2 >> 2] = px[((x)*2 >> 2) + 1]
\r
199 unsigned int *px = (unsigned int *)((short *)g_screen_ptr + scr_offs);
\r
200 unsigned int col_g = (led_reg & 2) ? 0x06000600 : 0;
\r
201 unsigned int col_r = (led_reg & 1) ? 0xc000c000 : 0;
\r
202 p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;
\r
203 p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;
\r
208 static void draw_pico_ptr(void)
\r
210 unsigned short *p = (unsigned short *)g_screen_ptr;
\r
211 int x, y, pitch = 320;
\r
213 // only if pen enabled and for 16bit modes
\r
214 if (pico_inp_mode == 0 || currentConfig.EmuOpt != RT_16BIT)
\r
217 x = pico_pen_x + PICO_PEN_ADJUST_X;
\r
218 y = pico_pen_y + PICO_PEN_ADJUST_Y;
\r
219 if (!(Pico.video.reg[12]&1) && !(PicoOpt & POPT_DIS_32C_BORDER))
\r
222 if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
\r
224 p += (319 - x) * pitch + y;
\r
226 p += x + y * pitch;
\r
229 p[pitch-1] ^= 0xffff;
\r
230 p[pitch] ^= 0xffff;
\r
231 p[pitch+1] ^= 0xffff;
\r
232 p[pitch*2] ^= 0xffff;
\r
235 /* rot thing for Wiz */
\r
236 static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2];
\r
238 static int EmuScanBegin16_rot(unsigned int num)
\r
240 DrawLineDest = rot_buff + (num & 3) * 320 * 2;
\r
244 static int EmuScanEnd16_rot(unsigned int num)
\r
246 if ((num & 3) != 3)
\r
248 rotated_blit16(g_screen_ptr, rot_buff, num + 1,
\r
249 !(Pico.video.reg[12] & 1) && !(PicoOpt & POPT_EN_SOFTSCALE));
\r
253 static int EmuScanBegin8_rot(unsigned int num)
\r
255 DrawLineDest = rot_buff + (num & 3) * 320;
\r
259 static int EmuScanEnd8_rot(unsigned int num)
\r
261 if ((num & 3) != 3)
\r
263 rotated_blit8(g_screen_ptr, rot_buff, num + 1,
\r
264 !(Pico.video.reg[12] & 1));
\r
268 /* line doublers */
\r
269 static unsigned int ld_counter;
\r
270 static int ld_left, ld_lines;
\r
272 static int EmuScanBegin16_ld(unsigned int num)
\r
274 if ((signed int)(ld_counter - num) > 100)
\r
277 if (emu_scan_begin)
\r
278 return emu_scan_begin(ld_counter);
\r
280 DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8;
\r
285 static int EmuScanEnd16_ld(unsigned int num)
\r
287 void *oldline = DrawLineDest;
\r
290 emu_scan_end(ld_counter);
\r
294 if (ld_left <= 0) {
\r
295 ld_left = ld_lines;
\r
297 EmuScanBegin16_ld(num);
\r
298 memcpy32(DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4);
\r
300 emu_scan_end(ld_counter);
\r
308 static int localPal[0x100];
\r
309 static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border);
\r
310 static int (*make_local_pal)(int fast_mode);
\r
312 static int make_local_pal_md(int fast_mode)
\r
316 bgr444_to_rgb32(localPal, Pico.cram);
\r
320 if (Pico.video.reg[0xC] & 8) { // shadow/hilight mode
\r
321 bgr444_to_rgb32_sh(localPal, Pico.cram);
\r
322 localPal[0xc0] = 0x0000c000;
\r
323 localPal[0xd0] = 0x00c00000;
\r
324 localPal[0xe0] = 0x00000000; // reserved pixels for OSD
\r
325 localPal[0xf0] = 0x00ffffff;
\r
328 else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
\r
329 bgr444_to_rgb32(localPal+0x40, HighPal);
\r
330 bgr444_to_rgb32(localPal+0x80, HighPal+0x40);
\r
333 memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess
\r
338 static int make_local_pal_sms(int fast_mode)
\r
340 unsigned short *spal = Pico.cram;
\r
341 unsigned int *dpal = (void *)localPal;
\r
344 for (i = 0x40; i > 0; i--) {
\r
346 t = ((t & 0x0003) << 22) | ((t & 0x000c) << 12) | ((t & 0x0030) << 2);
\r
355 void pemu_finalize_frame(const char *fps, const char *notice)
\r
357 int emu_opt = currentConfig.EmuOpt;
\r
360 if (PicoAHW & PAHW_32X)
\r
362 else if (get_renderer() == RT_8BIT_FAST)
\r
364 // 8bit fast renderer
\r
365 if (Pico.m.dirtyPal) {
\r
366 Pico.m.dirtyPal = 0;
\r
367 ret = make_local_pal(1);
\r
368 // feed new palette to our device
\r
369 gp2x_video_setpalette(localPal, ret);
\r
372 if (PicoAHW & PAHW_SVP)
\r
373 memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);
\r
375 vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8,
\r
376 !(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER));
\r
378 else if (get_renderer() == RT_8BIT_ACC)
\r
380 // 8bit accurate renderer
\r
381 if (Pico.m.dirtyPal)
\r
383 Pico.m.dirtyPal = 0;
\r
384 ret = make_local_pal(0);
\r
385 gp2x_video_setpalette(localPal, ret);
\r
390 osd_text(4, osd_y, notice);
\r
391 if (emu_opt & EOPT_SHOW_FPS)
\r
392 osd_text(osd_fps_x, osd_y, fps);
\r
393 if ((PicoAHW & PAHW_MCD) && (emu_opt & EOPT_EN_CD_LEDS))
\r
395 if (PicoAHW & PAHW_PICO)
\r
399 void plat_video_flip(void)
\r
401 int stride = g_screen_width;
\r
404 if (is_16bit_mode())
\r
406 PicoDrawSetOutBuf(g_screen_ptr, stride);
\r
411 unsigned int plat_get_ticks_ms(void)
\r
413 return gp2x_get_ticks_ms();
\r
416 unsigned int plat_get_ticks_us(void)
\r
418 return gp2x_get_ticks_us();
\r
422 void plat_wait_till_us(unsigned int us_to)
\r
426 spend_cycles(1024);
\r
427 now = plat_get_ticks_us();
\r
429 while ((signed int)(us_to - now) > 512)
\r
431 spend_cycles(1024);
\r
432 now = plat_get_ticks_us();
\r
436 void plat_video_wait_vsync(void)
\r
438 gp2x_video_wait_vsync();
\r
441 void plat_status_msg_clear(void)
\r
443 int is_8bit = !is_16bit_mode();
\r
444 if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
\r
448 for (i = 0; i < 4; i++) {
\r
449 p = (int *)gp2x_screens[i] + (240-8) / 4;
\r
450 for (u = 320; u > 0; u--, p += 240/4)
\r
451 p[0] = p[1] = 0xe0e0e0e0;
\r
454 for (i = 0; i < 4; i++) {
\r
455 p = (int *)gp2x_screens[i] + (240-8)*2 / 4;
\r
456 for (u = 320; u > 0; u--, p += 240*2/4)
\r
457 p[0] = p[1] = p[2] = p[3] = 0;
\r
464 gp2x_memset_all_buffers(320*232, 0xe0, 320*8);
\r
466 gp2x_memset_all_buffers(320*232*2, 0, 320*8*2);
\r
469 void plat_status_msg_busy_next(const char *msg)
\r
471 plat_status_msg_clear();
\r
472 pemu_finalize_frame("", msg);
\r
474 emu_status_msg("");
\r
476 /* assumption: msg_busy_next gets called only when
\r
477 * something slow is about to happen */
\r
481 void plat_status_msg_busy_first(const char *msg)
\r
483 gp2x_memcpy_all_buffers(g_screen_ptr, 0, 320*240*2);
\r
484 plat_status_msg_busy_next(msg);
\r
487 static void vid_reset_mode(void)
\r
489 int gp2x_mode = 16;
\r
490 int renderer = get_renderer();
\r
492 PicoOpt &= ~POPT_ALT_RENDERER;
\r
493 emu_scan_begin = NULL;
\r
494 emu_scan_end = NULL;
\r
496 switch (renderer) {
\r
498 PicoDrawSetOutFormat(PDF_RGB555, 0);
\r
499 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
\r
502 PicoDrawSetOutFormat(PDF_8BIT, 0);
\r
503 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width);
\r
507 PicoOpt |= POPT_ALT_RENDERER;
\r
508 PicoDrawSetOutFormat(PDF_NONE, 0);
\r
509 vidcpyM2 = vidcpy_m2;
\r
513 printf("bad renderer\n");
\r
517 if (PicoAHW & PAHW_32X) {
\r
518 // Wiz 16bit is an exception, uses line rendering due to rotation mess
\r
519 if (renderer == RT_16BIT && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) {
\r
520 PicoDrawSetOutFormat(PDF_RGB555, 1);
\r
523 PicoDrawSetOutFormat(PDF_NONE, 0);
\r
525 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
\r
529 if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
\r
530 if ((PicoAHW & PAHW_32X) || renderer == RT_16BIT) {
\r
531 emu_scan_begin = EmuScanBegin16_rot;
\r
532 emu_scan_end = EmuScanEnd16_rot;
\r
534 else if (renderer == RT_8BIT_ACC) {
\r
535 emu_scan_begin = EmuScanBegin8_rot;
\r
536 emu_scan_end = EmuScanEnd8_rot;
\r
538 else if (renderer == RT_8BIT_FAST)
\r
539 vidcpyM2 = vidcpy_m2_rot;
\r
542 PicoDrawSetCallbacks(emu_scan_begin, emu_scan_end);
\r
544 if (is_16bit_mode())
\r
545 osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text16_rot : osd_text16;
\r
547 osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text8_rot : osd_text8;
\r
549 gp2x_video_wait_vsync();
\r
550 if (!is_16bit_mode()) {
\r
551 // setup pal for 8-bit modes
\r
552 localPal[0xc0] = 0x0000c000; // MCD LEDs
\r
553 localPal[0xd0] = 0x00c00000;
\r
554 localPal[0xe0] = 0x00000000; // reserved pixels for OSD
\r
555 localPal[0xf0] = 0x00ffffff;
\r
556 gp2x_video_setpalette(localPal, 0x100);
\r
557 gp2x_memset_all_buffers(0, 0xe0, 320*240);
\r
560 gp2x_memset_all_buffers(0, 0, 320*240*2);
\r
562 if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)
\r
563 gp2x_mode = -gp2x_mode;
\r
565 gp2x_video_changemode(gp2x_mode);
\r
567 Pico.m.dirtyPal = 1;
\r
569 PicoOpt &= ~POPT_EN_SOFTSCALE;
\r
570 if (currentConfig.scaling == EOPT_SCALE_SW)
\r
571 PicoOpt |= POPT_EN_SOFTSCALE;
\r
573 // palette converters for 8bit modes
\r
574 make_local_pal = (PicoAHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md;
\r
577 void emu_video_mode_change(int start_line, int line_count, int is_32cols)
\r
579 int scalex = 320, scaley = 240;
\r
582 if (doing_bg_frame)
\r
585 osd_fps_x = OSD_FPS_X;
\r
588 /* set up hwscaling here */
\r
589 PicoOpt &= ~POPT_DIS_32C_BORDER;
\r
590 if (is_32cols && currentConfig.scaling == EOPT_SCALE_HW) {
\r
592 PicoOpt |= POPT_DIS_32C_BORDER;
\r
593 osd_fps_x = OSD_FPS_X - 64;
\r
596 if (currentConfig.vscaling == EOPT_SCALE_HW) {
\r
597 ln_offs = start_line;
\r
598 scaley = line_count;
\r
599 osd_y = start_line + line_count - 8;
\r
602 gp2x_video_RGB_setscaling(ln_offs, scalex, scaley);
\r
604 /* line doubling */
\r
605 if (currentConfig.vscaling == EOPT_SCALE_SW && line_count < 240) {
\r
606 ld_lines = ld_left = line_count / (240 - line_count);
\r
607 PicoDrawSetCallbacks(EmuScanBegin16_ld, EmuScanEnd16_ld);
\r
610 // clear whole screen in all buffers
\r
611 if (!is_16bit_mode())
\r
612 gp2x_memset_all_buffers(0, 0xe0, 320*240);
\r
614 gp2x_memset_all_buffers(0, 0, 320*240*2);
\r
617 void plat_video_toggle_renderer(int change, int is_menu_call)
\r
619 change_renderer(change);
\r
625 rendstatus_old = -1;
\r
627 if (PicoAHW & PAHW_32X)
\r
628 emu_status_msg(renderer_names32x[get_renderer()]);
\r
630 emu_status_msg(renderer_names[get_renderer()]);
\r
634 static void RunEventsPico(unsigned int events)
\r
636 int ret, px, py, lim_x;
\r
637 static int pdown_frames = 0;
\r
640 ret = gp2x_touchpad_read(&px, &py);
\r
645 if (pdown_frames++ > 5)
\r
646 PicoPad[0] |= 0x20;
\r
650 if (!(Pico.video.reg[12]&1)) {
\r
652 if (pico_pen_x < 0) pico_pen_x = 0;
\r
653 if (pico_pen_x > 248) pico_pen_x = 248;
\r
655 if (pico_pen_y > 224) pico_pen_y = 224;
\r
661 // PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
\r
666 void plat_update_volume(int has_changed, int is_up)
\r
668 static int prev_frame = 0, wait_frames = 0;
\r
669 int need_low_volume = 0;
\r
670 int vol = currentConfig.volume;
\r
673 soc = soc_detect();
\r
674 if ((PicoOpt & POPT_EN_STEREO) && soc == SOCID_MMSP2)
\r
675 need_low_volume = 1;
\r
679 if (need_low_volume && vol < 5 && prev_frame == Pico.m.frame_count - 1 && wait_frames < 12)
\r
683 plat_target_step_volume(¤tConfig.volume, is_up ? 1 : -1);
\r
684 vol = currentConfig.volume;
\r
686 emu_status_msg("VOL: %02i", vol);
\r
687 prev_frame = Pico.m.frame_count;
\r
690 if (!need_low_volume)
\r
693 /* set the right mixer func */
\r
695 PsndMix_32_to_16l = mix_32_to_16l_stereo;
\r
697 mix_32_to_16l_level = 5 - vol;
\r
698 PsndMix_32_to_16l = mix_32_to_16l_stereo_lvl;
\r
702 void pemu_sound_start(void)
\r
706 plat_target_step_volume(¤tConfig.volume, 0);
\r
709 static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
\r
713 // prepare sound stuff
\r
714 if (currentConfig.EmuOpt & EOPT_EN_SOUND)
\r
716 int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;
\r
717 int snd_rate_oss = PsndRate;
\r
720 memset(sndBuffer, 0, sizeof(sndBuffer));
\r
721 PsndOut = sndBuffer;
\r
722 PicoWriteSound = oss_write_nonblocking;
\r
723 plat_update_volume(0, 0);
\r
725 printf("starting audio: %i len: %i stereo: %i, pal: %i\n",
\r
726 PsndRate, PsndLen, is_stereo, Pico.m.pal);
\r
727 sndout_oss_start(snd_rate_oss, is_stereo, 1);
\r
728 sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
\r
730 soc = soc_detect();
\r
731 if (soc == SOCID_POLLUX)
\r
732 PsndRate = pollux_get_real_snd_rate(PsndRate);
\r
734 #define SOUND_RERATE_FLAGS (POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO|POPT_EXT_FM|POPT_EN_MCD_CDDA)
\r
735 if (PsndRate != PsndRate_old || Pico.m.pal != pal_old || ((PicoOpt & POPT_EXT_FM) && crashed_940) ||
\r
736 ((PicoOpt ^ PicoOpt_old) & SOUND_RERATE_FLAGS)) {
\r
737 PsndRerate(Pico.m.frame_count ? 1 : 0);
\r
740 PsndRate_old = PsndRate;
\r
741 PicoOpt_old = PicoOpt;
\r
742 pal_old = Pico.m.pal;
\r
747 static const int sound_rates[] = { 44100, 32000, 22050, 16000, 11025, 8000 };
\r
749 void pemu_sound_stop(void)
\r
753 /* get back from Pollux pain */
\r
755 for (i = 0; i < ARRAY_SIZE(sound_rates); i++) {
\r
756 if (PsndRate >= sound_rates[i]) {
\r
757 PsndRate = sound_rates[i];
\r
763 void pemu_forced_frame(int no_scale, int do_emu)
\r
765 doing_bg_frame = 1;
\r
766 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
\r
767 PicoDrawSetCallbacks(NULL, NULL);
\r
768 Pico.m.dirtyPal = 1;
\r
770 emu_cmn_forced_frame(no_scale, do_emu);
\r
772 g_menubg_src_ptr = g_screen_ptr;
\r
773 doing_bg_frame = 0;
\r
776 void plat_debug_cat(char *str)
\r
780 void plat_video_loop_prepare(void)
\r
782 // make sure we are in correct mode
\r
783 change_renderer(0);
\r
787 void pemu_loop_prep(void)
\r
789 if (gp2x_dev_id == GP2X_DEV_CAANOO)
\r
790 in_set_config_int(in_name_to_id("evdev:pollux-analog"),
\r
791 IN_CFG_ABS_DEAD_ZONE,
\r
792 currentConfig.analog_deadzone);
\r
794 // dirty buffers better go now than during gameplay
\r
799 void pemu_loop_end(void)
\r
803 /* do one more frame for menu bg */
\r
804 pemu_forced_frame(0, 1);
\r