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