	TITLE	'Tastaturtreiber K7604'

; Version 1.0
; 06.12.88

	public tasini,tab,tasabf
	public tasmer

	extrn zeisat

; Z80 macro library instruction definitions

	maclib	z80

; Port Adress Equates

	maclib	ports

;______________________________________________________________
; Sprungverteiler Tastaturaufruf
;______________________________________________________________

tasini:	jr tasin		; Initialisierung der Tastatur
tasabf:	jr tascod		; Abfrage ob Zeichen da

;______________________________________________________________
; Initialisierung der Tastatur
;______________________________________________________________

tasin:
	mvi a,1 ! sta wdhz
tasin1:
	in tastst ! bit 3,a
 	rnz	
	in taste ! jr tasin1

;______________________________________________________________
; Abfragen Tastatur auf Betaetigung
;______________________________________________________________

tascod:	lxi h,wdhz ! in tastst ! bit 3,a
	jrz tastda		; --> neues Zeichen von Tast.
	dcr m ! rnz		; --> Wiederholungszaehler noch
				; nicht abgelaufen
	mvi m,1			; 100 ms Wiederholfunktion
	bit 0,a
	jrz tasrep		; --> Taste noch betaetigt
	ret			; --> keine Taste mehr

;______________________________________________________________
; Einstellen Zeitkonstante fuer erste Tastenwiederholung
;______________________________________________________________

tastda:
	mvi m,5			; 500 ms fuer erste Wdh.
tasrep:
	in taste ! push psw	
	ani 0feh
	sui 0f0h
	jrz zeisum
	cpi 2
	jrz zeisum
	mvi b,tastpe-tastp	; Berechnen Pufferposition
	lxi h,tastp
	mvi	c,bstast
tapube:
zx1a:	db	0edh,070h	; INF-Befehl
	jp	zx1a
zx2a:	db	0edh,070h	; INF-Befehl
	jm	zx2a

	mov a,m ! ora a
	jrz tapupo		; --> freie Position gefunden
	inx h ! djnz tapube	; naechste Position pruefen

;______________________________________________________________
; Tastencode auswerten
;______________________________________________________________

tapupo:	pop psw
	mvi	c,bstast
zx1b:	db	0edh,070h	; INF-Befehl
	jp	zx1b
zx2b:	db	0edh,070h	; INF-Befehl
	jm	zx2b

	mov m,a ! sta tasmer
	ret

zeisum:	sta zeisat		; Zeichensatzumschaltung
	pop psw
	ret

;______________________________________________________________
; Puffer
;______________________________________________________________

tasmer:	db	0

wdhz:	db	0

tab:
	DB	0C3H,19H,0	; Fehler im Tastatur-EPROM
	DB	0D3H,19H,0

	DB	0B4H,11H,7FH,0	; ^QDEL	DELLINE LEFT 
	DB	0B6H,11H,56H,0	; ^QV	LAST FIND OR BLOCK
	DB	0B7H,11H,41H,0	; ^QA	FIND / REPLACE
	DB	0B8H,11H,45H,0	; ^QE	CURSOR TOP OF SCREEN
	DB	0B9H,11H,46H,0	; ^QF	FIND
	DB	0BAH,11H,53H,0	; ^QS	CURSOR LEFT SIDE
	DB	0BBH,11H,52H,0	; ^QR	CORSOR TOP OF FILE
	DB	0BCH,11H,44H,0	; ^QD	CURSOR RIGHT SIDE
	DB	0BDH,11H,53H,18H,0
				; ^QS^X	CURSOR BEGIN NEXT LINE
	DB	0BEH,11H,58H,0	; ^QX	CURSOR BOTTOM OF SCREEN
	DB	0BFH,11H,43H,0	; ^QC	CURSOR END OF FILE

	DB	0D1H,11H,59H,0	; ^QY	DEL LINE RIGHT
	DB	0D2H,01H,14H,0	; ^A^T	DEL WORD LEFT

	DB	0C5H,10H,56H,0	; ^PV
	DB	0D5H,10H,54H,0	; ^PT
	DB	0C6H,10H,53H,0	; ^PS
	DB	0D6H,10H,58H,0	; ^PX
	DB	0C8H,38h,0	;0BH,43H,0	; ^KC
	DB	0D8H,0BH,56H,0	; ^KV
	DB	0C9H,0BH,4EH,0	; ^KN
	DB	0D9H,0BH,59H,0	; ^KY
	DB	0CBH,35h,0	;0BH,42H,0	; ^KB
	DB	0DBH,11H,42H,0	; ^QB
	DB	0CCH,36h,0	;0BH,4BH,0	; ^KK
	DB	0DCH,11H,4BH,0	; ^QK
	DB	0DEH,11H,50H,0	; ^QP
	DB	0CFH,0FH,47H,0	; ^OF
	DB	0DFH,0FH,58H,0	; ^OX
	db	11h,34h,0
	db	02h,32h,0
	DB	0,0

tabe:

;______________________________________________________________

	END
