public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object SyncSettings) { CoreComm = comm; this.SyncSettings = (ColecoSyncSettings)SyncSettings ?? new ColecoSyncSettings(); bool skipbios = this.SyncSettings.SkipBiosIntro; Cpu = new Z80A(); Cpu.ReadMemory = ReadMemory; Cpu.WriteMemory = WriteMemory; Cpu.ReadHardware = ReadPort; Cpu.WriteHardware = WritePort; VDP = new TMS9918A(Cpu); PSG = new SN76489(); // TODO: hack to allow bios-less operation would be nice, no idea if its feasible string biosPath = CoreComm.CoreFileProvider.GetFirmwarePath("Coleco", "Bios", true, "Coleco BIOS file is required."); BiosRom = File.ReadAllBytes(biosPath); // gamedb can overwrite the syncsettings; this is ok if (game["NoSkip"]) skipbios = false; LoadRom(rom, skipbios); this.game = game; SetupMemoryDomains(); }
public Genesis(CoreComm comm, GameInfo game, byte[] rom) { ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; MainCPU = new MC68000(); SoundCPU = new Z80A(); YM2612 = new YM2612() { MaxVolume = 23405 }; PSG = new SN76489() { MaxVolume = 4681 }; VDP = new GenVDP(); VDP.DmaReadFrom68000 = ReadWord; (ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(VDP); SoundMixer = new SoundMixer(YM2612, PSG); MainCPU.ReadByte = ReadByte; MainCPU.ReadWord = ReadWord; MainCPU.ReadLong = ReadLong; MainCPU.WriteByte = WriteByte; MainCPU.WriteWord = WriteWord; MainCPU.WriteLong = WriteLong; MainCPU.IrqCallback = InterruptCallback; // ---------------------- musashi ----------------------- #if MUSASHI _vdp = vdpcallback; read8 = Read8; read16 = Read16; read32 = Read32; write8 = Write8; write16 = Write16; write32 = Write32; Musashi.RegisterVdpCallback(Marshal.GetFunctionPointerForDelegate(_vdp)); Musashi.RegisterRead8(Marshal.GetFunctionPointerForDelegate(read8)); Musashi.RegisterRead16(Marshal.GetFunctionPointerForDelegate(read16)); Musashi.RegisterRead32(Marshal.GetFunctionPointerForDelegate(read32)); Musashi.RegisterWrite8(Marshal.GetFunctionPointerForDelegate(write8)); Musashi.RegisterWrite16(Marshal.GetFunctionPointerForDelegate(write16)); Musashi.RegisterWrite32(Marshal.GetFunctionPointerForDelegate(write32)); #endif // ---------------------- musashi ----------------------- SoundCPU.ReadMemory = ReadMemoryZ80; SoundCPU.WriteMemory = WriteMemoryZ80; SoundCPU.WriteHardware = (a, v) => { Console.WriteLine("Z80: Attempt I/O Write {0:X2}:{1:X2}", a, v); }; SoundCPU.ReadHardware = x => 0xFF; SoundCPU.IRQCallback = () => SoundCPU.Interrupt = false; Z80Reset = true; RomData = new byte[0x400000]; for (int i = 0; i < rom.Length; i++) RomData[i] = rom[i]; SetupMemoryDomains(); #if MUSASHI Musashi.Init(); Musashi.Reset(); VDP.GetPC = () => Musashi.PC; #else MainCPU.Reset(); VDP.GetPC = () => MainCPU.PC; #endif InitializeCartHardware(game); }
public SMS(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { Settings = (SMSSettings)settings ?? new SMSSettings(); SyncSettings = (SMSSyncSettings)syncSettings ?? new SMSSyncSettings(); CoreComm = comm; IsGameGear = game.System == "GG"; IsSG1000 = game.System == "SG"; RomData = rom; CoreComm.CpuTraceAvailable = true; if (RomData.Length % BankSize != 0) Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize); RomBanks = (byte)(RomData.Length / BankSize); DisplayType = DetermineDisplayType(SyncSettings.DisplayType, game.Region); if (game["PAL"] && DisplayType != DisplayType.PAL) { DisplayType = DisplayType.PAL; CoreComm.Notify("Display was forced to PAL mode for game compatibility."); } if (IsGameGear) DisplayType = DisplayType.NTSC; // all game gears run at 60hz/NTSC mode CoreComm.VsyncNum = DisplayType == DisplayType.NTSC ? 60 : 50; CoreComm.VsyncDen = 1; Region = SyncSettings.ConsoleRegion; if (Region == "Auto") Region = DetermineRegion(game.Region); if (game["Japan"] && Region != "Japan") { Region = "Japan"; CoreComm.Notify("Region was forced to Japan for game compatibility."); } if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear) HasYM2413 = true; if (Controller == null) Controller = NullController.GetNullController(); Cpu = new Z80A(); Cpu.RegisterSP = 0xDFF0; Cpu.ReadHardware = ReadPort; Cpu.WriteHardware = WritePort; Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); PSG = new SN76489(); YM2413 = new YM2413(); SoundMixer = new SoundMixer(YM2413, PSG); if (HasYM2413 && game["WhenFMDisablePSG"]) SoundMixer.DisableSource(PSG); ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG; SystemRam = new byte[0x2000]; if (game["CMMapper"]) InitCodeMastersMapper(); else if (game["CMMapperWithRam"]) InitCodeMastersMapperRam(); else if (game["ExtRam"]) InitExt2kMapper(int.Parse(game.OptionValue("ExtRam"))); else if (game["KoreaMapper"]) InitKoreaMapper(); else if (game["MSXMapper"]) InitMSXMapper(); else if (game["NemesisMapper"]) InitNemesisMapper(); else if (game["TerebiOekaki"]) InitTerebiOekaki(); else InitSegaMapper(); if (Settings.ForceStereoSeparation && !IsGameGear) { if (game["StereoByte"]) { ForceStereoByte = byte.Parse(game.OptionValue("StereoByte")); } PSG.StereoPanning = ForceStereoByte; } if (SyncSettings.AllowOverlock && game["OverclockSafe"]) Vdp.IPeriod = 512; if (Settings.SpriteLimit) Vdp.SpriteLimit = true; if (game["3D"]) IsGame3D = true; if (game["BIOS"]) { Port3E = 0xF7; // Disable cartridge, enable BIOS rom InitBiosMapper(); } else if (game.System == "SMS") { BiosRom = comm.CoreFileProvider.GetFirmware("SMS", Region, false); if (BiosRom != null && (game["RequireBios"] || SyncSettings.UseBIOS)) Port3E = 0xF7; if (BiosRom == null && game["RequireBios"]) CoreComm.Notify("BIOS image not available. This game requires BIOS to function."); if (SyncSettings.UseBIOS && BiosRom == null) CoreComm.Notify("BIOS was selected, but rom image not available. BIOS not enabled."); } if (game["SRAM"]) SaveRAM = new byte[int.Parse(game.OptionValue("SRAM"))]; else if (game.NotInDatabase) SaveRAM = new byte[0x8000]; SetupMemoryDomains(); }