private uint _vblankClock; // counter of clock cycles elapsed in current scanline in vblank public LCDController(SystemClock clock, Interconnect interconnect, InterruptController interruptController, IVideoFrameSink frameSink) : base(clock) { _interconnect = interconnect; _interruptController = interruptController; _frameSink = frameSink; _interconnect.AddAddressHandler(0xFF40, 0xFF4B, this); // control registers _interconnect.AddAddressHandler(0x8000, 0x9FFF, this); // vram _interconnect.AddAddressHandler(0xFE00, 0xFE9F, this); // oam _screenData = new byte[ScreenWidth * ScreenHeight]; _vram = new byte[0x2000]; _tileCache = new byte[384][]; for (int i = 0; i < _tileCache.Length; i++) { _tileCache[i] = new byte[64]; } _tileCacheInvalid = new bool[384]; _oam = new byte[0xA0]; _oamDma = default(OamDma); _backgroundPalette = new byte[4]; _spritePalette = new byte[2][] { new byte[4], new byte[4] }; }
public GameBoy(IVideoFrameSink frameSink, IInputSource inputSource) { Clock = new SystemClock(); Interconnect = new Interconnect(); Interconnect.AddAddressHandler(0x0000, 0x00FF, new BootRom()); Memory = new SystemMemory(Interconnect); InterruptController = new InterruptController(Interconnect); CPU = new SM83(Clock, Interconnect, InterruptController); Timer = new Timer(Clock, Interconnect, InterruptController); SerialIO = new SerialCommunicationController(Clock, Interconnect, InterruptController); LCD = new LCDController(Clock, Interconnect, InterruptController, frameSink); PSG = new SoundController(Clock, Interconnect); Input = new InputController(Interconnect, InterruptController, inputSource); }