home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / WDHSUBS.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  31KB  |  793 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.         PAGE    58,132
  13.         TITLE   WDHSUBS.ASM -- Windowable and Advanced VIO Subroutines
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = WDHSUBS.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = Windowable and Advanced VIO Subroutines
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE
  25. ;*
  26. ;* DESCRIPTION  Interface routines to the Shield and Graphics
  27. ;*              Engine.
  28. ;*
  29. ;* FUNCTIONS    CheckAvio
  30. ;*              SecureSema4
  31. ;*              ReleaseSema4
  32. ;*              ClearGreDat
  33. ;*              UpdateCharRect
  34. ;*              EngineCharRect
  35. ;*              CharStr
  36. ;*              WinScroll
  37. ;*              ShieldInit
  38. ;*              ShieldTerm
  39. ;*              QueryConsole
  40. ;*
  41. ;* NOTES        NONE
  42. ;*
  43. ;* STRUCTURES   NONE
  44. ;*
  45. ;* EXTERNAL REFERENCES  NONE
  46. ;*
  47. ;* EXTERNAL FUNCTIONS
  48. ;*
  49. ;*              NONE
  50. ;*
  51. ;* CHANGE ACTIVIY =
  52. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  53. ;*   --------  ---------- -----   --------------------------------------
  54. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  55. ;*             @T14       P3711   TPL, Preserve AX in ReleaseSema4,
  56. ;*             @@TB8      HM00451 TLB, Leave filler cell selector and offset
  57. ;*             @@TB8      HM00451 set null.  PTR
  58. ;*             @B18       B705274 WKB, Pass graphics engine correct scroll parm
  59. ;*                                (DSS).
  60. ;*   11/02/89  @D549      D549    CJJ, Seltable changes due to rangeless
  61. ;*                                sessions,
  62. ;*   01/22/90  @T52       D704    TPL  DCR 704 work
  63. ;*   07/06/90  @T71       B714347 TPL, Allow Shell to make AVIO calls, Hursley
  64. ;*                                DCR 25177,
  65. ;*   SL02298T                     TPL, Pass full 32-bit values to PMGRE scroll routine
  66. ;*   04/11/91  D1348      D1348   NAKADA, Enable DBCS support in Vio-Window
  67. ;*             SM04393            WKB, Correct parm passing to PMGRE scroll routine
  68. ;*   02/06/92  @T80       B732479 TPL, Don't use the reserved register FS
  69. ;*   05/11/93  @TK1       A64278  TAK, Console creation serialization
  70. ;*   09/14/94  @95837             WKB, pmwinp.inc -> pmwinx.inc
  71. ;****************************************************************************/
  72.  
  73.         .xlist
  74.         include pmwinx.inc              ;@95837
  75.         include pmaviop.inc
  76.         include wdhequ.inc
  77.         include wdhgdata.inc            ;BVH global data externals      ;@T52
  78.         include bvscb.inc
  79.         include bvsparms.inc
  80.         include error2.inc
  81.         include struc.inc
  82.         include infoseg.inc
  83.         .list
  84.  
  85.         .386p                   ;@D549
  86.  
  87.         EXTRN   DOSALLOCSEG:FAR
  88.         EXTRN   DOSFREESEG:FAR
  89.         EXTRN   DOSSEMSETWAIT:FAR                                       ;@TK1
  90.         EXTRN   DOSSEMCLEAR:FAR                                         ;@TK1
  91.  
  92.         EXTRN   bvh_instance:DWORD                                      ;@T52
  93.         EXTRN   WININITIALIZE:FAR                                       ;@T52
  94.         EXTRN   WINCREATECONSOLE:FAR                                    ;@T52
  95.         EXTRN   WINDESTROYCONSOLE:FAR                                   ;@T52
  96.         EXTRN   LOCKVIOPS:FAR                                           ;@T52
  97.         EXTRN   UNLOCKVIOPS:FAR                                         ;@T52
  98.         EXTRN   GREENTRY5:FAR                                           ;@T52
  99.  
  100.         extrn   RegSav2:NEAR
  101.         extrn   RegRest:NEAR
  102.  
  103. WDHGSEG SEGMENT PARA PUBLIC 'DATA' USE16 ;Global data segment for WDH    @D549
  104. WDHGSEG ENDS
  105.  
  106. R2CSEG  SEGMENT PARA PUBLIC 'CODE' USE16                                ;@D549
  107.         ASSUME  CS:R2CSEG
  108.  
  109. ;/****************************************************************************
  110. ;*
  111. ;* FUNCTION NAME = CheckAvio
  112. ;*
  113. ;* DESCRIPTION   = Set NZ flag if an Avio session
  114. ;*
  115. ;* INPUT         = NONE
  116. ;* OUTPUT        = NONE
  117. ;*
  118. ;* RETURN-NORMAL = NONE
  119. ;* RETURN-ERROR  = NONE
  120. ;*
  121. ;****************************************************************************/
  122.  
  123. CheckAvio PROC  NEAR
  124.         public  CheckAvio
  125.  
  126.         push    ds
  127.         push    ax
  128.  
  129.         push    WDHGSEG
  130.         pop     ds
  131.         mov     ds,ds:wdh_LISsel                                        ;@T52
  132.  
  133.         sub     ax,ax                   ;Preset non-AVIO session        ;@T71
  134.         .if     <[bx].LIS_ProcType eq LIS_PT_PRESMGR> or          ;@D549,@T71
  135.         .if     <[bx].LIS_CurScrnGrp eq 1>                              ;@T71
  136.             inc     ax                  ;Set AVIO session               ;@T71
  137.         .endif
  138.         or      ax,ax                   ;Update the Zero flag           ;@T71
  139.  
  140. ;@T71   pop     cx
  141.         pop     ax
  142.         pop     ds
  143.         ret
  144. CheckAvio ENDP
  145.  
  146. ;/****************************************************************************
  147. ;*
  148. ;* FUNCTION NAME = SecureSema4
  149. ;*
  150. ;* DESCRIPTION   = Secure the PS Semaphore
  151. ;*                 No registers modified.  Calls LockVioPS in SHIELD.DLL
  152. ;*
  153. ;* INPUT         = NONE
  154. ;* OUTPUT        = NONE
  155. ;*
  156. ;* RETURN-NORMAL = NONE
  157. ;* RETURN-ERROR  = NONE
  158. ;*
  159. ;****************************************************************************/
  160.  
  161. SecureSema4 PROC NEAR
  162.         public  SecureSema4
  163.         Call    RegSav2
  164.  
  165.         push    WDHGSEG
  166.         pop     ds                      ;DS = Global data segment
  167.         mov     gs,ds:wdh_LISsel        ;DS = Local Info segment        ;@T80
  168.         mov     di,gs:[LIS_CurThrdID]   ;Get thread ID to get index and ;@T80
  169.         dec     di                      ;Thread 1 should use bit 0
  170.  
  171.         mov     cx,di                   ;bit mask
  172.         shr     di,3                    ;Divide by 8 to get index
  173.         and     cx,7                    ;Remainder
  174.         mov     al,1                    ;Remainder to create bit mask
  175.         shl     al,cl
  176.  
  177.         lgs     bx,ds:bvh_instance      ;load instance data             ;@T80
  178.         push    gs:[bx].wdhi_pssel                                      ;@T80
  179.         push    viops_PresentationSpaceLock ;Semaphore addr for Shield Lock
  180.  
  181.         mov     gs:[bx].wdhi_sema4,1    ;Set semaphore flag             ;@T80
  182.         test    gs:[bx][di].wdhi_wininits,al                            ;@T80
  183.         .if     <z>                     ;Wininitialize not yet called
  184.  
  185.             or      gs:[bx][di].wdhi_wininits,al ;Indicate thread called;@T80
  186.             push    di                  ;Prepare thread to use WINXXXX
  187.             call    WININITIALIZE                                       ;@T52
  188.  
  189.         .endif
  190.  
  191.         call    LOCKVIOPS               ;Secure semaphore               ;@T52
  192.                                         ;  with parms pushed above      ;@T52
  193.         Call    RegRest
  194.         ret
  195. SecureSema4 ENDP
  196.  
  197. ;/****************************************************************************
  198. ;*
  199. ;* FUNCTION NAME = ReleaseSema4
  200. ;*
  201. ;* DESCRIPTION   = Release the PS Semaphore
  202. ;*                 No registers modified.  Calls UnLockVioPS in SHIELD.DLL
  203. ;*
  204. ;* INPUT         = NONE
  205. ;* OUTPUT        = NONE
  206. ;*
  207. ;* RETURN-NORMAL = NONE
  208. ;* RETURN-ERROR  = NONE
  209. ;*
  210. ;****************************************************************************/
  211.  
  212. ReleaseSema4 PROC NEAR
  213.         public  ReleaseSema4
  214.         push    ax                      ;                               @T14
  215.         Call    RegSav2
  216.  
  217.         push    WDHGSEG                                                 ;@T52
  218.         pop     ds
  219.         lgs     si,ds:bvh_instance      ;load instance data             ;@T80
  220.         mov     gs:[si].wdhi_sema4,bx   ;clear semaphore flag (set to 0);@T80
  221.         push    gs:[si].wdhi_pssel      ;PS selector                    ;@T80
  222.         push    viops_PresentationSpaceLock ;Addr of Semaphore
  223.  
  224.         call    UNLOCKVIOPS             ;Release semaphore              ;@T52
  225.  
  226.         Call    RegRest
  227.         pop     ax                      ;                               @T14
  228.         ret
  229. ReleaseSema4 ENDP
  230.  
  231. ;/****************************************************************************
  232. ;*
  233. ;* FUNCTION NAME = ClearGreDat
  234. ;*
  235. ;* DESCRIPTION   = Clears the Engine parm block
  236. ;*                 No registers modified, except AX=0.
  237. ;*
  238. ;* INPUT         = NONE
  239. ;* OUTPUT        = NONE
  240. ;*
  241. ;* RETURN-NORMAL = NONE
  242. ;* RETURN-ERROR  = NONE
  243. ;*
  244. ;****************************************************************************/
  245.  
  246. ClearGreDat PROC NEAR
  247.         public  ClearGreDat
  248.  
  249.         push    di                      ;initialize...
  250.         push    cx                      ;...the....
  251.         push    es
  252.  
  253.         push    WDHGSEG                                                 ;@T52
  254.         pop     es
  255.         les     di,es:bvh_instance                                      ;@T52
  256.         mov     cx,(size GreStruc)/4    ;...engine...                   ;@T71
  257.         add     di,wdhi_GreDat          ;...parameter...                ;@T52
  258.         sub     eax,eax                                                 ;@T71
  259.         rep     stosd                   ;...block                       ;@T71
  260.  
  261.         pop     es
  262.         pop     cx
  263.         pop     di
  264.  
  265.         ret
  266. ClearGreDat ENDP
  267.  
  268. ;/****************************************************************************
  269. ;*
  270. ;* FUNCTION NAME = UpdateCharRect
  271. ;*
  272. ;* DESCRIPTION   = Allows Engine to synch the PS changes with BufferUpdate
  273. ;*                 No registers modified, except AX = return code.
  274. ;*                 Calls ClearGreDat and EngineCharRect
  275. ;*
  276. ;* INPUT         = NONE
  277. ;* OUTPUT        = NONE
  278. ;*
  279. ;* RETURN-NORMAL = NONE
  280. ;* RETURN-ERROR  = NONE
  281. ;*
  282. ;****************************************************************************/
  283.  
  284. UpdateCharRect PROC NEAR
  285.         public  UpdateCharRect
  286.         push    ds
  287.  
  288.         Call    ClearGreDat             ;set null parameter block
  289.  
  290.         push    WDHGSEG                                                 ;@T52
  291.         pop     ds
  292.         lgs     si,ds:bvh_instance                                      ;@T80
  293.         mov     ax,es:[viops_BufferRowCount]                            ;@T52
  294.         mov     gs:[si].wdhi_rect_height,ax                             ;@T80
  295.         mov     ax,es:[viops_BufferColumnCount]                         ;@T52
  296.         mov     gs:[si].wdhi_length_width,ax                            ;@T80
  297.  
  298.         Call    EngineCharRect          ;advise Engine of PS change
  299.  
  300.         pop     ds
  301.         ret
  302. UpdateCharRect ENDP
  303.  
  304. ;/****************************************************************************
  305. ;*
  306. ;* FUNCTION NAME = EngineCharRect
  307. ;*
  308. ;* DESCRIPTION   = Allows Engine to output a text rectangle from the LVB
  309. ;*                 Parameters already in GreDat.  Calls GreEntry5
  310. ;*                 No registers modified, except AX = return code.
  311. ;*
  312. ;* INPUT         = NONE
  313. ;* OUTPUT        = NONE
  314. ;*
  315. ;* RETURN-NORMAL = NONE
  316. ;* RETURN-ERROR  = NONE
  317. ;*
  318. ;****************************************************************************/
  319.  
  320. EngineCharRect PROC NEAR
  321.         public  EngineCharRect
  322.         Call    RegSav2
  323.         sub     bx,bx                                                   ;@T52
  324.         push    WDHGSEG                                                 ;@T52
  325.         pop     ds                                                      ;@T52
  326.         lgs     si,ds:bvh_instance      ;load instance data             ;@T80
  327. ;@T71   push    es:[bx].word ptr viops_hConsoleDisplayContext+2 ;DC handle pt. 1
  328.         push    dword ptr es:[bx].viops_hConsoleDisplayContext ;DC handle pt. 2 ;@T71
  329.         push    es                      ;PS selector
  330.         push    bx                      ;PS offset
  331.         push    gs                      ;param block selector           ;@T80
  332.         lea     ax,gs:[si].wdhi_GreDat                                  ;@T80
  333.         push    ax                      ;param block offset             ;@T52
  334. ;@T71   push    bx                      ;"cookie" parm pt. 1
  335.         push    dword ptr 0             ;"cookie" parm pt. 2            ;@T71
  336. ;@T71   push    GreCharRectHi           ;Engine function pt. 1
  337.         push    dword ptr GreCharRectLo ;Engine function pt. 2          ;@T71
  338.  
  339.         call    GREENTRY5                                               ;@T52
  340.         Call    RegRest
  341.         ret
  342. EngineCharRect ENDP
  343.  
  344. ;/****************************************************************************
  345. ;*
  346. ;* FUNCTION NAME = CharStr
  347. ;*
  348. ;* DESCRIPTION   = Allows Engine to output a text string from the LVB
  349. ;*                 Parameters on stack from BVS at DS:SI.
  350. ;*                 Calls ClearGreDat and GreEntry5.
  351. ;*                 No registers modified, except AX = return code.
  352. ;*
  353. ;* INPUT         = NONE
  354. ;* OUTPUT        = NONE
  355. ;*
  356. ;* RETURN-NORMAL = NONE
  357. ;* RETURN-ERROR  = NONE
  358. ;*
  359. ;****************************************************************************/
  360.  
  361. CharStr PROC    NEAR
  362.         public  CharStr
  363.         Call    RegSav2
  364.  
  365.         call    ClearGreDat
  366.         push    es                      ;Save PS selector
  367. IFDEF D1348
  368.         push    di
  369. ENDIF ;D1348
  370.  
  371.         sub     bx,bx                                                   ;@T52
  372.         mov     ax,es:[bx].viops_BufferRowCount ;get current row count
  373.         sub     ax,[si].vp_startrow     ;convert to x,y row coordinate
  374.         dec     ax                      ;normalize for 0 base
  375.  
  376. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  377.         mov     dx,es:[bx].env_dbcsstatus
  378. ENDIF ;D1348
  379.  
  380.         push    WDHGSEG                                                 ;@T52
  381.         pop     es
  382.         lgs     di,es:bvh_instance                                      ;@T80
  383.         mov     gs:[di].wdhi_start_row,ax                               ;@T80
  384.  
  385.         mov     ax,[si].vp_startcol
  386. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  387.         .if     <bit dx and BisectDBCS_START>
  388.             inc     [si].vp_repeatlength
  389.             dec     ax
  390.             .if     <s>
  391.                 inc     ax
  392.                 dec     [si].vp_repeatlength
  393.             .endif
  394.             mov     cx,[si].vp_repeatlength
  395.             inc     cx
  396.             pop     di
  397.             pop     es
  398.             .if     <cx a es:[di].mode_cols>
  399.                 dec     cx
  400.             .endif
  401.             push    es
  402.             push    di
  403.             mov     [si].vp_repeatlength,cx
  404.             push    WDHGSEG                                             ;@T52
  405.             pop     es                  ;restore es
  406.             lgs     di,es:bvh_instance  ;restore gs,di                  ;@T80
  407.         .endif
  408. ENDIF ;D1348
  409.         mov     gs:[di].wdhi_start_col,ax ;column                       ;@T80
  410.  
  411.         mov     ax,[si].vp_repeatlength
  412. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  413.         .if     <bit dx and BisectDBCS_LAST>
  414.             inc     ax
  415.             mov     dx,gs:[di].wdhi_start_col                           ;@T80
  416.             add     dx,ax
  417.             mov     cx,gs:[di].wdhi_start_row                           ;@T80
  418.             pop     di
  419.             pop     es
  420.             .if     <dx a es:[di].mode_cols> and
  421.             .if     <cx ae es:[di].mode_rows>
  422.                 dec     ax
  423.             .endif
  424.             push    es
  425.             push    di
  426.             push    WDHGSEG                                             ;@T52
  427.             pop     es                  ;restore es
  428.             lgs     di,es:bvh_instance  ;restore gs,di                  ;@T80
  429.         .endif
  430. ENDIF ;D1348
  431.         mov     gs:[di].wdhi_length_width,ax ;length                    ;@T80
  432.  
  433. IFDEF D1348
  434.         pop     ax                      ;dummy(get garbage)
  435. ENDIF ;D1348
  436.         pop     ds                      ;Restore PS selector
  437.         push    dword ptr [bx].viops_hConsoleDisplayContext ;DC handle pt. 2 ;@T71
  438.  
  439.         push    ds                      ;PS selector
  440.         push    bx                      ;PS offset
  441.         push    gs                      ;param block selector           ;@T80
  442.         lea     ax,gs:[di].wdhi_GreDat                                  ;@T80
  443.         push    ax                      ;param block offset             ;@T52
  444.         push    dword ptr 0             ;"cookie" parm pt. 2            ;@T71
  445.         push    dword ptr GreCharStrLo  ;Engine function pt. 2          ;@T71
  446.         call    GREENTRY5                                               ;@T52
  447.  
  448.         Call    RegRest
  449.         ret
  450. CharStr ENDP
  451.  
  452. ;/****************************************************************************
  453. ;*
  454. ;* FUNCTION NAME = WinScroll
  455. ;*
  456. ;* DESCRIPTION   = Handles calls to Scroll the LVB Up, Down, Left, or Right
  457. ;*                 Parameters on stack from BVS at DS:SI.
  458. ;*                 Calls ClearGreDat and GreEntry5.
  459. ;*                 No registers modified, except AX = return code.
  460. ;*
  461. ;* INPUT         = NONE
  462. ;* OUTPUT        = NONE
  463. ;*
  464. ;* RETURN-NORMAL = NONE
  465. ;* RETURN-ERROR  = NONE
  466. ;*
  467. ;****************************************************************************/
  468.  
  469. WinScroll PROC  NEAR
  470.         public  WinScroll
  471.         Call    RegSav2
  472.  
  473.         Call    ClearGreDat
  474.         push    es                      ;Save PS selector
  475.  
  476.         mov     ax,[si].vp_secondrow
  477.         .if     <ax ae es:[di].mode_rows>
  478.             mov     ax,es:[di].mode_rows
  479.             dec     ax
  480.         .endif
  481.         sub     ax,[si].vp_startrow
  482.         inc     ax                      ;Height
  483.  
  484.         mov     cx,[si].vp_secondcol
  485.         .if     <cx ae es:[di].mode_cols>
  486.             mov     cx,es:[di].mode_cols
  487.             dec     cx
  488.         .endif
  489.         sub     cx,[si].vp_startcol
  490.         inc     cx                      ;Width
  491.  
  492.         push    WDHGSEG                                                 ;@T52
  493.         pop     es
  494.         les     bx,es:bvh_instance                                      ;@T52
  495.         mov     es:[bx].wdhi_rect_height,ax
  496.         mov     es:[bx].wdhi_length_width,cx
  497.  
  498.         mov     ax,[si].vp_repeatlength ;Get # of lines to scroll
  499.         mov     cx,[si].vp_index        ;Get direction
  500.  
  501.         .if     <ax eq -1>              ;Wild card repeat count?        ;B18
  502.             pop     dx                  ;orig ds in di                  ;B18
  503.             push    ds                  ;save curr ds                   ;B18
  504.             mov     ds,dx               ;orig ds restored               ;B18
  505.             .if     <cl eq sx_ScrollUp> or                              ;SL02298
  506.             .if     <cl eq sx_ScrollDn>                                 ;SL02298
  507.                 mov     ax,ds:[viops_BufferRowCount] ;make start...     ;B18
  508.             .else                                                       ;SL02298
  509.                 mov     ax,ds:[viops_BufferColumnCount]                 ;SL02298
  510.             .endif                                                      ;SL02298
  511.             pop     ds                  ;restore local ds               ;B18
  512.             push    dx                  ;save orig ds                   ;B18
  513.         .endif
  514.  
  515.         sub     dx,dx                   ;set default hi-order word      ;SL02298
  516.         .if     <cl eq sx_ScrollUp> or  ;                               ;SL02298
  517.         .if     <cl eq sx_ScrollLf>     ;                               ;SL02298
  518.             neg     ax                  ;go negative direction on       ;SL02298
  519.             mov     dx,-1               ; scroll-up or scroll-left      ;SL02298
  520.         .endif                          ;                               ;SL02298
  521.  
  522. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  523.         push    di
  524. ENDIF ;D1348
  525.  
  526.         .if     <cl eq sx_ScrollUp> or  ;                               ;SL02298
  527.         .if     <cl eq sx_ScrollDn>     ;                               ;SL02298
  528.          ;;;mov     di,wdhi_vert_count  ;                               ;SL02298
  529.             lea     di,es:[bx].wdhi_vert_count                          ;SM04393
  530.         .else                           ;                               ;SL02298
  531.          ;;;mov     di,wdhi_horiz_count ;                               ;SL02298
  532.             lea     di,es:[bx].wdhi_horiz_count                         ;SM04393
  533.         .endif                          ;                               ;SL02298
  534.  
  535.         mov     word ptr es:[di],ax     ;                               ;SL02298
  536.         mov     word ptr es:[di+2],dx   ;                               ;SL02298
  537.  
  538.         mov     ax,[si].vp_startcol
  539.         mov     es:[bx].wdhi_start_col,ax ;start col
  540.  
  541.         mov     cx,[si].vp_startrow     ;raw start row
  542.  
  543. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  544.         pop     di
  545. ENDIF ;D1348
  546.  
  547.         pop     ds                      ;Restore PS selector
  548.         mov     ax,ds:[viops_BufferRowCount] ;make start...             ;@T52
  549.         sub     ax,es:[bx].wdhi_rect_height  ;...row relative...
  550.         sub     ax,cx                   ;...to bottom...
  551.         mov     es:[bx].wdhi_start_row,ax ;...left of LVB
  552.  
  553. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  554.         push    ds
  555.         push    es
  556.         push    bx
  557. ENDIF ;D1348
  558.  
  559.         push    dword ptr ds:[viops_hConsoleDisplayContext] ;DC handle pt. 2 ;@T52;;;;;;
  560.         push    ds                      ;PS selector
  561.         push    0                       ;PS offset                      ;@T52
  562.         push    es                      ;param block selector
  563.         lea     ax,es:[bx].wdhi_GreDat                                  ;@T52
  564.         push    ax                      ;param block offset
  565.         push    dword ptr 0             ;"cookie" parm pt. 2       ;@T52,@T71
  566.         push    dword ptr GreScrollRectLo ;Engine function pt. 2        ;@T71
  567.  
  568.         call    GREENTRY5                                               ;@T52
  569.  
  570. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  571.         pop     bx
  572.         pop     es
  573.         pop     ds
  574.  
  575.         mov     dx,es:[bx].wdhi_start_col
  576.         add     dx,es:[bx].wdhi_length_width
  577.         dec     dx
  578.         push    dx                      ;end_col
  579.  
  580.         .if     <bit ds:[env_dbcsstatus] and BisectDBCS_LEFT>
  581.             mov     dx,es:[bx].wdhi_start_col
  582.             dec     dx
  583.             .if     ge
  584.                 dec     es:[bx].wdhi_start_col
  585.                 mov     es:[bx].wdhi_length_width,3 ;Set 3 columns
  586.             .else
  587.                 mov     es:[bx].wdhi_length_width,2 ;Set 2 columns
  588.             .endif
  589.  
  590.             push    ds
  591.             push    es
  592.             push    bx
  593.             push    di
  594.                                             ;DBCS exception maintenance
  595.                                             ;for a left side of the rectangle
  596.             push    dword ptr ds:[viops_hConsoleDisplayContext] ;DC handle pt. 2
  597.             push    ds                      ;PS selector
  598.             push    0                       ;PS offset
  599.             push    es                      ;param block selector
  600.             lea     ax,es:[bx].wdhi_GreDat
  601.             push    ax                      ;param block offset
  602.             push    dword ptr 0             ;"cookie" parm pt. 2
  603.             push    dword ptr GreCharRectLo ;Engine function pt. 2
  604.  
  605.             call    GREENTRY5                                               ;@T52
  606.  
  607.             pop     di
  608.             pop     bx
  609.             pop     es
  610.             pop     ds
  611.         .endif
  612.  
  613.         pop     dx                      ;end_col
  614.  
  615.         .if     <bit <ds:[env_dbcsstatus]> and BisectDBCS_RIGHT>
  616.             inc     dx
  617.             .if     <dx a ds:[di].mode_cols>
  618.                 dec     dx
  619.                 mov     es:[bx].wdhi_length_width,2
  620.             .else
  621.                 mov     es:[bx].wdhi_length_width,3
  622.             .endif
  623.             dec     dx
  624.             dec     dx
  625.             mov     es:[bx].wdhi_start_col,dx
  626.  
  627.             push    ds
  628.             push    bx
  629.  
  630.             push    dword ptr ds:[viops_hConsoleDisplayContext] ;DC handle pt. 2
  631.             push    ds                      ;PS selector
  632.             push    0                       ;PS offset
  633.             push    es                      ;param block selector
  634.             lea     ax,es:[bx].wdhi_GreDat
  635.             push    ax                      ;param block offset
  636.             push    dword ptr 0             ;"cookie" parm pt. 2
  637.             push    dword ptr GreCharRectLo ;Engine function pt. 2
  638.  
  639.             call    GREENTRY5                                               ;@T52
  640.  
  641.             pop     bx
  642.             pop     ds
  643.         .endif
  644. ENDIF ;D1348
  645.  
  646.         Call    RegRest
  647.         ret
  648. WinScroll ENDP
  649.  
  650. ;/****************************************************************************
  651. ;*
  652. ;* FUNCTION NAME = ShieldInit
  653. ;*
  654. ;* DESCRIPTION   = Creates a console handle through the Shield.
  655. ;*                 Session Id is in SI.  Calls WinCreateConsole.
  656. ;*                 No registers modified, except AX = return code.
  657. ;*
  658. ;* INPUT         = NONE
  659. ;* OUTPUT        = NONE
  660. ;*
  661. ;* RETURN-NORMAL = NONE
  662. ;* RETURN-ERROR  = NONE
  663. ;*
  664. ;****************************************************************************/
  665.  
  666. ShieldInit PROC NEAR
  667.         public  ShieldInit
  668.         Call    RegSav2
  669.  
  670.         push    WDHGSEG
  671.         pop     ds
  672.  
  673.         push    es                      ;16-bit C functions like
  674.                                         ;WinCreateConsole only save SI/DI/DS!
  675.  
  676.         push    si                      ;setup SGID parameter
  677.         push    es
  678.         push    bx                      ;Addr of PSCB
  679.         push    ds
  680.         push    offset wdh_keybufsize   ;Addr of KbdMouParameter segment;@T52
  681.         push    es
  682.         push    env_conhandle           ;Addr of returned Console Handle
  683.  
  684.         call    WINCREATECONSOLE                                        ;@T52
  685.         pop     es                      ;restore ES
  686.  
  687.         .if     <zero ax>
  688.             inc     es:env_processes    ;Update count of processes
  689.         .endif
  690.  
  691.         ;-------------------------------------------------------------- ;@TK1
  692.         ; Use a semaphore to locally serialize console creation and     ;@TK1
  693.         ; avoid a premature result from query console.                  ;@TK1
  694.         ;-------------------------------------------------------------- ;@TK1
  695.  
  696.         mov     es:env_consinit, 1                                      ;@TK1
  697.  
  698.         push    es                                                      ;@TK1
  699.         push    env_consolesem                                          ;@TK1
  700.         Call    DOSSEMCLEAR                                             ;@TK1
  701.  
  702.         Call    RegRest
  703.         ret
  704. ShieldInit ENDP
  705.  
  706. ;/****************************************************************************
  707. ;*
  708. ;* FUNCTION NAME = ShieldTerm
  709. ;*
  710. ;* DESCRIPTION   = Releases a console handle through the Shield.
  711. ;*                 Session Id is passed as the offset.  Calls WinDestroyConsole.
  712. ;*                 No registers modified, except AX = return code.
  713. ;*
  714. ;* INPUT         = NONE
  715. ;* OUTPUT        = NONE
  716. ;*
  717. ;* RETURN-NORMAL = NONE
  718. ;* RETURN-ERROR  = NONE
  719. ;*
  720. ;****************************************************************************/
  721.  
  722. ShieldTerm PROC NEAR
  723.         public  ShieldTerm
  724.  
  725.         push    [si].vp_ev_session      ;setup SGID parameter
  726.  
  727. ;@T52   push    WDHGSEG
  728. ;@T52   pop     ds
  729.         call    WINDESTROYCONSOLE       ;release console instance       ;@T52
  730.  
  731.         ret
  732. ShieldTerm ENDP
  733.  
  734. ;/****************************************************************************
  735. ;*
  736. ;* FUNCTION NAME = QueryConsole
  737. ;*
  738. ;* DESCRIPTION   = Returns console information to BKSCALLS or BMSCALLS
  739. ;*                 Output is Console Handle, Mouse filter mask, and VioPS
  740. ;*                 selector. No routines called.  AX = 0 on return.
  741. ;*
  742. ;* INPUT         = NONE
  743. ;* OUTPUT        = NONE
  744. ;*
  745. ;* RETURN-NORMAL = NONE
  746. ;* RETURN-ERROR  = NONE
  747. ;*
  748. ;****************************************************************************/
  749.  
  750. QueryConsole PROC NEAR
  751.         public  QueryConsole
  752.  
  753.         ;-------------------------------------------------------------- ;@TK1
  754.         ; Make sure we wait until a console has been created before     ;@TK1
  755.         ; returning data about it.                                      ;@TK1
  756.         ;-------------------------------------------------------------- ;@TK1
  757.  
  758.         .if     <es:env_consinit eq 0>                                  ;@TK1
  759.             push    es                                                  ;@TK1
  760.             push    env_consolesem                                      ;@TK1
  761.             push    dword ptr -1                                        ;@TK1
  762.  
  763.             Call    DOSSEMSETWAIT                                       ;@TK1
  764.         .endif                                                          ;@TK1
  765.  
  766.  
  767.         mov     ax,es:[env_conhandle]   ;Shield Console Handle          ;@T52
  768.         mov     dx,es                   ;VioPS Selector
  769.         les     di,dword ptr [si].p_viohandle ;Return address
  770.  
  771.         Call    CheckAvio
  772.         .if     <nz>
  773.             sub     eax,eax             ;return NULL to caller          ;@T71
  774. ;@T71       stosw                       ;Console Handle
  775.             stosd                       ;Mouse Filter Mask              ;@T71
  776.             stosw                       ;VioPS Selector
  777.         .else
  778.             stosw                       ;Console Handle
  779.             push    WDHGSEG
  780.             pop     ds
  781.             mov     ax,ds:wdh_mouevntmask                               ;@T52
  782.             stosw                       ;Mouse Filter Mask
  783.             mov     ax,dx
  784.             stosw                       ;VioPS Selector
  785.             sub     ax,ax
  786.         .endif
  787.  
  788.         ret
  789. QueryConsole ENDP
  790.  
  791. R2CSEG  ENDS
  792.         END
  793.