示例#1
0
 /// <summary>
 /// Sends a byte to the port with the specified address
 /// </summary>
 /// <param name="addr">Port address</param>
 /// <param name="data">Data to write to the port</param>
 /// <returns>Byte read from the memory</returns>
 public void OnWritePort(ushort addr, byte data)
 {
     if ((addr & 0x0001) == 0)
     {
         _borderDevice.BorderColor = data & 0x07;
         _beeperDevice.ProcessEarBitValue(false, (data & 0x10) != 0);
         _tapeDevice.ProcessMicBit((data & 0x08) != 0);
     }
 }
        /// <summary>
        /// Handles Spectrum 48 ports
        /// </summary>
        /// <param name="addr">Port address</param>
        /// <param name="data">Data to write to the port</param>
        public void HandleSpectrum48PortWrites(ushort addr, byte data)
        {
            // --- Handle I/O contention
            ContentionWait(addr);

            // --- Carry out the I/O write operation
            if ((addr & 0x0001) != 0)
            {
                return;
            }

            _screenDevice.BorderColor = data & 0x07;
            _beeperDevice.ProcessEarBitValue(false, (data & 0x10) != 0);
            _tapeDevice.ProcessMicBit((data & 0x08) != 0);
        }
        /// <summary>
        /// Sends a byte to the port with the specified address
        /// </summary>
        /// <param name="addr">Port address</param>
        /// <param name="data">Data to write to the port</param>
        /// <returns>Byte read from the memory</returns>
        public override void OnWritePort(ushort addr, byte data)
        {
            // --- Handle I/O contention
            base.OnReadPort(addr);

            // --- Carry out the I/O write operation
            if ((addr & 0x0001) != 0)
            {
                return;
            }

            _screenDevice.BorderColor = data & 0x07;
            _beeperDevice.ProcessEarBitValue(false, (data & 0x10) != 0);
            _tapeDevice.ProcessMicBit((data & 0x08) != 0);
        }
        /// <summary>
        /// Writes the specified value to the port
        /// </summary>
        /// <param name="addr">Full port address</param>
        /// <param name="writeValue">Value to write to the port</param>
        public override void HandleWrite(ushort addr, byte writeValue)
        {
            _screenDevice.BorderColor = writeValue & 0x07;
            _beeperDevice.ProcessEarBitValue(false, (writeValue & 0x10) != 0);
            _tapeDevice.ProcessMicBit((writeValue & 0x08) != 0);

            // --- Set the lates value of bit 3
            _bit3LastValue = (writeValue & 0x08) != 0;

            // --- Manage bit 4 value
            var curBit4 = (writeValue & 0x10) != 0;

            if (!_bit4LastValue && curBit4)
            {
                // --- Bit 4 goers from0 to 1
                _bit4ChangedFrom0 = _cpu.Tacts;
                _bit4LastValue    = true;
            }
            else if (_bit4LastValue && !curBit4)
            {
                _bit4ChangedFrom1 = _cpu.Tacts;
                _bit4LastValue    = false;
            }
        }
 /// <summary>
 /// Writes the specified value to the port
 /// </summary>
 /// <param name="addr">Full port address</param>
 /// <param name="writeValue">Value to write to the port</param>
 public override void HandleWrite(ushort addr, byte writeValue)
 {
     _screenDevice.BorderColor = writeValue & 0x07;
     _beeperDevice.ProcessEarBitValue(false, (writeValue & 0x10) != 0);
     _tapeDevice.ProcessMicBit((writeValue & 0x08) != 0);
 }