X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pandora%2Fplat.c;h=1815274b814d1b9ec28fb37df3b37eed47b5cb6c;hb=ca69c3e5a0ecf407c02dc85c6f3282ebb1efc5a2;hp=a24e3ba2caf7a4e01b94569616cff14cf2b0a2e0;hpb=b6eccda3174977ced5e654b2278dd24381c713d8;p=libpicofe.git diff --git a/pandora/plat.c b/pandora/plat.c index a24e3ba..1815274 100644 --- a/pandora/plat.c +++ b/pandora/plat.c @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -21,6 +20,7 @@ #include "../common/input.h" #include "../linux/sndout_oss.h" #include "../linux/fbdev.h" +#include "../linux/xenv.h" #include "plat.h" #include "asm_utils.h" #include "version.h" @@ -30,6 +30,8 @@ #include static struct vout_fbdev *main_fb, *layer_fb; +// g_layer_* - in use, g_layer_c* - configured custom +int g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch; static int g_layer_x, g_layer_y; static int g_layer_w = 320, g_layer_h = 240; static int g_osd_fps_x, g_osd_y, doing_bg_frame; @@ -59,6 +61,30 @@ static const char * const pandora_gpio_keys[KEY_MAX + 1] = { [KEY_MENU] = "Pandora", }; +struct in_default_bind in_evdev_defbinds[] = +{ + /* MXYZ SACB RLDU */ + { KEY_UP, IN_BINDTYPE_PLAYER12, 0 }, + { KEY_DOWN, IN_BINDTYPE_PLAYER12, 1 }, + { KEY_LEFT, IN_BINDTYPE_PLAYER12, 2 }, + { KEY_RIGHT, IN_BINDTYPE_PLAYER12, 3 }, + { KEY_S, IN_BINDTYPE_PLAYER12, 4 }, /* B */ + { KEY_D, IN_BINDTYPE_PLAYER12, 5 }, /* C */ + { KEY_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */ + { KEY_ENTER, IN_BINDTYPE_PLAYER12, 7 }, + { KEY_BACKSLASH, IN_BINDTYPE_EMU, PEVB_MENU }, + { KEY_SPACE, IN_BINDTYPE_EMU, PEVB_MENU }, + /* Pandora */ + { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, 4 }, + { KEY_END, IN_BINDTYPE_PLAYER12, 5 }, + { KEY_HOME, IN_BINDTYPE_PLAYER12, 6 }, + { KEY_LEFTALT, IN_BINDTYPE_PLAYER12, 7 }, + { KEY_RIGHTSHIFT,IN_BINDTYPE_EMU, PEVB_STATE_SAVE }, + { KEY_RIGHTCTRL, IN_BINDTYPE_EMU, PEVB_STATE_LOAD }, + { KEY_LEFTCTRL, IN_BINDTYPE_EMU, PEVB_MENU }, + { 0, 0, 0 } +}; + static int get_cpu_clock(void) { FILE *f; @@ -144,6 +170,10 @@ void pemu_finalize_frame(const char *fps, const char *notice) void plat_video_flip(void) { g_screen_ptr = vout_fbdev_flip(layer_fb); + + // XXX: drain OS event queue here, maybe we'll actually use it someday.. + int dummy; + xenv_update(&dummy); } void plat_video_toggle_renderer(int change, int is_menu) @@ -240,51 +270,22 @@ static void make_bg(int no_scale) void pemu_forced_frame(int no_scale, int do_emu) { - int po_old = PicoOpt; - - memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4); - - PicoOpt |= POPT_ACC_SPRITES; - if (!no_scale) - PicoOpt |= POPT_EN_SOFTSCALE; - - PicoDrawSetOutFormat(PDF_RGB555, 1); - Pico.m.dirtyPal = 1; doing_bg_frame = 1; - if (do_emu) - PicoFrame(); - else - PicoFrameDrawOnly(); + emu_cmn_forced_frame(no_scale, do_emu); doing_bg_frame = 0; // making a copy because enabling the layer clears it's mem memcpy32((void *)fb_copy, g_screen_ptr, sizeof(fb_copy) / 4); make_bg(no_scale); - - PicoOpt = po_old; } -static void updateSound(int len) +static void oss_write_nonblocking(int len) { - unsigned int t; - - len <<= 1; - if (PicoOpt & POPT_EN_STEREO) - len <<= 1; - - // sndout_oss_can_write() not reliable.. + // sndout_oss_can_write() is not reliable, only use with no_frmlimit if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len)) return; - /* avoid writing audio when lagging behind to prevent audio lag */ - if (PicoSkipFrame == 2) - return; - - t = plat_get_ticks_ms(); - sndout_oss_write(PsndOut, len); - t = plat_get_ticks_ms() - t; - if (t > 1) - printf("audio lag %u\n", t); + sndout_oss_write_nb(PsndOut, len); } void pemu_sound_start(void) @@ -308,7 +309,7 @@ void pemu_sound_start(void) PsndRate, PsndLen, is_stereo, Pico.m.pal); sndout_oss_start(PsndRate, is_stereo, 2); //sndout_oss_setvol(currentConfig.volume, currentConfig.volume); - PicoWriteSound = updateSound; + PicoWriteSound = oss_write_nonblocking; plat_update_volume(0, 0); memset(sndBuffer, 0, sizeof(sndBuffer)); PsndOut = sndBuffer; @@ -471,8 +472,8 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) g_osd_y = fb_top + fb_h - 8; pnd_setup_layer(1, g_layer_x, g_layer_y, g_layer_w, g_layer_h); - vout_fbdev_resize(layer_fb, fb_w, fb_h, fb_left, fb_right, fb_top, fb_bottom, 0); vout_fbdev_clear(layer_fb); + vout_fbdev_resize(layer_fb, fb_w, fb_h, 16, fb_left, fb_right, fb_top, fb_bottom, 3); plat_video_flip(); } @@ -546,26 +547,6 @@ void plat_wait_till_us(unsigned int us_to) */ } -const char *plat_get_credits(void) -{ - return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n" - "Credits:\n" - "fDave: Cyclone 68000 core,\n" - " base code of PicoDrive\n" - "Reesy & FluBBa: DrZ80 core\n" - "MAME devs: YM2612 and SN76496 cores\n" - "Pandora team: Pandora\n" - "Inder, ketchupgun: graphics\n" - "\n" - "special thanks (for docs, ideas):\n" - " Charles MacDonald, Haze,\n" - " Stephane Dallongeville,\n" - " Lordus, Exophase, Rokas,\n" - " Nemesis, Tasco Deluxe"; -} - -#include "../linux/oshide.h" - void plat_early_init(void) { } @@ -598,10 +579,10 @@ void plat_init(void) exit(1); } - oshide_init(); + xenv_init(); w = h = 0; - main_fb = vout_fbdev_init(main_fb_name, &w, &h, 0); + main_fb = vout_fbdev_init(main_fb_name, &w, &h, 16, 2); if (main_fb == NULL) { fprintf(stderr, "couldn't init fb: %s\n", main_fb_name); exit(1); @@ -612,7 +593,7 @@ void plat_init(void) g_menuscreen_ptr = vout_fbdev_flip(main_fb); w = 320; h = 240; - layer_fb = vout_fbdev_init(layer_fb_name, &w, &h, 0); + layer_fb = vout_fbdev_init(layer_fb_name, &w, &h, 16, 3); if (layer_fb == NULL) { fprintf(stderr, "couldn't init fb: %s\n", layer_fb_name); goto fail0; @@ -651,18 +632,8 @@ void plat_finish(void) { sndout_oss_exit(); vout_fbdev_finish(main_fb); - oshide_finish(); + xenv_finish(); printf("all done\n"); } -/* lprintf */ -void lprintf(const char *fmt, ...) -{ - va_list vl; - - va_start(vl, fmt); - vprintf(fmt, vl); - va_end(vl); -} -