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