protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController controller, bool render, bool rendersound) { var prevDiskSignal = controller.IsPressed("Previous Disk"); var nextDiskSignal = controller.IsPressed("Next Disk"); var newDisk = _activeDisk; if (prevDiskSignal && !_prevDiskSignal) { newDisk--; } if (nextDiskSignal && !_nextDiskSignal) { newDisk++; } _prevDiskSignal = prevDiskSignal; _nextDiskSignal = nextDiskSignal; if (newDisk < -1) { newDisk = -1; } if (newDisk >= _disks.Length) { newDisk = _disks.Length - 1; } if (newDisk != _activeDisk) { _core.SetDisk(newDisk == -1 ? 0 : newDisk, newDisk == -1); _activeDisk = newDisk; } // if not reset, the core will maintain its own deterministic increasing time each frame if (!DeterministicEmulation) { _core.SetRtc((long)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, _syncSettings.Language); } DriveLightOn = false; if (controller.IsPressed("Power")) { _core.HardReset(); } _core.SetControllerData(_controllerDeck.Poll(controller)); SetVideoParameters(); return(new LibSaturnus.FrameInfo { ResetPushed = controller.IsPressed("Reset") ? 1 : 0 }); }
public Saturnus(CoreComm comm, IEnumerable <Disc> disks, bool deterministic, Settings settings, SyncSettings syncSettings) : base(comm, new Configuration { MaxSamples = 8192, DefaultWidth = 320, DefaultHeight = 240, MaxWidth = 1024, MaxHeight = 1024, SystemId = "SAT" }) { settings = settings ?? new Settings(); syncSettings = syncSettings ?? new SyncSettings(); _disks = disks.ToArray(); _diskReaders = disks.Select(d => new DiscSectorReader(d) { Policy = _diskPolicy }).ToArray(); if (!CheckDisks(_diskReaders)) { throw new InvalidOperationException("Some disks are not valid"); } InitCallbacks(); _core = PreInit <LibSaturnus>(new PeRunnerOptions { Filename = "ss.wbx", SbrkHeapSizeKB = 128, SealedHeapSizeKB = 4096, // 512KB of bios, 2MB of kof95/ultraman carts InvisibleHeapSizeKB = 8 * 1024, // 4MB of framebuffer MmapHeapSizeKB = 0, // not used? PlainHeapSizeKB = 24 * 1024, // up to 16MB of cart ram StartAddress = LibSaturnus.StartAddress, SkipCoreConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck), SkipMemoryConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck), }); SetFirmwareCallbacks(); SetCdCallbacks(); if (!_core.Init(_disks.Length, syncSettings.ExpansionCart, syncSettings.Region, syncSettings.RegionAutodetect)) { throw new InvalidOperationException("Core rejected the disks!"); } ClearAllCallbacks(); _controllerDeck = new SaturnusControllerDeck(new[] { syncSettings.Port1Multitap, syncSettings.Port2Multitap }, new[] { syncSettings.Port1, syncSettings.Port2, syncSettings.Port3, syncSettings.Port4, syncSettings.Port5, syncSettings.Port6, syncSettings.Port7, syncSettings.Port8, syncSettings.Port9, syncSettings.Port10, syncSettings.Port11, syncSettings.Port12 }, _core); ControllerDefinition = _controllerDeck.Definition; ControllerDefinition.Name = "Saturn Controller"; ControllerDefinition.BoolButtons.AddRange(new[] { "Power", "Reset", "Previous Disk", "Next Disk" }); _core.SetRtc((long)syncSettings.InitialTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, syncSettings.Language); PostInit(); SetCdCallbacks(); _core.SetDisk(0, false); PutSettings(settings); _syncSettings = syncSettings; DeterministicEmulation = deterministic || !_syncSettings.UseRealTime; }