home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / MOUSE / UTIL2.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  61KB  |  1,334 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.  
  13. ;/*************************************************************************
  14. ;*                                                                         
  15. ;* SOURCE FILE NAME = UTIL2.ASM                                                                   
  16. ;*                                                                                                          
  17. ;* DESCRIPTIVE NAME = Mouse swapable utility routines.                         
  18. ;*                                                                         
  19. ;*                                                                         
  20. ;* VERSION      V2.0                                                       
  21. ;*                                                                         
  22. ;* DATE         08/30/91
  23. ;*                                                                         
  24. ;* DESCRIPTION  This file contains mouse utility routines.                                      
  25. ;*              See linker control file for location in link list.
  26. ;*
  27. ;* FUNCTIONS    GetDeviceParms   
  28. ;*              InitSDevice      
  29. ;*              AccessCheck      
  30. ;*              QueueRead        
  31. ;*              PtrDrawCheck                                                                
  32. ;*              GetExtModeData   
  33. ;*              FlushMonChain    
  34. ;*              SaveCfgData      
  35. ;*              GetCfgDataOffset 
  36. ;*              SaveExtModeData  
  37. ;*              EnableMouse      
  38. ;*              DisableMouse     
  39. ;*              SGCreate                                                                    
  40. ;*              SGSwitchStart    
  41. ;*              SGSwitchEnd                                                                 
  42. ;*              InitFSCB         
  43. ;*                                                                         
  44. ;* EXTERNAL FUNCTIONS                                                      
  45. ;*                                                                         
  46. ;*              NONE                                                       
  47. ;*                                                                         
  48. ;* CHANGE ACTIVITY =                                                       
  49. ;*   DATE      FLAG        APAR   CHANGE DESCRIPTION                       
  50. ;*   --------  ----------  -----  --------------------------------------   
  51. ;*   mm/dd/yy  @Vr.mpppxx  xxxxx  xxxxxxx                                  
  52. ;**************************************************************************
  53.                                                                     
  54.  
  55. .xlist
  56.         include basemaca.inc
  57.         include osmaca.inc
  58.         include mouse.inc
  59.         include emiidc.inc                                                ;emi
  60. .list
  61.  
  62. CPUMODE 386
  63.  
  64. ;*
  65. ;* External symbols used in this module
  66. ;*
  67.  
  68.        extrn  DDD              : byte
  69.        extrn  DDD2             : byte
  70.        extrn  DeviceData       : byte
  71.        extrn  SInt_Packet      : byte                                     ;emi
  72.        extrn  AccessTbl        : byte
  73.        extrn  CallSessn        : byte
  74.        extrn  Ptr_Overide      : byte
  75.        extrn  ext_mode_data    : byte
  76.        extrn  Num_Grps         : byte
  77.        extrn  FullScrCBs       : byte
  78.        extrn  TypeOverRider    : byte
  79.        extrn  FgndSessn        : byte
  80.        extrn  EmiFlags         : byte                                     ;emi
  81.  
  82.        extrn  DDDInit          : word
  83.        extrn  EMaskMax         : word
  84.        extrn  Eq_Length        : word
  85.        extrn  cfg_offset       : word
  86.        extrn  free_space       : word
  87.        extrn  free_offset      : word
  88.        extrn  DevStatus        : word
  89.  
  90.        extrn  Device_Help      : dword
  91.        extrn  FgndCB           : dword
  92.  
  93.        extrn  MSEVDDEntry      : fword
  94.  
  95.        extrn  AllocCB           : near
  96.        extrn  FindCB            : near
  97.        extrn  Emi_far           : far                                     ;emi
  98.  
  99.        EXTRNFAR CollisionChk
  100.  
  101. CSEG2   SEGMENT   WORD  PUBLIC  USE16 'SWAPCODE'
  102.         ASSUME    CS:CSEG2, SS:NOTHING, ES:NOTHING, DS:NOTHING
  103.  
  104. ;*
  105. ;* Publics defined by this module
  106. ;*
  107.  
  108.        public  GetDeviceParms
  109.        public  InitSDevice
  110.        public  AccessCheck
  111.        public  QueueRead
  112.        public  PtrDrawCheck
  113.        public  GetExtModeData
  114.        public  FlushMonChain
  115.        public  SaveCfgData
  116.        public  GetCfgDataOffset
  117.        public  SaveExtModeData
  118.        public  EnableMouse
  119.        public  DisableMouse
  120.        public  SGSwitchStart
  121.        public  SGSwitchEnd
  122.        public  SGCreate
  123.        public  InitFSCB
  124.  
  125. ;***********************************************************************
  126. ;*                                                               
  127. ;*  FUNCTION NAME :  GetDeviceParms                             
  128. ;*                                                               
  129. ;*  DESCRIPTION   :  Call the device dependent DD to get the
  130. ;*                   device operation parameters.               
  131. ;*                                                                     
  132. ;*                   This routine is called to get the device parms
  133. ;*                   from the device dependent DD.  It will call the   
  134. ;*                   dependent DD only if this is a level 0 call.      
  135. ;*                   If the Get passes the DDInit flag is set to       
  136. ;*                   indicate so,  if it fails then the flag is set to 
  137. ;*                   indicate that also.  Data reporting is enabled
  138. ;*                   if the device parms are returned with no error.   
  139. ;*                                                               
  140. ;*  INPUT         :  None, DS is mouse data seg.
  141. ;*                                                               
  142. ;*  OUTPUT        : DDInit flag is set. 2=Initialized OK, -1=error.
  143. ;*                                                               
  144. ;*  SIDE EFFECTS  :  stack is clean.
  145. ;*                                                               
  146. ;***********************************************************************
  147. ;* PSEUDOCODE :
  148. ;*
  149. ;* BeginSub  GetDeviceParms
  150. ;*
  151. ;* IF <this is a level 0 request>
  152. ;*    call DDDD(Query_Config) to get device specific data
  153. ;*    IF <QueryConfig call worked>
  154. ;*       call DDDD(Read_Enable) to turn data reporting on
  155. ;*       IF <ReadEnable call worked>
  156. ;*          call DDDD(Enable_Device) to enable device interrupts
  157. ;*          set IDC flag to show IDC init done
  158. ;*       ELSE
  159. ;*          set IDC init flag to show IDC init failed.  All requests
  160. ;*             except opens and closes will fail device not ready
  161. ;*       ENDIF
  162. ;*    ELSE
  163. ;*       set IDC init flag to show IDC init failed.
  164. ;*    ENDIF
  165. ;* ENDIF
  166. ;* return
  167. ;*
  168. ;*EndSub  GetDeviceParms
  169. ;*
  170. ;***********************************************************************
  171.  
  172. GetDeviceParms  proc  near
  173.  
  174.        push bx
  175.        push es
  176.        mov  ax, cs                         ; put cs in ax
  177.        and  ax, 0003h                      ; save only CPL bits
  178.        .if <ax eq 0>  NEAR                 ; and we are at level 0
  179.           and  DDDInit, NOT DI_IDC         ; show we've tried to do IDC init
  180.           mov  ax, QUERYCONFIG             ; query config function
  181.           mov  di, offset DeviceData       ; offset to returned data
  182.           push ds                          ; save our ds on stack
  183.           push ds                          ; put our ds in es
  184.           pop  es
  185.           mov  ds, DDD.ProtDS              ; get DDs ds value
  186.           call es:DDD.ProtEntry            ; call DD
  187.           pop  ds
  188.           .if <nc>                         ; if there was no error
  189.              mov  al, DeviceData.NumButt   ; get byte value for # butts
  190.              cbw                           ; convert to word value
  191.              mov  bx, 0ffffh               ; init to all 1's
  192.              mov  cx, ax                   ; get number of buttons
  193.              shl  cx,1                     ; double for with and w/o events
  194.              inc  cx                       ; include motion only events
  195.              shl  bx, cl                   ; put 0's in valid event locations
  196.              not  bx                       ; invert to make valid events 1's
  197.              mov  EMaskMax, bx             ; save max event mask allowed
  198.              mov  ax, READENABLE           ; read enable function
  199.              mov  di, offset SInt_Packet   ; offset to shared data area   ;emi
  200.              push ds                       ; save our ds
  201.              push ds                       ; put ds on stack for switch
  202.              pop  es                       ; to es
  203.              mov  ds, DDD.ProtDS           ; get callers DS
  204.              call es:DDD.ProtEntry         ; go do the call
  205.              pop  ds                       ; restore our ds
  206.              .if <nc>                      ; if no error
  207.                 push ds                    ; put ds in fs for call
  208.                 pop  fs
  209.                 call EnableMouse           ; enable the mouse device now
  210.              .else                         ; else there was an error
  211.  
  212. ;*
  213. ;* if EMI is active, then continue even though the dependent mouse driver  ;emi
  214. ;* has failed. The system can use the EMI device instead.                  ;emi
  215. ;*                                                                          ;emi
  216.  
  217.                 .if  <bit EmiFlags z EMI_ACTIVE>                          ;emi
  218.                    or   DDDInit, DI_ERROR  ; fails all commands           ;emi
  219.                 .endif                                                    ;emi
  220.              .endif
  221.           .else                            ; else there was an error
  222.              .if  <bit EmiFlags z EMI_ACTIVE>                             ;emi
  223.                 or   DDDInit, DI_ERROR  ; fails all commands              ;emi
  224.              .endif                                                       ;emi
  225.           .endif                           ; end error check on query cfg
  226.        .endif
  227.  
  228.        pop  es
  229.        pop  bx
  230.  
  231.        ret
  232.  
  233. GetDeviceParms  endp
  234.  
  235.  
  236. ;***********************************************************************
  237. ;*                                                               
  238. ;*  FUNCTION NAME :  InitSDevice                                
  239. ;*                                                               
  240. ;*  DESCRIPTION   : Initialize the secondary device
  241. ;*                                                               
  242. ;*                  This routine is called to get the device parms
  243. ;*                  from the device dependent DD.  It will call the   
  244. ;*                  dependent DD only if this is a level 0 call.      
  245. ;*                  If the Get passes the DDInit flag is set to       
  246. ;*                  indicate so,  if it fails then the flag is set to 
  247. ;*                  indicate that also.  Data reporting is enabled    
  248. ;*                  if the device parms are returned with no error.   
  249. ;*                                                               
  250. ;*  INPUT         :  None, DS is mouse data seg.
  251. ;*                                                               
  252. ;*  OUTPUT        : DDInit flag is set. 2=Initialized OK, -1=error.
  253. ;*                                                               
  254. ;*  SIDE EFFECTS  :  stack is clean.
  255. ;*                                                               
  256. ;***********************************************************************
  257.  
  258. InitSDevice  proc  near
  259.  
  260.        push ax
  261.        push di
  262.        push es
  263.  
  264.        mov  ax, cs                      ; put cs in ax
  265.        .if <bit ax z 3> NEAR            ; If we are at level 0
  266.           push ds                       ; save our ds
  267.           mov  ax, READENABLE           ; read enable function
  268.           mov  di, offset SInt_Packet   ; offset to shared data area      ;emi
  269.           push ds                       ; put ds on stack for switch
  270.           pop  es                       ; to es
  271.           mov  ds, DDD2.ProtDS          ; get callers DS
  272.           call es:DDD2.ProtEntry        ; go do the call
  273.           pop  ds                       ; restore our ds
  274.        .endif
  275.  
  276.        pop  es
  277.        pop  di
  278.        pop  ax
  279.  
  280.        ret
  281.  
  282. InitSDevice  endp
  283.  
  284. ;***********************************************************************
  285. ;*                                                               
  286. ;*  FUNCTION NAME :  AccessCheck                                
  287. ;*                                                               
  288. ;*  DESCRIPTION   : Checks access to IOCtl parameter and
  289. ;*                    data area addresses                        
  290. ;*                                                               
  291. ;*                  This routine is used to check access to the
  292. ;*                  addresses passed in the IOCtl packet.  All        
  293. ;*                  selectors are either valid or NULL.  DOSDEVIOCTL  
  294. ;*                  checks this level.  A key value that is unique    
  295. ;*                  for each IOCtl request is used to determine what  
  296. ;*                  kind of access check to do.  Imbedded in the key  
  297. ;*                  is the length of the data area to check.  If this 
  298. ;*                  length is 0 this indicates that the 1st word in   
  299. ;*                  the data area is its length.  In this case 2      
  300. ;*                  access checks are required.  1st to access the    
  301. ;*                  length value, second to access the entire data    
  302. ;*                  area.                                             
  303. ;*                                                               
  304. ;*  INPUT         :  BX = requested IOCtl # (0 based)
  305. ;*                  BX is used to index a table of keys that indicates   
  306. ;*                  what access checking is needed.  Each table entry    
  307. ;*                  coresponds to a 2 byte entry.  A key is defined as   
  308. ;*                  follows:                                             
  309. ;*                     2 bytes:                                          
  310. ;*                       byte 1: key for parameter area                  
  311. ;*                       byte 2: key for data area                       
  312. ;*                       key format (X is the defined bit(s))            
  313. ;*                          0000 XXXX - length to check                  
  314. ;*                          X000 0000 - reserved 0                       
  315. ;*                          0X00 0000 - skip check if selector is NULL   
  316. ;*                          00X0 0000 - type of check (0-read, 1-r/w)    
  317. ;*                          000X 0000 - 1 indicates check is required    
  318. ;*                                                               
  319. ;*  OUTPUT        :  Carry clear if no error, Set if error.
  320. ;*                                                               
  321. ;*  SIDE EFFECTS  :  stack is clean.  BX is preserved.
  322. ;*                                                               
  323. ;***********************************************************************
  324. ;* PSEUDOCODE :
  325. ;*
  326. ;* BeginSub  AccessCheck
  327. ;*
  328. ;* FOR <both data and parameter addresses> DO
  329. ;*    IF <key indicates access check required>
  330. ;*       IF <key indicates selector check required>
  331. ;*          IF <selector is NULL>
  332. ;*             set flag to skip access check
  333. ;*          ENDIF
  334. ;*       IF <access check still required>
  335. ;*          CheckLength <- length from key
  336. ;*          IF <CheckLength is 0>
  337. ;*             call Device_Help(VerifyAccess) to check the 1st
  338. ;*                word (length of data structure)
  339. ;*             IF <access is OK>
  340. ;*                CheckLength <- 1st word of user data area
  341. ;*             ELSE
  342. ;*                set access check failure
  343. ;*                leave FOR loop
  344. ;*             ENDIF
  345. ;*          ENDIF
  346. ;*          call Device_Help(VerifyAccess) to check CheckLength
  347. ;*             bytes for data access
  348. ;*          IF <access is NOT OK>
  349. ;*             set access check failure status
  350. ;*             leave FOR loop
  351. ;*          ENDIF
  352. ;*       ENDIF
  353. ;*    ENDIF
  354. ;* ENDFOR
  355. ;*
  356. ;* IF <access check failed>
  357. ;*    return error
  358. ;* ELSE
  359. ;*    return no error
  360. ;* ENDIF
  361. ;* return
  362. ;*
  363. ;*EndSub  AccessCheck
  364. ;*
  365. ;***********************************************************************
  366.  
  367.  
  368. AccessCheck  proc  near
  369.  
  370.        ?frame = 0
  371.        LocalVar     Count,WORD
  372.        LocalVar     Status,WORD
  373.        EnterProc
  374.  
  375. ;*
  376. ;*      This code loops through the access check key for the requested
  377. ;*      IOCtl.  This time through the loop the parameter packet is checked.
  378. ;*      The second time the data packet is checked.  First it is determined
  379. ;*      wether the packet must be checked or not.  If so then the selector
  380. ;*      is checked to see if it is NULL.  If so and a NULL is allowed then
  381. ;*      the access check is skipped.
  382. ;*
  383.  
  384.        mov  count, 0                             ; init local vars
  385.        mov  Status, 0
  386.        push si                                   ; save si
  387.        push ax                                   ; save function # (IOCtl)
  388.        mov  dl, DevHlp_VerifyAccess              ; set up devhelp function
  389.        mov  si, GIOParaPack                      ; get offset to addresses
  390.        shl  ax, 1                                ; convert to word offset
  391.        mov  di, ax                               ; put in index register
  392.        .while <Count ne 2>                       ; do 2 times
  393.           mov  cl, fs:AccessTbl[di]              ; get key value
  394.           test cl, CHECKREQD                     ; if an access check
  395.           .if <nz>                               ; is required
  396.              mov  dh, cl                         ; get the key
  397.              shl  dh, 2                          ; and clear all bits except
  398.              shr  dh, 7                          ; the type of check (r,r/w)
  399.              and  cx, 0fh                        ; mask off all but len bits
  400.              mov  ax, es:[bx][si]+2              ; get selector
  401.              test fs:AccessTbl[di], NULLOK       ; if a NULL selector is to be
  402.              .if <nz>                            ; ignored
  403.                 test ax, 0fff8h                  ; and the selector is null
  404.                 .if <z>                          ; then set the status to
  405.                    or   status, 2                ; indicate that the access
  406.                 .endif                           ; check is to be skipped
  407.              .endif
  408.  
  409. ;*
  410. ;*         Now see if the access check still needs to be done.  If the
  411. ;*         length to check from the key is 0 then we will get the length
  412. ;*         to check from the 1st word of the user data area.  This
  413. ;*         requires us to do an access check on the 1st word before we
  414. ;*         can read the value of the length.  A check is then done on the
  415. ;*         rest of the data area.
  416. ;*
  417.  
  418.              test status, 2                      ; see if the access check
  419.              .if <z>                             ; is to be done.
  420.  
  421. ;*
  422. ;*              If the length to check is 0 then the first word of the
  423. ;*              packet is the length of the packet.  For this case we check
  424. ;*              for the required access to the first two bytes first.  If
  425. ;*              this test passes then we load the actual lenght and do a
  426. ;*              check of the entire packet.
  427. ;*
  428.  
  429.                 .if <cx eq 0>                    ; if the length key is 0
  430.                    mov  cx, 2                    ; check 1st word
  431.                    push di                       ; save di
  432.                    mov  di, es:[bx][si]          ; get offset of data area
  433.                    call fs:Device_Help           ; go check it
  434.                    .if <c>                       ; if check failed
  435.                       pop  di                    ; restore di
  436.                       or  status, 1              ; set error status for return
  437.                       .leave                     ; leave the loop
  438.                    .else                         ; otherwise access passed
  439.                       push es                    ; save es
  440.                       mov  es, ax                ; get selector to user area
  441.                       mov  cx, word ptr es:[di]  ; read length field
  442.                       pop  es                    ; restore es
  443.                       pop  di                    ; restore di
  444.                    .endif
  445.                 .endif
  446.  
  447.                 push di                          ; save di
  448.                 mov  di, es:[bx][si]             ; get offset again
  449.                 call fs:Device_Help              ; check acc to rest of buffer
  450.                 pop  di                          ; restore di
  451.                 .if <c>                          ; if access failed
  452.                    or   status, 1                ; set error status
  453.                    .leave                        ; and leave the loop
  454.                 .endif
  455.              .endif
  456.  
  457.           .endif
  458.           mov  status, 0                         ; reset status (no errors)
  459.           inc  di                                ; go to next key
  460.           add  si, 4                             ; go to next user address
  461.           inc  count                             ; update count
  462.        .endwhile
  463.  
  464.        pop  ax                                   ; restore function #
  465.        pop  si                                   ; restore MSCB offset
  466.        shr  Status, 1                            ; return status in Carry flag
  467.  
  468.        LeaveProc                                 ; clear local frame
  469.        ret                                       ; return
  470.  
  471. AccessCheck  EndP
  472.  
  473. ;***********************************************************************
  474. ;*                                                               
  475. ;*  FUNCTION NAME :  QueueRead                                  
  476. ;*                                                               
  477. ;*  DESCRIPTION   :  Read or peek into the session event queue.
  478. ;*                                                               
  479. ;*                   This function is used to read an event or just
  480. ;*                   peek at the session event queue.  A peek          
  481. ;*                   operation will return the current event without   
  482. ;*                   removing the event.  This routine maintains the   
  483. ;*                   pointers to the FIFO event queue.  This routine   
  484. ;*                   can only be called when there is data in the      
  485. ;*                   queue.                                            
  486. ;*                                                               
  487. ;*  INPUT         :  Stack frame as follows:                              
  488. ;*                   SS:[SP]    --> Return address                        
  489. ;*                   SS:[SP]+2  --> Size of queue record                  
  490. ;*                   SS:[SP]+4  --> Type of read (0=peek,<>0=read)        
  491. ;*                   SS:[SP]+6  --> offset of where to return event       
  492. ;*                   SS:[SP]+8  --> selector of where to return event     
  493. ;*                   SS:[SP]+10 --> offset to event queue control area    
  494. ;*                                                               
  495. ;*  EXIT-NORMAL   : Always
  496. ;*                                                               
  497. ;*  EXIT-ERROR    :  N/A
  498. ;*                                                               
  499. ;*  EFFECTS       :  Queue is updated along with queue pointers.
  500. ;*                   Stack is cleaned and no registers modified.
  501. ;*                                                               
  502. ;***********************************************************************
  503. ;* PSEUDOCODE :
  504. ;*
  505. ;* BeginSub  QueueRead
  506. ;*
  507. ;* move head record in the queue to output event buffer
  508. ;* IF <Read function, NOT a PEEK>
  509. ;*    QSize <- QSize - 1
  510. ;*    HeadPtr <- HeadPtr + RecordSize
  511. ;*    IF <HeadPtr is at end of queue memory>
  512. ;*       HeadPtr <- start of queue memory
  513. ;*    ENDIF
  514. ;* ENDIF
  515. ;* return
  516. ;*
  517. ;*EndSub  QueueRead
  518. ;*
  519. ;************************************************************************
  520.  
  521. QueueRead  proc  near
  522.  
  523. ;*
  524. ;* These equates are used to access the stack frame.
  525. ;*
  526.  
  527. EventOffset   equ     <(word ptr [bp+4])>
  528. EventSelector equ     <(word ptr [bp+6])>
  529.  
  530.        enter 0,0                    ; reserve no space
  531.  
  532.        push es                      ; save es
  533.        push di                      ; save di
  534.        push si                      ; save si
  535.        mov  di, EventOffset         ; get offset of where to return event
  536.        mov  es, EventSelector       ; put selector in es
  537.        mov  cx, ElRec_Size          ; get count of bytes in queue record
  538.        mov  si, [si].Eq_Head        ; get offset of head element
  539.        cld                          ; copy forward
  540.        rep  movsb                   ; copy the event
  541.        pop  si                      ; restore queue control block offset
  542.        dec  [si].Eq_Size            ; one less element in queue
  543.        mov  cx, ElRec_Size          ; get size of element
  544.        add  [si].Eq_Head, cx        ; update head pointer to next element
  545.        mov  cx, [si].E_Queue        ; get start of queue memory
  546.        add  cx, fs:Eq_Length        ; get end of queue memory
  547.        .if <[si].Eq_Head eq cx>     ; if head is at end of queue memory
  548.           mov  cx, [si].E_Queue     ; get start of queue memory
  549.           mov  [si].Eq_Head, cx     ; reset head to start of queue memory
  550.        .endif                       ; end head reset test
  551.        pop  di                      ; restore di
  552.        pop  es
  553.  
  554.        leave
  555.        ret  4                       ; pop 4 bytes parameter data
  556.  
  557. QueueRead  EndP
  558.  
  559. ;***********************************************************************
  560. ;*                                                               
  561. ;*  FUNCTION NAME :  PtrDrawCheck                               
  562. ;*                                                               
  563. ;*  DESCRIPTION   : See if a pointer draw drawing operation
  564. ;*                    is allowed.                                
  565. ;*                                                               
  566. ;*                  This routine is used to check the validity of a
  567. ;*                  drawing operation (draw or remove) to the pointer 
  568. ;*                  draw DD.  In order for a call to be valid the     
  569. ;*                  following checks must all pass:                   
  570. ;*                     1.  There must be a ptr draw DD registered.    
  571. ;*                     2.  The display mode must be supported.        
  572. ;*                     3.  Ptr draw operations must not be disabled.  
  573. ;*                     4.  The pointer draw overide flag must be OFF. 
  574. ;*                     5.  The caller must be in the foreground.      
  575. ;*                     6.  The pointer pos must not be in the         
  576. ;*                         collision area.                            
  577. ;*                                                               
  578. ;*  INPUT         :  bl = foreground session #                            
  579. ;*                   si = offset to callers MSCB                          
  580. ;*                                                               
  581. ;*  OUTPUT        :  AX = 0 if call OK, else AX <> 0 if call not OK.
  582. ;*                                                               
  583. ;*  SIDE EFFECTS  :  stack is clean.
  584. ;*                                                               
  585. ;***********************************************************************
  586. ;* PSEUDOCODE :
  587. ;*
  588. ;*  BeginSub  PtrDrawCheck
  589. ;* 
  590. ;*  IF <pointer draw DD is registered  AND
  591. ;*      display mode is supported      AND
  592. ;*      pointer draw routines used     AND
  593. ;*      caller is foreground           AND
  594. ;*      pointer draw overide is OFF>
  595. ;*     call CollisionChk to see if pointer in collision area
  596. ;*     IF <pointer not in collision area>
  597. ;*        set call OK
  598. ;*     ELSE
  599. ;*        set call NOT OK
  600. ;*     ENDIF
  601. ;*  ELSE
  602. ;*     set call NOT OK
  603. ;*  ENDIF
  604. ;*  return
  605. ;* 
  606. ;* EndSub  PtrDrawCheck
  607. ;* 
  608. ;***********************************************************************
  609.  
  610. PtrDrawCheck  proc  near
  611.  
  612.        test [si].D_Status, PtrDraw+USS_Mode ; If drawing is allowed
  613.        .if <z>               AND            ; and mode supported
  614.        .if <fs:CallSessn eq bl> AND         ; and caller is foreground
  615.        .if <fs:Ptr_Overide eq OFF>          ; and not in a session switch
  616.           CALLFAR CollisionChk              ; then see if a ptr collision
  617.        .else                                ; else
  618.           mov  ax, 1                        ; set error code
  619.        .endif                               ; end checks
  620.  
  621.        ret                                  ; ax is set here or by CollisionChk
  622.  
  623. PtrDrawCheck  endp
  624.  
  625. ;***********************************************************************
  626. ;*                                                               
  627. ;* FUNCTION NAME : GetExtModeData                               
  628. ;*                                                               
  629. ;* DESCRIPTION   : This routine will copy the extended mode data for
  630. ;*                 the specified session to the buffer pointed to by
  631. ;*                 es:di.
  632. ;*                                                               
  633. ;* INPUT         :  AX = session number                                   
  634. ;*                  ES:DI = pointer to buffer for extended mode data      
  635. ;*                  CX = length of data to copy                           
  636. ;*                  FS = selector where extended mode data is stored.     
  637. ;*                                                               
  638. ;* OUTPUT        : None.
  639. ;*                                                               
  640. ;* SIDE EFFECTS  : AX, DI are destroyed.
  641. ;*                                                               
  642. ;***********************************************************************
  643. ;* PSEUDOCODE :
  644. ;*
  645. ;* BeginSub  GetExtModeData  (get extended mode data)
  646. ;*
  647. ;* calculate offset for current session
  648. ;* move extended mode data from this offset to user data area
  649. ;* return
  650. ;*
  651. ;*EndSub  GetExtModeData
  652. ;*
  653. ;***********************************************************************
  654.  
  655. GetExtModeData  proc  near
  656.  
  657.        push dx                          ; save local regs
  658.        push si                          ; 
  659.        push cx                          ; save length of data
  660.        push ds
  661.        mul  cx                          ; calculate session offset
  662.        mov  si, offset ext_mode_data    ; get start of table
  663.        add  si, ax                      ; calculate offset into mode data
  664.        mov  dx, fs
  665.        mov  ds, dx
  666.        rep  movsb                       ; move the extended mode data
  667.        pop  ds
  668.        pop  cx                          ; restore length of data
  669.        pop  si                          ; restore local regs
  670.        pop  dx                          ; 
  671.        ret                              ; return
  672.  
  673. GetExtModeData  EndP
  674.  
  675.  
  676. ;***********************************************************************
  677. ;*                                                               
  678. ;* FUNCTION NAME : FlushMonChain                                
  679. ;*                                                               
  680. ;* DESCRIPTION   : This routine will flush a monitor chain.  SI must
  681. ;*                 point to the session CB.  This routine handles      
  682. ;*                 resetting the event queue pointers, issuing the     
  683. ;*                 DevHlp_MonFlush, and setting the necessary device   
  684. ;*                 status flags.  Any other required checking must be  
  685. ;*                 done by the caller.  The caller must disable        
  686. ;*                 interrupts befor calling this routine               
  687. ;*                                                               
  688. ;* INPUT         :  DS:SI = pointer to session CB
  689. ;*                                                                       
  690. ;* OUTPUT        : carry set if error, clear if no error                 
  691. ;*                                                               
  692. ;* SIDE EFFECTS  : Registers preserved.
  693. ;*                                                               
  694. ;***********************************************************************
  695. ;* PSEUDOCODE :
  696. ;*
  697. ;* BeginSub  FlushMonChain  (flush monitor chain and event queue)
  698. ;*
  699. ;* set device status to QueueBusy and Flush in progress
  700. ;* reset event queue head & tail pointer to start of queue
  701. ;* call Device_Help(MonFlush) to send a flush record)
  702. ;* save status from MonFlush call
  703. ;* IF <flush failed>
  704. ;*    reset Flush in progress bit in device status
  705. ;* ENDIF
  706. ;* set device status to NOT QueueBusy
  707. ;* get status from MonFlush call
  708. ;* return status from MonFlush call
  709. ;*
  710. ;*EndSub  FlushMonChain
  711. ;*
  712. ;***********************************************************************
  713.  
  714. FlushMonChain  proc  near
  715.  
  716.        push ax                                 ; save ax during call
  717.        or   [si].D_Status, Busy_Mask           ; Set busy bit
  718.  
  719.        xor  ah, ah                 ; Clear Reg used to
  720.        mov  [si].Eq_Size, ah       ; Reset que element counter
  721.        mov  ax, [SI].E_Queue       ; Get base event que offset
  722.        mov  [si].Eq_Head, ax       ; Reset Head ptr to base
  723.        mov  [si].Eq_Tail, ax       ; Reset Tail ptr to base
  724.  
  725. ;*
  726. ;*     Invoke DEVHLP (MonFlush) to clear SG monitor chain data, only if
  727. ;*     there are monitors in the chain.
  728. ;*     NOTE: Although it is not documented, the DS register must have the
  729. ;*           base Mouse device driver's data selector in it. The monitor
  730. ;*           dispatcher uses some info from the device header !!!
  731. ;*
  732.  
  733.        .if <[si].Chain_Size gt 0>
  734.           or   [si].D_Status, Q_Flush         ; Set Que Flush and busy bits
  735.           push ds                             ; Save Mouse base data sel
  736.           mov  ax, [si].Chain_Hdle            ; Get SG Monitor Chain Handle
  737.           push fs
  738.           pop  ds                             ; DS MUST have base data sel
  739.           mov  dl, DevHlp_MonFlush            ; Specify function number
  740.           call Device_Help                    ; Invoke MonFlush function
  741.           pop ds                              ; Restore Mouse base data sel
  742.        .else
  743.           clc
  744.        .endif
  745.  
  746.        pushf                               ; save carry flag state
  747.        .if c                               ; If MonFlush failed then
  748.           and  [si].D_Status, NOT Q_Flush  ; Reset Flush Flag Bit
  749.        .endif                              ; MonFlush Completion Flag
  750.  
  751.        and  [si].D_Status, NOT Busy_Mask   ; Que nolonger busy
  752.        popf                                ; restore carry flag for DevHlp call
  753.        pop  ax
  754.  
  755.        ret
  756.  
  757. FlushMonChain  EndP
  758.  
  759. ;***********************************************************************
  760. ;*                                                               
  761. ;* FUNCTION NAME : SaveCfgData                                  
  762. ;*                                                               
  763. ;* DESCRIPTION   : Save display config data in the config data save
  764. ;*                 area.  The configuration data is stored in the
  765. ;*                 config data segment.
  766. ;*                                                               
  767. ;* INPUT         :  BX    = configuration #
  768. ;*                  DS:SI = address of configuration data                 
  769. ;*                  FS    = config data segment                           
  770. ;*                                                               
  771. ;* OUTPUT        : Carry set if error detected, clear otherwise.
  772. ;*                                                               
  773. ;* SIDE EFFECTS  :  Regiseter preserved.
  774. ;*                                                               
  775. ;************************************************************************
  776. ;*  PSEUDOCODE :
  777. ;*
  778. ;* BeginSub  SaveCfgData  (save display configuration data)
  779. ;*
  780. ;* IF <config # is between 1 and max supported cfg number>
  781. ;*    IF <config #'s data not stored already>
  782. ;*       IF <enough FreeSpace for config data>
  783. ;*          copy config data to free offset
  784. ;*          save offset of config data
  785. ;*          FreeSpace <- FreeSpace - Size(config data)
  786. ;*          FreeOffset <- FreeOffset + Size(config data)
  787. ;*          set no error
  788. ;*       ELSE
  789. ;*          set error
  790. ;*       ENDIF
  791. ;*    ELSE
  792. ;*       set no error
  793. ;*    ENDIF
  794. ;* ELSE
  795. ;*    set error
  796. ;* ENDIF
  797. ;*
  798. ;* return
  799. ;*
  800. ;*EndSub  SaveCfgData
  801. ;*
  802. ;***********************************************************************
  803.  
  804. SaveCfgData  Proc  near
  805.  
  806.        .if <bx le MaxSupConfigs> AND   ; if the config number is in range
  807.        .if <bx ge 1>                   ; 
  808.           push bx                      ; save config number
  809.           push cx                      ; save local registers
  810.           dec  bx                      ; convert config number to zero base
  811.           shl  bx,1                    ; convert to word offset
  812.           .if <<word ptr fs:cfg_offset[bx]> eq 0>  ; if not stored already
  813.              mov  cx, word ptr ds:[si] ; get length of config data
  814.              .if <cx be fs:free_space> ; if space available for config data
  815.                 push si                ; save config data offset
  816.                 push di                ; save di for local use
  817.                 push cx                ; save length of config data
  818.                 mov  di, fs:free_offset  ; get first available free space
  819.                 push es
  820.                 push fs
  821.                 mov  ax, fs
  822.                 mov  es, ax
  823.                 mov  word ptr fs:cfg_offset[bx], di   ; save offset to data
  824.                 rep  movsb             ; copy config data to our segment
  825.                 pop  fs
  826.                 pop  es
  827.                 pop  cx                ; restore length of config data
  828.                 pop  di                ; restore local reg used
  829.                 pop  si                ; restore offset to config data
  830.                 add  fs:free_offset, cx  ; update free space pointer
  831.                 sub  fs:free_space, cx   ; update available free space
  832.                 clc                      ; clear carry, no error
  833.              .else                       ; not enough space to store data
  834.                 stc                      ; set carry, error detected
  835.              .endif                      ; end test for enough space
  836.           .else                          ; cfg data already stored
  837.              clc                         ; so clear carry for no error
  838.           .endif                         ; end data stored already test
  839.           pop  cx                        ; restore local reg used
  840.           pop  bx                        ; restore config number
  841.        .else                             ; else config number out of range
  842.           stc                            ; set error code
  843.        .endif                            ; end range check on config number
  844.        ret                               ; return
  845.  
  846. SaveCfgData  EndP
  847.  
  848.  
  849. ;***********************************************************************
  850. ;*                                                               
  851. ;* FUNCTION NAME : GetCfgDataOffset                             
  852. ;*                                                               
  853. ;* DESCRIPTION   : Get the offset to the configuration display data
  854. ;*                 for a specific display configuration.  This routine 
  855. ;*                 returns the offset only.  ES must be set to the     
  856. ;*                 data segment that contains the saved configuration  
  857. ;*                 data structures.  The caller must know the segment. 
  858. ;*                                                               
  859. ;* INPUT         :  BX = configuration number to return pointer for.      
  860. ;*                  FS = selector of configuration data save segment.     
  861. ;*                                                               
  862. ;* OUTPUT        : If error detected then carry is set.                  
  863. ;*                 If no error detected then carry is clear and          
  864. ;*                 DX contains the offset to the config data.            
  865. ;*                                                               
  866. ;* SIDE EFFECTS  : Registers preserved.
  867. ;*                                                               
  868. ;***********************************************************************
  869. ;* PSEUDOCODE :
  870. ;*
  871. ;* BeginSub  GetCfgDataOffset  (get stored config data offset)
  872. ;*
  873. ;* IF <requested cfg # is between 1 and max supported cfg #>
  874. ;*    IF <data is stored for cfg #>
  875. ;*       get offset
  876. ;*       set no error
  877. ;*    ELSE
  878. ;*       set error
  879. ;*    ENDIF
  880. ;* ELSE
  881. ;*    set error
  882. ;* ENDIF
  883. ;*
  884. ;* return
  885. ;*
  886. ;*EndSub  GetCfgDataOffset
  887. ;*
  888. ;***********************************************************************
  889.  
  890. GetCfgDataOffset  proc  near
  891.  
  892.        .if <bx le MaxSupConfigs> AND   ; if the config number is in range
  893.        .if <bx ge 1>                   ; 
  894.           push bx                      ; save configuration number
  895.           dec  bx                      ; convert config number to 0 base
  896.           shl  bx, 1                   ; convert to a word offset
  897.           .if <<word ptr fs:cfg_offset[bx]> ne 0>  ; if config data is stored
  898.              mov  dx, fs:cfg_offset[bx]            ; get config data offset
  899.              clc                                   ; clear carry, no error
  900.           .else                        ; else, no data found
  901.              stc                       ; set carry for error
  902.           .endif                       ; end data stored test
  903.           pop  bx                      ; restore config number
  904.        .else                           ; else config number out of range
  905.           stc                          ; set error
  906.        .endif                          ; range check on config #
  907.        ret                             ; return
  908. GetCfgDataOffset  EndP
  909.  
  910.  
  911. ;***********************************************************************
  912. ;*                                                               
  913. ;* FUNCTION NAME : SaveExtModeData                              
  914. ;*                                                               
  915. ;* DESCRIPTION   : This routine is used to save the extended mode data
  916. ;*                 for the session specified.  The data is stored in
  917. ;*                 the segment pointed to by ES.
  918. ;*                                                               
  919. ;* INPUT         :  AX = session number                                   
  920. ;*                  CX = length of extended mode data                     
  921. ;*                  DS:SI = points to extended mode data                  
  922. ;*                  FS = selector of segment to store the mode data       
  923. ;*                                                               
  924. ;* OUTPUT        : None.
  925. ;*                                                               
  926. ;* SIDE EFFECTS  : Registers preserved.
  927. ;*                                                               
  928. ;***********************************************************************
  929. ;*
  930. ;*BeginSub  SaveExtModeData  (save extended mode data)
  931. ;*
  932. ;* calculate offset for current session
  933. ;* move extended mode data to this offset
  934. ;* return
  935. ;*
  936. ;*EndSub  SaveExtModeData
  937. ;*
  938. ;***********************************************************************
  939.  
  940. SaveExtModeData  proc  near
  941.  
  942.        push dx                     ; save local registers
  943.        push di                     ; 
  944.        push cx                     ; save length of data
  945.        push es
  946.        mov  dx, fs
  947.        mov  es, dx
  948.        mul  cx                     ; calculate mode data session offset
  949.        mov  di, offset ext_mode_data ; get start of mode data save buffer
  950.        add  di, ax                 ; add to get offset for session
  951.        rep  movsb                  ; move the data to the save area
  952.        pop  es
  953.        pop  cx                     ; restore data length
  954.        pop  di                     ; restore local registers
  955.        pop  dx                     ; 
  956.        ret                         ; return
  957.  
  958. SaveExtModeData  EndP
  959.  
  960. ;***********************************************************************
  961. ;*                                                               
  962. ;*  FUNCTION NAME :  EnableMouse                                
  963. ;*                                                               
  964. ;*  DESCRIPTION   : Call the device dependent DD to Enable
  965. ;*                    the mouse device.                          
  966. ;*                                                                    
  967. ;*                  This routine is called to enable the mouse
  968. ;*                  hardware.  It calls the DDDD to do this action.   
  969. ;*                  It provides a common point for invoking this      
  970. ;*                  function.                                         
  971. ;*                                                                    
  972. ;*  INPUT         : FS = mouse data seg
  973. ;*                                                               
  974. ;*  OUTPUT        : None
  975. ;*                                                               
  976. ;*  SIDE EFFECTS  :  stack is clean.
  977. ;*                                                               
  978. ;***********************************************************************
  979. ;* PSEUDOCODE :
  980. ;*
  981. ;* BeginSub  EnableMouse
  982. ;*
  983. ;* call DDDD(EnableDevice) to enable the mouse
  984. ;* return
  985. ;*
  986. ;*EndSub  EnableMouse
  987. ;*
  988. ;***********************************************************************
  989.  
  990. EnableMouse  proc  near
  991.      .if <bit fs:EmiFlags nz EMI_ACTIVE>                                  ;emi
  992.         push ds                                                           ;emi
  993.         push es                                                           ;emi
  994.         pusha                                                             ;emi
  995.                                                                           ;emi
  996.         push fs                                                           ;emi
  997.         pop ds                                                            ;emi
  998.         mov  ax,EMI_ENABLE                                                ;emi
  999.         call Emi_far                                                      ;emi
  1000.                                                                           ;emi
  1001.         popa                                                              ;emi
  1002.         pop  es                                                           ;emi
  1003.         pop  ds                                                           ;emi
  1004.      .else                                                                ;emi
  1005.         .if <fs:TypeOverRider eq TRUE>
  1006.            push ax                 ; save input value
  1007.            push es                 ; save our es during call
  1008.            push ds
  1009.            push fs                 ; same with ds (in fs)
  1010.            push fs                 ; put our ds in
  1011.            pop  es                 ; es for call to DDD
  1012.            mov  ds, es:DDD.ProtDS  ; get DDD ds value
  1013.            mov  ax, ENABLEDEVICE   ; function
  1014.            call es:DDD.ProtEntry   ; do it
  1015.            pop  fs                 ; restore our ds (into fs)
  1016.            pop  ds
  1017.            pop  es                 ; restore our es
  1018.            pop  ax                 ; restore ax
  1019.         .else
  1020.            clc
  1021.            or   fs:DevStatus, gREADENABLE   ; We are ready for events now
  1022.         .endif
  1023.       .endif
  1024.       ret
  1025.  
  1026. EnableMouse  endp
  1027.  
  1028. ;***********************************************************************
  1029. ;*                                                               
  1030. ;*  FUNCTION NAME :  DisableMouse                               
  1031. ;*                                                               
  1032. ;*  DESCRIPTION   : Call the device dependent DD to Disable
  1033. ;*                    the mouse device.                          
  1034. ;*                                                               
  1035. ;*             This routine is called to disable the mouse
  1036. ;*             hardware.  It calls the DDDD to do this action.   
  1037. ;*             It provides a common point for invoking this      
  1038. ;*             function.                                         
  1039. ;*                                                               
  1040. ;*  INPUT         :  FS=mouse data seg
  1041. ;*                                                               
  1042. ;*  OUTPUT        : None
  1043. ;*                                                               
  1044. ;*  SIDE EFFECTS  :  stack is clean.
  1045. ;*                                                               
  1046. ;************************************************************************
  1047. ;* PSEUDOCODE :
  1048. ;*
  1049. ;* BeginSub  DisableMouse
  1050. ;*  
  1051. ;*  call DDDD(DisableDevice) to disable the mouse
  1052. ;*  return
  1053. ;*  
  1054. ;* EndSub  DisableMouse
  1055. ;*
  1056. ;***********************************************************************
  1057.  
  1058. DisableMouse  proc  near
  1059.      .if <bit fs:EmiFlags nz EMI_ACTIVE>                                  ;emi
  1060.         push ds                                                           ;emi
  1061.         push es                                                           ;emi
  1062.         pusha                                                             ;emi
  1063.                                                                           ;emi
  1064.         push fs                                                           ;emi
  1065.         pop  ds                                                           ;emi
  1066.         mov  ax,EMI_DISABLE                                               ;emi
  1067.         call Emi_far                                                      ;emi
  1068.                                                                           ;emi
  1069.         popa                                                              ;emi
  1070.         pop  es                                                           ;emi
  1071.         pop ds                                                            ;emi
  1072.      .else
  1073.         .if <fs:TypeOverRider eq TRUE>
  1074.            push ax                 ; save input value
  1075.            push es                 ; save our es during call
  1076.            push ds
  1077.            push fs                 ; same with ds
  1078.            push fs                 ; put our ds in
  1079.            pop  es                 ; es for call to DDD
  1080.            mov  ds, es:DDD.ProtDS  ; get DDD ds value
  1081.            mov  ax, DISABLEDEVICE  ; function
  1082.            call es:DDD.ProtEntry   ; do it
  1083.            pop  fs                 ; restore our ds
  1084.            pop  ds
  1085.            pop  es                 ; restore our es
  1086.            pop  ax                 ; restore ax
  1087.         .else
  1088.            clc
  1089.            and  fs:DevStatus, NOT gREADENABLE   ; No events for now
  1090.         .endif
  1091.      .endif                                                               ;emi
  1092.      ret
  1093.  
  1094. DisableMouse  endp
  1095.  
  1096.  
  1097. ;***********************************************************************
  1098. ;*                                                               
  1099. ;* FUNCTION NAME : SGCreate                                     
  1100. ;*                                                               
  1101. ;* FUNCTION      : Allocate a screen group control block.  The session
  1102. ;*                 type must have been verified by the caller.
  1103. ;*                                                               
  1104. ;* NOTES         : This routine should only be called on a CREATION
  1105. ;*                 notification where the current session type is a
  1106. ;*                 fullscreen.
  1107. ;*                                                               
  1108. ;* INPUT         : bx = incoming session number
  1109. ;*                                                               
  1110. ;* OUTPUT        :  DS:SI points to the new CB if no error, cy set if
  1111. ;*                  error.
  1112. ;*                                                               
  1113. ;* SIDE EFFECTS  :
  1114. ;*                                                               
  1115. ;***********************************************************************
  1116. ;* PSEUDOCODE :
  1117. ;*
  1118. ;* BeginSub  SGCreate
  1119. ;*
  1120. ;* set number of bytes for the new CB
  1121. ;* call AllocCB to allocate the new CB
  1122. ;* IF <no error allocating CB>
  1123. ;*    IF <Fullscreen session type>
  1124. ;*       call InitFSCB to initialize the fullscreen CB
  1125. ;*    ELSE
  1126. ;*       call InitVDMCB to initialize the VDM CB
  1127. ;*    ENDIF
  1128. ;* ELSE
  1129. ;*    set error code
  1130. ;* ENDIF
  1131. ;*
  1132. ;*EndSub  SGCreate
  1133. ;*
  1134. ;***********************************************************************
  1135.  
  1136. SGCreate  proc  near
  1137.  
  1138. ;*
  1139. ;*      First set the size of the requested CB to be allocated.  Then call
  1140. ;*      AllocCB to allocate the new control block.
  1141. ;*
  1142.        mov  cx, SIZE ScrGp_Data
  1143.        add  cx, Eq_Length
  1144.  
  1145.        SaveReg <ax,dx>
  1146.        call AllocCB
  1147.        RestoreReg <dx,ax>
  1148.  
  1149. ;*
  1150. ;*      If there was no error then initialize the new control block.
  1151. ;*
  1152.        .if <nc>
  1153.           call InitFSCB
  1154.        .endif
  1155.  
  1156.        ret
  1157.  
  1158. SGCreate  endp
  1159.  
  1160.  
  1161. ;***********************************************************************
  1162. ;*                                                               
  1163. ;* FUNCTION NAME : SGSwitchStart                                
  1164. ;*                                                               
  1165. ;* DESCRIPTION   : This routine starts a screen group switch.  It
  1166. ;*                 removes the pointer image if required and sets a    
  1167. ;*                 flag to disable the mouse until the switch is done. 
  1168. ;*                                                               
  1169. ;* NOTE          : This routine should only be called on a PRESWITCH
  1170. ;*                 notification where the current session type is a        
  1171. ;*                 fullscreen.                                             
  1172. ;*                                                               
  1173. ;* INPUT         : bx = current session number
  1174. ;*                                                               
  1175. ;* OUTPUT        :  pointer removed if needed.  Carry set if error.
  1176. ;*                                                               
  1177. ;* SIDE EFFECTS  : no regs preserved.
  1178. ;*                                                               
  1179. ;************************************************************************
  1180. ;* PSEUDOCODE :
  1181. ;*
  1182. ;* BeginSub  SGSwitchStart
  1183. ;*
  1184. ;* set pointer overide flag to ignore all mouse data
  1185. ;* IF <session type is Full Screen>
  1186. ;*    call FindCB to get pointer to session CB
  1187. ;*    IF <CB found>
  1188. ;*       IF <pointer needs to be removed>
  1189. ;*          call PointerDraw to remove the pointer image
  1190. ;*       ENDIF
  1191. ;*    ELSE
  1192. ;*       set error
  1193. ;*    ENDIF
  1194. ;* ENDIF
  1195. ;*
  1196. ;*EndSub  SGSwitchStart
  1197. ;*
  1198. ;***********************************************************************
  1199.  
  1200. SGSwitchStart  proc  near
  1201.  
  1202. ;*
  1203. ;*      Turn the overide flag on so that all mouse data is ignored until
  1204. ;*      the switch is complete.  If the session switching away is a fullscreen
  1205. ;*      session then remove the pointer image if needed.
  1206. ;*
  1207.  
  1208.        mov  Ptr_Overide, ON
  1209.        call FindCB
  1210.        .if <nc>
  1211.           .if <[si].Hdle_Cntr gt 0>  AND
  1212.           test [si].D_Status, PtrDraw+USS_Mode
  1213.           .if <z>                    AND
  1214.           CALLFAR CollisionChk
  1215.           .if <ax eq 0>
  1216.              mov  ax, bx
  1217.              mov  ah, 0
  1218.              mov  cx, 0
  1219.              RemovePointer
  1220.           .endif
  1221.           clc
  1222.        .endif
  1223.        ret
  1224.  
  1225. SGSwitchStart  endp
  1226.  
  1227.  
  1228. ;***********************************************************************
  1229. ;*                                                               
  1230. ;* FUNCTION NAME : SGSwitchEnd                                  
  1231. ;*                                                               
  1232. ;* DESCRIPTION   : This routine ends a screen switch.  The new session
  1233. ;*                 is now in the foreground.  The pointer image will
  1234. ;*                 be redrawn for a fullscreen session if needed.
  1235. ;*                                                               
  1236. ;* NOTE          : This routine should only be called on a PROSTSWITCH     
  1237. ;*                 notification where the current session type is a        
  1238. ;*                 fullscreen.                                             
  1239. ;*                                                               
  1240. ;* INPUT         : bl = incoming session number                           
  1241. ;*                 bh = incoming session type                             
  1242. ;*                                                               
  1243. ;* OUTPUT        :  pointer removed if needed.  Carry set if error.
  1244. ;*                                                               
  1245. ;* SIDE EFFECTS  : no regs preserved.
  1246. ;*                                                               
  1247. ;************************************************************************
  1248. ;*
  1249. ;*BeginSub  SGSwitchEnd
  1250. ;*
  1251. ;*
  1252. ;*EndSub  SGSwitchEnd
  1253. ;*
  1254. ;***********************************************************************
  1255.  
  1256. SGSwitchEnd  proc  near
  1257.  
  1258.        call FindCB
  1259.        .if <nc>
  1260.           mov  word ptr fs:FgndCB, si
  1261.           mov  word ptr fs:FgndCB+2, ds
  1262.           mov  fs:FgndSessn, bl
  1263.              test [si].D_Status, PtrDraw+USS_Mode
  1264.              .if <z> AND
  1265.              .if <<word ptr [si].Screen_Entp+2> ne 0>  AND
  1266.              .if <[si].Hdle_Cntr gt 0>
  1267.                 CALLFAR CollisionChk
  1268.                 .if <ax eq 0>
  1269.                    mov  al, bl
  1270.                    cbw
  1271.                    DrawPointer
  1272.                 .endif
  1273.              .endif
  1274.        .endif
  1275.        mov  fs:Ptr_Overide, OFF
  1276.        ret
  1277.  
  1278. SGSwitchEnd  endp
  1279.  
  1280. ;***********************************************************************
  1281. ;*                                                               
  1282. ;*  FUNCTION NAME :  InitFSCB                                   
  1283. ;*                                                               
  1284. ;*  DESCRIPTION   : Initialize the Full Screen Control Block
  1285. ;*                                                               
  1286. ;*                  This routine is called to initial the control
  1287. ;*                  block used for a Full Screen Group.               
  1288. ;*                                                               
  1289. ;*  INPUT         : ds:si points to the FSCB to initialize
  1290. ;*                                                               
  1291. ;*  OUTPUT        : ds:si points to the control block
  1292. ;*                                                               
  1293. ;*  SIDE EFFECTS  :  stack is clean.
  1294. ;*                                                               
  1295. ;************************************************************************
  1296. ;*
  1297. ;*BeginSub  InitFSCB
  1298. ;*
  1299. ;* call DDDD(DisableDevice) to disable the mouse
  1300. ;* return
  1301. ;*
  1302. ;*EndSub  InitFSCB
  1303. ;*
  1304. ;***********************************************************************
  1305.  
  1306. InitFSCB  proc  near
  1307.  
  1308.  
  1309.         mov [si].Hdle_Cntr, 0        ; Init handle counter to zero
  1310.  
  1311.         mov ax, si                   ; Get offset to start of FS CB
  1312.         add ax, SRec_Size            ; End of FS CB is start of event queue
  1313.         mov [si].E_Queue, ax         ; Get pointer to event queue
  1314.  
  1315.         mov [si].Eq_PID, 0           ; 
  1316.         mov [si].D_Status, 0
  1317.         mov [si].Chain_Size, 0       ; 
  1318.         mov [si].Chain_Hdle, 0       ; 
  1319.         mov [si].Screen_Entp, 0      ; 
  1320.         mov [si].Screen_Tble, 0      ; 
  1321.         mov [si].Screen_DOff, 0      ; 
  1322.         mov [si].Screen_DSeg, 0      ; 
  1323.         mov [si].MLength, 0          ; 
  1324.         mov [si].Ptr_Flags, 0        ; 
  1325.         mov [si].Cur_Config, 0       ; 
  1326.         mov [si].CfgOffset, 0        ; 
  1327.         mov [si].CfgSelector, 0      ; 
  1328.         ret
  1329.  
  1330. InitFSCB  endp
  1331.  
  1332. CSEG2  ENDS
  1333.        END
  1334.