home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / WDHBUFUP.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  31KB  |  672 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    60,132
  13.         TITLE   WDHBUFUP.ASM -- Buffer Update Routine for Windows
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = WDHBUFUP.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = Buffer Update Routine for Windows
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE
  25. ;*
  26. ;* DESCRIPTION  Mainline routine for video buffer read, write,
  27. ;*              scroll functions.
  28. ;*
  29. ;*   LINKAGE:   Far Call from Base Video Subsystem (BVSCALLS.DLL)
  30. ;*
  31. ;* INPUT:       STACK FRAME on entry
  32. ;*
  33. ;* SS:SP  --->  bvsip           dw      BVS IP offset
  34. ;*              bvscs           dw      BVS CS selector
  35. ;*              parmn           dd      Function number (256)
  36. ;*              parmnm2         dd      Parameter block
  37. ;*              parmnm4         dd      Environment buffer
  38. ;*
  39. ;*
  40. ;* PARAMETER BLOCK FORMAT:
  41. ;*
  42. ;*   SIZE   DESCRIPTION
  43. ;*   ----   -----------
  44. ;*
  45. ;*   WORD   ParmLength (length of structure - 28 bytes)
  46. ;*   WORD   Flags
  47. ;*            Bit 0 = 0, do not update physical display buffer
  48. ;*            Bit 0 = 1, update physical display buffer if possible
  49. ;*            Bit 1 = 0, logical display buffer update not required
  50. ;*            Bit 1 = 1, update logical display buffer
  51. ;*            Bit 2 = 0, use attribute as is
  52. ;*            Bit 2 = 1, convert attribute to or from CGA format
  53. ;*            Bit 3 - 15 are reserved and must be OFF
  54. ;*
  55. ;*          NOTE:  If bit 0 and 1 are both ON then the LVB will
  56. ;*                 be written first before the PVB is updated.
  57. ;*                 This will ensure that video devices with
  58. ;*                 slower VRAM will benefit from this algorithm.
  59. ;*
  60. ;*                 The caller of BufferUpdate routine (BVS) must
  61. ;*                 serialize access to this routine to insure
  62. ;*                 that the LVB and the PVB will not get out of sync.
  63. ;*
  64. ;*   DWORD  AppDataAddr (address of application data)
  65. ;*   DWORD  AppCellAddr (address of character, attribute, or cell)
  66. ;*   WORD   Index (BufferUpdate sub-function to be performed)
  67. ;*            0 = Read cell types
  68. ;*                  Bit 0 = 0, single cell character
  69. ;*                             (occupies one cell on the screen)
  70. ;*                  Bit 0 = 1, double cell character
  71. ;*                             (occupies two cells on the screen)
  72. ;*                  Bit 1 = 0, leading (or only) cell
  73. ;*                  Bit 1 = 1, trailing cell
  74. ;*                  Bit 2 - 15 are reserved and must be OFF
  75. ;*            1 = Read characters from (Row, Col)
  76. ;*            2 = Read cells from (Row, Col)
  77. ;*            3 = Scroll (Row, Col) through (Row2, Col2) Up
  78. ;*            4 = Scroll (Row, Col) through (Row2, Col2) Down
  79. ;*            5 = Scroll (Row, Col) through (Row2, Col2) Left
  80. ;*            6 = Scroll (Row, Col) through (Row2, Col2) Right
  81. ;*            7 = Write cells to (Row, Col)
  82. ;*            8 = Write characters to (Row, Col)
  83. ;*            9 = Write characters with constant attr to (Row, Col)
  84. ;*           10 = Write repeat character to (Row, Col)
  85. ;*           11 = Write repeat attribute to (Row, Col)
  86. ;*           12 = Write repeat cell to (Row, Col)
  87. ;*   WORD   Row  (Starting row)
  88. ;*   WORD   Col  (Starting column)
  89. ;*   WORD   Row2 (Secondary row)
  90. ;*   WORD   Col2 (Secondary column)
  91. ;*   WORD   RepeatFactor (# of character cells or rows/columns)
  92. ;*   WORD   LogicalBufSel (logical buffer selector - LVB)
  93. ;*
  94. ;*
  95. ;* ENVIRONMENT BUFFER FORMAT:
  96. ;*
  97. ;*   SIZE   DESCRIPTION
  98. ;*   ----   -----------
  99. ;*   WORD   ModeDataOff (offset to mode data structure)
  100. ;*
  101. ;*
  102. ;* MODEDATA STRUCTURE FORMAT:
  103. ;*
  104. ;*   SIZE   DESCRIPTION
  105. ;*   ----   -----------
  106. ;*   WORD   Length (length of mode data structure - 34 bytes)
  107. ;*   BYTE   ModeType
  108. ;*            Bit 0 = 0, monochrome compatible
  109. ;*            Bit 0 = 1, other
  110. ;*            Bit 1 = 0, text mode
  111. ;*            Bit 1 = 1, graphics mode
  112. ;*            Bit 2 = 0, enable color burst
  113. ;*            Bit 2 = 1, disable color burst
  114. ;*            Bit 3 = 0, VGA compatible modes (0 - 13h)
  115. ;*            Bit 3 = 1, native mode
  116. ;*            Bit 4 - 15 are reserved
  117. ;*   BYTE   Color (number of colors as a power of 2)
  118. ;*   WORD   TextCols (number of text columns in current mode)
  119. ;*   WORD   TextRows (number of text rows in current mode)
  120. ;*   WORD   HorizRes (horizontal pel resolution)
  121. ;*   WORD   VertRes (vertical pel resolution)
  122. ;*   BYTE   AttrFormat (attribute format)
  123. ;*   BYTE   NAttributes (number of attributes in a character cell)
  124. ;*  DWORD   BufferAddr (32-bit physical address of PVB)
  125. ;*  DWORD   BufferLength (length of PVB in current mode)
  126. ;*  DWORD   FullBufSize (size of buffer required for screen save)
  127. ;*  DWORD   PartBufSize (size of buffer for popup save)
  128. ;*  DWORD   ExtDataAddr (extended mode data structure address)
  129. ;*
  130. ;* EXIT-NORMAL: AX = 0
  131. ;*
  132. ;* EXIT-ERROR:  AX = error code, ERROR_VIO_COL
  133. ;*                               ERROR_VIO_INVALID_LENGTH
  134. ;*                               ERROR_VIO_INVALID_PARMS
  135. ;*                               ERRPR_VIO_MODE
  136. ;*                               ERROR_VIO_ROW
  137. ;*                               ERROR_VIO_INTERNAL_RESOURCE
  138. ;*
  139. ;* EFFECTS:     All other registers are preserved
  140. ;*
  141. ;* INTERNAL REFERENCES: None
  142. ;*
  143. ;* EXTERNAL REFERENCES: ReadCellTypes           in XGAREAD.ASM
  144. ;*                      ReadCharStr             in XGAREAD.ASM
  145. ;*                      ReadCellStr             in XGAREAD.ASM
  146. ;*                      ScrollUp                in XGASCROL.ASM
  147. ;*                      ScrollDown              in XGASCROL.ASM
  148. ;*                      ScrollLeft              in XGASCROL.ASM
  149. ;*                      ScrollRight             in XGASCROL.ASM
  150. ;*                      WriteCellStr            in XGAWRITE.ASM
  151. ;*                      WriteCharStr            in XGAWRITE.ASM
  152. ;*                      WriteCharStrAttr        in XGAWRITE.ASM
  153. ;*                      WriteNChar              in XGAWRITE.ASM
  154. ;*                      WriteNAttr              in XGAWRITE.ASM
  155. ;*                      WriteNCell              in XGAWRITE.ASM
  156. ;*
  157. ;* FUNCTIONS    BUFFERUPDATE
  158. ;*              DummyLVBToPVB
  159. ;*              SetGenParms
  160. ;*
  161. ;* NOTES        NONE
  162. ;*
  163. ;* STRUCTURES   NONE
  164. ;*
  165. ;* EXTERNAL REFERENCES  NONE
  166. ;*
  167. ;* EXTERNAL FUNCTIONS
  168. ;*
  169. ;*              NONE
  170. ;*
  171. ;* PSEUDOCODE
  172. ;*
  173. ;*      Begin BufferUpdate
  174. ;*          Preset return code to ERROR_VIO_MODE
  175. ;*          If text mode
  176. ;*              Preset return code to ERROR_VIO_INVALID_LENGTH
  177. ;*              If correct parameter length
  178. ;*                  Preset return code to ERROR_VIO_INVALID_PARMS
  179. ;*                  If valid reserved flags     AND
  180. ;*                  If valid video buffer flags AND
  181. ;*                  If valid function number    AND
  182. ;*                  If valid index number
  183. ;*                      Call Read/Write/Scroll routines
  184. ;*                  Endif
  185. ;*              Endif
  186. ;*          Endif
  187. ;*      End BufferUpdate
  188. ;*
  189. ;* CHANGE ACTIVIY =
  190. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  191. ;*   --------  ---------- -----   --------------------------------------
  192. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  193. ;*   03/25/89  @P1        D132    TPL, DCR 132 changes
  194. ;*   05/01/89  @C19       HM00550 CJJ, Clear carry flag for SetBuffAddr
  195. ;*                                routine,
  196. ;*   08/19/89  @S23       B706727 CJJ,TLB Save pssel in instance data,
  197. ;*   11/02/89  @D549      D549    CJJ, Seltable changes due to rangeless
  198. ;*                                sessions,
  199. ;*   01/22/90  @T52       D704    TPL, DCR 704 work
  200. ;*             @B55       B788870 WKB, Convert bytes to cell value for graphics
  201. ;*                                engine call
  202. ;*   04/11/91  D1348      D1348   NAKADA, Enable DBCS support in Vio-Window
  203. ;*   03/02/92  @C01       N/A     NAKADA, a     fix in vdm session.  Need to
  204. ;*                                be merged to U.S.
  205. ;*   05/20/93  KY03       N/A     KAZZ, Added the lines to support 3-byte
  206. ;*                                attribute mode (Local Fix in Japan).
  207. ;****************************************************************************/
  208.  
  209.         .xlist
  210.         include bvscb.inc               ;BVS Control Blocks     @S23
  211.         INCLUDE struc.inc               ; Structure macro
  212.         INCLUDE error2.inc              ; Subsystem error equates
  213.         INCLUDE vdhstruc.inc            ; Buffer update data structures
  214.         INCLUDE vdhequ.inc              ; Buffer update equates
  215.         .xlist
  216.  
  217.         EXTRN   ReadCellTypes    : NEAR ; 
  218.         EXTRN   ReadCharStr      : NEAR ; VioReadCharStr
  219.         EXTRN   ReadCellStr      : NEAR ; VioReadCellStr
  220.         EXTRN   ScrollUp         : NEAR ; VioScrollUp
  221.         EXTRN   ScrollDown       : NEAR ; VioScrollDn
  222.         EXTRN   ScrollLeft       : NEAR ; VioScrollLt
  223.         EXTRN   ScrollRight      : NEAR ; VioScrollRt
  224.         EXTRN   WriteCellStr     : NEAR ; VioWriteCellStr
  225.         EXTRN   WriteCharStr     : NEAR ; VioWriteCharStr
  226.         EXTRN   WriteCharStrAttr : NEAR ; VioWriteCharStrAttr
  227.         EXTRN   WriteNChar       : NEAR ; VioWriteNChar
  228.         EXTRN   WriteNAttr       : NEAR ; VioWriteNAttr
  229.         EXTRN   WriteNCell       : NEAR ; VioWriteNCell
  230.  
  231.         EXTRN   bvh_instance     : DWORD                                ;@T52
  232.  
  233. ;/*
  234. ;**  Start of window specific code
  235. ;*/
  236.  
  237.         .xlist
  238.         include pmwinx.inc
  239.         include pmaviop.inc
  240.         include wdhequ.inc              ; WDH Equates
  241.         include bvsparms.inc            ; BVS Parameter Equates
  242.         .list
  243.  
  244.         .386p                   ;@D549
  245.  
  246. IFDEF MSKK ; 1990-06-21 : prepare the 2nd LVB for DBCS flag             ;;MSKK  ;; added for J-FUNC
  247.         extrn   DOSGETSEG:FAR           ; Get DBCS flag LVB selector    ;;MSKK  ;; added for J-FUNC
  248. ENDIF ; MSKK                                                            ;;MSKK  ;; added for J-FUNC
  249.         extrn   SecureSema4:NEAR
  250.         extrn   ReleaseSema4:NEAR
  251.         extrn   CharStr:NEAR
  252.         extrn   WinScroll:NEAR
  253.  
  254. ;/*
  255. ;**  End of window specific code
  256. ;*/
  257.  
  258.         PUBLIC  BUFFERUPDATE
  259.         PUBLIC  DispTbl
  260.  
  261. WDHGSEG SEGMENT PARA PUBLIC 'DATA' USE16                                ;@T52
  262. WDHGSEG ENDS                                                            ;@T52
  263.  
  264.  
  265. R2CSEG  SEGMENT WORD    PUBLIC 'CODE' USE16     ;@D549
  266.         ASSUME  CS:R2CSEG,DS:NOTHING,ES:NOTHING
  267.  
  268. DispTbl DW      OFFSET R2CSEG:ReadCellTypes ; 
  269.         DW      OFFSET R2CSEG:ReadCharStr ; Read characters
  270.         DW      OFFSET R2CSEG:ReadCellStr ; Read character/attribute 's
  271.         DW      OFFSET R2CSEG:ScrollUp  ; Scroll window up
  272.         DW      OFFSET R2CSEG:ScrollDown ; Scroll window down
  273.         DW      OFFSET R2CSEG:ScrollLeft ; Scroll window left
  274.         DW      OFFSET R2CSEG:ScrollRight ; Scroll window right
  275.         DW      OFFSET R2CSEG:WriteCellStr ; Write character/attribute 's
  276.         DW      OFFSET R2CSEG:WriteCharStr ; Write characters
  277.         DW      OFFSET R2CSEG:WriteCharStrAttr ; Write characters with attr
  278.         DW      OFFSET R2CSEG:WriteNChar ; Write character N times
  279.         DW      OFFSET R2CSEG:WriteNAttr ; Write attribute N times
  280.         DW      OFFSET R2CSEG:WriteNCell ; Write cell N times
  281.         DW      OFFSET R2CSEG:DummyLVBToPVB ; Copy a rect of LVB to the PVB @P1
  282.  
  283. ;/****************************************************************************
  284. ;*
  285. ;* FUNCTION NAME = BUFFERUPDATE
  286. ;*
  287. ;* DESCRIPTION   =
  288. ;*
  289. ;*           This mainline routine checks all high level errors before
  290. ;*           control is transfer to the worker routine.
  291. ;*           On entry to each worker routine, the following registers
  292. ;*           are setup:
  293. ;*
  294. ;* INPUT     =   DS:SI -> Parameter block buffer
  295. ;*               ES:DI -> Mode data structure in the environment buffer
  296. ;*               SS:BP -> Parameter stack frame
  297. ;*
  298. ;*               All registers are preserved
  299. ;*
  300. ;* OUTPUT        = NONE
  301. ;*
  302. ;* RETURN-NORMAL = NONE
  303. ;* RETURN-ERROR  = NONE
  304. ;*
  305. ;****************************************************************************/
  306.  
  307. BUFFERUPDATE PROC FAR
  308.  
  309.  
  310.         sub     sp, bottomdest-PVB_Sel+2; Allocate storage for: PVB selector @P1
  311.                                         ;                       Scroll parms
  312.         push    bp                      ; Save caller's BP
  313.         mov     bp, sp                  ; Establish parameter addressability
  314.         pusha                           ; Save all registers
  315.         push    ds                      ; 
  316.         push    es                      ; 
  317.         les     di, [bp].EnvBufParm     ; ES:DI -> environment buffer
  318.  
  319. IFDEF D1348
  320.  
  321. IFDEF MSKK ; 1990-06-21 : prepare the 2nd LVB for DBCS flag             ;;MSKK  ;; added for J-FUNC
  322.         mov     bx,es:[di].env_dbcslvbsel                               ;;MSKK  ;; added for J-FUNC
  323.         .if     <nonzero bx>            ; prepared                      ;;MSKK  ;; added for J-FUNC
  324.             verw    bx                  ; verify selector               ;;MSKK  ;; added for J-FUNC
  325.             .if     <nz>                                                ;;MSKK  ;; added for J-FUNC
  326.                 push    bx                                              ;;MSKK  ;; added for J-FUNC
  327.                 call    DOSGETSEG                                       ;;MSKK  ;; added for J-FUNC
  328.             .endif                                                      ;;MSKK  ;; added for J-FUNC
  329.         .endif                                                          ;;MSKK  ;; added for J-FUNC
  330.         mov     [bp].j_dbcslvbsel,bx                                    ;;MSKK  ;; added for J-FUNC
  331. ENDIF ; MSKK                                                            ;;MSKK  ;; added for J-FUNC
  332.         mov     ax,es:[di].env_lvbsize
  333.         .if     <zero ax>               ; For mark© in vdm session, ;@C02
  334.                                         ; confirm its content.          ;@C02
  335.                                         ; This code is kind of kludge.  ;@C02
  336.                                         ; But if we don't have this,    ;@C02
  337.                                         ; Shield(pmvdmp.dll) needs to   ;@C02
  338.                                         ; have meaningless structure    ;@C02
  339.                                         ; to access and set env_*.      ;@C02
  340.             xor     dx,dx                                               ;@C02
  341.             mov     ax,es:[di].viops_CellByteSize                       ;@C02
  342.             mul     es:[di].viops_BufferRowCount                        ;@C02
  343.             mul     es:[di].viops_BufferColumnCount                     ;@C02
  344.         .endif                                                          ;@C02
  345.         mov     [bp].j_lvbsize,ax
  346.         .if     <es:[di].env_cols eq 0> ; for vdm direct call           ;@C02
  347.             mov      es:[di].env_cols,80                                ;@C02
  348.         .endif                                                          ;@C02
  349.         .if     <es:[di].env_rows eq 0> ; for vdm direct call           ;@C02
  350.             mov      es:[di].env_rows,25                                ;@C02
  351.         .endif                                                          ;@C02
  352.         mov     ax,es:[di].env_funcindx
  353.         .if     <zero ax>               ; For mark© in vdm session, ;@C02
  354.                                         ; confirm its content.          ;@C02
  355.             .if     <es:[di].viops_FormatID eq WorldFormat>             ;@C02
  356.                 mov     ax,WorldFmtIndx                                 ;@C02
  357.             .elseif <bit <es:[di].viops_FormatID> and PSFormat>         ;@C02
  358.  
  359.                 .if     <es:[di].viops_FormatID eq 81h>                 ;@C02
  360.                     mov     al,1        ; epoch monochrome              ;@C02
  361.                 .else                                                   ;@C02
  362.                     mov     al,4        ; epoch color                   ;@C02
  363.                 .endif                                                  ;@C02
  364.                 mov     es:[di].env_colors,al  ; set colors value       ;@C02
  365.  
  366.                 mov     ax,PSFmtIndx                                    ;@C02
  367.             .elseif <<es:[di].viops_CellByteSize> eq <ExtPSAttrCount+1>>;@C02
  368.                 mov     ax,ExtPSFmtIndx                                 ;@C02
  369.             .endif                                                      ;@C02
  370.         .endif                                                          ;@C02
  371.         mov     [bp].j_funcindx,ax
  372.         mov     [bp].j_dbcsstatus,0     ; clear bisecting flag
  373.  
  374. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  375.         xor     ah,ah                                                   ;;EPOCH ;; added for J-FUNC
  376.         mov     al, es:[di].env_colors  ; Get Colors value              ;;EPOCH ;; added for J-FUNC
  377.         mov     [bp].shadowColor,ax     ; Save Colors value             ;;EPOCH ;; added for J-FUNC
  378. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  379.         mov     ax,es:[di].viops_CellByteSize
  380.         mov     [bp].cellsize,ax
  381.  
  382.         mov     ax,word ptr es:[di+2].viops_lpNLSExt
  383.         .if     <nonzero ax>            ; prepared                  ;@B01
  384.             verw    ax                  ; verify selector           ;@B01
  385.             .if     <nz>                                            ;@B01
  386.                 push    ax                                          ;@B01
  387.                 call    DOSGETSEG                                   ;@B01
  388.             .endif                                                  ;@B01
  389.         .endif                                                      ;@B01
  390.  
  391.         mov     word ptr [bp+2].lpNLSExt,ax
  392.         mov     ax,word ptr es:[di].viops_lpNLSExt   ; get the pointer to nls exteded env.
  393.         mov     word ptr [bp].lpNLSExt,ax
  394.  
  395.         mov     [bp].flgDBCS,0          ;/set dbcs flag
  396.                                         ; 0         : there is no dbcs.
  397.                                         ; otherwize : one or more dbcs exist(s).
  398.  
  399. ;@C01   .if     <<es:[di].env_DBCSEvBuff>  ne 0> or
  400. ;@C01       or      [bp].flgDBCS,defaultDBCS
  401. ;@C01   .if     <<es:[di].env_DBCSEvBuff1> ne 0> or
  402. ;@C01   .if     <<es:[di].env_DBCSEvBuff2> ne 0> or
  403. ;@C01   .if     <<es:[di].env_DBCSEvBuff3> ne 0>
  404. ;@C01       or      [bp].flgDBCS,AvioDBCS
  405. ;@C01   .endif
  406.  
  407.         push    es                                                          ;@C01
  408.         push    di                                                          ;@C01
  409.         les     di, [bp].lpNLSExt       ; ES:DI -> nls extension area in    ;@C01
  410.                                         ; the environment buffer            ;@C01
  411.  
  412.         .if     <<es:[di].dbcsenvinfo_DBCSVector>  ne 0> or                 ;@C01
  413.             or      [bp].flgDBCS,defaultDBCS                                ;@C01
  414.             add     di,DBCSEvBufSiz+4   ; see the next structure            ;@C01
  415.         .if     <<es:[di].dbcsenvinfo_DBCSVector> ne 0> or                  ;@C01
  416.             add     di,DBCSEvBufSiz+4   ; see the next structure            ;@C01
  417.         .if     <<es:[di].dbcsenvinfo_DBCSVector> ne 0> or                  ;@C01
  418.             add     di,DBCSEvBufSiz+4   ; see the next structure            ;@C01
  419.         .if     <<es:[di].dbcsenvinfo_DBCSVector> ne 0>                     ;@C01
  420.             or      [bp].flgDBCS,AvioDBCS                                   ;@C01
  421.         .endif                                                              ;@C01
  422.         pop     di                                                          ;@C01
  423.         pop     es                                                          ;@C01
  424.  
  425. ENDIF ;D1348
  426.  
  427. IFDEF EPOCH                                                             ;;EPOCH ;; added for J-FUNC
  428.         mov     ax,word ptr es:[di].viops_FormatID                      ;;EPOCH ;; added for J-FUNC
  429.         and     al,0fh                                                  ;;EPOCH ;; added for J-FUNC
  430.         mov     word ptr [bp].shadowFMTID,ax                            ;;EPOCH ;; added for J-FUNC
  431. ENDIF                                                                   ;;EPOCH ;; added for J-FUNC
  432.         push    WDHGSEG                                                 ;@T52
  433.         pop     ds                      ; @S23
  434.         lds     bx,ds:bvh_instance      ;                               ;@T52
  435.         mov     [bx].wdhi_pssel,es      ; @S23 Save PS selector in instance data
  436.  
  437.         add     di, env_mdlen           ; ES:DI -> mode data structure
  438.         mov     ax, ERROR_VIO_MODE      ; Preset invalid mode error
  439.  
  440.         lds     si, [bp].ParmBuf        ; DS:SI -> parameter buffer
  441. IFDEF D1348
  442.         mov     ax,[si].Flags
  443.         mov     [bp].shadow_Flags,ax
  444. ENDIF ;D1348
  445.         mov     ax, ERROR_VIO_INVALID_LENGTH ; Preset error code
  446.         .if     <[si].ParmLength ae LogicalBufSel+2> NEAR  ; Valid parm length? @P1
  447.             mov     ax, ERROR_VIO_INVALID_PARMS ; Preset error code
  448.             test    [si].Flags, RESERVED_FLAGS ; 
  449.             .if     <z>                         AND ; Valid reserved flags?
  450.             .if     <[bp].FuncNumHi e 0>        AND ; Correct function #?
  451.             .if     <[bp].FuncNumLo e FUNC_NUM> AND ; 
  452.             .if     <[si].FuncIndex be MAX_INDEX> ; Invalid index?
  453.  
  454.                 sub     ax, ax          ; Clear return code
  455.                 push    ds
  456.                 push    si
  457.                 push    es
  458.                 push    di
  459.  
  460.                 cld
  461.                 mov     bx, [si].FuncIndex
  462.                 shl     bx, 1           ; Word align jump table
  463.                 call    cs:DispTbl[bx]  ; Dispatch to handler
  464.  
  465. ;/*
  466. ;**   Start of window specific code
  467. ;*/
  468.  
  469.                 pop     di
  470.                 pop     es
  471.                 pop     si
  472.                 pop     ds
  473.  
  474.                 .if     <zero ax>
  475.                     mov     dx,[si].vp_index ;Get the subroutine index
  476.                     sub     bx,bx
  477.  
  478.                     .if     <dl ae sx_ScrollUp> and
  479.                     .if     <dl be sx_WriteNCell> ;Update window
  480.                         Call    SecureSema4
  481.  
  482. IFDEF D1348 ;DBCS BufferUpdate (bisecting DBCS character status)
  483.                         mov     ax,[bp].j_dbcsstatus
  484.                         mov     es:[bx].env_dbcsstatus,ax
  485. ENDIF ;D1348
  486.  
  487.                         .if     <dl ae sx_WriteCellStr> ;Writing
  488.                             .if     <dl e sx_WriteCellStr> ;Writing     ;@B55
  489.                                mov     ax,[si].vp_repeatlength          ;@B55
  490.                                shr     ax,1                             ;@B55
  491.                                .if <<es:[bx].viops_CellByteSize> eq <WorldCellSize>>    ;;KY03A
  492. ;; alternative (same meaning)  .if <<es:[bx].viops_CellByteSize> eq <ExtPSCellSize>>    ;;KY03A
  493.                                         shr     ax,1                            ;;KY03A
  494.                                .endif                                           ;;KY03A
  495.                                mov     [si].vp_repeatlength,ax          ;@B55
  496.                             .endif                                      ;@B55
  497.                             Call    CharStr
  498.                         .else           ;Scrolling
  499.                             Call    WinScroll
  500.                         .endif
  501.  
  502.                         Call    ReleaseSema4
  503.                         sub     ax,ax
  504.                     .endif
  505.                 .endif
  506.  
  507. ;/*
  508. ;**  End of window specific code
  509. ;*/
  510.  
  511.             .endif
  512.         .endif
  513.  
  514.         mov     [bp-2], ax
  515.         pop     es
  516.         pop     ds
  517.         popa
  518.         pop     bp
  519.         add     sp, bottomdest          ; Deallocate local storage
  520.  
  521.         ret     12
  522.  
  523. BUFFERUPDATE ENDP
  524.  
  525. ;/****************************************************************************
  526. ;*
  527. ;* FUNCTION NAME = DummyLVBToPVB
  528. ;*
  529. ;* DESCRIPTION   =
  530. ;*
  531. ;*      DummyLVBToPVB replaces the function LVBToPVB.  The LVBToPVB copies
  532. ;*      a rectangle from the LVB onto the PVB.  Since the LVB == PVB for
  533. ;*      the windowed VDH, this function is a NOP.
  534. ;*
  535. ;* INPUT         = NONE
  536. ;* OUTPUT        = NONE
  537. ;*
  538. ;* RETURN-NORMAL = AX = 0
  539. ;* RETURN-ERROR  = NONE
  540. ;*
  541. ;****************************************************************************/
  542.  
  543.                 PUBLIC  DummyLVBToPVB                           ;@P1 begin
  544. DummyLVBToPVB   PROC                                            ; 
  545.                                                                 ; 
  546.         xor     ax,ax                   ; return good error code;
  547.         ret                                                     ; 
  548.                                                                 ; 
  549. DummyLVBToPVB   ENDP                                            ;@P1 end
  550.  
  551.  
  552. ;/****************************************************************************
  553. ;*
  554. ;* FUNCTION NAME = SetGenParms
  555. ;*
  556. ;* DESCRIPTION   = Set general parameters used by all buffer update functions
  557. ;*
  558. ;*      SetGenParms sets up basic information relating to LVB substitution.
  559. ;*      The routine sets up the boundaries for the write based on whether
  560. ;*      the LVB has been superceeded by passed parameters.
  561. ;*
  562. ;* INPUT         = SS:BP - local data storage area
  563. ;*                 DS:SI - user passed parameter block
  564. ;*                 ES:DI - mode data structure
  565. ;*
  566. ;* OUTPUT       AX - index of right most row in LVB
  567. ;*              CX - index of bottom most column in LVB
  568. ;*              [bp].minrow - index of top most row in LVB (PVB coordinates)
  569. ;*              [bp].mincol - index of left most col in LVB (PVB coordinates)
  570. ;*              [bp].maxrow - index of bottom most row in LVB (PVB coordinates)
  571. ;*              [bp].maxcol - index of right most col in LVB (PVB coordinates)
  572. ;*              [bp].lvb_width - width of the LVB in cells
  573. ;*              [bp].lvb_height - height of the LVB in cells
  574. ;*
  575. ;*      CALLS   none
  576. ;*
  577. ;*      USES    AX,CX,DX,FLAGS
  578. ;*
  579. ;*      NOTES
  580. ;*
  581. ;*  PSEUDOCODE
  582. ;*
  583. ;*      PVB_SEL = 0
  584. ;*      LVB_SEL = parmLVB
  585. ;*      cellsize = VioPSCellByteSize
  586. ;*
  587. ;*      if (parmlength >= LVBHeight)
  588. ;*          mincol = parmLVBColOff
  589. ;*          maxcol = parmLVBWidth + mincol
  590. ;*          minrow = parmLVBRowOff
  591. ;*          maxrow = parmLVBHeight + minrow
  592. ;*          lvb_width = parmLVBWidth
  593. ;*          lvb_height = parmLVBHeight
  594. ;*          if (parmlength >= LVBAttrCount)
  595. ;*              if (parmAttrCount == 3)
  596. ;*                  cellsize = 4
  597. ;*              else
  598. ;*                  cellsize = 2
  599. ;*      else
  600. ;*          mincol = 0
  601. ;*          maxcol = modeCols - 1
  602. ;*          minrow = 0
  603. ;*          maxrow = modeRows - 1
  604. ;*          lvb_width = modeCols
  605. ;*          lvb_height = modeRows
  606. ;*          cellsize = modeattrcnt + 1
  607. ;*
  608. ;* RETURN-NORMAL = AX = 0
  609. ;* RETURN-ERROR  = NONE
  610. ;*
  611. ;****************************************************************************/
  612.  
  613.                 PUBLIC  SetGenParms                             ;@P1 begin
  614. SetGenParms     PROC
  615.  
  616.         mov     [bp].PVB_Sel,0          ; do not use PVB selector
  617.         mov     ax, [si].LogicalBufSel  ; use LVB selector
  618.         mov     [bp].LVB_Sel,ax         ; save the LVB selector
  619.  
  620.         mov     ax,es:viops_CellByteSize
  621.         mov     [bp].cellsize,ax
  622.  
  623.         cmp     ds:[si].ParmLength,LVBFormatID  ; Did the caller specify LVB info?
  624.         .if     <ae>                        ;   Yes, use callers information
  625.             mov     cx,ds:[si].LVBColOff    ; (cx) = left most column
  626.             mov     [bp].mincol,cx          ; store left most column
  627.             mov     dx,ds:[si].LVBWidth     ; (dx) = number of columns
  628.             mov     [bp].lvb_width,dx       ; store number of columns
  629.             add     cx,dx                   ; (cx) = right most column + 1
  630.             dec     cx                      ; (cx) = right most column
  631.             mov     [bp].maxcol,cx          ; store right most column
  632.             mov     ax,ds:[si].LVBRowOff    ; (ax) = top most row
  633.             mov     [bp].minrow,ax          ; store top most row
  634.             mov     dx,ds:[si].LVBHeight    ; (dx) = number of rows
  635.             mov     [bp].lvb_height,dx      ; store number of rows
  636.             add     ax,dx                   ; (ax) = bottom most row + 1
  637.             dec     ax                      ; (ax) = bottom most row
  638.             mov     [bp].maxrow,ax          ; store bottom most row
  639.             cmp     ds:[si].ParmLength,LVBAttrCount + 1 ; Is the parm present?
  640.             .if     <ae> and near           ;   Yes, attribute count is included
  641.             cmp     word ptr ds:[si].LVBFormatID,WorldFMTATTR   ; Special format?
  642. IFDEF D1348 ;support format ID 00h, attr count 3. (un-necessary ?)
  643.             .if     <e> or near             ;   Yes, use three byte attributes
  644.             cmp     word ptr ds:[si].LVBFormatID,ExtPSFMTATTR
  645. ENDIF ;D1348
  646.             .if     <e> near                ;   Yes, use three byte attributes
  647.                 mov     [bp].cellsize,WorldCellSize
  648.             .else
  649.                 mov     [bp].cellsize,DefaultCellSize
  650.             .endif
  651.         .else                               ; Use default screen group information
  652.             mov     [bp].mincol,0           ; store left most column
  653.             mov     cx,es:[di].TextCols     ; (ax) = number of columns
  654.             mov     [bp].lvb_width,cx       ; store number of columns
  655.             dec     cx                      ; (ax) = right most column
  656.             mov     [bp].maxcol,cx          ; store right most column
  657.             mov     [bp].minrow,0           ; store top most row
  658.             mov     ax,es:[di].TextRows     ; (ax) = number of rows
  659.             mov     [bp].lvb_height,ax      ; store number of rows
  660.             dec     ax                      ; (ax) = bottom most row
  661.             mov     [bp].maxrow,ax          ; store bottom most row
  662.             cmp     [bp].cellsize,ExtAttrib ; clear carry if extended attr @C19
  663.         .endif
  664.  
  665.         ret
  666.  
  667. SetGenParms     ENDP                                            ;@P1 end
  668.  
  669. R2CSEG  ENDS
  670.         END
  671.  
  672.