/// <summary> /// Create new emulation engine /// </summary> /// <param name="fileName">The rom complete path. Not compressed</param> /// <param name="tvsetting">The tv system setting to use</param> /// <param name="makeThread">Indicates if the emulation engine should make an internal thread and run through it. Otherwise you should make a thread and use EMUClock to run the loop.</param> public static void CreateNew(string fileName, TVSystemSetting tvsetting, bool makeThread) { switch (Path.GetExtension(fileName).ToLower()) { case ".nes": { INes header = new INes(); header.Load(fileName, true); if (header.IsValid) { INITIALIZED = false; GAMEFILE = fileName; CheckGameVSUnisystem(header.SHA1, header.IsVSUnisystem, header.MapperNumber); // Make SRAM file name SRAMFileName = Path.Combine(SRAMFolder, Path.GetFileNameWithoutExtension(fileName) + ".srm"); STATESlot = 0; UpdateStateSlot(STATESlot); // Make snapshots file name SNAPSFileName = Path.GetFileNameWithoutExtension(fileName); // Initialzie MEMInitialize(header); TVFormatSetting = tvsetting; // Hard reset hardReset(); // Run emu EmulationPaused = true; EmulationON = true; // Let's go ! if (makeThread) { EmulationThread = new Thread(new ThreadStart(EMUClock)); EmulationThread.Start(); } // Done ! INITIALIZED = true; if (EMUInitialized != null) { EMUInitialized(null, new EventArgs()); } } else { throw new RomNotValidException(); } break; } } }
public void CreateNew(string fileName, TVSystemSetting tvsetting, bool makeThread) { switch (Path.GetExtension(fileName).ToLower()) { case ".nes": { INes header = new INes(); header.Load(fileName, true); if (header.IsValid) { initialized = false; GAMEFILE = fileName; this.legacyNesEmu.CheckGameVSUnisystem(header.SHA1, header.IsVSUnisystem, header.MapperNumber); // Make SRAM file name SRAMFileName = Path.Combine(SRAMFolder, Path.GetFileNameWithoutExtension(fileName) + ".srm"); this.emulationState.STATESlot = 0; this.emulationState.UpdateStateSlot(this.emulationState.STATESlot); // Make snapshots file name SNAPSFileName = Path.GetFileNameWithoutExtension(fileName); // Initialzie this.memory.MEMInitialize(header); TVFormatSetting = tvsetting; // Hard reset HardReset(); // Run emu this.emulationState.EmulationPaused = true; this.emulationState.EmulationON = true; // Let's go ! if (makeThread) { EmulationThread = new Thread(new ThreadStart(GameLoop)); EmulationThread.Start(); } // Done ! initialized = true; } else { throw new RomNotValidException(); } break; } } }
/// <summary> /// Create new emulation engine /// </summary> /// <param name="fileName">The rom complete path. Not compressed</param> /// <param name="tvsetting">The tv system setting to use</param> /// <param name="makeThread">Indicates if the emulation engine should make an internal thread and run through it. Otherwise you should make a thread and use EMUClock to run the loop.</param> public static void CreateNew(string fileName, TVSystemSetting tvsetting, bool makeThread) { switch (Path.GetExtension(fileName).ToLower()) { case ".nes": { INes header = new INes(); header.Load(fileName, true); if (header.IsValid) { INITIALIZED = false; GAMEFILE = fileName; CheckGameVSUnisystem(header.SHA1, header.IsVSUnisystem, header.MapperNumber); // Make SRAM file name SRAMFileName = Path.Combine(SRAMFolder, Path.GetFileNameWithoutExtension(fileName) + ".srm"); STATESlot = 0; UpdateStateSlot(STATESlot); // Make snapshots file name SNAPSFileName = Path.GetFileNameWithoutExtension(fileName); // Initialzie MEMInitialize(header); TVFormatSetting = tvsetting; // Hard reset hardReset(); // Run emu EmulationPaused = true; EmulationON = true; // Let's go ! if (makeThread) { EmulationThread = new Thread(new ThreadStart(EMUClock)); EmulationThread.Start(); } // Done ! INITIALIZED = true; if (EMUInitialized != null) EMUInitialized(null, new EventArgs()); } else { throw new RomNotValidException(); } break; } } }
public static void LoadRom(string fileName) { CurrentGameFile = fileName; NesEmu.EmulationPaused = true; // Make sure it's still paused ! bool is_supported_mapper = false; bool has_issues = false; string issues = ""; if (NesEmu.CheckRom(fileName, out is_supported_mapper, out has_issues, out issues)) { if (!is_supported_mapper) { Console.WriteLine("** MAPPER IS NOT SUPPORTED !!"); Console.WriteLine("** RUNNING WITH DEFAULT MAPPER CONFIGURATION"); } if (has_issues) { Console.WriteLine("** " + issues); } NesEmu.EmulationON = false; NesEmu.EmulationPaused = true; // Kill the original thread if (NesEmu.EmulationThread != null) { if (NesEmu.EmulationThread.IsAlive) { NesEmu.EmulationThread.Abort(); } } // Create new TVSystemSetting sett = TVSystemSetting.AUTO; switch (Settings.TvSystemSetting.ToLower()) { case "auto": sett = TVSystemSetting.AUTO; break; case "ntsc": sett = TVSystemSetting.NTSC; break; case "palb": sett = TVSystemSetting.PALB; break; case "dendy": sett = TVSystemSetting.DENDY; break; } NesEmu.CreateNew(fileName, sett, true); VIDEO.SetWindowTitle(); InitializePalette();// Confirm palette selection ! NesEmu.EmulationPaused = true; } else { Console.WriteLine(@"** MY NES CAN'T RUN THIS GAME !!"); if (!is_supported_mapper) { Console.WriteLine("** MAPPER IS NOT SUPPORTED !!"); Console.WriteLine("** RUNNING WITH DEFAULT MAPPER CONFIGURATION"); } if (has_issues) { Console.WriteLine("** " + issues); } if (NesEmu.EmulationON) { NesEmu.EmulationPaused = false; } } }