public NES(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; byte[] fdsbios = comm.CoreFileProvider.GetFirmware("NES", "Bios_FDS", false); if (fdsbios != null && fdsbios.Length == 40976) { comm.ShowMessage("Your FDS BIOS is a bad dump. BizHawk will attempt to use it, but no guarantees! You should find a new one."); var tmp = new byte[8192]; Buffer.BlockCopy(fdsbios, 16 + 8192 * 3, tmp, 0, 8192); fdsbios = tmp; } SyncSettings = (NESSyncSettings)syncSettings ?? new NESSyncSettings(); ControllerSettings = SyncSettings.Controls; CoreComm = comm; MemoryCallbacks = new MemoryCallbackSystem(); BootGodDB.Initialize(); videoProvider = new MyVideoProvider(this); Init(game, rom, fdsbios); if (Board is FDS) { DriveLightEnabled = true; (Board as FDS).SetDriveLightCallback((val) => DriveLightOn = val); // bit of a hack: we don't have a private gamedb for FDS, but the frontend // expects this to be set. RomStatus = game.Status; } PutSettings((NESSettings)settings ?? new NESSettings()); // we need to put this here because the line directly above will overwrite palette intialization anywhere else // TODO: What if settings are later loaded? if (_isVS) { PickVSPalette(cart); } ser.Register <IDisassemblable>(cpu); Tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(Tracer); ser.Register <IVideoProvider>(videoProvider); ser.Register <ISoundProvider>(magicSoundProvider); if (Board is BANDAI_FCG_1) { var reader = (Board as BANDAI_FCG_1).reader; // not all BANDAI FCG 1 boards have a barcode reader if (reader != null) { ser.Register <DatachBarcode>(reader); } } }
public TI83(CoreComm comm, GameInfo game, byte[] rom, object settings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; PutSettings((TI83Settings)settings ?? new TI83Settings()); CoreComm = comm; _cpu.FetchMemory = ReadMemory; _cpu.ReadMemory = ReadMemory; _cpu.WriteMemory = WriteMemory; _cpu.ReadHardware = ReadHardware; _cpu.WriteHardware = WriteHardware; _cpu.IRQCallback = IRQCallback; _cpu.NMICallback = NMICallback; _cpu.MemoryCallbacks = MemoryCallbacks; _rom = rom; LinkPort = new TI83LinkPort(this); HardReset(); SetupMemoryDomains(); _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ser.Register <IDisassemblable>(_cpu); }
public TI83(CoreLoadParameters <TI83Settings, object> lp) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; PutSettings(lp.Settings ?? new TI83Settings()); _cpu.FetchMemory = ReadMemory; _cpu.ReadMemory = ReadMemory; _cpu.WriteMemory = WriteMemory; _cpu.ReadHardware = ReadHardware; _cpu.WriteHardware = WriteHardware; _cpu.IRQCallback = IRQCallback; _cpu.NMICallback = NMICallback; _cpu.MemoryCallbacks = MemoryCallbacks; _rom = lp.Comm.CoreFileProvider.GetFirmwareOrThrow(new("TI83", "Rom")); LinkPort = new TI83LinkPort(this); HardReset(); SetupMemoryDomains(); _tracer = new TraceBuffer(_cpu.TraceHeader); ser.Register <ITraceable>(_tracer); ser.Register <IDisassemblable>(_cpu); ser.Register <IStatable>(new StateSerializer(SyncState)); LinkPort.SendFileToCalc(new MemoryStream(lp.Roms[0].RomData, false), false); }
public SubNESHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); subnesSettings = (NES.NES.NESSettings)settings ?? new NES.NES.NESSettings(); subnesSyncSettings = (NES.NES.NESSyncSettings)syncSettings ?? new NES.NES.NESSyncSettings(); CoreComm = comm; subnes = new NES.NES(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, game, rom, subnesSettings, subnesSyncSettings); ser.Register <IVideoProvider>(subnes.videoProvider); ser.Register <ISoundProvider>(subnes); _tracer = new TraceBuffer { Header = "6502: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP), flags (NVTBDIZCR), CPU Cycle, PPU Cycle" }; ser.Register <ITraceable>(_tracer); ServiceProvider = ser; (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(subnes._memoryDomains); subnes.using_reset_timing = true; HardReset(); current_cycle = 0; subnes.cpu.ext_ppu_cycle = current_cycle; VBL_CNT = 0; }
public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; Tracer = new TraceBuffer(); MemoryCallbacks = new MemoryCallbackSystem(); InputCallbacks = new InputCallbackSystem(); Ram = new byte[128]; CoreComm = comm; Settings = (A2600Settings)settings ?? new A2600Settings(); SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings(); Rom = rom; _game = game; if (!game.GetOptionsDict().ContainsKey("m")) { game.AddOption("m", DetectMapper(rom)); } Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]); RebootCore(); SetupMemoryDomains(); ser.Register <IDisassemblable>(Cpu); ser.Register <ITraceable>(Tracer); ser.Register <IVideoProvider>(_tia); }
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; byte[] bios = comm.CoreFileProvider.GetFirmware("GBA", "Bios", false); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new InvalidOperationException("A BIOS is required for deterministic recordings!"); } if (!DeterministicEmulation && bios != null && !_syncSettings.RTCUseRealTime && !_syncSettings.SkipBios) { // in these situations, this core is deterministic even though it wasn't asked to be DeterministicEmulation = true; } if (bios != null && bios.Length != 16384) { throw new InvalidOperationException("BIOS must be exactly 16384 bytes!"); } core = LibmGBA.BizCreate(bios); if (core == IntPtr.Zero) { throw new InvalidOperationException("BizCreate() returned NULL! Bad BIOS?"); } try { if (!LibmGBA.BizLoad(core, file, file.Length)) { throw new InvalidOperationException("BizLoad() returned FALSE! Bad ROM?"); } if (!DeterministicEmulation && _syncSettings.SkipBios) { LibmGBA.BizSkipBios(core); } var ser = new BasicServiceProvider(this); ser.Register <IDisassemblable>(new ArmV4Disassembler()); ser.Register <IMemoryDomains>(CreateMemoryDomains(file.Length)); ServiceProvider = ser; CoreComm = comm; CoreComm.VsyncNum = 262144; CoreComm.VsyncDen = 4389; CoreComm.NominalWidth = 240; CoreComm.NominalHeight = 160; InitStates(); } catch { LibmGBA.BizDestroy(core); throw; } }
public Intellivision(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; CoreComm = comm; _rom = rom; _settings = (IntvSettings)settings ?? new IntvSettings(); _syncSettings = (IntvSyncSettings)syncSettings ?? new IntvSyncSettings(); _controllerDeck = new IntellivisionControllerDeck(_syncSettings.Port1, _syncSettings.Port2); _cart = new Intellicart(); if (_cart.Parse(_rom) == -1) { _cart = new Cartridge(); _cart.Parse(_rom); } _cpu = new CP1610 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, MemoryCallbacks = MemoryCallbacks }; _cpu.Reset(); _stic = new STIC { ReadMemory = ReadMemory, WriteMemory = WriteMemory }; _stic.Reset(); _psg = new PSG { ReadMemory = ReadMemory, WriteMemory = WriteMemory }; _psg.Reset(); ser.Register <IVideoProvider>(_stic); ser.Register <ISoundProvider>(_psg); Connect(); LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required.")); LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required.")); _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); SetupMemoryDomains(); }
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic, GameInfo game) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; var bios = comm.CoreFileProvider.GetFirmware(new("GBA", "Bios")); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new MissingFirmwareException("A BIOS is required for deterministic recordings!"); } if (!DeterministicEmulation && bios != null && !_syncSettings.RTCUseRealTime && !_syncSettings.SkipBios) { // in these situations, this core is deterministic even though it wasn't asked to be DeterministicEmulation = true; } if (bios != null && bios.Length != 16384) { throw new InvalidOperationException("BIOS must be exactly 16384 bytes!"); } var skipBios = !DeterministicEmulation && _syncSettings.SkipBios; Core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(_syncSettings), skipBios); if (Core == IntPtr.Zero) { throw new InvalidOperationException($"{nameof(LibmGBA.BizCreate)}() returned NULL! Bad BIOS? and/or ROM?"); } try { CreateMemoryDomains(file.Length); var ser = new BasicServiceProvider(this); ser.Register <IDisassemblable>(new ArmV4Disassembler()); ser.Register <IMemoryDomains>(_memoryDomains); ServiceProvider = ser; PutSettings(_settings); const string TRACE_HEADER = "ARM7: PC, machine code, mnemonic, operands, registers"; Tracer = new TraceBuffer(TRACE_HEADER); _tracecb = msg => Tracer.Put(_traceInfo(msg)); ser.Register(Tracer); MemoryCallbacks = new MGBAMemoryCallbackSystem(this); } catch { LibmGBA.BizDestroy(Core); throw; } InputCallback = new LibmGBA.InputCallback(InputCb); LibmGBA.BizSetInputCallback(Core, InputCallback); }
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic, GameInfo game) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; byte[] bios = comm.CoreFileProvider.GetFirmware("GBA", "Bios", false); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new InvalidOperationException("A BIOS is required for deterministic recordings!"); } if (!DeterministicEmulation && bios != null && !_syncSettings.RTCUseRealTime && !_syncSettings.SkipBios) { // in these situations, this core is deterministic even though it wasn't asked to be DeterministicEmulation = true; } if (bios != null && bios.Length != 16384) { throw new InvalidOperationException("BIOS must be exactly 16384 bytes!"); } var skipBios = !DeterministicEmulation && _syncSettings.SkipBios; _core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(game), skipBios); if (_core == IntPtr.Zero) { throw new InvalidOperationException($"{nameof(LibmGBA.BizCreate)}() returned NULL! Bad BIOS? and/or ROM?"); } try { CreateMemoryDomains(file.Length); var ser = new BasicServiceProvider(this); ser.Register <IDisassemblable>(new ArmV4Disassembler()); ser.Register <IMemoryDomains>(_memoryDomains); ServiceProvider = ser; CoreComm = comm; CoreComm.NominalWidth = 240; CoreComm.NominalHeight = 160; PutSettings(_settings); _tracer = new TraceBuffer() { Header = "ARM7: PC, machine code, mnemonic, operands, registers" }; _tracecb = new LibmGBA.TraceCallback((msg) => _tracer.Put(_traceInfo(msg))); ser.Register(_tracer); } catch { LibmGBA.BizDestroy(_core); throw; } }
public VectrexHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); cpu = new MC6809 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch, }; audio = new Audio(); ppu = new PPU(); serialport = new SerialPort(); CoreComm = comm; _settings = (VectrexSettings)settings ?? new VectrexSettings(); _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); _controllerDeck = new VectrexHawkControllerDeck(_syncSettings.Port1); byte[] Bios = null; Bios = comm.CoreFileProvider.GetFirmware("Vectrex", "Bios", true, "BIOS Not Found, Cannot Load"); _bios = Bios; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); string hash_md5 = null; hash_md5 = "md5:" + rom.HashMD5(0, rom.Length); Console.WriteLine(hash_md5); _rom = rom; Setup_Mapper(); _frameHz = 60; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (VectrexSettings)settings ?? new VectrexSettings(); _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); SetupMemoryDomains(); HardReset(); cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); }
public GBHawkLink3x(CoreLoadParameters <GBLink3xSettings, GBLink3xSyncSettings> lp) { if (lp.Roms.Count != 3) { throw new InvalidOperationException("Wrong number of roms"); } var ser = new BasicServiceProvider(this); ServiceProvider = ser; Link3xSettings = (GBLink3xSettings)lp.Settings ?? new GBLink3xSettings(); Link3xSyncSettings = (GBLink3xSyncSettings)lp.SyncSettings ?? new GBLink3xSyncSettings(); _controllerDeck = new( GBHawkControllerDeck.DefaultControllerName, GBHawkControllerDeck.DefaultControllerName, GBHawkControllerDeck.DefaultControllerName); var tempSetL = new GBHawk.GBHawk.GBSettings(); var tempSetC = new GBHawk.GBHawk.GBSettings(); var tempSetR = new GBHawk.GBHawk.GBSettings(); var tempSyncL = new GBHawk.GBHawk.GBSyncSettings(); var tempSyncC = new GBHawk.GBHawk.GBSyncSettings(); var tempSyncR = new GBHawk.GBHawk.GBSyncSettings(); tempSyncL.ConsoleMode = Link3xSyncSettings.ConsoleMode_L; tempSyncC.ConsoleMode = Link3xSyncSettings.ConsoleMode_C; tempSyncR.ConsoleMode = Link3xSyncSettings.ConsoleMode_R; tempSyncL.GBACGB = Link3xSyncSettings.GBACGB; tempSyncC.GBACGB = Link3xSyncSettings.GBACGB; tempSyncR.GBACGB = Link3xSyncSettings.GBACGB; tempSyncL.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_L; tempSyncC.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_C; tempSyncR.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_R; tempSyncL.RTCOffset = Link3xSyncSettings.RTCOffset_L; tempSyncC.RTCOffset = Link3xSyncSettings.RTCOffset_C; tempSyncR.RTCOffset = Link3xSyncSettings.RTCOffset_R; L = new GBHawk.GBHawk(lp.Comm, lp.Roms[0].Game, lp.Roms[0].RomData, tempSetL, tempSyncL); C = new GBHawk.GBHawk(lp.Comm, lp.Roms[1].Game, lp.Roms[1].RomData, tempSetC, tempSyncC); R = new GBHawk.GBHawk(lp.Comm, lp.Roms[2].Game, lp.Roms[2].RomData, tempSetR, tempSyncR); ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(this); _tracer = new TraceBuffer(L.cpu.TraceHeader); ser.Register(_tracer); _lStates = L.ServiceProvider.GetService <IStatable>(); _cStates = C.ServiceProvider.GetService <IStatable>(); _rStates = R.ServiceProvider.GetService <IStatable>(); SetupMemoryDomains(); HardReset(); }
public C64(CoreLoadParameters <C64Settings, C64SyncSettings> lp) { PutSyncSettings((C64SyncSettings)lp.SyncSettings ?? new C64SyncSettings()); PutSettings((C64Settings)lp.Settings ?? new C64Settings()); var ser = new BasicServiceProvider(this); ServiceProvider = ser; CoreComm = lp.Comm; _roms = lp.Roms.Select(r => r.RomData).ToList(); _currentDisk = 0; RomSanityCheck(); Init(SyncSettings.VicType, Settings.BorderType, SyncSettings.SidType, SyncSettings.TapeDriveType, SyncSettings.DiskDriveType); _cyclesPerFrame = _board.Vic.CyclesPerFrame; _memoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); InitMedia(_roms[_currentDisk]); HardReset(); switch (SyncSettings.VicType) { case VicType.Ntsc: case VicType.Drean: case VicType.NtscOld: Region = DisplayType.NTSC; break; case VicType.Pal: Region = DisplayType.PAL; break; } if (_board.Sid != null) { _soundProvider = new DCFilter(_board.Sid, 512); ser.Register <ISoundProvider>(_soundProvider); } ser.Register <IVideoProvider>(_board.Vic); ser.Register <IDriveLight>(this); _tracer = new TraceBuffer { Header = _board.Cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ser.Register <IStatable>(new StateSerializer(SyncState)); if (_board.CartPort.IsConnected) { // There are no multi-cart cart games, so just hardcode .First() RomDetails = $"{lp.Game.Name}\r\nSHA1:{_roms.First().HashSHA1()}\r\nMD5:{_roms.First().HashMD5()}\r\nMapper Impl \"{_board.CartPort.CartridgeType}\""; } SetupMemoryDomains(); }
public C64(CoreComm comm, IEnumerable <byte[]> roms, GameInfo game, object settings, object syncSettings) { PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings()); PutSettings((C64Settings)settings ?? new C64Settings()); var ser = new BasicServiceProvider(this); ServiceProvider = ser; InputCallbacks = new InputCallbackSystem(); CoreComm = comm; _roms = roms?.ToList() ?? new List <byte[]>(); _currentDisk = 0; RomSanityCheck(); Init(SyncSettings.VicType, Settings.BorderType, SyncSettings.SidType, SyncSettings.TapeDriveType, SyncSettings.DiskDriveType); _cyclesPerFrame = _board.Vic.CyclesPerFrame; _memoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); InitMedia(_roms[_currentDisk]); HardReset(); switch (SyncSettings.VicType) { case VicType.Ntsc: case VicType.Drean: case VicType.NtscOld: Region = DisplayType.NTSC; break; case VicType.Pal: Region = DisplayType.PAL; break; } if (_board.Sid != null) { _soundProvider = new DCFilter(_board.Sid, 512); ser.Register <ISoundProvider>(_soundProvider); } ser.Register <IVideoProvider>(_board.Vic); ser.Register <IDriveLight>(this); _tracer = new TraceBuffer { Header = _board.Cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); if (_board.CartPort.IsConnected) { // There are no multi-cart cart games, so just hardcode .First() CoreComm.RomStatusDetails = $"{game.Name}\r\nSHA1:{_roms.First().HashSHA1()}\r\nMD5:{roms.First().HashMD5()}\r\nMapper Impl \"{_board.CartPort.CartridgeType}\""; } SetupMemoryDomains(); }
public void When_Not_Registered_Resolution_Throws_Key_Not_Found_Exception() { var serviceProvider = new BasicServiceProvider(); serviceProvider.Register <IRootType, RootType>(); serviceProvider.Register <IChildOne, ChildOne>(); Assert.Throws <KeyNotFoundException>(() => serviceProvider.Resolve <IRootType>()); }
//[CoreConstructor("GB", "GBC")] public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings(); linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings(); _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName); CoreComm = comm; var temp_set_L = new GBHawk.GBHawk.GBSettings(); var temp_set_R = new GBHawk.GBHawk.GBSettings(); var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings(); var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings(); temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L; temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R; temp_sync_L.GBACGB = linkSyncSettings.GBACGB; temp_sync_R.GBACGB = linkSyncSettings.GBACGB; temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L; temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R; temp_sync_L.RTCOffset = linkSyncSettings.RTCOffset_L; temp_sync_R.RTCOffset = linkSyncSettings.RTCOffset_R; L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, game_L, rom_L, temp_set_L, temp_sync_L); R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, game_R, rom_R, temp_set_R, temp_sync_R); ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(this); _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); _lStates = L.ServiceProvider.GetService <IStatable>(); _rStates = R.ServiceProvider.GetService <IStatable>(); SetupMemoryDomains(); HardReset(); }
public SubGBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var subGBSettings = (GBHawk.GBHawk.GBSettings)settings ?? new GBHawk.GBHawk.GBSettings(); var subGBSyncSettings = (GBHawk.GBHawk.GBSyncSettings)syncSettings ?? new GBHawk.GBHawk.GBSyncSettings(); _GBCore = new GBHawk.GBHawk(comm, game, rom, subGBSettings, subGBSyncSettings); HardReset(); current_cycle = 0; CycleCount = 0; _GBStatable = _GBCore.ServiceProvider.GetService <IStatable>(); var ser = new BasicServiceProvider(this); ServiceProvider = ser; ser.Register(_GBCore.ServiceProvider.GetService <IVideoProvider>()); ser.Register(_GBCore.ServiceProvider.GetService <ISoundProvider>()); ser.Register(_GBCore.ServiceProvider.GetService <ITraceable>()); ser.Register(_GBCore.ServiceProvider.GetService <IMemoryDomains>()); ser.Register(_GBCore.ServiceProvider.GetService <ISaveRam>()); ser.Register(_GBCore.ServiceProvider.GetService <IDebuggable>()); ser.Register(_GBCore.ServiceProvider.GetService <IRegionable>()); ser.Register(_GBCore.ServiceProvider.GetService <ICodeDataLogger>()); _tracer = new TraceBuffer { Header = _GBCore.cpu.TraceHeader }; ser.Register(_tracer); _GBCore.ControllerDefinition.AxisControls.Add("Input Cycle"); _GBCore.ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 70224, 70224)); }
public SubGBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ GBHawk.GBHawk.GBSettings settings, GBHawk.GBHawk.GBSyncSettings syncSettings) { var subGBSettings = (GBHawk.GBHawk.GBSettings)settings ?? new GBHawk.GBHawk.GBSettings(); var subGBSyncSettings = (GBHawk.GBHawk.GBSyncSettings)syncSettings ?? new GBHawk.GBHawk.GBSyncSettings(); _GBCore = new GBHawk.GBHawk(comm, game, rom, subGBSettings, subGBSyncSettings); HardReset(); current_cycle = 0; CycleCount = 0; _GBStatable = _GBCore.ServiceProvider.GetService <IStatable>(); var ser = new BasicServiceProvider(this); ServiceProvider = ser; ser.Register(_GBCore.ServiceProvider.GetService <IVideoProvider>()); ser.Register(_GBCore.ServiceProvider.GetService <ISoundProvider>()); ser.Register(_GBCore.ServiceProvider.GetService <ITraceable>()); ser.Register(_GBCore.ServiceProvider.GetService <IMemoryDomains>()); ser.Register(_GBCore.ServiceProvider.GetService <ISaveRam>()); ser.Register(_GBCore.ServiceProvider.GetService <IRegionable>()); ser.Register(_GBCore.ServiceProvider.GetService <ICodeDataLogger>()); ser.Register(_GBCore.ServiceProvider.GetService <IGameboyCommon>()); _tracer = new TraceBuffer(_GBCore.cpu.TraceHeader); ser.Register(_tracer); _GBCore.ControllerDefinition.AddAxis("Input Cycle", 0.RangeTo(70224), 70224) .MakeImmutable(); }
public ChannelF(CoreLoadParameters <ChannelFSettings, ChannelFSyncSettings> lp) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; CoreComm = lp.Comm; _gameInfo = lp.Roms.Select(r => r.Game).ToList(); _files = lp.Roms.Select(r => r.RomData).ToList(); var settings = lp.Settings ?? new ChannelFSettings(); var syncSettings = lp.SyncSettings ?? new ChannelFSyncSettings(); region = syncSettings.Region; MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); ControllerDefinition = ChannelFControllerDefinition; var bios01 = CoreComm.CoreFileProvider.GetFirmwareOrThrow(new("ChannelF", "ChannelF_sl131253")); var bios02 = CoreComm.CoreFileProvider.GetFirmwareOrThrow(new("ChannelF", "ChannelF_sl131254")); //var bios02 = CoreComm.CoreFileProvider.GetFirmwareOrThrow(new("ChannelF", "ChannelF_sl90025")); Cartridge = VesCartBase.Configure(_gameInfo.First(), _files.First()); BIOS01 = bios01; BIOS02 = bios02; CPU = new F3850 { ReadMemory = ReadBus, WriteMemory = WriteBus, ReadHardware = ReadPort, WriteHardware = WritePort, DummyReadMemory = ReadBus }; _tracer = new TraceBuffer(CPU.TraceHeader); //var rom = _files.First(); //Array.Copy(rom, 0, Rom, 0, rom.Length); CalcClock(); ser.Register <IVideoProvider>(this); ser.Register <ITraceable>(_tracer); ser.Register <IDisassemblable>(CPU); ser.Register <ISoundProvider>(this); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); }
public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, ColecoSettings settings, ColecoSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; _syncSettings = (ColecoSyncSettings)syncSettings ?? new ColecoSyncSettings(); bool skipBios = _syncSettings.SkipBiosIntro; _cpu = new Z80A { FetchMemory = ReadMemory, ReadMemory = ReadMemory, WriteMemory = WriteMemory, ReadHardware = ReadPort, WriteHardware = WritePort, MemoryCallbacks = MemoryCallbacks }; PSG = new SN76489col(); SGM_sound = new AY_3_8910_SGM(); _blip.SetRates(3579545, 44100); ControllerDeck = new ColecoVisionControllerDeck(_syncSettings.Port1, _syncSettings.Port2); _vdp = new TMS9918A(_cpu); ser.Register <IVideoProvider>(_vdp); ser.Register <IStatable>(new StateSerializer(SyncState)); // TODO: hack to allow bios-less operation would be nice, no idea if its feasible _biosRom = comm.CoreFileProvider.GetFirmware("Coleco", "Bios", true, "Coleco BIOS file is required."); // gamedb can overwrite the SyncSettings; this is ok if (game["NoSkip"]) { skipBios = false; } use_SGM = _syncSettings.UseSGM; if (use_SGM) { Console.WriteLine("Using the Super Game Module"); } LoadRom(rom, skipBios); SetupMemoryDomains(); _tracer.Header = _cpu.TraceHeader; ser.Register <IDisassemblable>(_cpu); ser.Register <ITraceable>(_tracer); }
//[CoreConstructor("GB", "GBC")] public GBHawkLink3x(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_C, byte[] rom_C, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; Link3xSettings = (GBLink3xSettings)settings ?? new GBLink3xSettings(); Link3xSyncSettings = (GBLink3xSyncSettings)syncSettings ?? new GBLink3xSyncSettings(); _controllerDeck = new GBHawkLink3xControllerDeck(GBHawkLink3xControllerDeck.DefaultControllerName, GBHawkLink3xControllerDeck.DefaultControllerName, GBHawkLink3xControllerDeck.DefaultControllerName); var tempSetL = new GBHawk.GBHawk.GBSettings(); var tempSetC = new GBHawk.GBHawk.GBSettings(); var tempSetR = new GBHawk.GBHawk.GBSettings(); var tempSyncL = new GBHawk.GBHawk.GBSyncSettings(); var tempSyncC = new GBHawk.GBHawk.GBSyncSettings(); var tempSyncR = new GBHawk.GBHawk.GBSyncSettings(); tempSyncL.ConsoleMode = Link3xSyncSettings.ConsoleMode_L; tempSyncC.ConsoleMode = Link3xSyncSettings.ConsoleMode_C; tempSyncR.ConsoleMode = Link3xSyncSettings.ConsoleMode_R; tempSyncL.GBACGB = Link3xSyncSettings.GBACGB; tempSyncC.GBACGB = Link3xSyncSettings.GBACGB; tempSyncR.GBACGB = Link3xSyncSettings.GBACGB; tempSyncL.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_L; tempSyncC.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_C; tempSyncR.RTCInitialTime = Link3xSyncSettings.RTCInitialTime_R; tempSyncL.RTCOffset = Link3xSyncSettings.RTCOffset_L; tempSyncC.RTCOffset = Link3xSyncSettings.RTCOffset_C; tempSyncR.RTCOffset = Link3xSyncSettings.RTCOffset_R; L = new GBHawk.GBHawk(comm, game_L, rom_L, tempSetL, tempSyncL); C = new GBHawk.GBHawk(comm, game_C, rom_C, tempSetC, tempSyncC); R = new GBHawk.GBHawk(comm, game_R, rom_R, tempSetR, tempSyncR); ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(this); _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; ser.Register(_tracer); _lStates = L.ServiceProvider.GetService <IStatable>(); _cStates = C.ServiceProvider.GetService <IStatable>(); _rStates = R.ServiceProvider.GetService <IStatable>(); SetupMemoryDomains(); HardReset(); }
public GBHawkLink(CoreLoadParameters <GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings> lp) { if (lp.Roms.Count != 2) { throw new InvalidOperationException("Wrong number of roms"); } var ser = new BasicServiceProvider(this); ServiceProvider = ser; linkSettings = (GBLinkSettings)lp.Settings ?? new GBLinkSettings(); linkSyncSettings = (GBLinkSyncSettings)lp.SyncSettings ?? new GBLinkSyncSettings(); _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName); var temp_set_L = new GBHawk.GBHawk.GBSettings(); var temp_set_R = new GBHawk.GBHawk.GBSettings(); var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings(); var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings(); temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L; temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R; temp_sync_L.GBACGB = linkSyncSettings.GBACGB; temp_sync_R.GBACGB = linkSyncSettings.GBACGB; temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L; temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R; temp_sync_L.RTCOffset = linkSyncSettings.RTCOffset_L; temp_sync_R.RTCOffset = linkSyncSettings.RTCOffset_R; L = new GBHawk.GBHawk(lp.Comm, lp.Roms[0].Game, lp.Roms[0].RomData, temp_set_L, temp_sync_L); R = new GBHawk.GBHawk(lp.Comm, lp.Roms[1].Game, lp.Roms[1].RomData, temp_set_R, temp_sync_R); ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(this); _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); _lStates = L.ServiceProvider.GetService <IStatable>(); _rStates = R.ServiceProvider.GetService <IStatable>(); SetupMemoryDomains(); HardReset(); }
public GGHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); linkSettings = (GGLinkSettings)settings ?? new GGLinkSettings(); linkSyncSettings = (GGLinkSyncSettings)syncSettings ?? new GGLinkSyncSettings(); _controllerDeck = new GGHawkLinkControllerDeck(GGHawkLinkControllerDeck.DefaultControllerName, GGHawkLinkControllerDeck.DefaultControllerName); CoreComm = comm; var temp_set_L = new SMS.SmsSettings(); var temp_set_R = new SMS.SmsSettings(); var temp_sync_L = new SMS.SmsSyncSettings(); var temp_sync_R = new SMS.SmsSyncSettings(); L = new SMS(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, game_L, rom_L, temp_set_L, temp_sync_L); R = new SMS(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, game_R, rom_R, temp_set_R, temp_sync_R); ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(this); _tracer = new TraceBuffer { Header = L.Cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ServiceProvider = ser; SetupMemoryDomains(); HardReset(); L.stand_alone = false; R.stand_alone = false; _lStates = L.ServiceProvider.GetService <IStatable>(); _rStates = R.ServiceProvider.GetService <IStatable>(); }
public C64(CoreComm comm, IEnumerable <byte[]> roms, object settings, object syncSettings) { PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings()); PutSettings((C64Settings)settings ?? new C64Settings()); var ser = new BasicServiceProvider(this); ServiceProvider = ser; InputCallbacks = new InputCallbackSystem(); CoreComm = comm; Roms = roms?.ToList() ?? new List <byte[]>(); _currentDisk = 0; RomSanityCheck(); Init(SyncSettings.VicType, Settings.BorderType, SyncSettings.SidType, SyncSettings.TapeDriveType, SyncSettings.DiskDriveType); _cyclesPerFrame = _board.Vic.CyclesPerFrame; SetupMemoryDomains(_board.DiskDrive != null); _memoryCallbacks = new MemoryCallbackSystem(); HardReset(); switch (SyncSettings.VicType) { case VicType.Ntsc: case VicType.Drean: case VicType.NtscOld: Region = DisplayType.NTSC; break; case VicType.Pal: Region = DisplayType.PAL; break; } if (_board.Sid != null) { _soundProvider = new DCFilter(_board.Sid, 512); ser.Register <ISoundProvider>(_soundProvider); } ser.Register <IVideoProvider>(_board.Vic); ser.Register <IDriveLight>(this); _tracer = new TraceBuffer { Header = _board.Cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); }
public AppleII(CoreComm comm, GameInfo game, byte[] rom, Settings settings) { GameInfoSet = new List <GameInfo>(); var ser = new BasicServiceProvider(this); ServiceProvider = ser; CoreComm = comm; _disk1 = rom; RomSet.Add(rom); _appleIIRom = comm.CoreFileProvider.GetFirmware( SystemId, "AppleIIe", true, "The Apple IIe BIOS firmware is required"); _diskIIRom = comm.CoreFileProvider.GetFirmware( SystemId, "DiskII", true, "The DiskII firmware is required"); _machine = new Machine(_appleIIRom, _diskIIRom); _machine.BizInitialize(); //make a writeable memory stream cloned from the rom. //for junk.dsk the .dsk is important because it determines the format from that InitDisk(); //trace logger stuff Tracer = new TraceBuffer(); ser.Register <ITraceable>(Tracer); InitSaveStates(); SetupMemoryDomains(); PutSettings(settings ?? new Settings()); }
public AppleII(CoreComm comm, byte[] rom, Settings settings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; _tracer = new TraceBuffer { Header = "6502: PC, opcode, register (A, X, Y, P, SP, Cy), flags (NVTBDIZC)" }; _disk1 = rom; _romSet.Add(rom); _appleIIRom = comm.CoreFileProvider.GetFirmware( SystemId, "AppleIIe", true, "The Apple IIe BIOS firmware is required"); _diskIIRom = comm.CoreFileProvider.GetFirmware( SystemId, "DiskII", true, "The DiskII firmware is required"); _machine = new Components(_appleIIRom, _diskIIRom); // make a writable memory stream cloned from the rom. // for junk.dsk the .dsk is important because it determines the format from that InitDisk(); ser.Register <ITraceable>(_tracer); SetCallbacks(); SetupMemoryDomains(); PutSettings(settings ?? new Settings()); }
public AppleII(CoreLoadParameters <Settings, object> lp) { _romSet = lp.Roms.Select(r => r.RomData).ToList(); var ser = new BasicServiceProvider(this); ServiceProvider = ser; const string TRACE_HEADER = "6502: PC, opcode, register (A, X, Y, P, SP, Cy), flags (NVTBDIZC)"; _tracer = new TraceBuffer(TRACE_HEADER); _disk1 = _romSet[0]; _appleIIRom = lp.Comm.CoreFileProvider.GetFirmwareOrThrow(new(SystemId, "AppleIIe"), "The Apple IIe BIOS firmware is required"); _diskIIRom = lp.Comm.CoreFileProvider.GetFirmwareOrThrow(new(SystemId, "DiskII"), "The DiskII firmware is required"); _machine = new Components(_appleIIRom, _diskIIRom); // make a writable memory stream cloned from the rom. // for junk.dsk the .dsk is important because it determines the format from that InitDisk(); ser.Register <ITraceable>(_tracer); SetCallbacks(); SetupMemoryDomains(); PutSettings(lp.Settings ?? new Settings()); }
public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; _ram = new byte[128]; CoreComm = comm; Settings = (A2600Settings)settings ?? new A2600Settings(); SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings(); _controllerDeck = new Atari2600ControllerDeck(SyncSettings.Port1, SyncSettings.Port2); _leftDifficultySwitchPressed = SyncSettings.LeftDifficulty; _rightDifficultySwitchPressed = SyncSettings.RightDifficulty; Rom = rom; _game = game; if (!game.GetOptionsDict().ContainsKey("m")) { game.AddOption("m", DetectMapper(rom)); } if (Rom.HashSHA1() == "3A77DB43B6583E8689435F0F14AA04B9E57BDDED" || Rom.HashSHA1() == "E986E1818E747BEB9B33CE4DFF1CDC6B55BDB620" || Rom.HashSHA1() == "982B8016B393A9AA7DD110295A53C4612ECF2141") { game.RemoveOption("m"); game.AddOption("m", "F8_sega"); } Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]); Console.WriteLine(Rom.HashSHA1()); RebootCore(); SetupMemoryDomains(); Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; ser.Register <IDisassemblable>(Cpu); ser.Register <ITraceable>(Tracer); ser.Register <IVideoProvider>(_tia); ser.Register <ISoundProvider>(_dcfilter); ser.Register <IStatable>(new StateSerializer(SyncState)); }
public void When_More_Constructors_Throws_Exception() { var serviceProvider = new BasicServiceProvider(); serviceProvider.Register <IChildThreeWithTwoConstructors, ChildThreeWithTwoConstructors>(); Assert.Throws <Exception>(() => serviceProvider.Resolve <IChildThreeWithTwoConstructors>()); }
public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; MemoryCallbacks = new MemoryCallbackSystem(); InputCallbacks = new InputCallbackSystem(); Ram = new byte[128]; CoreComm = comm; Settings = (A2600Settings)settings ?? new A2600Settings(); SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings(); _leftDifficultySwitchPressed = SyncSettings.LeftDifficulty; _rightDifficultySwitchPressed = SyncSettings.RightDifficulty; Rom = rom; _game = game; if (!game.GetOptionsDict().ContainsKey("m")) { game.AddOption("m", DetectMapper(rom)); } if (Rom.HashSHA1() == "3A77DB43B6583E8689435F0F14AA04B9E57BDDED" || Rom.HashSHA1() == "E986E1818E747BEB9B33CE4DFF1CDC6B55BDB620") { game.RemoveOption("m"); game.AddOption("m", "F8_sega"); } Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]); Console.WriteLine(Rom.HashSHA1()); RebootCore(); SetupMemoryDomains(); Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; ser.Register <IDisassemblable>(Cpu); ser.Register <ITraceable>(Tracer); ser.Register <IVideoProvider>(_tia); }
public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); CoreComm = comm; _syncSettings = (ColecoSyncSettings)syncSettings ?? new ColecoSyncSettings(); bool skipbios = _syncSettings.SkipBiosIntro; _cpu = new Z80A { FetchMemory = ReadMemory, ReadMemory = ReadMemory, WriteMemory = WriteMemory, ReadHardware = ReadPort, WriteHardware = WritePort, MemoryCallbacks = MemoryCallbacks }; PSG = new SN76489(); _fakeSyncSound = new FakeSyncSound(PSG, 735); ser.Register <ISoundProvider>(_fakeSyncSound); ControllerDeck = new ColecoVisionControllerDeck(_syncSettings.Port1, _syncSettings.Port2); _vdp = new TMS9918A(_cpu); ser.Register <IVideoProvider>(_vdp); // TODO: hack to allow bios-less operation would be nice, no idea if its feasible _biosRom = CoreComm.CoreFileProvider.GetFirmware("Coleco", "Bios", true, "Coleco BIOS file is required."); // gamedb can overwrite the syncsettings; this is ok if (game["NoSkip"]) { skipbios = false; } LoadRom(rom, skipbios); SetupMemoryDomains(); _tracer.Header = _cpu.TraceHeader; ser.Register <IDisassemblable>(_cpu); ser.Register <ITraceable>(_tracer); }
public AppleII(CoreComm comm, GameInfo game, byte[] rom, Settings settings) { GameInfoSet = new List<GameInfo>(); var ser = new BasicServiceProvider(this); ServiceProvider = ser; CoreComm = comm; Tracer = new TraceBuffer(); MemoryCallbacks = new MemoryCallbackSystem(); InputCallbacks = new InputCallbackSystem(); _disk1 = rom; RomSet.Add(rom); _appleIIRom = comm.CoreFileProvider.GetFirmware( SystemId, "AppleIIe", true, "The Apple IIe BIOS firmware is required"); _diskIIRom = comm.CoreFileProvider.GetFirmware( SystemId, "DiskII", true, "The DiskII firmware is required"); _machine = new Machine(_appleIIRom, _diskIIRom); _machine.BizInitialize(); //make a writeable memory stream cloned from the rom. //for junk.dsk the .dsk is important because it determines the format from that InitDisk(); ser.Register<ITraceable>(Tracer); setCallbacks(); InitSaveStates(); SetupMemoryDomains(); PutSettings(settings ?? new Settings()); }