public Display(IOState ioState) { Icon = Resources.cookie_chocolate_512; _ioState = ioState; InitializeComponent(); _originalText = Text; KeybindingState = new KeybindingState(); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var ioState = new IOState(); var form = new Display(ioState); var cpu = new CPU(ioState); var cpuTicks = 0; var secondStart = DateTime.Now; form.Show(); cpu.LoadRom(); Task.Run(() => { while (true) { if (cpu.Delay > 0) { cpu.Delay--; } Thread.Sleep(1000 / 60); } }); while (form.Visible) { Application.DoEvents(); var clockCycleStart = DateTime.Now; if (ioState.Reset) { ioState.Reset = false; cpu.Reset(); cpu.LoadRom(); } cpu.Clock(); cpuTicks++; if (ioState.ForceRedraw) { ioState.ForceRedraw = false; form.RenderDisplay(); } var delta = (DateTime.Now - secondStart).TotalMilliseconds; if (delta > 1000) { form.IPS = cpuTicks; secondStart = DateTime.Now; cpuTicks = 0; } while ((DateTime.Now - clockCycleStart).TotalMilliseconds < 1.0) { } } }
public CPU(IOState ioState) { _ioState = ioState; LoadFont(); }