public MemoryDispatcher(LCDController graphics, SoundUnit sound, TimerUnit timer, Joypad joypad) { Timer = timer; Timer.TimerOverflow += Timer_TimerOverflow; GraphicsUnit = graphics; GraphicsUnit.VBlankInterrupt += Gu_VBlankInterrupt; GraphicsUnit.LCDCInterrupt += Gu_LCDCInterrupt; SoundUnit = sound; Joypad = joypad; Joypad.JoypadInterrupt += Joypad_JoypadInterrupt; }
public GameBoyEmulator() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); InitializeComponent(); graphics = new LCDController(); sound = new SoundUnit(); timer = new TimerUnit(); joypad = new Joypad(); memory = new MemoryDispatcher(graphics, sound, timer, joypad); processor = new Z80Processor(memory); gameThread = new BackgroundWorker(); gameThread.DoWork += GameThread_DoWork; gameThread.RunWorkerCompleted += GameThread_RunWorkerCompleted; gameThread.WorkerSupportsCancellation = true; frameTimer.Interval = 15; // Run at 60 FPS syncTimer.Interval = 8; }