public Chip8Emulator(Timers timers, Screen screen, Keyboard keyboard, Sound sound) { _cpu = new Cpu(); _memory = new Memory(); _timers = timers; _screen = screen; _keyboard = keyboard; _sound = sound; }
/// <summary> /// Updates the GUI. /// </summary> private void updateGui() { textBoxReg0.Text = Cpu.ToBinaryString(cpu.Register[0]); textBoxReg1.Text = Cpu.ToBinaryString(cpu.Register[1]); textBoxReg2.Text = Cpu.ToBinaryString(cpu.Register[2]); textBoxReg3.Text = Cpu.ToBinaryString(cpu.Register[3]); textBoxRegCommand.Text = Cpu.ToBinaryString(cpu.CommandRegister); lblCurrentCommand.Text = cpu.find().ToString(); textBoxCommandCounter.Text = Cpu.ToBinaryString(cpu.CommandCounter); checkBoxCarry.Checked = cpu.CarryFlag; listBoxCommandStack.Items.Clear(); var cc = Cpu.ToShort(cpu.CommandCounter); for (var i = (cc - 5 * Cpu.WORD_LENGTH); i <= (cc + 10 * Cpu.WORD_LENGTH); i += Cpu.WORD_LENGTH) { listBoxCommandStack.Items.Add(i + ":\t" + Cpu.ToBinaryString(cpu.FromMemory(i, 2)) + "\t" + Cpu.ToShort(cpu.FromMemory(i, 2))); //listBoxCommandStack.Items.Add(i + ":\t" + cpu.FromMemory(i, 1)[0] + " " + cpu.FromMemory(i + 1, 1)[0]); } listBoxCommandStack.SelectedIndex = 5; listBoxMemoryStack.Items.Clear(); for (var i = 500; i <= 529; i += Cpu.WORD_LENGTH) { listBoxMemoryStack.Items.Add(i + ":\t" + Cpu.ToBinaryString(cpu.FromMemory(i, 2)) + "\t" + Cpu.ToShort(cpu.FromMemory(i, 2))); //listBoxMemoryStack.Items.Add(i + ":\t" + cpu.FromMemory(i, 1)[0] + " " + cpu.FromMemory(i + 1, 1)[0]); } toolStripStatusLabel1.Text = "Steps: " + (cpu.StepCounter > 999 ? cpu.StepCounter.ToString("#,000") : cpu.StepCounter.ToString()); }