private void LoadRom() { if (_cpuRunner != null) { _cpuRunner.Stop(); _cpuRunner = null; } var openFileDialog = new OpenFileDialog(); var showDialog = openFileDialog.ShowDialog(View); if (!showDialog.HasValue || !showDialog.Value) return; var fileStream = openFileDialog.OpenFile(); var buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, (int)fileStream.Length); CreateCpu(buffer); }
private void CreateCpu(byte[] buffer) { var display = new Display(); var randomizer = new Randomizer(); var wpfKeyboard = new WpfKeyboard(View); var bcdConverter = new BcdConverter(); var instructionDecoder = new InstructionDecoder(); var timerClock = new TimerClock(); var chip8Cpu = new Chip8Cpu(display, randomizer, wpfKeyboard, bcdConverter, instructionDecoder, timerClock); Array.Copy(buffer, 0, chip8Cpu.State.Memory, 0x200, buffer.Length); chip8Cpu.State.ProgramCounter = 0x200; _cpuRunner = new CpuRunner(this, chip8Cpu, display); _cpuRunner.Start(); }