home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / MOUSE / IDC.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  41KB  |  1,175 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 = IDC.ASM
  16. ;*
  17. ;* DESCRIPTIVE NAME = Mouse device independent IDC routines
  18. ;*
  19. ;*
  20. ;* VERSION      V2.0
  21. ;*
  22. ;* DATE         02/29/92
  23. ;*
  24. ;* DESCRIPTION  Mouse device independent IDC routines
  25. ;*
  26. ;* FUNCTIONS    GIDC_Entry()
  27. ;*              VDMEvent  ()
  28. ;*              ProtectEvent  ()
  29. ;*              Process_Packet()
  30. ;*              IntrSetup     ()
  31. ;*
  32. ;* NOTES        This file contains the mouse device independent IDC
  33. ;*              entry point and support routines.  These are refe-
  34. ;*              renced by the device dependent DD.  See the linker
  35. ;*              control file for location in link list
  36. ;*
  37. ;* STRUCTURES   NONE
  38. ;*
  39. ;* EXTERNAL REFERENCES
  40. ;*
  41. ;*              NONE
  42. ;*
  43. ;* EXTERNAL FUNCTIONS
  44. ;*
  45. ;*              NONE
  46. ;*
  47. ;* CHANGE ACTIVITY =
  48. ;*   DATE      FLAG        APAR   CHANGE DESCRIPTION
  49. ;*   --------  ----------  -----  --------------------------------------
  50. ;*   mm/dd/yy  @Vr.mpppxx  xxxxx  xxxxxxx
  51. ;*   02/29/92              DCR 1555
  52. ;*
  53. ;*
  54. ;*
  55. ;*
  56. ;*
  57. ;*
  58. ;*
  59. ;*
  60. ;**************************************************************************
  61.  
  62.  
  63. .386p
  64.  
  65. .xlist
  66.         include mouse.inc
  67.         include infoseg.inc
  68.         include singleq.inc
  69. .list
  70.  
  71.  
  72. ;*
  73. ;* External Mouse Module Data References
  74. ;*
  75.  
  76.        extrn  Ptr_Overide          : byte
  77.        extrn  MEvent               : byte
  78.        extrn  VEvent               : byte
  79.        extrn  Int_Packet           : byte
  80.        extrn  Num_Grps             : byte
  81.        extrn  FgndSessn            : byte
  82.        extrn  SN_Flags             : byte
  83.  
  84.        extrn  GDT_Seg              : word
  85.        extrn  DDDInit              : word
  86.        extrn  IntEntry             : word
  87.        extrn  VDM_Flags            : word
  88.        extrn  IDC_CB               : word
  89.        extrn  Last_Event           : word
  90.  
  91.        extrn  MSEVDDEntry          : fword
  92.        extrn  FgndCB               : dword
  93.        extrn  Process_Absolute     : near
  94.        extrn  CalcRelative         : near
  95.        extrn  CalcPixelMvmnt       : near
  96.        extrn  CalcPtrPos           : near
  97.        extrn  CalcProtThreshold    : near
  98.        extrn  ReportProtectEvent   : near
  99.        extrn  CollisionChk         : near
  100.        extrn  Emi_Stock_Revent     : near                            ; emi
  101.        extrn  Emi_Stock_Aevent     : near                            ; emi
  102.  
  103.        extrn  Request_Handler      : far
  104.        extrn  Monitor_Handler      : far
  105.  
  106.  
  107. CSEG     SEGMENT   WORD  PUBLIC  USE16 'CODE'
  108.          ASSUME    CS:CSEG, SS:nothing, ES:nothing, DS:nothing
  109.  
  110. ;*
  111. ;* Module Procs made Public for other Mouse Modules
  112. ;*
  113.  
  114.        public  GIDC_Entry
  115.        public  Process_Packet
  116.        public  Disable_Support
  117.        public  IntrSetup
  118.        public  ProtectEvent
  119.        public  VDMEvent
  120.        public  Strat_Entry
  121.        public  Open_Mouse
  122.        public  Close_Mouse
  123.        public  Query_Mouse
  124.        public  Up_Activity
  125.        public  Security_Hook1                ;           
  126.        public  Security_End1                 ;           
  127.  
  128.  
  129. ;*********************************************************************
  130. ;*
  131. ;*  FUNCTION NAME :  GIDC_Entry
  132. ;*
  133. ;*  DESCRIPTION   :  Generic mouse device driver IDC entry
  134. ;*                   point.
  135. ;*
  136. ;*                   This routine is the Mouse Device Independent
  137. ;*                   device driver IDC entry point router/handler.
  138. ;*                   IDC function requests are routed to the specific
  139. ;*                   support/worker routines.  The address of this
  140. ;*                   routine is returned when an AttachDD DevHelp call
  141. ;*                   is issued specifying the mouse device (MOUSE$).
  142. ;*
  143. ;*
  144. ;*  INPUT         :  AX = Function code
  145. ;*                   DS = Our data segment selector
  146. ;*                   ES = callers data segment selector
  147. ;*                   Other registers used by specific functions
  148. ;*
  149. ;*  RETURN-NORMAL :  Function performed, carry clear, registers
  150. ;*                   modified by specific functions.
  151. ;*
  152. ;*  RETURN-ERROR  :  Carry set, registers modified.
  153. ;*
  154. ;*  EFFECTS       :  Registers modified.  See individual functions for
  155. ;*                   other possible effects.
  156. ;*
  157. ;*  INTERNAL REFERENCES:
  158. ;*     ROUTINES   :  Process_Packet, Disable_Support.
  159. ;*
  160. ;*  EXTERNAL REFERENCES:
  161. ;*     ROUTINES:  NONE.
  162. ;*     DevHelps:  NONE.
  163. ;*
  164. ;************************************************************************
  165. ;*
  166. ;* PSEUDOCODE   :
  167. ;*
  168. ;*BeginSub  GIDC_Entry  (entry pt for device indpndnt IDC interface)
  169. ;*
  170. ;* IF <support has not been disabled by DISABLE_SUPPORT call>
  171. ;*    IF <requested function is PROCESSPACKET>
  172. ;*       call Process_Packet to process the packet
  173. ;*       set no error code
  174. ;*    IF <requested function is DISABLESUPPORT>
  175. ;*       call Disable_Support to disable support
  176. ;*       set no error code
  177. ;*    IF <requested function is PROCESSABSOLUTE>
  178. ;*       call Process_Absolute to process the packet
  179. ;*       set no error code
  180. ;*    IF <requested function is OPENMOUSE>
  181. ;*       call Start_IDC to check for an available handle
  182. ;*    IF <requested function is CLOSEMOUSE>
  183. ;*       call Stop_IDC to free callers handle
  184. ;*    IF <requested function is QUERYMOUSE>
  185. ;*       IF <SN support is active>
  186. ;*          call Query_Mouse to return the activity status since last call
  187. ;*       ELSE
  188. ;*          Set carry flag to indicate error
  189. ;*          return unknown command error code
  190. ;*       ENDIF
  191. ;*    ELSE
  192. ;*       set error code
  193. ;*    ENDIF
  194. ;* ELSE
  195. ;*    set error code
  196. ;* ENDIF
  197. ;* return
  198. ;*
  199. ;*EndSub  GIDC_Entry
  200. ;*
  201. ;************************************************************************
  202.  
  203. GIDC_Entry  Proc  FAR
  204.  
  205. ;*
  206. ;*      If support is enabled then call the appropriate support routine.
  207. ;*
  208.  
  209.        .if <bit DDDInit z DI_ERROR>      ; if support has not been disbled
  210.  
  211.           .if <ax eq PROCESSPACKET>      ; Process packet call ?
  212.              call Emi_Stock_Revent       ; pre_process packet         ;emi
  213.  
  214.              .if <bit SN_Flags nz SNF_ACTIVE> ; If SN support is active
  215.                 call Up_Activity         ; Update activity status
  216.              .endif
  217.  
  218.              clc                         ; clear carry for no error
  219.  
  220.           .elseif <ax eq DISABLESUPPORT> ; Disable support call ?
  221.              call Disable_Support        ; go set flag to disable support
  222.              clc                         ; clear carry for no error
  223.  
  224.           .elseif <ax eq PROCESSABSOLUTE>; Process packet call ?
  225.              call Emi_Stock_Aevent       ; pre_process packet         ;emi
  226.  
  227.              .if <bit SN_Flags nz SNF_ACTIVE> ; If SN support is active
  228.                 call Up_Activity         ; Update activity status
  229.              .endif
  230.  
  231.              clc                         ; clear carry for no error
  232.  
  233.           .elseif <ax eq OPENMOUSE>      ; Open MOUSE$ call?
  234.              call Open_Mouse             ; Try to obtain a handle
  235.  
  236.           .elseif <ax eq CLOSEMOUSE>     ; Close MOUSE$ call?
  237.              call Close_Mouse            ; Try to release the handle
  238.  
  239.           .elseif <ax eq QUERYMOUSE>     ; Query mouse activity call?
  240.              .if <bit SN_Flags nz SNF_ACTIVE> ; If SN support is active.
  241.                 call Query_Mouse         ; Get status since last call
  242.              .else
  243.                 stc                      ; indicate error
  244.                 mov ax, 1                ; unknown command error code
  245.              .endif
  246.  
  247.           .else                          ; un recognized function
  248.              stc                         ; indicate error
  249.              mov  ax, 1                  ; unknown command error code
  250.           .endif                         ; end
  251.  
  252.        .else                             ; else support has been disabled
  253.           mov  ax, 1                     ; set error code
  254.        .endif
  255.        ret                               ; return to Device Dependent DD
  256.  
  257. GIDC_Entry  EndP
  258.  
  259.  
  260. ;*************************************************************************
  261. ;*
  262. ;*  FUNCTION NAME :  Process_Packet
  263. ;*
  264. ;*  DESCRIPTION   :  Process a relative mouse packet.
  265. ;*
  266. ;*                   This routine processes the interrupt data for the
  267. ;*                   mouse device.  A complete interrupt packet has
  268. ;*                   been recieved.  Motion is calculated.  If the
  269. ;*                   event is reportable then it is sent down the
  270. ;*                   monitor chain.  If no monitors are registered
  271. ;*                   then it is sent directly to the monitor handler.
  272. ;*                   The pointer image is then updated.  If a hot key
  273. ;*                   is detected then the event is sent.  This routine
  274. ;*                   is called by the IDC router for the indep.  DD.
  275. ;*
  276. ;*  ENTRY POINT   :  Process_Packet    LINKAGE:  CALL NEAR
  277. ;*
  278. ;*  INPUT         :  Int_Packet should be filled by the DDDD
  279. ;*
  280. ;*                         where Int_Packet is defined as
  281. ;*
  282. ;*                                    Event       DW
  283. ;*                                    Col_Mov     dw
  284. ;*                                    Row_Mov     dw
  285. ;*
  286. ;*  RETURN-NORMAL :  Always.
  287. ;*
  288. ;*  RETURN-ERROR  :  Never.
  289. ;*
  290. ;*  EFFECTS       :  Pointer position updated and event saved.
  291. ;*
  292. ;*  INTERNAL REFERENCES:
  293. ;*     ROUTINES   :  CalcNewPtrPos, IntrSetup, ReportEvent
  294. ;*
  295. ;*  EXTERNAL REFERENCES:
  296. ;*     ROUTINES   :  NONE.
  297. ;*     DevHelps   :  NONE.
  298. ;*
  299. ;*************************************************************************
  300. ;* PSEUDOCODE :
  301. ;*
  302. ;* BeginSub  Process_Packet  (process an interrupt packet of data)
  303. ;*
  304. ;*  call IntrSetup to do common event processing setup
  305. ;*  IF <session has support>
  306. ;*     call CalcNewPtrPos to update row position
  307. ;*     call CalcNewPtrPos to update col position
  308. ;*     call ReportEvent to report the mouse event if needed.
  309. ;*  ENDIF          /* Ignore event if no support available  */
  310. ;*
  311. ;*  return
  312. ;*
  313. ;* EndSub  Process_Packet
  314. ;*
  315. ;************************************************************************
  316.  
  317. Process_Packet  Proc  Near
  318.  
  319. ;*
  320. ;*  First increment the entry flag for use in debugging to see if we are
  321. ;*  servicing a mouse event.  Then check if this event is for a full screen
  322. ;*  session. If it is a full screen session then call IntrSetup to setup
  323. ;*  everything needed to process a protect mode full screen mouse event.
  324. ;*  IntrSetup puts the sel:off of the mouse CB affected in DS:SI and
  325. ;*  leaves the mouse data selector in FS.  DS should be reset to
  326. ;*  the mouse data selector before exiting.
  327. ;*
  328.  
  329. Security_Hook1:      ;           
  330.  
  331.        inc  IntEntry
  332.        mov  al, Num_Grps                ; Get number of full screen sessions
  333.  
  334. Security_End1:       ;           
  335.  
  336.        .if <FgndSessn lt al> AND        ; If this is a full screen session AND
  337.        .if <bit VDM_Flags z VDMXMOUSEMODE> ; A windowed VDM does NOT have
  338.                                            ; Exclusive mouse access!
  339.           push ds
  340.           push fs
  341.           call IntrSetup             ; do common event processing setup
  342.  
  343. ;*
  344. ;* If carry is clear then it is OK to process the event.
  345. ;*
  346.  
  347.           .if <nc>   NEAR            ; and session has open mse support
  348.              call ProtectEvent       ; process a fullscreen event
  349.           .endif
  350.           pop  fs                    ; restore fs to entry value
  351.           pop  ds                    ; restore our ds
  352.  
  353.        .else
  354.           call VDMEvent              ; process VDM event
  355.        .endif
  356.  
  357.        dec  IntEntry                 ; decrement entry count
  358.  
  359.        ret                           ; return to IDC router
  360.  
  361. Process_Packet  EndP
  362.  
  363. ;***********************************************************************
  364. ;*
  365. ;*  FUNCTION NAME :  Disable_Support
  366. ;*
  367. ;*  DESCRIPTION   :  Disabe support support routine.
  368. ;*
  369. ;*                   This routine disables support for all API level
  370. ;*                   requests.  It is issued by the device dependent
  371. ;*                   DD when it receives a deinstall request.  It sets
  372. ;*                   a flag value that is check on entry to all API
  373. ;*                   level requests.
  374. ;*
  375. ;*  ENTRY POINT   :  Disable_Support   LINKAGE:  CALL NEAR
  376. ;*
  377. ;*  INPUT         :  None.
  378. ;*
  379. ;*  RETURN-NORMAL :  Always.
  380. ;*
  381. ;*  RETURN-ERROR  :  Never.
  382. ;*
  383. ;*  EFFECTS       :  API is disabled.
  384. ;*
  385. ;*  INTERNAL REFERENCES:
  386. ;*     ROUTINES   :  NONE
  387. ;*
  388. ;*  EXTERNAL REFERENCES:
  389. ;*     ROUTINES   :  None.
  390. ;*     DevHelps   :  None.
  391. ;*
  392. ;***********************************************************************
  393. ;*
  394. ;* BeginSub  Disable_Support
  395. ;*
  396. ;*   set flag indicating that support has been disabled
  397. ;*   return
  398. ;*
  399. ;* EndSub  Disable_Support
  400. ;*
  401. ;************************************************************************
  402.  
  403. Disable_Support  Proc  Near
  404.  
  405.         mov  DDDInit, DI_ERROR         ; flag shut down of all activities
  406.         ret
  407.  
  408. Disable_Support  EndP
  409.  
  410. ;**********************************************************************
  411. ;*
  412. ;*  FUNCTION NAME :  Open_Mouse
  413. ;*
  414. ;*  DESCRIPTION   :  Start an Inter Device Communication link
  415. ;*                     with the mouse device independent device
  416. ;*                     driver (MOUSE$).
  417. ;*
  418. ;*                   This function is invoked by another Device
  419. ;*                   driver to get a Mouse IDC interface handle.
  420. ;*                   This function supports a max of 5 open Mouse
  421. ;*                   IDC handles at any one time. If a 6th Mouse IDC
  422. ;*                   handle is requested a NO_HANDLES_AVAILABLE error
  423. ;*                   code will be returned.
  424. ;*
  425. ;*  ENTRY POINT  :  Open_Mouse        LINKAGE:  CALL NEAR
  426. ;*
  427. ;*  ENTRY        :  AX = Function code
  428. ;*                  Open Mouse = 0004h
  429. ;*                  DS = Mouse$ DD DS value
  430. ;*                  ES = Calling DD DS value
  431. ;*                  All other reqs are undefined
  432. ;*
  433. ;*  RETURN-NORMAL: Carry Flag clear. Register listed below;
  434. ;*
  435. ;*                   BX = Mouse IDC handle
  436. ;*                   DS = Mouse$ DD DS value
  437. ;*                   ES = Calling DD DS value
  438. ;*                   All other reqs are undefined
  439. ;*
  440. ;*  RETURN-ERROR :  Carry set, registers listed below;
  441. ;*
  442. ;*                  AX = Error return code if carry set
  443. ;*                  DS = Mouse$ DD DS value
  444. ;*                  ES = Calling DD DS value
  445. ;*                  All other reqs are undefined
  446. ;*
  447. ;*  EFFECTS      :  Registers modified.
  448. ;*
  449. ;*  INTERNAL REFERENCES:
  450. ;*     ROUTINES:  NONE.
  451. ;*
  452. ;*  EXTERNAL REFERENCES:
  453. ;*     ROUTINES:  NONE.
  454. ;*     DevHelps:  NONE.
  455. ;*
  456. ;**********************************************************************
  457. ;*  PSEUDOCODE :
  458. ;*
  459. ;* BeginSub  Open_Mouse
  460. ;*
  461. ;*
  462. ;*    Get CB for handle 0
  463. ;*    REPEAT
  464. ;*       IF <this handle is free>
  465. ;*          Mark this handle as active in CB
  466. ;*          LEAVE
  467. ;*       ENDIF
  468. ;*       Get CB for next handle
  469. ;*    UNTIL <MAXIDCS have been checked>
  470. ;*
  471. ;*
  472. ;*    IF <a new handle has been given>
  473. ;*       Clear carry flag
  474. ;*    ELSE
  475. ;*       move into AX register (ERROR_NO_MORE_HANDLES)
  476. ;*       Set carry flag
  477. ;*    ENDIF
  478. ;*
  479. ;*  return
  480. ;*
  481. ;* EndSub  Open_Mouse
  482. ;*
  483. ;************************************************************************
  484.  
  485. Open_Mouse  proc  near
  486.  
  487.    lea  si, IDC_CB                       ; Offset to the block of handles.
  488.    xor  bx, bx                           ; Start with handle zero.
  489.  
  490.    .repeat
  491.       .if <bit [si].IDC_Flags z IDC_ACTIVE>    ; If handle is free.
  492.          or [si].IDC_Flags, IDC_ACTIVE   ; This handle is now in use.
  493.          .leave
  494.       .endif
  495.       inc  bx                            ; Try next handle
  496.       add  si, size IDC_Entry            ; Get next slot
  497.    .until <bx eq MAXIDCS>                ; Zero based (6th entry is invalid)
  498.  
  499.  
  500.    .if <bx lt MAXIDCS>                   ; If a new handle has been given
  501.       clc
  502.    .else
  503.       mov  ax, 8024h                     ; ERROR_NO_MORE_HANDLES
  504.       stc
  505.    .endif
  506.  
  507.    ret
  508.  
  509. Open_Mouse  endp
  510.  
  511. ;**********************************************************************
  512. ;*
  513. ;*  FUNCTION NAME :  Close_Mouse
  514. ;*
  515. ;*  DESCRIPTION   :  Shut down the inter device communication
  516. ;*                   link between MOUSE$ and the calling
  517. ;*                   device driver.
  518. ;*
  519. ;*                   This function is invoked by another Device
  520. ;*                   driver to free a Mouse IDC interface handle.
  521. ;*                   This handle value must have been generated using
  522. ;*                   the mouse IDC function 0004h (Start_IDC). If
  523. ;*                   the handle is invalid then an INVALID_HANDLE
  524. ;*                   error code will be returned.
  525. ;*
  526. ;*  ENTRY POINT   :  Close_Mouse       LINKAGE:  CALL NEAR
  527. ;*
  528. ;*  ENTRY         :    AX = Function code
  529. ;*                          Close Mouse = 0005h
  530. ;*                     BX = Mouse IDC handle
  531. ;*                     DS = Mouse$ DD DS value
  532. ;*                     ES = Calling DD DS value
  533. ;*                     All other reqs are undefined
  534. ;*
  535. ;*  RETURN-NORMAL : Carry Flag clear. Register listed below;
  536. ;*
  537. ;*                      DS = Mouse$ DD DS value
  538. ;*                      ES = Calling DD DS value
  539. ;*                      All other reqs are undefined
  540. ;*
  541. ;*  RETURN-ERROR :  Carry set, registers listed below;
  542. ;*
  543. ;*                      AX = Error return code if carry set
  544. ;*                      DS = Mouse$ DD DS value
  545. ;*                      ES = Calling DD DS value
  546. ;*                      All other reqs are undefined
  547. ;*
  548. ;*  EFFECTS      :  Registers modified.
  549. ;*
  550. ;*  INTERNAL REFERENCES:
  551. ;*     ROUTINES:  NONE.
  552. ;*
  553. ;*  EXTERNAL REFERENCES:
  554. ;*     ROUTINES:  NONE.
  555. ;*     DevHelps:  NONE.
  556. ;*
  557. ;**********************************************************************
  558. ;* PSEUDOCODE :
  559. ;*
  560. ;* BeginSub  Close_Mouse
  561. ;*
  562. ;*
  563. ;*  IF <callers handle le MAXIDCS>
  564. ;*     Get a pointer to the CB for this handle
  565. ;*     Mark this handle as inactive in CB
  566. ;*     Bring status back to idle state. (Set to zero)
  567. ;*     Clear the carry flag
  568. ;*  ELSE
  569. ;*     Move into AX register (ERROR_MOUSE_INVALID_HANDLE)
  570. ;*     Set carry flag
  571. ;*  ENDIF
  572. ;*
  573. ;*  return
  574. ;*
  575. ;* EndSub  Close_Mouse
  576. ;*
  577. ;*************************************************************************
  578.  
  579. Close_Mouse  proc  near
  580.  
  581.    .if <bx lt MAXIDCS>
  582.       lea  si, IDC_CB                     ; Offset to the block of handles
  583.       imul bx, size IDC_Entry             ; Get offset to this entry
  584.       add  si, bx                         ; We now point to the handle entry
  585.       and  [si].IDC_Flags, NOT IDC_ACTIVE ; This handle is now in use
  586.       mov  [si].IDC_Status, 0             ; Bring status back to idle state.
  587.       clc
  588.    .else
  589.       mov  ax, 502                        ; ERROR_MOUSE_INVALID_HANDLE
  590.       stc
  591.    .endif
  592.  
  593.    ret
  594.  
  595. Close_Mouse  endp
  596.  
  597. ;***********************************************************************
  598. ;*
  599. ;*  FUNCTION NAME :  Query_Mouse
  600. ;*
  601. ;*  DESCRIPTION   :  Query for mouse activity since last call.
  602. ;*
  603. ;*  FUNCTION      :  This function is invoked by another Input Device
  604. ;*                   driver to get the current mouse activity status.
  605. ;*
  606. ;*                   The activity status word shows any activity that
  607. ;*                   went on since the last time this function was
  608. ;*                   called or since the caller's handle was opened.
  609. ;*
  610. ;*                   The activity status word also shows any buttons
  611. ;*                   that are currently in use (down).
  612. ;*
  613. ;*                   A return value of zero in the BX register,
  614. ;*                   without an error condition, means no mouse device
  615. ;*                   activity has been recorded since the last call
  616. ;*                   and no buttons are currently down.
  617. ;*
  618. ;*                   In addition, the return status is on a system
  619. ;*                   wide basis. Meaning, there is no evaluation for a
  620. ;*                   particular session's activity.
  621. ;*
  622. ;*                   If the input mouse IDC handle in invalid then an
  623. ;*                   INVALID_HANDLE error code is returned.        .
  624. ;*
  625. ;*  NOTES        :   This function is valid only when OS/2 Special
  626. ;*                   needs support is enabled. If SN support is
  627. ;*                   disabled an UNKNOWN_COMMAND error code is
  628. ;*                   returned to the caller.
  629. ;*
  630. ;*
  631. ;*  ENTRY POINT  : Query_Mouse           LINKAGE: CALL NEAR
  632. ;*
  633. ;*  ENTRY        :         AX = Function code
  634. ;*                              Query Mouse = 0006h
  635. ;*                         BX = Mouse IDC handle
  636. ;*                         DS = Mouse$ DD DS value
  637. ;*                         ES = Calling DD DS value
  638. ;*                         All other reqs are undefined
  639. ;*
  640. ;*  RETURN-NORMAL : Carry Flag clear. Register listed below;
  641. ;*
  642. ;*                         BX = Mouse Activity Status
  643. ;*                         DS = Mouse$ DD DS value
  644. ;*                         ES = Calling DD DS value
  645. ;*                         All other reqs are undefined
  646. ;*
  647. ;*  RETURN-ERROR  :  Carry set, registers listed below;
  648. ;*
  649. ;*                         AX = Error return code if carry set
  650. ;*                         DS = Mouse$ DD DS value
  651. ;*                         ES = Calling DD DS value
  652. ;*                         All other reqs are undefined
  653. ;*
  654. ;*  EFFECTS       :  Registers modified.
  655. ;*
  656. ;*  INTERNAL REFERENCES:
  657. ;*     ROUTINES:  NONE.
  658. ;*
  659. ;*  EXTERNAL REFERENCES:
  660. ;*     ROUTINES:  NONE.
  661. ;*     DevHelps:  NONE.
  662. ;*
  663. ;***********************************************************************
  664. ;* PSEUDOCODE :
  665. ;*
  666. ;*  BeginSub  Query_Mouse
  667. ;*
  668. ;*   IF <handle is in valid range>
  669. ;*      Get pointer to the CB for this handle
  670. ;*      Move the mouse activity status into the BX register
  671. ;*      Bring status back to idle state. (Set to zero)
  672. ;*      Clear the carry flag
  673. ;*   ELSE
  674. ;*      Move into the AX register (ERROR_MOUSE_INVALID_HANDLE)
  675. ;*      Set the carry flag
  676. ;*   ENDIF
  677. ;*
  678. ;*  return
  679. ;*
  680. ;* EndSub  Query_Mouse
  681. ;*
  682. ;************************************************************************
  683.  
  684. Query_Mouse  proc  near
  685.  
  686.    .if <bx lt MAXIDCS>                ; If handle is in valid range AND
  687.       lea  si, IDC_CB                 ; Offset to the block of handles
  688.       imul bx, size IDC_Entry         ; Get offset to this entry
  689.       add  si, bx                     ; We now point to the handle entry
  690.       mov  bx, [si].IDC_Status        ; MSE activity status since last call
  691.  
  692.       mov  ax, Int_Packet.Event       ; Get current mouse state
  693.       and  ax, NOT 1                  ; We want button status only
  694.  
  695.       or   bx, ax                     ; Return activity since last call +
  696.                                       ; current buttons in use.
  697.       mov [si].IDC_Status, ax         ; Bring status back to current state.
  698.       clc
  699.    .else
  700.       mov  ax, 502                    ; ERROR_MOUSE_INVALID_HANDLE
  701.       stc
  702.    .endif
  703.  
  704.    ret
  705.  
  706. Query_Mouse  endp
  707.  
  708.  
  709. ;**********************************************************************
  710. ;*
  711. ;* FUNCTION NAME :  ProtectEvent
  712. ;*
  713. ;* FUNCTION      :  This routine processes a protect mode session mse
  714. ;*                  event.
  715. ;*
  716. ;* INPUT         : none
  717. ;*
  718. ;* OUTPUT        : none
  719. ;*
  720. ;**********************************************************************
  721. ;* PSEUDOCODE  :
  722. ;* BeginSub  ProtectEvent
  723. ;*
  724. ;*
  725. ;* EndSub  ProtectEvent
  726. ;*
  727. ;************************************************************************
  728.  
  729.  
  730. ProtectEvent  proc  near
  731.  
  732. NewRow     equ   <(word ptr [bp-2])>   ; local var for new row coord
  733. NewCol     equ   <(word ptr [bp-4])>   ; local var for new col coord
  734.  
  735.        enter 4,0                       ; reserve space for vars
  736.  
  737. ;*
  738. ;*      Put the current row/column resolution on the stack to be pulled off
  739. ;*      later for use in motion calcs.
  740. ;*
  741.        test [SI].MType, Graphics      ; Test for Disp Mode Resolution
  742.        .if  nz                        ; If in Graphics Mode then
  743.          push [si].GCol_Res           ; push the graphics resolutions
  744.          push [si].GRow_Res           ; on stack for use by CalcNewPtrPos
  745.        .else                          ; else push the text resolutions
  746.          push [si].TCol_Res           ; on stack for use by CalcNewPtrPos
  747.          push [si].TRow_Res           ; 
  748.        .endif                         ; end display mode type test
  749.  
  750. ;*
  751. ;*   Calculate the row motion.  First determine the number of pixels moved
  752. ;*   by calling CalcPixelMvmnt.  If there was motion then apply the
  753. ;*   thresholding algorithm and calculate the new pointer position.  If there
  754. ;*   was no motion then the current row position is used.
  755. ;*
  756.        push [si].RowScale_Fact        ; row scale factor
  757.        push fs:Int_Packet.Row_Mov     ; raw row motions (mickeys)
  758.        push [si].Row_Remain           ; row mickey motion remainder
  759.        call CalcPixelMvmnt            ; calculate number of pixels moved
  760.        pop  [si].Row_Remain           ; save remainder
  761.        add  sp, 4                     ; remove parameters from stack
  762.  
  763.        .if <ax ne 0>                  ; if there was pixel movement
  764.           push fs:Int_Packet.Row_Mov  ; push raw motion
  765.           call CalcProtThreshold      ; do a protect mode threshold calc
  766.           add  sp, 2                  ; remove parameter from stack
  767.  
  768.           push [si].Ptr_Row_Pos       ; ptr row pos (row res already there)
  769.           push [si].Row_Cell_Size     ; row cell size
  770.           push [si].Row_Cell_Remain   ; row cell motion remainder
  771.           call CalcPtrPos             ; calculate new pointer position
  772.           pop  [si].Row_Cell_Remain   ; save cell remainder for later use
  773.           add  sp, 6                  ; remove parameters from stack
  774.           mov  NewRow, ax             ; this is the new row
  775.        .else                          ; else no screen movement
  776.           add  sp, 2                  ; remove row resolution from stack
  777.           mov  ax, [si].Ptr_Row_Pos   ; get current row
  778.           mov  NewRow, ax             ; the new row is the old row
  779.        .endif
  780.  
  781. ;*
  782. ;*     Repeat the same steps for the column position (motion).
  783. ;*
  784.  
  785.        push [si].ColScale_Fact        ; col scale factor
  786.        push fs:Int_Packet.Col_Mov     ; raw col motions (mickeys)
  787.        push [si].Col_Remain           ; col mickey motion remainder
  788.        call CalcPixelMvmnt            ; calculate number of pixels moved
  789.        pop  [si].Col_Remain           ; save last remainder
  790.        add  sp, 4                     ; remove parameters from stack
  791.  
  792.        .if <ax ne 0>                  ; if there was pixel movement
  793.           push fs:Int_Packet.Col_Mov  ; push raw motion
  794.           call CalcProtThreshold      ; do a protect mode threshold calc
  795.           add  sp, 2                  ; remove parameter from stack
  796.  
  797.           push [si].Ptr_Col_Pos       ; ptr row pos (col res already there)
  798.           push [si].Col_Cell_Size     ; coc cell size
  799.           push [si].Col_Cell_Remain   ; coc cell motion remainder
  800.           call CalcPtrPos             ; calculate new pointer position
  801.           pop  [si].Col_Cell_Remain   ; save cell remainder for later use
  802.           add  sp, 6                  ; remove parameters from stack
  803.           mov  NewCol, ax             ; save new col
  804.        .else                          ; else no screen movement
  805.           add  sp, 2                  ; remove col resolution from stack
  806.           mov  ax, [si].Ptr_Col_Pos   ; get the current col
  807.           mov  NewCol, ax             ; the new col is the old col
  808.        .endif
  809.  
  810. ;*
  811. ;*      Now build the mouse event.  If mickey data is to be reported then
  812. ;*      put the raw motion in the event and push the uncondintional report flag.
  813. ;*      Otherwise put the row/col position in the event and push the conditional
  814. ;*      report flag.  Then call ReportProtectEvent to route the event to the
  815. ;*      appropriate place.
  816. ;*
  817.  
  818.         test [SI].D_Status, MickeyData   ; check to see if mickey data
  819.        .if  nz                           ; to be reported.  If so
  820.           mov  ax, fs:Int_Packet.Row_Mov ; raw motion motion reported
  821.           mov  cx, fs:Int_Packet.Col_Mov ; for both row and col
  822.           mov  fs:MEvent.Mon_Row_Pos, ax ; and put in the event record
  823.           mov  fs:MEvent.Mon_Col_Pos, cx ; 
  824.           push 1                         ; undonditionaly report the event
  825.        .else                             ; Else report type pointer pos.
  826.           mov  ax, NewRow                ; get new row
  827.           mov  cx, NewCol                ; get new col
  828.           mov  fs:MEvent.Mon_Row_Pos, ax ; put in event record
  829.           mov  fs:MEvent.Mon_Col_Pos, cx
  830.           push 0                         ; report event if not a duplicate
  831.        .endif                            ; Mickey Data Report Test
  832.  
  833.        push NewRow
  834.        push NewCol
  835.        call ReportProtectEvent           ; go report a protect mode event
  836.        add  sp, 6                        ; clear parameters from stack
  837.  
  838.        leave                             ; clear stack
  839.        ret
  840.  
  841. ProtectEvent  endp
  842.  
  843.  
  844. ;***********************************************************************
  845. ;*
  846. ;* FUNCTION NAME : VDMEvent
  847. ;*
  848. ;* DESCRIPTION   : This routine processes a VDM session mouse event.
  849. ;*
  850. ;*                 This routine processes the mouse event for a
  851. ;*                 full screen VDM. The PMSE calls the VMSE with
  852. ;*                 the NOTIFYEVENT function of the PMSE-VMSE IDC.
  853. ;*                 The event is reported in relative mickeys moved.
  854. ;*                 The packet passed to the VMSE is listed below;
  855. ;*
  856. ;*                 This structure is used when the PMSE
  857. ;*                 sends an event to the VMSE.
  858. ;*
  859. ;*            VDMEvent_        struc
  860. ;*               ve_SGID       dw       ?   ; Screen group number.
  861. ;*               ve_Event      dw       ?   ; Button/motion status bits.
  862. ;*               ve_DeltaX     dw       ?   ; Column motion in mickeys.
  863. ;*               ve_DeltaY     dw       ?   ; Row motion in mickeys.
  864. ;*            VDMEvent_        Ends
  865. ;*
  866. ;*  ENTRY POINT  :  VDMEvent          LINKAGE:  CALL NEAR
  867. ;*
  868. ;*  INPUT        :  DS:SI = offset to interrupt packet data.
  869. ;*
  870. ;*  RETURN-NORMAL:  Always.
  871. ;*
  872. ;*  RETURN-ERROR :  Never.
  873. ;*
  874. ;*  EFFECTS      :  All regs may be modified.
  875. ;*
  876. ;*  INTERNAL REFERENCES:
  877. ;*     ROUTINES  :  CalcNewPtrPos, IntrSetup, ReportEvent
  878. ;*
  879. ;*  EXTERNAL REFERENCES:
  880. ;*     ROUTINES  :  NONE.
  881. ;*     DevHelps  :  NONE.
  882. ;*
  883. ;***********************************************************************
  884. ;* PSEUDOCODE :
  885. ;*
  886. ;* BeginSub  VDM_Event
  887. ;*
  888. ;*   Store current SGID in input packet to VMSE
  889. ;*
  890. ;*   Store current event in input packet to VMSE
  891. ;*   Store column movement in mickeys in the input packet to VMSE
  892. ;*   Store row movement in mickeys in the input packet to VMSE
  893. ;*
  894. ;*   IF <the VDM interface is enabled>
  895. ;*      send off the event to VMSE
  896. ;*   ENDIF
  897. ;*
  898. ;*  return
  899. ;*
  900. ;* EndSub  VDM_Event
  901. ;*
  902. ;************************************************************************
  903.  
  904. VDMEvent  proc  near
  905.  
  906. ;*
  907. ;* If excluse mouse access mode is ON, then the VEvent.ve_SGID field
  908. ;* has already been updated when the VMSE called PDDCMD_XMouseMode.
  909. ;*
  910.  
  911.        .if <bit VDM_Flags z VDMXMOUSEMODE>
  912.           mov  al, fgndsessn            ; Foreground FS VDM SGID
  913.           cbw                           ; Make into a word
  914.           mov  VEvent.ve_SGID, ax       ; Update input packet.
  915.        .endif
  916.  
  917.        mov  ax, Int_Packet.Event        ; Motion/button status.
  918.        mov  VEvent.ve_Event, ax         ; Update input packet.
  919.  
  920.        mov  ax, Int_Packet.Col_Mov      ; Column movement in mickeys.
  921.        mov  VEvent.ve_X, ax             ; Update input packet.
  922.  
  923.        mov  ax, Int_Packet.Row_Mov      ; Row movement in mickeys.
  924.        mov  VEvent.ve_Y, ax             ; Update input packet.
  925.  
  926.        .if <bit VDM_Flags nz VDMREGISTERED> ; if VDM interface enabled
  927.           push dword ptr VMSE_EVENT         ; event notify function
  928.           push ds                           ; selector of input packet
  929.           push offset VEvent                ; offset of input packet
  930.           push dword ptr 0                  ; output packet selector (N/A)
  931.           call MSEVDDEntry                  ; go notify the VDD
  932.  
  933.  
  934.        .endif
  935.  
  936.        ret
  937.  
  938. VDMEvent  EndP
  939.  
  940.  
  941. ;***********************************************************************
  942. ;*
  943. ;*  FUNCTION NAME :  IntrSetup
  944. ;*
  945. ;*  DESCRIPTION   :  This routine performs all setup required to
  946. ;*                   process a mouse event.  It sets the session
  947. ;*                   type, checks to see that the session is active,
  948. ;*                   then gets the system time.  It returns carry set
  949. ;*                   if it is not OK to proceed, clear if it is OK to
  950. ;*                   proceed.
  951. ;*
  952. ;*  INPUT         :  none.
  953. ;*
  954. ;*  OUTPUT        :   carry clear if OK to proceed, set otherwise.
  955. ;*
  956. ;***********************************************************************
  957. ;* PSEUDOCODE :
  958. ;*
  959. ;* BeginSub  IntrSetup
  960. ;*
  961. ;*  return
  962. ;*
  963. ;* EndSub  IntrSetup
  964. ;*
  965. ;************************************************************************
  966.  
  967. IntrSetup  proc  near
  968.  
  969. ;*
  970. ;*      First determine if the mouse is disabled.  If not then continue, if so
  971. ;*      set the carry flag and get out.
  972. ;*
  973.  
  974.        .if <Ptr_Overide eq OFF>
  975.           mov  es, word ptr GDT_Seg          ; Get GDT Bi-Modal Info Seg Selector
  976.           sub  bx, bx                        ; Clear Base GDT Offset
  977.  
  978. ;*
  979. ;*         Mouse event has the following format:
  980. ;*          for motion only, bit 0 is set
  981. ;*          for button x, bit 2x-1 is set if button x is down with motion
  982. ;*          for button x, bit 2x   is set if button x is down w/o motion
  983. ;*         put the event in the event buffer for use later.
  984. ;*
  985.  
  986.            mov  cx, Int_Packet.Event
  987.           mov  MEvent.Mon_EMask, cx          ; Save event
  988.  
  989. ;*
  990. ;*          Now go find the CB sel:offset for the interrupting session.  If
  991. ;*          it is found then check to see if the session is setup for mouse
  992. ;*          support.
  993. ;*
  994.  
  995.           push ds                         ; save mouse ds
  996.           lds  si, FgndCB                 ; get foreground session CB
  997.           pop  fs                         ; put mouse ds in fs
  998.  
  999.           mov  bl, fs:FgndSessn           ; Get Current Foreground SG ID
  1000.           test [si].D_Status, USS_Mode    ; see if the mode is supported
  1001.           .if <z>            AND          ; if it is and
  1002.           test [si].Ptr_Flags, SM_WinFlag ; if we not are in the middle of
  1003.           .if z              AND          ; setting the display mode and
  1004.           .if <[si].Hdle_Cntr gt 0>       ; and session has open mse support
  1005.              jmp  short SetTime           ; go set event time
  1006.           .endif
  1007.  
  1008. ;*
  1009. ;*         will fall through to here is session does not have support setup.
  1010. ;*         The carry flag will be set and this routine will be exited.  If
  1011. ;*         the session has support then the time will be set, carry flag
  1012. ;*         cleared and control returned to the caller.
  1013. ;*
  1014.            stc
  1015.            jmp  short exit
  1016.  
  1017. SetTime:
  1018.  
  1019. ;*
  1020. ;* emi      setting of the timestamp moved to emi.asm
  1021. ;*
  1022.  
  1023. ;*
  1024. ;*  emi      xor  bx, bx
  1025. ;*  emi      mov  ax, word ptr es:[bx].SIS_MsCount   ; Milli-Second Time
  1026. ;*  emi      mov  word ptr fs:MEvent.Mon_Time, ax    ; Low Word Value
  1027. ;*  emi      mov  ax, word ptr es:[bx].SIS_MsCount+2 ; Milli-Second Time
  1028. ;*  emi      mov  word ptr fs:MEvent.Mon_Time+2, ax  ; High Word Value
  1029. ;*
  1030.  
  1031.          clc                                         ; session has support
  1032.  
  1033.         .else
  1034.           stc
  1035.        .endif
  1036.  
  1037. exit:
  1038.        ret
  1039.  
  1040. IntrSetup  Endp
  1041.  
  1042. ;***********************************************************************
  1043. ;*
  1044. ;*  FUNCTION NAME :  Up_Activity
  1045. ;*
  1046. ;*  DESCRIPTION   :  Update all active SN entries.
  1047. ;*
  1048. ;*                   This function will update the activity status
  1049. ;*                   word field for all open IDC handle entries.
  1050. ;*
  1051. ;*                   This field is returned to the caller when the
  1052. ;*                   Query_Mouse function is issued.
  1053. ;*
  1054. ;*                   This function will only be called when OS/2
  1055. ;*                   Special needs support is enabled (SNF_ACTIVE
  1056. ;*                   bit is on in the SN_Flags byte).
  1057. ;*
  1058. ;*  ENTRY POINT   : Up_Activity           LINKAGE: CALL NEAR
  1059. ;*
  1060. ;*  ENTRY         : DS = MOUSE$ data selector
  1061. ;*
  1062. ;*  RETURN-NORMAL : Always.
  1063. ;*
  1064. ;*  RETURN-ERROR  : None
  1065. ;*
  1066. ;*  EFFECTS       : The IDC_Status field will be updated for all
  1067. ;*                  open IDC handle entries.
  1068. ;*
  1069. ;*                  NO REGISTERS MODIFIED.
  1070. ;*
  1071. ;*  INTERNAL REFERENCES:
  1072. ;*     ROUTINES   :  NONE.
  1073. ;*
  1074. ;*  EXTERNAL REFERENCES:
  1075. ;*     ROUTINES   :  NONE.
  1076. ;*     DevHelps   :  NONE.
  1077. ;*
  1078. ;***********************************************************************
  1079. ;* PSEUDOCODE :
  1080. ;*
  1081. ;* BeginSub  Up_Activity
  1082. ;*
  1083. ;*
  1084. ;*   Put this event mask in AX
  1085. ;*
  1086. ;*   Get pointer to CB for handle zero
  1087. ;*   REPEAT
  1088. ;*      IF <handle is active>
  1089. ;*         Update the activity status field for this handle with new mask in AX
  1090. ;*      ENDIF
  1091. ;*      Get pointer to CB for next handle
  1092. ;*   UNTIL <we have gone thru the CB for every handle>
  1093. ;*
  1094. ;*  return
  1095. ;*
  1096. ;* EndSub  Up_Activity
  1097. ;*
  1098. ;************************************************************************
  1099.  
  1100. Up_Activity  proc  near
  1101.  
  1102.    push ax                          ; AX will hold the current event
  1103.    push bx
  1104.    push si
  1105.  
  1106.    mov  ax, Int_Packet.Event        ; Get this event.
  1107.  
  1108.    lea  si, IDC_CB                  ; Offset to the block of handles.
  1109.    xor  bx, bx                      ; Start with handle zero.
  1110.  
  1111.    .repeat
  1112.  
  1113.       .if <bit [si].IDC_Flags nz IDC_ACTIVE> ; If handle is active.
  1114.          or [si].IDC_Status, ax          ; Or in this event.
  1115.       .endif
  1116.  
  1117.       inc  bx                            ; Next handle.
  1118.       add  si, size IDC_Entry            ; Next IDC entry for this handle.
  1119.  
  1120.    .until <bx eq MAXIDCS>                ; Zero based (6th entry is invalid)
  1121.  
  1122.    pop  si
  1123.    pop  bx
  1124.    pop  ax
  1125.  
  1126.    ret
  1127.  
  1128. Up_Activity  endp
  1129.  
  1130.  
  1131. ;**********************************************************************
  1132. ;*
  1133. ;*  FUNCTION NAME :  Strat_Entry
  1134. ;*
  1135. ;*  DESCRIPTION   :  Entry point for all strategy requests.
  1136. ;*
  1137. ;*                   This routine is just a stub that immediatly
  1138. ;*                   routes the call to Request_Handler. This stub
  1139. ;*                   is needed because the strategy entry point must
  1140. ;*                   be in the same segment as the interrupt entry
  1141. ;*                   point. Since all strategy time code can be in
  1142. ;*                   swappable memory this stub simply exists in the
  1143. ;*                   low fixed non-swappable memory and does a far
  1144. ;*                   call to the real strategy request handler which
  1145. ;*                   resides in a swappable code segent.
  1146. ;*
  1147. ;*  ENTRY POINT   :  Strat_Entry        (PROTECT MODE ONLY)
  1148. ;*                    LINKAGE:  CALL FAR
  1149. ;*
  1150. ;*  INPUT         :  ES:BX points to the request packet.
  1151. ;*
  1152. ;*  RETURN-NORMAL :  Request Block status field set to indicate
  1153. ;*                   function complete, no error.
  1154. ;*
  1155. ;*  RETURN-ERROR  :  Error codes set in Request Block status fiel
  1156. ;*
  1157. ;*  EFFECTS       :  Stack is clean on return, Registers not preserved.
  1158. ;*
  1159. ;*  INTERNAL REFERENCES:
  1160. ;*     ROUTINES   :  None.
  1161. ;*
  1162. ;*  EXTERNAL REFERENCES:
  1163. ;*     ROUTINES   : Request_Handler.
  1164. ;*     DevHlps    :  None.
  1165. ;*
  1166. ;**********************************************************************
  1167.  
  1168. Strat_Entry  Proc  Far
  1169.          call  Request_Handler
  1170.          ret
  1171. Strat_Entry  endp
  1172.  
  1173. CSEG     ENDS
  1174.          END
  1175.