X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Femu.c;h=585c1d5544c6631df7e56c22c0e2fcaff2bda2a1;hb=421713439805e3d389c420a04afc48fc267eb28f;hp=237105addc1dbd69f6dd154763db00b8e27dbfdf;hpb=e2de9939cd42db1810cb523eda4bc9186d7b4ddf;p=picodrive.git diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 237105a..585c1d5 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -16,7 +16,8 @@ #include "emu.h" #include "gp2x.h" -#include "menu.h" +#include "soc.h" +#include "../common/menu.h" #include "../common/arm_utils.h" #include "../common/fonts.h" #include "../common/emu.h" @@ -40,8 +41,6 @@ #endif -int select_exits = 0; - extern int crashed_940; static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; @@ -145,19 +144,6 @@ void emu_prepareDefaultConfig(void) defaultConfig.Frameskip = -1; // auto defaultConfig.CPUclock = 200; defaultConfig.volume = 50; - defaultConfig.KeyBinds[ 0] = 1<<0; // SACB RLDU - defaultConfig.KeyBinds[ 4] = 1<<1; - defaultConfig.KeyBinds[ 2] = 1<<2; - defaultConfig.KeyBinds[ 6] = 1<<3; - defaultConfig.KeyBinds[14] = 1<<4; - defaultConfig.KeyBinds[13] = 1<<5; - defaultConfig.KeyBinds[12] = 1<<6; - defaultConfig.KeyBinds[ 8] = 1<<7; - defaultConfig.KeyBinds[15] = 1<<26; // switch rend - defaultConfig.KeyBinds[10] = 1<<27; // save state - defaultConfig.KeyBinds[11] = 1<<28; // load state - defaultConfig.KeyBinds[23] = 1<<29; // vol up - defaultConfig.KeyBinds[22] = 1<<30; // vol down defaultConfig.gamma = 100; defaultConfig.scaling = 0; defaultConfig.turbo_rate = 15; @@ -415,7 +401,7 @@ static void emu_msg_tray_open(void) gettimeofday(¬iceMsgTime, 0); } -static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) +static void RunEventsPico(unsigned int events) { int ret, px, py, lim_x; static int pdown_frames = 0; @@ -449,11 +435,11 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) // PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; } + if (PicoPad[0] & 1) pico_pen_y--; + if (PicoPad[0] & 2) pico_pen_y++; + if (PicoPad[0] & 4) pico_pen_x--; + if (PicoPad[0] & 8) pico_pen_x++; PicoPad[0] &= ~0x0f; // release UDLR - if (gp2x_keys & GP2X_UP) pico_pen_y--; - if (gp2x_keys & GP2X_DOWN) pico_pen_y++; - if (gp2x_keys & GP2X_LEFT) pico_pen_x--; - if (gp2x_keys & GP2X_RIGHT) pico_pen_x++; lim_x = (Pico.video.reg[12]&1) ? 319 : 255; if (pico_pen_y < 8) pico_pen_y = 8; @@ -507,15 +493,31 @@ static void RunEvents(unsigned int which) { int do_it = 1; if ( emu_checkSaveFile(state_slot) && - (( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load - (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save - unsigned long keys; - blit("", (which & 0x1000) ? "LOAD STATE? (Y=yes, X=no)" : "OVERWRITE SAVE? (Y=yes, X=no)"); - while ( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) ) - usleep(50*1024); - if (keys & GP2X_X) do_it = 0; - while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release - usleep(50*1024); + (( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load + (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save + { + const char *nm; + char tmp[64]; + int keys, len; + + strcpy(tmp, (which & 0x1000) ? "LOAD STATE? " : "OVERWRITE SAVE? "); + len = strlen(tmp); + nm = in_get_key_name(-1, -PBTN_MA3); + snprintf(tmp + len, sizeof(tmp) - len, "(%s=yes, ", nm); + len = strlen(tmp); + nm = in_get_key_name(-1, -PBTN_MBACK); + snprintf(tmp + len, sizeof(tmp) - len, "%s=no)", nm); + + blit("", tmp); + + in_set_blocking(1); + while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK)); // wait for release + while ( !((keys = in_menu_wait_any(50)) & (PBTN_MA3|PBTN_MBACK)) ); // .. press + if (keys & PBTN_MBACK) + do_it = 0; + while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK)); // .. release + in_set_blocking(0); + clearArea(0); } if (do_it) { @@ -544,7 +546,7 @@ static void RunEvents(unsigned int which) strcpy(noticeMsg, " 8bit accurate renderer"); } - gettimeofday(¬iceMsgTime, 0); + emu_noticeMsgUpdated(); } if (which & 0x0300) { @@ -556,7 +558,7 @@ static void RunEvents(unsigned int which) if(state_slot > 9) state_slot = 0; } sprintf(noticeMsg, "SAVE SLOT %i [%s]", state_slot, emu_checkSaveFile(state_slot) ? "USED" : "FREE"); - gettimeofday(¬iceMsgTime, 0); + emu_noticeMsgUpdated(); } if (which & 0x0080) { engineState = PGS_Menu; @@ -565,48 +567,11 @@ static void RunEvents(unsigned int which) static void updateKeys(void) { - unsigned int keys, keys2, allActions[2] = { 0, 0 }, events; + unsigned int allActions[2] = { 0, 0 }, events; static unsigned int prevEvents = 0; - keys = gp2x_joystick_read(0); - if (keys & GP2X_SELECT) - engineState = select_exits ? PGS_Quit : PGS_Menu; - - keys &= CONFIGURABLE_KEYS; - keys2 = keys; - -#if 1 - /* FIXME: combos, player2 */ + /* FIXME: player2 */ allActions[0] = in_update(); -#else - for (i = 0; i < 32; i++) - { - if (keys2 & (1 << i)) - { - int pl, acts = currentConfig.KeyBinds[i]; - if (!acts) continue; - pl = (acts >> 16) & 1; - if (kb_combo_keys & (1 << i)) - { - int u = i+1, acts_c = acts & kb_combo_acts; - // let's try to find the other one - if (acts_c) { - for (; u < 32; u++) - if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) { - allActions[pl] |= acts_c & currentConfig.KeyBinds[u]; - keys2 &= ~((1 << i) | (1 << u)); - break; - } - } - // add non-combo actions if combo ones were not found - if (!acts_c || u == 32) - allActions[pl] |= acts & ~kb_combo_acts; - } else { - allActions[pl] |= acts; - } - } - } -#endif PicoPad[0] = allActions[0] & 0xfff; PicoPad[1] = allActions[1] & 0xfff; @@ -629,7 +594,7 @@ static void updateKeys(void) events &= ~prevEvents; if (PicoAHW == PAHW_PICO) - RunEventsPico(events, keys); + RunEventsPico(events); if (events) RunEvents(events); if (movie_data) emu_updateMovie(); @@ -834,7 +799,6 @@ void emu_Loop(void) scaling_update(); Pico.m.dirtyPal = 1; oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc; - emu_findKeyBindCombos(); // pal/ntsc might have changed, reset related stuff target_fps = Pico.m.pal ? 50 : 60; @@ -1052,7 +1016,7 @@ const char *plat_get_credits(void) "Reesy & FluBBa: DrZ80 core\n" "MAME devs: YM2612 and SN76496 cores\n" "rlyeh and others: minimal SDK\n" - "Squidge: squidgehack\n" + "Squidge: mmuhack\n" "Dzz: ARM940 sample\n" "GnoStiC / Puck2099: USB joy code\n" "craigix: GP2X hardware\n"