#include"del_prn.h"

static	void	restorevsize(void)
{
	if	(Prn_islinedouble_ && Prn_isvdouble==1)
	{
		Prn_minheight_   -= 24;
		Prn_islinedouble_ = 0;
	}
}

enum PRNERR	prn_vsize(unsigned mode)
{
	enum PRNERR	temp;

	if	(mode==2)
	{
		if	(Prn_mode==PRNMODE_ESCP)
		{
			static	char	code[] = {0x1c,'W',1,0x1b,'W',0};

			if	(Prn_ishdouble == 2)	code[5] = 1;
			else				code[5] = 0;

			temp = prn_putcode(6,code);
			if	(temp)
				return temp;
		}
		else if	(Prn_mode==PRNMODE_MSX || Prn_mode==PRNMODE_PCPR)
		{
			static	char	code[] = {0x1b,'e','2','1'};

			if	(Prn_ishdouble == 2)	code[3]='2';
			else				code[3]='1';

			temp = prn_putcode(4,code);
			if	(temp)
				return temp;
		}
		else
			return PRNERR_BADDATA;

		if	(Prn_islinedouble_ == 0)
		{
			Prn_functable_[Prn_funcnum_++] = restorevsize;

			Prn_islinedouble_ = 1;
			Prn_minheight_ += 24;
		}
	}
	else if	(mode==1)
	{
		if	(Prn_mode==PRNMODE_ESCP)
		{
			static	char	code[] = {0x1c,'W',0,0x1b,'W',0};

			if	(Prn_ishdouble == 2)	code[5] = 1;
			else				code[5] = 0;

			temp = prn_putcode(6,code);
			if	(temp)
				return temp;
		}
		else if	(Prn_mode==PRNMODE_MSX || Prn_mode==PRNMODE_PCPR)
		{
			static	char	code[] = {0x1b,'e','1','1'};

			if	(Prn_ishdouble==2)	code[3]='2';
			else				code[3]='1';

			temp = prn_putcode(4,code);
			if	(temp)
				return temp;
		}
		else
			return PRNERR_BADDATA;

		if	(Prn_islinestart_ && Prn_isvdouble==2)
		{		/* 詳細は内部資料マニュアル参照 */

			Prn_minheight_   -= 24;
			Prn_islinedouble_ = 0;
		}
	}
	else
		return PRNERR_BADDATA;

	return PRNERR_OK;
}
