.z80


	;Application for Write-Hand-Man to allow users
	;to define the function keys on an Amstrad PCW8256 (JOYCE).
	;Written by D.W.Clements for HiSoft
	;July 1986


	;Rewriten by Dave Nutkins March 1987


	; This tool has a number of flaws.
	; 1. It requires that the f1..f8 keys remain programmed
	;    to produce #81..#88 as on the standard system.
	; 2. MORE IMPORTANT: It does not allow control codes in the
	;    strings. Uggh
	; 3. Relies on the fact that RETURN key gives 13

randread	equ	33
open	equ	15
	org	0

base	equ	$
BDOS	equ	base+5
macros	equ	base+18h
buf	equ	base+80h

	org	0100H

	ld	a,(base+5ch)
	ld	(fcb),a
	ld	de,fcb
	ld	c,open
	call	BDOS
	inc	a
	jr	z,fin	;no data file - forget it

	ld	de,fcb
	ld	c,randread
	call	BDOS

	ld	de,(macros)
	ld	hl,buf
	ld	bc,128
	ldir

fin:	jp	base

fcb:	db	0
	db	"KEYS    DAT"
	ds	21
	dw	1
	db	0
	
	END

