/*
 ----------------------------------------------------------------
 |    Perlin Production Corporation, February-April 1993 (c).	|##
 |   WINDOW PACKAGE Source Code for SuperSoft C 1.2.3 compiler.	|##
 |    V e r s i o n  3.2 , part 2.  LAST CHANGES: 01.12.1993.	|##
 ----------------------------------------------------------------##
  #################################################################

			LIST OF FUNCTIONS:
	init_wns
	w_version
*/

#include "stdio.h"
#include "conio.h"

#define	_CUSTOMBORDER_

#include "wios.h"

/* Global package variables */

int werrno;

/* Pointers to structures with different border symbols */

PBORDER S_BORD;
PBORDER D_BORD;
PBORDER H_BORD;
PBORDER V_BORD;

char	*SCREEN;		/* Pointer to screen img */

int	init_wns()
{
	static char *Trade[3];
	register char *pb;

	Trade[0]="Perlin Production Co.Ltd. WIOS (TM). v. 4.0. 1994 (c).";
	Trade[1]="Window Interface Onscreen System runtime library.";
	Trade[2]="Saint-Petersburg, contact phone: 588-12-35.";

	if(pb=S_BORD=malloc(4*sizeof(tag_BORDER)+(((MAXX+1)*(MAXY+1)) << 1)))
			return werrno=WEALLOCATE;
	D_BORD=S_BORD+sizeof(tag_BORDER);
	H_BORD=D_BORD+sizeof(tag_BORDER);
	V_BORD=H_BORD+sizeof(tag_BORDER);
	SCREEN=V_BORD+sizeof(tag_BORDER);

/* Oh, this fuckin' SuperSoft C compiler !
	I'm very sorry for this style of initialization. Perlin V.A. */

	*pb++= SBHL;
	*pb++= SBVL;
	*pb++= SBLU;
	*pb++= SBRU;
	*pb++= SBRD;
	*pb++= SBLD;

	*pb++= DBHL;
	*pb++= DBVL;
	*pb++= DBLU;
	*pb++= DBRU;
	*pb++= DBRD;
	*pb++= DBLD;

	*pb++= HBHL;
	*pb++= HBVL;
	*pb++= HBLU;
	*pb++= HBRU;
	*pb++= HBRD;
	*pb++= HBLD;

	*pb++= VBHL;
	*pb++= VBVL;
	*pb++= VBLU;
	*pb++= VBRU;
	*pb++= VBRD;
	*pb++= VBLD;

	return werrno=WENOERR;
}

int	w_version()
{
	return(W_VERSION);
}
