예제 #1
0
        /// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary>
        public Spectrum48(
            IRomProvider romProvider,
            IClockProvider clockProvider,
            IKeyboardProvider keyboardProvider,
            IScreenFrameProvider pixelRenderer,
            IEarBitFrameProvider earBitFrameProvider   = null,
            ITapeContentProvider loadContentProvider   = null,
            ISaveToTapeProvider tapeSaveToTapeProvider = null)
        {
            // --- Init the CPU
            MemoryDevice  = new Spectrum48MemoryDevice();
            PortDevice    = new Spectrum48PortDevice();
            Cpu           = new Z80Cpu(MemoryDevice, PortDevice);
            OsInitialized = false;

            // --- Setup the clock
            Clock = clockProvider;

            // --- Set up Spectrum devices
            BorderDevice    = new BorderDevice();
            ScreenDevice    = new Spectrum48ScreenDevice(pixelRenderer);
            BeeperDevice    = new BeeperDevice(earBitFrameProvider);
            KeyboardDevice  = new KeyboardDevice(keyboardProvider);
            InterruptDevice = new InterruptDevice(InterruptTact);
            TapeDevice      = new TapeDevice(loadContentProvider, tapeSaveToTapeProvider);

            // --- Carry out frame calculations

            ResetUlaTact();
            _frameTacts             = ScreenDevice.ScreenConfiguration.UlaFrameTactCount;
            PhysicalFrameClockCount = Clock.GetFrequency() / (double)ClockFrequeny * _frameTacts;
            FrameCount      = 0;
            Overflow        = 0;
            _frameCompleted = true;

            // --- Collect Spectrum devices
            _spectrumDevices.Add(MemoryDevice);
            _spectrumDevices.Add(PortDevice);
            _spectrumDevices.Add(BorderDevice);
            _spectrumDevices.Add(ScreenDevice);
            _spectrumDevices.Add(BeeperDevice);
            _spectrumDevices.Add(KeyboardDevice);
            _spectrumDevices.Add(InterruptDevice);
            _spectrumDevices.Add(TapeDevice);

            // --- Now, prepare devices to find each other
            foreach (var device in _spectrumDevices)
            {
                device.OnAttachedToVm(this);
            }

            // --- Prepare bound devices
            _frameBoundDevices = _spectrumDevices
                                 .OfType <IFrameBoundDevice>()
                                 .ToList();
            _cpuBoundDevices = _spectrumDevices
                               .OfType <ICpuOperationBoundDevice>()
                               .ToList();

            DebugInfoProvider = new SpectrumDebugInfoProvider();

            // --- Init the ROM
            InitRom(romProvider, "ZXSpectrum48");
        }
예제 #2
0
 /// <summary>
 /// Initializes the tape device for the specified host VM
 /// </summary>
 /// <param name="contentProvider">Tape content provider</param>
 /// <param name="saveToTapeProvider">Save provider for the tape</param>
 public TapeDevice(ITapeContentProvider contentProvider, ISaveToTapeProvider saveToTapeProvider)
 {
     ContentProvider    = contentProvider;
     SaveToTapeProvider = saveToTapeProvider;
 }