3000 51e8 0000 S ... LAYOUT.A
	PN	LAYOUT
;   Fertig am 12.10.'91,
;   mit ANLAY 29.12.'91
ZANF:	EQU	00800H
ALAY:	EQU	00C00H
BMEM:	EQU	01000H
LOAD:	EQU	0E003H
SAVE:	EQU	0E006H
PDR:	EQU	050H
PFL:	EQU	052H
;
	ORG	00100H
;
START:	LD	SP,090H
	XOR	A
	OUT	018H
	LD	(BTX),A
	LD	(MVZ),A
	INC	A
	LD	(PIX),A
	LD	HL,07C7CH
	LD	(ALSP),HL
	LD	HL,0EE00H
	LD	(DPOS),HL
	RST	020H
	DB	2
	DB	12
	DB	'         '
	DB	'Layoutmaker'
	DB	' I.'
	DB	13
	DB	'        '
	DB	'***********'
	DB	'*****'
	DB	13
	DB	13
	DB	'    A - LINE'
	DB	'-Anfang'
	DB	13
	DB	13
	DB	'    E - LINE'
	DB	'-Ende'
	DB	13
	DB	13
	DB	'    Z - Zeich'
	DB	'nen/Löschen'
	DB	13
	DB	13
	DB	'  K/k - kle'
	DB	'ines Loch'
	DB	13
	DB	13
	DB	'  G/g - gro'
	DB	'ßes Loch'
	DB	13
	DB	13
	DB	'  M/m - Punkt'
	DB	13
	DB	13
	DB	'    V - Voll'
	DB	'grafik'
	DB	13
	DB	13
	DB	'  W/w - Besch'
	DB	'riften'
	DB	13
	DB	13
	DB	'    L - Lay'
	DB	'out laden'
	DB	13
	DB	13
	DB	'    S - Lay'
	DB	'out saven'
	DB	13
	DB	13
	DB	'    * - CLS'
	DB	13
	DB	13
	DB	'  P/p - Hard'
	DB	'copy'
	DB	13
	DB	13
	DB	'    N - Nach'
	DB	'bearbeitung'
	DB	08DH
	LD	A,17
	LD	(XPS),A
	LD	(YPS),A
GETT:	XOR	A
	LD	(BTX),A
	OUT	018H
GET:	LD	A,(BTX)
	OR	A
	CAZ	GPOS
	CANZ	CPOS
	RST	020H
	DB	1
	PUSH	AF
	LD	A,(BTX)
	OR	A
	CANZ	CPOS
	POP	AF
IKOR:	AND	07FH
	LD	C,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