home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / XGASUBAX.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  49KB  |  1,274 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. ;       SCCSID = @(#)xgasubax.asm       6.1 91/04/26
  13. IFDEF D1348 ;DBCS bits handling routines
  14.  
  15. ; ****************************************************************************
  16. ; *                                                                          *
  17. ; *                                                                          *
  18. ; *                                                                          *
  19. ; ****************************************************************************
  20.         PAGE    60,132
  21.         TITLE   XGASUBAX.ASM -- BufferUpdate SubRoutine for DBCS Code Page
  22.  
  23. ;********************** START OF SPECIFICATIONS ****************************
  24. ;*                                                                         *
  25. ;* SOURCE FILE NAME:    XGASUBAX.ASM                                       *
  26. ;*                                                                         *
  27. ;* DESCRIPTIVE NAME:    BUFFERUPDATE subroutine for DBCS Codepage          *
  28. ;*                                                                         *
  29. ;* COPYRIGHT:   na                                                         *
  30. ;*                                                                         *
  31. ;* STATUS:      OS/2 version 2.0                                           *
  32. ;*                                                                         *
  33. ;* CHANGE HISTORY:                                                         *
  34. ;*                                                                         *
  35. ;* NOTES:       Ring 2 conforming code segment                             *
  36. ;*                                                                         *
  37. ;*    DEPENDENCIES:     None                                               *
  38. ;*                                                                         *
  39. ;*    RESTRICTIONS:     None                                               *
  40. ;*                                                                         *
  41. ;*    PATH LABEL:       na                                                 *
  42. ;*                                                                         *
  43. ;* ENTRY POINTS:        WriteCellStrWrld, WriteCharStrWrld, WriteNCharWrld *
  44. ;*                      WriteCharStrAttrWrld, WriteNAttrWrld,WriteNCellWrld*
  45. ;*                      ReadCharStrWrld, ReadCellStrWrld, MoveUpLeftWrld   *
  46. ;*                      MoveDownRightWrld, ReadCellTypesWrld, UBCellToLVB3 *
  47. ;*                      UBCharToLVB3, UBCharAttToLVB3, UBNCharToLVB3       *
  48. ;*                      UBNAttToLVB3, UBNCellToLVB3, LVBCharToUB3          *
  49. ;*                      LVBCellToUB3, LVBCellToLVB3I, LVBCellToLVB3D       *
  50. ;*                      LVBCharTypeToUB3                                   *
  51. ;*                                                                         *
  52. ;*                                                                         *
  53. ;* EXTERNAL REFERENCES: LocateBuffAddr  (in XGAREAD.ASM)                   *
  54. ;*                                                                         *
  55. ;********************** END OF SPECIFICATIONS ******************************
  56.  
  57.         .286c                           ; 286 protect mode instructions
  58.  
  59.         .xlist
  60.         INCLUDE struc.inc               ; Structure macro
  61.         INCLUDE pmwinx.inc              ; for check dbcs range
  62.         INCLUDE pmaviop.inc             ; for check dbcs range
  63.         INCLUDE vdhstruc.inc            ; Buffer update data structures
  64.         INCLUDE vdhequ.inc              ; Buffer update equates
  65.         .list
  66.  
  67. IFDEF EPOCH
  68.         EXTRN   Translate:NEAR
  69. ENDIF
  70.  
  71. R2CSEG  SEGMENT WORD    PUBLIC 'CODE'
  72.         ASSUME  CS:R2CSEG,DS:NOTHING,ES:NOTHING
  73.  
  74. WrtCellStrTbl   dw      offset r2cseg:UBCellToLVB1      ; DefaultFMTATTR
  75.                 dw      offset r2cseg:UBCellToLVB3      ; WorldFMTATTR
  76. IFDEF EPOCH
  77.                 dw      offset r2cseg:UBCellToLVB1E     ; PSFMTATTR
  78. ELSE
  79.                 dw      offset r2cseg:UBCellToLVB1      ; PSFMTATTR
  80. ENDIF
  81.                 dw      offset r2cseg:UBCellToLVB3      ; ExtPSFMTATTR
  82.  
  83. WrtCharStrTbl   dw      offset r2cseg:UBCharToLVB1      ; DefaultFMTATTR
  84.                 dw      offset r2cseg:UBCharToLVB3      ; WorldFMTATTR
  85. IFDEF EPOCH
  86.                 dw      offset r2cseg:UBCharToLVB1E     ; PSFMTATTR
  87. ELSE
  88.                 dw      offset r2cseg:UBCharToLVB1      ; PSFMTATTR
  89. ENDIF
  90.                 dw      offset r2cseg:UBCharToLVB3      ; ExtPSFMTATTR
  91.  
  92. WrtCharStrAttTbl dw     offset r2cseg:UBCharAttToLVB1   ; DefaultFMTATTR
  93.                 dw      offset r2cseg:UBCharAttToLVB3   ; WorldFMTATTR
  94. IFDEF EPOCH
  95.                 dw      offset r2cseg:UBCharAttToLVB1E  ; PSFMTATTR
  96. ELSE
  97.                 dw      offset r2cseg:UBCharAttToLVB1   ; PSFMTATTR
  98. ENDIF
  99.                 dw      offset r2cseg:UBCharAttToLVB3   ; ExtPSFMTATTR
  100.  
  101. WrtNCharTbl     dw      offset r2cseg:UBNCharToLVB1     ; DefaultFMTATTR
  102.                 dw      offset r2cseg:UBNCharToLVB3     ; WorldFMTATTR
  103. IFDEF EPOCH
  104.                 dw      offset r2cseg:UBNCharToLVB1E    ; PSFMTATTR
  105. ELSE
  106.                 dw      offset r2cseg:UBNCharToLVB1     ; PSFMTATTR
  107. ENDIF
  108.                 dw      offset r2cseg:UBNCharToLVB3     ; ExtPSFMTATTR
  109.  
  110. WrtNAttrTbl     dw      offset r2cseg:UBNAttToLVB1      ; DefaultFMTATTR
  111.                 dw      offset r2cseg:UBNAttToLVB3      ; WorldFMTATTR
  112. IFDEF EPOCH
  113.                 dw      offset r2cseg:UBNAttToLVB1E     ; PSFMTATTR
  114. ELSE
  115.                 dw      offset r2cseg:UBNAttToLVB1      ; PSFMTATTR
  116. ENDIF
  117.                 dw      offset r2cseg:UBNAttToLVB3      ; ExtPSFMTATTR
  118.  
  119. WrtNCellTbl     dw      offset r2cseg:UBNCellToLVB1     ; DefaultFMTATTR
  120.                 dw      offset r2cseg:UBNCellToLVB3     ; WorldFMTATTR
  121. IFDEF EPOCH
  122.                 dw      offset r2cseg:UBNCellToLVB1E    ; PSFMTATTR
  123. ELSE
  124.                 dw      offset r2cseg:UBNCellToLVB1     ; PSFMTATTR
  125. ENDIF
  126.                 dw      offset r2cseg:UBNCellToLVB3     ; ExtPSFMTATTR
  127.  
  128. ReadCharStrTbl  dw      offset r2cseg:LVBCharToUB1      ; DefaultFMTATTR
  129.                 dw      offset r2cseg:LVBCharToUB3      ; WorldFMTATTR
  130. IFDEF EPOCH
  131.                 dw      offset r2cseg:LVBCharToUB1E     ; PSFMTATTR
  132. ELSE
  133.                 dw      offset r2cseg:LVBCharToUB1      ; PSFMTATTR
  134. ENDIF
  135.                 dw      offset r2cseg:LVBCharToUB3      ; ExtPSFMTATTR
  136.  
  137. ReadCellStrTbl  dw      offset r2cseg:LVBCellToUB1      ; DefaultFMTATTR
  138.                 dw      offset r2cseg:LVBCellToUB3      ; WorldFMTATTR
  139. IFDEF EPOCH
  140.                 dw      offset r2cseg:LVBCellToUB1E     ; PSFMTATTR
  141. ELSE
  142.                 dw      offset r2cseg:LVBCellToUB1      ; PSFMTATTR
  143. ENDIF
  144.                 dw      offset r2cseg:LVBCellToUB3      ; ExtPSFMTATTR
  145.  
  146. MoveUpLfTbl     dw      offset r2cseg:LVBCellToLVB1I    ; DefaultFMTATTR
  147.                 dw      offset r2cseg:LVBCellToLVB3I    ; WorldFMTATTR
  148. IFDEF EPOCH
  149.                 dw      offset r2cseg:LVBCellToLVB1IE   ; PSFMTATTR
  150. ELSE
  151.                 dw      offset r2cseg:LVBCellToLVB1I    ; PSFMTATTR
  152. ENDIF
  153.                 dw      offset r2cseg:LVBCellToLVB3I    ; ExtPSFMTATTR
  154.  
  155. MoveDnRtTbl     dw      offset r2cseg:LVBCellToLVB1D    ; DefaultFMTATTR
  156.                 dw      offset r2cseg:LVBCellToLVB3D    ; WorldFMTATTR
  157. IFDEF EPOCH
  158.                 dw      offset r2cseg:LVBCellToLVB1DE   ; PSFMTATTR
  159. ELSE
  160.                 dw      offset r2cseg:LVBCellToLVB1D    ; PSFMTATTR
  161. ENDIF
  162.                 dw      offset r2cseg:LVBCellToLVB3D    ; ExtPSFMTATTR
  163.  
  164. CellTypesTbl    dw      offset r2cseg:LVBCharTypeToUB1  ; DefaultFMTATTR
  165.                 dw      offset r2cseg:LVBCharTypeToUB3  ; WorldFMTATTR
  166. IFDEF EPOCH
  167.                 dw      offset r2cseg:LVBCharTypeToUB1E ; PSFMTATTR
  168. ELSE
  169.                 dw      offset r2cseg:LVBCharTypeToUB1  ; PSFMTATTR
  170. ENDIF
  171.                 dw      offset r2cseg:LVBCharTypeToUB3  ; ExtPSFMTATTR
  172.  
  173.  
  174.  
  175. ;Entry
  176. ;  ds:si - user cells pointer
  177. ;  es:di - LVB pointer
  178. ;  cx    - cell length (in byte)
  179.  
  180. WriteCellStrWrld   proc    near
  181. public  WriteCellStrWrld
  182.  
  183.         mov     bx,[bp].j_funcindx
  184.         jmp     cs:WrtCellStrTbl[bx]
  185.  
  186. WriteCellStrWrld   endp
  187.  
  188.  
  189. ;Entry
  190. ;  ds:si - user chars pointer
  191. ;  es:di - LVB pointer
  192. ;  cx    - char length (in byte)
  193.  
  194. WriteCharStrWrld   proc    near
  195. public  WriteCharStrWrld
  196.  
  197.         mov     bx,[bp].j_funcindx
  198.         jmp     cs:WrtCharStrTbl[bx]
  199.  
  200. WriteCharStrWrld   endp
  201.  
  202.  
  203. ;Entry
  204. ;  ah    - 1st attribute
  205. ;  dl    - 2nd attribute (if WorldFormat)
  206. ;  dh    - system byte   (if WorldFormat)
  207. ;  ds:si - user chars pointer
  208. ;  es:di - LVB pointer
  209. ;  cx    - char length (in byte)
  210.  
  211. WriteCharStrAttrWrld proc  near
  212. public  WriteCharStrAttrWrld
  213.  
  214.         mov     bx,[bp].j_funcindx
  215.         jmp     cs:WrtCharStrAttTbl[bx]
  216.  
  217. WriteCharStrAttrWrld endp
  218.  
  219.  
  220. ;Entry
  221. ;  al    - leading character or SBCS character
  222. ;  ah    - trailing character
  223. ;  es:di - LVB pointer
  224. ;  cx    - char count
  225.  
  226. WriteNCharWrld     proc    near
  227. public  WriteNCharWrld
  228.  
  229.         mov     bx,[bp].j_funcindx
  230.         jmp     cs:WrtNCharTbl[bx]
  231.  
  232. WriteNCharWrld     endp
  233.  
  234.  
  235. ;Entry
  236. ;  al    - 1st attribute
  237. ;  ds:si - 2nd attribute pointer
  238. ;  es:di - LVB pointer
  239. ;  cx    - attr count
  240.  
  241. WriteNAttrWrld     proc    near
  242. public  WriteNAttrWrld
  243.  
  244.         mov     bx,[bp].j_funcindx
  245.         jmp     cs:WrtNAttrTbl[bx]
  246.  
  247. WriteNAttrWrld     endp
  248.  
  249.  
  250. ;Entry
  251. ;  al    - character
  252. ;  ah    - 1st attribute
  253. ;  ds:si - Trailing byte character or 2nd attribute pointer
  254. ;  es:di - LVB pointer
  255. ;  cx    - cell count
  256.  
  257. WriteNCellWrld     proc    near
  258. public  WriteNCellWrld
  259.  
  260.         mov     bx,[bp].j_funcindx
  261.         jmp     cs:WrtNCellTbl[bx]
  262.  
  263. WriteNCellWrld     endp
  264.  
  265.  
  266. ;Entry
  267. ;  ds:si - LVB pointer
  268. ;  es:di - user buffer pointer
  269. ;  cx    - char length (in byte)
  270.  
  271. ReadCharStrWrld    proc    near
  272. public  ReadCharStrWrld
  273.  
  274.         mov     bx,[bp].j_funcindx
  275.         jmp     cs:ReadCharStrTbl[bx]
  276.  
  277. ReadCharStrWrld    endp
  278.  
  279.  
  280. ;Entry
  281. ;  ds:si - LVB pointer
  282. ;  es:di - user buffer pointer
  283. ;  cx    - cell length (in byte) / 2
  284.  
  285. ReadCellStrWrld    proc    near
  286. public  ReadCellStrWrld
  287.  
  288.         mov     bx,[bp].j_funcindx
  289.         jmp     cs:ReadCellStrTbl[bx]
  290.  
  291. ReadCellStrWrld    endp
  292.  
  293.  
  294. ;Entry
  295. ;  ds:si - source LVB pointer
  296. ;  es:di - destination LVB pointer
  297. ;  cx    - cell length (in byte) / 2
  298. ;  dx    - reserved
  299.  
  300. MoveUpLeftWrld     proc    near
  301. public  MoveUpLeftWrld
  302.  
  303.         mov     bx,[bp].j_funcindx
  304.         jmp     cs:MoveUpLfTbl[bx]
  305.  
  306. MoveUpLeftWrld     endp
  307.  
  308.  
  309. ;Entry
  310. ;  ds:si - source LVB pointer
  311. ;  es:di - destination pointer
  312. ;  cx    - cell length (in byte) / 2
  313. ;  dx    - reserved
  314.  
  315. MoveDownRightWrld  proc    near
  316. public  MoveDownRightWrld
  317.  
  318.         mov     bx,[bp].j_funcindx
  319.         jmp     cs:MoveDnRtTbl[bx]
  320.  
  321. MoveDownRightWrld  endp
  322.  
  323.  
  324. ; support CheckCharType of DBCS
  325. ;Entry
  326. ;  ds:si - LVB pointer
  327. ;  es:di - user buffer pointer
  328.  
  329. ReadCellTypesWrld  proc    near
  330. public  ReadCellTypesWrld
  331.  
  332.         mov     bx,[bp].j_funcindx
  333.         jmp     cs:CellTypesTbl[bx]
  334.  
  335. ReadCellTypesWrld  endp
  336.  
  337.  
  338. ;  SetSystemByte
  339. ;
  340. ;       maintain the DBCS and trail byte flags in the system byte.
  341. ;       arguments are used to obtain the system byte to be modified.
  342. ;
  343. ;
  344. ;       INPUT
  345. ;               AL  -  Character to be Tested for lead byte range
  346. ;               DH  -  Previous Character first byte of DBCS status
  347. ;                      (return value of previous macro invocation)
  348. ;       USES
  349. ;               DX  -  to maintain the Lead/TrailByte State information
  350. ;
  351. ;       RETURNS
  352. ;               AX  -  [copied 2nd attribute (AL) and] New SystemByte (AH)
  353. ;               DH  -  1 if character first byte of DBCS
  354. ;
  355. ;       ALGORITHM
  356. ;
  357. ;
  358. ;           if( LeadingByte )
  359. ;               ThisIsLeadByteFlag = 1
  360. ;           if( PrevWasLeadByteFlag )
  361. ;               ThisIsLeadByteFlag = 0
  362. ;
  363. ;           <process attribute>
  364. ;
  365. ;           system byte = ThisIsLeadByteFlag
  366. ;           swap( ThisIsLeadByteFlag, PrevWasLeadByteFlag )
  367. ;           system byte |= ThisIsLeadByteFlag
  368. ;                       { which is true if PREV was lead byte }
  369. ;
  370. ;
  371. SetSystemByte macro  instruction
  372.  
  373.         xor     dl,dl           ; DL = 0
  374.         push    ds
  375.         push    si
  376.         CheckLeadByte           ; Cy set if leading byte in AL
  377.         pop     si
  378.         pop     ds
  379.         adc     dl,dl           ; DL = 1 if this was leading byte
  380.  
  381.         IFNB <instruction>
  382.                 &instruction    ; optional code to load AH (or AX)
  383.         ENDIF
  384.                                 ; [AL = 2nd attr,] AH = system byte
  385.         mov     ah,dl           ; set DBCS bit in system byte
  386.         or      ah,dh           ; " " " if previous was lead_byte
  387.         sub     dl,dh           ; dl = 0 if previous was leading byte already
  388.         adc     dl,0
  389.         xchg    dl,dh           ; save dl for next char, use dh now
  390.         ror     dl,1            ; rotate to get tail_byte bit 0 into bit 7
  391.         or      ah,dl           ; or TrailBYTE bit into system byte
  392.  
  393.         endm
  394.  
  395.  
  396. Erase1  macro
  397.         local   er1_end
  398.  
  399.         cmp     di,0                    ; first cell ?
  400.         jbe     er1_end                 ; exit if yes
  401.  
  402.         test    byte ptr es:[di+3],TrailByteFlag
  403.         jz      er1_end                 ; exit if not
  404.  
  405.         mov     byte ptr es:[di-4],CharBlank ; fill blank in this cell
  406. ;@A04   mov     byte ptr es:[di-1],SBCS_BYTE ; and clear trailbyte bit
  407.         and     byte ptr es:[di-1],NOT DBCSFlag+TrailByteFlag ; and clear    ;@A04
  408.                                                               ; trailbyte bit;@A04
  409.         or      [bp].j_dbcsstatus,BisectDBCS_START
  410.  
  411. er1_end:
  412.         endm
  413.  
  414. Erase1x macro
  415.         local   er1x_end, er1x
  416.  
  417.         cmp     di,0                    ; first cell ?
  418.         jbe     er1x_end                ; exit if yes
  419.  
  420.         push    ds                      ; save source selector
  421.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  422.  
  423.         test    byte ptr ds:[di+1],TrailByteFlag
  424.         jz      er1x                    ; exit if not
  425.  
  426.         mov     byte ptr es:[di-2],CharBlank ; copy blank into this cell
  427. ;@A04   mov     byte ptr es:[di-1],SBCS_BYTE ; and clear trailbyte bit
  428.         and     byte ptr ds:[di-1],NOT DBCSFlag+TrailByteFlag ; and clear    ;@A04
  429.                                                               ; trailbyte bit;@A04
  430.         or      [bp].j_dbcsstatus,BisectDBCS_START
  431.  
  432. er1x:
  433.         pop     ds                      ; restore source selector
  434. er1x_end:
  435.         endm
  436.  
  437.  
  438. Erase2  macro
  439.         local   er2_end
  440.  
  441.         cmp     di,[bp].j_lvbsize       ; outside LVB
  442.         jae     er2_end                 ; skip if yes
  443.  
  444.         test    byte ptr es:[di+3],TrailByteFlag
  445.         jz      er2_end                 ; skip if not
  446.  
  447.         mov     byte ptr es:[di],CharBlank   ; copy blank into this cell
  448. ;@A04   mov     byte ptr es:[di+3],SBCS_BYTE ; and clear trailbyte bit
  449.         and     byte ptr es:[di+3],NOT DBCSFlag+TrailByteFlag ; and clear    ;@A04
  450.                                                               ; trailbyte bit;@A04
  451.         or      [bp].j_dbcsstatus,BisectDBCS_LAST
  452.  
  453. er2_end:
  454.         endm
  455.  
  456. Erase2x macro
  457.         local   er2x_end, er2x
  458.  
  459.         cmp     di,[bp].j_lvbsize       ; outside LVB
  460.         jae     er2x_end                ; skip if yes
  461.  
  462.         push    ds                      ; save source selector
  463.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  464.  
  465.         test    byte ptr ds:[di+1],TrailByteFlag
  466.         jz      er2x                    ; skip if not
  467.  
  468.         mov     byte ptr es:[di],CharBlank   ; copy blank into this cell
  469. ;@A04   mov     byte ptr es:[di+1],SBCS_BYTE ; and clear trailbyte bit
  470.         and     byte ptr ds:[di+1],NOT DBCSFlag+TrailByteFlag ; and clear    ;@A04
  471.                                                               ; trailbyte bit;@A04
  472.         or      [bp].j_dbcsstatus,BisectDBCS_LAST
  473.  
  474. er2x:
  475.         pop     ds                      ; restore source selector
  476. er2x_end:
  477.         endm
  478.  
  479.  
  480. Erase5  macro
  481.         local   er5_end
  482.  
  483.         test    byte ptr [si+3],TrailByteFlag ; CF = 0
  484.         jz      er5_end                 ; exit if not
  485.  
  486.         mov     al,CharBlank            ; AL = blank
  487.         stc                             ; CF set if was trailing byte
  488.  
  489. er5_end:
  490.         endm
  491.  
  492. Erase5x macro
  493.         local   er5x_end
  494.  
  495.         push    ds                      ; save source selector
  496.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  497.  
  498.         test    byte ptr ds:[si+1],TrailByteFlag ; CF = 0
  499.         jz      er5x_end                ; exit if not
  500.  
  501.         mov     al,CharBlank            ; AL = blank
  502.         stc                             ; CF set if was trailing byte
  503.  
  504. er5x_end:
  505.         pop     ds                      ; restore source selector
  506.         endm
  507.  
  508.  
  509. Erase6  macro
  510.         local   er6_end
  511.  
  512.         test    byte ptr [si+3],DBCSFlag; CF = 0
  513.         jz      er6_end                 ; exit if not DBCS
  514.  
  515.         test    byte ptr [si+3],TrailByteFlag
  516.         jnz     er6_end                 ; exit if trail byte
  517.  
  518.         mov     al,CharBlank            ; AL = blank
  519.         stc                             ; CF set if was lead byte
  520.  
  521. er6_end:
  522.         endm
  523.  
  524. Erase6x macro
  525.         local   er6x_end
  526.  
  527.         push    ds                      ; save source selector
  528.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  529.  
  530.         test    byte ptr ds:[si+1],DBCSFlag     ; CF = 0
  531.         jz      er6x_end                ; exit if not DBCS
  532.  
  533.         test    byte ptr ds:[si+1],TrailByteFlag
  534.         jnz     er6x_end                ; exit if trail byte
  535.  
  536.         mov     al,CharBlank            ; AL = blank
  537.         stc                             ; CF set if was lead byte
  538.  
  539. er6x_end:
  540.         pop     ds                      ; restore source selector
  541.         endm
  542.  
  543.  
  544. ;Entry
  545. ;  ds:si - user cells pointer
  546. ;  es:di - LVB pointer
  547. ;  cx    - cell length (in byte)
  548.  
  549.  
  550. UBCellToLVB3    PROC
  551.         public  UBCellToLVB3
  552.  
  553. ; check to see whether we are about to overwrite to a trailing byte
  554. ; and if so, erase preceding lead byte.
  555.         Erase1
  556.  
  557.         shr     cx,2                    ; convert bytes to number of cell
  558.         xor     dx,dx                   ; clear DH for use as flag in loop
  559.  
  560. ; write cells.
  561.         .repeat
  562.             mov     bx,word ptr es:[di] ; Save for restoring the previous ;@A00
  563.                                         ; cp & attr#1 for tail exception  ;@A00
  564.             lodsw                       ; AL = char, AH = 1st attribute
  565.             stosw                       ; write char and 1st attribute
  566.             mov     ah,byte ptr ds:[si] ; get attr#2(including lcid)      ;@A00
  567.             SetSystemByte <lodsw>       ; AL = 2nd attr, AH = system byte
  568.             stosw                       ; store 2nd attr and system byte
  569.         .loop
  570.  
  571. ; Check to see if the last char written was a lead byte, if so, erase
  572.         .if     <bit dh and 1>          ; last char copied was lead byte
  573. ;@A00       mov     byte ptr es:[di-4],CharBlank
  574. ;@A00                                   ; write a blank into the last character
  575. ;@A00       mov     byte ptr es:[di-1],SBCS_BYTE
  576. ;@A00                                   ; clear system byte
  577.             mov     word ptr es:[di-4],bx ; Undo                          ;@A00
  578.             shl     dh,1                                                  ;@A00
  579.         .endif
  580.  
  581. ; Check if next cell contains a trail byte, if so, erase
  582.         .if     <dh ne 2>               ; When dbcs 1st has been ignored, ;@A00
  583.                                         ; forget the exception handling.  ;@A00
  584.             Erase2
  585.         .endif                                                            ;@A00
  586.  
  587.         ret
  588. UBCellToLVB3    ENDP
  589.  
  590.  
  591. ;Entry
  592. ;  ds:si - user chars pointer
  593. ;  es:di - LVB pointer
  594. ;  cx    - char length (in byte)
  595.  
  596. UBCharToLVB3    PROC
  597.         public  UBCharToLVB3
  598.  
  599. ; check to see whether we are about to overwrite to a trailing byte
  600. ; and if so, erase preceding lead byte.
  601.         Erase1
  602.  
  603.         xor     dx,dx                   ; clear DH for use as flag in loop
  604.  
  605. ; write characters
  606.         .repeat
  607.             mov     bl,byte ptr es:[di] ; Save for restoring the previous cp.
  608.             mov     bh,byte ptr es:[di+3] ; Save for restoring the previous sys. byte ;@N1
  609.             lodsb                       ; copy char
  610.             stosb
  611.             xor     ah,ah               ; ignore attr#2(including lcid),
  612.                                         ; which means using a default
  613.                                         ; dbcs env. vector.
  614.             inc     di                  ; skip 1st attribute
  615.             SetSystemByte <mov ax,es:[di]>
  616.                                         ; AL = 2nd attr, AH = system byte
  617.             stosw                       ; store 2nd attr and system byte
  618.         .loop
  619.  
  620. ; Check to see if the last char written was a lead byte, if so, erase
  621.         .if     <bit dh and 1>          ; last char copied was lead byte
  622.             mov     byte ptr es:[di-4],bl ; undo ; restore the prev. cp.
  623.             mov     byte ptr es:[di-1],bh ; undo ; restore the prev. sys. byte. ;@N1
  624.             shl     dh,1
  625.         .endif
  626.  
  627. ; Check if next cell contains a trail byte, if so, erase
  628.         .if     <dh ne 2>               ; When dbcs 1st has been ignored,
  629.                                         ; forget the exception handling.
  630.             Erase2
  631.         .endif
  632.  
  633.         ret
  634. UBCharToLVB3    ENDP
  635.  
  636.  
  637. ;Entry
  638. ;  ah    - 1st attribute
  639. ;  dl    - 2nd attribute (if WorldFormat)
  640. ;  dh    - system byte   (if WorldFormat)
  641. ;  ds:si - user chars pointer
  642. ;  es:di - LVB pointer
  643. ;  cx    - char length (in byte)
  644.  
  645. UBCharAttToLVB3 PROC
  646.         public  UBCharAttToLVB3
  647.  
  648. ; check to see whether we are about to overwrite to a trailing byte
  649. ; and if so, erase preceding lead byte.
  650.         Erase1
  651.  
  652.         mov     bl,ah                   ; BL = 1st attribute
  653.         mov     bh,dl                   ; BH = 2nd attribute
  654.         xor     dx,dx                   ; clear DH for use as flag in loop
  655.  
  656. ; write characters and attributes
  657.         .repeat
  658.             mov     ax,word ptr es:[di]              ; save for retrieve ;@A01
  659.             mov     word ptr [bp].wSaveCpAttr1,ax                        ;@A01
  660.             mov     ax,word ptr es:[di+2]                                ;@A01
  661.             mov     word ptr [bp].wSaveAttr2Attr3,ax                     ;@A01
  662.             lodsb                       ; char = AL
  663.             mov     ah,bl               ; AH = first attribute
  664.             stosw                       ; write char and 1st attribute
  665.             mov     ah,bh               ; AH = attr #2(include lcid)    ;@A00
  666.             SetSystemByte               ; output : AH = system byte
  667.             mov     al,bh               ; AL = 2nd attribute
  668.             stosw                       ; store 2nd attr and system byte
  669.         .loop
  670.  
  671. ; Check to see if the last char written was a lead byte, if so, erase
  672.         .if     <bit dh and 1>          ; last char copied was lead byte
  673. ;@A01       mov     byte ptr es:[di-4],CharBlank
  674. ;@A01                                   ; write a blank into the last character
  675. ;@A01       mov     byte ptr es:[di-1],SBCS_BYTE
  676. ;@A01                                   ; clear system byte
  677.  
  678.             .if     <bit <word ptr [bp].shadow_Flags> and CGAAttr>       ;@A03
  679.                 mov     byte ptr es:[di-4],CharBlank                     ;@A03
  680.                                             ; write a blank at           ;@A03
  681.                                             ; the last character         ;@A03
  682.                                                                          ;@A03
  683. ;@A04           mov     byte ptr es:[di-1],SBCS_BYTE                     ;@A03
  684.                 and     byte ptr es:[di-1],NOT DBCSFlag+TrailByteFlag    ;@A04
  685.                                             ; clear system byte          ;@A03
  686.             .else                                                        ;@A03
  687.                 mov     ax,word ptr [bp].wSaveCpAttr1    ; retrieve      ;@A01
  688.                 mov     word ptr es:[di-4],ax                            ;@A01
  689.                 mov     ax,word ptr [bp].wSaveAttr2Attr3                 ;@A01
  690.                 mov     word ptr es:[di-2],ax                            ;@A01
  691.                 shl     dh,1                                             ;@A01
  692.             .endif                                                       ;@A03
  693.         .endif
  694.  
  695. ; Check if next cell contains a trail byte, if so, erase
  696.         .if     <dh ne 2>               ; When dbcs 1st has been ignored, ;@A00
  697.                                         ; forget the exception handling.  ;@A00
  698.             Erase2
  699.         .endif                                                            ;@A00
  700.  
  701.         ret
  702. UBCharAttToLVB3 ENDP
  703.  
  704.  
  705. ;Entry
  706. ;  al    - leading character or SBCS character
  707. ;  ah    - trailing character
  708. ;  es:di - LVB pointer
  709. ;  cx    - char count
  710.  
  711. UBNCharToLVB3   PROC
  712.         public  UBNCharToLVB3
  713.  
  714. ; check to see whether we are about to overwrite to a trailing byte
  715. ; and if so, erase preceding lead byte.
  716.         Erase1
  717.  
  718.         xor     dx,dx                   ; clear DX (system byte)
  719.  
  720. ; branch by DBCS character or SBCS character
  721.         push    ax                      ; keep ah(trailing byte)
  722.         xor     ah,ah                   ; can ignore lcid because of
  723.                                         ; char code only
  724.         push    ds
  725.         push    si
  726.         lds     si,[bp].lpNLSExt
  727.         CheckLeadByte                   ; is it leading byte?
  728.         pop     si
  729.         pop     ds
  730.         pop     ax
  731.  
  732. ; write DBCS characters
  733.         .if     <c>                     ; yes
  734.             shr     cx,1                ; CX = a pair of lead and trail byte
  735.             pushf                       ; save frag whether DBCS bisect
  736.             jcxz    @F
  737.                                         ;     fix for starting from max point
  738.             mov     dl,DBCSFlag         ; system byte
  739.             mov     dh,TrailByteFlag OR DBCSFlag
  740.             .repeat
  741.                 stosb                   ; copy leading character
  742.                 inc     di              ; skip attributes
  743.                 inc     di
  744.                 mov     byte ptr es:[di],dl     ; store leading system byte
  745.                 inc     di
  746.                 xchg    ah,al           ; flip lead/trail byte
  747.                 stosb                   ; copy trailing character
  748.                 inc     di              ; skip attributes
  749.                 inc     di
  750.                 mov     byte ptr es:[di],dh     ; store trailing system byte
  751.                 inc     di
  752.                 xchg    ah,al           ; flip lead/trail byte
  753.             .loop
  754.  
  755. ; if the char count cause DBCS bisecting, store blank character
  756. @@:
  757.                                         ;     fix for starting from max point
  758.             popf                        ; restore frag whether DBCS bisect
  759.             .if     <c>                 ; last char is pointed to lead byte
  760.                 mov     al,CharBlank    ; last character is blank
  761.                 stosb                   ; copy blank character
  762.                 inc     di              ; skip attributes
  763.                 inc     di
  764. ;@A04           mov     dl,SBCS_BYTE    ; last system byte is SBCS flag
  765.                 and     dl,NOT DBCSFlag+TrailByteFlag                   ;@A04
  766.                 mov     byte ptr es:[di],dl     ; store system byte
  767.                 inc     di
  768.             .endif
  769.  
  770. ; write SBCS characters
  771.         .else short                     ; no
  772.             .repeat
  773.                 stosb                   ; copy char
  774.                 inc     di              ; skip attributes
  775.                 inc     di
  776.                 mov     byte ptr es:[di],dl     ; store system
  777.                 inc     di
  778.             .loop
  779.         .endif
  780.  
  781. ; Check if next cell contains a trail byte, if so, erase
  782.         Erase2
  783.  
  784.         ret
  785. UBNCharToLVB3   ENDP
  786.  
  787.  
  788. ;Entry
  789. ;  al    - 1st attribute
  790. ;  ds:si - 2nd attribute pointer
  791. ;  es:di - LVB pointer
  792. ;  cx    - attr count
  793.  
  794.  
  795. UBNAttToLVB3    PROC
  796.         public  UBNAttToLVB3
  797.  
  798. ; set 1st attr to AL, 2nd attr to AH
  799.         mov     ah,ds:[si]              ; ds:[si] = 2nd attribute
  800.  
  801. ; write attributes
  802.         .repeat
  803.             inc     di                  ; skip character
  804.             stosw                       ; copy attribute
  805.             inc     di                  ; skip system
  806.         .loop
  807.  
  808.         ret
  809. UBNAttToLVB3    ENDP
  810.  
  811.  
  812. ;Entry
  813. ;  al    - character
  814. ;  ah    - 1st attribute
  815. ;  ds:si - Trailing byte character or 2nd attribute pointer
  816. ;  es:di - LVB pointer
  817. ;  cx    - cell count
  818.  
  819.  
  820. UBNCellToLVB3   PROC
  821.         public  UBNCellToLVB3
  822.  
  823. ; check to see whether we are about to overwrite to a trailing byte
  824. ; and if so, erase preceding lead byte.
  825.         Erase1
  826.  
  827.         mov     bl,byte ptr [si]        ; BL = Leading 2nd attribute
  828.         xor     dx,dx                   ; clear DX (system byte)
  829.         inc     si                      ; point trailing byte character
  830.         inc     si
  831.  
  832. ; branch by DBCS character or SBCS character
  833.         push    ds
  834.         push    si
  835.         xchg    ah,bl                   ; get attr#2(including lcid) to AH ;@A02
  836.         CheckLeadByte                   ; is it leading byte?
  837.         xchg    ah,bl                                                      ;@A02
  838.         pop     si
  839.         pop     ds
  840.  
  841. ; write DBCS cells
  842.         .if     <c>                     ; yes
  843.             shr     cx,1                ; CX = a pair of lead and trail byte
  844.             pushf                       ; save frag whether DBCS bisect
  845.             mov     bh,bl               ; BH = Leading 2nd attribute
  846.             mov     bl,ah               ; BL = Leading 1st attribute
  847.             mov     ah,al               ; AH = Leading character
  848.             jcxz    @F                  ; 1990-08-02 updated
  849.                                         ;     fix for starting from max point
  850.             lodsb                       ; AL = Trailing character
  851.             mov     dl,byte ptr ds:[si] ; DL = Trailing 1st attribute
  852.             mov     dh,byte ptr ds:[si+1];DH = Trailing 2nd attribute
  853.             .repeat
  854.                 xchg    al,ah           ; flip trail/lead byte character
  855.                 stosb                   ; copy leading char
  856.                 mov     es:[di],bx      ; store leading 1st attr and 2nd attr
  857.                 inc     di
  858.                 inc     di
  859.                 mov     byte ptr es:[di],DBCSFlag
  860.                                         ; store leading system byte
  861.                 inc     di
  862.                 xchg    al,ah           ; flip lead/trail byte
  863.                 stosb                   ; copy trailing char
  864.                 mov     es:[di],dx      ; store trailing 1st attr and 2nd attr
  865.                 inc     di
  866.                 inc     di
  867.                 mov     byte ptr es:[di],TrailByteFlag OR DBCSFlag
  868.                                         ; store leading system byte
  869.                 inc     di
  870.             .loop
  871.  
  872. ; if the cell count cause DBCS bisecting, store attribute only.
  873. @@:                                     ; 1990-08-02 updated
  874.                                         ;     fix for starting from max point
  875.             popf                        ; restore frag whether DBCS bisect
  876.             .if     <c>                 ; last cell is pointed to lead byte
  877.                 mov     al,CharBlank    ; last character is blank
  878.                 mov     ah,bl           ; set 1st attribute
  879.                 stosw                   ; copy char and 1st attr
  880.                 mov     al,bh           ; set 2nd attribute
  881. ;@A04           mov     ah,SBCS_BYTE    ; last system byte is SBCS flag
  882.                 and     ah,NOT DBCSFlag+TrailByteFlag                   ;@A04
  883.                 stosw                   ; store 2nd attr and system byte
  884.             .endif
  885.  
  886. ; write SBCS characters
  887.         .else short                     ; no
  888.             mov     bh,dh               ; copy system byte to BH
  889.             .repeat
  890.                 stosw                   ; copy char and 1st attr
  891.                 mov     es:[di],bx      ; store 2nd attr and system byte
  892.                 inc di
  893.                 inc di
  894.             .loop
  895.         .endif
  896.  
  897. ; Check if next cell contains a trail byte, if so, erase
  898.         Erase2
  899.  
  900.         ret
  901. UBNCellToLVB3   ENDP
  902.  
  903.  
  904. ;Entry
  905. ;  ds:si - LVB pointer
  906. ;  es:di - user buffer pointer
  907. ;  cx    - char length (in byte)
  908.  
  909.  
  910. LVBCharToUB3    PROC
  911.         public  LVBCharToUB3
  912.  
  913. ; Check if first cell to copy contains a trail byte, if so, erase
  914.         mov     al,[si]                 ; AL = first character
  915.         Erase5                          ; replace AL by blank if trail byte
  916.         dec     cx                      ; count down this character
  917.  
  918.         .if     <ncxz>                  ; branch if only 1 char total
  919.             stosb                       ; store character
  920.             add     si,4                ; skip first cell point
  921.             jmp short @F                ; jump into loop to do cx-1 iterations
  922.  
  923.             .repeat
  924.                 movsb                   ; copy character
  925.                 add     si,3            ; skip 3 attributes
  926. @@:
  927.             .loop
  928.  
  929. ; Check if last cell to copy contains lead byte, if so, erase
  930. ; We check the source before copy, as then the following trail byte
  931. ; is still attached and we can use the system byte TrailByteFlag to check.
  932.             mov     al,[si]             ; last character
  933.         .endif
  934.         Erase6                          ; replace AL by blank if lead byte
  935.         stosb                           ; store character
  936.  
  937.         ret
  938. LVBCharToUB3    ENDP
  939.  
  940.  
  941. ;Entry
  942. ;  ds:si - LVB pointer
  943. ;  es:di - user buffer pointer
  944. ;  cx    - cell length (in byte) / 2
  945.  
  946.  
  947. LVBCellToUB3    PROC
  948.         public  LVBCellToUB3
  949.  
  950.         shr     cx,1                    ; convert to number of cell
  951.  
  952. ; Check if first cell to copy contains a trail byte, if so, erase
  953.         mov     ax,[si]                 ; AL = first char, AH = 1st attr
  954.         Erase5                          ; replace AL by blank if trail byte
  955.         dec     cx                      ; count down this cell
  956.  
  957.         .if     <c> or                  ; branch if char was a trail byte
  958.         .if     <ncxz>                  ; branch if this only cell to copy
  959.             stosw                       ; store character and 1st attribute
  960.             inc     si                  ; adjust source pointer
  961.             inc     si
  962.  
  963.             lodsw                       ; AL = 2nd attr, AH = system byte
  964.             .if     <c>                 ; branch if was not trail byte
  965. ;@A04           mov     ah,SBCS_BYTE    ; clear system byte
  966.                 and     ah,NOT DBCSFlag+TrailByteFlag                   ;@A04
  967.             .endif
  968.             stosw                       ; store 2nd attr and system byte
  969.             jcxz        @F              ; branch if this only cell to copy
  970.  
  971.             dec     cx
  972.             add     cx,cx               ; word count
  973.             rep     movsw               ; copy all except last cell.
  974.  
  975. ; Check if last cell to copy contains lead byte, if so, erase
  976. ; We check the source before copy, as then the following trail byte
  977. ; is still attached and we can use the system byte TrailByteFlag to check.
  978.             mov     ax,[si]             ; AL = character, AH = attribute
  979.         .endif
  980.         Erase6                          ; replace AL by blank if lead byte
  981.         stosw                           ; store character and attribute
  982.         inc     si                      ; adjust source pointer
  983.         inc     si
  984.         lodsw                           ; get 2nd attribute and system byte
  985.         .if     <c>                     ; branch if was not lead byte
  986. ;@A04       mov     ah,SBCS_BYTE        ; clear system byte
  987.             and     ah,NOT DBCSFlag+TrailByteFlag                       ;@A04
  988.         .endif
  989.         stosw                           ; store 2nd attribute and system byte
  990.  
  991. @@:
  992.         ret
  993. LVBCellToUB3    ENDP
  994.  
  995.  
  996. ;Entry
  997. ;  ds:si - source LVB pointer
  998. ;  es:di - destination LVB pointer
  999. ;  cx    - cell length (in byte) / 2
  1000. ;  dx    - reserved
  1001.  
  1002.  
  1003. LVBCellToLVB3I  PROC NEAR
  1004.         public  LVBCellToLVB3I
  1005.  
  1006. ; Check if first source cell to copy contains a trail byte
  1007. ; and if so, erase this DBCS character.
  1008.         .if     <si ae 4> and
  1009.         .if     <bit <byte ptr ds:[si+3]> and TrailByteFlag>
  1010.             mov     byte ptr ds:[si],CharBlank
  1011.                                         ; copy blank into this trailing char
  1012. ;@A04       mov     byte ptr ds:[si+3],SBCS_BYTE
  1013.             and     byte ptr ds:[si+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  1014.                                         ; and clear trailing bit
  1015.             mov     byte ptr ds:[si-4],CharBlank
  1016.                                         ; copy blank into this leading char
  1017. ;@A04       mov     byte ptr ds:[si-1],SBCS_BYTE
  1018.             and     byte ptr ds:[si-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1019.                                         ; and clear leading bit
  1020.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  1021.         .endif
  1022.  
  1023. ; check to see whether we are about to overwrite to a trailing byte
  1024. ; and if so, erase preceding lead byte.
  1025.         .if     <di ae 4 > and
  1026.         .if     <bit <byte ptr es:[di+3]> and TrailByteFlag>
  1027.             mov     byte ptr es:[di-4],CharBlank
  1028.                                         ; copy blank into this leading char
  1029. ;@A04       mov     byte ptr es:[di-1],SBCS_BYTE
  1030.             and     byte ptr es:[di-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1031.  
  1032.                                         ; and clear leading bit
  1033.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  1034.         .endif
  1035.  
  1036. ; move cells
  1037.         rep     movsw                   ; copy all remaining cells
  1038.  
  1039. ; Check if last source cell to copy contains a lead byte
  1040. ; and if so, erase this DBCS character and leading character stored.
  1041.         .if     <si b [bp].j_lvbsize> and
  1042.         .if     <bit <byte ptr ds:[si+3]> and TrailByteFlag>
  1043.             mov     byte ptr ds:[si],CharBlank
  1044.                                         ; copy blank into this trailing char
  1045. ;@A04       mov     byte ptr ds:[si+3],SBCS_BYTE
  1046.             and     byte ptr ds:[si+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  1047.                                         ; and clear trailing bit
  1048.             mov     byte ptr ds:[si-4],CharBlank
  1049.                                         ; copy blank into this leading char
  1050. ;@A04       mov     byte ptr ds:[si-1],SBCS_BYTE
  1051.             and     byte ptr ds:[si-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1052.                                         ; and clear leading bit
  1053.             mov     byte ptr es:[di-4],CharBlank
  1054.                                         ; copy blank into stored leading char
  1055. ;@A04       mov     byte ptr es:[di-1],SBCS_BYTE
  1056.             and     byte ptr es:[di-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1057.                                         ; and clear stored leading bit
  1058.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  1059.         .endif
  1060.  
  1061. ; Check if next destination cell contains a trail byte, if so, erase
  1062.         .if     <di b [bp].j_lvbsize> and
  1063.         .if     <bit <byte ptr es:[di+3]> and TrailByteFlag>
  1064.             mov     byte ptr es:[di],CharBlank
  1065.                                         ; copy blank into this trailing char
  1066. ;@A04       mov     byte ptr es:[di+3],SBCS_BYTE
  1067.             and     byte ptr es:[di+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  1068.                                         ; and clear trailing bit
  1069.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  1070.         .endif
  1071.  
  1072.         ret
  1073. LVBCellToLVB3I  ENDP
  1074.  
  1075.  
  1076. ;Entry
  1077. ;  ds:si - source LVB pointer
  1078. ;  es:di - destination pointer
  1079. ;  cx    - cell length (in byte) / 2
  1080. ;  dx    - reserved
  1081.  
  1082.  
  1083. LVBCellToLVB3D  PROC
  1084.         public  LVBCellToLVB3D
  1085.  
  1086. ; calculate the valid last cell pointer
  1087.         mov     ax,[bp].j_lvbsize
  1088.         .if     <ax eq 0FFFFh>          ; 64KB on AVIO
  1089.             sub     ax,3
  1090.         .else
  1091.             sub     ax,4
  1092.         .endif
  1093.         push    ax                      ; save valid last cell pointer
  1094.  
  1095. ; Check if first source cell to copy contains a lead byte
  1096. ; and if so, erase this DBCS character.
  1097.         .if     <si b ax> and
  1098.         .if     <bit <byte ptr ds:[si+5]> and TrailByteFlag>
  1099.             mov     byte ptr ds:[si-2],CharBlank
  1100.                                         ; copy blank into this leading char
  1101. ;@A04       mov     byte ptr ds:[si+1],SBCS_BYTE
  1102.             and     byte ptr ds:[si+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1103.                                         ; and clear leading bit
  1104.             mov     byte ptr ds:[si+2],CharBlank
  1105.                                         ; copy blank into this trailing char
  1106. ;@A04       mov     byte ptr ds:[si+5],SBCS_BYTE
  1107.             and     byte ptr ds:[si+5],NOT DBCSFlag+TrailByteFlag       ;@A04
  1108.                                         ; and clear trailing bit
  1109.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  1110.         .endif
  1111.  
  1112. ; check to see whether we are about to overwrite to a leading byte
  1113. ; and if so, erase next trail byte.
  1114.         pop     ax                      ; restore valid last cell pointer
  1115.         .if     <di b ax > and
  1116.         .if     <bit <byte ptr es:[di+5]> and TrailByteFlag>
  1117.             mov     byte ptr es:[di+2],CharBlank
  1118.                                         ; copy blank into this leading char
  1119. ;@A04       mov     byte ptr es:[di+5],SBCS_BYTE
  1120.             and     byte ptr es:[di+5],NOT DBCSFlag+TrailByteFlag       ;@A04
  1121.                                         ; and clear leading bit
  1122.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  1123.         .endif
  1124.  
  1125. ; move cells
  1126.         rep     movsw                   ; copy all remaining cells
  1127.  
  1128. ; Check if last source cell to copy contains a trail byte
  1129. ; and if so, erase this DBCS character and trailing character stored.
  1130.         .if     <si ge 2> and
  1131.         mov     al,byte ptr ds:[si+1]
  1132.         and     al,(TrailByteFlag or DBCSFlag)
  1133.         .if     <al eq DBCSFlag>
  1134.             mov     byte ptr ds:[si-2],CharBlank
  1135.                                         ; copy blank into this leading char
  1136. ;@A04       mov     byte ptr ds:[si+1],SBCS_BYTE
  1137.             and     byte ptr ds:[si+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1138.                                         ; and clear leading bit
  1139.             mov     byte ptr ds:[si+2],CharBlank
  1140.                                         ; copy blank into this trailing char
  1141. ;@A04       mov     byte ptr ds:[si+5],SBCS_BYTE
  1142.             and     byte ptr ds:[si+5],NOT DBCSFlag+TrailByteFlag       ;@A04
  1143.                                         ; and clear trailing bit
  1144.             mov     byte ptr es:[di+2],CharBlank
  1145.                                         ; copy blank into stored trailing char
  1146. ;@A04       mov     byte ptr es:[di+5],SBCS_BYTE
  1147.             and     byte ptr es:[di+5],NOT DBCSFlag+TrailByteFlag       ;@A04
  1148.                                         ; and clear stored trailing bit
  1149.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  1150.         .endif
  1151.  
  1152. ; Check if next destination cell contains a lead byte, if so, erase
  1153.         .if     <di ge 2> and
  1154.         mov     al,byte ptr es:[di+1]
  1155.         and     al,(TrailByteFlag or DBCSFlag)
  1156.         .if     <al eq DBCSFlag>
  1157.             mov     byte ptr es:[di-2],CharBlank
  1158.                                         ; copy blank into this leading char
  1159. ;@A04       mov     byte ptr es:[di+1],SBCS_BYTE
  1160.             and     byte ptr es:[di+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  1161.                                         ; and clear trailing bit
  1162.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  1163.         .endif
  1164.  
  1165.         ret
  1166. LVBCellToLVB3D  ENDP
  1167.  
  1168.  
  1169. ; support CheckCharType of DBCS
  1170. ;Entry
  1171. ;  ds:si - LVB pointer
  1172. ;  es:di - user buffer pointer
  1173.  
  1174. TypeSBCS        equ     0
  1175. TypeDBCSLead    equ     2
  1176. TypeDBCSTrail   equ     3
  1177.  
  1178.  
  1179. LVBCharTypeToUB3 PROC
  1180.         public  LVBCharTypeToUB3
  1181.  
  1182.         mov     ah,byte ptr ds:[si+3]   ; get system byte
  1183.                                                                         ;@A05 start
  1184.         test    ah, (TrailByteFlag or DBCSFlag)
  1185.         .if     z   near                    ; check whether it is a real SBCS
  1186.             push    es
  1187.             push    ds
  1188.             push    di
  1189.  
  1190.             push    ds
  1191.             pop     es
  1192.             push    si
  1193.             pop     di
  1194.  
  1195.             lds     bx, [bp].EnvBufParm     ; DS:BX -> environment buffer
  1196.             mov     ax,di
  1197.             mov     cx, ds:[bx].viops_CellByteSize
  1198.             shr     cl,1
  1199.             shr     ax,cl
  1200.             mov     cx,ax                   ; set the number of bytes before
  1201.                                             ; the specified position.
  1202.             mov     bx, ds:[bx].viops_CellByteSize
  1203.             xor     ax,ax
  1204.             .if     <cx a 0>
  1205.                 mov     ax,cx           ;save
  1206.                 .repeat                 ;keep the upper compatible
  1207.                                         ;for dbcs applications.
  1208.                                         ;Avio must ensure all
  1209.                                         ;of dbcs bits are valid.
  1210.                     test    byte ptr es:[di+3], DBCSFlag+TrailByteFlag
  1211.                     jnz     @F
  1212.                     sub     di,bx
  1213.                 .loop
  1214.             @@:
  1215.                 mov     dl, byte ptr es:[di+3]              ;@C01
  1216.                 and     dl, DBCSFlag+TrailByteFlag          ;@C01
  1217.                 .if     <bit dl and TrailByteFlag> and      ;@C01
  1218.         ;@C01   .if     <bit <byte ptr es:[di+3]> and <NOT TrailByteFlag>> and
  1219.                 .if     <nonzero cx>
  1220.                     sub     di,bx       ;look at the dbcs leading byte
  1221.                     dec     cx
  1222.                 .endif
  1223.                 sub     ax,cx
  1224.             .endif
  1225. ;@C01       add     cx,ax
  1226.             mov     cx,ax       ;@C01
  1227.             inc     cx                  ;include the specified position itself
  1228.  
  1229.             .repeat
  1230.                 mov     ah,byte ptr es:[di+2]   ; AH : attr#2(including lcid)
  1231.                 mov     al,byte ptr es:[di]     ; AL : char code point
  1232.                 inc     di                      ; skip char
  1233.                 inc     di                      ; skip 1st attribute
  1234.                 SetSystemByte <mov ax,es:[di]>  ; get 2nd attr & 3rd attr
  1235.                 stosw                           ; store 2nd attr and system byte
  1236.             .loop
  1237.  
  1238.             pop     di
  1239.             pop     ds
  1240.             pop     es
  1241.  
  1242.         .endif
  1243.                                                                         ;@A05 end
  1244.         and     ah,(TrailByteFlag or DBCSFlag)
  1245.  
  1246.         mov     al,TypeSBCS             ; default SBCS
  1247.         .if     <ah eq DBCSFlag>
  1248.             mov     al,TypeDBCSLead     ; leading byte
  1249.         .elseif <ah eq <TrailByteFlag or DBCSFlag>>
  1250.             mov     al,TypeDBCSTrail    ; trailing byte
  1251.         .endif
  1252.  
  1253.         xor     ah,ah
  1254.         stosw                           ; store character type
  1255.  
  1256.         ret
  1257. LVBCharTypeToUB3 ENDP
  1258.  
  1259.  
  1260. include xgasubax.inc
  1261.  
  1262. IFDEF EPOCH ;epoch format handling routiones
  1263. include xgasubep.inc
  1264. ENDIF
  1265.  
  1266.  
  1267. R2CSEG  ENDS
  1268. ENDIF ;D1348
  1269.         END
  1270.  
  1271. ;D1348 = 04/11/91 NAKADA, Enable DBCS support in Vio-Window, DCR 1348
  1272. ;                         Written for DCR 1348
  1273. ;@C01  = 03/09/92 NAKADA,     fix : trap-D
  1274.