Beispiel #1
0
        /// <summary>
        /// Signs that the device has been attached to the Spectrum virtual machine
        /// </summary>
        public void OnAttachedToVm(ISpectrumVm hostVm)
        {
            HostVm = hostVm;
            var kempstonInfo = HostVm.GetDeviceInfo <IKempstonDevice>();

            _kempstonProvider = (IKempstonProvider)kempstonInfo?.Provider;
        }
Beispiel #2
0
        /// <summary>
        /// Signs that the device has been attached to the Spectrum virtual machine
        /// </summary>
        public void OnAttachedToVm(ISpectrumVm hostVm)
        {
            HostVm = hostVm;
            var screenInfo = hostVm.GetDeviceInfo <IScreenDevice>();

            ScreenConfiguration = hostVm.ScreenConfiguration;
            _pixelRenderer      = (IScreenFrameProvider)screenInfo.Provider ?? new NoopPixelRenderer();
            _memoryDevice       = hostVm.MemoryDevice;
            _contentionType     = hostVm.MemoryConfiguration.ContentionType;
            InitializeScreenRenderingTactTable();
            _flashPhase = false;
            FrameCount  = 0;

            // --- Calculate refresh rate related values
            RefreshRate       = (decimal)hostVm.BaseClockFrequency / ScreenConfiguration.ScreenRenderingFrameTactCount;
            FlashToggleFrames = (int)Math.Round(RefreshRate / 2);

            // --- Calculate color conversion table
            _flashOffColors = new int[0x200];
            _flashOnColors  = new int[0x200];

            for (var attr = 0; attr < 0x100; attr++)
            {
                var ink   = (attr & 0x07) | ((attr & 0x40) >> 3);
                var paper = ((attr & 0x38) >> 3) | ((attr & 0x40) >> 3);
                _flashOffColors[attr]         = paper;
                _flashOffColors[0x100 + attr] = ink;
                _flashOnColors[attr]          = (attr & 0x80) != 0 ? ink : paper;
                _flashOnColors[0x100 + attr]  = (attr & 0x80) != 0 ? paper : ink;
            }

            _screenWidth = hostVm.ScreenDevice.ScreenConfiguration.ScreenWidth;
            _pixelBuffer = new byte[_screenWidth * hostVm.ScreenDevice.ScreenConfiguration.ScreenLines];
        }
Beispiel #3
0
        /// <summary>
        /// Signs that the device has been attached to the Spectrum virtual machine
        /// </summary>
        public void OnAttachedToVm(ISpectrumVm hostVm)
        {
            HostVm = hostVm;
            var keyboardInfo = HostVm.GetDeviceInfo <IKeyboardDevice>();

            _keyboardProvider = (IKeyboardProvider)keyboardInfo?.Provider;
            _keyboardProvider?.SetKeyStatusHandler(SetStatus);
        }