From: Greg King Date: Tue, 5 Sep 2017 07:40:34 +0000 (-0400) Subject: Made the CBM Pet kbrepeat() work on both 40-column and 80-column machines. X-Git-Tag: V2.17~95^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3c0b8c4e862de0b54e547aa3ad0dfa7e6fd668f2;p=cc65 Made the CBM Pet kbrepeat() work on both 40-column and 80-column machines. Put the kbrepeat() description in an alphabetical position in the function document. --- diff --git a/asminc/pet.inc b/asminc/pet.inc index 8f2f469e0..43d52a5d5 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -26,22 +26,21 @@ SCR_LINELEN := $D5 ; Screen line length 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 @@ -67,5 +66,3 @@ VIA_PRB := $E840 VIA_PRA := $E841 VIA_DDRB := $E842 VIA_DDRA := $E843 - - diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 5ef773b95..1d5ee7c19 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -2,8 +2,9 @@
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 @@ -2166,26 +2167,6 @@ to get off the serial bus so it can be used for other purposes. </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> @@ -4062,6 +4043,28 @@ do), the function is rather useless. </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> diff --git a/libsrc/pet/kbrepeat.s b/libsrc/pet/kbrepeat.s index 8299f5103..100d8502a 100644 --- a/libsrc/pet/kbrepeat.s +++ b/libsrc/pet/kbrepeat.s @@ -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