Example #1
0
        public void Loop()
        {
            while (!_Halted)
            {
                byte instruction = _MMU.ReadByte(_RegPC);
                bool prefixed    = false;

                if (instruction == INSTRUCTION_PREFIX)
                {
                    instruction = _MMU.ReadByte((ushort)(_RegPC + 1));
                    prefixed    = true;
                }
                Console.WriteLine($"{_RegPC.ToString("x2")}:{instruction.ToString("x2")}");
                ExecuteInstruction(instruction, prefixed);

                _PPU.Step();
                Interupts();
                if (_PPU.Line >= PPU._height + 10)
                {
                    _PPU.Line = 0;
                    _Halted   = true;
                }
            }
        }
Example #2
0
 public void Step()
 {
     if (Line == 0)
     {
         _tileSet = new TileSet(_MMU.GetTileSet0());
         _tileMap = new TileMap(_MMU.GetTileMap0());
     }
     if (Line < _height)
     {
         RenderScan(Line);
     }
     else if (Line == _height)
     {
         byte interruptsTriggered = _MMU.ReadByte(INTERRUPTS_TRIGGERED_ADDRESS);
         _MMU.WriteByte(INTERRUPTS_TRIGGERED_ADDRESS, (byte)(interruptsTriggered | 0b00000001));
     }
     _MMU.WriteByte(_lyAddress, (byte)Line);
     Line++;
 }