CURS_Y := $D8 ; Cursor row
FNADR := $DA ; Pointer to file name
+; 80-Column CBMs
+KBDREPEAT80 := $E4
+KBDRPTRATE80 := $E5
+KBDRPTDELAY80 := $E6
+
BASIC_BUF := $200 ; Location of command-line
BASIC_BUF_LEN = 81 ; Maximum length of command-line
KEY_BUF := $26F ; Keyboard buffer
-;FIXME: we must somehow handle the difference between the two - how?
-
-; 40-Column PETs
-;KBDREPEAT := $3ee
-;KBDREPEATRATE := $3ea
-;KBDREPEATDELAY := $3e9
-
-; 80-Column PETs
-KBDREPEAT := $e4
-KBDREPEATRATE := $e5
-KBDREPEATDELAY := $e6
+; 40-Column PETs/CBMs
+KBDRPTDELAY40 := $3E9
+KBDRPTRATE40 := $3EA
+KBDREPEAT40 := $3EE
+KBDREPEAT40B := $3F8
;----------------------------------------------------------------------------
; PET ROM type detection
VIA_PRA := $E841
VIA_DDRB := $E842
VIA_DDRA := $E843
-
-
<article>
<title>cc65 function reference
-<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
-<date>2016-08-07
+<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
+<url url="mailto:greg.king5@verizon.net" name="Greg King">
+<date>2017-09-02
<abstract>
cc65 is a C compiler for 6502 based systems. This function reference describes
</descrip>
</quote>
-<sect1>kbrepeat<label id="kbrepeat"><p>
-
-<quote>
-<descrip>
-<tag/Function/Set keyboard repeat mode
-<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
-<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/
-<tag/Description/This function changes which keys have automatic repeat when
-being hold down for a certain time. Possible values are KBREPEAT_CURSOR (repeat
-only cursor-related keys), KBREPEAT_NONE (no repeat for any keys) and
-KBREPEAT_ALL (repeat all keys). The old mode is returned so it can be restored
-later.
-<tag/Notes/<itemize>
-<item>The function is available only as a fastcall function; so, it may be used
-only in the presence of a prototype.
-</itemize>
-<tag/Availability/cc65
-<tag/Example/None.
-</descrip>
-</quote>
<sect1>cclear<label id="cclear"><p>
</quote>
+<sect1>kbrepeat<label id="kbrepeat"><p>
+
+<quote>
+<descrip>
+<tag/Function/Set the keyboard repeat mode.
+<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
+<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/
+<tag/Description/This function changes which keys have automatic repeat when
+being held down for a certain time. Possible values are <tt/KBREPEAT_CURSOR/
+(repeat only cursor-related keys), <tt/KBREPEAT_NONE/ (no repeat for any
+keys), and <tt/KBREPEAT_ALL/ (repeat all keys). The old mode is returned, so
+it can be restored later.
+<tag/Notes/<itemize>
+<item>The function is available only as a fastcall function; so, it may be used
+only in the presence of a prototype.
+</itemize>
+<tag/Availability/cc65
+<tag/Example/None.
+</descrip>
+</quote>
+
+
<sect1>labs<label id="labs"><p>
<quote>
;
; 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