// TODO: This doesn't really belong here, but not sure where to put it public static void PopulateWithDefaultHeaderValues( this IMovie movie, IEmulator emulator, IGameInfo game, FirmwareManager firmwareManager, string author) { movie.Author = author; movie.EmulatorVersion = VersionInfo.GetEmuVersion(); movie.OriginalEmulatorVersion = VersionInfo.GetEmuVersion(); movie.SystemID = emulator.SystemId; var settable = new SettingsAdapter(emulator); if (settable.HasSyncSettings) { movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings()); } if (game.IsNullInstance()) { movie.GameName = "NULL"; } else { movie.GameName = game.FilesystemSafeName(); movie.Hash = game.Hash; if (game.FirmwareHash != null) { movie.FirmwareHash = game.FirmwareHash; } } if (emulator.HasBoardInfo()) { movie.BoardName = emulator.AsBoardInfo().BoardName; } if (emulator.HasRegions()) { var region = emulator.AsRegionable().Region; if (region == Emulation.Common.DisplayType.PAL) { movie.HeaderEntries.Add(HeaderKeys.Pal, "1"); } } if (firmwareManager.RecentlyServed.Any()) { foreach (var firmware in firmwareManager.RecentlyServed) { var key = $"{firmware.SystemId}_Firmware_{firmware.FirmwareId}"; if (!movie.HeaderEntries.ContainsKey(key)) { movie.HeaderEntries.Add(key, firmware.Hash); } } } if (emulator is GBHawk gbHawk && gbHawk.IsCGBMode()) { movie.HeaderEntries.Add("IsCGBMode", "1"); } if (emulator is SubGBHawk subgbHawk) { if (subgbHawk._GBCore.IsCGBMode()) { movie.HeaderEntries.Add("IsCGBMode", "1"); } movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0"); } if (emulator is Gameboy gb) { if (gb.IsCGBMode()) { movie.HeaderEntries.Add("IsCGBMode", "1"); } movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0"); } if (emulator is SMS sms) { if (sms.IsSG1000) { movie.HeaderEntries.Add("IsSGMode", "1"); } if (sms.IsGameGear) { movie.HeaderEntries.Add("IsGGMode", "1"); } } if (emulator is GPGX gpgx && gpgx.IsMegaCD) { movie.HeaderEntries.Add("IsSegaCDMode", "1"); } if (emulator is PicoDrive pico && pico.Is32XActive) { movie.HeaderEntries.Add("Is32X", "1"); } if (emulator is SubNESHawk) { movie.HeaderEntries.Add(HeaderKeys.VBlankCount, "0"); } movie.Core = ((CoreAttribute)Attribute .GetCustomAttribute(emulator.GetType(), typeof(CoreAttribute))) .CoreName; }
private void LoadOne(string f) { _current = new Result { Filename = f }; bool result; try { result = _ldr.LoadRom(f, _comm, null); } catch (Exception e) { _current.Status = Result.EStatus.ExceptOnLoad; _current.Messages.Add(e.ToString()); _results.Add(_current); _current = null; return; } _current.Fullname = _ldr.CanonicalFullPath; if (_current.Status == Result.EStatus.ErrorOnLoad) { _results.Add(_current); _current = null; return; } if (result == false) { _current.Status = Result.EStatus.FalseOnLoad; _results.Add(_current); _current = null; return; } using (IEmulator emu = _ldr.LoadedEmulator) { _current.Game = _ldr.Game; _current.CoreType = emu.GetType(); var controller = new Controller(emu.ControllerDefinition); _current.BoardName = emu.HasBoardInfo() ? emu.AsBoardInfo().BoardName : null; _current.Frames = 0; _current.LaggedFrames = 0; for (int i = 0; i < _numFrames; i++) { try { emu.FrameAdvance(controller, true); // some cores really really really like it if you drain their audio every frame if (emu.HasSoundProvider()) { emu.AsSoundProvider().GetSamplesSync(out _, out _); } _current.Frames++; if (emu.CanPollInput() && emu.AsInputPollable().IsLagFrame) { _current.LaggedFrames++; } } catch (Exception e) { _current.Messages.Add(e.ToString()); _current.Status = Result.EStatus.ExceptOnAdv; _results.Add(_current); _current = null; return; } } } _current.Status = Result.EStatus.Success; _results.Add(_current); _current = null; }
// TODO: This doesn't really belong here, but not sure where to put it public static void PopulateWithDefaultHeaderValues( this IMovie movie, IEmulator emulator, ISettingsAdapter settable, IGameInfo game, FirmwareManager firmwareManager, string author) { movie.Author = author; movie.EmulatorVersion = VersionInfo.GetEmuVersion(); movie.OriginalEmulatorVersion = VersionInfo.GetEmuVersion(); movie.SystemID = emulator.SystemId; if (settable.HasSyncSettings) { movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings()); } if (game.IsNullInstance()) { movie.GameName = "NULL"; } else { movie.GameName = game.FilesystemSafeName(); movie.Hash = game.Hash; if (game.FirmwareHash != null) { movie.FirmwareHash = game.FirmwareHash; } } if (emulator.HasBoardInfo()) { movie.BoardName = emulator.AsBoardInfo().BoardName; } if (emulator.HasRegions()) { var region = emulator.AsRegionable().Region; if (region == DisplayType.PAL) { movie.HeaderEntries.Add(HeaderKeys.Pal, "1"); } } if (firmwareManager.RecentlyServed.Count != 0) { foreach (var firmware in firmwareManager.RecentlyServed) { var key = firmware.ID.MovieHeaderKey; if (!movie.HeaderEntries.ContainsKey(key)) { movie.HeaderEntries.Add(key, firmware.Hash); } } } if (emulator is NDS nds && nds.IsDSi) { movie.HeaderEntries.Add("IsDSi", "1"); if (nds.IsDSiWare) { movie.HeaderEntries.Add("IsDSiWare", "1"); } } if ((emulator is NES nes && nes.IsVS) || (emulator is SubNESHawk subnes && subnes.IsVs)) { movie.HeaderEntries.Add("IsVS", "1"); } if (emulator is IGameboyCommon gb) { if (gb.IsCGBMode()) { movie.HeaderEntries.Add(gb.IsCGBDMGMode() ? "IsCGBDMGMode" : "IsCGBMode", "1"); } } if (emulator is SMS sms) { if (sms.IsSG1000) { movie.HeaderEntries.Add("IsSGMode", "1"); } if (sms.IsGameGear) { movie.HeaderEntries.Add("IsGGMode", "1"); } } if (emulator is GPGX gpgx && gpgx.IsMegaCD) { movie.HeaderEntries.Add("IsSegaCDMode", "1"); } if (emulator is PicoDrive pico && pico.Is32XActive) { movie.HeaderEntries.Add("Is32X", "1"); } if (emulator is ICycleTiming) { movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0"); movie.HeaderEntries.Add(HeaderKeys.ClockRate, "0"); } movie.Core = emulator.Attributes().CoreName; }
void LoadOne(string f) { current = new Result { Filename = f }; bool result = false; try { result = ldr.LoadRom(f, Comm); } catch (Exception e) { current.Status = Result.EStatus.ExceptOnLoad; current.Messages.Add(e.ToString()); Results.Add(current); current = null; return; } current.Fullname = ldr.CanonicalFullPath; if (current.Status == Result.EStatus.ErrorOnLoad) { Results.Add(current); current = null; return; } if (result == false) { current.Status = Result.EStatus.FalseOnLoad; Results.Add(current); current = null; return; } using (IEmulator emu = ldr.LoadedEmulator) { current.GI = ldr.Game; current.CoreType = emu.GetType(); var controller = new Controller(emu.ControllerDefinition); current.BoardName = emu.HasBoardInfo() ? emu.AsBoardInfo().BoardName : null; // hack if (emu is Emulation.Cores.Nintendo.GBA.VBANext) { current.BoardName = (emu as Emulation.Cores.Nintendo.GBA.VBANext).GameCode; } current.Frames = 0; current.LaggedFrames = 0; for (int i = 0; i < numframes; i++) { try { int nsamp; short[] samp; emu.FrameAdvance(controller, true, true); // some cores really really really like it if you drain their audio every frame if (emu.HasSoundProvider()) { emu.AsSoundProvider().GetSamplesSync(out samp, out nsamp); } current.Frames++; if (emu.CanPollInput() && emu.AsInputPollable().IsLagFrame) { current.LaggedFrames++; } } catch (Exception e) { current.Messages.Add(e.ToString()); current.Status = Result.EStatus.ExceptOnAdv; Results.Add(current); current = null; return; } } } current.Status = Result.EStatus.Success; Results.Add(current); current = null; return; }