     
     internal override func readByte(position: UInt8) -> UInt8 {
         switch position {
-        case kDataPortRegisterAAddress:
+        case 0x00:
             //TODO: implement bit 7-8
-            return (PRA | ~DDRA) & 0x3F
+            return (pra | ~ddra) & 0x3F
         default:
             return super.readByte(position)
         }

    
    internal override func readByte(position: UInt8) -> UInt8 {
        switch position {
        case kDataPortRegisterAAddress:
            //TODO: Real joystick
            return 0xFF
        case kDataPortRegisterBAddress:
            //TODO: Actually read from kDataPortRegisterAAddress because of joystick that might change bits
            return keyboard.readMatrix(PRA) & PRB
        default:
            return super.readByte(position)
        }

    
    internal func writeByte(position: UInt8, byte: UInt8) {
        switch position {
        case 0x02:
            ddra = byte
        case 0x03:
            ddrb = byte
        case 0x04:
            latchA = (latchA & 0xFF00) | UInt16(byte)
        case 0x05:
            latchA = (UInt16(byte) << 8) | (latchA & 0xFF);
        case 0x0D:
            if ((byte & 0x80) != 0) {
                imr |= (byte & 0x1F)
            } else {
                imr &= ~(byte & 0x1F)
            }
        case 0x0E:
            // bit4: force load
            if ((byte & 0x10) != 0) {
                counterA = latchA
            }
            //TODO: more timer stuff
            cra = byte
        case 0x0F:
            //TODO: Timer stuff
            crb = byte
        default:
            println("todo cia write address: " + String(position, radix: 16, uppercase: true))
            abort()
