]> git.sur5r.net Git - cc65/blobdiff - libsrc/pet/kbrepeat.s
Made the CBM Pet kbrepeat() work on both 40-column and 80-column machines.
[cc65] / libsrc / pet / kbrepeat.s
index 8299f5103b9fc1339ebd02f563df0954ecebba47..100d8502ac75aeafb08bf80025ff071dfe094f6f 100644 (file)
@@ -1,14 +1,29 @@
 ;
 ; unsigned char __fastcall__ kbrepeat (unsigned char mode);
+;
+; 2017-06-16, Groepaz
+; 2017-09-05, Greg King
 ;
 
-        .export _kbrepeat
+        .export         _kbrepeat
 
         .include        "pet.inc"
 
 _kbrepeat:
-        ldx KBDREPEAT           ; get old value
-        sta KBDREPEAT           ; store new value
-        txa                     ; return old value
-        ldx #0
+        ldx     #>$0000
+        ldy     SCR_LINELEN
+        cpy     #40 + 1
+        bcc     L1              ; branch if screen is 40 columns wide
+
+        ldy     KBDREPEAT80     ; get old value
+        sta     KBDREPEAT80     ; store new value
+        tya                     ; return old value
+        rts
+
+L1:     tay
+        lda     KBDREPEAT40B    ; get REPEAT-key flag (used by some editor ROMs)
+        lsr     a               ; move bit 0 into bit 7
+        ror     a
+        ora     KBDREPEAT40     ; combine with old key-REPEAT flags
+        sty     KBDREPEAT40
         rts