X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fplat.c;h=e80b0fb279530b779264d06b2a0d7f14078a863f;hb=1bc471ebf1c85cf78f1862f5596a76f051e7112d;hp=a2b839449d7daad44c099b792d6439f11d1214e3;hpb=e31266dd116b6bea59ce3f2036feeb6725c45a72;p=libpicofe.git diff --git a/gp2x/plat.c b/gp2x/plat.c index a2b8394..e80b0fb 100644 --- a/gp2x/plat.c +++ b/gp2x/plat.c @@ -1,44 +1,110 @@ +/* + * (C) notaz, 2013 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * - MAME license. + * See the COPYING file in the top-level directory. + */ + +#include +#include #include +#include +#include +#include +#include + +#include "../plat.h" +#include "../input.h" +#include "plat_gp2x.h" +#include "soc.h" + +int default_cpu_clock; +int gp2x_dev_id; -#include "gp2x.h" -#include "../common/plat.h" -#include "../common/readpng.h" -#include "../common/menu.h" -#include "../common/emu.h" +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", +}; +/* to be filled by mmsp2/pollux _init */ +struct plat_target plat_target; -void plat_video_menu_enter(int is_rom_loaded) +int plat_target_init(void) { - 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); - } - else + gp2x_soc_t soc; + FILE *f; + + soc = soc_detect(); + switch (soc) { - // should really only happen once, on startup.. - readpng(g_screen_ptr, "skin/background.png", READPNG_BG); + case SOCID_MMSP2: + mmsp2_init(); + default_cpu_clock = 200; + gp2x_dev_id = GP2X_DEV_GP2X; + break; + case SOCID_POLLUX: + pollux_init(); + 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.\n"); + break; } - // copy to buffer2 - gp2x_memcpy_buffers((1<<2), g_screen_ptr, 0, 320*240*2); - - // switch to 16bpp - gp2x_video_changemode2(16); - gp2x_video_RGB_setscaling(0, 320, 240); - gp2x_video_flip2(); + return 0; } -void plat_video_menu_begin(void) +/* to be called after in_probe */ +void plat_target_setup_input(void) { - gp2x_pd_clone_buffer2(); + 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)); } -void plat_video_menu_end(void) +void plat_target_finish(void) { - gp2x_video_flush_cache(); - gp2x_video_flip2(); -} + gp2x_soc_t soc; + soc = soc_detect(); + switch (soc) + { + case SOCID_MMSP2: + mmsp2_finish(); + break; + case SOCID_POLLUX: + pollux_finish(); + break; + default: + break; + } +}