+ if (kb_hook_enabled) {
+ unsigned char result = (unsigned int)read8((uint32_t)address);
+ if (address == CIAAICR) {
+ if (get_num_kb_queued() && (!send_keypress || send_keypress == 1)) {
+ result |= 0x08;
+ if (!send_keypress)
+ send_keypress = 1;
+ }
+ if (send_keypress == 2) {
+ result |= 0x02;
+ send_keypress = 0;
+ }
+ return result;
+ }
+ if (address == CIAADAT) {
+ if (send_keypress) {
+ uint8_t c = 0, t = 0;
+ pop_queued_key(&c, &t);
+ t ^= 0x01;
+ result = ((c << 1) | t) ^ 0xFF;
+ send_keypress = 2;
+ }
+ return result;
+ }
+ }