; WSPATCH.ASM 5-30-86 gsd
; Simple patch to WS 3.30 for Kaypro Keyboard Arrow Keys
; Assembles with DRI MAC.COM
; 
; These patches are intended to work with The Advent TurboROM.
; The patches simply swap the CP/M level arrow key definitions
; for MicroPRO type arrow key usage on start up of the program.
; On exit from the program the CP/M levle definitiions are restored.
;
; USE DDT TO PATCH WS.COM:
;
; A>DDT WS.COM
; DDT VERS 2.2
; NEXT PC
; 4600 0100
; -IWSPATCH.HEX
; -R
; NEXT PC
; 4600 0100
; -G0
;
; Warm Boot 
; A>SAVE 69 WS.COM
;
 
djnz	macro addr
	db 10h
	db low addr-($+1)
	endm

	org 0162h	; id string
	
	db '3.30'

	org 0287h

;
inisub:	jmp	morpat
;
unisub: jmp	morpat

	org 2d7h
;
morpat:	lhld	0001		; GET WARM BOOT JMP ADDR
	lxi	d,32h		; offset to xlate table
	  dad	d		; hl --> xlate table (bios) 
	lxi	d,table		; de --> xlate table (local)
	mvi	b,4		; count 
;
loop:				; repeat
	mov	c,m		;   swap *hl,*de
	ldax	d
	mov	m,a
	mov	a,c
	stax	d
	inx	h		;   hl++, de++
	inx	d
	djnz	loop		; unitl bytes swaped
        ret
;
table:	db	'E'-40h		; up arrow
	db	'X'-40h		; down arrow
	db	'S'-40h		; left arrow
	db	'D'-40H		; right arrow

	end
