3 * (C) notaz, 2006-2010
\r
5 * This work is licensed under the terms of MAME license.
\r
6 * See COPYING file in the top-level directory.
\r
12 #include "../libpicofe/menu.h"
\r
13 #include "../libpicofe/plat.h"
\r
14 #include "../common/emu.h"
\r
15 #include "../common/arm_utils.h"
\r
16 #include "../common/version.h"
\r
18 #include <pico/pico_int.h>
\r
21 const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };
\r
22 const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };
\r
23 enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };
\r
26 void pemu_prep_defconfig(void)
\r
30 void pemu_validate_config(void)
\r
33 // PicoOpt &= ~POPT_EXT_FM;
\r
35 PicoOpt &= ~POPT_EN_DRC;
\r
39 static void draw_cd_leds(void)
\r
41 int led_reg, pitch, scr_offs, led_offs;
\r
42 led_reg = Pico_mcd->s68k_regs[0];
\r
46 scr_offs = pitch * 2 + 4;
\r
48 if (currentConfig.renderer != RT_16BIT) {
\r
49 #define p(x) px[(x) >> 2]
\r
51 unsigned int *px = (unsigned int *)((char *)g_screen_ptr + scr_offs);
\r
52 unsigned int col_g = (led_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;
\r
53 unsigned int col_r = (led_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;
\r
54 p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;
\r
55 p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;
\r
58 #define p(x) px[(x)*2 >> 2] = px[((x)*2 >> 2) + 1]
\r
60 unsigned int *px = (unsigned int *)((short *)g_screen_ptr + scr_offs);
\r
61 unsigned int col_g = (led_reg & 2) ? 0x06000600 : 0;
\r
62 unsigned int col_r = (led_reg & 1) ? 0xc000c000 : 0;
\r
63 p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;
\r
64 p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;
\r
69 void pemu_finalize_frame(const char *fps, const char *notice)
\r
71 if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) {
\r
72 unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width;
\r
73 unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8;
\r
74 unsigned short *pal = Pico.est.HighPal;
\r
76 if (Pico.m.dirtyPal)
\r
77 PicoDrawUpdateHighPal();
\r
78 for (i = 0; i < 224; i++, ps += 8)
\r
79 for (x = 0; x < 320; x++)
\r
83 if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {
\r
85 emu_osd_text16(4, g_screen_height - 8, notice);
\r
86 if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
\r
87 emu_osd_text16(g_screen_width - 60, g_screen_height - 8, fps);
\r
89 if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))
\r
93 static void apply_renderer(void)
\r
95 switch (currentConfig.renderer) {
\r
97 PicoOpt &= ~POPT_ALT_RENDERER;
\r
98 PicoDrawSetOutFormat(PDF_RGB555, 0);
\r
99 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
\r
102 PicoOpt &= ~POPT_ALT_RENDERER;
\r
103 PicoDrawSetOutFormat(PDF_8BIT, 0);
\r
104 PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328);
\r
107 PicoOpt |= POPT_ALT_RENDERER;
\r
108 PicoDrawSetOutFormat(PDF_NONE, 0);
\r
112 if (PicoAHW & PAHW_32X)
\r
113 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
\r
116 void plat_video_toggle_renderer(int change, int is_menu)
\r
118 currentConfig.renderer += change;
\r
119 if (currentConfig.renderer >= RT_COUNT)
\r
120 currentConfig.renderer = 0;
\r
121 else if (currentConfig.renderer < 0)
\r
122 currentConfig.renderer = RT_COUNT - 1;
\r
127 emu_status_msg(renderer_names[currentConfig.renderer]);
\r
130 void plat_status_msg_clear(void)
\r
132 unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_width * g_screen_height;
\r
133 int l = g_screen_width * 8;
\r
134 memset32((int *)(d - l), 0, l * 2 / 4);
\r
137 void plat_status_msg_busy_next(const char *msg)
\r
139 plat_status_msg_clear();
\r
140 pemu_finalize_frame("", msg);
\r
142 emu_status_msg("");
\r
146 void plat_status_msg_busy_first(const char *msg)
\r
148 // memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);
\r
149 plat_status_msg_busy_next(msg);
\r
152 void plat_update_volume(int has_changed, int is_up)
\r
156 void pemu_forced_frame(int no_scale, int do_emu)
\r
158 PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
\r
159 PicoDrawSetCallbacks(NULL, NULL);
\r
160 Pico.m.dirtyPal = 1;
\r
162 emu_cmn_forced_frame(no_scale, do_emu);
\r
164 g_menubg_src_ptr = g_screen_ptr;
\r
167 void pemu_sound_start(void)
\r
172 void plat_debug_cat(char *str)
\r
176 void emu_video_mode_change(int start_line, int line_count, int is_32cols)
\r
178 // clear whole screen in all buffers
\r
179 memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);
\r
182 void pemu_loop_prep(void)
\r
187 void pemu_loop_end(void)
\r
189 /* do one more frame for menu bg */
\r
190 pemu_forced_frame(0, 1);
\r
193 void plat_wait_till_us(unsigned int us_to)
\r
197 now = plat_get_ticks_us();
\r
199 while ((signed int)(us_to - now) > 512)
\r
202 now = plat_get_ticks_us();
\r