	TITLE	IOINIT - FORTRAN-80 I/O FLAG & VARIABLE INIT

	.8080

	ENTRY	$IOINI
	EXT	$IOFLG,$LNPTR,$CPMBF,$LUNTB
	EXT	$FLFLG,$DSKER,$OPNFL

$IOINI:	LDA	$IOFLG		;SEE IF WE'VE ALREADY BEEN CALLED
	ORA	A
	RNZ
	INR	A		;SET NON-ZERO
	STA	$IOFLG

	LXI	H,$CPMBF
	MVI	M,132+1		;MAX CHRS TO READ FOR BDOS CALL
	INX	H
	MVI	M,0		;ZERO NO. OF CHARS READ
	INX	H
	SHLD	$LNPTR		;PTR TO BEGINNING OF LINE

	MVI	M,10		;STORE LINE FEED AT BEG. OF LINE

	LDA	$LUNTB		;GET NO. OF LUN'S
	DCR	A
	MOV	B,A		;SAVE LOOP COUNT
	LXI	H,$FLFLG	;INITIALIZE FLAGS FOR DSKDRV
	XRA	A

FLGLOP:	MOV	M,A		;ZERO $FLFLG BYTE
	INX	H		;INCREMENT PTR
	DCR	B		;DECREMENT COUNT
	JNZ	FLGLOP		;NEXT
	STA	$DSKER

	XRA	A
	STA	$OPNFL		;CLEAR $OPNFL FOR LPTDRV
	RET

	END
