From bb2b4981b877bd152143159c8465ef41c946ad5d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 13 Oct 2019 20:39:05 +0200 Subject: [PATCH] new SCNKEY is functionning, but probably needs different matrix format --- STATUS.md | 6 ++--- c64/kernal/e50a.plot.s | 4 +-- c64/kernal/keyboard/scnkey.s | 49 +++++++++++++++++++++++++++++++----- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/STATUS.md b/STATUS.md index 6c5ebc5b..4195a6ba 100644 --- a/STATUS.md +++ b/STATUS.md @@ -62,7 +62,7 @@ Note: vectors at `$0300` are not supported yet - for now only the locations belo | `(00306)` | `$A71A` | `QPLOP` | NOT DONE | some implementation exists, but not connected here | | `(00308)` | `$A7E4` | `GONE` | NOT DONE | some implementation exists, but not connected here | | `(0030A)` | `$AE86` | `EVAL` | NOT DONE | some implementation exists, but not connected here | -| `($A000)` | | cold start | PARTIAL | | +| `($A000)` | `$E394` | cold start | PARTIAL | | | `($A002)` | | warm start | PARTIAL | |
@@ -109,7 +109,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | `$FF96` | | `TKSA` | DONE | | | `$FF99` | | `MEMTOP` | DONE | | | `$FF9C` | | `MEMBOT` | DONE | | -| `$FF9F` | | `SCNKEY` | DONE | could be better integrated with ROM (aliases) | +| `$FF9F` | | `SCNKEY` | PARTIAL | future complete version has compatibility problems | | `$FFA2` | | `SETTMO` | DONE | | | `$FFA5` | | `ACPTR` | DONE | | | `$FFA8` | | `CIOUT` | DONE | | @@ -138,7 +138,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | `$FFE7` | `$F32F` | `CLALL` | DONE | | | `$FFEA` | | `UDTIM` | DONE | | | `$FFED` | | `SCREEN` | DONE | | -| `$FFF0` | `$E50A` | `PLOT` | PARTIAL | | +| `$FFF0` | `$E50A` | `PLOT` | DONE | | | `$FFF3` | | `IOBASE` | DONE | | | `($FFFA)` | | NMI vec | PARTIAL | | | `($FFFC)` | | RESET vec | PARTIAL | | diff --git a/c64/kernal/e50a.plot.s b/c64/kernal/e50a.plot.s index ae9d32ff..a36dfc08 100644 --- a/c64/kernal/e50a.plot.s +++ b/c64/kernal/e50a.plot.s @@ -17,16 +17,16 @@ PLOT: // - 'Duotris' game calls $E50C during startup screen initialization plot_set: + sty PNTR stx TBLX jsr screen_calculate_line_pointer - // XXX cursor blink might need to be handled too - // FALLTROUGH to save one byte on RTS plot_get: + ldy PNTR ldx TBLX rts diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index 099ca857..a2316b34 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -20,6 +20,7 @@ // - MODE - flag, whether charset toggle (SHIFT+VENDOR) is allowed +// XXX add RPTFLG support // XXX add Commodore 128 keyboard support // XXX add Commodore 65 keybopard support // XXX add support for using joystick to move sursor keys @@ -58,7 +59,7 @@ scnkey_bucky_loop: sta CIA1_PRA lda kb_matrix_bucky_testmask, y and CIA1_PRB - bne !+ // not pressed + bne !+ // not pressed lda SHFLAG ora kb_matrix_bucky_shflag, y sta SHFLAG @@ -68,9 +69,14 @@ scnkey_bucky_loop: // Set KEYTAB vector - jsr scnkey_via_keylog // XXX for some CPUs we have indirect jsr + jsr via_keylog // XXX for some CPUs we have indirect jsr + + // Check if we have free space in the keyboard buffer + + lda NDX + cmp XMAX + bcs scnkey_no_keys // no space in keyboard buffer - do not waste time - // XXX check if there is space in keyboard buffer // XXX check for joystick activity // Scan the keyboard matrix @@ -113,7 +119,7 @@ scnkey_matrix_loop_next: scnkey_no_keys: - // XXX + // Mark no key press lda #$40 // XXX adapt value for C128 and C65 keyboards sta LSTX @@ -122,18 +128,49 @@ scnkey_no_keys: scnkey_got_key: // .X should now contain the key offset in matrix pointed by KEYTAB + cpx LSTX + beq scnkey_handle_repeat // branch if the same key as previously + stx LSTX + + // Reset key repeat counters - see [CM64] page 58 + + lda #$04 + sta KOUNT + lda #$10 + sta DELAY + + // FALLTROUGH + +scnkey_output_key: + + // Output PETSCII code to the keyboard buffer + + txa // XXX switch registers!!! + tay + + lda (KEYTAB), y + beq scnkey_no_keys // branch if we have no PETSCII code for this key + ldy NDX + sta KEYD, y + inc NDX + + rts + +scnkey_handle_repeat: + // Handle repeat timer - .break lda KOUNT beq !+ dec KOUNT !: // XXX + rts -scnkey_via_keylog: +via_keylog: jmp (KEYLOG) + #endif // no CONFIG_SCNKEY_TWW_CTR