diff --git a/STATUS.md b/STATUS.md index 40464b97..28523aaa 100644 --- a/STATUS.md +++ b/STATUS.md @@ -134,7 +134,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | `$FFDB` | | `SETTIM` | DONE | | | `$FFDE` | | `RDTIM` | DONE | | | `$FFE1` | `$F6ED` | `STOP` | DONE | | -| `$FFE4` | `$F13E` | `GETIN` | PARTIAL | only some devices supported | +| `$FFE4` | `$F13E` | `GETIN` | PARTIAL | only keyaboard supported | | `$FFE7` | `$F32F` | `CLALL` | DONE | | | `$FFEA` | | `UDTIM` | DONE | | | `$FFED` | | `SCREEN` | DONE | | diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index 40b293f5..89242f1b 100644 Binary files a/bin/basic_generic.rom and b/bin/basic_generic.rom differ diff --git a/bin/basic_mega65.rom b/bin/basic_mega65.rom index d74a3c0a..5fff525b 100644 Binary files a/bin/basic_mega65.rom and b/bin/basic_mega65.rom differ diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom index b63c2cb9..36620ad7 100644 Binary files a/bin/basic_ultimate64.rom and b/bin/basic_ultimate64.rom differ diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom index 4c60712c..15295fdd 100644 Binary files a/bin/kernal_generic.rom and b/bin/kernal_generic.rom differ diff --git a/bin/kernal_mega65.rom b/bin/kernal_mega65.rom index e7c74f77..c8395834 100644 Binary files a/bin/kernal_mega65.rom and b/bin/kernal_mega65.rom differ diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom index 5caf1cfb..a69028ef 100644 Binary files a/bin/kernal_ultimate64.rom and b/bin/kernal_ultimate64.rom differ diff --git a/c64/kernal/f13e.getin.s b/c64/kernal/f13e.getin.s index 5eefc0ac..be8e3faa 100644 --- a/c64/kernal/f13e.getin.s +++ b/c64/kernal/f13e.getin.s @@ -8,26 +8,9 @@ // CPU registers that has to be preserved (see [RG64]): .X, .Y // -// XXX currently does not preserve registers, to be fixed! GETIN: - // Wait for a key - lda NDX - bne !+ + // XXX this should be a dispatcher for several different devices! - // Nothing in keyboard buffer to read - sec - lda #$00 - rts - -!: - lda KEYD - pha - - jsr pop_keyboard_buffer - - pla - clc - - rts + jmp read_kb_buf diff --git a/c64/kernal/interrupts/udtim.s b/c64/kernal/interrupts/udtim.s index 34528613..f9d4fa99 100644 --- a/c64/kernal/interrupts/udtim.s +++ b/c64/kernal/interrupts/udtim.s @@ -26,16 +26,22 @@ udtim_update_stkey: // entry to be used when interrupts are disabled // Another action we have to perform is to copy the last row of keyboard to RAM, // so that various routines can detect the STOP key press +#if CONFIG_KEYBOARD_C128 + lda #$FF + sta VIC_XSCAN // disconnect the extra C128 keys +#endif + lda #$7F sta CIA1_PRA // select the last row (bit to 0) lda CIA1_PRB // read the row sta STKEY - // Finish by disconnecting the keyboard, this will prevent - // interference when scanning joystick in port 1 + // Leave the CIA configured this way. It would be far better to disconnect + // the keyboard at this point, but certain software (mainly intros) is + // unable to, for example, read the space bar status. - jmp keyboard_disconnect + rts udtim_clock_rollover: diff --git a/c64/kernal/keyboard/f142.interop b/c64/kernal/keyboard/f142.interop new file mode 100644 index 00000000..73019c17 --- /dev/null +++ b/c64/kernal/keyboard/f142.interop @@ -0,0 +1,4 @@ +$F142 is a well-known address of keyboard reading routine, described for example here: +- http://sta.c64.org/cbm64kbdfunc.html + +It is used for eexample by a music eeditor here: https://github.com/martinpiper/C64Public/blob/master/MusicEditor/GetKey.a diff --git a/c64/kernal/keyboard/f142.read_kb_buf.s b/c64/kernal/keyboard/f142.read_kb_buf.s new file mode 100644 index 00000000..8b72b9e2 --- /dev/null +++ b/c64/kernal/keyboard/f142.read_kb_buf.s @@ -0,0 +1,30 @@ + +// +// Well-known Kernal routine, described in: +// +// - http://sta.c64.org/cbm64kbdfunc.html +// + + +read_kb_buf: + + // Check for a key + lda NDX + bne !+ + + // Nothing in keyboard buffer to read + sec + rts + +!: + lda KEYD + pha + phy_trash_a + + jsr pop_keyboard_buffer + + ply_trash_a + pla + clc + + rts diff --git a/c64/kernal/keyboard/keyboard_disconnect.s b/c64/kernal/keyboard/keyboard_disconnect.s index 37f4e973..1fdae023 100644 --- a/c64/kernal/keyboard/keyboard_disconnect.s +++ b/c64/kernal/keyboard/keyboard_disconnect.s @@ -2,6 +2,10 @@ // // Helper routine - disconnects the keyboard from CIA1_PRB, // leaves $FF in .X (behavior needed in some places) +// + + +#if !CONFIG_LEGACY_SCNKEY keyboard_disconnect: @@ -13,3 +17,6 @@ keyboard_disconnect: #endif rts + + +#endif diff --git a/c64/kernal/keyboard/pop_keyboard_buffer.s b/c64/kernal/keyboard/pop_keyboard_buffer.s index e540a221..6f3b172b 100644 --- a/c64/kernal/keyboard/pop_keyboard_buffer.s +++ b/c64/kernal/keyboard/pop_keyboard_buffer.s @@ -2,7 +2,9 @@ // Pop key out of keyboard buffer // Disable interrupts while reading from keyboard buffer // so that no race conditions can occur - +// +// CPU registers that has to be preserved: .X +// pop_keyboard_buffer: diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index a3fb99c5..e35baaf2 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -53,7 +53,6 @@ SCNKEY: #endif // Retrieve SHIFT / VENDOR / CTRL status - // Use .X to detect 2 or more keys pressed (should be $FF now) ldy #(__kb_matrix_bucky_confmask_end - kb_matrix_bucky_confmask - 1) scnkey_bucky_loop: @@ -154,7 +153,7 @@ scnkey_matrix_loop_inner: !: dey bpl scnkey_matrix_loop_inner - bmi scnkey_no_keys // branch always, multiple keys must have been pressed + bmi scnkey_no_keys // branch always, multiple keys must have been pressed scnkey_matrix_loop_next: dex bpl scnkey_matrix_loop