	title	Handwritten Character Driver
	name	('HANDWR')

; This is the machine part of a BASIC-program written
; by Kelvin Stott,
; published in 8000 Plus, December 1987

; Disassembled by W.Cirsovius

B1PORT	equ	0f1h		; Memory 04000H-07FFFH
B2PORT	equ	0f2h		; Memory 08000H-0BFFFH

SCR1BNK	equ	081h
SCR2BNK	equ	082h
TPA1BNK	equ	085h
TPA2BNK	equ	086h

CHARMTX	equ	0b800h		; Area of character matrices

MATLEN	equ	8		; Length of character matrix

	.phase	0c070h

;
; Define character
;
HANDWR:
	di
	ld	a,SCR1BNK
	out	(B1PORT),a	; Select screen bank
	ld	a,SCR2BNK
	out	(B2PORT),a
	xor	a
	ld	e,a		; Clear some data
	ld	h,a
	ld	d,HIGH CHARMTX	; Load base page of matrix area
	ld	a,(CHAR)	; Load character
	ld	l,a
	add	hl,hl		; Build index by character*8
	add	hl,hl
	add	hl,hl
	add	hl,de
	ld	de,CHARBIT	; Point to new bits
	ex	de,hl
	ld	bc,MATLEN
	ldir			; Define new character
	ld	a,TPA1BNK
	out	(B1PORT),a	; Select TPA bank
	ld	a,TPA2BNK
	out	(B2PORT),a
	ei
	ret
;
CHAR:				; Character storage
CHARBIT	equ	CHAR+1		; Start of eight byte character matrix

	.dephase

	end

