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;
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();
}
}
-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
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;
}
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();
}
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
giz_screen = Framework2D_LockBuffer(1);
PicoDrawSetColorFormat(1);
- PicoScan = EmuScan16;
- PicoScan((unsigned) -1, NULL);
+ PicoScanBegin = EmuScanBegin16;
Pico.m.dirtyPal = 1;
PicoFrameDrawOnly();
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;
}
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;
- if (act == 16 || act == 17) continue; // player2 flag
- for (u = 0; u < 32; u++)
- {
- if (currentConfig.KeyBinds[u] & (1 << act)) keyc++;
- }
- 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)
{
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;
reset_timing = 1;
// prepare CD buffer
- if (PicoMCD & 1) PicoCDBufferInit();
+ if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
// prepare sound stuff
PsndOut = NULL;
{
int ret, snd_excess_add, stereo;
if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
- sound_rerate(Pico.m.frame_count ? 1 : 0);
+ PsndRerate(Pico.m.frame_count ? 1 : 0);
}
stereo=(PicoOpt&8)>>3;
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
/* 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)
}
- if (PicoMCD & 1) PicoCDBufferFree();
+ if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
if (PsndOut != NULL) {
PsndOut = snd_cbuff = NULL;
void emu_ResetGame(void)
{
- PicoReset(0);
+ PicoReset();
reset_timing = 1;
}