X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fplat.c;h=d20fc221cb21e795a7df167387b49de5ea34e25e;hb=902972d1c7f353aebb17a5ab587b2526e1a45d60;hp=075937ee705f37ec2b538806e057b4127f6d1d54;hpb=1eb704b6332072581bf7c3bc411babc66f8bda8a;p=libpicofe.git diff --git a/gp2x/plat.c b/gp2x/plat.c index 075937e..d20fc22 100644 --- a/gp2x/plat.c +++ b/gp2x/plat.c @@ -10,20 +10,43 @@ #include "../common/readpng.h" #include "../common/menu.h" #include "../common/emu.h" +#include "../common/input.h" #include "../linux/sndout_oss.h" #include /* GP2X local */ int default_cpu_clock; +int gp2x_dev_id; +int gp2x_current_bpp; void *gp2x_screens[4]; +#include + +static const char * const caanoo_keys[KEY_MAX + 1] = { + [0 ... KEY_MAX] = NULL, + [KEY_UP] = "Up", + [KEY_LEFT] = "Left", + [KEY_RIGHT] = "Right", + [KEY_DOWN] = "Down", + [BTN_TRIGGER] = "A", + [BTN_THUMB] = "X", + [BTN_THUMB2] = "B", + [BTN_TOP] = "Y", + [BTN_TOP2] = "L", + [BTN_PINKIE] = "R", + [BTN_BASE] = "Home", + [BTN_BASE2] = "Lock", + [BTN_BASE3] = "I", + [BTN_BASE4] = "II", + [BTN_BASE5] = "Push", +}; + void gp2x_video_changemode(int bpp) { gp2x_video_changemode_ll(bpp); - gp2x_memset_all_buffers(0, 0, 320*240*2); - gp2x_video_flip(); + gp2x_current_bpp = bpp < 0 ? -bpp : bpp; } static void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len) @@ -65,37 +88,18 @@ void gp2x_make_fb_bufferable(int yes) } /* common */ -char cpu_clk_name[16] = "GP2X CPU clocks"; - void plat_video_menu_enter(int is_rom_loaded) { - if (is_rom_loaded) - { - // darken the active framebuffer - memset(g_screen_ptr, 0, 320*8*2); - menu_darken_bg((char *)g_screen_ptr + 320*8*2, 320*224, 1); - memset((char *)g_screen_ptr + 320*232*2, 0, 320*8*2); + if (gp2x_current_bpp != 16 || gp2x_dev_id == GP2X_DEV_WIZ) { + /* try to switch nicely avoiding glitches */ + gp2x_video_wait_vsync(); + memset(gp2x_screens[0], 0, 320*240*2); + memset(gp2x_screens[1], 0, 320*240*2); + gp2x_video_flip2(); // might flip to fb2/3 + gp2x_video_flip2(); // ..so we do it again } else - { - char buff[256]; - - // should really only happen once, on startup.. - emu_make_path(buff, "skin/background.png", sizeof(buff)); - if (readpng(g_screen_ptr, buff, READPNG_BG) < 0) - memset(g_screen_ptr, 0, 320*240*2); - } - - // copy to buffer2, switch to black - gp2x_memcpy_buffers((1<<2), g_screen_ptr, 0, 320*240*2); - - /* try to switch nicely avoiding tearing on Wiz */ - gp2x_video_wait_vsync(); - memset(gp2x_screens[0], 0, 320*240*2); - memset(gp2x_screens[1], 0, 320*240*2); - gp2x_video_flip2(); - gp2x_video_wait_vsync(); - gp2x_video_wait_vsync(); + gp2x_video_flip2(); // switch to 16bpp gp2x_video_changemode_ll(16); @@ -104,51 +108,47 @@ void plat_video_menu_enter(int is_rom_loaded) void plat_video_menu_begin(void) { - memcpy(g_screen_ptr, gp2x_screens[2], 320*240*2); + g_menuscreen_ptr = g_screen_ptr; } void plat_video_menu_end(void) { - // FIXME - // gp2x_video_flush_cache(); gp2x_video_flip2(); } -void plat_validate_config(void) -{ - gp2x_soc_t soc; - - soc = soc_detect(); - if (soc != SOCID_MMSP2) - PicoOpt &= ~POPT_EXT_FM; - if (soc != SOCID_POLLUX) - currentConfig.EmuOpt &= ~EOPT_WIZ_TEAR_FIX; - - if (currentConfig.gamma < 10 || currentConfig.gamma > 300) - currentConfig.gamma = 100; - - if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 1024) - currentConfig.CPUclock = default_cpu_clock; -} - void plat_early_init(void) { gp2x_soc_t soc; + FILE *f; soc = soc_detect(); switch (soc) { case SOCID_MMSP2: default_cpu_clock = 200; + gp2x_dev_id = GP2X_DEV_GP2X; break; case SOCID_POLLUX: - strcpy(cpu_clk_name, "Wiz CPU clock"); default_cpu_clock = 533; + f = fopen("/dev/accel", "rb"); + if (f) { + printf("detected Caanoo\n"); + gp2x_dev_id = GP2X_DEV_CAANOO; + fclose(f); + } + else { + printf("detected Wiz\n"); + gp2x_dev_id = GP2X_DEV_WIZ; + } break; default: printf("could not recognize SoC, running in dummy mode.\n"); break; } + + // just use gettimeofday until plat_init() + gp2x_get_ticks_ms = plat_get_ticks_ms_good; + gp2x_get_ticks_us = plat_get_ticks_us_good; } void plat_init(void) @@ -160,11 +160,9 @@ void plat_init(void) { case SOCID_MMSP2: mmsp2_init(); - menu_plat_setup(0); break; case SOCID_POLLUX: pollux_init(); - menu_plat_setup(1); break; default: dummy_init(); @@ -175,8 +173,17 @@ void plat_init(void) gp2x_memset_all_buffers(0, 0, 320*240*2); + // use buffer2 for menubg to save mem (using only buffers 0, 1 in menu) + g_menubg_ptr = gp2x_screens[2]; + // snd sndout_oss_init(); + + if (gp2x_dev_id == GP2X_DEV_CAANOO) + in_set_config(in_name_to_id("evdev:pollux-analog"), IN_CFG_KEY_NAMES, + caanoo_keys, sizeof(caanoo_keys)); + + gp2x_menu_init(); } void plat_finish(void)