static void Main(string[] args) { var cancellation = new CancellationTokenSource(); var arguments = GameboyOptions.Parse(args); var emulator = new Emulator(arguments); if (!arguments.RomSpecified) { GameboyOptions.PrintUsage(Console.Out); Console.Out.Flush(); Environment.Exit(1); } if (arguments.Interactive) { var ui = new CommandLineInteractivity(); emulator.Controller = ui; emulator.Display.OnFrameProduced += ui.UpdateDisplay; emulator.Run(cancellation.Token); ui.ProcessInput(); } else { emulator.Run(cancellation.Token); Console.WriteLine("Running headless."); Console.WriteLine("Press ANY key to exit."); Console.ReadKey(true); } cancellation.Cancel(); }
public MooneyeTestRunner(FileInfo romFileInfo, TextWriter os, bool trace) { _tracer = trace ? (ITracer) new Tracer(romFileInfo.Name) : new NullTracer(); var opts = new List <string>(); if (romFileInfo.ToString().EndsWith("-C.gb") || romFileInfo.ToString().EndsWith("-cgb.gb")) { opts.Add("c"); } if (romFileInfo.Name.StartsWith("boot_")) { opts.Add("b"); } opts.Add("db"); var options = new GameboyOptions(romFileInfo, new List <string>(), opts); var cart = new Cartridge(options); _gb = new Gameboy(options, cart, new NullDisplay(), new NullController(), new NullSoundOutput(), new NullSerialEndpoint()); Console.WriteLine("System type: " + (cart.Gbc ? "CGB" : "DMG")); Console.WriteLine("Bootstrap: " + (options.UseBootstrap ? "enabled" : "disabled")); _cpu = _gb.Cpu; _registers = _cpu.Registers; _mem = _gb.Mmu; _os = os; }
public SerialTestRunner(FileInfo romFile, TextWriter os) { var options = new GameboyOptions(romFile); var cart = new Cartridge(options); gb = new Gameboy(options, cart, new NullDisplay(), new NullController(), new NullSoundOutput(), this); text = new StringBuilder(); this.os = os; }
public WinFormsEmulatorSurface() { InitializeComponent(); Controls.Add(_menu = new MenuStrip { Items = { new ToolStripMenuItem("Emulator") { DropDownItems = { new ToolStripMenuItem("Load ROM", null, (sender, args) =>{ StartEmulation(); }), new ToolStripMenuItem("Pause", null, (sender, args) =>{ _emulator.TogglePause(); }), new ToolStripMenuItem("Quit", null, (sender, args) =>{ Close(); }) } }, new ToolStripMenuItem("Graphics") { DropDownItems = { new ToolStripMenuItem("Screenshot", null, (sender, args) =>{ Screenshot(); }) } } } }); Controls.Add(_pictureBox = new PictureBox { Top = _menu.Height, Width = BitmapDisplay.DisplayWidth * 5, Height = BitmapDisplay.DisplayHeight * 5, BackColor = Color.Black, SizeMode = PictureBoxSizeMode.Zoom }); _controls = new Dictionary <Keys, Button> { { Keys.Left, Button.Left }, { Keys.Right, Button.Right }, { Keys.Up, Button.Up }, { Keys.Down, Button.Down }, { Keys.Z, Button.A }, { Keys.X, Button.B }, { Keys.Enter, Button.Start }, { Keys.Back, Button.Select } }; Height = _menu.Height + _pictureBox.Height + 50; Width = _pictureBox.Width; _cancellation = new CancellationTokenSource(); _gameboyOptions = new GameboyOptions(); _emulator = new Emulator(_gameboyOptions); ConnectEmulatorToPanel(); }
public SerialTestRunner(FileInfo romFileInfo, TextWriter os, bool trace) { _tracer = trace ? (ITracer) new Tracer(romFileInfo.Name) : new NullTracer(); var options = new GameboyOptions(romFileInfo); var cart = new Cartridge(options); _gb = new Gameboy(options, cart, new NullDisplay(), new NullController(), new NullSoundOutput(), this); _text = new StringBuilder(); _os = os; }
public MainWindow() { Opened += OnWindowOpenedBindWindowEvents; InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif BuildMenuViewModel(); BindKeysToButtons(); AdjustEmulatorScreenSize(); _cancellation = new CancellationTokenSource(); _gameboyOptions = new GameboyOptions(); _emulator = new Emulator(_gameboyOptions); ConnectEmulatorToUI(); }
public MooneyeTestRunner(FileInfo romFile, TextWriter os) { var opts = new List <string>(); if (romFile.Name.EndsWith("-C.gb") || romFile.Name.EndsWith("-cgb.gb")) { opts.Add("c"); } if (romFile.Name.StartsWith("boot_")) { opts.Add("b"); } opts.Add("db"); var options = new GameboyOptions(romFile, new List <string>(), opts); var cart = new Cartridge(options); gb = new Gameboy(options, cart, new NullDisplay(), new NullController(), new NullSoundOutput(), new NullSerialEndpoint()); os.WriteLine("System type: " + (cart.IsGbc ? "CGB" : "DMG")); os.WriteLine("Bootstrap: " + (options.UseBootstrap ? "enabled" : "disabled")); cpu = gb.Cpu; regs = cpu.Registers; mem = gb.AddressSpace; this.os = os; }
public Emulator(GameboyOptions options) { _runnables = new List <Thread>(); Options = options; }
public Cartridge(GameboyOptions options) { var file = options.RomFile; var rom = LoadFile(file); var type = CartridgeTypeExtensions.GetById(rom[0x0147]); Title = GetTitle(rom); // LOG.debug("Cartridge {}, type: {}", title, type); var gameboyType = GetFlag(rom[0x0143]); var romBanks = GetRomBanks(rom[0x0148]); var ramBanks = GetRamBanks(rom[0x0149]); if (ramBanks == 0 && type.IsRam()) { // LOG.warn("RAM bank is defined to 0. Overriding to 1."); ramBanks = 1; } // LOG.debug("ROM banks: {}, RAM banks: {}", romBanks, ramBanks); IBattery battery = new NullBattery(); if (type.IsBattery() && options.IsSupportBatterySaves()) { //throw new NotImplementedException("Implement battery loading"); battery = new FileBattery(file.Name); } if (type.IsMbc1()) { _addressSpace = new Mbc1(rom, type, battery, romBanks, ramBanks); } else if (type.IsMbc2()) { _addressSpace = new Mbc2(rom, type, battery, romBanks); } else if (type.IsMbc3()) { _addressSpace = new Mbc3(rom, type, battery, romBanks, ramBanks); } else if (type.IsMbc5()) { _addressSpace = new Mbc5(rom, type, battery, romBanks, ramBanks); } else { _addressSpace = new Rom(rom, type, romBanks, ramBanks); } _dmgBootstrap = options.UseBootstrap ? 0 : 1; if (options.ForceCgb) { Gbc = true; return; } switch (gameboyType) { case GameboyTypeFlag.NON_CGB: Gbc = false; break; case GameboyTypeFlag.CGB: Gbc = true; break; default: // UNIVERSAL Gbc = !options.ForceDmg; break; } }