Exemplo n.º 1
0
        public void StartGame(string rom, bool loop = false)
        {
            ConsoleRenderer renderer = new ConsoleRenderer(32, 32);
            GameMemory      mem      = new GameMemory(renderer);

            machine = new NMOSMachine(mem);

            LoadRom($"./roms/{rom}", 0x0600);

            while (true)
            {
                // input poll
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo pressed = Console.ReadKey(true);

                    // exit if escape
                    if (pressed.Key == ConsoleKey.Escape)
                    {
                        break;
                    }

                    machine.Memory.Set(0xFF, (byte)pressed.KeyChar);
                }

                for (int i = 0; i < INSTRUCTIONS_PER_SLEEP; i++)
                {
                    machine.CPU.NextInstruction();
                }
                System.Threading.Thread.Sleep(1);

                if (loop && machine.CPU.PC.Value == 0)
                {
                    StartGame(rom, loop);
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public GameMemory(ConsoleRenderer renderer) : base(65536)
 {
     this.renderer = renderer;
 }