; REPATCH.ASM 6-5-86 gsd
; Simple patch to REDIT 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 level definitiions are restored.
;
; All of the following files must be patched:
;
;	DATASTAR.COM
;	FORMGEN.COM
;	REDIT.COM
;	REPORT.COM
;	RINSTALL.COM
;
;
; USE DDT TO PATCH REDIT.COM:
;
; A>DDT REDIT.COM
; DDT VERS 2.2
; NEXT PC
; 7100 0100
; -IDSPATCH.HEX
; -R
; NEXT PC
; 7100 0100
; -G0
;
; Warm Boot 
; A>SAVE 112 REDIT.COM
;
;
 
djnz	macro addr
	db 10h
	db low addr-($+1)
	endm

	org 0162h	; id string REDIT.COM 1.03
	db	'1.03'

	org 2A7h
;
inisub:	jmp	morpat
;
unisub: jmp	morpat

	org 2deh
;
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

