]> git.sur5r.net Git - cc65/blobdiff - libsrc/plus4/cgetc.s
no TGI_ERR_NO_MEM or TGI_ERR_NO_IOCB anymore: replaced by TGI_ERR_NO_RES
[cc65] / libsrc / plus4 / cgetc.s
index c486767456bc093334d6b6dca3a094af5f496585..0a440312719806b6d833c386c199086c67df9f35 100644 (file)
@@ -9,9 +9,10 @@
 
                .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
                bne     L2              ; Jump if there are already chars waiting
@@ -44,7 +45,9 @@ 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
 
@@ -56,6 +59,8 @@ L2:           jsr     KBDREAD         ; Read char and return in A
        .constructor    initkbd
        .destructor     donekbd
 
+.segment        "INIT"          ; Special init code segment may get overwritten
+
 .proc  initkbd
 
        ldy     #15
@@ -68,13 +73,17 @@ L2:         jsr     KBDREAD         ; Read char and return in A
 .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