;	|===============================================|
;	|           *** KEYPAD V 3.0 ***                |
;	|						|
;	| TO CONVERT LOWERCASE KEYS TO A NUMERIC KEYPAD |
;	| FOR THE OSBORNE 04 VIXEN ONLY.                | 
;       | (to replace KEYPAD  V 2.2)			|
;	|						|
;	| MAY 12, 1986                                  |
;	| BY PAUL A. LEHMAN                             |
;	| 19207 60TH W. #4, LYNNWOOD, WA.  98036        |
;	|						|
;	| (C) COPYRIGHT 1985 BY PAUL A. LEHMAN FOR THE  |
;	| EXCLUSIVE USE AND ENJOYMENT OF THE MEMBERS OF |
;	| THE FIRST OSBORNE USER GROUP (FOG). NO OTHER  |
;	| USE OR RESALE IS ALLOWED WITHOUT THE WRITTEN  |
;	| PERMISSION OF THE AUTHOR.			|
;	|===============================================|
;
;
;INFORMATION FOR THE ASSEMBLER,

DATA1	EQU	0164H		;START OF 1ST LIST.
LOCAT1	EQU	0E178H		;LOCATION OF SUBROUTINE.
BYTES1	EQU	95D		;# TO SEND.

LOCAT2	EQU	0E747H		;LOCATION OF CONSULE INPUT.

DATA3	EQU	01C3H		;START OF 2ND LIST.
LOCAT3	EQU	0E13EH		;MEMORY LOCATIONS OF FUNC KEYS.
BYTES3	EQU	30D		;# TO SEND.

DATA4	EQU	01E1H		;START OF 3RD LIST.
LOCAT4	EQU	LOCAT1+BYTES1   ;BUFFER FOR FUNCTION KEYS.
BYTES4	EQU	14D		;# TO SEND.

CONIN	EQU	0F106H		;ROM SUBROUTINE FOR KEY INPUT.
BDOS 	EQU	0005H		;BIOS WARM BOOT SUBROUTINE.
ONE	EQU	LOCAT1+ 63D	;INFO FOR KEYPAD SUBROUTINE.
TWO	EQU	ONE   + 03D
THREE	EQU	TWO   + 03D
FOUR	EQU	THREE + 03D
FIVE	EQU	FOUR  + 03D
SIX	EQU	FIVE  + 03D
ZERO	EQU	SIX   + 03D
MEM	EQU	ZERO  + 03D
LCDR	EQU	MEM   + 01D
SWITCH	EQU	LOCAT1+ 59D

;DONE WITH THAT, LETS GET TO WORK!

	ORG	0100H		;A NICE PLACE TO START.
	JMP	MOVE1		;GET TO WORK.

        DB	0AH,0DH,'KEYPAD V 3.0'
	DB	0AH,0DH,'(C) 1986 by Paul A. Lehman$'

;FIRST, TRANSFER THE SUBROUTINE INTO FUNCTION KEY BUFFER.
;0E0B = LDIR IN Z-80 LANGUAGE, A NIFTY MOVER OF DATA.

MOVE1	LXI	H,DATA1		;START OF 1ST LIST.
	LXI	D,LOCAT1	;SEND IT TO 1ST LOCATION.
	LXI     B,BYTES1	;# OF BYTES TO SEND.
	DB  	0EDH,0B0H       ;MOVE IT NOW!

;NOW LOAD THE REROUTE FOR THE CONSOLE INPUT TO THIS SUBROUTINE.

MOVE2	LXI	H,LOCAT1	;GET START OF SUBROUTINE.
	SHLD    LOCAT2          ;MOVE IT INTO THE BIOS.

;NOW PUT IN THE NEW FUNCTION KEY MEMORY LOCATIONS.

MOVE3   LXI	H,DATA3		;START OF 2ND LIST.
	LXI	D,LOCAT3	;SEND IT TO 3RD LOCATION.
	LXI	B,BYTES3	;# OF BYTES TO SEND.
	DB      0EDH,0B0H       ;MOVE IT NOW!

;NOW PUT BACK IN THE FUNCTION & ARROW DEFINITIONS.

MOVE4	LXI	H,DATA4		;START OF 3RD LIST.
	LXI	D,LOCAT4	;SEND IT TO 4TH LOCATION.
	LXI	B,BYTES4	;# OF BYTES TO SEND.
	DB  	0EDH,0B0H       ;MOVE IT NOW!

;LETS SEND A MESSAGE TO THE SCREEN.

MSSG	LXI	D,0104H		;LOCATION OF MESSAGE.
	LXI	B,0009H		;SELECT BDOS WRITE FUNCTION.
	CALL	BDOS		;WRITE IT NOW!

;ALL MOVED IN, NOW LETS GET BACK TO THE REAL WORLD...

DONE	LXI	B,00H		;SELECT BDOS RESET FUNCTION.
	JMP	BDOS		;AND AWAY WE GO.

;THE KEYPAD SUBROUTINE WILL LOOK LIKE THIS IN MEMORY...
;(THIS IS ALSO THE START OF THE 1ST LIST TO MOVE.)

START	CALL 	CONIN		;CALL CONSOLE INPUT FUNCTION IN ROM.
	CPI	7FH		;CHECK FOR THE DELETE KEY INPUT.
	JZ	LCDR		;IF YES JUMP TO SWITCH IT ON/OFF.
;
ONOFF	PUSH    H		;SAVE HL.
	PUSH	D		;SAVE DE.
	LXI	H,MEM		;LOAD HL WITH MEMORY ON/OFF INDICATOR.
	MOV	E,A		;SAVE THE PRESSED KEY IN "E".
	MVI	A,0     	;LOAD "A" WITH 0.
	CMP	M		;DOES "A" MATCH MEMORY INDICATOR?
	JZ	SWITCH		;IF IT DOES GOTO SWICH = KEYPAD OFF.
	MOV	A,E		;IF NOT, PUT PRESSED KEY BACK IN "A".
	POP	D		;GET BACK DE.
	POP	H		;GET BACK HL.
;
COMP	CPI 	6AH		;IS IT j?
	JZ 	ONE		;IF YES JUMP TO 1.
	CPI 	6BH		;IS IT k?
	JZ 	TWO		;IF YES JUMP TO 2.
	CPI 	6CH		;IS IT l?
	JZ 	THREE		;IF YES JUMP TO 3.
	CPI 	75H		;IS IT u?
	JZ 	FOUR		;IF YES JUMP TO 4.
	CPI 	69H		;IS IT i?
	JZ 	FIVE		;IF YES JUMP TO 5.
	CPI 	6FH		;IS IT o?
	JZ	SIX		;IF YES JUMP TO 6.
	CPI	6DH		;IS IT M?
	JZ	ZERO		;IF YES JUMP TO 0.
	RET			;NOPE, NONE OF THE ABOVE,
				;DON'T CHANGE ANYTHING.
;
SWICH	MOV	A,E		;PUT PRESSED KEY BACK INTO "A".
	POP	D		;GET BACK DE.
	POP	H		;GET BACK HL.
	RET			;GO BACK TO WORK.
;	
;NOW CHANGE IT TO THE DESIRED NUMBER.
		
1  	MVI 	A,31H		;CHANGE IT TO 1,
	RET			;THEN RETURN.
2  	MVI	A,32H		;CHANGE IT TO 2,
	RET			;THEN RETURN.
3    	MVI 	A,33H		;CHANGE IT TO 3,
	RET			;THEN RETURN.
4       MVI 	A,34H		;CHANGE IT TO 4,
	RET			;THEN RETURN.
5   	MVI 	A,35H		;CHANGE IT TO 5,
	RET			;THEN RETURN.
6  	MVI 	A,36H		;CHANGE IT TO 6,
	RET			;THEN RETURN.
0   	MVI 	A,30H		;CHANGE IT TO 0,
	RET			;THEN RETURN.
;
INDIC   DB	0      		;ON/OFF SWITCH INDICATOR.
;
;	
LCD 	LDA	MEM		;LOAD "A" WITH MEMORY SWITCH INDICATOR.
	CMA			;CHANGE IT TO OPPOSITE.
	STA	MEM		;SAVE INDICATOR BACK TO MEMORY.
	JP	LOCAT1		;GO BACK FOR KEY INPUT.
;
;THIS IS THE END OF THE KEYPAD SUBROUTINE.

;NOW TO REBUILD THE CTRL-FUNCTION KEY BUFFER AREA...
;(THIS IS THE SECOND LIST TO MOVE.)

	DB	0D7H,0E1H	;NEW FUNCTION KEY LOCATIONS.
	DB	0D8H,0E1H
	DB	0D9H,0E1H
	DB	0DAH,0E1H
	DB	0DBH,0E1H
	DB	0DCH,0E1H
	DB	0DDH,0E1H
	DB	0DEH,0E1H
	DB	0DFH,0E1H
	DB	0E0H,0E1H

	DB	0E1H,0E1H	;NEW ARROW KEY LOCATIONS.
	DB	0E2H,0E1H
	DB	0E3H,0E1H
	DB	0E4H,0E1H
	
	DB	0E5H,0E1H	;NEXT EMPTY SPOT.

;PUTTING BACK IN THE CTRL-FUNCTION  KEY DEFINITIONS AS...
;(THIS IS THE 3RD LIST TO MOVE.)


	DB	30H
	DB	31H	
	DB	32H
	DB 	33H
	DB	34H
	DB	35H
	DB	36H
	DB	37H
	DB	38H
	DB	39H

;PUTTING BACK IN THE ARROW KEY DEFINITIONS (AS WITH CPM)...

	DB	0BH
	DB	0CH
	DB	0AH
	DB	08H

;WHEW, ALL DONE

	END
	

TING BACK IN THE ARROW KEY DEFINITIONS (AS WITH CPM)...

	DB	0BH
	DB	0CH
	DB	0AH
	DB	08H

;WHEW, ALL DONE

	END
	

