#define IDM_ABOUT		100
#define WTERM_EXIT		101
#define IDM_NAME		102
#define WTERM_CONNECT	201
#define WTERM_SHUTDOWN	202

#define WTERMICON		1

#define IRMX_CHARS      WM_USER+1   // characters received from iRMX

#define MK_FP(seg, off) ((void far*) ((unsigned long) (seg)<<16 | (off)));
#define BUFFER(x, y) *(pBuffer + y * cxBuffer +x)

#define MAX_COLUMN		80
#define MAX_ROW			25

#define EOK				0
#define rootjob			3
#define callingtask		0

int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
long FAR PASCAL MainWndProc(HWND, unsigned, WORD, LONG);
BOOL FAR PASCAL About(HWND, unsigned, WORD, LONG);
void Process_Text_Buffer(HWND, WORD, LPSTR);
void Scroll_Window_Up(unsigned, unsigned, HWND);
void Scroll_Window_Down(unsigned, unsigned, HWND);
void Signal_iRMX(HWND);
void Paint_Window(HWND);
BOOL Make_Connection(HWND);

extern unsigned pascal RQLookupObject(unsigned, unsigned char far *, unsigned, unsigned far *);
extern void pascal RQSendMessage(unsigned, unsigned, unsigned, unsigned far *);
extern unsigned pascal RQGetTaskTokens(unsigned char, unsigned far *);

HANDLE hInst;			  // current instance

typedef struct {
		 char flag_byte;
		 char data_byte;
		} OUTPUT_BUFFER;

typedef struct {
		 char count;
		 char data_byte[29];
		} INPUT_BUFFER;

unsigned char vm86[12] ={10,'R','?','V','M','8','6','_','J','O','B',0};

unsigned char kb_mb[14] ={12,'R','?','K','B','_'
							,'M','A','I','L','B','O','X',0};

OUTPUT_BUFFER far *out_buf= MK_FP (0x0040, 0xE0);
INPUT_BUFFER  far *in_buf = MK_FP (0x0040, 0xE2);

static unsigned	roottoken;
static unsigned	vm86j;
static unsigned	Kb_Mux;
static unsigned	except;
static unsigned	response;
static unsigned	segment;
static unsigned	rootjobtoken;

static unsigned char KB_Char;
char	MsgBuff[30];		// Buffer to hold incoming characters

BOOL	Connected = FALSE;		// Flag to indicate if connected

BOOL	Stop_output = FALSE;
short	Routine_index = 0;

static char		*pBuffer = NULL;
static int		cxChar, cyChar, cxBuffer, cyBuffer;
static int		xCaret, yCaret;
static int		x, y, i;
static short	xClientView = 0;
static short	yClientView = 0;
static short	xscreen, yscreen;

