/// <summary> /// Writes a byte of data to a specified port address /// Because of the port decoding, multiple devices can be written to /// </summary> public override void WritePort(ushort port, byte value) { BitArray portBits = new BitArray(BitConverter.GetBytes(port)); BitArray dataBits = new BitArray(BitConverter.GetBytes(value)); byte portUpper = (byte)(port >> 8); byte portLower = (byte)(port & 0xff); var devs = DecodeOUTPort(port); foreach (var d in devs) { if (d == PortDevice.GateArray) { GateArray.WritePort(port, value); } else if (d == PortDevice.RAMManagement) { // not present in the unexpanded CPC464 } else if (d == PortDevice.CRCT) { CRCT.WritePort(port, value); } else if (d == PortDevice.ROMSelect) { } else if (d == PortDevice.Printer) { } else if (d == PortDevice.PPI) { PPI.WritePort(port, value); } else if (d == PortDevice.Expansion) { } } return; }
/// <summary> /// Writes a byte of data to a specified port address /// Because of the port decoding, multiple devices can be written to /// </summary> /// <param name="port"></param> /// <param name="value"></param> public override void WritePort(ushort port, byte value) { BitArray portBits = new BitArray(BitConverter.GetBytes(port)); BitArray dataBits = new BitArray(BitConverter.GetBytes(value)); byte portUpper = (byte)(port >> 8); byte portLower = (byte)(port & 0xff); var devs = DecodeOUTPort(port); foreach (var d in devs) { if (d == PortDevice.GateArray) { GateArray.WritePort(port, value); } else if (d == PortDevice.RAMManagement) { if (value.Bit(7) && value.Bit(6)) { RAMConfig = value & 0x07; // additional 64K bank index var b64 = value & 0x38; } } else if (d == PortDevice.CRCT) { CRCT.WritePort(port, value); } else if (d == PortDevice.ROMSelect) { UpperROMPosition = value; } else if (d == PortDevice.Printer) { } else if (d == PortDevice.PPI) { PPI.WritePort(port, value); } else if (d == PortDevice.Expansion) { if (!port.Bit(7)) { // FDC if (port.Bit(8) && !port.Bit(0) || port.Bit(8) && port.Bit(0)) { // FDC data register UPDDiskDevice.WriteData(value); } if ((!port.Bit(8) && !port.Bit(0)) || (!port.Bit(8) && port.Bit(0))) { // FDC motor UPDDiskDevice.Motor(value); } } } } return; }