Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Intel8080Registers"/> class.
        /// </summary>
        /// <param name="initialState">The initial state.</param>
        /// <param name="platformConfig">The platform configuration.</param>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public Intel8080Registers(Intel8080RegisterState initialState, IPlatformConfig platformConfig)
        {
            _initialState = initialState;

            IFlagsRegister flagsRegister;

            switch (platformConfig.CpuMode)
            {
            case CpuMode.Intel8080:
            case CpuMode.Z80:
                flagsRegister = new Intel8080FlagsRegister();
                break;

            case CpuMode.GameBoy:
                flagsRegister = new GameBoyFlagsRegister();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            GeneralPurposeRegisters      = new GeneralPurposeRegisterSet();
            AccumulatorAndFlagsRegisters = new AccumulatorAndFlagsRegisterSet(flagsRegister);
            Reset();
        }
Beispiel #2
0
        /// <summary>Override to add registrations to the container.</summary>
        /// <remarks>
        /// Note that the ContainerBuilder parameter is unique to this module.
        /// </remarks>
        /// <param name="builder">The builder through which components can be
        /// registered.</param>
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterInstance(_gameBoyConfig);
            builder.RegisterType <InterruptFlagsRegister>().As <IInterruptFlagsRegister>().As <IRegister>().InZ80Scope();
            builder.RegisterType <HardwareRegisters>().As <IHardwareRegisters>().InZ80Scope();

            // Named registers
            builder.RegisterType <InterruptEnableRegister>().As <IInterruptEnableRegister>().InZ80Scope();
            builder.RegisterType <JoyPad>().As <IJoyPadRegister>().As <IJoyPad>().InZ80Scope();
            builder.RegisterType <SyncSerialPort>().As <ISerialPort>().As <ISerialPortRegister>().InZ80Scope();
            builder.RegisterType <MemoryBankController1>().As <IMemoryBankController>().InZ80Scope();
            builder.RegisterType <TimerControlRegister>().As <ITimerControlRegister>().InZ80Scope();
            builder.RegisterType <TimerRegisters>().As <ITimerRegisters>().InZ80Scope();

            // GPU registers.
            builder.RegisterType <GpuRegisters>().As <IGpuRegisters>().InZ80Scope();
            builder.RegisterType <LcdControlRegister>().As <ILcdControlRegister>().InZ80Scope();
            builder.RegisterType <CurrentScanlineRegister>().As <ICurrentScanlineRegister>().InZ80Scope();
            builder.RegisterType <LcdMonochromePaletteRegister>().As <ILcdMonochromePaletteRegister>().InZ80Scope();
            builder.RegisterType <LcdStatusRegister>().As <ILcdStatusRegister>().InZ80Scope();

            // Un-named registers
            builder.RegisterType <LazyDividerRegister>().As <IRegister>().InZ80Scope();
            builder.RegisterType <LcdOamDmaTransferRegister>().As <IRegister>().InZ80Scope();

            // Peripherals, no IO mapped peripherals on GB, only memory mapped
            builder.RegisterType <GameBoyMemoryMappedIo>().As <IPeripheral>().InZ80Scope();

            // GPU
            builder.RegisterType <Gpu>().As <IGpu>().InZ80Scope();

            // Initial state.
            var initialRegisterState =
                new Intel8080RegisterState(new GeneralPurposeRegisterState(0x00, 0x13, 0x00, 0xd8, 0x01, 0x4d),
                                           new AccumulatorAndFlagsRegisterState(0x01, 0xb0),
                                           0xfffe,
                                           0x0100,
                                           true,
                                           true,
                                           InterruptMode.InterruptMode0);

            builder.RegisterInstance(initialRegisterState);
        }