]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm610/kscnkey.s
no TGI_ERR_NO_MEM or TGI_ERR_NO_IOCB anymore: replaced by TGI_ERR_NO_RES
[cc65] / libsrc / cbm610 / kscnkey.s
index ce9851731ee6553a725bf287828077e0ea6ad922..7e637540e41a8e8adb123b02d488644b39721a86 100644 (file)
@@ -4,22 +4,23 @@
 ; Keyboard polling stuff for the 610.
 ;
 
-       .export         SCNKEY
-       .importzp       tpi2, ktab1, ktab2, ktab3, ktab4
+       .export         scnkey
+       .importzp       tpi2, ktab1, ktab2, ktab3, ktab4
+        .importzp       keyidx, keybuf, keyscanbuf, keysave, modkey, norkey
+        .importzp       graphmode, lastidx, rptdelay, rptcount
 
-       .include        "cbm610.inc"
+       .include        "cbm610.inc"
 
-
-.proc  SCNKEY
+.proc  scnkey
 
         lda     #$FF
-        sta     ModKey
-        sta     NorKey
+        sta     modkey
+        sta     norkey
         lda    #$00
-       sta     KbdScanBuf
-       ldy     #tpiPortB
+       sta     keyscanbuf
+       ldy     #TPI::PRB
        sta     (tpi2),y
-       ldy     #tpiPortA
+       ldy     #TPI::PRA
        sta     (tpi2),y
         jsr     Poll
         and     #$3F
         jmp     NoKey
 
 L1:    lda     #$FF
-       ldy     #tpiPortA
-       sta     (tpi2),y
+       ldy     #TPI::PRA
+       sta     (tpi2),y
         asl     a
-       ldy     #tpiPortB
-       sta     (tpi2),y
+       ldy     #TPI::PRB
+       sta     (tpi2),y
         jsr     Poll
         pha
-        sta     ModKey
+        sta     modkey
         ora     #$30
-        bne     L3             ; Branch always
+        bne     L3             ; Branch always
 
 L2:    jsr     Poll
 L3:    ldx     #$05
        ldy     #$00
 L4:    lsr     a
         bcc     L5
-        inc    KbdScanBuf
+        inc    keyscanbuf
         dex
         bpl     L4
         sec
-       ldy     #tpiPortB
+       ldy     #TPI::PRB
        lda     (tpi2),y
        rol     a
-       sta     (tpi2),y
-               ldy     #tpiPortA
+       sta     (tpi2),y
+               ldy     #TPI::PRA
        lda     (tpi2),y
-       rol     a
+       rol     a
        sta     (tpi2),y
         bcs     L2
         pla
-        bcc     NoKey          ; Branch always
+        bcc     NoKey          ; Branch always
 
-L5:    ldy     KbdScanBuf
-       sty     NorKey
+L5:    ldy     keyscanbuf
+       sty     norkey
         pla
         asl     a
         asl     a
@@ -69,76 +70,76 @@ L5: ldy     KbdScanBuf
         bcc     L6
         bmi     L7
         lda     (ktab2),y              ; Shifted normal key
-        ldx     GrafMode
+        ldx     graphmode
         beq     L8
         lda     (ktab3),y              ; Shifted key in graph mode
         bne     L8
 
 L6:    lda     (ktab4),y               ; Key with ctrl pressed
        bne     L8
-L7:    lda     (ktab1),y               ; Normal key
-L8:    tax
+L7:    lda     (ktab1),y               ; Normal key
+L8:    tax
        cpx     #$FF                    ; Valid key?
         beq     Done
-        cpy     LastIndex
+        cpy     lastidx
         beq     Repeat
         ldx     #$13
-        stx     RepeatDelay
-        ldx     KeyIndex
+        stx     rptdelay
+        ldx     keyidx
         cpx     #$09
         beq     NoKey
         cpy     #$59
         bne     PutKey
         cpx     #$08
         beq     NoKey
-        sta     KeyBuf,x
+        sta     keybuf,x
         inx
         bne     PutKey
 
 NoKey: ldy     #$FF
-Done:          sty     LastIndex
+Done:          sty     lastidx
 End:   lda     #$7F
-       ldy     #tpiPortA
+       ldy     #TPI::PRA
        sta     (tpi2),y
-       ldy     #tpiPortB
+       ldy     #TPI::PRB
        lda     #$FF
        sta     (tpi2),y
         rts
 
-Repeat:        dec     RepeatDelay
+Repeat:        dec     rptdelay
         bpl     End
-        inc     RepeatDelay
-        dec     RepeatCount
+        inc     rptdelay
+        dec     rptcount
         bpl     End
-        inc     RepeatCount
-        ldx     KeyIndex
+        inc     rptcount
+        ldx     keyidx
         bne     End
 
-PutKey:        sta     KeyBuf,x
+PutKey:        sta     keybuf,x
         inx
-        stx     KeyIndex
+        stx     keyidx
         ldx     #$03
-        stx     RepeatCount
+        stx     rptcount
         bne     Done
 
 .endproc
 
-
 ; Poll the keyboard port until it's stable
+; This code goes into page 2, since it is included in every program and
+; there's space left in p2
+
+.segment        "PAGE2"
 
 .proc  Poll
-       ldy     #tpiPortC
+       ldy     #TPI::PRC
 L1:    lda     (tpi2),y
-       sta     KeySave
+       sta     keysave
        lda     (tpi2),y
-       cmp     KeySave
+       cmp     keysave
        bne     L1
        rts
 .endproc
 
 
-.bss
-
-KeySave:       .res    1