private void Run(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.DefaultExt = ".gb"; dialog.Filter = "Gameboy ROM (.gb)|*.gb"; bool? res = dialog.ShowDialog(); if (res == true) { emu = new GBLib(); gbdisplay.GBemu = emu; emu.onDisplayUpdate += new OnDisplayUpdate(this.gbdisplay.OnDisplayUpdate); emu.LoadRom(dialog.FileName); emu.Start(); DispatcherTimer t = new DispatcherTimer(); Int64 ticks_per_mhz = 10; t.Interval = new TimeSpan(ticks_per_mhz); t.Tick += HandleTick; t.Start(); } }
public void Execute(GBLib sys) { if (down) { sys.Keydown((uint)button); } else { sys.Keyup((uint)button); } }
public static void Run(String filename) { fn = filename; sys = new GBLib(); //sys.onSerialDataReady += new OnSerialDataReady(CheckResult); sys.LoadRom(filename); sys.Start(); int test_status = sys.Inspect((int)GBLocations.MEM, (ushort)0xA000); int pc = sys.Inspect((int)GBLocations.PC, 0); //while (test_status == 0x80 || sys.Inspect((int)GBLocations.PC, 0) < 0x200) while(true) { //Debug.WriteLine("PC: {0}", sys.Inspect((int)GBLocations.PC, 0)); sys.Step(); test_status = sys.Inspect((int)GBLocations.MEM, (ushort)0xA000); pc = sys.Inspect((int)GBLocations.PC, 0); Debug.WriteLine("PC: 0x{0:X}", pc); Debug.WriteLine("Test Status: 0x{0:X}", test_status); } String result = ""; int character = '\0'; for(ushort start_addr = 0xA004; character != '\0'; ++start_addr) { result += (char)character; } result += '\0'; Debug.WriteLine(result); if (test_status != 0x00) { Debug.WriteLine("Test " + fn + " Failed:"); Assert.Fail(); } else { Debug.WriteLine("Test " + fn + " Passed:"); } }
public static void LoadAAT(String filename) { assembler = new Assembler(); lineExpectations = new Dictionary<int, GBTestExpections>(); lineEvents = new Dictionary<int, GBTestEvent>(); System.IO.StreamReader file = new System.IO.StreamReader(filename); int lno = 0; while (!file.EndOfStream) { String line = file.ReadLine(); String [] parts = line.Split(';'); if ((parts.Length == 2) && parts[1].StartsWith("EXPECT:")) { lineExpectations[lno] = new GBTestExpections(parts[1].Substring(8)); } if ((parts.Length == 2) && parts[1].StartsWith("EVENTS:")) { lineEvents[lno] = new GBTestEvent(parts[1].Substring(8)); } ++lno; } file = new System.IO.StreamReader(filename); rom = assembler.AssembleString(file.ReadToEnd()); sys = new GBLib(); sys.SetRom(rom); sys.Start(); }
public void CheckRegs(GBLib sys) { foreach (GBLocations reg in regs.Keys) { ushort inspected_value = (ushort)sys.Inspect((int)reg, 0); ushort expectation = (ushort)regs[reg]; Assert.AreEqual(expectation, inspected_value); } }
public void CheckRam(GBLib sys) { foreach (ushort loc in ram.Keys) { byte inspected_value = (byte)sys.Inspect((int)GBLocations.MEM, loc); byte expectation = (byte)ram[loc]; Assert.AreEqual(expectation, inspected_value); } }