static int StateAction(StateMem *sm, int load, int data_only) { if(Genie_BIOSInstalled()) { if(!data_only) MDFN_DispMessage(_("Cannot use states in GG Screen.")); return(0); } if(!X6502_StateAction(sm, load, data_only)) return(0); if(!MDFNPPU_StateAction(sm, load, data_only)) return(0); if(!MDFNSND_StateAction(sm, load, data_only)) return(0); if(!load || load >= 0x0500) { if(!NESINPUT_StateAction(sm, load, data_only)) return(0); } if(GameInterface->StateAction) { if(!GameInterface->StateAction(sm, load, data_only)) return(0); } return(1); }
static void InstallReadPatch(uint32 address, uint8 value, int compare) { if(Genie_BIOSInstalled()) return; address &= 0xFFFF; SetReadHandler(address, address, CheatReadFunc, 0); }
static void RemoveReadPatches(void) { if(Genie_BIOSInstalled()) return; for(uint32 A = 0; A <= 0xFFFF; A++) { SetReadHandler(A, A, NonCheatARead[A], 0); } }
void PowerNES(void) { MDFNMOV_AddCommand(MDFN_MSC_POWER); if(!MDFNGameInfo) return; if(!Genie_BIOSInstalled()) MDFNMP_RemoveReadPatches(); MDFNMP_AddRAM(0x0800, 0x0000, RAM); // Genie_Power() will remove any cheat read patches, and then install the BIOS(and its read hooks) Genie_Power(); // http://wiki.nesdev.com/w/index.php/CPU_power_up_state memset(RAM, 0xFF, 0x800); RAM[0x008] = 0xF7; RAM[0x009] = 0xEF; RAM[0x00A] = 0xDF; RAM[0x00F] = 0xBF; NESINPUT_Power(); MDFNSND_Power(); MDFNPPU_Power(); /* Have the external game hardware "powered" after the internal NES stuff. Needed for the NSF code and VS System code. */ if(GameInterface->Power) GameInterface->Power(); if(NESIsVSUni) MDFN_VSUniPower(); timestampbase = 0; X6502_Power(); if(!Genie_BIOSInstalled()) MDFNMP_InstallReadPatches(); }
static void Emulate(EmulateSpecStruct *espec) { int ssize; #if 0 static bool firstcat = true; MDFN_PixelFormat tmp_pf; tmp_pf.Rshift = 0; tmp_pf.Gshift = 0; tmp_pf.Bshift = 0; tmp_pf.Ashift = 8; tmp_pf.Rprec = 6; tmp_pf.Gprec = 6; tmp_pf.Bprec = 6; tmp_pf.Aprec = 0; tmp_pf.bpp = 8; tmp_pf.colorspace = MDFN_COLORSPACE_RGB; espec->surface->SetFormat(tmp_pf, false); espec->VideoFormatChanged = firstcat; firstcat = false; #endif if(espec->VideoFormatChanged) { MDFN_InitPalette(NESIsVSUni ? MDFN_VSUniGetPaletteNum() : (bool)PAL, espec->CustomPalette, espec->CustomPaletteNumEntries); MDFNNES_SetPixelFormat(espec->surface->format); } if(espec->SoundFormatChanged) MDFNNES_SetSoundRate(espec->SoundRate); NESPPU_GetDisplayRect(&espec->DisplayRect); MDFN_UpdateInput(); if(!Genie_BIOSInstalled()) MDFNMP_ApplyPeriodicCheats(); MDFNPPU_Loop(espec); ssize = FlushEmulateSound(espec->NeedSoundReverse, espec->SoundBuf, espec->SoundBufMaxSize); espec->NeedSoundReverse = 0; timestampbase += timestamp; espec->MasterCycles = timestamp; timestamp = 0; if(MDFNGameInfo->GameType == GMT_PLAYER) MDFNNES_DrawNSF(espec->surface, &espec->DisplayRect, espec->SoundBuf, ssize); espec->SoundBufSize = ssize; if(MDFNGameInfo->GameType != GMT_PLAYER) { if(NESIsVSUni) MDFN_VSUniDraw(espec->surface); } }