Exemple #1
0
 public Emulator()
 {
     _cartridge        = new Cartridge();
     _gpu              = new GPU();
     _timer            = new Timer();
     _divideRegister   = new DivideRegister();
     _joypad           = new Joypad();
     _apu              = new APU();
     _mmu              = new MMU(_cartridge, _gpu, _timer, _divideRegister, _joypad, _apu);
     _cpu              = new CPU(_mmu);
     _cpu.OnClockTick += UpdateSystems;
 }
Exemple #2
0
        public CPU(MMU mmu)
        {
            _mmu = mmu;
            _mmu.GetSpeedState        = GetSpeedState;
            _mmu.OnPendingSpeedSwitch = OnPendingSpeedSwitch;

            _interruptHandler = new InterruptHandler(_mmu);
            _interruptHandler.IncrementClock       += IncrementClock;
            _interruptHandler.PushProgramCounter   += () => { Push(_pc); };
            _interruptHandler.UpdateProgramCounter += (pc, joypadInterrupt) =>
            {
                _pc = pc;
                if (joypadInterrupt)
                {
                    _stopped = false;
                }
            };

            MessageBus.Instance.OnRequestInterrupt += i => _interruptHandler.RequestInterrupt(i);

            InitInstructions();
        }
Exemple #3
0
 public InterruptHandler(MMU mmu)
 {
     _mmu = mmu;
 }