X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fplus4%2Fcgetc.s;h=0a440312719806b6d833c386c199086c67df9f35;hb=351e0828c6c26965cd18ea934cc4232d7c193413;hp=493bbf1955f33f97d27fb713c5afae024b9723d5;hpb=53dd513176425872128ef26031d00952ef7a0628;p=cc65 diff --git a/libsrc/plus4/cgetc.s b/libsrc/plus4/cgetc.s index 493bbf195..0a4403127 100644 --- a/libsrc/plus4/cgetc.s +++ b/libsrc/plus4/cgetc.s @@ -9,6 +9,9 @@ .include "plus4.inc" +; -------------------------------------------------------------------------- + +.segment "LOWCODE" ; Accesses the ROM - must go into low mem _cgetc: lda KEY_COUNT ; Get number of characters ora FKEY_COUNT ; Or with number of function key chars @@ -42,7 +45,53 @@ L1: lda KEY_COUNT sta TED_CURSLO ; Cursor off sta TED_CURSHI -L2: jsr KBDREAD ; Read char and return in A +L2: sta ENABLE_ROM ; Bank in the ROM + jsr KBDREAD ; Read char and return in A (ROM routine) + sta ENABLE_RAM ; Reenable the RAM ldx #0 rts +; -------------------------------------------------------------------------- +; Make the function keys return function key codes instead of the current +; strings so the program will see and may handle them. +; Undo this change when the program ends + + .constructor initkbd + .destructor donekbd + +.segment "INIT" ; Special init code segment may get overwritten + +.proc initkbd + + ldy #15 +@L1: lda fnkeys,y + sta FKEY_SPACE,y + dey + bpl @L1 + rts + +.endproc + + +.segment "LOWCODE" ; Accesses the ROM - must go into low mem + +.proc donekbd + + ldx #$39 ; Copy the original function keys + sta ENABLE_ROM ; Bank in the ROM +@L1: lda FKEY_ORIG,x + sta FKEY_SPACE,x + dex + bpl @L1 + sta ENABLE_RAM ; Bank out the ROM + rts + +.endproc + + +; Function key table, readonly + +.rodata +fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01 + .byte 133, 137, 134, 138, 135, 139, 136, 140 +