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