
; Update to LSDOS 6.3.1 2022-09-16 dpm

zJCL		LD	DE,JCLCB$	;JCL file FCB
		JR	zGET
zKBD		LD	DE,KIDCB$	;KIDCB$, keyboard DCB
zGET		PUSH	BC
		LD	B,1		;Bit 0, GET
		JR	IOBGN	
zPRT		LD	DE,PRDCB$	;Printer DCB
		JR	zPUT
zDSP		LD	DE,DODCB$	;DODCB$ - Video DCB
zPUT		PUSH	BC
		LD	B,2		;Bit 1, PUT

; I/O begin on entry - DE	DCB.

IOBGN		PUSH	IX		;Save the registers
		PUSH	HL
		PUSH	DE		;Xfer DCB to IX
		POP	IX
		PUSH	DE
		LD	C,A		;Xfer the I/O char
		LD	HL,zRSTREG	;Restore register routine
		LD	A,(LBANK$)	;If bank 0 is not
		OR	A		;resident, need to
		JR	Z,$?0		; Skip <get> resident!		

; Some other bank is resident - invoke bank 0
			
		PUSH	BC		;Save reg again
		XOR	A		;Prepare for bank-0
		LD	B,A
		LD	C,A
		CALL	zBANK		;Invoke bank-0
		LD	H,B		;Get old bank data
		LD	L,C		;into reg HL
		POP	BC		;Rcvr BC
		PUSH	HL		;Bank data to stack
		LD	HL,RSTBNK	;Set return address
$?0		PUSH	HL		;to restore registers
		LD	A,(DE)		;p/u DCB type byte
		OR	A
		RET	Z		;Back if nothing
		CP	8		;Ck on GET/PUT/CTL
		JR	NC,zCHNIO	;Branch if special
		LD	L,(IX+1)	;else p/u the vector
		LD	H,(IX+2)
$?1		LD	A,B		;Xfer I/O code
		CP	2		;Set flags state
		JP	(HL)
RSTBNK		POP	BC		;Get old bank data
		PUSH	AF		;Can"t affect AF
		LD	A,C		;Request to A
		CALL	zBANK		;Bring back original bank
		POP	AF
zRSTREG		POP	DE		;Restore regs
		POP	HL
		POP	IX
		POP	BC
		RET