
*	ReadOneChar.asm (of PCQ Pascal runtime library)
*	Copyright (c) 1989 Patrick Quaid

*	This module implements a simple buffering scheme for
*	standard in.  We don't always buffer a character- we only buffer
*	one when we have read one too many.

	SECTION	ONE

	XREF	stdinbuffed
	XREF	stdinbuffer
	XREF	_stdin
	XREF	_p%DOSBase
	XREF	_LVORead

	XDEF	_p%readonechar
_p%readonechar
	tst.b	stdinbuffed
	beq.s	1$
	move.b	#0,stdinbuffed
	rts
1$	movem.l	d1-d3,-(sp)
	move.l	_stdin,d1
	move.l	#stdinbuffer,d2
	move.l	#1,d3
	move.l	_p%DOSBase,a6
	jsr	_LVORead(a6)
	move.b	#-1,stdinbuffed
	movem.l	(sp)+,d1-d3
	rts

	XDEF	_p%getthatchar
_p%getthatchar
	move.b	stdinbuffer,d0
	move.b	#0,stdinbuffed
	rts

	END
