;	kgetchar.a - KGetChar implementation using ROM routines
;	$VER: kgetchar.a 37.1 (10.5.96)
;	Copyright © 1996 Michael Letowski
;
;	37.1 (10.5.96) - initial version

	include	"exec/funcdef.i"
	include	"exec/exec_lib.i"

	xdef	_KGetChar
	xdef	@KGetChar

; Some aliases

	xdef	_kgetc
	xdef	@kgetc
	xdef	KGetChar

	section	text,code


******* debug.lib/KGetChar **************************************************
*
*   NAME
*       KGetChar -- get a character from the debugging console. (V37)
*
*   SYNOPSIS
*       char = KGetChar()
*       D0
*
*       LONG KGetChar(VOID);
*
*   FUNCTION
*       Busy waits until a character arrives from the debugging console
*       (defaults to the serial port at 9600 baud).
*
*   RESULT
*       char - a character that arrived from console.
*
*   NOTES
*       @KGetChar, @kgetc and KGetChar are identical assembly interfaces.
*       _KGetChar, _kgetc are the C interfaces.
*
*****************************************************************************
*
* _KGetChar(void)
* @KGetChar(void)
*
_KGetChar:
_kgetc:
@KGetChar:
@kgetc:
KGetChar:
	move.l	a6,-(sp)			; Save a6
	move.l	(4).w,a6			; Load a6 with SysBase
Loop:
	jsr	_LVORawMayGetChar(a6)		; Try to get char
	tst.l	d0				; Got it?
	bmi.b	Loop				; No - loop
	move.l	(sp)+,a6			; Restore a6
	rts					; Return d0

	end
