#include "pia6521.i65" #include "kdefs.i65" #define PIO $e810 #define KEY_START 16 /* when does key repetition start */ /**************************************************************************/ .( .data rcnt .byt 0 shiftfl .byt 0 prev .byt 0 kcnt .byt 0 ; temporary used during getkey rspd .byt 0 ; keyboard repeat speed .zero tzei .word 0 .text &inikbd .( lda PIO+PIA_CRA and #255-4 sta PIO+PIA_CRA ldx #15 stx PIO+PIA_PA ora #4 sta PIO+PIA_CRA lda PIO+PIA_CRB and #255-4 sta PIO+PIA_CRB ldx #0 stx PIO+PIA_PB ora #4 sta PIO+PIA_CRB lda #4 sta rcnt sta rspd rts .) &&getkey .( lda PIO and #$f0 ora #8 sta PIO ix1 lda PIO+2 cmp PIO+2 bne ix1 ldy #0 and #%00100001 cmp #%00100001 beq nshift iny nshift inc PIO x0 lda PIO+2 cmp PIO+2 bne x0 and #%00000001 bne nctrl iny iny nctrl sty shiftfl tya asl tax lda ttab+1,x tay lda ttab,x sta tzei sty tzei+1 ldy #0 ldx #0 lx1 stx kcnt lda PIO and #$f0 ora kcnt sta PIO ldx #8 l2 lda PIO+2 cmp PIO+2 bne l2 l3 asl bcs lc pha lda (tzei),y bne le pla lc iny dex bne l3 ldx kcnt inx cpx #10 bcc lx1 ldy #<-1 sty prev nokey /* TODO: check keyboard code - C64 works different */ ; ldx #KEY_START ; stx rcnt ldx shiftfl sec rts le tax pla txa cpy prev sty prev bne lx dec rcnt bne nokey ldx rspd .byt $2c lx ldx #KEY_START stx rcnt ldx shiftfl clc rts .) ttab .word ktab,stab,ctab,sctab ktab .asc TC_CRGT,TC_HOME,"~(&%#!",TC_BS,TC_CDWN,"^@)\'$":.byt $22 .asc "97^^outeq/8^@piyrw" .asc "64^@ljgda*5^@:khfs" .asc "31",TC_CR,";mbcz+2^@?,nvx" .asc "-0^@>^@]@^@=.^@@< [^@" stab .asc TC_CLFT,TC_CLR,"|(&%#!",TC_INS,TC_CUP,"^@)\'$":.byt $22 .asc "97^^OUTEQ/8^@PIYRW" .asc "64^@LJGDA*5^@:KHFS" .asc "31",TC_LF,";MBCZ+2^@?,NVX" .asc "-0^@>^@}@^@=.^@",TC_ESC,"< {^@" ctab .asc TC_WRU,TC_WCLS,"~(&%#!",TC_DEL,TC_WLO,"^@)\'$",$22 .asc "97^^^o^u^t^e^q/8^@^p^i^y^r^w" .asc "64^@^l^j^g^d^a*5^@:^k^h^f^s" .asc "31",TC_EOL,";^m^b^c^z+2^@?,^n^v^x" .asc "-0^@>^@]@^@=.^@",TC_CLL,"< [^@" sctab .asc "^@^@|(&%#!^H^@^@)\'$":.byt $22 .asc "97^^O^U^T^E^Q/8^@^P^I^Y^R^W" .asc "64^@^L^J^G^D^A*5^@:^K^H^F^S" .asc "31^m;^M^B^C^Z+2^@?,^N^V^X" .asc "-0^@>^@}@^@=.^@@< {^@" .)