internal FanCutCommon(FormMain formMain, string gameName, string assetsPath, List<TimelineSave> timelineSaves, string sha1Hash) { _formMain = formMain; _gameName = gameName; _assetsPath = assetsPath; _timelineSaves = timelineSaves; NesEmu.EMUHardReseted += onCoreHardReseted; layoutFormMain(); OpenFileDialog romOpenFileDialog = new OpenFileDialog(); romOpenFileDialog.Title = string.Format("Open {0} ROM", gameName); romOpenFileDialog.Filter = "NES ROM (*.nes) | *.nes"; bool isROMSelected = false; while (!isROMSelected) { if (romOpenFileDialog.ShowDialog(formMain) == DialogResult.OK) { StringBuilder romHashString; using (FileStream romFileStream = new FileStream(romOpenFileDialog.FileName, FileMode.Open)) { using (BufferedStream romBufferedStream = new BufferedStream(romFileStream)) { using (SHA1Managed romSHA1 = new SHA1Managed()) { byte[] romHash = romSHA1.ComputeHash(romBufferedStream); romHashString = new StringBuilder(romHash.Length * 2); foreach (byte b in romHash) romHashString.AppendFormat("{0:X2}", b); } } } if (romHashString.ToString() == sha1Hash) { isROMSelected = true; formMain.OpenRom(romOpenFileDialog.FileName); } else MessageBox.Show("You must load the proper ROM for this FanCut.", "ROM Mismatch"); } else { isROMSelected = true; Application.Exit(); } } }
static void Main(string[] Args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Add listeners System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.ConsoleTraceListener()); // Detect languages DetectSupportedLanguages(); // Load settings Settings = new Properties.Settings(); Settings.Reload(); // First run ? if (!Program.Settings.FirstRun) { FixFolders(); FixPalette(); ControlMappingSettings.BuildDefaultControlSettings(); try { FormFirstRun frm = new FormFirstRun(); frm.ShowDialog(); Program.Settings.FirstRun = true; } catch (Exception ex) { MMB.ManagedMessageBox.ShowErrorMessage(ex.Message); } } // Set language Language = Settings.Language; ResourceManager = new ResourceManager("MyNes.LanguageResources.Resource", Assembly.GetExecutingAssembly()); // Start-up nes emulation engine MyNes.Core.NesEmu.WarmUp(); // Create the main form FormMain = new FormMain(); // Do command lines DoCommandLines(Args); // Run ! Application.Run(FormMain); }
internal FanCutSuperMarioBros(FormMain formMain) { _levels = new List<SuperMarioBrosLevel>(); _levels.Add(new SuperMarioBrosLevel() { Name = "World 1-1", WorldNumber = 0, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x25, CheckpointScreenNumber = 5 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 1-2", WorldNumber = 0, LevelDisplayNumber = 1, LevelNumber = 2, AreaLoadedValue = 0x40, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 1-3", WorldNumber = 0, LevelDisplayNumber = 2, LevelNumber = 3, AreaLoadedValue = 0x26, CheckpointScreenNumber = 4 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 1-4", WorldNumber = 0, LevelDisplayNumber = 3, LevelNumber = 4, AreaLoadedValue = 0x60, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 2-1", WorldNumber = 1, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x28, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 2-2", WorldNumber = 1, LevelDisplayNumber = 1, LevelNumber = 2, AreaLoadedValue = 0x01, CheckpointScreenNumber = 5 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 2-3", WorldNumber = 1, LevelDisplayNumber = 2, LevelNumber = 3, AreaLoadedValue = 0x27, CheckpointScreenNumber = 7 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 2-4", WorldNumber = 1, LevelDisplayNumber = 3, LevelNumber = 4, AreaLoadedValue = 0x62, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 3-1", WorldNumber = 2, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x24, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 3-2", WorldNumber = 2, LevelDisplayNumber = 1, LevelNumber = 1, AreaLoadedValue = 0x35, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 3-3", WorldNumber = 2, LevelDisplayNumber = 2, LevelNumber = 2, AreaLoadedValue = 0x20, CheckpointScreenNumber = 4 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 3-4", WorldNumber = 2, LevelDisplayNumber = 3, LevelNumber = 3, AreaLoadedValue = 0x63, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 4-1", WorldNumber = 3, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x22, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 4-2", WorldNumber = 3, LevelDisplayNumber = 1, LevelNumber = 2, AreaLoadedValue = 0x41, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 4-3", WorldNumber = 3, LevelDisplayNumber = 2, LevelNumber = 3, AreaLoadedValue = 0x2C, CheckpointScreenNumber = 4 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 4-4", WorldNumber = 3, LevelDisplayNumber = 3, LevelNumber = 4, AreaLoadedValue = 0x61, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 5-1", WorldNumber = 4, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x2A, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 5-2", WorldNumber = 4, LevelDisplayNumber = 1, LevelNumber = 1, AreaLoadedValue = 0x31, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 5-3", WorldNumber = 4, LevelDisplayNumber = 2, LevelNumber = 2, AreaLoadedValue = 0x26, CheckpointScreenNumber = 4 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 5-4", WorldNumber = 4, LevelDisplayNumber = 3, LevelNumber = 3, AreaLoadedValue = 0x62, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 6-1", WorldNumber = 5, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x2E, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 6-2", WorldNumber = 5, LevelDisplayNumber = 1, LevelNumber = 1, AreaLoadedValue = 0x23, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 6-3", WorldNumber = 5, LevelDisplayNumber = 2, LevelNumber = 2, AreaLoadedValue = 0x2D, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 6-4", WorldNumber = 5, LevelDisplayNumber = 3, LevelNumber = 3, AreaLoadedValue = 0x60, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 7-1", WorldNumber = 6, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x33, CheckpointScreenNumber = 6 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 7-2", WorldNumber = 6, LevelDisplayNumber = 1, LevelNumber = 2, AreaLoadedValue = 0x01, CheckpointScreenNumber = 5 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 7-3", WorldNumber = 6, LevelDisplayNumber = 2, LevelNumber = 3, AreaLoadedValue = 0x27, CheckpointScreenNumber = 7 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 7-4", WorldNumber = 6, LevelDisplayNumber = 3, LevelNumber = 4, AreaLoadedValue = 0x64, CheckpointScreenNumber = 0 }); _levels.Add(new SuperMarioBrosLevel() { Name = "World 8-1", WorldNumber = 7, LevelDisplayNumber = 0, LevelNumber = 0, AreaLoadedValue = 0x30, CheckpointScreenNumber = 12 }); // no checkpoint in the actual game _levels.Add(new SuperMarioBrosLevel() { Name = "World 8-2", WorldNumber = 7, LevelDisplayNumber = 1, LevelNumber = 1, AreaLoadedValue = 0x32, CheckpointScreenNumber = 6 }); // no checkpoint in the actual game _levels.Add(new SuperMarioBrosLevel() { Name = "World 8-3", WorldNumber = 7, LevelDisplayNumber = 2, LevelNumber = 2, AreaLoadedValue = 0x21, CheckpointScreenNumber = 6 }); // no checkpoint in the actual game _levels.Add(new SuperMarioBrosLevel() { Name = "World 8-4", WorldNumber = 7, LevelDisplayNumber = 3, LevelNumber = 3, AreaLoadedValue = 0x65, CheckpointScreenNumber = 0 }); // this will override all the current saves, only do this when regenerating saves //upateTimelineSaves(); _timelineSaves = new List<TimelineSave>(); int index = 0; foreach (SuperMarioBrosLevel level in _levels) { TimelineSave timelineSave = new TimelineSave() { ID = index, Name = level.Name, Filename = level.Name + TIMELINE_SAVE_FILE_EXTENSION, ThumbnailFilename = level.Name + TIMELINE_SAVE_THUMBNAIL_FILE_EXTENSION }; _timelineSaves.Add(timelineSave); index++; if (level.CheckpointScreenNumber != 0) { timelineSave = new TimelineSave() { ID = index, Name = level.Name + CHECKPOINT_FILENAME_SUFFIX, Filename = level.Name + CHECKPOINT_FILENAME_SUFFIX + TIMELINE_SAVE_FILE_EXTENSION, ThumbnailFilename = level.Name + CHECKPOINT_FILENAME_SUFFIX + TIMELINE_SAVE_THUMBNAIL_FILE_EXTENSION }; _timelineSaves.Add(timelineSave); index++; } } NesEmu.ChangeTriggers = new List<ushort>(); NesEmu.ChangeTriggers.Add(PLAYER_STATE_ADDRESS); NesEmu.ChangeTriggers.Add(WORLD_NUMBER_ADDRESS); NesEmu.ChangeTriggers.Add(LEVEL_NUMBER_ADDRESS); NesEmu.ChangeTriggerHandler = onMemoryChanging; _fanCutCommon = new FanCutCommon(formMain, GAME_NAME, ASSETS_PATH, _timelineSaves, SHA1_HASH); }