X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgizmondo%2Femu.c;h=ebc15a2d7de281b5547ae6fcaec251be5e53fa9d;hb=6fc5714482ecd4da20c3d5189b607afafc72b248;hp=152c64844a22fd720cbd0f4c2637210d6d8ad659;hpb=1f4e9f147fc079f0efe4c4f95c0c9549d3b41553;p=picodrive.git diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 152c648..ebc15a2 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -31,7 +31,6 @@ int engineState; unsigned char *PicoDraw2FB = gfx_buffer; // temporary buffer for alt renderer ( (8+320)*(8+240+8) ) int reset_timing = 0; -static int combo_keys = 0, combo_acts = 0; // keys and actions which need button combos static DWORD noticeMsgTime = 0; static short *snd_cbuff = NULL; static int snd_cbuf_samples = 0, snd_all_samples = 0; @@ -109,19 +108,8 @@ void emu_Deinit(void) SRam.changed = 0; } - if (!(currentConfig.EmuOpt & 0x20)) { - FILE *f = fopen(PicoConfigFile, "r+b"); - if (!f) emu_WriteConfig(0); - else { - // if we already have config, reload it, except last ROM - fseek(f, sizeof(currentConfig.lastRomFile), SEEK_SET); - fread(¤tConfig.EmuOpt, 1, sizeof(currentConfig) - sizeof(currentConfig.lastRomFile), f); - fseek(f, 0, SEEK_SET); - fwrite(¤tConfig, 1, sizeof(currentConfig), f); - fflush(f); - fclose(f); - } - } + if (!(currentConfig.EmuOpt & 0x20)) + config_writelrom(PicoConfigFile); PicoExit(); } @@ -155,10 +143,10 @@ void emu_setDefaultConfig(void) } -static int EmuScan16(unsigned int num, void *sdata) +static int EmuScanBegin16(unsigned int num) { if (!(Pico.video.reg[1]&8)) num += 8; - DrawLineDest = (unsigned short *) giz_screen + 321*(num+1); + DrawLineDest = (unsigned short *) giz_screen + 321 * num; if ((currentConfig.EmuOpt&0x4000) && (num&1) == 0) // (Pico.m.frame_count&1)) return 1; // skip next line @@ -166,11 +154,11 @@ static int EmuScan16(unsigned int num, void *sdata) return 0; } -static int EmuScan8(unsigned int num, void *sdata) +static int EmuScanBegin8(unsigned int num) { // draw like the fast renderer if (!(Pico.video.reg[1]&8)) num += 8; - HighCol = gfx_buffer + 328*(num+1); + HighCol = gfx_buffer + 328 * num; return 0; } @@ -265,7 +253,7 @@ static void blit(const char *fps, const char *notice) if (emu_opt & 2) osd_text(OSD_FPS_X, h, fps); } - if ((emu_opt & 0x400) && (PicoMCD & 1)) + if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD)) cd_leds(); } @@ -292,10 +280,10 @@ static void vidResetMode(void) if (PicoOpt&0x10) { } else if (currentConfig.EmuOpt&0x80) { PicoDrawSetColorFormat(1); - PicoScan = EmuScan16; + PicoScanBegin = EmuScanBegin16; } else { PicoDrawSetColorFormat(-1); - PicoScan = EmuScan8; + PicoScanBegin = EmuScanBegin8; } if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) { // setup pal for 8-bit modes @@ -368,8 +356,7 @@ void emu_forcedFrame(void) giz_screen = Framework2D_LockBuffer(1); PicoDrawSetColorFormat(1); - PicoScan = EmuScan16; - PicoScan((unsigned) -1, NULL); + PicoScanBegin = EmuScanBegin16; Pico.m.dirtyPal = 1; PicoFrameDrawOnly(); @@ -468,20 +455,21 @@ static void updateKeys(void) int pl, acts = currentConfig.KeyBinds[i]; if (!acts) continue; pl = (acts >> 16) & 1; - if (combo_keys & (1 << i)) + if (kb_combo_keys & (1 << i)) { - int u = i+1, acts_c = acts & combo_acts; + int u = i+1, acts_c = acts & kb_combo_acts; // let's try to find the other one - if (acts_c) + if (acts_c) { for (; u < 32; u++) - if ( (currentConfig.KeyBinds[u] & acts_c) && (keys & (1 << u)) ) { - allActions[pl] |= acts_c; + if ( (keys & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) { + allActions[pl] |= acts_c & currentConfig.KeyBinds[u]; keys &= ~((1 << i) | (1 << u)); break; } + } // add non-combo actions if combo ones were not found if (!acts_c || u == 32) - allActions[pl] |= acts & ~combo_acts; + allActions[pl] |= acts & ~kb_combo_acts; } else { allActions[pl] |= acts; } @@ -515,45 +503,6 @@ static void updateKeys(void) prevEvents = (allActions[0] | allActions[1]) >> 16; } -static void find_combos(void) -{ - int act, u; - - // find out which keys and actions are combos - combo_keys = combo_acts = 0; - for (act = 0; act < 32; act++) - { - int keyc = 0, keyc2 = 0; - if (act == 16 || act == 17) continue; // player2 flag - if (act > 17) - { - for (u = 0; u < 32; u++) - if (currentConfig.KeyBinds[u] & (1 << act)) keyc++; - } - else - { - for (u = 0; u < 32; u++) - if ((currentConfig.KeyBinds[u] & 0x30000) == 0 && // pl. 1 - (currentConfig.KeyBinds[u] & (1 << act))) keyc++; - for (u = 0; u < 32; u++) - if ((currentConfig.KeyBinds[u] & 0x30000) == 1 && // pl. 2 - (currentConfig.KeyBinds[u] & (1 << act))) keyc2++; - if (keyc2 > keyc) keyc = keyc2; - } - if (keyc > 1) - { - // loop again and mark those keys and actions as combo - for (u = 0; u < 32; u++) - { - if (currentConfig.KeyBinds[u] & (1 << act)) { - combo_keys |= 1 << u; - combo_acts |= 1 << act; - } - } - } - } -} - static void simpleWait(DWORD until) { @@ -588,7 +537,7 @@ void emu_Loop(void) else PicoOpt&=~0x4000; Pico.m.dirtyPal = 1; oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc; - find_combos(); + emu_findKeyBindCombos(); // pal/ntsc might have changed, reset related stuff target_fps = Pico.m.pal ? 50 : 60; @@ -596,7 +545,7 @@ void emu_Loop(void) reset_timing = 1; // prepare CD buffer - if (PicoMCD & 1) PicoCDBufferInit(); + if (PicoAHW & PAHW_MCD) PicoCDBufferInit(); // prepare sound stuff PsndOut = NULL; @@ -766,9 +715,6 @@ void emu_Loop(void) /* be sure correct framebuffer is locked */ giz_screen = Framework2D_LockBuffer((currentConfig.EmuOpt&0x8000) ? 0 : 1); - if (!(PicoOpt&0x10)) - PicoScan((unsigned) -1, NULL); - PicoFrame(); if (giz_screen == NULL) @@ -807,7 +753,7 @@ void emu_Loop(void) } - if (PicoMCD & 1) PicoCDBufferFree(); + if (PicoAHW & PAHW_MCD) PicoCDBufferFree(); if (PsndOut != NULL) { PsndOut = snd_cbuff = NULL; @@ -825,7 +771,7 @@ void emu_Loop(void) void emu_ResetGame(void) { - PicoReset(0); + PicoReset(); reset_timing = 1; }