Esempio n. 1
0
        private void LoadAndReset()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title            = "Select a Chip-8 ROM File";
            openFileDialog.DefaultExt       = "ch8";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Filter           = "Chip-8 ROM (*.ch8)|*.ch8|Chip-8 ROM (*.c8k)|*.c8k|Chip-8 ROM (*.c8)|*.c8|All Files (*.*)|*.*";
            openFileDialog.FilterIndex      = 1;

            if (openFileDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                _romfile = openFileDialog.FileName;
                _chip8.LoadROM(_romfile);

                this.Text = "Chip-8: " + Path.GetFileName(_romfile);

                NotifyToolbar();
                ClearControls();
                ShowASM();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Console.SetWindowSize(Console.WindowWidth, 32);

            FillScreen();

            var consoleKeyboardInput = new ConsoleKeyboardInput();
            var consoleAudioPlayer   = new ConsoleSound();

            Chip8Emulator emulator           = new Chip8Emulator(consoleKeyboardInput, consoleAudioPlayer);
            var           consoleDisplayView = new ConsoleDisplayView(emulator);

            if (args.Length > 0)
            {
                emulator.LoadROM(args[0]);

#if false
                var runChipEmulator = new RunChip8EmulatorTest(emulator, consoleDisplayView);
//                var runChipEmulator = new RunChip8EmulatorWithTimers(emulator, consoleDisplayView);

                try
                {
                    while (true)
                    {
                        runChipEmulator.Run();
                    }
                }
                catch (EndEmulationException)
                {
                }
#endif

#if true
                var runChipEmulator = new RunChip8EmulatorWithTimers(emulator, consoleDisplayView);

                while (true)
                {
                    runChipEmulator.Run();
                }
#endif

                Environment.ExitCode = 0;
                return;
            }

#if false
            var memory = emulator.Memory;
            memory[0x0200] = 0x62;
            memory[0x0201] = 0x0A;
            memory[0x0202] = 0x63;
            memory[0x0203] = 0x0C;
            memory[0x0204] = 0xA2;
            memory[0x0205] = 0x20;
            memory[0x0206] = 0xD2;
            memory[0x0207] = 0x36;
            memory[0x0208] = 0xD2;
            memory[0x0209] = 0x36;
            memory[0x020A] = 0x00; // Invalid!
            memory[0x0220] = 0xBA;
            memory[0x0221] = 0x7C;
            memory[0x0222] = 0xD6;
            memory[0x0223] = 0xFE;
            memory[0x0224] = 0x54;
            memory[0x0225] = 0xAA;
#endif


            Console.CursorVisible = true;
        }