3000 4c9f 0000 S ... PF-PICTU.A
;  PrintFox DECODER -> MT81
;
	ORG	00100H
PIPL:	EQU	01000H
KBE:	EQU	PIPL+01F40H
GBE:	EQU	PIPL+07D00H
PDR:	EQU	050H
PFL:	EQU	052H
;
INIT:	RST	020H
	DB	2
	DB	'Bilddiskette'
	DB	' einlegen !'
	DB	08DH
	RST	020H
	DB	1
	LD	A,0FFH
	OUT	PFL+1
	LD	A,0C7H
	OUT	PFL+1
	OUT	PFL
	LD	A,00FH
	OUT	PDR+1
	CALL	LOAD
	RST	020H
	DB	2
	DB	'Converting'
	DB	'...'
	DB	08DH
	LD	HL,PIPL
NXT:	LD	DE,SPAC
	LD	C,1
	CALL	ZROT
	EX	DE,HL
	LD	HL,SPAC
	LD	BC,8
	LDIR
	EX	DE,HL
	PUSH	HL
	LD	DE,(PUFF)
	SBC	HL,DE
	POP	HL
	JRC	NXT-#
	JR	EKO-#
ZROT:	PUSH	HL
	PUSH	DE
	PUSH	BC
	CALL	ROT
	LD	A,D
	POP	BC
	POP	DE
	POP	HL
	LD	(DE),A
	INC	DE
	INC	C
	LD	A,C
	CMP	9
	JRC	ZROT-#
	RET
ROT:	LD	B,8
NBM:	PUSH	BC
	LD	A,M
	INC	HL
BFM:	RLA
	DEC	C
	JRNZ	BFM-#
	RL	D
	POP	BC
	DJNZ	NBM-#
	RET
EKO:	LD	HL,(LZEI)
	LD	(LZE2),HL
	LD	A,5
	LD	(PMOD),A
	LD	A,H
	CMP	2
	JRNZ	BPOK-#
	RST	020H
	DB	2
	DB	'(A)ll or'
	DB	' (P)lot ?'
	DB	08DH
PFQ:	RST	020H
	DB	1
	CMP	'P'
	JRZ	PLOT-#
	CMP	'A'
	JRNZ	PFQ-#
	LD	A,4
	LD	(PMOD),A
	JR	BPOK-#
PLOT:	LD	HL,576
	LD	(LZE2),HL
BPOK:	RST	020H
	DB	2
	DB	'printing...'
	DB	08DH
	LD	DE,DINI
	CALL	IGET
	LD	HL,PIPL
	JR	START-#
NEXT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ALL	PNAM
	POP	HL
	LD	C,060H
	CALL	OPEN
	CALL	OTALK
	CALL	IECIN
	CMP	042H
	JRZ	PIC-#
	CMP	047H
	JRZ	PIC-#
	LD	A,B
	OR	A
	JPNZ	LERR
	RST	020H
	DB	2
	DB	'no Picture'
	DB	08DH
	XOR	A
	LD	(FANZ),A
	JR	LB2-#
PIC:	LD	HL,KBE
	LD	DE,320
	CMP	042H
	JRZ	SPIC-#
	LD	HL,GBE
	LD	DE,640
SPIC:	LD	(PUFF),HL
	LD	(LZEI),DE
	LD	HL,PIPL
	RST	020H
	DB	2
	DB	'DECODING'
	DB	08DH
	CALL	PAE
LNXT:	CALL	IECL
	JRNZ	LBRK-#
	LD	A,M
	CMP	09BH
	JRNZ	NCOD-#
	CALL	IECIN
	LD	E,A
	CALL	IECIN
	LD	D,A
	CALL	IECIN
	LD	B,A
COD:	LD	M,B
	INC	HL
	DEC	DE
	LD	A,D
	OR	E
	JRNZ	COD-#
	DEC	HL
NCOD:	INC	HL
	PUSH	HL
	LD	DE,(PUFF)
	SBC	HL,DE
	POP	HL
	JRNC	OVER-#
	LD	A,L
	OR	A
	JRNZ	LNXT-#
	CALL	GAD
	RST	020H
	DB	4
	CMP	3
	JRNZ	LNXT-#
OVER:	LD	A,040H
LBRK:	CMP	040H
	PUSH	AF
	CALL	GAD
	POP	AF
	JRZ	LB2-#
LERR:	RST	020H
	DB	2,08DH
	CALL	FSTAT
LB2:	RST	020H
	DB	2,08DH
	CALL	UTALK
	LD	C,060H
	CALL	CLOSE
	RET
PAE:	RST	020H
	DB	7
	RST	020H
	DB	2,0ADH
	RST	020H
	DB	7
	RET
PNAM:	LD	A,M
	OR	A
	JRZ	NCR-#
	RST	020H
	DB	0
	INC	HL
	JR	PNAM-#
NCR:	RST	020H
	DB	2,08DH
	RET
GAD:	RST	020H
	DB	2
	DB	8,8,8,088H
	RST	020H
	DB	7
	RET
DIR:	LD	HL,TDIR
	LD	C,060H
	XOR	A
	LD	(FANZ),A
	CALL	O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