#include<jctype.h>
#include"del_prn.h"

unsigned	Prn_carridge = 0;
unsigned	Prn_attr = 0;
unsigned	Prn_isvdouble = 1, Prn_ishdouble = 1;
unsigned	Prn_istategaki = 0;

unsigned	Prn_minheight_ = 0;
int		Prn_oldtype_ = CT_ANK;
int		Prn_islinestart_ = 1;
int		Prn_islinedouble_ = 0, Prn_islineunder_ = 0;
void		(*Prn_functable_[10])();
unsigned	Prn_funcnum_ = 0;

enum PRNERR	prn_init(void)
{
	register enum PRNERR	temp;

	if	(Prn_mode==PRNMODE_ESCP)
	{
	static	char	code[] = {
			0x1c,'&',		/* 漢字横書きモードの指定 */
			0x1c,0x0f,		/* 半角２バイト文字の指定 */
			0x1c,'S',1,2,		/* 全角文字の前後のｽﾍﾟｰｽ  */
			0x1c,'T',1,1,		/* 半角文字の前後のｽﾍﾟｰｽ  */
			0x1c,'U',		/* 半角文字ﾉ右ｽﾍﾟｰｽの補正 */
			'\r' };

		temp = prn_putcode(sizeof(code),code);
		if	(temp)
			return temp;
	}
	else if	(Prn_mode==PRNMODE_MSX)
	{
	static	char	code[] = {
			0x1b,'K',		/* 漢字横書きモードの指定 */
			0x1a,'N',		/* 漢字27/180ドットピッチ */
			'\r' };

		temp = prn_putcode(sizeof(code),code);
		if	(temp)
			return temp;
	}
	else if	(Prn_mode==PRNMODE_PCPR)
	{
	static	char	code[] = {
			0x1b,'K',		/* 漢字横書きモードの指定 */
			0x1a,'A',		/* 3/20(==27/180)ﾄﾞｯﾄﾋﾟｯﾁ */
			'\r' };

		temp = prn_putcode(sizeof(code),code);
		if	(temp)
			return temp;
	}

	Prn_carridge = 0;
	Prn_funcnum_ = 0;
	Prn_islinedouble_ = Prn_islineunder_ = 0;
	Prn_oldtype_ = CT_ANK;
	Prn_islinestart_ = 1;
	Prn_minheight_ = 0;

	if	((temp=prn_hsize(1))    ||
		 (temp=prn_vsize(1))    ||
		 (temp=prn_setattr(0))  ||
		 (temp=prn_tategaki(0)))
		return temp;

	return PRNERR_OK;
}
