/*
 *	Simple terminal emulator for Atari ST
 *
 *	Martin Guy, UKC, 8th March 1988
 */

#include <osbind.h>

/* Device codes to pass to Bconstat(), Bconin() and Bconout() */
#define PRT 0	/* printer */
#define AUX 1	/* RS232 */
#define CON 2	/* Console (ie screen and keyboard) */
#define MIDI 3	/* Atari MIDI port */
#define KBD 4	/* Atari Keyboard port */

main()
{
	while (1) {
		register int i;		/* no keyboard starvation loop counter */
		register int ch;

		/* highest priority: grabbing line input */
		for (i=32; i>0 && Bconstat(AUX) != 0; i--) {
			ch = Bconin(AUX);
			Bconout(CON, ch);
		}
		
		if (Bconstat(CON) != 0) {
			ch = Bconin(CON);
			if ((ch & 0xFF) == 0) {	/* what UNDO sends */
				exit(0);
			}
			Bconout(AUX, ch);
		}
	}
}
