public static string GetScreenshotFilePath(IGameSource gameSource) { string gameName = null; if (gameSource is BiosOnlyGameSource || gameSource == null) { gameName = "(No Game)"; } else { gameName = gameSource.GetGameName(); } string currentTime = DateTime.Now.ToString("u"); currentTime = currentTime.Replace("Z", ""); currentTime = currentTime.Replace("-", "."); currentTime = currentTime.Replace(":", "."); currentTime = currentTime.Replace(" ", "_"); string fileName = string.Format("{0} - {1}", currentTime, GetFriendlyGameName(gameName)); string screenshotFolder = GetScreenshotFilePath(); string fullFilePath = Path.Combine(screenshotFolder, fileName); return(fullFilePath); }
public MainWindow() { InitializeComponent(); foreach (var device in CaptureDeviceList.Instance) { var deviceMenuItem = new MenuItem { Header = device.Description, Tag = device }; if (SelectedDevice != null) { deviceMenuItem.IsChecked = device.Name == SelectedDevice.Name; } deviceMenuItem.Click += DeviceMenuItem_Click; _miDevices.Items.Add(deviceMenuItem); } var sources = new IGameSource[] { new Albion.GameSource(), new Tera.GameSource() }; foreach (var gameSource in sources.OrderByDescending(gs => gs.Name)) { var menuItem = new MenuItem { Header = gameSource.Name, IsCheckable = true, DataContext = gameSource }; menuItem.Checked += OnConnect; _miGame.Items.Insert(0, menuItem); } TuneControls(); }
public MainWindow(IGameSource gameSource, IKeyBinds keyBinds) { InitializeComponent(); SetStatus(false); isFocused = false; gameSource.Load(); gamesComboBox.ItemsSource = gameSource.GameList; this.nativeMethods = new NativeMethods(); this.keyboardListener = new KeyboardListener(); keyboardListener.KeyDown += OnKeyPress; this.keyBinds = keyBinds; nativeMethods.WindowChanged += NativeMethods_WindowChanged; }
public static string GetSaveStateFileName(IGameSource gameSource, int saveStateSlot) { ////////////// // Get the filename we'll use for this game and save slot. string preferredFileName = null; string fileNamePrefix = null; if (gameSource is BiosOnlyGameSource || gameSource == null) { // TODO: Come up with separate "buckets" for different BIOS's? // Currently, any BIOS will save and load from the same block of save states. fileNamePrefix = "No_Game_Loaded"; } else { string friendlyGameName = SaveHelper.GetFriendlyGameName(gameSource.GetGameName()); if (friendlyGameName != null) { // If the "preferred" save filename exists, go ahead and use it. string preferredFileNamePrefix = string.Format("{0}_{1}", gameSource.GetGameId(), friendlyGameName); preferredFileName = SaveHelper.GetFullSaveStateFilePath(preferredFileNamePrefix, saveStateSlot); if (File.Exists(preferredFileName)) { return(preferredFileName); } } // Otherwise, we'll try to find the closest match by the game Id. // NOTE: This is because a game may have previously saved under a different "friendly name" somewhere in the filename. // This makes the code capable of dealing with changes to the "friendly names" inside 4DO. fileNamePrefix = gameSource.GetGameId(); } ////////////// // We didn't find an obvious pick, so let's try finding one by gameId. // Come up with a search pattern. string fullSearchFilePath = SaveHelper.GetFullSaveStateFilePath(fileNamePrefix + "*", saveStateSlot); string searchDirectory = Path.GetDirectoryName(fullSearchFilePath); string searchFilePattern = Path.GetFileName(fullSearchFilePath); string[] candidateFiles = null; // Find candidates! if (Directory.Exists(searchDirectory)) { candidateFiles = Directory.GetFiles(searchDirectory, searchFilePattern); } ////////////// // Return the first match if there is one. if (candidateFiles != null && candidateFiles.Length > 0) { return(candidateFiles[0]); } // If we have a preferred file name (when the game has a name), use that as the expected prefix. if (preferredFileName != null) { return(preferredFileName); } // Well crap. Just return the most basic filename we can, using gameId as the prefix. return(SaveHelper.GetFullSaveStateFilePath(fileNamePrefix, saveStateSlot)); }
public DiscFileReader(IGameSource gameSource) { _gameSource = gameSource; }
public Database(IGameSource gameSource) { GameSource = gameSource; Thumbnails = new List <IGameMetaInfo>(GameSource.GetMetaInfoOfAllGames()); RandomNumberGenerator = new Random(); }
public void Start(string biosRom1FileName, string biosRom2FileName, IGameSource gameSource, string nvramFileName) { int fixMode = 0; /////////// // If they haven't initialized us properly, complain! if (!this.maxLagTicks.HasValue) { throw new InvalidOperationException("Audio buffer not set!"); } if (!this.cpuClockHertz.HasValue) { throw new InvalidOperationException("CPU Clock speed not set!"); } if (!this.renderHighResolution.HasValue) { throw new InvalidOperationException("High resolution setting not set!"); } // Are we already started? if (this.workerThread != null) { return; } this.GameSource = gameSource; ////////////// // Attempt to load Bios #1. try { this.biosRom1Copy = System.IO.File.ReadAllBytes(biosRom1FileName); } catch { throw new BadBiosRom1Exception(); } // Also get outta here if it's not the right length. if (this.biosRom1Copy.Length != ROM1_SIZE) { throw new BadBiosRom1Exception(); } if (this.biosRom1Copy[28] == 234) { FreeDOCore.SetAnvilFix(30); } //bios anvil ////////////// // Attempt to load Bios #2. // If we don't load Bios #2, we'll just use all zeroes. this.biosRom2Copy = new byte[ROM2_SIZE]; // Allocate full size to get all 0's // Load from file, if a file was chosen byte[] biosRom2Bytes = null; if (!string.IsNullOrWhiteSpace(biosRom2FileName)) { try { biosRom2Bytes = System.IO.File.ReadAllBytes(biosRom2FileName); } catch { throw new BadBiosRom2Exception(); } // Bios #2 is allowed to be less than or equal to the right size. // The only example file I know of is less than (912KB) the actual size on the hardware (1MB). if (biosRom2Bytes.Length > ROM2_SIZE || biosRom2Bytes.Length == 0) { throw new BadBiosRom2Exception(); } // Copy to the member variable. biosRom2Bytes.CopyTo(this.biosRom2Copy, 0); } ////////////// // Load a copy of the nvram. try { // If we previously had a game open, and they have now loaded // a new game, we want to make sure the game that was previously // open does not accidentally save. lock (nvramCopySemaphore) { // Note that we copy to the OLD nvram file name, just in case. if (this.nvramTimer.Enabled == true) { Memory.WriteMemoryDump(this.nvramFileName, this.nvramCopyPtr, NVRAM_SIZE); } this.nvramTimer.Enabled = false; // Read the new NVRAM into memory. Memory.ReadMemoryDump(this.nvramCopy, nvramFileName, NVRAM_SIZE); } } catch { throw new BadNvramFileException(); } // Freak out if the nvram isn't the right size. if (this.nvramCopy.Length != NVRAM_SIZE) { throw new BadNvramFileException(); } // Remember the file name. this.nvramFileName = nvramFileName; ////////////// // Attempt to start up the game source (it is allowed to throw errors). try { this.GameSource.Open(); } catch { throw new BadGameRomException(); } FreeDOCore.SetFixMode(fixMode); ///////////////// // Initialize the core FreeDOCore.Initialize(); //////////////// // Set fix mode GameRecord record = GameRegistrar.GetGameRecordById(this.GameSource.GetGameId()); if (record != null) { if ( record.Id == "F3AF1B13" || // Crash 'n Burn (JP) record.Id == "217344B0" // Crash 'n Burn (US) ) { fixMode = fixMode | (int)FixMode.FIX_BIT_TIMING_1; } if (record.Id == "DBB419FA" || // Street Figthter 2, for intro sync record.Id == "07C32F10" ||// Street Figthter 2, for intro sync record.Id == "5282889F" ||// Street Figthter 2, for intro sync record.Id == "7340307E" // Street Figthter 2, for intro sync ) { fixMode = fixMode | (int)FixMode.FIX_BIT_TIMING_2; } if (record.Id == "CB8EE795" // Dinopark Tycoon ) { fixMode = fixMode | (int)FixMode.FIX_BIT_TIMING_3; } if (record.Id == "1A370EBA" || // Microcosm record.Id == "B35C911D"// Microcosm ) { fixMode = fixMode | (int)FixMode.FIX_BIT_TIMING_5; } if (record.Id == "0511D3D2" || // Alone in the Dark record.Id == "9F7D72BC" ||// Alone in the Dark record.Id == "E843C635"// Alone in the Dark ) { fixMode = fixMode | (int)FixMode.FIX_BIT_TIMING_6; } if (record.Id == "2AABA5B9" || // Samurai Shodown (EU-US) record.Id == "BF61BB32" // Samurai Shodown (JP) ) { fixMode = fixMode | (int)FixMode.FIX_BIT_GRAPHICS_STEP_Y; } } FreeDOCore.SetFixMode(fixMode); ///////////////// // Start the core thread this.InternalResume(false); }