home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / MOUSE / IOSET.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  124KB  |  2,606 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 = IOSET.ASM                                                                           
  16. ;*                                                                                                                  
  17. ;* DESCRIPTIVE NAME = Mouse Device Driver, Protect Mode IOCtls.                        
  18. ;*                                                                         
  19. ;*                                                                         
  20. ;* VERSION      V2.0                                                       
  21. ;*                                                                         
  22. ;* DATE         01/23/92
  23. ;*                                                                         
  24. ;* DESCRIPTION  Mouse Device Driver, Protect Mode IOCtls.                              
  25. ;*                                                                         
  26. ;* FUNCTIONS    IOMW_MM   (Cat 0Ah, Function 40h)
  27. ;*              SGControl (Cat B - function 41h)
  28. ;*              IOMW_SM    (51h) 
  29. ;*              IOMW_SS    (53h)
  30. ;*              IOMW_EM    (54h)                                                           
  31. ;*              IOMW_TH    (55H)
  32. ;*              IOMW_PS    (56h)
  33. ;*              IOMW_DP    (57h)
  34. ;*              IOMW_RP    (58h)
  35. ;*              IOMW_SP    (59h)
  36. ;*              IOMW_SD    (5A)
  37. ;*              IOMW_DS    (5C)
  38. ;*              IOMW_MD    (5Dh)
  39. ;*
  40. ;* NOTES        This file contains Mouse DD Protect Mode IOCtl
  41. ;*              Set worker routines.                          
  42. ;*             
  43. ;* STRUCTURES   NONE                                                       
  44. ;*                                                                         
  45. ;* EXTERNAL REFERENCES                                                     
  46. ;*                                                                         
  47. ;*              NONE                                                       
  48. ;*                                                                         
  49. ;* EXTERNAL FUNCTIONS                                                      
  50. ;*                                                                         
  51. ;*              NONE                                                       
  52. ;*                                                                         
  53. ;* CHANGE ACTIVITY =                                                       
  54. ;*   DATE      FLAG        APAR   CHANGE DESCRIPTION                       
  55. ;*   --------  ----------  -----  --------------------------------------   
  56. ;*   mm/dd/yy  @Vr.mpppxx  xxxxx  xxxxxxx                                  
  57. ;*   01/23/92              B736749
  58. ;*
  59. ;**************************************************************************
  60.                                                                     
  61.  
  62. .386p
  63.  
  64. INCL_WINPROGRAMLIST    equ          1      ; define for pmshl.inc defines
  65. INCL_ERRORS            equ          1      ; define for pmshl.inc defines
  66. SESMGR                 equ          1      ; define for pmshl.inc defines
  67.  
  68.  
  69. .xlist
  70.         include mouse.inc
  71.         include singleq.inc
  72.         include pmshl.inc
  73.         include basemaca.inc
  74.         include osmaca.inc
  75. .list
  76.  
  77. CPUMODE 386
  78.  
  79. ;*
  80. ;*    External Mouse Module Data References
  81. ;*
  82.        extrn  Num_Grps             : byte
  83.        extrn  CallSessn            : byte
  84.        extrn  FgndSessn            : byte
  85.        extrn  Modes                : byte
  86.        extrn  DeviceData           : byte
  87.        extrn  DDD                  : byte
  88.        extrn  SQDDName             : byte
  89.        extrn  SQDD                 : byte
  90.        extrn  Detach_Proc          : byte
  91.        extrn  Ptr_Overide          : byte
  92.        extrn  SN_Flags             : byte
  93.        extrn  Ptr_Rec              : byte
  94.  
  95.        extrn  Sem_PID              : word
  96.        extrn  Eq_Length            : word
  97.        extrn  CallPID              : word
  98.        extrn  SQ_Pid               : word
  99.        extrn  VDM_Flags            : word
  100.        extrn  EMaskMax             : word
  101.  
  102.        extrn  Device_Help          : dword
  103.        extrn  FgndCB               : dword
  104.  
  105.        extrn  FlushMonChain        : near
  106.        extrn  GetExtModeData       : near
  107.        extrn  PtrDrawCheck         : near
  108.        extrn  Monitor_Handler      : near
  109.        extrn  AllocCB              : near
  110.        extrn  EnableMouse          : near
  111.        extrn  DisableMouse         : near
  112.        extrn  InitFSCB             : near
  113.        extrn  FindCB               : near
  114.        extrn  FreeCB               : near
  115.        extrn  SGSwitchStart        : near
  116.        extrn  SGSwitchEnd          : near
  117.        extrn  SGCreate             : near
  118.        extrn  SaveCfgData          : near
  119.        extrn  GetCfgDataOffset     : near
  120.        extrn  SaveExtModeData      : near
  121.  
  122.        extrn  Emi_BegVMChange      : near                        ;emi
  123.        extrn  Emi_EndVMChange      : near                        ;emi
  124.        extrn  Emi_BegSesSwitch     : near                        ;emi
  125.        extrn  Emi_EndSesSwitch     : near                        ;emi
  126.  
  127.        EXTRNFAR Calc_Num
  128.  
  129. CSEG   SEGMENT   WORD  PUBLIC  USE16 'CODE'
  130. CSEG   ENDS
  131.  
  132. CSEG2   SEGMENT  WORD  PUBLIC  USE16  'SWAPCODE'
  133.         ASSUME    CS:CSEG2, SS:NOTHING, ES:NOTHING, DS:NOTHING
  134.  
  135. ;*
  136. ;*    Module Procs made Public for other Mouse Modules
  137. ;*
  138.  
  139.  
  140.        public  IOMW_MM       ; Cat A - func 40h
  141.        public  SGControl     ; Cat B - func 41h
  142.  
  143.        public  IOMW_SM       ; Cat 7 - func 51h
  144.        public  IOMW_SS       ; Cat 7 - func 53h
  145.        public  IOMW_EM       ; Cat 7 - func 54h
  146.        public  IOMW_TH       ; Cat 7 - func 55h
  147.        public  IOMW_PS       ; Cat 7 - func 56h
  148.        public  IOMW_DP       ; Cat 7 - func 57h
  149.        public  IOMW_RP       ; Cat 7 - func 58h
  150.        public  IOMW_SP       ; Cat 7 - func 59h
  151.  
  152.        public  IOMW_SD       ; Cat 7 - func 5ah
  153.        public  IOMW_DS       ; Cat 7 - func 5ch
  154.        public  IOMW_MD       ; Cat 7 - func 5dh
  155.  
  156.  
  157. ;********************************************************************** 
  158. ;*                                                               
  159. ;*  FUNCTION NAME :  IOMW_MM   (Cat 0Ah, Function 40h)          
  160. ;*                                                               
  161. ;*  DESCRIPTION   :  Performs Mouse Monitor Registration
  162. ;*                   for a Generic IOCtl request block that    
  163. ;*                   is generated by a DosMonReg function      
  164. ;*                   call.                                     
  165. ;*                                                                     
  166. ;*                   The data address field points to a monitor
  167. ;*                   register packet.  This packet has four fields:    
  168. ;*                      1. word  - placement in the chain.             
  169. ;*                      2. word  - index field.                        
  170. ;*                      3. dword - address of input buffer.            
  171. ;*                      4. word  - offset to ouput buffer.             
  172. ;*                   A DevHlp is used to add the monitor to the        
  173. ;*                   requested session's chain.                        
  174. ;*                                                               
  175. ;*  ENTRY POINT   :  IOMW_MM           LINKAGE:  CALL NEAR
  176. ;*                                                               
  177. ;*  INPUT         :  ES:BX points to the request block.
  178. ;*                   DS:SI has offset to current session control block    
  179. ;*                   FS    Mouse data selector                            
  180. ;*                                                               
  181. ;*  NOTES         :  A detached process cannot register a monitor for
  182. ;*                  its own session. It can however register a monitor   
  183. ;*                  for a different session, as long as that session     
  184. ;*                  is a valid full screen session.                      
  185. ;*                                                               
  186. ;*  RETURN-NORMAL :  Monitor is added to caller's session monitor   
  187. ;*                   chain.
  188. ;*                                                               
  189. ;*  RETURN-ERROR  :  Error code set in Request Block status field.   
  190. ;*                                                               
  191. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  192. ;*                                                               
  193. ;*  INTERNAL REFERENCES:                                         
  194. ;*           ROUTINES:   NONE.                                   
  195. ;*                                                               
  196. ;*  EXTERNAL REFERENCES:                                         
  197. ;*           ROUTINES:  NONE.                                    
  198. ;*           DevHlps:   Register.                                
  199. ;*                                                               
  200. ;********************************************************************** 
  201. ;* PSEUDOCODE :
  202. ;*
  203. ;* BeginSub  IOMW_MM  (register a mouse monitor)
  204. ;*
  205. ;* get user register parameters
  206. ;* disable system ints
  207. ;* get requested session number
  208. ;* IF <current process is DETACHED  AND
  209. ;*     request is for current session>
  210. ;*    set requested session to Max_Session to cause failure
  211. ;* ENDIF
  212. ;* IF <requested session is gt -1 AND
  213. ;*     lt Max_Session>
  214. ;*    IF <specific session requested>
  215. ;*       get MSCB of requested session
  216. ;*    ENDIF
  217. ;*    IF <monitor session does not have SQ mode active>
  218. ;*       call Device_Help(Register) to register the monitor
  219. ;*       IF <Register worked>
  220. ;*          increment session monitor chain size
  221. ;*       ELSE
  222. ;*          set General Failure error code
  223. ;*       ENDIF
  224. ;*    ELSE
  225. ;*       set parameter error
  226. ;*    ENDIF
  227. ;* ELSE
  228. ;*    set parameter error
  229. ;* ENDIF
  230. ;* enable system ints
  231. ;* return
  232. ;*
  233. ;* EndSub  IOMW_MM
  234. ;*
  235. ;************************************************************************
  236.  
  237.  
  238. IOMW_MM  PROC  near
  239.  
  240. TempES     equ   <(word ptr [bp-2])>   ; Request packet selector
  241. TempBX     equ   <(word ptr [bp-4])>   ; Reguest packet offset
  242. TempSI     equ   <(word ptr [bp-6])>   ; CB offset of foreground session
  243. TempDS     equ   <(word ptr [bp-8])>   ; CB selector of foreground session
  244. OtherSI    equ   <(word ptr [bp-10])>  ; CB offset of SG to be monitored
  245. OtherDS    equ   <(word ptr [bp-12])>  ; CB selector of SG to be monitored
  246. ErrorCode  equ   <(word ptr [bp-14])>  ; 0 = no error, other is error code
  247.  
  248.    Enter  14,0
  249.                                       
  250.    mov  TempES, es                     ; Save RP selector
  251.    mov  TempBX, bx                     ; Save RP offset
  252.    mov  TempSI, si                     ; Save foreground SG CB Offset
  253.    mov  TempDS, ds                     ; Save foreground SG CB Selector
  254.    mov  OtherSI, si                    ; Init to current SGs CB Offset
  255.    mov  OtherDS, ds                    ; Init to current SGs CB Selector
  256.    mov  ErrorCode, 0
  257.  
  258.    les  bx, es:[bx].GIODataPack         ; Get Addr of Data Packet
  259.    cli                                  ; Disable interrupts for Mon register
  260.    mov  ax, es:[bx].Index               ; Get Requested SG for MonChain
  261.  
  262.    .if <ax eq -1>                       ; If current SG ID
  263.  
  264.       .if <fs:Detach_Proc eq ON> OR     ; If this is a detached proc (OR)
  265.       .if <bit [si].D_Status nz SQ_Mode>; If we are in the PM SG
  266.          mov  ErrorCode, MNS            ; then no_monitor_support
  267.       .endif
  268.  
  269.    .else                                ; Caller specificed a SG #
  270.  
  271.       .if <ax lt -1> OR                 ; If Index is less then -1 (OR)
  272.       .if <ah gt 0> OR                  ; If high byte is not 0 (OR)
  273.       .if <al ge fs:Num_Grps>           ; if Index is greater= 16
  274.          mov  ErrorCode, INVALIDPARMS   ; then caller has invalid parms
  275.  
  276.       .elseif <ax eq 2>                 ; Old 3X box SG # then return
  277.          mov  ErrorCode, MNS            ; error no_monitor_support
  278.  
  279. ;*
  280. ;*                  We should check the calling session (CallSessn)
  281. ;*      instead of foreground session (FgndSession) because the application
  282. ;*      can call from a background or detached process.
  283. ;*
  284.  
  285. ;**     .elseif <al ne fs:FgndSessn>      ; Index valid and not fgnd
  286.       .elseif <al ne fs:CallSessn>      ; Index valid and not fgnd
  287.  
  288. ;*
  289. ;*        At this point we know that we are about to register a
  290. ;*        monitor for a session that is not in the foreground. If
  291. ;*        this session has not been created yet we must create the CB
  292. ;*        for this screen group.
  293. ;*
  294.  
  295.          mov  bl, al                    ; get session #
  296.          xor  bh, bh
  297.          push fs
  298.          pop  ds
  299.          call FindCB                    ; ds:si -> CB if created already
  300.  
  301.          .if <c>                        ; if not found, create the CB
  302.             mov  cx, SIZE ScrGp_Data    ; size of the full screen CB
  303.             add  cx, Eq_Length          ; add on event queue size
  304.             call AllocCB                ; returns ds:si -> new CB allocated
  305.             .if <c>
  306.                mov  ErrorCode, GENERALFAILURE
  307.             .else
  308.                call InitFSCB
  309.             .endif
  310.          .endif
  311.  
  312.          mov OtherDS, ds                ; Sel of the CB to be monitored
  313.          mov OtherSI, si                ; Off of the CB to be monitored
  314.  
  315.       .endif
  316.  
  317. ;*
  318. ;*      DCAF CHANGE - We should check the SQ_Mode flag instead of
  319. ;*      Shell_Session when the application is trying to register a
  320. ;*      monitor. DCAF temporarily disables the singleq before registering
  321. ;*      a monitor for screen group 1.
  322. ;*
  323. ;**   .elseif <ax eq Shell_Session> OR  ; Else if Index equals PM SG (OR)
  324.       .if <bit [si].D_Status nz SQ_Mode>                                  
  325.          mov  ErrorCode, MNS            ; error no_monitor_support        
  326.       .endif                                                              
  327.  
  328.  
  329.    .endif
  330.  
  331.  
  332. ;*
  333. ;* At this point DS:SI points to the CB for the requested screen group ID
  334. ;*
  335.  
  336. ;*
  337. ;* If no errors where encountered we will create the monitor chain if
  338. ;* this hasn't been done yet.
  339. ;*
  340.  
  341.    .if <ErrorCode eq 0>
  342.  
  343.       mov  al, [si].Chain_Size               ; # of Monitors in chain
  344.       .if <al eq 0>                          ; If none so far
  345.                                              ; Create the Monitor chain
  346.          mov  [si].MB_Len, 14                ; This must always be set
  347.          add  si, MB_Len                     ; add in offset to MOB
  348.          mov  es, OtherDS                    ; SG CB selector
  349.          push cs
  350.          pop  ds                             ; Notify Rtn Address
  351.          mov  di, offset Monitor_Handler
  352.          xor  ax, ax                         ; Specify Create Chain
  353.          mov  dl, DevHlp_MonitorCreate       ; Specify function num
  354.          call fs:Device_Help                 ; Invoke MonitorCreate
  355.          mov  si, OtherSI                    ; Restore CB offset
  356.          mov  ds, OtherDS                    ; Restore CB selector
  357.  
  358.          .if <nc>
  359.             mov  [si].Chain_Hdle, ax         ; Store handle returned
  360.          .else
  361.             mov  ErrorCode, GENERALFAILURE
  362.          .endif
  363.  
  364.       .endif
  365.  
  366.    .endif
  367.  
  368.    .if <ErrorCode eq 0>
  369.  
  370.       mov  cx, fs:Sem_PID                     ; Get caller's PID
  371.       mov  ax, [si].Chain_Hdle                ; Load SG Mon Chain Handle
  372.       mov  es, TempES                         ; Restore RP selector
  373.       mov  bx, TempBX                         ; Restore RP offset
  374.       les  bx, es:[bx].GIODataPack            ; Access Data Parm Record
  375.       mov  dh, byte ptr es:[bx].P_Flag        ; Get placement flag
  376.       mov  dl, DevHlp_Register                ; Register function
  377.       mov  di, es:[bx].Output_Buff            ; Load Output Buf Offset
  378.       mov  si, word ptr ES:[BX].Input_Buff    ; Load Input Buf Offset
  379.       mov  es, word ptr ES:[BX].Input_Buff[2] ; Load Input Buf Selector
  380.       call fs:Device_Help                     ; do the register
  381.       mov  si, OtherSI
  382.  
  383.        .IF nc                         ; Normal return from Register?
  384.          inc  [SI].Chain_Size         ; Update monitor chain counter
  385.        .ELSE
  386.          mov  ErrorCode, GENERALFAILURE
  387.        .ENDIF
  388.  
  389.    .endif
  390.  
  391.    mov  es, TempES
  392.    mov  bx, TempBX
  393.    mov  si, TempSI
  394.    mov  ds, TempDS
  395.  
  396.    .if <ErrorCode ne 0>
  397.       mov  ax, ErrorCode
  398.       mov  es:[bx].PktStatus, ax
  399.    .endif
  400.  
  401.    sti                              ; Enable interrupts DevHlp Complete
  402.    Leave                            ; Clear local vars off stack
  403.    ret                              ; Return to Request Handler Rtn
  404.  
  405. IOMW_MM  ENDP
  406.  
  407. ;********************************************************************** 
  408. ;*                                                               
  409. ;* FUNCTION NAME  : SGControl (Cat B - function 41h)
  410. ;*                                                               
  411. ;* DESCRIPTION    : This routine handles all notifications that we
  412. ;*                  registered for with the session manager via the
  413. ;*                  DOSSMREGISTERDD call at init time.
  414. ;*                                                               
  415. ;* ENTRY POINT    : SGControl        LINKAGE: CALL NEAR
  416. ;*                                                               
  417. ;* INPUT          : ES:BX -> request packet
  418. ;*                  FS,DS -> mouse data segment
  419. ;*                                                               
  420. ;*                  The parameter packet has the following format          
  421. ;*                                                                         
  422. ;*                  SC_Length  - WORD   - Varies according to action       
  423. ;*                  SC_Action  - WORD   - Could be any action below        
  424. ;*                  SC_Data    - BYTES  - Varies according to action       
  425. ;*                                                                         
  426. ;*                  If action is          The data is                      
  427. ;*                                                               
  428. ;*                  08h   TERMINATION        TN_TypeOut   - WORD              
  429. ;*                                           TN_SIDOut    - WORD              
  430. ;*                                                                            
  431. ;*                                                                            
  432. ;*                  10h   CREATION           CN_SIDIn     - WORD              
  433. ;*                                           CN_TypeIn    - WORD              
  434. ;*                                                                            
  435. ;*                  20h   PRESWITCH OR       PS_SIDIn     - WORD              
  436. ;*                  40h   POSTSWITCH         PS_TypeIn    - WORD              
  437. ;*                                           PS_SIDOut    - WORD              
  438. ;*                                           PS_TypeOut   - WORD              
  439. ;*                                                                            
  440. ;*                                                                            
  441. ;*                 100h   AIMPOSTSAVE        AIM_Errors   - DWORD             
  442. ;*                                           AIM_Active   - WORD              
  443. ;*                                           AIM_TimeOut  - WORD              
  444. ;*                                           AIM_FKAccept - DWORD             
  445. ;*                                           AIM_FKRate   - DWORD             
  446. ;*                                           AIM_FKDelay  - DWORD             
  447. ;*                                                               
  448. ;* RETURN-NORMAL  : Always
  449. ;*                                                               
  450. ;*                  Carry Flag clear                                 
  451. ;*                  ES:BX preserved                                  
  452. ;*                  All other registers are undefined                
  453. ;*                                                               
  454. ;* EFFECTS        : Registers modified
  455. ;*                                                               
  456. ;* INTERNAL REFERENCES:                                          
  457. ;*    ROUTINES: SGSwitchStart, SGSwitchEnd, FreeCB, SGCreate     
  458. ;*                                                               
  459. ;* EXTERNAL REFERENCES:                                          
  460. ;*    ROUTINES: None                                             
  461. ;*    DEVHLPS:  None                                             
  462. ;*                                                               
  463. ;********************************************************************** 
  464. ;*
  465. ;* PSEUDOCODE :
  466. ;*
  467. ;* BeginSub  SGControl
  468. ;*
  469. ;*      Save the request packet pointer.
  470. ;*      Load a pointer to the parameter packet
  471. ;*
  472. ;*      IF <Action eq PRESWITCH>
  473. ;*         IF <Outgoing Type eq PROG_FULLSCREEN>
  474. ;*            Get SG number going out.
  475. ;*            call SGSwitchStart to initiate the SG switch
  476. ;*         ELSE
  477. ;*            Do nothing
  478. ;*         ENDIF
  479. ;*
  480. ;*
  481. ;*      ELSEIF <Action eq POSTSWITCH>
  482. ;*         IF <Incoming Type eq PROG_FULLSCREEN>
  483. ;*            Get SG number coming in.
  484. ;*            call SGSwitchEnd to end the SG switch
  485. ;*         ELSE
  486. ;*            Clear carry, no error ignored operation
  487. ;*            Zero pointer to fgnd CB
  488. ;*            Shut down processing mouse data
  489. ;*            Get SG number coming in.
  490. ;*         .endif
  491. ;*
  492. ;*         Store fgndsessn
  493. ;*
  494. ;*
  495. ;*      ELSEIF <Action eq TERMINATION>
  496. ;*         IF <Outgoing Type eq PROG_FULLSCREEN>
  497. ;*            Get Outgoing SGID
  498. ;*            IF <SGID eq FgndSessn>
  499. ;*               Zero out pointer to foreground CB
  500. ;*               Shut down processing data
  501. ;*            ENDIF
  502. ;*            Get CB for this SG
  503. ;*            IF <no monitors registered>
  504. ;*               call FreeCB to de-allocate to memory for the CB
  505. ;*            ENDIF
  506. ;*         ELSEIF <Outgoing Type eq PROG_VDM>
  507. ;*            AND off VDMREADY bit to stop sending events to VMSE
  508. ;*         ELSE
  509. ;*            clear carry and ignore operation
  510. ;*         ENDIF
  511. ;*
  512. ;*
  513. ;*      ELSEIF <Action eq CREATION>
  514. ;*         IF <Incoming type eq PROG_FULLSCREEN>
  515. ;*            get incoming SG number
  516. ;*            call SGCreate to allocate memory for the CB
  517. ;*         ELSEIF <Incoming Type eq PROG_VDM>
  518. ;*            AND off VDMREADY (VMSE is not ready for events yet)
  519. ;*         ELSE
  520. ;*            clear carry and ignore operation
  521. ;*         ENDIF
  522. ;*         ENDIF
  523. ;*
  524. ;*      ELSEIF <Action eq AIMPOSTSAVE>
  525. ;*         IF <AIM_Active eq 0>
  526. ;*            Turn off SN_ACTIVE bit in SN_Flags byte
  527. ;*         ELSE
  528. ;*            Turn on SN_ACTIVE bit in SN_Flags byte
  529. ;*         ENDIF
  530. ;*
  531. ;*      ELSE
  532. ;*         Clear carry (operation is ignored)
  533. ;*      ENDIF
  534. ;*
  535. ;*      Point ES:BX back to RP
  536. ;*      return
  537. ;*
  538. ;*
  539. ;* EndSub  SGControl
  540. ;*
  541. ;************************************************************************
  542.  
  543. public SGControl ;whswhs deleteme
  544. SGControl  proc  near
  545.  
  546.        ?frame = 0                         ; Get Local/Temp Stack Frame
  547.        LocalVar TempES, WORD              ; For ES register
  548.        LocalVar TempBX, WORD              ; For BX register
  549.        LocalVar TempDS, WORD              ; For DS register
  550.  
  551.        EnterProc
  552.  
  553. ;*
  554. ;*      First save the request packet pointer.  Then get the pointer to the
  555. ;*      switch control input.
  556. ;*
  557.  
  558.        mov  TempES, es
  559.        mov  TempBX, bx
  560.        mov  TempDS, ds
  561.  
  562.        les  bx, es:[bx].GIOParaPack
  563.  
  564. ;*
  565. ;*      If it is a PRESWITCH operation then get the current screen group
  566. ;*      number.  If it is a fullscreen session then start a switch.  If not
  567. ;*      a fullscreen clear the carry flag to show no error (operation ignored).
  568. ;*      In both cases the call may return an error, if so the carry flag is
  569. ;*      propagated to the end of the routine and returned to the caller
  570. ;*
  571.  
  572.        .if <es:[bx].SC_Action eq PRESWITCH>
  573.           mov  cx, es:[bx].PS_SIDIn                                   ;emi
  574.           .if <es:[bx].PS_TypeOut eq PROG_FULLSCREEN>
  575.              mov  bx, es:[bx].PS_SIDOut                               ;emi
  576.              mov  ax, TRUE                                            ;emi
  577.              push bx
  578.              call Emi_BegSesSwitch ; cx = caller's session            ;emi
  579.                                    ; bx = future   session            ;emi
  580.              pop  bx               ; ax = TRUE = fullscreen           ;emi
  581.              call SGSwitchStart
  582.           .else
  583.              mov  bx, es:[bx].PS_SIDOut                                ;emi
  584.              mov  ax, FALSE                                            ;emi
  585.              call Emi_BegSesSwitch ; cx = caller's session             ;emi
  586.                                    ; bx = future   session             ;emi
  587.                                    ; ax = FALSE = not full screen      ;emi
  588.              clc
  589.           .endif
  590.  
  591. ;*
  592. ;*      Now see if this is a POSTSWITCH operation.  This operation is done
  593. ;*      after the switch is complete.  The SC_Incomming field is the new
  594. ;*      screen group that is in the foreground.  If the new screen group is
  595. ;*      not a recognized type then the foreground control block pointer is
  596. ;*      zero'd so that no one will try to access it.  In all cases store the
  597. ;*      new foreground session number.
  598. ;*
  599.  
  600.        .elseif <es:[bx].SC_Action eq POSTSWITCH>
  601.           .if <es:[bx].PS_TypeIn eq PROG_FULLSCREEN>
  602.              mov  bx, es:[bx].PS_SIDIn      ; get affected session
  603.              mov  ax, TRUE                                              ;emi
  604.              push bx                                                    ;emi
  605.              call Emi_EndSesSwitch ; bx = session                       ;emi
  606.                                    ; ax = TRUE = fullscreen             ;emi
  607.              pop  bx                                                    ;emi
  608.              call SGSwitchEnd               ; end a screen group switch
  609.           .else                             ; Other session type
  610.              mov  word ptr FgndCB+2, 0      ; zero pointer
  611.              mov  Ptr_Overide, ON           ; shut down processing mouse data
  612.              mov  bx, es:[bx].PS_SIDIn      ; get affected session
  613.              mov  ax, FALSE                                               ;emi
  614.              call Emi_EndSesSwitch          ; bx = session                ;emi
  615.                                             ; ax = FALSE = not full screen;emi
  616.              clc                            ; no error, ignored operation ;emi
  617.           .endif
  618.           mov  fs:FgndSessn, bl
  619.  
  620. ;*
  621. ;*      If the operation is a TERMINATION, then the SC_Current field has the
  622. ;*      session number that is being terminated.  If the session type is
  623. ;*      supported then we go get the CB pointer.  If the session has no
  624. ;*      monitors in its chain then the CB is freed by calling FreeCB, otherwise
  625. ;*      some process in another session has registered a monitor in this
  626. ;*      session.  The CB remains so that when the session is created again the
  627. ;*      monitor will be present.
  628. ;*
  629.  
  630.        .elseif <es:[bx].SC_Action eq TERMINATION>
  631.           .if <es:[bx].TN_TypeOut eq PROG_FULLSCREEN>
  632.              mov  bx, es:[bx].TN_SIDOut
  633.              .if <bl eq FgndSessn>                ; If the session is the
  634.                 mov  word ptr FgndCB+2, 0         ; foreground then zero ptr.
  635.                 mov  Ptr_Overide, ON              ; shut down processing data
  636.              .endif
  637.              call FindCB                          ; Get the current ptr.
  638.              .if <[si].Chain_Size eq 0>           ; monitors registered
  639.                 mov  ds, TempDS                   ; Re-load base DS
  640.                 call FreeCB                       ; then free the CB
  641.              .endif
  642.           .else
  643.              clc
  644.           .endif
  645.  
  646. ;*
  647. ;*      If operation is a CREATION, then SC_Incomming is the new session
  648. ;*      number.  If it is a full screen session type then check to see if
  649. ;*      the CB has already been allocated. The only way that a CB could
  650. ;*      already be allocated before this CREATION notification is if an
  651. ;*      app has already registered a monitor for this new SG ID.
  652. ;*
  653. ;*      If the the TypeIn is a VDM the simply init the VDMREADY bit and
  654. ;*      and return.
  655. ;*
  656. ;*      All CREATION notifications for other SG types are ignored.
  657. ;*
  658.  
  659.        .elseif <es:[bx].SC_Action eq CREATION>
  660.           .if <es:[bx].CN_TypeIn eq PROG_FULLSCREEN>
  661.              mov  bx, es:[bx].CN_SIDIn
  662.              call FindCB                         ; Check if CB already alloced
  663.              .if <c>                             ; If not
  664.                 call SGCreate                    ; Alloc CB
  665.              .endif
  666.           .else
  667.              clc
  668.           .endif
  669.  
  670. ;*
  671. ;*      If operation is a AIMPOSTSAVE check the AIM_Active word of the
  672. ;*      parameter packet. If upported session type then call SGCreate to
  673. ;*      create the control block.
  674. ;*
  675.  
  676.        .elseif <es:[bx].SC_Action eq AIMPOSTSAVE>
  677.           .if <es:[bx].AIM_Active eq 0>
  678.              and SN_Flags, NOT SNF_ACTIVE
  679.           .else
  680.              or SN_Flags, SNF_ACTIVE
  681.           .endif
  682. ;*
  683. ;*      Otherwise the operation is not recognized.  The carry flag is left
  684. ;*      clear to show the operation is not an error.  It is ignored.
  685. ;*
  686.  
  687.        .else
  688.           clc
  689.        .endif
  690.  
  691.        mov  bx, TempBX       ; restore request packet address
  692.        mov  es, TempES
  693.        LeaveProc
  694.        ret
  695.  
  696. SGControl  Endp
  697.  
  698.  
  699. ;********************************************************************** 
  700. ;*                                                               
  701. ;*  FUNCTION NAME :  IOMW_SM    (51h)                           
  702. ;*                                                               
  703. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  704. ;*                     IOMW_SM, start a display mode change.     
  705. ;*                                                                    
  706. ;*                  The parameter list field points to a VIOSetMode   
  707. ;*                  record.  The data list field points to the        
  708. ;*                  displays configuration data.  If the current      
  709. ;*                  session is in the FG and the set mode window flag 
  710. ;*                  is not set then the pointer is hidden.  This is   
  711. ;*                  maintain compatibility with old mouse subsystems. 
  712. ;*                  The set mode window flag is always set if the     
  713. ;*                  mode data is valid.  The flag may have been set   
  714. ;*                  by the ptr draw register IOCtl.  The Pointer      
  715. ;*                  Draw DD is then called to validate the new mode   
  716. ;*                  data.  If supported then Point DD will fill in    
  717. ;*                  the session control block with the mode data.     
  718. ;*                  If unsupported then mouse support for that session
  719. ;*                  is disabled.  IOCtl IOMW_MD is used to finish the 
  720. ;*                  mode switch.  Status word on stack is used to     
  721. ;*                  flag intermediate errors so processing can be     
  722. ;*                  halted.  0 indicates no errors.                   
  723. ;*                                                               
  724. ;*  ENTRY POINT   : IOMW_SM         LINKAGE: CALL NEAR
  725. ;*                                                               
  726. ;*  INPUT         :  ES:BX points to the request block.
  727. ;*                   DS:SI has offset to current session control block.
  728. ;*                                                               
  729. ;*  RETURN-NORMAL :  Mouse pointer is hidden, session control block 
  730. ;*                   mode data fields are updated.
  731. ;*                                                               
  732. ;*  RETURN-ERROR  :  session CB fields unchanged.  Device status     
  733. ;*                   flags set to indicate mode unsupported.  Ptr    
  734. ;*                   Draw functions are disabled until a supported   
  735. ;*                   mode is set.                                    
  736. ;*                                                               
  737. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  738. ;*                                                               
  739. ;*  INTERNAL REFERENCES:                                         
  740. ;*     ROUTINES   :  Calc_Num,     SaveCfgData, SaveExtModeData,
  741. ;*                   GetCfgDataOffset, CheckAccess
  742. ;*                                                               
  743. ;*  EXTERNAL REFERENCES:                                         
  744. ;*     ROUTINES   :  Ptr Draw(RemovePointer, CheckModeProtect)
  745. ;*                DDDD(Enable_Device, Disable_Device)            
  746. ;*     DevHelps:  NONE.                                          
  747. ;*                                                               
  748. ;********************************************************************** 
  749. ;* PSEUDOCODE :
  750. ;*
  751. ;* BeginSub  IOMW_SM  (set display mode)
  752. ;*
  753. ;* call DDDD(Disable_Device) to disable the mouse
  754. ;* IF <setmode window is not active>
  755. ;*    remove the pointer if needed
  756. ;*    set setmode window as active
  757. ;* ENDIF
  758. ;* IF <selector to config data is not NULL>
  759. ;*    IF <length of config data is valid>
  760. ;*       call SaveCfgData to save the config data
  761. ;*       IF <error saving config data>
  762. ;*          set error status
  763. ;*       ENDIF
  764. ;*       IF <status indicates no error so far>
  765. ;*          call GetCfgDataOffset to get config data offset
  766. ;*          IF <offset returned>
  767. ;*             store selector:offset in MSCB
  768. ;*          ELSE
  769. ;*             0 out sel:off in MSCB to show no cfg data available
  770. ;*          ENDIF
  771. ;*       ENDIF
  772. ;*    ENDIF
  773. ;* ENDIF
  774. ;*
  775. ;* IF <status indicates no errors so far>
  776. ;*    IF <current mode data available AND
  777. ;*        mode is supported>
  778. ;*       set flag indicating previous mode data exists
  779. ;*       save current display mode type resolutions
  780. ;*    ENDIF
  781. ;*    call PtrDraw(CheckModeProt) to check new display mode
  782. ;*
  783. ;*    IF <new display mode is supported>
  784. ;*       set device status to supported display mode
  785. ;*       IF <previous mode data exists>
  786. ;*          map old ptr position to new screen resolution
  787. ;*       ELSE
  788. ;*          set ptr position to center of screen
  789. ;*       ENDIF
  790. ;*    ELSE
  791. ;*       set parameter error (display mode not supported)
  792. ;*    ENDIF
  793. ;* ENDIF
  794. ;*
  795. ;* call DDDD(Enbale_Device) to enable the mouse
  796. ;*
  797. ;* return
  798. ;*
  799. ;* EndSub  IOMW_SM
  800. ;*
  801. ;************************************************************************
  802.  
  803. IOMW_SM  proc  near
  804.  
  805. TempES        equ  <(word ptr [bp-2])>     ; For ES register
  806. TempBX        equ  <(word ptr [bp-4])>     ; For BX register
  807. TempSI        equ  <(word ptr [bp-6])>     ; for SI register
  808. Old_Col_Res   equ  <(word ptr [bp-8])>     ; for old mode data
  809. Old_Row_Res   equ  <(word ptr [bp-10])>    ; for old mode data
  810. Status        equ  <(word ptr [bp-12])>    ; For error status
  811.  
  812. ;*
  813. ;* These equates are use for the status word.
  814. ;*
  815.  
  816. SM_ERROR      equ    1                    ; error detected
  817. SM_PREVMODE   equ    2                    ; previous mode data was available
  818.  
  819.        Enter  12,0
  820.        mov  TempES, es                    ; Save Request Block Address
  821.        mov  TempBX, bx
  822.        mov  TempSI, si                    ; save session CB offset
  823.        mov  Status, 0                     ; no error so far
  824.  
  825.        call DisableMouse                  ; Hold Mouse Interrupts
  826.  
  827.        test [si].Ptr_Flags, SM_WinFlag    ; see if set mode window active now
  828.        .if z                              ; if not then we must handle the
  829.           mov  bl, fs:FgndSessn           ; compatibility case. FG session
  830.           call PtrDrawCheck
  831.           .IF <ax eq 0>                   ; If Not a Ptr Collision
  832.              mov  al, fs:CallSessn        ; set foregrnd session
  833.              push cx                      ; Save current reg value
  834.              mov  cx, 0                   ; Flag Remove Ptr Required
  835.              RemovePointer                ; Hide Mouse Pointer Image
  836.              pop  cx                      ; restore cx
  837.           .endif                          ; Collision Area Test
  838.           or  [si].Ptr_Flags, SM_WinFlag  ; set mode window active
  839.        .endif
  840.        mov  bx, TempBX                    ; restore offset to packet
  841.  
  842. ;*
  843. ;* Check access to set mode data and config data.  We must be able to access
  844. ;* the mode data.  If we cannot access the config data it is not an error from
  845. ;* the mouse's view.  The config data address is passed in  session CB to ptr
  846. ;* draw.  If config data does not exist then this field is zero'd out. If ptr
  847. ;* draw needs to access the config data then he must return an error on the
  848. ;* check mode call.
  849. ;*
  850.  
  851.        test word ptr es:[bx].GIODataPack+2, 0fff8h
  852.        .if <nz>                               ; valid selector(area valid)
  853.           les  di, es:[bx].GIODataPack
  854.  
  855.           .if <<word ptr es:[di]> ae 14>
  856.                                               ; looks like valid data
  857.              mov  bx, es:[di]+CfgNumOff       ; get this config data's number
  858.              push ds
  859.              push es                          ; save cfg data selector
  860.              mov  si, di                      ; put cfg data offset in si
  861.              pop  ds                          ; DS:SI -> new config data
  862.              call SaveCfgData                 ; try to save the config data
  863.              pop  ds
  864.              mov  si, TempSI                  ; restore session CB offset
  865.  
  866.              .if <c>                          ; if an error saving data
  867.                 or   Status, SM_ERROR         ; set error code
  868.              .else                            ; 
  869.                 call GetCfgDataOffset         ; get offset to config data
  870.                 .if <nc>                      ; offset of cfg data returned
  871.                    mov  [si].CfgSelector, fs  ; save sel to config data
  872.                    mov  [si].CfgOffset, dx    ; save offset fo config data
  873.                 .else                         ; error retrieveing offset
  874.                    mov  [si].CfgSelector, 0   ; zero out he config data
  875.                    mov  [si].CfgOffset, 0     ; pointer in the session CB
  876.                 .endif                        ; end cfg offset returned test
  877.              .endif
  878.           .endif
  879.        .endif
  880.  
  881. ;*
  882. ;* Config data has been stored, if given, and the session CB has been set up
  883. ;* to point to it.  Now if there were no previous errors then continue.
  884. ;* First set up the address to the mode data.  Then call ptr draw.
  885. ;*
  886.  
  887.        test Status, SM_ERROR                  ; Is everything cool so far?
  888.        .if <z>  NEAR                          ; yes so continue
  889.           mov  es, TempES                     ; restore packet selector
  890.           mov  bx, TempBX                     ; and packet offset
  891.           les  di, es:[bx].GIOParaPack        ; get mode data pointer
  892.  
  893. ;*
  894. ;* We are now set up to call pointer draw to check the mode data.  Ptr draw
  895. ;* should only validate the mode data.  We sill save the mode data.
  896. ;* Save the extended mode data before calling ptr draw.  This is to avoid
  897. ;* having to reload addresses in case ptr draw destroys them.
  898. ;*
  899.  
  900.           .if <[si].MLength ne 0>  AND         ; Is there current mode data?
  901.           test [si].D_Status, USS_Mode         ; and is it supported ? if so
  902.           .if <z>                              ; then remap old position
  903.              or   Status, SM_PREVMODE          ; Set previous mode flag
  904.              test [si].MType, Graphics         ; Is mode a graphics mode ?
  905.              .if <nz>                          ; If so then save the
  906.                 mov  ax, [si].GRow_Res         ; graphics row and column
  907.                 mov  bx, [si].GCol_Res         ; resolutions.
  908.              .else                             ; Else it's a text mode so
  909.                 mov  ax, [si].TRow_Res         ; save the text row and
  910.                 mov  bx, [si].TCol_Res         ; column resolutions
  911.              .endif                            ; end mode type test
  912.              mov  Old_Row_Res, ax              ; Save old resolutions in
  913.              mov  Old_Col_Res, bx              ; the save area
  914.           .endif                               ; end mode data available test
  915.  
  916.           push es                              ; save mode data address
  917.           push di                              ; 
  918.  
  919.           mov  al, fs:CallSessn                ; calling session
  920.           CheckModeProtect                     ; call ptr draw
  921.  
  922.           pop  di                              ; restore set mode address
  923.           pop  es
  924.  
  925.           .if <ax eq 0>                        ; if mode supported
  926.              and  [si].D_Status, NOT USS_Mode  ; Reset Disp Mode Flag Bit
  927.  
  928. ;*
  929. ;* This section will if center the pointer if no previous mode data was
  930. ;* available, or map the old position to the new mode if there was old mode data.
  931. ;*
  932.  
  933.              test Status, SM_PREVMODE          ; was there old mode data
  934.              .if <nz>                          ; yes so map old to new
  935.                 test es:[di].M_Type, Graphics     ; is new mode graphics ?
  936.                 .if <nz>                          ; yes
  937.                    mov  bx, es:[di].New_GRow_Res  ; so get the graphics
  938.                    push es:[di].New_GCol_Res      ; resolutions
  939.                 .else                             ; else text mode
  940.                    mov  bx, es:[di].New_TRow_Res  ; so get the text
  941.                    push es:[di].New_TCol_Res      ; resolutions
  942.                 .endif                            ; end mode type tests
  943.  
  944.                 mov  ax, [si].Ptr_Row_Pos         ; current row position
  945.                 mov  cx, Old_Row_Res              ; old row resolution
  946.                 CALLFAR Calc_Num                  ; map to new
  947.                 mov  [si].Ptr_Row_Pos, ax         ; store new row position
  948.  
  949.                 pop  bx                           ; get new col resolution
  950.                 mov  ax, [si].Ptr_Col_Pos         ; current col position
  951.                 mov  cx, Old_Col_Res              ; old col resolution
  952.                 CALLFAR Calc_Num                  ; map to new
  953.                 mov  [si].Ptr_Col_Pos, ax         ; store new col position
  954.  
  955.              .else
  956.  
  957.                 test   es:[di].M_Type, Graphics   ; Check current Disp Mode
  958.                 .if nz                            ; If in Graphics Mode then
  959.                    mov  ax, es:[di].New_GRow_Res  ; Get row resolution
  960.                    mov  bx, es:[di].New_GCol_Res  ; Get col resolution
  961.                 .else                             ; If in Text Mode then
  962.                    mov  ax, es:[di].New_TRow_Res  ; Get row resolution
  963.                    mov  bx, es:[di].New_TCol_Res  ; Get col resolution
  964.                 .endif                            ; Display Mode Tests
  965.  
  966.                 shr  ax, 1                        ; Get half row resolution
  967.                 mov  [si].Ptr_Row_Pos, ax         ; to center ptr position
  968.                 shr  bx, 1                        ; Get half col resolution
  969.                 mov  [si].Ptr_Col_Pos, bx         ; to center ptr position
  970.              .endif
  971.              xor  ch, ch                                                  ;emi
  972.              mov  cl, fs:CallSessn                                        ;emi
  973.              xor  bh, bh                                                  ;emi
  974.              mov  bl, fs:FgndSessn                                        ;emi
  975.              push si                                                      ;emi
  976.              call Emi_BegVMChange              ; cx = caller's session    ;emi
  977.                                                ; bx = future   session    ;emi
  978.                                                ; es:di = video data       ;emi
  979.                                                                           ;emi
  980.              pop  si                                                      ;emi
  981.           .else                                ; new Mode is not supported
  982.              ParmErr
  983.              or   [si].D_Status, USS_Mode      ; Set Unsupported Mode Bit
  984.           .endif                               ; end supported mode test
  985.        .else                                   ; intermediate error det.
  986.           ParmErr                              ; set parameter error
  987.           or   [si].D_Status, USS_Mode         ; Set Unsupported Mode Bit
  988.        .endif                                  ; end error detection
  989.  
  990. ;*
  991. ;* Now copy the base mode data to the session CB, regardless of return code.
  992. ;* Access to mode data is OK here.  1st load address to mode data.
  993. ;*
  994.  
  995.        mov  es, TempES                      ; restore sel to req packet
  996.        mov  bx, TempBX                      ; restore off to req packet
  997.        les  di, es:[bx].GIOParaPack         ; get ptr to mode data
  998.        add  si, MLength                     ; pt to mode data fields
  999.        mov  cx, BaseModeLen                 ; move only base mode data
  1000.        mov  al, fs:CallSessn                ; current session
  1001.        xor  ah, ah                          ; convert to word
  1002.        push ds                              ; exchange es and ds
  1003.        push es                              ;  ds -> mode data
  1004.        pop  ds                              ;  es -> our data seg
  1005.        pop  es                              ; 
  1006.        xchg si, di                          ; switch si and di
  1007.        push ds:[si]                         ; save length of mode data
  1008.        cld                                  ; go forward
  1009.        rep  movsb                           ; copy the mode data
  1010.        pop  cx                              ; get saved mode data len
  1011.        sub  cx, BaseModeLen                 ; calc ext mode data len
  1012.        .if <cx gt 0>                        ; if there is ext mode data
  1013.           call SaveExtModeData              ; save the ext mode data
  1014.        .endif
  1015.        push es                              ; mouse cb from es
  1016.        pop  ds
  1017.        mov  si, TempSI                      ; restore session CB off
  1018.  
  1019.        call EnableMouse                    ; allow mouse interrupts
  1020.  
  1021.        mov  es, TempES                     ; Restore request packet address
  1022.        mov  bx, TempBX                     ; in es:bx
  1023.  
  1024.        Leave                               ; Clear Local Var Stack Frame
  1025.  
  1026.        ret                                 ; Return to IOCtl Handler Rtn
  1027. IOMW_SM  ENDP
  1028.  
  1029.  
  1030. ;********************************************************************** 
  1031. ;*                                                               
  1032. ;*  FUNCTION NAME :  IOMW_SS    (53h)                           
  1033. ;*                                                               
  1034. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  1035. ;*                     IOMW_SS, set scaling factors for current  
  1036. ;*                     session.                                  
  1037. ;*                                                                    
  1038. ;*                  The parmlist field in the request block points to
  1039. ;*                  a 2 word structure.  The 1st word is the new row  
  1040. ;*                  scaling factor.  The 2nd word is the new column   
  1041. ;*                  scaling factor.  The input values must be > 0 and 
  1042. ;*                  <= Max_Scale.  A parameter error is set if any    
  1043. ;*                  value is out of range.                            
  1044. ;*                                                               
  1045. ;*  ENTRY POINT   :  IOMW_SS           LINKAGE:  CALL NEAR
  1046. ;*                                                               
  1047. ;*  INPUT         :  ES:BX points to the request block.
  1048. ;*                   SI has offset to current session control block.
  1049. ;*                                                               
  1050. ;*  RETURN-NORMAL :  Session's scaling factors are updated.         
  1051. ;*                                                               
  1052. ;*  RETURN-ERROR  :  Session's scaling factors are unchanged, the    
  1053. ;*                    Request Block status field set to error code.
  1054. ;*                                                               
  1055. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  1056. ;*                                                               
  1057. ;*  INTERNAL REFERENCES:                                         
  1058. ;*           ROUTINES:  NONE.                                    
  1059. ;*                                                               
  1060. ;*  EXTERNAL REFERENCES:                                         
  1061. ;*     ROUTINES:  NONE.                                          
  1062. ;*     DevHelps:  NONE.                                          
  1063. ;*                                                               
  1064. ;********************************************************************** 
  1065. ;* PSEUDOCODE :
  1066. ;*
  1067. ;* BeginSub  IOMW_SS  (set session scaling factors)
  1068. ;*
  1069. ;* get new scale factors
  1070. ;* IF <new scale factors are in range>
  1071. ;*    disable system ints
  1072. ;*    assign new scale factors to MSCB
  1073. ;*    enable system ints
  1074. ;* ELSE
  1075. ;*    set parameter error
  1076. ;* ENDIF
  1077. ;* return
  1078. ;*
  1079. ;* EndSub  IOMW_SS
  1080. ;*
  1081. ;************************************************************************/
  1082.  
  1083. IOMW_SS  proc near
  1084.  
  1085. TempES     equ   <(word ptr [bp-2])>     ; local var for saving es
  1086. TempBX     equ   <(word ptr [bp-4])>     ; local var for saving bx
  1087.  
  1088.        Enter 4,0
  1089.        mov  TempES, es                   ; Save Request Block Address
  1090.        mov  TempBX, bx
  1091.  
  1092.        les  di, es:[bx].GIOParaPack      ; load selector to data area
  1093.        mov  dx, es:[di].Parm1            ; Get input Row Scale Factor
  1094.        mov  cx, es:[di].Parm2            ; Get input Col Scale Factor
  1095.  
  1096.        .if <dx gt 0>         AND         ; Check to make sure that the
  1097.        .if <dx le Max_Scale> AND         ; new scaling factors are both
  1098.        .if <cx gt 0>         AND         ; in the valid range.  If so
  1099.        .if <cx le Max_Scale>             ; then assign the new factors
  1100.           cli                            ; Hold interrupts for data update
  1101.           mov  [si].RowScale_Fact, dx    ; Assign new Scaling factors
  1102.           mov  [si].ColScale_Fact, cx
  1103.           xor  ax, ax                    ; Setup to Clear fields
  1104.           mov  [si].Row_Remain, ax       ; Clear row remainder field
  1105.           mov  [si].Col_Remain, ax       ; Clear col remainder field
  1106.           mov  [si].Row_Cell_Remain, ax  ; Clear row pixel remainder
  1107.           mov  [si].Col_Cell_Remain, ax  ; Clear col pixel remainder
  1108.           sti                            ; restore system ints
  1109.        .else                             ; If invalid Scaling Factor(s) then
  1110.           ParmErr                        ; Flag Invalid Parm Error
  1111.        .endif                            ; Input Scaling Factor Tests
  1112.  
  1113.        mov  es, TempES
  1114.        mov  bx, TempBX
  1115.        Leave
  1116.  
  1117.        ret                              ; Return to IOCTL Handler Rtn.
  1118.  
  1119. IOMW_SS  EndP
  1120.  
  1121.  
  1122.  
  1123. ;********************************************************************** 
  1124. ;*                                                               
  1125. ;*  FUNCTION NAME :  IOMW_EM    (54h)                           
  1126. ;*                                                               
  1127. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  1128. ;*                     IOMW_EM, set session's event mask.        
  1129. ;*                                                               
  1130. ;*                   The parmlist field in the request block points to
  1131. ;*                   the new 1 word event mask.  The event mask must   
  1132. ;*                   be in range.  Ints disabled while event mask is   
  1133. ;*                   updated.                                          
  1134. ;*                                                               
  1135. ;*  ENTRY POINT   :  IOMW_EM           LINKAGE:  CALL NEAR
  1136. ;*                                                               
  1137. ;*  INPUT         :  ES:BX points to the request block.
  1138. ;*                   SI has offset to current session control block.
  1139. ;*                                                               
  1140. ;*  RETURN-NORMAL :  Session's event mask is updated.               
  1141. ;*                                                               
  1142. ;*  RETURN-ERROR  :  Session's event mask is unchanged, the          
  1143. ;*                   request block status field set to error code.
  1144. ;*                                                               
  1145. ;*  EFFECTS       :  Stack is clean on return.  AX, CX, DX, DI, and
  1146. ;*                   SI registers contents are destroyed.
  1147. ;*                                                               
  1148. ;*  INTERNAL REFERENCES:                                         
  1149. ;*     ROUTINES:  NONE.                                          
  1150. ;*                                                               
  1151. ;*  EXTERNAL REFERENCES:                                         
  1152. ;*     ROUTINES:  NONE.                                          
  1153. ;*     DevHelps:  NONE.                                          
  1154. ;*                                                               
  1155. ;********************************************************************** 
  1156. ;* PSEUDOCODE :
  1157. ;*
  1158. ;* BeginSub  IOMW_EM  (set session event mask)
  1159. ;*
  1160. ;* calculate max event mask from number of mouse buttons
  1161. ;* IF <new event mask is lt max event mask>
  1162. ;*    disable system ints
  1163. ;*    set new event mask in MSCB
  1164. ;*    enable system ints
  1165. ;* ELSE
  1166. ;*    set parameter error
  1167. ;* ENDIF
  1168. ;* return
  1169. ;*
  1170. ;* EndSub  IOMW_EM
  1171. ;*
  1172. ;************************************************************************
  1173.  
  1174. IOMW_EM  PROC  near
  1175.  
  1176.        ?frame = 0                     ; Define Local Stack frame
  1177.        LocalVar TempES, WORD
  1178.        LocalVar TempBX, WORD
  1179.  
  1180.        EnterProc
  1181.        mov  TempES, es                ; Save Request Block address
  1182.        mov  TempBX, bx
  1183.  
  1184.        les  di, es:[bx].GIOParaPack   ; load selector to data area
  1185.        mov  ax, es:[di]               ; Get new event mask
  1186.  
  1187.        .if <ax le fs:EMaskMax>        ; If new event mask is valid then
  1188.           cli                         ; Hold interrupts for Data Updates
  1189.           mov  [si].E_Mask, ax        ; Save event mask in SG CB
  1190.           sti                         ; SG CB updated, allow interrupts
  1191.        .else                          ; If new event mask is invalid then
  1192.           ParmErr                     ; Set Parm Error Return code
  1193.        .endif                         ; Event Mask Tests
  1194.  
  1195.        mov  bx, TempBX                ; Restore Request Block address
  1196.        mov  es, TempES
  1197.        LeaveProc                      ; Clear Local Stack frame
  1198.  
  1199.        ret                            ; Return to Generic IOCtl Handler Rtn
  1200.  
  1201. IOMW_EM  ENDP
  1202.  
  1203.  
  1204. ;********************************************************************** 
  1205. ;*                                                               
  1206. ;*  FUNCTION NAME :  IOMW_TH  (55H)                             
  1207. ;*                                                               
  1208. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  1209. ;*                     IOMW_TH, set session threshold values.    
  1210. ;*                                                                     
  1211. ;*                   The parameter address field points to a 5 word
  1212. ;*                   structure.  The 1st word is the length and should 
  1213. ;*                   be 10 for this IOCtl.  The 2nd word is the 1st    
  1214. ;*                   level movement rate.  The 3rd word is the 1st     
  1215. ;*                   level multiplier.  The 4th and 5th words are the  
  1216. ;*                   second level movement rate and multipliers re-    
  1217. ;*                   spectively.  All values are legal.                
  1218. ;*                                                               
  1219. ;*  ENTRY POINT   :  IOMW_TH           LINKAGE:  CALL NEAR
  1220. ;*                                                               
  1221. ;*  INPUT         :  ES:BX points to the request block.
  1222. ;*                   SI has offset to current session control block.
  1223. ;*                                                               
  1224. ;*  RETURN-NORMAL :  Session threshold vlaues updated.              
  1225. ;*                                                               
  1226. ;*  RETURN-ERROR  :  Invalid Parameter error returned.               
  1227. ;*                                                               
  1228. ;*  EFFECTS       :  Stack is clean on return. Regs not preserved.
  1229. ;*                                                               
  1230. ;*  INTERNAL REFERENCES:                                         
  1231. ;*     ROUTINES:  NONE                                           
  1232. ;*                                                               
  1233. ;*  EXTERNAL REFERENCES:                                         
  1234. ;*     ROUTINES:  DDDD(Disable_Device, Enable_Device)            
  1235. ;*     DevHlps:   NONE.                                          
  1236. ;*                                                               
  1237. ;********************************************************************** 
  1238. ;* PSEUDOCODE :
  1239. ;*
  1240. ;* BeginSub  IOMW_TH  (Set session threshold values)
  1241. ;*
  1242. ;*  call DDDD(Disable_Device) to disable the mouse
  1243. ;*  IF <length of new threshold data OK>
  1244. ;*     assign new threshold values and multipliers to session CB
  1245. ;*  ELSE
  1246. ;*     set PARAMETER ERROR
  1247. ;*  ENDIF
  1248. ;*
  1249. ;*  call DDDD(Enable_Device) to enable the mouse
  1250. ;*  return
  1251. ;*
  1252. ;* EndSub  IOMW_TH
  1253. ;*
  1254. ;************************************************************************
  1255.  
  1256. IOMW_TH  proc  near
  1257.  
  1258.        call DisableMouse       ; disable the mouse
  1259.  
  1260.        push es                 ; save es
  1261.  
  1262.        les  di, dword ptr es:[bx].GioParapacx    ; get address of ne values
  1263.  
  1264.        .if <es:[di].THLength eq 10>    and       ; if data length is ok and
  1265.        .if <es:[di].THLevel1 ne 0>     and       ; Level 1 is non 0 and
  1266.        .if <es:[di].THLevel2 ne 0>     and       ; Level 2 is non 0 and
  1267.        .if <es:[di].THLvl1Mplr ne 0>   and       ; 1st level mply is non 0 and
  1268.        .if <es:[di].THLvl2Mplr ne 0>   and       ; 1st level mply is non 0 and
  1269.        mov  cx, es:[di].THLevel1                 ; (get 1st level)
  1270.        mov  dx, es:[di].THLvl1Mplr               ; (get 1st multiplier)
  1271.        .if <<word ptr es:[di].THLevel2> ge cx> and  ; 2nd lvl >= 1st lvl and
  1272.        .if <<word ptr es:[di].THLvl2Mplr> ge dx>    ; 2nd mplr >= 1st Mplr
  1273.  
  1274.           mov  [si].Level1, cx                   ; put in MSCB
  1275.           mov  ax, es:[di].THLevel2              ; get 2nd level
  1276.           mov  [si].Level2, ax                   ; put in MSCB
  1277.           mov  [si].Lvl1Mplr, dx                 ; put in MSCB
  1278.           mov  ax, es:[di].THLvl2Mplr            ; get 2nd level multiplier
  1279.           mov  [si].Lvl2Mplr, ax                 ; put in MSCB
  1280.        .else
  1281.           pop  es                                ; restore es
  1282.           mov  es:[bx].PktStatus, INVALIDPARMS   ; Invalid Parm Error
  1283.           push es                                ; save es again
  1284.        .endif
  1285.  
  1286.        pop  es                                   ; restore es
  1287.        call EnableMouse                          ; enable the mouse
  1288.  
  1289.        ret
  1290.  
  1291. IOMW_TH  EndP
  1292.  
  1293.  
  1294. ;********************************************************************** 
  1295. ;*                                                               
  1296. ;*  FUNCTION NAME :  IOMW_PS    (56h)                           
  1297. ;*                                                               
  1298. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  1299. ;*                        IOMW_PS, set pointer image shape.
  1300. ;*                                                               
  1301. ;*                   Builds a pointer image definition record from
  1302. ;*                   user input data.  Parmlist address points to the  
  1303. ;*                   new pointer image buffer.  Data address field     
  1304. ;*                   points to the new pointer definition record.      
  1305. ;*                   The new record is passed to the Pointer Draw DD.  
  1306. ;*                   If the new pointer is valid then Pointer Draw     
  1307. ;*                   will update the session control block with the    
  1308. ;*                   new pointer image data.                           
  1309. ;*                                                               
  1310. ;*  ENTRY POINT   :  IOMW_PS           LINKAGE:  CALL NEAR
  1311. ;*                                                               
  1312. ;*  INPUT         :  ES:BX points to the request block.
  1313. ;*                   SI has offset to current session control block.
  1314. ;*                                                               
  1315. ;*  RETURN-NORMAL :  Session's pointer image is changed.  Foreground
  1316. ;*                    pointer image on the display will change.
  1317. ;*                                                               
  1318. ;*  RETURN-ERROR  :  Session's pointer image data is unchanged,      
  1319. ;*                   Request Block Status field set to error code.
  1320. ;*                                                               
  1321. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  1322. ;*                                                               
  1323. ;*  INTERNAL REFERENCES:                                         
  1324. ;*     ROUTINES:  None.                                          
  1325. ;*                                                               
  1326. ;*  EXTERNAL REFERENCES:                                         
  1327. ;*     ROUTINES:  Ptr Draw(RemovePointer, DrawPointer,           
  1328. ;*                GetPointerMem, FreePointerMem) DDDD(Enable_-   
  1329. ;*                Device, Disable_Device)                        
  1330. ;*                                                               
  1331. ;*                                                               
  1332. ;********************************************************************** 
  1333. ;* PSEUDOCODE :
  1334. ;*
  1335. ;* BeginSub  IOMW_PS  (set session pointer shape)
  1336. ;*
  1337. ;* call DDDD(Disable_Device) to disable the mouse
  1338. ;* IF <current display mode is supported>
  1339. ;*    IF <caller is foreground          AND
  1340. ;*        ptr draw routines used        AND
  1341. ;*        ptr overide flag is off       AND
  1342. ;*        there is no ptr collision>
  1343. ;*       call Ptr Draw(RemovePointer) to do unconditional remove
  1344. ;*       set flag for redraw required
  1345. ;*    ENDIF
  1346. ;*    call Ptr Draw(FreePointerMem) to release current pointer image
  1347. ;*    set up ptr definition record from user input image and definition
  1348. ;*       data areas
  1349. ;*    call Ptr Draw(GetPointerMem) to allocate new pointer image
  1350. ;*    IF <new pointer image allocated OK>
  1351. ;*       IF <redraw required>
  1352. ;*          call Ptr Draw(DrawPointer) to draw new ptr image
  1353. ;*       ENDIF
  1354. ;*    ELSE
  1355. ;*       set parameter error
  1356. ;*    ENDIF
  1357. ;* ELSE
  1358. ;*    set parameter error
  1359. ;* ENDIF
  1360. ;* call DDDD(Enable_Device) to enable the mouse
  1361. ;* return
  1362. ;*
  1363. ;* EndSub  IOMW_PS
  1364. ;*
  1365. ;************************************************************************
  1366.  
  1367. IOMW_PS  PROC  near
  1368.  
  1369. TempES        equ  <(word ptr [bp-2])>     ; For ES register
  1370. TempBX        equ  <(word ptr [bp-4])>     ; For BX register
  1371.  
  1372.        Enter 4,0
  1373.        mov  TempES, es                ; Save Request Block
  1374.        mov  TempBX, bx                ; Address
  1375.  
  1376.        call DisableMouse              ; Hold Mouse Interrupts for update
  1377.  
  1378.        test [si].D_Status, USS_Mode   ; See if display mode is supported.
  1379.        .if <z>  NEAR                  ; If so then OK to continue
  1380.  
  1381.           mov  bl, fs:FgndSessn       ; Get forground screen group #
  1382.           call PtrDrawCheck
  1383.           .if <ax eq 0>               ; If Not a Ptr Collision
  1384.              mov  al, fs:CallSessn    ; Get forground screen group #
  1385.              push cx                  ; Save current reg value
  1386.              mov  cx, 0               ; Flag Remove Ptr Required
  1387.              RemovePointer            ; Hide Mouse Pointer Image
  1388.              pop  cx                  ; Restore previous reg value
  1389.           .endif                      ; Collision Area Test
  1390.  
  1391.           mov  al, fs:CallSessn          ; Get forground screen group #
  1392.           FreePointerMem                 ; Call Ptr Draw DD to free buffers
  1393.  
  1394.           lea  di, fs:Ptr_Rec            ; Setup DI to point to Ptr_Rec in DS
  1395.                                          ; Load Ptr Rec for Ptr Draw DD call
  1396.           mov  bx, TempBX                ; Restore Request Block Offset
  1397.                                          ; Ptr Rec Addr1 = Pointer Image Buf
  1398.           mov  ax, es:[bx.GIOParaPacx]       ; Get caller's Parmlist Parm addr
  1399.           mov  word ptr fs:[di].Addr1, ax    ; High word, & put in Ptr Rec
  1400.           mov  ax, es:[bx.GIOParaPacx+2]     ; Get caller's ParmList Parm addr
  1401.           mov  word ptr fs:[di].Addr1[2], ax ; Low word, & put in Ptr Rec
  1402.  
  1403.                                              ; Ptr Rec Addr2 = Ptr Def Record
  1404.           mov  ax, es:[bx.GIODataPacx]       ; Get caller's Data Parm address
  1405.           mov  word ptr fs:[di].Addr2, ax    ; High word, & put in Ptr Rec
  1406.           mov  ax, es:[bx.GIODataPacx+2]     ; Get caller's Data Parm address
  1407.           mov  word ptr fs:[di].Addr2[2], ax ; Low word, & put in Ptr Rec
  1408.  
  1409.           push fs
  1410.           pop  es                        ; Set ES:DI to point to Ptr_Rec
  1411.           mov  al, fs:CallSessn          ; Get foreground screen group #
  1412.           GetPointerMem                  ; Call Ptr Draw DD to get memory
  1413.  
  1414.           .if <ax eq 0>                  ; If GetPointerMem worked then
  1415.              mov  bl, fs:FgndSessn       ; Get forground screen group #
  1416.              call PtrDrawCheck           ; see ptr drawing OK
  1417.              .if <ax eq 0>               ; If Not a Ptr Collision
  1418.                 mov  al, fs:CallSessn    ; Get forground screen group #
  1419.                 DrawPointer              ; Ensure Mouse Ptr is visible
  1420.              .endif                      ; New Ptr Collision Test
  1421.           .else                          ; If GetPointerMem failed then
  1422.             ParmErr                      ; Set ParmErr in Status field
  1423.           .endif                         ; GetPointerMem test
  1424.        .else
  1425.           ParmErr
  1426.        .endif
  1427.  
  1428.        call EnableMouse               ; Update done, Allow mouse interrupts
  1429.        mov  es, TempES                ; Restore Local Var's
  1430.        mov  bx, TempBX                ; Original Contents
  1431.        Leave                          ; Clear local Stack variables
  1432.  
  1433.        ret                            ; Return to IOCTL Handler Rtn
  1434.  
  1435. IOMW_PS  ENDP
  1436.  
  1437.  
  1438. ;********************************************************************** 
  1439. ;*                                                               
  1440. ;*  FUNCTION NAME :  IOMW_DP    (57h)                           
  1441. ;*                                                               
  1442. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  1443. ;*                     IOMW_DP, reset a session's collision area 
  1444. ;*                     and draw the pointer.                     
  1445. ;*                                                               
  1446. ;*                   Clears the session's collision area definition
  1447. ;*                   fields.  If the caller is the FG session then the 
  1448. ;*                   pointer is drawn.  Ints are disabled during       
  1449. ;*                   access to the collision area definition fields.   
  1450. ;*                                                               
  1451. ;*  NOTE          :  This function requires no input/output parameters.
  1452. ;*                                                               
  1453. ;*  ENTRY POINT   :  IOMW_DP           LINKAGE:  CALL NEAR
  1454. ;*                                                               
  1455. ;*  INPUT         :  ES:BX points to the request block.                   
  1456. ;*                   SI has offset to current session control block.      
  1457. ;*                                                               
  1458. ;*  RETURN-NORMAL :  Session's collision area is cleared. (always)  
  1459. ;*                                                               
  1460. ;*  RETURN-ERROR  :  N/A                                             
  1461. ;*                                                               
  1462. ;*  EFFECTS:  Stack is clean on return.  Regs not preserved.     
  1463. ;*                                                               
  1464. ;*  INTERNAL REFERENCES:                                         
  1465. ;*     ROUTINES:  NONE.                                          
  1466. ;*                                                               
  1467. ;*  EXTERNAL REFERENCES:                                         
  1468. ;*     ROUTINES:  Ptr Draw(DrawPointer), DDDD(Enable_Device,     
  1469. ;*                Disable_Device)                                
  1470. ;*                                                               
  1471. ;********************************************************************** 
  1472. ;* PSEUDOCODE :
  1473. ;*
  1474. ;* BeginSub  IOMW_DP  (remove session collision area and draw pointer)
  1475. ;*
  1476. ;* call DDDD(Disable_Device) to disable the mouse
  1477. ;* set collision area flags to NO collision area defined
  1478. ;* IF <ptr draw routines used AND
  1479. ;*     display mode supported AND
  1480. ;*     caller is foreground   AND
  1481. ;*     ptr overide is OFF>
  1482. ;*    call Ptr Draw(DrawPointer) to draw pointer image
  1483. ;* ENDIF
  1484. ;* call DDDD(Enable_Device) to enable the mouse
  1485. ;* return
  1486. ;*
  1487. ;* EndSub  IOMW_DP
  1488. ;*
  1489. ;************************************************************************
  1490.  
  1491. IOMW_DP  proc  near
  1492.  
  1493.        push bx
  1494.        call DisableMouse              ; Hold Mouse Interrupts
  1495.        mov  [si].Area_Flags, 0000h    ; Clear collision area field flags
  1496.        mov  bl, fs:FgndSessn          ; Get forground screen group #
  1497.        call PtrDrawCheck
  1498.        .if <ax eq 0>                  ; if draws are OK
  1499.           mov  al, fs:CallSessn       ; Get forground screen group #
  1500.           DrawPointer                 ; Draw Mouse Pointer image
  1501.        .endif
  1502.  
  1503.        call EnableMouse               ; Update done, Allow mouse interrupts
  1504.        pop  bx
  1505.        ret                            ; Return to IOCTL Handler Rtn
  1506.  
  1507. IOMW_DP  ENDP
  1508.  
  1509.  
  1510. ;********************************************************************** 
  1511. ;*                                                               
  1512. ;*  FUNCTION NAME :  IOMW_RP    (58h)                           
  1513. ;*                                                               
  1514. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  1515. ;*                     IOMW_RP, define a collision area.         
  1516. ;*                                                                     
  1517. ;*                   The parmlist field in the request block points to
  1518. ;*                   a 4 word structure which defines the collision    
  1519. ;*                   area.  1st two words is the upper left coordinates
  1520. ;*                   2nd two words is the lower right coordinates.     
  1521. ;*                   If the two points are in reversed order then they 
  1522. ;*                   are swapped.  The defined collision are must be   
  1523. ;*                   in the display coordinate space.  The pointer     
  1524. ;*                   image will be removed if the caller is the FG and 
  1525. ;*                   the pointer is in the new collision area. It will 
  1526. ;*                   be redrawn if the pointer position is outside the 
  1527. ;*                   new collision area.                               
  1528. ;*                                                               
  1529. ;*  ENTRY POINT   :  IOMW_RP           LINKAGE:  CALL NEAR
  1530. ;*                                                               
  1531. ;*  INPUT         :  ES:BX points to the request block.                   
  1532. ;*                   SI has offset to current session control block.      
  1533. ;*                                                               
  1534. ;*  RETURN-NORMAL :  Session's collision area definition fields     
  1535. ;*                   are updated, and FG pointer image may be
  1536. ;*                   removed or restored.
  1537. ;*                                                               
  1538. ;*  RETURN-ERROR  :  The screen group's collision area data remains  
  1539. ;*                   unchanged, an error return code is set in the
  1540. ;*                   Request Block Status field.
  1541. ;*                                                               
  1542. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  1543. ;*                                                               
  1544. ;*  INTERNAL REFERENCES:                                         
  1545. ;*     ROUTINES:  None.                                          
  1546. ;*                                                               
  1547. ;*  EXTERNAL REFERENCES:                                         
  1548. ;*     ROUTINES:  Ptr Draw(RemovePointer, DrawPointer),          
  1549. ;*                DDDD(Disable_Device, Enable_Device)            
  1550. ;*     DevHelps:  VerifyAccess.                                  
  1551. ;*                                                               
  1552. ;********************************************************************** 
  1553. ;* PSEUDOCODE :
  1554. ;*
  1555. ;* BeginSub  IOMW_RP   (define session collision area)
  1556. ;*
  1557. ;* IF <user defined values in reverse order>
  1558. ;*    switch user defined coordinates
  1559. ;* ENDIF
  1560. ;*
  1561. ;* IF <user defined coords are inside display mode type limits>
  1562. ;*    call DDDD(Disable_Device) to disable the mouse
  1563. ;*    IF <ptr draw routines are used AND
  1564. ;*        display mode is supported  AND
  1565. ;*        caller is foreground       AND
  1566. ;*        ptr overide is OFF>
  1567. ;*       set flag that drawing is OK
  1568. ;*       IF <there is no ptr collision>
  1569. ;*          call Ptr Draw(RemovePointer) to unconditionally remove ptr
  1570. ;*       ENDIF
  1571. ;*    ENDIF
  1572. ;*    define collsion area with user defined collision area
  1573. ;*    IF <drawing is OK AND
  1574. ;*        there is no collision>
  1575. ;*       call Ptr Draw(DrawPointer) to draw the pointer
  1576. ;*    ENDIF
  1577. ;*    call DDDD(Enable_Device) to enable the mouse
  1578. ;* ELSE
  1579. ;*    set parameter error
  1580. ;* ENDIF
  1581. ;*
  1582. ;* return
  1583. ;*
  1584. ;* EndSub  IOMW_RP
  1585. ;*
  1586. ;***********************************************************************
  1587.  
  1588. IOMW_RP  PROC  near
  1589.  
  1590. TempES        equ  <(word ptr [bp-2])>     ; For ES register
  1591. TempBX        equ  <(word ptr [bp-4])>     ; For BX register
  1592.  
  1593.        Enter 4,0
  1594.        mov  TempES, es              ; Save Request Block Address
  1595.        mov  TempBX, bx
  1596.  
  1597.        les  di, es:[bx].GIOParaPack ; load selector to data area
  1598.        test [si].MType, Graphics
  1599.        .if nz                       ; If display in Graphics mode
  1600.           mov  cx, [si].GRow_Res    ; Get Graphics resolution values
  1601.           mov  dx, [si].GCol_Res    ; for parm checking
  1602.        .else                        ; If display in Text mode then
  1603.           mov  cx, [si].TRow_Res    ; Get Text resolution values
  1604.           mov  dx, [si].TCol_Res    ; for parm checking
  1605.        .endif                       ; Display mode test
  1606.  
  1607.        dec  cx                      ; Get Resolution Values as
  1608.        dec  dx                      ; Base: 0 thru (Res - 1)
  1609.  
  1610.        mov  ax, es:[di].R_Pos       ; Get Input Row Coords
  1611.        mov  bx, es:[di].R_End       ; For Collision Area
  1612.  
  1613.        .if <ax a bx>                ; If 1st Row coord larger
  1614.           mov  es:[di].R_Pos, bx    ; Than 2nd Row coord then
  1615.           mov  es:[di].R_End, ax    ; Reverse the defined order
  1616.        .endif                       ; Of the Row coordinates
  1617.  
  1618.        mov  ax, es:[di].C_Pos       ; Get Input Col Coords
  1619.        mov  bx, ES:[di].C_End       ; For Collision Area
  1620.  
  1621.        .if <ax a bx>                ; If 1st Col coord larger
  1622.           mov  es:[di].C_Pos, bx    ; Than 2nd Col coord then
  1623.           mov  es:[di].C_End, ax    ; Reverse the defined order
  1624.        .endif                       ; Of the Col coordinates
  1625.  
  1626. ;*
  1627. ;* Check the defined collision area for valid screen coordinates
  1628. ;*
  1629.  
  1630.        .if <es:[di].R_Pos be cx> NEAR AND  ; Check starting row & col pos
  1631.        .if <es:[di].C_Pos be dx> NEAR AND
  1632.        .if <es:[di].R_End be cx> NEAR AND  ; Check Ending row & col pos
  1633.        .if <es:[di].C_End be dx> NEAR
  1634.  
  1635.           call DisableMouse          ; Hold Mouse Interrupts
  1636.  
  1637.           mov  bl, fs:FgndSessn      ; Get forground screen group #
  1638.           call PtrDrawCheck
  1639.           .if <ax eq 0>              ; If Not a Ptr Collision
  1640.              mov  al, fs:CallSessn   ; Get forground screen group #
  1641.              push cx                 ; Save current reg value
  1642.              mov  cx, 0              ; Flag Remove Ptr Required
  1643.              RemovePointer           ; Hide Mouse Pointer Image
  1644.              pop  cx                 ; Restore previous reg value
  1645.           .endif                     ; Collision Area Test
  1646.  
  1647.           mov  [si].Area_Flags, 0001H  ; Update SG CB Collision Area
  1648.           mov  ax, es:[di].R_Pos       ; With caller's record values
  1649.           mov  [si].Area_Top, ax
  1650.           mov  ax, es:[di].C_Pos
  1651.           mov  [si].Area_Left, ax
  1652.           mov  ax, es:[di].R_End
  1653.           mov  [si].Area_Bot, ax
  1654.           mov  ax, es:[di].C_End
  1655.           mov  [si].Area_Right, ax
  1656.  
  1657.           mov  bl, fs:FgndSessn       ; Get forground session #
  1658.  
  1659.           call PtrDrawCheck           ; see it ptr draws OK
  1660.           .if <ax eq 0>               ; If Not a Ptr Collision
  1661.              mov  al, fs:CallSessn    ; Get forground screen group #
  1662.              DrawPointer              ; Ensure Mouse Ptr is visible
  1663.           .endif                      ; New Ptr Collision Test
  1664.  
  1665.           call EnableMouse            ; Update done, Allow Mouse Intrpts
  1666.  
  1667.        .else                          ; If Collision Area Parms Invalid
  1668.           ParmErr                     ; Set Error Return in Status field
  1669.        .endif                         ; Collision Area Parm tests
  1670.  
  1671.        mov  bx, TempBX                ; Restore ES:BX to Request
  1672.        mov  es, TempES                ; Block Address
  1673.  
  1674.        sti                            ; Data updated, allow interupts
  1675.        Leave
  1676.  
  1677.        ret                            ; Return to IOCTL Handler Rtn
  1678.  
  1679. IOMW_RP  ENDP
  1680.  
  1681.  
  1682. ;********************************************************************** 
  1683. ;*                                                               
  1684. ;*  FUNCTION NAME :  IOMW_SP    (59h)                           
  1685. ;*                                                               
  1686. ;*  DESCRIPTION   :   Performs the Mouse IOCtl function
  1687. ;*                     IOMW_SP, set pointer position.            
  1688. ;*                                                                     
  1689. ;*                   The parmlist field address field in the requset
  1690. ;*                   block points to a 2 word structure.  The 1st word 
  1691. ;*                   is the new X coordinate, 2nd word is the new      
  1692. ;*                   column coordinate.  The new pointer position must 
  1693. ;*                   within the display coordinate space.  If the      
  1694. ;*                   caller is the foreground then the pointer is      
  1695. ;*                   hidden and redrawn.  Ints disabled while updating.
  1696. ;*                                                               
  1697. ;*  ENTRY POINT   :  IOMW_SP           LINKAGE:  CALL NEAR
  1698. ;*                                                               
  1699. ;*  INPUT         :  ES:BX points to the request block.                   
  1700. ;*                   SI has offset to current session control block.      
  1701. ;*                                                               
  1702. ;*  RETURN-NORMAL :  Session's pointer position is updated.         
  1703. ;*                                                               
  1704. ;*  RETURN-ERROR  :  Session pointer position unchanged, request     
  1705. ;*                    block status field set to error code.
  1706. ;*                                                               
  1707. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  1708. ;*                                                               
  1709. ;*  INTERNAL REFERENCES:                                         
  1710. ;*     ROUTINES:  None.                                          
  1711. ;*                                                               
  1712. ;*  EXTERNAL REFERENCES:                                         
  1713. ;*     ROUTINES:  Ptr Draw(RemovePointer, DrawPointer), DDDD(    
  1714. ;*                Disable_Device, Enable_Device)                 
  1715. ;*     DevHelps:  None                                           
  1716. ;*                                                               
  1717. ;********************************************************************** 
  1718. ;* PSEUDOCODE :
  1719. ;*
  1720. ;* BeginSub  IOMW_SP  (set session pointer position)
  1721. ;*
  1722. ;* get new pointer pos
  1723. ;* IF <new pointer pos is inside current display mode resolution>
  1724. ;*    call DDDD(Disable_Device) to disable the mouse
  1725. ;*    IF <ptr draw routines are used      AND
  1726. ;*        current display mode supported  AND
  1727. ;*        caller is foreground            AND
  1728. ;*        session switch not in progress  AND
  1729. ;*        there is no ptr collision>
  1730. ;*       call Ptr Draw(RemovePointer) to unconditionally remove the ptr
  1731. ;*    ENDIF
  1732. ;*    set new pointer pos in MSCB
  1733. ;*    IF <ptr draw routines are used      AND
  1734. ;*        current display mode supported  AND
  1735. ;*        caller is foreground            AND
  1736. ;*        session switch not in progress  AND
  1737. ;*        there is no ptr collision>
  1738. ;*       call Ptr Draw(DrawPointer) to draw the ptr at the new position
  1739. ;*    ENDIF
  1740. ;*    call DDDD(Enable_Device) to enable the mouse
  1741. ;* ELSE
  1742. ;*    set parameter error
  1743. ;* ENDIF
  1744. ;* return
  1745. ;*
  1746. ;*EndSub  IOMW_SP
  1747. ;*
  1748. ;***********************************************************************
  1749.  
  1750.  
  1751. IOMW_SP  proc near
  1752.  
  1753. TempES   equ   <(word ptr [bp-2])>   ; temp storage for es
  1754. TempBX   equ   <(word ptr [bp-4])>   ; temp storage for bx
  1755.  
  1756.        Enter  4,0
  1757.        mov  TempES, es               ; Save Request Block Address
  1758.        mov  TempBX, bx
  1759.  
  1760.        les  di, es:[bx].GIOParaPack  ; load selector to data area
  1761.        mov  cx, es:[di].Parm1        ; Get new Row coordinate
  1762.        mov  dx, es:[di].Parm2        ; Get new Col coordinate
  1763.  
  1764.        test [si].Mtype, Graphics     ; Check current Display Mode
  1765.        .if z                         ; If in Text Mode then
  1766.           mov  ax, [si].TRow_Res     ; Get text mode row resolution
  1767.           mov  di, [si].TCol_Res     ; Get text mode col resolution
  1768.        .else                         ; If in Graphics Mode then
  1769.           mov  ax, [si].GRow_Res     ; Get graphics mode row resolution
  1770.           mov  di, [si].GCol_Res     ; Get graphics mode col resolution
  1771.        .endif                        ; Display Mode Tests
  1772.  
  1773. ;*
  1774. ;*    Now check the new position to make sure that it is in the current
  1775. ;*    display mode limits.  If so then if the old pointer position is visible
  1776. ;*    it is removed.  Then the new position is set and the image drawn if
  1777. ;*    it should be visible.
  1778. ;*
  1779.  
  1780.        .if <cx ge 0>  AND            ; Validate new Ptr Row coordinate
  1781.        .if <cx lt ax> AND            ;  X >= 0 AND X < current row res
  1782.        .if <dx ge 0>  AND            ; Validate new Ptr Col coordinate
  1783.        .if <dx lt di>                ;  Y >= 0 AND Y < current col res
  1784.  
  1785.           call DisableMouse          ; Hold Mouse Interrupts
  1786.           mov  bl, fs:FgndSessn      ; Get current foreground SG #
  1787.           call PtrDrawCheck          ; see if pointer draw op is OK
  1788.           .if <ax eq 0>              ; If Not a Ptr Collision
  1789.              mov  al, fs:CallSessn   ; Get forground screen group #
  1790.              push cx                 ; Save current reg value
  1791.              mov  cx, 0              ; Flag Remove Ptr Required
  1792.              RemovePointer           ; Hide Mouse Pointer Image
  1793.              pop  cx                 ; Restore previous reg value
  1794.           .endif                     ; Collision Area Test
  1795.  
  1796.           mov  [si].Ptr_Row_Pos, cx  ; Update pointer position
  1797.           mov  [si].Ptr_Col_Pos, dx  ; Fields in SG CB
  1798.           mov  bl, fs:FgndSessn      ; Get current foreground SG #
  1799.  
  1800.           call PtrDrawCheck
  1801.           .if <ax eq 0>              ; If Not a Ptr Collision
  1802.              mov  al, fs:CallSessn   ; Get forground screen group #
  1803.              DrawPointer             ; Ensure Mouse Ptr is visible
  1804.           .endif                     ; New Ptr Collision Test
  1805.  
  1806.           call EnableMouse           ; Data Updated, Allow Mouse Ints
  1807.  
  1808.        .else                         ; If input values are invalid then
  1809.           ParmErr                    ; Set Invalid Parm Error
  1810.        .endif                        ; Input Ptr Coord Tests
  1811.  
  1812.        mov  bx, TempBX               ; Restore ES:BX to Request
  1813.        mov  es, TempES               ; Block Address
  1814.        Leave
  1815.  
  1816.        ret                           ; Return to IOCTL Handler Rtn.
  1817. IOMW_SP  ENDP
  1818.  
  1819.  
  1820. ;********************************************************************** 
  1821. ;*                                                               
  1822. ;*  FUNCTION NAME :  IOMW_SD (5A)                               
  1823. ;*                                                               
  1824. ;*  DESCRIPTION   : Performs the mouse IOCtl function
  1825. ;*                    IOMW_SD, register a Pointer Draw DD for a  
  1826. ;*                    protect mode session.                      
  1827. ;*                                                               
  1828. ;*                   The parmlist field of the request block points to
  1829. ;*                   a 3 word structure.  The 1st two words is the FAR 
  1830. ;*                   address to the Pointer Draw entry point.  The 3rd 
  1831. ;*                   word is the Pointer Draw data selector.  The data 
  1832. ;*                   list field points to a 3 word structure.  1st is  
  1833. ;*                   the structure length (6), 2nd is display config # 
  1834. ;*                   the pointer is switching to, 3rd is who the call  
  1835. ;*                   is coming from (0 = app, 1 = BVS).  This IOCtl is 
  1836. ;*                   generated on every MOUOPEN call.  For BVS the ptr 
  1837. ;*                   is always removed and the set mode window flag is 
  1838. ;*                   set.  This is the beginning of a set mode         
  1839. ;*                   sequence if BVS is the caller.                    
  1840. ;*                                                                     
  1841. ;*                   A word is allocated on the local stack frame that 
  1842. ;*                   is used as a local status word.  The bits are     
  1843. ;*                   defined as follows:  bits 15-4, reserved, bit 3 - 
  1844. ;*                   set if configuration number is changing, bit 2 -  
  1845. ;*                   set if ptr image was removed and may need to be   
  1846. ;*                   redrawn, bit 1 - set if ptr draw address is       
  1847. ;*                   changing, bit 0 - set if BVS is the caller.       
  1848. ;*                                                               
  1849. ;*  ENTRY POINT   :  IOMW_SD           LINKAGE:  CALL NEAR
  1850. ;*                                                               
  1851. ;*  INPUT         :  ES:BX points to the request block.                   
  1852. ;*                   SI has offset to current session control block.      
  1853. ;*                                                               
  1854. ;*  RETURN-NORMAL :  Session's Pointer Draw entry point changed.    
  1855. ;*                                                               
  1856. ;*  RETURN-ERROR  :  N/A                                             
  1857. ;*                                                               
  1858. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  1859. ;*                                                               
  1860. ;*  INTERNAL REFERENCES:                                         
  1861. ;*     ROUTINES:  CheckAccess, GetCfgDataOffset, GetExtModeData. 
  1862. ;*                                                               
  1863. ;*  EXTERNAL REFERENCES:                                         
  1864. ;*     ROUTINES:  Ptr Draw(DrawPointer, RemovePointer, Check-    
  1865. ;*                ModeProtect), DDDD(Enable_Device, Disable_-    
  1866. ;*                Device)                                        
  1867. ;*     Dev Helps: None                                           
  1868. ;*                                                               
  1869. ;********************************************************************** 
  1870. ;* PSEUDOCODE :
  1871. ;*
  1872. ;* BeginSub  IOMW_SD  (register ptr draw routine for a session)
  1873. ;*
  1874. ;* check access to data area (caller information from BVS)
  1875. ;* IF <data list pointer is not NULL>
  1876. ;*    IF <length of data area is 6>
  1877. ;*       IF <caller value is 1>
  1878. ;*          set status to BVS is the caller
  1879. ;*          set setmode window flag
  1880. ;*       ENDIF
  1881. ;*       get config # from data area
  1882. ;*       IF <config # is new/different from current>
  1883. ;*          set status to config # is changing
  1884. ;*          save new config #
  1885. ;*       ENDIF
  1886. ;*    ENDIF
  1887. ;* ENDIF
  1888. ;*
  1889. ;* get new ptr draw entry point
  1890. ;* IF <new entry pt is different from current>
  1891. ;*    set status to show ptr draw is changing
  1892. ;* ENDIF
  1893. ;* IF <(BVS is caller OR ptr draw changing OR config # changing) AND
  1894. ;*     Ptr draw routines are used for drawing                    AND
  1895. ;*     display mode is supported                                 AND
  1896. ;*     caller is foreground                                      AND
  1897. ;*     ptr overide flag is off                                   AND
  1898. ;*     there is no collision>
  1899. ;*    call Ptr Draw(RemovePointer) to unconditionally remove the ptr
  1900. ;*    set status to show redraw may be needed
  1901. ;* ENDIF
  1902. ;*
  1903. ;* IF <ptr draw changing OR config # changing>
  1904. ;*    assign new ptr draw entry point
  1905. ;*    IF <BVS is NOT the caller>
  1906. ;*       IF <display mode is currently available>
  1907. ;*          IF <config # is changing>
  1908. ;*             call GetCfgDataOffset to get new cfg data offset
  1909. ;*             IF <offset returned>
  1910. ;*                store sel:off in MSCB for ptr draw use
  1911. ;*             ELSE
  1912. ;*                0 out sel:off to show no config data available
  1913. ;*             ENDIF
  1914. ;*          ENDIF
  1915. ;*          build a display mode record
  1916. ;*          call Ptr Draw(CheckModeProt) to check curren mode
  1917. ;*          IF <current display mode is supported>
  1918. ;*             set device status to supported mode
  1919. ;*             IF <pointer image needs to be redrawn>
  1920. ;*                call Ptr Draw(DrawPointer) to draw the ptr
  1921. ;*             ENDIF
  1922. ;*          ELSE
  1923. ;*             set device status to unsupported mode
  1924. ;*          ENDIF
  1925. ;*       ENDIF
  1926. ;*    ENDIF
  1927. ;* ENDIF
  1928. ;*
  1929. ;* return
  1930. ;*
  1931. ;* EndSub  IOMW_SD
  1932. ;*
  1933. ;***********************************************************************
  1934.  
  1935. IOMW_SD  PROC  near
  1936.  
  1937.        ?frame = 0                         ; Get Local/Temp Stack Frame
  1938.        LocalVar TempES, WORD              ; For ES register
  1939.        LocalVar TempBX, WORD              ; For BX register
  1940.        LocalVar TempSI, WORD              ; For SI register
  1941.        LocalVar TempDS, WORD              ; for ds register
  1942.        LocalVar Status, WORD              ; for local status
  1943.        LocalVar NewCfg, WORD              ; for new config number
  1944. ;*
  1945. ;* These equates are used to set bits in the Status word.
  1946. ;*
  1947.  
  1948. BVSCall     EQU     0001h
  1949. PtrChange   EQU     0002h
  1950. PtrRedraw   EQU     0004h
  1951. CfgChange   EQU     0008h
  1952.  
  1953.  
  1954.        EnterProc
  1955.        mov  TempES, es                    ; Save Request Block Address
  1956.        mov  TempBX, bx
  1957.        mov  TempSI, si                    ; Save Input SG CB Offset
  1958.        mov  TempDS, ds                    ; save ds
  1959.        mov  Status, 0                     ; set status to 0
  1960.  
  1961.        call DisableMouse                  ; disable the mouse
  1962.  
  1963. ;*
  1964. ;* Check access to data area.  First check and see that we can load the
  1965. ;* passed selector offset.  This is for compatibilty because we never checked
  1966. ;* to make sure that the pointer was a dword of 0's in the past.  If that
  1967. ;* access fails then we assume that an old subsystem is calling and will
  1968. ;* not set the BVS calling status bit.  If the access is OK then we will
  1969. ;* check access to the data area.  If access then fails to the data area,
  1970. ;* we will fail with a parameter error.
  1971. ;*
  1972.  
  1973.        test word ptr es:[bx].GIODataPack+2, 0fff8h
  1974.        .if <nz>
  1975.           les  di, es:[bx].GIODataPack
  1976.           .if <es:[di].DLLen eq 6>          ; if valid length field
  1977.              .if <es:[di].DLCaller eq 1>    ; if BVS is the caller
  1978.                 or  Status, BVSCall         ; then set BVS caller bit
  1979.              .endif                         ; 
  1980.              mov  bx, es:[di].DLCfg         ; get new config number
  1981.              .if <bx ne [si].Cur_Config>    ; if new config is different
  1982.                 or   Status, CfgChange      ; show that cfg has changed
  1983.                 mov  NewCfg, bx             ; save new config #
  1984.              .endif                         ; end config changed test
  1985.           .endif                            ; ignore invalid length
  1986.        .endif                               ; 
  1987.  
  1988. ;*
  1989. ;* Now set flag indicating that ptr draw is changing or not and set the
  1990. ;* set mode window active if BVS is the caller.  Also remove the pointer if
  1991. ;* needed. Removal is done by current pointer draw, not new one.
  1992. ;*
  1993.  
  1994.        mov  es, TempES                       ; restore request packet sel
  1995.        mov  bx, TempBX                       ; restore offset
  1996.        les  di, es:[bx].GIOParaPack          ; get address to ptr draw data
  1997.        mov  ax, word ptr es:[di].Addr1+2     ; get current ptr entry
  1998.        mov  dx, word ptr es:[di].Addr1       ; point
  1999.        mov  cx, word ptr es:[di].Addr2       ; data selector
  2000.        push ax
  2001.        push dx
  2002.        push cx
  2003.        .if <ax ne <word ptr [si].Screen_Entp+2>> OR  ; if ptr entry pt
  2004.        .if <dx ne <word ptr [si].Screen_Entp>>   OR  ; has changed, or
  2005.        .if <cx ne <word ptr [si].Screen_DSeg>>       ; data sel changed
  2006.           or  Status, PtrChange              ; then set change status
  2007.        .endif                                ; 
  2008.  
  2009.        mov  bl, fs:FgndSessn                ; get foreground session
  2010.        test Status, BVSCall+PtrChange+CfgChange  ; BVS caller or ptr draw
  2011.        .if nz     ; add and to change back ; has changed or cfg change
  2012.           call PtrDrawCheck
  2013.           .if <ax eq 0>                   ; If Not a Ptr Collision
  2014.              mov  al, fs:CallSessn          ; set foregrnd session
  2015.              push cx                        ; save cx
  2016.              xor  cx, cx                    ; unconditional remove
  2017.              RemovePointer                  ; Hide Mouse Pointer Image
  2018.              pop  cx                        ; restore cx
  2019.              or  Status, PtrRedraw          ; ptr needs to be redrawn
  2020.           .endif                            ; Collision Area Test
  2021.        .endif
  2022.        pop  cx
  2023.        pop  dx
  2024.        pop  ax
  2025.  
  2026. ;*
  2027. ;* Now register the new pointer draw if either the ptr draw DD or the
  2028. ;* display configuration number changed.  If BVS is not the caller then
  2029. ;* verify the current mode data with the new pointer draw.
  2030. ;*
  2031.  
  2032.        test Status, PtrChange+CfgChange       ; if ptr draw or cfg change
  2033.        .if nz  NEAR                           ; then register new one
  2034.           mov  word ptr [si].Screen_Entp, dx  ; save in session CB
  2035.           mov  word ptr [si].Screen_Entp+2, ax ; save in session CB
  2036.           mov  word ptr [si].Screen_DOff, 0   ; zero offset
  2037.           mov  word ptr [si].Screen_DSeg, cx  ; save in session CB
  2038.  
  2039. ;*
  2040. ;*         Now see if the configuration has changed.  If so then store the
  2041. ;*         new configuration data information in the session control block.
  2042. ;*         If BVS is the caller then a subsequent set mode will be done and
  2043. ;*         this new configuration data will be checked.  If BVS is not the
  2044. ;*         caller then a check of the current mode is forced.  If no mode
  2045. ;*         data is available then leave the mouse in its current state.
  2046. ;*
  2047.  
  2048.           test Status, CfgChange          ; see if cfg changed
  2049.           .if <nz>                        ; if it has then
  2050.              mov  bx, NewCfg              ; get new config num
  2051.              call GetCfgDataOffset        ; go get the offset
  2052.              .if <nc>                     ; if offset found then
  2053.                 mov  [si].Cur_Config, bx  ; save new config number
  2054.                 mov  [si].CfgOffset, dx   ; put data offset in CB
  2055.                 mov  [si].CfgSelector, fs ; put selector in CB
  2056.              .else                        ; offset not found
  2057.                 mov  [si].CfgOffset, 0    ; zero out the config data
  2058.                 mov  [si].CfgSelector, 0  ; pointer in the CB
  2059.              .endif
  2060.           .endif
  2061.  
  2062. ;*
  2063. ;*         Now see if BVS is the caller.  If not then build a mode data
  2064. ;*         structure and call PtrDraw to check it.
  2065.  
  2066.  
  2067.           test Status, BVSCall                ; see if BVS is the caller
  2068.           .if z  NEAR                         ; if not then verify mode
  2069.              .if <[si].MLength ne 0> NEAR       ; if mode data available
  2070.                 push fs
  2071.                 pop  es                      ; es pts to our data seg
  2072.                 mov  di, offset Modes        ; get offset of mode struc
  2073.                 push di                      ; save offset of mode struc
  2074.                 mov  cx, BaseModeLen         ; get Base Mode data length
  2075.                 add  si, Mlength             ; offset to mode data in CB
  2076.                 cld                          ; go forwart
  2077.                 rep  movsb                   ; move base mode data
  2078.                 mov  cx, ExtModeLen          ; max len of extended data
  2079.                 mov  al, fs:CallSessn        ; calling session
  2080.                 xor  ah, ah                  ; convert to word value
  2081.                 call GetExtModeData          ; get the extended mode data
  2082.                 pop  di                      ; restore offset mode struc
  2083.                 mov  si, TempSI              ; restore CB offset
  2084.                 mov  ds, TempDS              ; restore our data selector
  2085.  
  2086.                 CheckModeProtect             ; verify data with new ptr draw
  2087.  
  2088.                 .if <ax eq 0>                ; If Mode is supportable then
  2089.                    and  [si].D_Status, NOT USS_Mode  ; show supported mode
  2090.                    mov  bl, fs:FgndSessn
  2091.                    test [si].D_Status, PtrDraw ; If Ptr Draw Rtns Used
  2092.                    call PtrDrawCheck
  2093.                    .if <ax eq 0>          ; If Not a Ptr Collision
  2094.                       mov  al, fs:CallSessn ; Get caller's screen group #
  2095.                       DrawPointer           ; Ensure Mouse Ptr is visible
  2096.                    .endif                   ; New Ptr Collision Test
  2097.  
  2098.                 .else                          ; Mode is unsupported so
  2099.                    or   [si].D_Status, USS_Mode  ; set unsupported mode
  2100.                 .endif                         ; supported mode tests
  2101.              .endif
  2102.           .endif                            ; BVS is caller test
  2103.        .endif                               ; ptr draw or cfg change test
  2104.  
  2105. sd1:
  2106.        mov  es, TempES                      ; restore registers
  2107.        mov  bx, TempBX
  2108.        mov  si, TempSI                      ; Save Input SG CB Offset
  2109.        mov  ds, TempDS                      ; save ds
  2110.  
  2111.        test Status, BVSCall                 ; see if BVS is the caller
  2112.        .if nz                               ; if so then this is the
  2113.           or  [si].Ptr_Flags, SM_WinFlag    ; start of set mode sequence
  2114.        .endif                               ; 
  2115.  
  2116.        call EnableMouse
  2117.  
  2118.        LeaveProc                          ; Clear local Stack variables
  2119.  
  2120.        RET                                ; Return to IOCTL Handler Rtn
  2121. IOMW_SD  ENDP
  2122.  
  2123.  
  2124. ;**********************************************************************
  2125. ;*                                                               
  2126. ;*  FUNCTION NAME :  IOMW_DS  (5C)                              
  2127. ;*                                                               
  2128. ;*  DESCRIPTION   :  Performs the Mouse IOCtl function
  2129. ;*                     IOMW_DS, set device status flags.         
  2130. ;*                                                               
  2131. ;*                  The parmlist field in the request block points to
  2132. ;*                  a new 1-word device status flag.  See Tech Ref    
  2133. ;*                  for definition of each flag.  If singleQ mode is  
  2134. ;*                  activated then mouse "attaches" itself to the     
  2135. ;*                  singleQ device driver.  Reserved bits may not be  
  2136. ;*                  set.  Any further request to start singleQ mode   
  2137. ;*                  by the same caller is ignored.                    
  2138. ;*                                                               
  2139. ;*  ENTRY POINT   :  IOMW_DS           LINKAGE:  CALL NEAR
  2140. ;*                                                               
  2141. ;*  INPUT         :  ES:BX points to the request block.                   
  2142. ;*                   DS:SI has offset to current session control block.   
  2143. ;*                                                               
  2144. ;*  RETURN-NORMAL :  Session's device status flags are updated.     
  2145. ;*                                                               
  2146. ;*  RETURN-ERROR  :  Session's device status flags are unchanged,    
  2147. ;*                   status field in request block set to error code.
  2148. ;*                                                               
  2149. ;*  EFFECTS       :  Stack is clean on return.  Regs not preserved.
  2150. ;*                                                               
  2151. ;*  INTERNAL REFERENCES:                                         
  2152. ;*     ROUTINES:  GetExtModeData, FlushMonChain                  
  2153. ;*                                                               
  2154. ;*  EXTERNAL REFERENCES:                                         
  2155. ;*     ROUTINES:  Ptr Draw(RemovePointer, CheckModeProtect),     
  2156. ;*                DDDD(Enable_Device, Disable_Device), SQ DD     
  2157. ;*     DevHlps:   AttachDD, ProcRun                              
  2158. ;*                                                               
  2159. ;**********************************************************************
  2160. ;* PSEUDOCODE :
  2161. ;*
  2162. ;* BeginSub  IOMW_DS  (set session device status)
  2163. ;*
  2164. ;* call DDDD (Disable_Device) to disable the mouse
  2165. ;* IF <new device status mask is valid>
  2166. ;*    IF <new device status mask is different>
  2167. ;*
  2168. ;*
  2169. ;*** Enable/Disable ptr draw routines.
  2170. ;*
  2171. ;*
  2172. ;*       IF <ptr draw routines are currently used>
  2173. ;*          IF <ptr draw routines are being disabled AND
  2174. ;*              display mode is supported            AND
  2175. ;*              caller is foreground                 AND
  2176. ;*              pointer overide is OFF               AND
  2177. ;*              there is no collision>
  2178. ;*             call Ptr Draw(RemovePointer) unconditional remove
  2179. ;*          ENDIF
  2180. ;*       ELSEIF <ptr draw routines are being enabled>
  2181. ;*          build a display mode data record
  2182. ;*          set ptr draw routines used in device status
  2183. ;*          call Ptr Draw(CheckModeProt) to check mode
  2184. ;*          IF <display mode is supported>
  2185. ;*             set device status to supported mode
  2186. ;*          ELSE
  2187. ;*             set device status to unsupported mode
  2188. ;*          ENDIF
  2189. ;*          set ptr draw routines not used in device status
  2190. ;*       ENDIF
  2191. ;*
  2192. ;*
  2193. ;*** data report format.
  2194. ;*
  2195. ;*
  2196. ;*       IF <data report format is changing>
  2197. ;*          call FlushMonChain to flush monitors and event queue
  2198. ;*          IF <flush failed>
  2199. ;*             set flag for fail set device status
  2200. ;*          ENDIF
  2201. ;*       ENDIF
  2202. ;*
  2203. ;*
  2204. ;*** SingleQ mode enable/disable
  2205. ;*
  2206. ;*
  2207. ;*       IF <activate SQ mode request>
  2208. ;*          IF <no process has activated SQ mode>
  2209. ;*             IF <SQ mode is not active>
  2210. ;*                call Device_Help(AttachDD) to attach to SQDD
  2211. ;*                IF <attach worked>
  2212. ;*                   call SQDD(initialize) for mouse data
  2213. ;*                   IF <initialize call worked>
  2214. ;*                      set SQ ownership PID to current PID
  2215. ;*                      IF <Queue flush not in progress>
  2216. ;*                         call FlushMonChain to flush data
  2217. ;*                      ELSE
  2218. ;*                         set flag indicating queue flush done
  2219. ;*                      ENDIF
  2220. ;*                      IF <queue flush was done>
  2221. ;*                         IF <thread blocked on mouse data>
  2222. ;*                            call Device_Help(ProcRun) to wake up
  2223. ;*                         ENDIF
  2224. ;*                      ENDIF
  2225. ;*                   ELSE
  2226. ;*                      set flag to fail set device status
  2227. ;*                   ENDIF
  2228. ;*                ELSE  /* attach failed */
  2229. ;*                   set flag to fail set device status
  2230. ;*                ENDIF
  2231. ;*             ENDIF
  2232. ;*          ELSE  /* SQ has a process owner  */
  2233. ;*             IF <calling PID is not same as SQ owner PID>
  2234. ;*                set flag for invalid parameters
  2235. ;*             ENDIF
  2236. ;*          ENDIF
  2237. ;*       ELSE    /* could be a reset SQ mode request  */
  2238. ;*          IF <SQ mode is active    AND
  2239. ;*              caller ownes SQ mode>
  2240. ;*             call SQDD(endinput) to end mouse input
  2241. ;*          ENDIF
  2242. ;*       ENDIF
  2243. ;*
  2244. ;*
  2245. ;*** set cmpletion status
  2246. ;*
  2247. ;*
  2248. ;*       IF <failure indicated>
  2249. ;*          set general failure
  2250. ;*       ELSEIF <parameter error indicated>
  2251. ;*          set parameter error
  2252. ;*       ELSE
  2253. ;*          set new device status
  2254. ;*       ENDIF
  2255. ;*
  2256. ;*    ENDIF  /* new status same as old  */
  2257. ;* ELSE      /* new status is invalide  */
  2258. ;*    set parameter error
  2259. ;* ENDIF
  2260. ;*
  2261. ;* call DDDD(Enable_Device) to enable the mouse
  2262. ;* return
  2263. ;*
  2264. ;* EndSub  IOMW_DS
  2265. ;*
  2266. ;***********************************************************************/
  2267.  
  2268. IOMW_DS  proc near
  2269.  
  2270. TempES      equ   <(word ptr[bp-2])>   ; temp storage
  2271. TempBX      equ   <(word ptr[bp-4])>
  2272. SetStatus   equ   <(word ptr[bp-6])>
  2273.  
  2274.     Enter  6,0
  2275.     mov  TempES, es                    ; Save Request Block address
  2276.     mov  TempBX, bx
  2277.     mov  SetStatus, 0                  ; Clear Internal Error Flag
  2278.  
  2279.     les  di, es:[bx].GIOParaPack       ; load selector to data area
  2280.     call DisableMouse                  ; Hold Mouse Interrupts
  2281.  
  2282.     mov  cx, [si].D_Status             ; Get SG device status field flags
  2283.     mov  ax, word ptr es:[di]          ; Get new SG dev status user flags
  2284.  
  2285. ;*
  2286. ;*   First make sure that the new status is valid.  If so then see if it is
  2287. ;*   changing.  If so then continue
  2288. ;*
  2289.  
  2290.     test ax, NOT DevStatSetMax         ; see if any non settable bits set
  2291.     .if <z>              NEAR          ; If not and the new mask
  2292.        .if <ah ne ch>    NEAR          ; is different
  2293.  
  2294. ;*
  2295. ;*   If pointer draw calls for drawing operations are currently acitve
  2296. ;*   and the new device status is disabling them then remove the current
  2297. ;*   pointer image.
  2298. ;*
  2299.  
  2300.           test [si].D_Status, PtrDraw  ; Check Ptr Draw Usage Flag
  2301.           .if <z>                      ; If Ptr Draw is Active then
  2302.              mov  bl, fs:FgndSessn     ; Get FG SG ID #
  2303.              test ax, PtrDraw          ; Check New Ptr Draw Flag Bit
  2304.              .if <nz>                  ; If we are disabling it
  2305.                 call PtrDrawCheck      ; go see if we can call ptr draw
  2306.                 .if <ax eq 0>          ; If so then
  2307.                    mov  al, fs:CallSessn ; Get forground screen group #
  2308.                    push cx             ; Save current reg value
  2309.                    xor  cx, cx         ; Flag Remove Ptr Required
  2310.                    RemovePointer       ; Hide Mouse Pointer Image
  2311.                    pop  cx             ; Restore previous reg value
  2312.                 .endif                 ; Collision Area Test
  2313.              .endif                    ; Ptr Image Visibility Tests
  2314.  
  2315. ;*
  2316. ;*     If pointer draw calls are disabled and the new device status is
  2317. ;*     enabling them then we must check the current mode data to make
  2318. ;*     sure that we can draw.  The reason is that a mode may be only
  2319. ;*     partially supported when ptr draw calls are disabled, but un-
  2320. ;*     supported when they are enabled.
  2321. ;*
  2322.  
  2323.           .else                      ; else ptr draw is currently not active
  2324.  
  2325.              test ax, PtrDraw        ; Is ptr draw being enabled ?
  2326.              .if  z                  ; Yes, is so check the display mode
  2327.                 push di
  2328.                 push es
  2329.                 push fs              ; save our data sel
  2330.                 push fs              ; setup es:di as destination
  2331.                 pop  es
  2332.                 mov  di, offset Modes
  2333.                 push di
  2334.                 push si
  2335.                 add  si, MLength         ; set ds:si as src of base mode data
  2336.                 mov  cx, BaseModeLen     ; base mode data lenght in bytes
  2337.                 cld                      ; go forward
  2338.                 rep  movsb               ; move base mode data
  2339.                 mov  cx, ExtModeLen      ; length of extended mode data
  2340.                 mov  al, fs:CallSessn    ; calling session
  2341.                 xor  ah, ah              ; make word
  2342.                 call GetExtModeData      ; get the extended mode data
  2343.                 pop  si                  ; restore saved registers
  2344.                 pop  di
  2345.                 CheckModeProtect         ; go check the mode data
  2346.                 pop  fs
  2347.                 pop  es
  2348.                 pop  di
  2349.                 .if <ax eq 0>            ; was mode supported
  2350.                    and  [si].D_Status, NOT USS_Mode  ; display mode valid
  2351.                 .else                           ; mode is unsupported
  2352.                    or  [si].D_Status, USS_Mode  ; set unsupported mode
  2353.                 .endif                          ; end mode supported test
  2354.              .endif                             ; end ptr draw enabled test
  2355.           .endif                                ; Ptr Draw Rtn Override Test
  2356.  
  2357. ;*
  2358. ;*         Now see if the reporting format is changing.  This would be from
  2359. ;*         mickey data to screen position or the other way.  If the format
  2360. ;*         is changing then flush the monitor chain to get rid of any old
  2361. ;*         formatted data.
  2362. ;*
  2363.  
  2364.           mov  ax, word ptr es:[di]    ; Get new SG dev status user flags
  2365.           mov  cx, [si].D_Status       ; Get SG device status field flags
  2366.  
  2367.           and  ax, MickeyData          ; Check Data Format Flag Bits
  2368.           and  cx, MickeyData          ; For both Current & New Masks
  2369.  
  2370.           .if <ah ne ch>               ; If Data formats are different
  2371.  
  2372.              call FlushMonChain        ; Flush the monitor chain and evnt que
  2373.  
  2374.              .if c                     ; If MonFlush failed then
  2375.                 mov  SetStatus, 1      ; Flag General Failure
  2376.              .endif                    ; MonFlush Completion Tests
  2377.           .endif                       ; Data Format Change Test
  2378.  
  2379. ;*
  2380. ;*         Now determine is single queue mode is being enabled or disabled.
  2381. ;*
  2382.  
  2383.           mov  ax, word ptr es:[di]              ; Get new dev status flags
  2384.  
  2385. ;*
  2386. ;*         If SQ mode is being activated then attach to the singleq device
  2387. ;*         driver and initialize the IDC interface.  If this works then the
  2388. ;*         monitor chain is flushed.  If a process is blocked on data then
  2389. ;*         it is unblocked, which will cause an error to be returned on the
  2390. ;*         read request (part of another thread) since SQ mode will be active.
  2391. ;*
  2392.  
  2393.           test ax, SQ_Mode                       ; Get SQ Input Mode Flag Mask
  2394.           .if  nz  NEAR                          ; If SQ Activate Request then
  2395.              .if <fs:SQ_Pid eq 0> NEAR           ; no active SQ yet
  2396.  
  2397.                 test [si].D_Status, SQ_Mode      ; Check SQ Mode Flag Bit
  2398.                 .if  z  NEAR                     ; If SQ Input Mode InActive
  2399.  
  2400.                    push di                       ; Save New Mask Offset
  2401.  
  2402.                    lea  bx, fs:SQDDName          ; Offset for SQ DD Name
  2403.                    lea  di, fs:SQDD              ; Offset to Data Record
  2404.                    mov  dl, DevHlp_AttachDD      ; DevHelp Function Number
  2405.                    call fs:Device_Help           ; Invoke AttachDD Function
  2406.  
  2407.                    pop  di                       ; Restore New Mask Offset
  2408.  
  2409.                    .if nc  NEAR                  ; If Attach DD worked then
  2410.  
  2411.                      mov   ax, fs:Eq_Length      ; Get Event Queue Byte Size
  2412.                      mov   cx, ElRec_Size        ; Get Que Element Rec Size
  2413.                      div   cl                    ; Calculate # of Elements
  2414.                      cbw                         ; Get Element Count as Word
  2415.                      mov   cx, Que_Header_Size   ; Get Element Header Size
  2416.                      mul   cl                    ; Calc # Header Bytes
  2417.                      add   ax, fs:Eq_Length      ; Add required Byte Count
  2418.                            
  2419.                      mov   cx, ax                ; Total Byte Cnt
  2420.                      mov   bx, 0001H             ; SQ DD Init & FIFO Buf
  2421.                      mov   ax, 0200H             ; Mouse DD calling
  2422.                      push  es                    ; Save User Data Selector
  2423.                      push  fs:SQDD.ProtDS        ; Get SQ DD DS Selector
  2424.                      pop   es                    ; Load into ES for call
  2425.                      call  dword ptr fs:SQDD.ProtEntry ; Invoke SQ DD Init Func
  2426.                      pop   es                    ; Restore User Data Selector
  2427.  
  2428.                       .if <ax eq 0> NEAR         ; If SQ Init worked then
  2429.  
  2430.                          mov  cx, fs:CallPID           ; get callers PID
  2431.                          mov  fs:SQ_Pid, cx            ; Save in SQ PID
  2432.  
  2433.                          test [si].D_Status, Q_Flush   ; Check Flush Bit
  2434.                          .if  z                        ; AOK to Flush Que
  2435.                             call FlushMonChain         ; go flush mon chain
  2436.                          .else                         ; If Flush in Progress
  2437.                             clc                        ; Set DevHlp worked Flag
  2438.                          .endif                        ; Event Que Flush Tests
  2439.  
  2440.                          .if  nc                       ; If MonFlush worked
  2441.  
  2442.                             test [si].D_Status, Block_Mask ; Check Block Bit
  2443.                             .if  nz                    ; If Thread(s) Blocked
  2444.                                mov  bx, ds             ; SG que addr low word
  2445.                                mov  ax, [si].E_Queue   ; SG que addr high word
  2446.                                mov  dl, DevHlp_ProcRun ; Specify DevHlp Func
  2447.                                call fs:Device_Help     ; Invoke Run Function
  2448.                             .endif                     ; Blocked Thread test
  2449.  
  2450.                          .else                      ; If MonFlush failed then
  2451.                             mov  SetStatus,  1      ; Flag General Failure
  2452.                          .endif                     ; MonFlush Completion Tests
  2453.  
  2454.                       .else                   ; If SQ Init failed then
  2455.                         mov  SetStatus, 1     ; Flag General Failure
  2456.                       .endif                  ; SQ DD Init Function Tests
  2457.  
  2458.                    .else                      ; If Attach DD failed then
  2459.                       mov  SetStatus, 1       ; Flag General Failure
  2460.                    .endif                     ; Attach DD Tests
  2461.                 .endif                        ; SQ Mode InActive Test
  2462.  
  2463.              .else                            ; SQ already active then
  2464.                 mov  ax, fs:SQ_Pid            ; Get PID of SQ owner
  2465.                 .if <ax ne fs:CallPID>        ; If Caller not owner then error
  2466.                    mov  SetStatus, 2          ; Flag Invalid parameter
  2467.                 .endif                        ; Caller not owner test
  2468.              .endif                           ; Shell SQ ID Tests
  2469.  
  2470.           .else                               ; If not a Set SQ Mode request
  2471.  
  2472.              mov  ax, fs:SQ_Pid               ; Get single queue PID
  2473.              .if <fs:CallPID eq ax> AND       ; See if caller owns SQ
  2474.              test [si].D_Status, SQ_Mode      ; Check SQ Mode Flag Bit &
  2475.              .if  nz                          ; If SQ Input Mode Active
  2476.  
  2477.                 mov  ax, 0200H                ; Specify Mouse DD calling
  2478.                 mov  bx, 0003H                ; Specify SQ DD End Function
  2479.                 push es                       ; Save User Data Selector
  2480.                 push fs:SQDD.ProtDS           ; Get SQ DD DS Selector
  2481.                 pop  es                       ; Load into ES for call
  2482.                 call dword ptr fs:SQDD.ProtEntry ; Invoke SQ DD End Func
  2483.                 pop  es                       ; Restore User Data Selector
  2484.                 mov  word ptr fs:SQ_Pid, 00H  ; Reset SQ Pid as available
  2485.  
  2486.              .endif                           ; End SQ Input Mode Tests
  2487.           .endif                              ; SQ Input Mode Activate Tests
  2488.  
  2489. ;*
  2490. ;*         If every thing was OK then set the new device status
  2491. ;*
  2492.  
  2493.           .if <SetStatus eq 0>         ; If Mask Bits are verified then
  2494.              mov  ax, word ptr es:[di] ; Get new SG dev status user flags
  2495.              mov  cx, [si].D_Status    ; Get SG device status field flags
  2496.              mov  al, cl               ; Keep current Status Flags low byte
  2497.              mov  [si].D_Status, ax    ; Set new SG Status Flags high byte
  2498.           .elseif <SetStatus eq 1>     ; If General code failure then
  2499.              GenFail                   ; Flag General Failure in code
  2500.           .elseif <SetStatus eq 2>     ; If Invalid Parm error then
  2501.              ParmErr                   ; Flag Invalid Mask Parameter
  2502.           .endif                       ; Mask Processing Verifications
  2503.  
  2504.        .endif
  2505.  
  2506.     .else                              ; Non settable bits where set
  2507.        ParmErr                         ; Flag user parameter error
  2508.     .endif                             ; New Mask Tests
  2509.  
  2510.     call EnableMouse                   ; Allow Mouse Interrupts
  2511.  
  2512.     mov  es, TempES                    ; Restore Request Block address
  2513.     mov  bx, TempBX
  2514.  
  2515.     Leave                              ; Clear Local stack frame
  2516.  
  2517.     ret                                ; Return to Generic IOCtl Handler Rtn
  2518. IOMW_DS  ENDP
  2519.  
  2520. ;**********************************************************************
  2521. ;                                                               
  2522. ;  FUNCTION NAME :  IOMW_MD    (5Dh)                           
  2523. ;                                                               
  2524. ;  DESCRIPTION   :  Performs the Mouse IOCtl function
  2525. ;                     IOMW_MD, display mode change is complete. 
  2526. ;                                                               
  2527. ;                   This IOCtl is used to tell the mouse that the
  2528. ;                   mode switch has completed and is now active.  If  
  2529. ;                   the caller is FG then the pointer is redrawn if   
  2530. ;                   the new mode is supported.  This IOCtl works in   
  2531. ;                   conjunction with IOCtl IOMW_SM (51h).             
  2532. ;                                                               
  2533. ;  ENTRY POINT    : IOMW_MD         LINKAGE: CALL NEAR
  2534. ;                                                               
  2535. ;  INPUT          :  ES:BX points to the request block.                   
  2536. ;                    SI has offset to current session control block.      
  2537. ;                                                               
  2538. ;  RETURN-NORMAL  :  Always,  pointer is redrawn if necessary.
  2539. ;                                                               
  2540. ;  RETURN-ERROR   :  N/A
  2541. ;                                                               
  2542. ;  EFFECTS        :  Stack is clean on return.  AX, CX, & DI registers
  2543. ;                    are changed.
  2544. ;                                                               
  2545. ;  INTERNAL REFERENCES:                                         
  2546. ;     ROUTINES:  None.                                          
  2547. ;                                                               
  2548. ;  EXTERNAL REFERENCES:                                         
  2549. ;     ROUTINES:  Ptr Draw(DrawPointer)                          
  2550. ;                DDDD(Enable_Device, Disable_Device)            
  2551. ;     DevHelps:  NONE.                                          
  2552. ;                                                               
  2553. ;**********************************************************************
  2554. ;* PSEUDOCODE :
  2555. ;*
  2556. ;* BeginSub  IOMW_MD   (end of display mode switch)
  2557. ;*
  2558. ;* call DDDD(Disable_Device) to disable the mouse
  2559. ;* clear setmode window flag
  2560. ;* call Ptr Draw(DrawPointer) to draw ptr if needed
  2561. ;* call DDDD(Enable_Device) to enable the mouse
  2562. ;* return
  2563. ;*
  2564. ;* EndSub  IOMW_MD
  2565. ;*
  2566. ;***********************************************************************
  2567.  
  2568.  
  2569. IOMW_MD  PROC  near
  2570.  
  2571.  
  2572.        push bx                               ; save bx
  2573.        call DisableMouse                     ; disable the mouse
  2574.  
  2575.        and  [si].Ptr_Flags, NOT SM_WinFlag   ; Reset sem mode window flag
  2576.        push si                                                            ;emi
  2577.  
  2578.        mov  bl, fs:FgndSessn                 ; get FG session
  2579.        call PtrDrawCheck
  2580.        .if <ax eq 0>                         ; If Not a Ptr Collision
  2581.           mov  al, fs:CallSessn              ; forground screen group #
  2582.           DrawPointer                        ; go draw the pointer image
  2583.        .endif                                ; Collision Area Test
  2584.        pop  si                                                            ;emi
  2585.  
  2586.        add  si, MLength                                                   ;emi
  2587.        xor  ch, ch                                                        ;emi
  2588.        mov  cl, fs:CallSessn                                              ;emi
  2589.        xor  bh, bh                                                        ;emi
  2590.        mov  bl, fs:FgndSessn                                              ;emi
  2591.        push es                                                            ;emi
  2592.        call Emi_EndVMChange                  ; cx = caller's session      ;emi
  2593.                                              ; bx = future   session      ;emi
  2594.                                              ; ds:si = video data         ;emi
  2595.        pop  es                                                            ;emi
  2596.  
  2597.        call EnableMouse                      ; enable the mouse
  2598.        pop  bx                               ; restore bx
  2599.  
  2600.        ret                                   ; return to IOCtl routine
  2601.  
  2602. IOMW_MD ENDP
  2603.  
  2604. CSEG2   ENDS
  2605.         END
  2606.