;  CKEYFIX.HEX:
;      A patch for VDE version 2.63 on Kaypro 2/4/10.
;
;  LIMITATIONS:
;      This patch works with Kaypro F, G, and H-series ROMs, and
;      Micro-Cornucopia's PRO-884 ROM (standard and MAX versions).
;      It will NOT work with Kaypro's U-series ROM, nor with the
;      Advent Turbo ROM.
;
;  FUNCTION:
;      New VDE initialization and de-initialization sequences.
;      Initialization changes Kaypro cursor keys to generate
;      Wordstar diamond pattern (^E^X^S^D) upon entry to VDE.
;      De-initialization changes them back to standard Kaypro
;      control sequences (^K^J^H^L) upon exit to CP/M.
;
;  RATIONALE:
;      Redifining cursor keys allows VDE to be installed for
;      normal Wordstar use of ^K (block commands), without
;      assigning alternate cursor keys via the VINST program.
;      Retains correct functions of Kaypro cursor keys.
;
;  INSTALLATION:
;      Assemble this file with ASM or MAC.
;      Overlay resulting HEX file into VDE263.COM with DDT or MLOAD.
;      Typical installations shown below.
;
;  ------------------------------------------------------------------------
;  DDT installation procedure:
;
;  A0>ddt vde263.com   ; loads the original version
;
;  DDT VERS 2.2
;  NEXT  PC
;  3500 0100
;  -ickeyfix.hex      ; tell DDT name of patch file
;  -r                 ; then read it in
;  -g0                ; exit to CP/M
;
;  A0>save 52 newvde.com   ; save new version of VDE v2.63
;
;  ------------------------------------------------------------------------
;  MLOAD installation procedure:
;
;  A0> MLOAD NEWVDE.COM=VDE63.COM,CKEYFIX.HEX  ; that's all!
;                                              ; doesn't that look easier?
;
;  ------------------------------------------------------------------------
;
;  ACKNOWLEDGEMENTS:
;      Machine language patch was taken from the MORPAT
;      segment of a Kaypro distribution copy of Wordstar.
;      It was modified to fit the addresses supplied by
;      VINST263.COM and .DOC files.
;
;  ------------------------------------------------------------------------
;
;  OKAY ALREADY, LET'S GET ON WITH IT . . .
;
	ORG	0100H	; beginning of TPA, start of VDE.
;
	JMP	INIT	; replace VDE's "JMP 0480" start instruction
	JMP	DINIT   ; replace VDE's "JMP 0000" exit instruction
;
;
	ORG	0248h	; beginning of VDE user patch area
;
INIT:				; Done before VDE normal initialization
	LHLD	1		; A routine for swapping four bytes into
	LXI	D,32H		; Kaypro's BIOS.  Dis-assembled from the
	DAD	D       	; MORPAT area in a Kaypro copy of Wordstar.
	XCHG
	LXI	H,EXSD		; point to data for wordstar diamond
	LXI	B,4		; how many bytes to move
	DB	0EDh, 0B0h	; kludge for poor folks who only have
				; 8080 ASM.  Those two bytes are really
				; a Z80 insruction:  LDIR
;
	JMP	0480H		; Special init done, do VDE's regular init.
;
DINIT:				; Done after VDE normal de-initialization
	LHLD	1		; Almost same as INIT, reverses effect.
	LXI	D,32H		; Restores original values to cursor keys.
	DAD	D
	LXI	D,KJHL		; a self-explanatory label, right?
	XCHG
	LXI	B,4
	DB	0EDh, 0B0h	; remeber, it's really an LDIR
;
	JMP	0		; Special DINIT done, exit VDE from here.
;
; data for cursor key assignments:
;
EXSD:	DB	05h,18h,13h,04h		; wordstar diamond codes
KJHL:	DB	0Bh,0Ah,08h,0Ch		; kaypro cursor codes
;
	END
