Exemplo n.º 1
0
        public GameBoyViewModel(IGameBoy gameBoy, IDispatcher dispatcher, IWindow window, 
                                IOpenFileDialogFactory fileDialogFactory, 
                                IKeyboardHandler keyboardHandler)
        {
            _gameBoy = gameBoy;
            _dispatcher = dispatcher;
            _window = window;
            _keyboardHandler = keyboardHandler;
            _keyboardHandler.KeyDown += OnKeyDown;
            _keyboardHandler.KeyUp += OnKeyUp;
            _window.OnClosing += HandleClosing;

            _buttonMapping = new ButtonMapping();

            _memory = new MemoryViewModel(_gameBoy.Memory, "Memory View");
            _cpu = new CPUViewModel(_gameBoy, _dispatcher);

            // TODO(aaecheve): Should this be another function handling this?
            _gameBoy.CPU.BreakpointFound += BreakpointHandler;
            _gameBoy.CPU.InterruptHappened += InterruptHandler;
            _gameBoy.ErrorEvent += _gameBoy_ErrorEvent;

            _interrupt = new InterruptManagerViewModel(_gameBoy, _dispatcher);
            _ioRegisters = new IORegistersManagerViewModel(_gameBoy, _dispatcher);
            _soundChannelInternals = new SoundChannelInternalsViewModel(_gameBoy);
            _display = new DisplayViewModel(_gameBoy, _gameBoy.Display, _gameBoy.Memory, _dispatcher);
            _gameBoyGamePad = new GameBoyGamePadViewModel(_gameBoy, _dispatcher);
            _breakpoints = new BreakpointsViewModel(_gameBoy);
            _dissasemble = new DissasembleViewModel(_breakpoints, _gameBoy);
            _instructionHistogram = new InstructionHistogramViewModel(_gameBoy, _dispatcher);
            _apu = new APUViewModel(_gameBoy, _dispatcher);
            _memoryImage = new MemoryImageViewModel(_gameBoy, _dispatcher);
            _soundRecording = new SoundRecordingViewModel(_gameBoy);
            _controls = new ControlsViewModel(this, _buttonMapping);

            // Gameboy Controller events
            _gameBoyController = new GameBoyContollerViewModel(_gameBoy, fileDialogFactory, _breakpoints);
            _gameBoyController.OnFileLoaded += FileLoadedHandler;
            _gameBoyController.OnStep += StepHandler;
            _gameBoyController.OnRun += RunHandler;
            _gameBoyController.OnPause += PauseHandler;
        }
Exemplo n.º 2
0
        public GameBoyViewModel(IGameBoy gameBoy, IDispatcher dispatcher, IWindow window,
                                IOpenFileDialogFactory fileDialogFactory,
                                IKeyboardHandler keyboardHandler)
        {
            _gameBoy                  = gameBoy;
            _dispatcher               = dispatcher;
            _window                   = window;
            _keyboardHandler          = keyboardHandler;
            _keyboardHandler.KeyDown += OnKeyDown;
            _keyboardHandler.KeyUp   += OnKeyUp;
            _window.OnClosing        += HandleClosing;

            _buttonMapping = new ButtonMapping();

            _memory = new MemoryViewModel(_gameBoy.Memory, "Memory View");
            _cpu    = new CPUViewModel(_gameBoy, _dispatcher);

            // TODO(aaecheve): Should this be another function handling this?
            _gameBoy.CPU.BreakpointFound   += BreakpointHandler;
            _gameBoy.CPU.InterruptHappened += InterruptHandler;
            _gameBoy.ErrorEvent            += _gameBoy_ErrorEvent;

            _interrupt             = new InterruptManagerViewModel(_gameBoy, _dispatcher);
            _ioRegisters           = new IORegistersManagerViewModel(_gameBoy, _dispatcher);
            _soundChannelInternals = new SoundChannelInternalsViewModel(_gameBoy);
            _display              = new DisplayViewModel(_gameBoy, _gameBoy.Display, _gameBoy.Memory, _dispatcher);
            _gameBoyGamePad       = new GameBoyGamePadViewModel(_gameBoy, _dispatcher);
            _breakpoints          = new BreakpointsViewModel(_gameBoy);
            _dissasemble          = new DissasembleViewModel(_breakpoints, _gameBoy);
            _instructionHistogram = new InstructionHistogramViewModel(_gameBoy, _dispatcher);
            _apu            = new APUViewModel(_gameBoy, _dispatcher);
            _memoryImage    = new MemoryImageViewModel(_gameBoy, _dispatcher);
            _soundRecording = new SoundRecordingViewModel(_gameBoy);
            _controls       = new ControlsViewModel(this, _buttonMapping);

            // Gameboy Controller events
            _gameBoyController = new GameBoyContollerViewModel(_gameBoy, fileDialogFactory, _breakpoints);
            _gameBoyController.OnFileLoaded += FileLoadedHandler;
            _gameBoyController.OnStep       += StepHandler;
            _gameBoyController.OnRun        += RunHandler;
            _gameBoyController.OnPause      += PauseHandler;
        }