#include<dos.h>
#include<del_prn.h>

int	prn_writebyte(char c)
{
	union	REGS	regs;
	register int	i;
retry:
	switch	(Prn_machine)
	{
	case PRNBIOS_NEC98:
		regs.h.ah = 0x11;
		regs.h.al = c;
		int86(0x1a,&regs,&regs);
		regs.h.ah &= 2;
		break;
	case PRNBIOS_TOWNS:
		regs.x.ax = 0x100;
		regs.h.dl = c;
		int86(0x94,&regs,&regs);
		break;
	case PRNBIOS_IBMPC:
	case PRNBIOS_J3100:
		if	(Prn_machine==PRNBIOS_IBMPC)
			regs.h.ah = 0;
		else
			regs.h.ah = 0x84;
		regs.h.al = c;
		regs.x.dx = 0;
		int86(0x17,&regs,&regs);
		regs.h.ah &= 1;
		break;
	default:
		return -1;
	}

	if	(regs.h.ah)
	{
		switch	(prn_harderr())
		{
		case PRNHERR_RETRY:
			goto retry;

		case PRNHERR_IGNORE:
			regs.h.ah = 0;

		case PRNHERR_FAIL:
			regs.h.ah = -1;
		}
	}

	for	(i=128 ; i ; i--)
		;

	return (int)regs.h.ah;
}

