Esempio n. 1
0
 public GameBoy(ICartridge cartridge)
 {
     Cartridge = cartridge;
     Memory    = new GameBoyMemory(this);
     Cpu       = new GameBoyCpu(this);
     Gpu       = new GameBoyGpu(this);
     Spu       = new GameBoySpu(this);
     KeyPad    = new GameBoyPad(this);
     Timer     = new GameBoyTimer(this);
     Reset();
     IsPoweredOn = true;
 }
Esempio n. 2
0
        public GameBoy(ICartridge cartridge, IClock clock, bool preferGbcMode)
        {
            GbcMode = preferGbcMode && (cartridge.GameBoyColorFlag & GameBoyColorFlag.SupportsColor) != 0;

            _clock = clock;

            Components = new List <IGameBoyComponent>
            {
                (Cartridge = cartridge),
                (Memory = new GameBoyMemory(this)),
                (Cpu = new GameBoyCpu(this, clock)),
                (Gpu = new GameBoyGpu(this)),
                (Spu = new GameBoySpu(this)),
                (KeyPad = new GameBoyPad(this)),
                (Timer = new GameBoyTimer(this))
            }.AsReadOnly();

            foreach (var component in Components)
            {
                component.Initialize();
            }

            Reset();
            IsPoweredOn = true;

            _clock.Tick += NextFrame;
            new Thread(CpuLoop)
            {
                Name         = "Z80CPULOOP",
                IsBackground = true
            }.Start();


            _lastFrameTime     = DateTime.Now;
            Gpu.VBlankStarted += (_, __) =>
            {
                _framesCount++;

                FrameDelta     = DateTime.Now - _lastFrameTime;
                _lastFrameTime = DateTime.Now;
            };
        }
Esempio n. 3
0
        public GameBoy(ICartridge cartridge, IClock clock, bool preferGbcMode)
        {
            GbcMode = preferGbcMode && (cartridge.GameBoyColorFlag & GameBoyColorFlag.SupportsColor) != 0;

            Components = new List <IGameBoyComponent>
            {
                (Cartridge = cartridge),
                (Memory = new GameBoyMemory(this)),
                (Cpu = new GameBoyCpu(this, clock)),
                (Gpu = new GameBoyGpu(this)),
                (Spu = new GameBoySpu(this)),
                (KeyPad = new GameBoyPad(this)),
                (Timer = new GameBoyTimer(this))
            }.AsReadOnly();

            foreach (var component in Components)
            {
                component.Initialize();
            }

            Reset();
            IsPoweredOn = true;
        }