PASEX5ASM;------ ROUTINE PASEX5.KCC -----
;				\
;	f}r KC-PACAL V5.01	\
;				\
;Selbststart auf 5300H		\
;Test, ob Floppy vorhanden	\
;ab BA00H	CCTL0 (ASCII)	\
;ab BC00H	PASEX		\
;				\
;		` ml 16.07.1992	\
;-------------------------------
CCTL0	EQU	0B7A6H
SUTAB	EQU	0B7B0H
SUBALT	EQU	0B7FEH	;SUTAB merken
PV1	EQU	0F003H
WAIT	EQU	14H
ERRM	EQU	19H
AHEX	EQU	1CH
OSTR	EQU	23H
OCHR	EQU	24H
CRLF	EQU	2CH
;-------
	ORG	5300H
START	LD	HL,0
	LD	B,80H
PAS02	LD	A,M
	CP	7FH	;Test Prolog?
	INC	HL
	JR	Z,PAS01
	DJNZ	PAS02
	JR	PAS03
PAS01	LD	M,0	;l|schen
PAS03	LD	HL,(CCTL0)
	LD	DE,0BA00H
	LD	BC,200H
	LDIR			;CCTL0
	LD	HL,USASC
	LD	DE,0BBD8H
	LD	BC,18H
	LDIR			;ASCII's
	LD	HL,BASCI
	LD	DE,SASCI
	LD	BC,PTAPE-SASCI
	LDIR			;Men}w.
	LD	A,7FH
	LD	(SASCI),A
	LD	(SASCI+1),A
	LD	BC,0FC80H
	IN	A,(C)
	CP	0A7H		;Floppy?
	JP	NZ,ASCII	;nein
	LD	BC,SUBNEU-PTAPE
	LDIR			;Pasex
	LD	A,7FH
	LD	(PTAPE),A
	LD	(PTAPE+1),A
	LD	(PDISK),A
	LD	(PDISK+1),A
	LD	HL,(SUTAB)
	LD	(SUBALT),HL	;merken
	LD	DE,SUBNEU
	LD	(SUTAB),DE
	LD	BC,92H		;L{nge
	LDIR			;SUTAB
	LD	HL,MBO
	LD	(SUBNEU+2),HL
	LD	HL,MBI
	LD	(SUBNEU+10),HL
	LD	HL,STAB
	LD	DE,SUBNEU+16
	LD	C,8
	LDIR
	JP	ASCII
;-------
STAB	DEFW	ISRO	;08
	DEFW	CSRO	;09
	DEFW	ISRI	;0A
	DEFW	CSRI	;0B
;-------
USASC	DEFB	7CH		;5BH
	DEFB	60H
	DEFB	60H
	DEFB	60H
	DEFB	60H
	DEFB	60H
	DEFB	7CH
	DEFB	0
 
	DEFB	0C0H		;5CH
	DEFB	60H
	DEFB	30H
	DEFB	18H
	DEFB	0CH
	DEFB	6
	DEFB	2
	DEFB	0
 
	DEFB	7CH		;5DH
	DEFB	0CH
	DEFB	0CH
	DEFB	0CH
	DEFB	0CH
	DEFB	0CH
	DEFB	7CH
	DEFB	0
 
BASCI	EQU	$
;-------
	ORG	0BC00H
SASCI	DEFW	0
	DEFM	'ASCII'
	DEFB	1
ASCII	LD	HL,0BA00H
	LD	(CCTL0),HL
	RET
;-------
PTAPE	DEFW	0
	DEFM	'PASTAPE'
	DEFB	1
	LD	HL,(SUBALT) ;SUTAB alt
PAS06	LD	(SUTAB),HL
	RET
;-------
PDISK	DEFW	0
	DEFM	'PASDISK'
	DEFB	1
	LD	HL,SUBNEU ;SUTAB neu
	JR	PAS06
;-------
ISRO	LD	(IX+2),0 ;Blocknummer
	LD	L,(IX+5)
	LD	H,(IX+6) ;Blockpuffer
	LD	BC,83F3H ;Name
	LD	E,11	 ;Anzahl
PAS07	OUTI
	INC	B
	INC	B
	DEC	E
	JR	NZ,PAS07 ;Name ausgeben
	LD	D,11	;write open
PAS10	INC	(IX+2)	;n{chster Block
	LD	H,(IX+6)
	LD	L,(IX+5)
	LD	BC,81F2H
	LD	E,80H	;Blockl{nge
PAS08	OUTI
	INC	B
	INC	B
	DEC	E
	JR	NZ,PAS08
STEUER	LD	BC,80F3H ;Steuerbyte
	OUT	(C),D
PAS09	PUSH	BC
	LD	A,1
	CALL	PV1
	DEFB	WAIT
	POP	BC
	IN	A,(C)
	BIT	0,A	;fertig?
	JR	NZ,PAS09
	AND	A
	BIT	7,A	;Fehler?
	RET	Z
	INC	B
	IN	A,(C)
	CALL	PV1
	DEFB	AHEX	;Fehlernummer
	CALL	PV1
	DEFB	ERRM
	SCF
	RET
;-------
MBO	LD	D,3	;write
	CALL	PAS10
	RET	C	;wenn Fehler
	LD	A,2
	CP	(IX+2)
	RET	NC	;Block < 3
	CALL	PV1
	DEFB	OSTR
	DEFW	808H
	DEFB	8
	NOP
	AND	A	;CY=0
	RET
;-------
CSRO	CALL	MBO
	RET	C
	LD	D,43H	;write close
	JR	STEUER
;-------
ISRI	LD	(IX+2),0
	LD	HL,06F8H ;Namenpuffer
	LD	BC,83F3H ;Name
	LD	DE,090BH ;open/L{nge
PAS12	OUTI
	INC	B
	INC	B
	DEC	E
	JR	NZ,PAS12
PAS13	CALL	STEUER	;Steuerbyte
	RET	C	;Fehler
	PUSH	HL
	PUSH	AF
	LD	L,(IX+5)
	LD	H,(IX+6);Puffer
	LD	BC,80F2H
	LD	E,80H	;L{nge
PAS14	INI
	INC	B
	INC	B
	DEC	E
	JR	NZ,PAS14
	INC	(IX+2)	;Blocknummer
	POP	AF
	POP	HL
	RET
;-------
MBI	PUSH	DE
	LD	D,1	;read
	CALL	PAS13
	POP	DE
	RET	C	;Fehler
	LD	A,2
	CP	(IX+2)
	RET	NC	;Block < 3
	CALL	PV1
	DEFB	OSTR
	DEFW	808H
	DEFW	808H
	NOP
	AND	A	;CY=0
	RET
;-------
CSRI	CALL	PV1
	DEFB	CRLF
	RET
;-------
SUBNEU	EQU	$
À@Àt(Àp6ÀnTop of Text: End of Text: Start of MC: ASMT
;-------
CSRI	CALL	PV1
	DEFB	CRLF
	RET
;-------
SUBNEU	EQU	$
À@Àt(Àp6ÀnTop of Text: End of Text: Start of MC: ASM