
Listing 1: The EVENT class

class Event {
	public:
		DOSMSG DosMsg;
		// Class overhead and management;
		Event();		// Class constructor
		~Event();	// Class destructor
		// Mouse-specific functions;
		BOOL	HasMouse();
		POINT	WhereMouseXY();
		BOOL	SetMouseXY(int, int);
		// Keyboard-specific functions;
		int	WhereX();
		int	WhereY();
		POINT	WhereXY();
		BOOL	GotoXY(int, int);
		// Message retreval;
		DOSMSG  *GetMessage(char *, int);
		DOSMSG  *GetMessage(BOOL);
		// Miscellaneous functions;
		void	BellAlert(BOOL);
	private:
		int	C1X;	// Keyboard cursor (cursor #1)
		int	C1Y;	// ibid.
		int	C2X;	// Mouse cursor (cursor #2)
		int	C2Y;	// ibid.
		int	BUTTON;	// 'L', 'R', NULL code
		int	CTRLKEY;	// 2nd value of scan code
		int	bx, cx, dx; // used for register calls
		BOOL	bMouseOn;	// TRUE = Mouse Installed
		BOOL	bBellOn;	// BEEP on error
		int	GetEvent();
		// inline 4speed;
		int	_mouse(int, int *, int *, int *);
		int	MouseStatus();
		// Ret FALSE (0) if no mouse
		BOOL	MouseReset();
		// Only used for graphics mode.
		void	install_cursor_image(void); };

Listing 2: EVENT's constructor and destructor 

Event::Event(){
  CTRLKEY = NULL;
  bBellOn  = TRUE;
  // Ret T if mouse installed
  bMouseOn = MouseReset();
  if(bMouseOn == TRUE) {
	bx = cx = dx = 0;
	// Turn the mouse on
	_mouse(MOUSE_ON, &bx, &cx, &dx);
	// Set C2X, C2Y, and BUTTON
	MouseStatus();}
  // init keyboard stuff
  WhereXY();
	_setcursortype(_NOCURSOR); } //Event()

Event::~Event(){
  if(bMouseOn == TRUE) {
	// Turn the mouse off
	bx = cx = dx = 0;
	_mouse(MOUSE_OFF, &bx, &cx, &dx);
  } else {
	// destruct keyboard stuff
	// (not needed on DOS)
  }
	_setcursortype(_NORMALCURSOR); } //~Event()

Listing 3: Checking for Windows enhanced mode

; *******************************
; Check for windows 3.0, 2.0
; AL = 1 if found, else AL = 0
; *******************************
is_win30 proc near
   mov  ax,1600h ;Test for enhanced mode
   int  2Fh
   or   al,al    ;extended check, AL==00h
   jz   rstest
   cmp  al,80h   ;extended check, AL==80h
   je   rstest
found_it:
   mov  al,1;    ;set AL
   ret           ;return found
rstest:
   mov  ax,4680h ;see real or standard?
   int  2Fh
   or   ax,ax    ;if AX==0
   jz   found_it ;then we got it
                 ; else
   xor  al,al    ;reset AL
   ret           ;return not found
is_win30 endp

; *******************************
; Check for Windows 3.1
; CX = 3 enhanced, CX = 2 standard mode
; *******************************
is_win31 proc near
   mov   ax,160ah ;windows there?
   int   2fh
   ret
is_win31 endp

; *******************************
; Give-up time slice to Windows VM
; *******************************
to_win31 proc near
   mov   ax,352fh      ;get DOS vector
   int   21h
   move  ax, es
   or    ax, bx        ;Is it there?
   jz    no_need       ; nope..
   mov   ax, 1680h     ;back to windows
   int   2fh           ; give it up
no_need:
   ret
to_win31 endp

END OF FILE