示例#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;
 }
示例#2
0
文件: GameBoy.cs 项目: lukehorak/Emux
        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;
            };
        }
示例#3
0
文件: GameBoy.cs 项目: luqide/Emux
        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;
        }