;       SCCSID = @(#)bmsmain.inc	6.1 90/11/16
;	SCCSID = @(#)bmsmain.inc	12.3 88/03/30
;STJFMT,DISABLE
Wait_		EQU	1		; Wait option
PTRCONTROL	EQU	03H		; Category code for generic IOCtl
MOUSECONTROL	EQU	07H		; Category code for generic IOCtl
DYNLINKINITDONE EQU	1		; Dynlink initialization done
INITREALDONE	EQU	2		; MouInitReal done
LOADMODULEDONE	EQU	4		; PM modules loaded
;
;	MOU call function code equates
;
MouGetNumButtons	EQU	00h
MouGetNumMickeys	EQU	01h
MouGetDevStatus 	EQU	02h
MouGetNumQueEl		EQU	03h
MouReadEventQue 	EQU	04h
MouGetScaleFact 	EQU	05h
MouGetEventMask 	EQU	06h
MouSetScaleFact 	EQU	07h
MouSetEventMask 	EQU	08h
MouGetHotKey		EQU	09h
MouSetHotKey		EQU	0Ah
MouOpen 		EQU	0Bh
MouClose		EQU	0Ch
MouGetPtrShape		EQU	0Dh
MouSetPtrShape		EQU	0Eh
MouDrawPtr		EQU	0Fh
MouRemovePtr		EQU	10h
MouGetPtrPos		EQU	11h
MouSetPtrPos		EQU	12h
MouInitReal		EQU	13h
MouSetDevStatus 	EQU	14h
;
;	Mouse IOCTL function code equates
;
IOMR_NB EQU	60H			; Get # of mouse buttons
IOMR_MC EQU	61H			; Get # of mickeys/centimeter
IOMR_GS EQU	62H			; Get device status flags
IOMR_RD EQU	63H			; Read event queue contents
IOMR_QS EQU	64H			; Get # of event queue element(s)
IOMR_GM EQU	65H			; Get current event mask
IOMR_GF EQU	66H			; Get current scaling factors
IOMR_GP EQU	67H			; Get pointer screen position
IOMR_PS EQU	68H			; Get pointer shape image
IOMR_GK EQU	69H			; Get hot key button mask
IOMR_GV EQU	6AH			; Get mouse version number
IOMW_SC EQU	50H			; Allow pointer drawing
IOMW_SM EQU	51H			; Update screen display mode
IOMW_SN EQU	52H			; Screen switcher call
IOMW_SS EQU	53H			; Set new scaling factors
IOMW_EM EQU	54H			; Set new event mask
IOMW_SK EQU	55H			; Set hot key
IOMW_PS EQU	56H			; Set new pointer shape
IOMW_DP EQU	57H			; Draw pointer-unmarked collision area
IOMW_RP EQU	58H			; Remove pointer-mark collision area
IOMW_SP EQU	59H			; Set pointer position
IOMW_SD EQU	5AH			; Set protect mode pointer draw
					;   routine address
IOMW_RS EQU	5BH			; Set real mode pointer draw
					;   routine address
IOMW_DS EQU	5CH			; Set device status flags
IOMW_MD EQU	5DH			; Mode done
;
;	Pointer draw control function code
;
IOSR_GP EQU	72H			; Get pointer draw routine address
;
;	Stack frame structure for PUSHA instruction
;
PUSHA_STACK	STRUC
  DI_REG	DW	?
  SI_REG	DW	?
  BP_REG	DW	?
  SP_REG	DW	?		; Original SP before PUSHA
  BX_REG	DW	?
  DX_REG	DW	?
  CX_REG	DW	?
  AX_REG	DW	?
PUSHA_STACK	ENDS
;
;	Stackframe for general MouXxx calls
;
STACKFRAME	STRUC
		dw	?		; Who is caller (0=app, 1=BVS)
		dw	?		; Screen group number
		dw	?		; Offset to screen group data
		dw	?		; Offset to open/close FS semaphore
					;   for screen group
		dw	?		; Draw routine return code   **
		dd	?		; Draw routine address	     ** KEEP
		dw	?		; Draw routine Data Selector ** THIS
		dw	?		; Reserved (=0) for IOMW_SD  ** ORDER
					;   and IOMW_RS IOCTLs	     **
		dw	?		; Display configuration being opened
		dw	3 DUP (?)	; Temporary open/close storage
		dw	?		; Draw routine handle
		dw	?		; DosOpen action taken
		dw	?		; Temp storage for mouse handle
		db	14 DUP (?)	; Pointer draw name string
  RetAddr	dd	?		; Return address of MOUROUT (far)
		dw	?		; Save area for caller's DS
		dw	?		; MOUxxx return address     (near)
  FunctionNum	dw	?		; FunctionNum aurgment passed to MOUROUT
		dd	?		; Return address of original caller (far)
  DeviceHandle	dw	?		; Mouse device handle
  Parm1of2	dd	?		; 1st of 2 parameter arguments
					;   or 2nd of 3 parameter arguments
  Parm1of3	dd	?		; 1st of three parameter arguments
STACKFRAME	ENDS
;
;	Stackframe for MouOpen
;
MOUSEOPENPROT	STRUC
		dw	?		; Who is caller (0=app, 1=BVS)
		dw	?		; Screen group number
		dw	?		; Offset to screen group data
		dw	?		; Offset to open/close FS semaphore
					;   for screen group
		dw	?		; Draw routine return code   **
		dd	?		; Draw routine address	     ** KEEP
		dw	?		; Draw routine Data Selector ** THIS
		dw	?		; Reserved (=0) for IOMW_SD  ** ORDER
					;   and IOMW_RS IOCTLs	     **
		dw	?		; Display configuration being opened
		dw	3 DUP (?)	; Temporary open/close storage
		dw	?		; Draw routine handle
		dw	?		; DosOpen action taken
		dw	?		; Temp storage for mouse handle
		db	14 DUP (?)	; Pointer draw name string
		dd	?		; Return address of MOUROUT (far)
		dw	?		; Save area for caller's DS
		dw	?		; MOUxxx return address     (near)
		dw	?		; FunctionNum aurgment passed to MOUROUT
		dd	?		; Return address of original caller (far)
  HandleAddress dd	?		; Address of mouse handle to be returned
  DrawNameOffP	dw	?		; Address of draw routine name
  DrawNameSelP	dw	?		;   (selector:offset)
MOUSEOPENPROT	ENDS
;
;	Stackframe for MouInitReal
;
MOUSEOPENREAL	STRUC
		dw	?		; Who is caller (0=app, 1=BVS)
		dw	?		; Screen group number
		dw	?		; Offset to screen group data
		dw	?		; Offset to open/close FS semaphore
					;   for screen group
		dw	?		; Draw routine return code   **
		dd	?		; Draw routine address	     ** KEEP
		dw	?		; Draw routine Data Selector ** THIS
		dw	?		; Reserved (=0) for IOMW_SD  ** ORDER
					;   and IOMW_RS IOCTLs	     **
		dw	?		; Display configuration being opened
		dw	3 DUP (?)	; Temporary open/close storage
		dw	?		; Draw routine handle
		dw	?		; DosOpen action taken
		dw	?		; Temp storage for mouse handle
		db	14 DUP (?)	; Pointer draw name string
		dd	?		; Return address of MOUROUT (far)
		dw	?		; Save area for caller's DS
		dw	?		; MOUxxx return address     (near)
		dw	?		; FunctionNum aurgment passed to MOUROUT
		dd	?		; Return address of original caller (far)
  DrawNameOffR	dw	?		; Address of draw routine name
  DrawNameSelR	dw	?		;   (selector:offset)
MOUSEOPENREAL	ENDS
;
;
;
; Common stackframe equates
;
WhoIsCaller	EQU	WORD PTR[bp+00h] ; Who is caller (0=app, 1=BVS)
Mou_SG		EQU	WORD PTR[bp+02h] ; Screen group number
ScrnGrpDataOff	EQU	WORD PTR[bp+04h] ; Offset to screen group data
OpenCloseFSSemOff EQU	WORD PTR[bp+06h] ; Offset to open/close FS semaphore
;					 ;   for screen group
;
;  Open, close, initreal stackframe equates.  These are non-Winthorn
;  variables.  Keep DrawRoutineErr,  DrawRoutineAddr, and DrawRoutineDS
;  together.
;
DrawRoutineErr	EQU	WORD PTR[bp+08h] ; Draw routine return code   **
DrawRoutineAddr EQU	WORD PTR[bp+0Ah] ; Draw routine address       ** KEEP
DrawRoutineDS	EQU	WORD PTR[bp+0Eh] ; Draw routine Data Selector ** THIS
DrawRoutineRsvd EQU	WORD PTR[bp+10h] ; Reserved (=0) for IOMW_SD  ** ORDER
					 ;   and IOMW_RS IOCTLs       **
WorkConfig	EQU	WORD PTR[bp+12h] ; Display configuration being opened
ScratchArea	EQU	WORD PTR[bp+14h] ; Temporary open/close storage
DrawHandle	EQU	WORD PTR[bp+1Ah] ; Draw routine handle
ActionTaken	EQU	WORD PTR[bp+1Ch] ; Used for DosOpen
MouseHandle	EQU	WORD PTR[bp+1Eh] ; Temp storage for mouse handle
WorkPtrName	EQU	BYTE PTR[bp+20h] ; Pointer draw name string
;
;
;
;	Per Screen Group Active Pointer Draw Routine Name
;
SCRNGRPDATA	STRUC
  AppPtrDrawName db	8 DUP (?)	; App-specified ptr draw routine
  OwnerPID	dw	?		; Owner PID
					;   0 - Use system default
					;	draw routine
					;  >0 - Use screen default
					;	draw routine
  OwnerHandle	dw	?		; Owner mouse DD handle
  BvsMouHandle	dw	?		; BVS Mouse DD Handle
  OpenCloseFSSem db	14 DUP (?)	; Open/close FS RAM semaphore
					;   structure
SCRNGRPDATA	ENDS
SCRNGRPSIZE	EQU	TYPE SCRNGRPDATA
;
;
;
;	VioGetConfig data structure
;
CONFIGDATA	STRUC
  CF_StrucLen		dw	?	; Length of structure
  CF_AdapterType	dw	?	; Adapter type
  CF_DisplayType	dw	?	; Display type
  CF_Memory		dd	?	; Memory on card
  CF_ConfigNum		dw	?	; ConfigNum
  CF_DDVersion		dw	?	; Device driver version
  CF_Flags		dw	?	; Flag bits
  CF_HWStateSize	dd	?	; Hardware state buffer size
  CF_FullSaveSize	dd	?	; Full save size
  CF_PopupSaveSize	dd	?	; Partial save size
  CF_EmulAdapOfs	dw	?	; Emulated adapters offset
  CF_EmulDispOfs	dw	?	; Emulated dispalys offset
CONFIGDATA	ENDS
;
;
;
;	FS Ram Semaphore Structure
;
FSRAMSEM	STRUC
  FS_Len	dw	?
  FS_PID	dw	?
  FS_TID	dw	?
  FS_Count	dw	?
  FS_Client	dw	?
  FS_Sem	dd	?
FSRAMSEM	ENDS
;
;
;
;****************************************************************
;*  Global Segment Variables					*
;****************************************************************
;
GDSEG	SEGMENT WORD PUBLIC 'DATA'

InitFlag	dw	0		; InitFlag
MouseFileName	db	'\DEV\MOUSE$',0 ; Mouse device name
GlobalSeg	dw	0		; Global information selector
LocalSeg	dw	0		; Local information selector
MouseVer	dw	0		; Mouse DD version number
LastBaseSG	dw	0		; Highest SG before Winthorn
SkeletonPtrName db	'\DEV\        ',0  ; Skeleton pointer draw name

;Winthorn Dynamic link module entry points and module names		CDB2
;The code is table driven and therefore care should be taken in 	CDB2
;rearranging this table.						CDB2

	PUBLIC	LoadWinthorn				;		CDB2
	PUBLIC	WINCONSOLEFLUSHPOINTEREVENTS		;		CDB2
	PUBLIC	WINCONSOLEQUEUEDPOINTEREVENTS		;		CDB2
	PUBLIC	WINCONSOLEREADPOINTEREVENT		;		CDB2
	PUBLIC	WINCONSOLEGETPOINTERFILTERMASK		;		CDB2
	PUBLIC	WINCONSOLESETPOINTERFILTERMASK		;		CDB2
	PUBLIC	WINCONSOLEGETPTRPOS			;		CDB2
	PUBLIC	WINCONSOLESETPTRPOS			;		CDB2
	PUBLIC	WINCONSOLEATTACHMOUSEUSER		;		TPL
	PUBLIC	WINCONSOLEDETACHMOUSEUSER		;		TPL
	PUBLIC	ShieldEntries				;		CDB2
	PUBLIC	Shield_DLL				;		CDB2

ShieldEntries			dw  9	; Number of Shield Entries	CDB2
ShieldHandle			dw  0	; SHIELD module handle		CDB2
WINCONSOLEFLUSHPOINTEREVENTS	dd  0	; Shield procedure addresses	CDB2
WINCONSOLEQUEUEDPOINTEREVENTS	dd  0	;				CDB2
WINCONSOLEREADPOINTEREVENT	dd  0	;				CDB2
WINCONSOLEGETPOINTERFILTERMASK	dd  0	;				CDB2
WINCONSOLESETPOINTERFILTERMASK	dd  0	;				CDB2
WINCONSOLEGETPTRPOS		dd  0	;				CDB2
WINCONSOLESETPTRPOS		dd  0	;				CDB2
WINCONSOLEATTACHMOUSEUSER	dd  0	;				TPL
WINCONSOLEDETACHMOUSEUSER	dd  0	;				TPL

Shield_DLL	LABEL	BYTE
	db	'PMVIOP'                        ; Name of SHIELD.DLL    CDB2
	db	0					;		CDB2
	db	'WINCONSOLEFLUSHPOINTEREVENTS'          ; = SHIELD.19   CDB2
	db	0					;		CDB2
	db	'WINCONSOLEQUEUEDPOINTEREVENTS'         ; = SHIELD.17   CDB2
	db	0					;		CDB2
	db	'WINCONSOLEREADPOINTEREVENT'            ; = SHIELD.18   CDB2
	db	0					;		CDB2
	db	'WINCONSOLEGETPOINTERFILTERMASK'        ; = SHIELD.20   CDB2
	db	0					;		CDB2
	db	'WINCONSOLESETPOINTERFILTERMASK'        ; = SHIELD.21   CDB2
	db	0					;		CDB2
	db	'WINCONSOLEGETPTRPOS'                   ; = SHIELD.22   CDB2
	db	0					;		CDB2
	db	'WINCONSOLESETPTRPOS'                   ; = SHIELD.23   CDB2
	db	0					;		CDB2
	db	'WINCONSOLEATTACHMOUSEUSER'             ; = SHIELD.??   TPL
	db	0					;		TPL
	db	'WINCONSOLEDETACHMOUSEUSER'             ; = SHIELD.??   TPL
	db	0					;		TPL

	db	0					; Align screen group
							;   data on word
							;   boundary

END_OF_GDSEG	LABEL	BYTE
START_OF_SCRNGRP_DATA	EQU	OFFSET END_OF_GDSEG

GDSEG	ENDS
;
;
;
;****************************************************************
;*  Per Process Instance Data Variables 			*
;****************************************************************
;
IDSEG	SEGMENT WORD PUBLIC 'DATA'

ProcessInitFlag dw	0	; Process initialization flag
;
;  Winthorn variables
;
WTMouseHandle	dw	0	; Mouse handle used by Winthorn apps
MouOpenCnt	dw	0	; Mouse open count
hConsole	dw	0	; Shield Console Handle**keep together
MouFilter	dw	0	; Mouse Filter Mask    **keep together
PS_Sel		dw	0	; PS Selector	       **keep together
PtrBuffer	dw	0ffffh	; default pointer bit image	; @@THG01
		dw	7700h					; @@THG01
PtrDefRec	dw	4	; default pointer shape record	; @@THG01
		dw	1					; @@THG01
		dw	1					; @@THG01
		dw	0					; @@THG01
		dw	0					; @@THG01

IDSEG	ENDS
