ESCAPE	EQU	1BH
	EXTRN	BD006D,BD001,SNDESC,KEYCPM,KEYWRD
	PUBLIC	DECODE
DECODE:
	ANI	01011111B ;convert to upper case.
	CPI	'Q'	;was quit selected?
	RZ		;yes, go home.
	CPI	10H
	JZ	CPMKEY
	CPI	11H
	JZ	WRDKEY
	CPI	12H
	JZ	TRANON
	CPI	13H
	JZ	TRANOF
	CPI	14H
	JZ	GRAFON
	CPI	15H
	JZ	GRAFOF
	CPI	16H
	JZ	ALTCHR
	CPI	17H
	JZ	NRMCHR
	CPI	18H
	JZ	SDIM
	CPI	19H
	JZ	EDIM
	CPI	5BH
	JZ	INVON
	CPI	5DH
	JZ	INVOFF
	CPI	08h
	JZ	SBLNK
	CPI	09h
	JZ	EBLNK
	CPI	0Fh
	JZ	SUNDER
	CPI	5Ch
	JZ	EUNDER
	CPI	06H
	JZ	STREV
	CPI	05H
	JZ	ENDREV
	CPI	'Z'
	JZ	UNSCRW
	SUI	40H	;convert a to 1, b to 2, c to 3, etc.
	JM	INERR	;can not be less than 1
	SUI	17	;or greater than 16
	JP	CURTYP
	ADI	40H	;add finagle number
;at this point the letter a has been converted to 30h,b to 31h etc
;register a must be saved and two calls must be made as specified
;on pages 451 and 452 of the osborne executive reference guide.
SETBCK:	PUSH	A
	MVI	E,'x'
	CALL	SNDESC
	POP	A
	MOV	E,A
	CALL	BD006D
	RET
CURTYP:	SUI	6
	JP	OTHER
	ADI	35H
	PUSH	A
	MVI	E,2EH
	CALL	SNDESC
	POP	A
	MOV	E,A
	CALL	BD006D
	RET
SDIM:	MVI	E,29H
	JP	SNDTWO
EDIM:	MVI	E,28H
	JP	SNDTWO
SBLNK:	MVI	E,5EH
	JP	SNDTWO
EBLNK:	MVI	E,71H
	JP	SNDTWO
SUNDER:	MVI	E,6CH
	JP	SNDTWO
EUNDER:	MVI	E,6DH
	JP	SNDTWO
INVON:	MVI	E,106
	JP	SNDTWO
INVOFF:	MVI	E,107
	JP	SNDTWO
STREV:	MVI	E,62H
	JP	SNDTWO
ENDREV:	MVI	E,64H
	JP	SNDTWO
CPMKEY:	CALL	KEYCPM
	RET
WRDKEY:	CALL	KEYWRD
	RET
TRANON:	MVI	E,101
	JP	SNDTWO
TRANOF:	MVI	E,102
	JP	SNDTWO
GRAFON:	MVI	E,67H
	JP	SNDTWO
GRAFOF:	MVI	E,47H
	JP	SNDTWO
ALTCHR:	MVI	E,61H
	JP	SNDTWO
NRMCHR:	MVI	E,41H
	JP	SNDTWO
UNSCRW:	CALL	KEYCPM
	CALL	NRMCHR
	CALL	TRANON
	CALL	GRAFOF
	CALL	INVOFF
	MVI	A,30h
	CALL	SETBCK
	CALL	EDIM
	CALL	EBLNK
	CALL	EUNDER
	RET
OTHER:	ADI	57H
	CPI	'X'
	JZ	CLKON
	CPI	'Y'
	JZ	CLKOF
INERR:	MVI	A,'?'	;indicate error
	RET
CLKOF:	MVI	E,3CH
	JP	SNDTWO
CLKON:	MVI	E,3EH
SNDTWO:	CALL	SNDESC
	RET
;the click on and off are are incorrect in the osborne executive
;reference guide. they are just the reverse of what it says.
	END
