9 #include "../common/plat.h"
10 #include "../common/readpng.h"
11 #include "../common/menu.h"
12 #include "../common/emu.h"
13 #include "../linux/sndout_oss.h"
15 #include <pico/pico.h>
18 int default_cpu_clock;
19 void *gp2x_screens[4];
21 void gp2x_video_changemode(int bpp)
23 gp2x_video_changemode_ll(bpp);
25 gp2x_memset_all_buffers(0, 0, 320*240*2);
29 static void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
32 if (buffers & (1<<0)) { dst = (char *)gp2x_screens[0] + offset; if (dst != data) memcpy(dst, data, len); }
33 if (buffers & (1<<1)) { dst = (char *)gp2x_screens[1] + offset; if (dst != data) memcpy(dst, data, len); }
34 if (buffers & (1<<2)) { dst = (char *)gp2x_screens[2] + offset; if (dst != data) memcpy(dst, data, len); }
35 if (buffers & (1<<3)) { dst = (char *)gp2x_screens[3] + offset; if (dst != data) memcpy(dst, data, len); }
38 void gp2x_memcpy_all_buffers(void *data, int offset, int len)
40 gp2x_memcpy_buffers(0xf, data, offset, len);
43 void gp2x_memset_all_buffers(int offset, int byte, int len)
45 memset((char *)gp2x_screens[0] + offset, byte, len);
46 memset((char *)gp2x_screens[1] + offset, byte, len);
47 memset((char *)gp2x_screens[2] + offset, byte, len);
48 memset((char *)gp2x_screens[3] + offset, byte, len);
51 void gp2x_make_fb_bufferable(int yes)
56 ret |= warm_change_cb_range(WCB_B_BIT, yes, gp2x_screens[0], 320*240*2);
57 ret |= warm_change_cb_range(WCB_B_BIT, yes, gp2x_screens[1], 320*240*2);
58 ret |= warm_change_cb_range(WCB_B_BIT, yes, gp2x_screens[2], 320*240*2);
59 ret |= warm_change_cb_range(WCB_B_BIT, yes, gp2x_screens[3], 320*240*2);
62 fprintf(stderr, "could not make fb buferable.\n");
64 printf("made fb buferable.\n");
68 char cpu_clk_name[16] = "GP2X CPU clocks";
70 void plat_video_menu_enter(int is_rom_loaded)
74 // darken the active framebuffer
75 memset(g_screen_ptr, 0, 320*8*2);
76 menu_darken_bg((char *)g_screen_ptr + 320*8*2, 320*224, 1);
77 memset((char *)g_screen_ptr + 320*232*2, 0, 320*8*2);
83 // should really only happen once, on startup..
84 emu_make_path(buff, "skin/background.png", sizeof(buff));
85 if (readpng(g_screen_ptr, buff, READPNG_BG) < 0)
86 memset(g_screen_ptr, 0, 320*240*2);
89 // copy to buffer2, switch to black
90 gp2x_memcpy_buffers((1<<2), g_screen_ptr, 0, 320*240*2);
92 /* try to switch nicely avoiding tearing on Wiz */
93 gp2x_video_wait_vsync();
94 memset(gp2x_screens[0], 0, 320*240*2);
95 memset(gp2x_screens[1], 0, 320*240*2);
97 gp2x_video_wait_vsync();
98 gp2x_video_wait_vsync();
101 gp2x_video_changemode_ll(16);
102 gp2x_video_RGB_setscaling(0, 320, 240);
105 void plat_video_menu_begin(void)
107 memcpy(g_screen_ptr, gp2x_screens[2], 320*240*2);
110 void plat_video_menu_end(void)
113 // gp2x_video_flush_cache();
117 void plat_validate_config(void)
122 if (soc != SOCID_MMSP2)
123 PicoOpt &= ~POPT_EXT_FM;
124 if (soc != SOCID_POLLUX)
125 currentConfig.EmuOpt &= ~EOPT_WIZ_TEAR_FIX;
127 if (currentConfig.gamma < 10 || currentConfig.gamma > 300)
128 currentConfig.gamma = 100;
130 if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 1024)
131 currentConfig.CPUclock = default_cpu_clock;
134 void plat_early_init(void)
142 default_cpu_clock = 200;
145 strcpy(cpu_clk_name, "Wiz CPU clock");
146 default_cpu_clock = 533;
149 fprintf(stderr, "could not recognize SoC, bailing out.\n");
175 gp2x_memset_all_buffers(0, 0, 320*240*2);
181 void plat_finish(void)
201 void lprintf(const char *fmt, ...)