Beispiel #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ResetAll();
                byte[] code = File.ReadAllBytes(ofd.FileName);
                _outputWindow = new OutputWindow();
                _outputWindow.Show();

                _cpu = new Chip8Cpu(_outputWindow.Chip8Control, _outputWindow.Chip8Control);
                _interpreter = new Chip8Interpreter(_cpu, code);

                Chip8Disassembler disassembler = new Chip8Disassembler(_cpu.Memory);
                foreach (var instruction in disassembler.Disassemble())
                {
                    lvCode.Items.Add(new ListViewItem(
                        new string[]
                        {
                            instruction.Offset.ToString("X8"),
                            instruction.Value.ToString("X4"),
                            instruction.OpCode.Name.ToString()
                        })
                        { Tag = instruction });
                }

                _interpreter.Resumed += _interpreter_Resumed;
                _interpreter.Suspended += _interpreter_Suspended;
                _interpreter.Stepped += _interpreter_Stepped;

                HighlightCurrentInstruction();
                new Thread(_interpreter.InterpetCode).Start();
            }
        }
Beispiel #2
0
 public Chip8Interpreter(Chip8Cpu cpu, byte[] code)
 {
     this._cpu = cpu;
     Buffer.BlockCopy(FontSet, 0, cpu.Memory, FontSetAddress, FontSet.Length);
     Buffer.BlockCopy(code, 0, cpu.Memory, CodeAddress, code.Length);
     this._code = code;
     this._disassembler = new Chip8Disassembler(cpu.Memory);
 }
Beispiel #3
0
 public void Execute(Chip8Cpu cpu)
 {
     OpCode.Action(cpu, Value);
 }