Ejemplo n.º 1
0
 /// <summary>
 /// Handles the read from the port
 /// </summary>
 /// <param name="addr">Full port address</param>
 /// <param name="readValue">The value read from the port</param>
 /// <returns>True, if read handled; otherwise, false</returns>
 public override bool HandleRead(ushort addr, out byte readValue)
 {
     readValue = _keyboardDevice.GetLineStatus((byte)(addr >> 8));
     if (_tapeDevice.IsInLoadMode)
     {
         var earBit = _tapeDevice.GetEarBit(_cpu.Tacts);
         if (!earBit)
         {
             readValue = (byte)(readValue & 0b1011_1111);
         }
     }
     else
     {
         var bit4Sensed = _bit4LastValue;
         if (!bit4Sensed)
         {
             var chargeTime = _bit4ChangedFrom1 - _bit4ChangedFrom0;
             if (chargeTime > 0)
             {
                 var delay = Math.Min(chargeTime * 4, 2800);
                 bit4Sensed = _cpu.Tacts - _bit4ChangedFrom1 < delay;
             }
         }
         var bit6Value = (_bit3LastValue || bit4Sensed) ? 0b0100_0000 : 0x00;
         if (_bit3LastValue && !bit4Sensed && _isUla3)
         {
             bit6Value = 0x00;
         }
         readValue = (byte)((readValue & 0b1011_1111) | bit6Value);
     }
     return(true);
 }
        /// <summary>
        /// Handles the read from the port
        /// </summary>
        /// <param name="addr">Full port address</param>
        /// <param name="readValue">The value read from the port</param>
        /// <returns>True, if read handled; otherwise, false</returns>
        public override bool HandleRead(ushort addr, out byte readValue)
        {
            readValue = _keyboardDevice.GetLineStatus((byte)(addr >> 8));
            var earBit = _tapeDevice.GetEarBit(_cpu.Tacts);

            if (!earBit)
            {
                readValue = (byte)(readValue & 0b1011_1111);
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the port with the specified address
        /// </summary>
        /// <param name="addr">Port address</param>
        /// <returns>Byte read from the port</returns>
        public byte OnReadPort(ushort addr)
        {
            if ((addr & 0x0001) != 0)
            {
                return(0xFF);
            }

            var portBits = _keyboardDevice.GetLineStatus((byte)(addr >> 8));
            var earBit   = _tapeDevice.GetEarBit(_cpu.Tacts);

            if (!earBit)
            {
                portBits = (byte)(portBits & 0b1011_1111);
            }
            return(portBits);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the port with the specified address
        /// </summary>
        /// <param name="addr">Port address</param>
        /// <returns>Byte read from the port</returns>
        public override byte OnReadPort(ushort addr)
        {
            // --- Handle I/O contention
            ContentionWait(addr);

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

            var portBits = _keyboardDevice.GetLineStatus((byte)(addr >> 8));
            var earBit   = _tapeDevice.GetEarBit(Cpu.Tacts);

            if (!earBit)
            {
                portBits = (byte)(portBits & 0b1011_1111);
            }
            return(portBits);
        }