******************************* Wait routine ******************************

	SECTION		printer

*--------- Included Files -------------------------------------------------

	INCLUDE		"exec/types.i"
	INCLUDE		"exec/ports.i"
	INCLUDE		"exec/devices.i"
	INCLUDE		"exec/io.i"

	INCLUDE		"devices/timer.i"

	INCLUDE		"macros.i"
	INCLUDE		"devices/prtbase.i"

*--------- Imported Functions --------------------------------------------

	XREF_EXE	Forbid
	XREF_EXE	Permit
	XREF_EXE	WaitIO
	XREF		_SysBase

	XREF		_PD

*--------- Exported Functions --------------------------------------------

	XDEF		_PWait

*--------- printer.device/PWait ------------------------------------------
*
*   NAME
*        PWait - wait for a time
*
*   SYNOPSIS
*        PWait(seconds,microseconds)
*
*   FUNCTION
*        PWait uses the timer device to wait after writes are complete
*
*------------------------------------------------------------------------

_PWait:
	MOVEM.L	A4/A6,-(A7)
	MOVE.L	_PD,A4
	MOVE.L	pd_PBothReady(A4),A0
	JSR	(A0)
	TST.L	D0
	BNE.S	error

	LEA	pd_TIOR(A4),A1
	MOVE.W	#TR_ADDREQUEST,IO_COMMAND(A1)
	MOVE.L	12(A7),IOTV_TIME+TV_SECS(A1)
 	MOVE.L	16(A7),IOTV_TIME+TV_MICRO(A1)
	CLR.B	IO_FLAGS(A1)
	MOVE.L	IO_DEVICE(A1),A6
	JSR	DEV_BEGINIO(A6)
	LINKEXE	Forbid
	LEA	pd_TIOR(A4),A1
	LINKEXE	WaitIO
	LINKEXE	Permit
	MOVEQ	#0,D0
	TST.L	D0

error:
	MOVEM.L	(A7)+,A4/A6
	RTS

	END
