#include <dos/dos.h>
#include <proto/dos.h>
#include <string.h>

static BPTR stdout;
static UBYTE buf[256];
static int bufptr;

void _STI_print()
{
	stdout = Output();
	bufptr = 0;
}

void printchar(char c)
{
	buf[bufptr++] = c;
	if (c == '\n' || bufptr >= 256) {
		Write(stdout, buf, bufptr);
		bufptr = 0;
	}
}

void print(char *s)
{
	while (*s)
		printchar(*s++);
}

void printlong(long l)
{
	char buf[12];

	stcl_d(buf, l);
	print(buf);
}

void printaddr(long l)
{
	int n;
	char buf[9];

	n = stcl_h(buf, l);
	while (n++ < 8)
		printchar('0');
	print(buf);
}

void printhex(short s)
{
	int n;
	char buf[5];

	n = stci_h(buf, s);
	while (n++ < 4)
		printchar('0');
	print(buf);
}
