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; }
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; }; }
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; }