home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / WDHMODE.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  35KB  |  728 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   WDHMODE.Asm -- Windowable Device Handler Mode Routines
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = WDHMODE.Asm
  18. ;*
  19. ;* DESCRIPTIVE NAME = Windowable Device Handler Mode Routines
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE
  25. ;*
  26. ;* DESCRIPTION  BVS Device Handler for Windowable Sessions
  27. ;*              This module contains the equivalent of the OS/2 1.1
  28. ;*              hooks for Windowable and Advanced VIO.
  29. ;*
  30. ;* FUNCTIONS    GetMode, SetMode, ClearLVB
  31. ;*
  32. ;* NOTES        NONE
  33. ;*
  34. ;* STRUCTURES   NONE
  35. ;*
  36. ;* EXTERNAL REFERENCES  NONE
  37. ;*
  38. ;* EXTERNAL FUNCTIONS
  39. ;*
  40. ;*              NONE
  41. ;*
  42. ;* CHANGE ACTIVIY =
  43. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  44. ;*   --------  ---------- -----   --------------------------------------
  45. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  46. ;*   12/02/88  @T1        P2944   TPL, Grow LVB as neccessary,
  47. ;*   02/16/89  @T16       HZ00014 TPL, Disallowed Get/Set mode in AVIO session,
  48. ;*   03/06/89  @@S1       B700065 STJ, Refresh the cursor after SetMode,
  49. ;*   03/06/89  @@S2       B700413 STJ, Disallow Color Burst with Mono Modes,
  50. ;*   03/15/89  @C11       B700599 CJJ, Allow size of 4 and 5 for SetMode,
  51. ;*   03/25/89  @P1        D132    TPL, DCR 132 changes
  52. ;*   04/04/89  @C14       B700906 CJJ, Zero out AX after being used as temp
  53. ;*                                storage
  54. ;*   05/18/89  @C22       HZ00183 CJJ, Update scrollable region in UpdateMode,
  55. ;*   08/09/89  @B22       B706089 WKB, Check number of rows for validity,
  56. ;*   08/18/89  @S25       B706860 STJ, Use 1.0 length as default for GetXXXX
  57. ;*                                calls,
  58. ;*   11/02/89  @D549      D549    CJJ, Seltable changes due to rangeless
  59. ;*                                sessions
  60. ;*   01/22/90  @T52       D704    TPL, DCR 704 work
  61. ;*   07/06/90  @T71       B714347 TPL, Allow Shell to make AVIO calls, Hursley
  62. ;*                                DCR 25177,
  63. ;*   04/11/91             D1348   NAKADA, Enable DBCS support in Vio-Window,
  64. ;*   02/06/92  @T80               TPL, Don't use the reserved register FS
  65. ;*****************************************************************************/
  66.  
  67.         .xlist
  68.         include pmwinx.inc
  69.         include pmaviop.inc
  70.         include wdhequ.inc              ;Windowable Device Handler Equates
  71.         include wdhgdata.inc            ;BVH global data externals      ;@T52
  72.         include bvscb.inc               ;BVS Control Blocks
  73.         include bvsparms.inc            ;BVS Parameter Equates
  74.         include error2.inc              ;OS/2 Subsystem Error Codes
  75.         include infoseg.inc             ;System Information Segments
  76.         include struc.inc               ;Structured Macros
  77.         include error.inc               ;OS/2 Kernel Error Codes
  78.         .list
  79.  
  80.         .386p                   ;@D549
  81.  
  82.         extrn   DOSREALLOCSEG:FAR       ;Realloc AVIO LVB               ;@T1
  83.         extrn   DOSREALLOCHUGE:FAR      ;Realloc VIO windowable         ;@T1
  84.  
  85. IFDEF MSKK ; 1990-06-21 : prepare the 2nd LVB for DBCS flag             ;;MSKK  ;; added for J-FUNC
  86.         extrn   DOSGETSEG:FAR           ;Get DBCS flag LVB selector     ;;MSKK  ;; added for J-FUNC
  87. ENDIF ; MSKK                                                            ;;MSKK  ;; added for J-FUNC
  88.         extrn   SecureSema4:NEAR
  89.         extrn   ReleaseSema4:NEAR
  90.  
  91.         extrn   RegSave:NEAR
  92.         extrn   RegRest:NEAR
  93.         extrn   UpdateMode:NEAR
  94.         extrn   CheckAvio:NEAR          ;@T16
  95.  
  96.         extrn   bvh_instance:DWORD                                      ;@T52
  97.         extrn   GREENTRY4:FAR                                           ;@T52
  98.         extrn   GREENTRY6:FAR                                           ;@T52
  99.         extrn   WINSYNCWITHPS:FAR                                       ;@T52
  100.  
  101. WDHGSEG SEGMENT PARA PUBLIC 'DATA' USE16        ;@D549
  102. WDHGSEG ENDS
  103.  
  104. R2CSEG  SEGMENT BYTE PUBLIC 'CODE' USE16        ;@D549
  105.         ASSUME  CS:R2CSEG
  106.  
  107. ;/****************************************************************************
  108. ;*
  109. ;*  SUBROUTINE NAME: GetMode
  110. ;*
  111. ;*  DESCRIPTIVE NAME: Get current video mode setting
  112. ;*
  113. ;*  FUNCTION: GetMode is called by BVS to get the current mode setting.
  114. ;*            If the request specifies hardware and the hardware is
  115. ;*            readable, the actual hardware setting will be read and
  116. ;*            returned.  Otherwise the returned information will be
  117. ;*            taken from the environment buffer, if it has been passed.
  118. ;*
  119. ;*  ENTRY POINT: GetMode
  120. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 271 )
  121. ;*
  122. ;*  INPUT: (Passed on stack)
  123. ;*             FAR *Environment ( Environment buffer for the session )
  124. ;*             FAR *ParmBlock
  125. ;*                     USHORT Length = length of this packet
  126. ;*                     USHORT Flags  = 0 - Environment buffer only
  127. ;*                                     1 - Hardware also
  128. ;*                     VIOMODEINFO FAR *ModeDataPTR
  129. ;*             ULONG Function ( Call vector table entry = 271 )
  130. ;*         (Referenced)
  131. ;*             Modes[] (global data - table of supported video modes )
  132. ;*
  133. ;*  EXIT-NORMAL: AX = 0
  134. ;*               Current mode setting is returned
  135. ;*
  136. ;*  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  137. ;*
  138. ;*  EFFECTS: If hardware specified and hardware is readable, the
  139. ;*           environment buffer is updated, if passed.
  140. ;*
  141. ;*  INTERNAL REFERENCES:
  142. ;*    ROUTINES: NONE
  143. ;*
  144. ;*  EXTERNAL REFERENCES:
  145. ;*    ROUTINES: NONE
  146. ;*
  147. ;****************************************************************************/
  148.  
  149. GetMode PROC    FAR
  150.         public  GetMode
  151.         Call    RegSave
  152.  
  153.         mov     ax,ERROR_VIO_INVALID_LENGTH
  154.         .if     <[si].vp_parmlength eq 8> and near
  155.         les     di,dword ptr [si].vp_offset ;Get address of mode data
  156.         lds     si,dword ptr [bp].stk_envblock ;Get environment block
  157.         add     si,env_mdlen            ;Get offset of mode data
  158.         mov     cx,es:[di].mode_datalen ;Get length of mode data
  159.         .if     <cx a 1>
  160.             Call    SecureSema4
  161.  
  162.             mov     ax,cx
  163.             .if     <al a <size modedata>> ;@S25
  164.                 mov     al,mode_attrformat ;@S25
  165.             .endif                      ;@S25
  166.  
  167.             push    di
  168.             sub     al,size mode_datalen
  169.             .if     <ns>
  170.                 movsw
  171.             .endif
  172.  
  173.             sub     al,size mode_type
  174.             .if     <ns>
  175.                 movsb
  176.             .endif
  177.  
  178.             sub     al,size mode_colors
  179.             .if     <ns>
  180.                 movsb
  181.             .endif
  182.  
  183.             sub     al,size mode_cols
  184.             .if     <ns>
  185.                 movsw
  186.             .endif
  187.  
  188.             sub     al,size mode_rows
  189.             .if     <ns>
  190.                 movsw
  191.             .endif
  192.  
  193.             sub     al,size mode_gcols
  194.             .if     <ns>
  195.                 movsw
  196.             .endif
  197.  
  198.             sub     al,size mode_grows
  199.             .if     <ns>
  200.                 movsw
  201.             .endif
  202.  
  203.             sub     al,size mode_attrformat
  204.             .if     <ns>
  205. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  206.                 .if     <<byte ptr ds:[si]> eq 41h> or  ;epoch color    ;;EPOCH ;; added for J-FUNC
  207.                 .if     <<byte ptr ds:[si]> eq 81h>     ;epoch mono.    ;;EPOCH ;; added for J-FUNC
  208.                                                 ;DCR JP20 #103          ;;EPOCH ;; added for J-FUNC
  209.                                                 ;Applications don't     ;;EPOCH ;; added for J-FUNC
  210.                                                 ;need to know the       ;;EPOCH ;; added for J-FUNC
  211.                                                 ;internal format IDs.   ;;EPOCH ;; added for J-FUNC
  212.                     push    ax                                          ;;EPOCH ;; added for J-FUNC
  213.                     lodsb                                               ;;EPOCH ;; added for J-FUNC
  214.                     and     al, 0fh             ;Ignore high byte used  ;;EPOCH ;; added for J-FUNC
  215.                                                 ;internally.            ;;EPOCH ;; added for J-FUNC
  216.                     stosb                                               ;;EPOCH ;; added for J-FUNC
  217.                     pop     ax                                          ;;EPOCH ;; added for J-FUNC
  218.                 .else                                                   ;;EPOCH ;; added for J-FUNC
  219. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  220.                 movsb
  221. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  222.                 .endif                                                  ;;EPOCH ;; added for J-FUNC
  223. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  224.             .endif
  225.  
  226.             sub     al,size mode_attrbytes
  227.             .if     <ns>
  228.                 movsb
  229.             .endif
  230.  
  231.             sub     al,size mode_bufaddr
  232.             .if     <ns>
  233.                 movsd                                                   ;@T71
  234.             .endif
  235.  
  236.             sub     al,size mode_bufsize
  237.             .if     <ns>
  238.                 movsd                                                   ;@T71
  239.             .endif
  240.  
  241.             sub     al,size mode_fullbufsz
  242.             .if     <ns>
  243.                 movsd                                                   ;@T71
  244.             .endif
  245.  
  246.             sub     al,size mode_partbufsz
  247.             .if     <ns>
  248.                 movsd                                                   ;@T71
  249.             .endif
  250.  
  251.             sub     al,size mode_extdata
  252.             .if     <ns>
  253.                 movsd                                                   ;@T71
  254.             .endif
  255.  
  256.             mov     ax,di
  257.             pop     di
  258.             sub     ax,di
  259.             .if     <al a 2>            ;More than just a length request
  260.                 stosw                   ;Update length in Mode data
  261.             .endif
  262.  
  263.             Call    ReleaseSema4
  264.             sub     ax,ax               ;Set good return code
  265.         .endif
  266.  
  267.         Call    RegRest
  268.         ret     12
  269. GetMode ENDP
  270.  
  271. ;/****************************************************************************
  272. ;*
  273. ;*  SUBROUTINE NAME: SetMode
  274. ;*
  275. ;*  DESCRIPTIVE NAME: Set video mode
  276. ;*
  277. ;*  FUNCTION: SetMode is called by BVS to set the video mode.
  278. ;*            If the request specifies hardware, the hardware and the
  279. ;*            environment buffer, if passed, will be updated.
  280. ;*            Otherwise just the environment buffer, if passed, will
  281. ;*            be updated.
  282. ;*
  283. ;*  ENTRY POINT: SetMode
  284. ;*    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 272 )
  285. ;*
  286. ;*  INPUT: (Passed on stack)
  287. ;*             FAR *Environment ( Environment buffer for the session )
  288. ;*             FAR *ParmBlock
  289. ;*                     USHORT Length = length of this packet
  290. ;*                     USHORT Flags  = 0 - Environment buffer only
  291. ;*                                     1 - Hardware also
  292. ;*                     VIOMODEINFO FAR *ModeDataPTR
  293. ;*             ULONG Function ( Call vector table entry = 272 )
  294. ;*         (Referenced)
  295. ;*             Modes[] (global data - table of supported video modes )
  296. ;*
  297. ;*  EXIT-NORMAL: AX = 0
  298. ;*               Video mode is set
  299. ;*
  300. ;*  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  301. ;*
  302. ;*  INTERNAL REFERENCES:
  303. ;*    ROUTINES: NONE
  304. ;*
  305. ;*  EXTERNAL REFERENCES:
  306. ;*    ROUTINES: NONE
  307. ;*
  308. ;****************************************************************************/
  309.  
  310. SetMode PROC    FAR
  311.         public  SetMode
  312.         Call    RegSave
  313.  
  314.         mov     ax,ERROR_VIO_EXTENDED_SG ;@T16
  315.         call    CheckAvio               ;@T16
  316.         .if     <z> near                ; Vio windowable session?       ;@T16
  317.             mov     ax,ERROR_VIO_INVALID_LENGTH
  318.             .if     <[si].vp_parmlength eq 8> and near
  319.             lds     si,dword ptr [si].vp_offset ;Get address of mode data
  320.             mov     cx,[si].mode_datalen ;Get length of mode data
  321.             .if     <cl ae 3> and near
  322.             mov     ax,ERROR_VIO_MODE   ;Preset mode error
  323.             mov     dl,[si].mode_type
  324.             test    dl,NOT (mode_f_color + mode_f_uncolor)
  325.             .if     <z> and near        ;Mono/Color Text only (Type = 0/1)
  326.             mov     dh,dl               ;@@S2
  327.             and     dh,mode_f_color + mode_f_uncolor ;@@S2
  328.             .if     <dh ne mode_f_uncolor> and near ;No Color Burst w/Mono ;@@S2
  329.             .if     <cl eq 3> or        ;Only Type specified
  330.             and     dl,mode_f_color
  331. IFDEF EPOCH ;25Sep91An
  332.             .if     <dl eq [si].mode_colors> or     ;epoch format support
  333. ENDIF
  334.             shl     dl,2
  335.             .if     <dl eq [si].mode_colors> near ;Type/Colors = 1/4 or 0/0 ;@T1
  336.  
  337. IFDEF D1348
  338.                 .if     <cl ae <mode_attrformat+size mode_attrformat>>
  339.                     mov     al,[si].mode_attrformat
  340.                     .if     <cl ae <mode_attrbytes+size mode_attrbytes>> and
  341.                     mov     ah,[si].mode_attrbytes
  342.                     .if     <ax eq WorldFMTATTR>    and
  343.                     .if     <<[si].mode_cols> eq 0>
  344.                         mov     [si].mode_cols,80   ;set the default value
  345.                     .endif
  346.                     .if     <ax eq WorldFMTATTR>    and
  347.                     .if     <<[si].mode_rows> eq 0>
  348.                         mov     [si].mode_rows,25   ;set the default value
  349.                     .endif
  350.                 .endif
  351. ENDIF ;D1348
  352.                 mov     dx,25           ;Preset 25 rows
  353.                 .if     <cl b <mode_cols+size mode_cols>> or             ;@C11
  354.                 .if     <[si].mode_cols eq 80> ;80-column modes only
  355.                     sub     ax,ax
  356.                     .if     <cl ae <mode_rows+size mode_rows>>
  357.                         mov     ax,[si].mode_rows
  358.                         .if     <ax be 0>       ;Check rows<=0          ;@B22
  359.                             mov     ax,ERROR_VIO_MODE                   ;@B22
  360.                         .else
  361.                             mul     [si].mode_cols
  362.                             .if     <ax a 2000h> or
  363.                             .if     <nonzero dx>    ;Buffer too large
  364.                                 mov     ax,ERROR_VIO_MODE
  365.                             .else
  366.                                 sub     ax,ax
  367.                                 mov     dx,[si].mode_rows
  368.                             .endif
  369.                         .endif                                          ;@B22
  370.                     .endif
  371.                 .endif
  372.  
  373. IFDEF D1348 ;set the format ID and attribute count
  374.                 .if     <zero ax> and
  375.                 mov     es:[viops_FormatID],DefaultFormat    ; initialize
  376.                 mov     es:[env_attrbytes],DefaultAttrCount  ; initialize
  377.                 .if     <cl ae <mode_attrformat+size mode_attrformat>>
  378.                                         ; check format ID and attribute count
  379.                     mov     ax,word ptr es:[env_attrformat]
  380.                     mov     al,[si].mode_attrformat
  381.                     .if     <cl ae <mode_attrbytes+size mode_attrbytes>>
  382.                         mov     ah,[si].mode_attrbytes
  383.                     .endif
  384. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  385.                     .if     <ax eq PSFMTATTR> or                        ;;EPOCH ;; added for J-FUNC
  386. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  387.                     .if     <ax eq DefaultFMTATTR> or
  388.                     .if     <ax eq WorldFMTATTR>
  389.                         mov     es:[env_attrbytes],ah        ; update
  390.                         sub     ah,ah
  391.                         mov     es:[viops_FormatID],ax       ; update
  392.                         sub     ax,ax
  393.                     .else
  394.                         mov     ax,ERROR_VIO_MODE
  395.                     .endif
  396.                 .endif
  397. ENDIF ;D1348
  398.  
  399.                 .if     <zero ax>   near                                ;@T1
  400.                     Call    SecureSema4
  401.  
  402.                     push    dx          ;Save requested rows
  403.                     push    es          ;Save PS selector
  404. IFDEF EPOCH ;25Sep91An                                                  ;;EPOCH ;; added for J-FUNC
  405.                     mov     al,[si].mode_colors                         ;;EPOCH ;; added for J-FUNC
  406.                     mov     es:[env_colors],al                          ;;EPOCH ;; added for J-FUNC
  407. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  408. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  409.                     .if     <cl a 12> near  ;Only when the length       ;;EPOCH ;; added for J-FUNC
  410.                                             ;includes FormatID and      ;;EPOCH ;; added for J-FUNC
  411.                                             ;attrbytes.                 ;;EPOCH ;; added for J-FUNC
  412. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  413.  
  414. IFDEF D1348 ;prepare the 2nd LVB for DBCS flag
  415.                     mov     ax,es:[viops_FormatID]
  416.                     .if     <al ne es:[env_attrformat]> near ; change format ID
  417.                         push    ds                                      ;@B01
  418.                         push    si                                      ;@B01
  419.                         lds     si,es:[viops_lpNLSExt]                  ;@B01
  420.                                         ;Set default RGB to support               ;@B01
  421.                                         ;grid color and screen intensity          ;@B01
  422.                                         ;in the same way of VDM.                  ;@B01
  423.                         mov     dword ptr ds:[si].viopsnlsext_grid_color,0fcfcfch ;@B01
  424.                         mov     dword ptr ds:[si].viopsnlsext_scrnattrflag,0      ;@B01
  425.                         .if     <al eq DefaultFormat>
  426.                             mov     es:[env_funcindx],DefaultFmtIndx
  427.  
  428.                             mov     es:[viops_CellByteSize],DefaultCellSize
  429. IFDEF MSKK ;25Sep91 : prepare the 2nd LVB for DBCS flag
  430.                             mov     ax,es:[env_dbcslvbsel]      ; DBCS flag LVB sel
  431.                             verw    ax                          ; check selector
  432.                             .if     <nz>                        ; unavailable
  433.                                 push    ax
  434.                                 call    DOSGETSEG               ; get share
  435.                             .endif
  436. ENDIF ; MSKK
  437. IFDEF EPOCH
  438.                         .elseif     <al eq PSFormat>
  439.                             .if <<es:[env_colors]> eq 01>
  440.                                 mov     al,81h  ;internal epoch monochrome format id
  441.                                                                 ;set green.               ;@B01
  442.                                 mov     dword ptr ds:[si].viopsnlsext_grid_color,000fc00h ;@B01
  443.                             .else
  444.                                 mov     al,41h  ;internal epoch color format id
  445.                             .endif
  446.                             xor     ah,ah
  447.                             mov     es:[viops_FormatID],ax      ;26Sep91
  448.                             mov     es:[env_funcindx],PSFmtIndx
  449.                             mov     es:[viops_CellByteSize],PSCellSize
  450. ENDIF
  451.                         .else                           ; WorldFMTATTR
  452.                             mov     es:[env_funcindx],WorldFmtIndx
  453.  
  454.                             mov     es:[viops_CellByteSize],WorldCellSize
  455.                         .endif
  456.                         pop     si      ;@B01
  457.                         pop     ds      ;@B01
  458.                         mov     es:[env_attrformat],al  ; update
  459.                         call    ClearLVB                ; clear current LVB
  460.                     .endif
  461. ENDIF ;D1348
  462.  
  463. IFDEF EPOCH
  464.                     .elseif     <al eq 1>   ;Or when Epoch monochrome.
  465.                                             ;Overlook the     of PE2.exe
  466.                         mov     es:[env_attrbytes],1
  467.                         mov     es:[viops_FormatID],81h
  468.                         mov     es:[env_funcindx],PSFmtIndx
  469.                         mov     es:[viops_CellByteSize],PSCellSize
  470.  
  471.                         push    ds                                      ;@B01
  472.                         push    si                                      ;@B01
  473.                         lds     si,es:[viops_lpNLSExt]                  ;@B01
  474.                                         ;Set default RGB to support               ;@B01
  475.                                         ;grid color and screen intensity          ;@B01
  476.                                         ;in the same way of VDM.                  ;@B01
  477.                         mov     dword ptr ds:[si].viopsnlsext_grid_color,000fc00h ;@B01
  478.                         mov     dword ptr ds:[si].viopsnlsext_scrnattrflag,0      ;@B01
  479.                         pop     si                                      ;@B01
  480.                         pop     ds                                      ;@B01
  481.  
  482.                     .else                   ;Set Default values of CGA
  483.                         mov     es:[env_attrbytes],1
  484.                         mov     es:[viops_FormatID],0
  485.                         mov     es:[env_funcindx],DefaultFmtIndx
  486.                         mov     es:[viops_CellByteSize],DefaultCellSize
  487.  
  488.                         push    ds                                      ;@B01
  489.                         push    si                                      ;@B01
  490.                         lds     si,es:[viops_lpNLSExt]                  ;@B01
  491.                                         ;Set default RGB to support               ;@B01
  492.                                         ;grid color and screen intensity          ;@B01
  493.                                         ;in the same way of VDM.                  ;@B01
  494.                         mov     dword ptr ds:[si].viopsnlsext_grid_color,0fcfcfch ;@B01
  495.                         mov     dword ptr ds:[si].viopsnlsext_scrnattrflag,0      ;@B01
  496.                         pop     si                                      ;@B01
  497.  
  498.                         pop     ds                                      ;@B01
  499.  
  500. IFDEF MSKK ;25Sep91 : prepare the 2nd LVB for DBCS flag
  501.                         mov     ax,es:[env_dbcslvbsel]      ; DBCS flag LVB sel
  502.                         verw    ax                          ; check selector
  503.                         .if     <nz>                        ; unavailable
  504.                             push    ax
  505.                             call    DOSGETSEG               ; get share
  506.                         .endif
  507. ENDIF ; MSKK
  508.                     .endif
  509. ENDIF
  510.                     mov     ax,es:[viops_BufferColumnCount]         ;@T1;@T52
  511.                     mul     dx          ;LVB size = row * col * cellsize;@T1
  512.                     mul     es:[viops_CellByteSize]                 ;@T1;@T52
  513. IFDEF D1348 ;save LVB size
  514.                     push    ax
  515.                     sub     ax,dx                       ; if 64KB, set 0FFFFh
  516.                     mov     es:[env_lvbsize],ax
  517.                     pop     ax
  518. ENDIF ;D1348
  519.                     cmp     dx,word ptr es:[bx].env_bufsize+2           ;@T1
  520.                     .if     < a >   or                                  ;@T1
  521.                     .if     < e > near  and                             ;@T1
  522.                     .if     <ax a <word ptr es:[env_bufsize]>> near ;@T1;@T52
  523.                         mov     di,WDHGSEG                              ;@T1
  524.                         mov     ds,di   ;Global data segment            ;@T1
  525.                         mov     cx,ax   ;Save size(low)                 ;@T1
  526.  
  527. IFDEF MSKK ; 1990-06-21 : prepare the 2nd LVB for DBCS flag
  528.                         .if     <es:[viops_CellByteSize] eq DefaultCellSize>
  529.                             push    ax                  ; save size
  530.                             push    ax                  ; re-allocate size
  531.                             push    es:[env_dbcslvbsel] ; DBCS flag LVB selector
  532.                             call    DOSREALLOCSEG
  533.                             .if     <zero ax>           ; no error
  534.                                 push    cx
  535.                                 mov     di,word ptr es:[env_fullbufsz]
  536.                                                         ; 1990-07-05 updated
  537.                                 sub     cx,di
  538.                                 shr     cx,1            ; clear DBCS flag LVB
  539.                                 push    es
  540.                                 mov     es,es:[env_dbcslvbsel]
  541.                                 rep     stosw           ; clear by 0
  542.                                 pop     es
  543.                                 pop     cx
  544.                             .endif
  545.                             pop     ax                  ; restore size
  546.                         .endif
  547. ENDIF ; MSKK
  548.                         push    dx                                      ;@T1
  549.                         push    ax                                      ;@T1
  550.                         push    es:[viops_Sel_LogicalVideoBuffer]   ;@T1;@T52
  551.                         call    DOSREALLOCHUGE                          ;@T1
  552.                         .if     <zero ax>   or                          ;@T1
  553.                         .if     <ax e ERROR_ACCESS_DENIED>              ;@T1
  554.                             mov     di,word ptr es:[env_bufsize]    ;@T1;@T52
  555.                             sub     cx,di                               ;@T1
  556. IFDEF D1348 ;update LVB clear to corresponding format ID
  557.                             .if     <es:[viops_CellByteSize] eq DefaultCellSize>
  558. ENDIF ;D1348
  559.                                 shr     cx,1                                ;@T1
  560.                                 mov     ax,0720H                            ;@T1
  561.                                 push    es                                  ;@T1
  562.                                 mov     es,es:[viops_Sel_LogicalVideoBuffer];@T1;@T52
  563.                                 cld                                         ;@T1
  564.                                 rep     stosw                               ;@T1
  565.                                 pop     es                                  ;@T1
  566. IFDEF D1348 ;update LVB clear to corresponding format ID
  567.                             .else                       ; WorldCellSize
  568.                                 shr     cx,2
  569.                                 mov     ax,0720h
  570.                                 mov     dx,0000h
  571.                                 push    es
  572.                                 mov     es,es:[viops_Sel_LogicalVideoBuffer]
  573.                                 cld
  574.                                 .repeat
  575.                                     stosw
  576.                                     mov     es:[di],dx
  577.                                     inc     di
  578.                                     inc     di
  579.                                 .loop
  580.                                 pop     es
  581.                             .endif
  582. ENDIF ;D1348
  583.                             sub     ax,ax                               ;@T1
  584.                         .endif                                          ;@T1
  585.                     .else                                               ;@T1
  586.                         sub     ax,ax                                   ;@T1
  587.                     .endif                                              ;@T1
  588.  
  589.                     .if     <zero ax> near                          ;@T1;@T52
  590.  
  591.                         push    WDHGSEG                                 ;@T52
  592.                         pop     ds                                      ;@T52
  593.                         lgs     si,ds:bvh_instance                      ;@T80
  594.  
  595.                         push    dword ptr es:[viops_hConsoleDisplayContext] ;@@E,@T71
  596.                         push    dword ptr 5     ;32-bit Index           ;@T71
  597.                         push    gs                                      ;@T80
  598.                         lea     ax,gs:[si].wdhi_Scratch                 ;@T80
  599.                         push    ax              ;32-bit Return Value    ;@T52
  600.                         push    dword ptr 1     ;32-bit number of items ;@T71
  601.                         push    dword ptr 0     ;32-bit "cookie" parm ;@T52,@T71
  602.                         push    dword ptr GreQueryDevCapsLo             ;@T71
  603.  
  604.                         call    GREENTRY6                               ;@T52
  605.  
  606.                         pop     es              ;Restore PS selector
  607.                         pop     dx              ;Restore requested number of rows
  608.                         sub     bx,bx
  609.                         .if     <ax ne 1>
  610.                             mov     ax,ERROR_VIO_MODE
  611.                         .else
  612.                             mov     es:[bx].viops_BufferRowCount,dx ;Update #rows
  613.                             Call    UpdateMode
  614.  
  615.                             push    es
  616.                             push    es:[bx].env_conhandle
  617.                             call    WINSYNCWITHPS                       ;@T52
  618.                             pop     es
  619.  
  620.                             sub     bx,bx ;@@S1
  621.                             mov     ax,es:[bx].viops_BufferRowCount ;Get # of rows ;@@S1
  622.                             dec     ax  ;Normalize to 0 base ;@@S1
  623.                             mov     es:[bx].viops_TextCursorRow,ax ;@@S1
  624.                             mov     es:[bx].viops_TextCursorColumn,bx ;@@S1
  625.  
  626.                             mov     ax,es:[bx].viops_CellImageHeight ;@@S1
  627.                             dec     ax  ;@@S1
  628.                             mov     es:[bx].viops_TextCursorEndLine,ax ;@@S1
  629.                             dec     ax  ;@@S1
  630.                             mov     es:[bx].viops_TextCursorStartLine,ax ;@@S1
  631.  
  632.                             push    es                                  ;@P1
  633.                             push    dword ptr es:[bx].viops_hConsoleDisplayContext ;DC handle ;@@S1,@T71
  634.                             push    es  ;@@S1
  635.                             push    bx  ;Ptr to VioPS ;@@S1
  636.                             push    dword ptr 0  ;"cookie" parm pt. 2 ;@@S1,@T71
  637.                             push    dword ptr GreUpdateCursorLo ;Engine function pt. 2 ;@@S1,@T71
  638.                             call    GREENTRY4 ;Refresh the cursor  ;@@S1;@T52
  639.                             pop     es                                  ;@P1
  640.  
  641.                             sub     ax,ax
  642.                         .endif
  643.                     .else                                               ;@T1
  644.                         pop     es                                      ;@T1
  645.                         pop     dx                                      ;@T1
  646.                     .endif                                              ;@T1
  647.                     Call    ReleaseSema4
  648.                 .endif
  649.             .endif                      ;@T16
  650.         .endif
  651.  
  652.         Call    RegRest
  653.         ret     12
  654. SetMode ENDP
  655.  
  656. IFDEF D1348
  657.  
  658. ;/****************************************************************************
  659. ;*
  660. ;* FUNCTION NAME = ClearLVB
  661. ;*
  662. ;* DESCRIPTION   =
  663. ;*
  664. ;* INPUT         =
  665. ;* OUTPUT        = NONE
  666. ;*
  667. ;* RETURN-NORMAL = NONE
  668. ;* RETURN-ERROR  = NONE
  669. ;*
  670. ;****************************************************************************/
  671.  
  672. ClearLVB proc   near
  673.          public ClearLVB
  674.  
  675.         push    ds
  676.         push    es
  677.         push    di
  678.         push    cx
  679.         push    dx
  680.  
  681.         mov     cx,word ptr es:[env_lvbsize]
  682.         mov     dl,es:[env_attrformat]
  683.         push    es
  684.         pop     ds
  685.         mov     es,es:[viops_Sel_LogicalVideoBuffer]    ; LVB selector
  686.         sub     di,di
  687. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  688.         and     dl,0fh                  ; Ignore internal formatid      ;;EPOCH ;; added for J-FUNC
  689. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  690.  
  691.         .if     <dl eq DefaultFormat>
  692.             shr     cx,1                                ; cell size
  693.             mov     ax,0720h                            ; attr and char
  694.             rep     stosw
  695.                                                         ; prepare the 2nd LVB
  696.                                                         ; for DBCS flag
  697. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  698.         .elseif     <dl eq PSFormat>                                    ;;EPOCH ;; added for J-FUNC
  699.             mov     ax,0020h                                            ;;EPOCH ;; added for J-FUNC
  700.             shr     cx,1                                                ;;EPOCH ;; added for J-FUNC
  701.             rep     stosw                                               ;;EPOCH ;; added for J-FUNC
  702. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  703.         .else                                           ; WorldFormat
  704.             shr     cx,2                                ; cell size
  705.             mov     ax,0720h                            ; attr1 and char
  706.             mov     dx,0000h                            ; attr3 and attr2
  707.             .repeat
  708.                 stosw
  709.                 mov     es:[di],dx
  710.                 inc     di
  711.                 inc     di
  712.             .loop
  713.         .endif
  714.  
  715.         pop     dx
  716.         pop     cx
  717.         pop     di
  718.         pop     es
  719.         pop     ds
  720.  
  721.         ret
  722. ClearLVB endp
  723. ENDIF ;D1348
  724.  
  725. R2CSEG  ENDS
  726.         END
  727.  
  728.