home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / XGASUBEP.INC < prev    next >
Text File  |  1995-04-14  |  33KB  |  815 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12. ;       SCCSID = @(#)xgasubep.inc        6.1 91/04/26
  13.  
  14. ; ****************************************************************************
  15. ; *                                                                          *
  16. ; *                                                                          *
  17. ; *                                                                          *
  18. ; ****************************************************************************
  19.  
  20. ;********************** START OF SPECIFICATIONS ****************************
  21. ;*                                                                         *
  22. ;* SOURCE FILE NAME:    XGASUBEP.INC                                       *
  23. ;*                                                                         *
  24. ;* DESCRIPTIVE NAME:    BUFFERUPDATE subroutine for DBCS Codepage          *
  25. ;*                                                                         *
  26. ;* COPYRIGHT:   na                                                         *
  27. ;*                                                                         *
  28. ;* STATUS:      OS/2 version 2.0                                           *
  29. ;*                                                                         *
  30. ;* CHANGE HISTORY:                                                         *
  31. ;*                                                                         *
  32. ;* NOTES:       Ring 2 conforming code segment                             *
  33. ;*                                                                         *
  34. ;*    DEPENDENCIES:     None                                               *
  35. ;*                                                                         *
  36. ;*    RESTRICTIONS:     None                                               *
  37. ;*                                                                         *
  38. ;*    PATH LABEL:       na                                                 *
  39. ;*                                                                         *
  40. ;* ENTRY POINTS:                                                           *
  41. ;*                                                                         *
  42. ;*                                                                         *
  43. ;* EXTERNAL REFERENCES: included XGASUBAX.ASM                              *
  44. ;*                                                                         *
  45. ;********************** END OF SPECIFICATIONS ******************************
  46.  
  47. Erase1e macro
  48.         local   er1x_end
  49.  
  50.         cmp     di,0                    ; first cell ?
  51.         jbe     er1x_end                ; exit if yes
  52.  
  53.         test    byte ptr es:[di+1],epochDBCSTrail
  54.         jz      er1x_end                ; exit if not
  55.  
  56.         mov     byte ptr es:[di-2],CharBlank ; copy blank into this cell
  57.         and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail; and clear
  58.                                                                    ; trailbyte bit
  59.         or      [bp].j_dbcsstatus,BisectDBCS_START
  60.  
  61. er1x_end:
  62.         endm
  63.  
  64. Erase2e macro
  65.         local   er2x_end
  66.  
  67.         cmp     di,[bp].j_lvbsize       ; outside LVB
  68.         jae     er2x_end                ; skip if yes
  69.  
  70.         test    byte ptr es:[di+1],epochDBCSTrail
  71.         jz      er2x_end                ; skip if not
  72.  
  73.         mov     byte ptr es:[di],CharBlank   ; copy blank into this cell
  74.         and     byte ptr es:[di+1],NOT epochDBCSLead+epochDBCSTrail; and clear
  75.                                                                    ; trailbyte bit
  76.         or      [bp].j_dbcsstatus,BisectDBCS_LAST
  77.  
  78. er2x_end:
  79.         endm
  80.  
  81. Erase5e macro
  82.         local   er5x_end
  83.  
  84.         push    ds                      ; save source selector
  85.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  86.  
  87.         test    byte ptr ds:[si+1],TrailByteFlag ; CF = 0
  88.         jz      er5x_end                ; exit if not
  89.  
  90.         mov     al,CharBlank            ; AL = blank
  91.         stc                             ; CF set if was trailing byte
  92.  
  93. er5x_end:
  94.         pop     ds                      ; restore source selector
  95.         endm
  96.  
  97. Erase6e macro
  98.         local   er6x_end
  99.  
  100.         push    ds                      ; save source selector
  101.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  102.  
  103.         test    byte ptr ds:[si+1],DBCSFlag     ; CF = 0
  104.         jz      er6x_end                ; exit if not DBCS
  105.  
  106.         test    byte ptr ds:[si+1],TrailByteFlag
  107.         jnz     er6x_end                ; exit if trail byte
  108.  
  109.         mov     al,CharBlank            ; AL = blank
  110.         stc                             ; CF set if was lead byte
  111.  
  112. er6x_end:
  113.         pop     ds                      ; restore source selector
  114.         endm
  115.  
  116. ;  SetSystemByteE
  117. ;
  118. ;       maintain the DBCS and trail byte flags in the system byte.
  119. ;       arguments are used to obtain the system byte to be modified.
  120. ;
  121. ;
  122. ;       INPUT
  123. ;               AL  -  Character to be Tested for lead byte range
  124. ;               DH  -  Previous Character first byte of DBCS status
  125. ;                      (return value of previous macro invocation)
  126. ;       USES
  127. ;               DX  -  to maintain the Lead/TrailByte State information
  128. ;
  129. ;       RETURNS
  130. ;               AX  -  [copied 2nd attribute (AL) and] New SystemByte (AH)
  131. ;               DH  -  1 if character first byte of DBCS
  132. ;
  133. ;       ALGORITHM
  134. ;
  135. ;
  136. ;           if( LeadingByte )
  137. ;               ThisIsLeadByteFlag = 1
  138. ;           if( PrevWasLeadByteFlag )
  139. ;               ThisIsLeadByteFlag = 0
  140. ;
  141. ;           <process attribute>
  142. ;
  143. ;           system byte = ThisIsLeadByteFlag
  144. ;           swap( ThisIsLeadByteFlag, PrevWasLeadByteFlag )
  145. ;           system byte |= ThisIsLeadByteFlag
  146. ;                       { which is true if PREV was lead byte }
  147. ;
  148. ;
  149. SetSystemByteE macro  instruction
  150.  
  151.         xor     dl,dl           ; DL = 0
  152.         push    ds
  153.         push    si
  154.         CheckLeadByte           ; Cy set if leading byte in AL
  155.         pop     si
  156.         pop     ds
  157.         adc     dl,dl           ; DL = 1 if this was leading byte
  158.  
  159.         IFNB <instruction>
  160.                 &instruction    ; optional code to load AH (or AX)
  161.         ENDIF
  162.                                 ; [AL = 2nd attr,] AH = system byte
  163.         mov     ah,dl           ; set DBCS bit in system byte
  164.         or      ah,dh           ; " " " if previous was lead_byte
  165.         sub     dl,dh           ; dl = 0 if previous was leading byte already
  166.         adc     dl,0
  167.         xchg    dl,dh           ; save dl for next char, use dh now
  168. ;;      ror     dl,1            ; rotate to get tail_byte bit 0 into bit 7
  169.         shl     dl,1            ; rotate to get tail_byte bit 0 into bit 7
  170.         or      ah,dl           ; or TrailBYTE bit into system byte
  171.  
  172.         endm
  173.  
  174.  
  175. IFDEF EPOCH
  176. ;Entry
  177. ;  ds:si - user cells pointer
  178. ;  es:di - LVB pointer
  179. ;  cx    - cell length (in byte)
  180.  
  181.  
  182. UBCellToLVB1E   PROC
  183.         public  UBCellToLVB1E
  184.  
  185. ; check to see whether we are about to overwrite to a trailing byte
  186. ; and if so, erase preceding lead byte.
  187.         Erase1e
  188.  
  189.         shr     cx,1                    ; convert bytes to number of cell
  190.         xor     dx,dx                   ; clear DH for use as flag in loop
  191.  
  192. ; write cells.
  193.         .repeat
  194.             mov     bx,word ptr es:[di] ; Save for restoring the previous
  195.                                         ; cp & attr#1 for tail exception
  196.             lodsw                       ; AL = char, AH = 1st attribute
  197.             stosw                       ; write char and 1st attribute
  198.             xor     ah,ah               ; ignore attr#2(including lcid),
  199.                                         ; which means using a default
  200.                                         ; dbcs env. vector.
  201.             SetSystemByteE              ; AH = system byte
  202.             and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail
  203.             or      byte ptr es:[di-1],ah       ; store system byte
  204.         .loop
  205.  
  206. ; Check to see if the last char written was a lead byte, if so, erase
  207.         .if     <bit dh and 1>          ; last char copied was lead byte
  208.             mov     word ptr es:[di-2],bx ; Undo
  209.             shl     dh,1
  210.         .endif
  211.  
  212. ; Check if next cell contains a trail byte, if so, erase
  213.         .if     <dh ne 2>               ; When dbcs 1st has been ignored,
  214.                                         ; forget the exception handling.
  215.             Erase2e
  216.         .endif
  217.  
  218.         ret
  219. UBCellToLVB1E   ENDP
  220.  
  221.  
  222. ;Entry
  223. ;  ds:si - user chars pointer
  224. ;  es:di - LVB pointer
  225. ;  cx    - char length (in byte)
  226.  
  227. UBCharToLVB1E   PROC
  228.         public  UBCharToLVB1E
  229.  
  230. ; check to see whether we are about to overwrite to a trailing byte
  231. ; and if so, erase preceding lead byte.
  232.         Erase1e
  233.  
  234.         xor     dx,dx                   ; clear DH for use as flag in loop
  235.  
  236. ; write characters
  237.         .repeat
  238.             mov     bl,byte ptr es:[di] ; Save for restoring the previous
  239.             lodsb                       ; copy char
  240.             stosb
  241.             xor     ah,ah               ; ignore attr#2(including lcid),
  242.                                         ; which means using a default
  243.                                         ; dbcs env. vector.
  244.             SetSystemByteE              ; AH = system byte
  245. ;;          mov     byte ptr es:[di],ah ; store system byte                     ;;KY01D
  246.             and     byte ptr es:[di],NOT epochDBCSLead+epochDBCSTrail           ;;KY01A
  247.             or      byte ptr es:[di],ah ; store system byte                     ;;KY01A
  248.             inc     di                  ; skip 1st attribute
  249.         .loop
  250.  
  251. ; Check to see if the last char written was a lead byte, if so, erase
  252.         .if     <bit dh and 1>          ; last char copied was lead byte
  253.             mov     byte ptr es:[di-2],bl ; undo ; restore the prev. cp.
  254.             shl     dh,1
  255.         .endif
  256.  
  257. ; Check if next cell contains a trail byte, if so, erase
  258.         .if     <dh ne 2>               ; When dbcs 1st has been ignored,
  259.                                         ; forget the exception handling.
  260.             Erase2e
  261.         .endif
  262.  
  263.         ret
  264. UBCharToLVB1E   ENDP
  265.  
  266.  
  267. ;Entry
  268. ;  ah    - 1st attribute
  269. ;  dl    - 2nd attribute (if WorldFormat)
  270. ;  dh    - system byte   (if WorldFormat)
  271. ;  ds:si - user chars pointer
  272. ;  es:di - LVB pointer
  273. ;  cx    - char length (in byte)
  274.  
  275. UBCharAttToLVB1E PROC
  276.         public  UBCharAttToLVB1E
  277.  
  278. ; check to see whether we are about to overwrite to a trailing byte
  279. ; and if so, erase preceding lead byte.
  280.  
  281.         Erase1e
  282.         ;25Sep91 +
  283.         test    [bp].shadow_Flags,CGAAttr ; CGA Translation
  284.         .if <nz>
  285.             push    ax
  286.             xchg    ah,al
  287.             mov     ah,dl
  288.             ;06Nov91 +
  289.             mov     ax,[bp].shadowAttribute ; Get ANSI's attributes
  290.             ;06Nov91 -
  291.             Call    Translate           ; Common AX -> Epoch AL
  292.             mov     bl,al               ; BL = 1st attribute
  293.             pop     ax
  294.         .else
  295.             mov     bl,ah                   ; BL = 1st attribute
  296.         .endif
  297.         ;25Sep91 -
  298.  
  299.         xor     dx,dx                   ; clear DH for use as flag in loop
  300.  
  301. ; write characters and attributes
  302.         .repeat
  303.             mov     ax,word ptr es:[di] ; save cp+attr in lvb for retrieve
  304.             mov     word ptr [bp].wSaveCpAttr1,ax
  305.             lodsb                       ; char = AL
  306.             mov     ah,bl               ; AH = first attribute
  307.             stosw                       ; write char and 1st attribute
  308.             xor     ah,ah               ; ignore attr#2(including lcid),
  309.                                         ; which means using a default
  310.                                         ; dbcs env. vector.
  311.             SetSystemByteE              ; AH = system byte
  312.             ;js01542 jc20 +
  313.             and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail
  314.             ;js01542 jc20 -
  315.             or      byte ptr es:[di-1],ah       ; store system byte
  316.         .loop
  317.  
  318. ; Check to see if the last char written was a lead byte, if so, erase
  319.         .if     <bit dh and 1>          ; last char copied was lead byte
  320.  
  321.             .if     <bit <word ptr [bp].shadow_Flags> and CGAAttr>
  322.                 mov     byte ptr es:[di-2],CharBlank
  323.                                             ; write a blank at
  324.                                             ; the last character
  325.  
  326.                 and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail
  327.                                             ; clear system byte
  328.             .else
  329.                 mov     ax,word ptr [bp].wSaveCpAttr1    ; retrieve
  330.                 mov     word ptr es:[di-2],ax
  331.                 shl     dh,1
  332.             .endif
  333.         .endif
  334.  
  335. ; Check if next cell contains a trail byte, if so, erase
  336.         .if     <dh ne 2>               ; When dbcs 1st has been ignored,
  337.                                         ; forget the exception handling.
  338.             Erase2e
  339.         .endif
  340.  
  341.         ret
  342. UBCharAttToLVB1E ENDP
  343.  
  344.  
  345. ;Entry
  346. ;  al    - leading character or SBCS character
  347. ;  ah    - trailing character
  348. ;  es:di - LVB pointer
  349. ;  cx    - char count
  350.  
  351. UBNCharToLVB1E  PROC
  352.         public  UBNCharToLVB1E
  353.  
  354. ; check to see whether we are about to overwrite to a trailing byte
  355. ; and if so, erase preceding lead byte.
  356.         Erase1e
  357.  
  358.         xor     dx,dx                   ; clear DX (system byte)
  359.  
  360. ; branch by DBCS character or SBCS character
  361.         push    ax                      ; keep ah(trailing byte)
  362.         xor     ah,ah                   ; can ignore lcid because of
  363.                                         ; char code only
  364.         push    ds
  365.         push    si
  366.         lds     si,[bp].lpNLSExt
  367.         CheckLeadByte                   ; is it leading byte?
  368.         pop     si
  369.         pop     ds
  370.         pop     ax
  371.  
  372. ; write DBCS characters
  373.         .if     <c>                     ; yes
  374.             mov     dl,epochDBCSLead         ; system byte
  375.             mov     dh,epochDBCSTrail OR epochDBCSLead
  376. ;07Oct91    push    ds                  ; save source selector
  377. ;07Oct91    mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  378.             shr     cx,1                ; CX = a pair of lead and trail byte
  379.             pushf                       ; save frag whether DBCS bisect
  380.             jcxz    @F                  ; 1990-08-02 updated
  381.                                         ;     fix for starting from max point
  382.             .repeat
  383.                 stosb                           ; copy leading character
  384. ;07Oct91        mov     byte ptr ds:[di],dl     ; store leading system byte
  385.                 mov     byte ptr es:[di],dl     ; store leading system byte ;07Oct91
  386.                 inc     di
  387.                 xchg    ah,al                   ; flip lead/trail char
  388.                 stosb                           ; copy trailing character
  389. ;07Oct91        mov     byte ptr ds:[di],dh     ; store trailing system byte
  390.                 mov     byte ptr es:[di],dh     ; store trailing system byte;07Oct91
  391.                 inc     di
  392.                 xchg    ah,al                   ; flip lead/trail char
  393.             .loop
  394.  
  395. ; if the char count cause DBCS bisecting, store blank character
  396. @@:                                     ; 1990-08-02 updated
  397.                                         ;     fix for starting from max point
  398.             popf                        ; restore frag whether DBCS bisect
  399.             .if     <c>                 ; last char is pointed to lead byte
  400.                 mov     al,CharBlank    ; last character is blank
  401.                 stosb                   ; copy blank character
  402. ;07Oct91        and     byte ptr ds:[di],NOT epochDBCSLead+epochDBCSTrail
  403.                 and     byte ptr es:[di],NOT epochDBCSLead+epochDBCSTrail   ;07Oct91
  404.                 inc     di
  405.             .endif
  406. ;07Oct91    pop     ds                  ; restore source selector
  407.  
  408. ; write SBCS characters
  409.         .else short                     ; no
  410. ;07Oct91    push    ds                  ; save source selector
  411. ;07Oct91    mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  412.             .repeat
  413.                 stosb                           ; copy char
  414. ;07Oct91        mov     byte ptr ds:[di],dl     ; store system byte
  415.                 mov     byte ptr es:[di],dl     ; store system byte         ;07Oct91
  416.                 inc     di
  417.             .loop
  418. ;07Oct91    pop     ds                  ; restore source selector
  419.         .endif
  420.  
  421. ; Check if next cell contains a trail byte, if so, erase
  422.         Erase2e
  423.  
  424.         ret
  425. UBNCharToLVB1E  ENDP
  426.  
  427. ;Entry
  428. ;  al    - 1st attribute
  429. ;  ds:si - 2nd attribute pointer
  430. ;  es:di - LVB pointer
  431. ;  cx    - attr count
  432.  
  433.  
  434. UBNAttToLVB1E   PROC NEAR
  435.         public  UBNAttToLVB1E
  436.  
  437. ; write attributes
  438.         and     al,NOT epochDBCSLead+epochDBCSTrail ;clear dbcs bits
  439.         mov     ah,al
  440.         .repeat
  441.             inc     di                  ; skip character
  442.             mov     al,byte ptr es:[di] ; get target attribute
  443.             and     al,epochDBCSLead+epochDBCSTrail
  444.             or      al,ah               ; merge them
  445.             stosb                       ; copy attribute
  446.         .loop
  447.  
  448.         ret
  449. UBNAttToLVB1E   ENDP
  450.  
  451. ;Entry
  452. ;  al    - character
  453. ;  ah    - 1st attribute
  454. ;  ds:si - Trailing byte character or 2nd attribute pointer
  455. ;  es:di - LVB pointer
  456. ;  cx    - cell count
  457.  
  458.  
  459. UBNCellToLVB1E  PROC
  460.         public  UBNCellToLVB1E
  461.  
  462. ; check to see whether we are about to overwrite to a trailing byte
  463. ; and if so, erase preceding lead byte.
  464.         Erase1e
  465.  
  466.         xor     dx,dx                   ; clear DX (system byte)
  467.  
  468. ; branch by DBCS character or SBCS character
  469.         push    ax                      ; keep ah(trailing byte)
  470.         xor     ah,ah                   ; Don't need lcid check ;07Oct91
  471.         push    ds
  472.         push    si
  473.         lds     si,[bp].lpNLSExt
  474.         CheckLeadByte                   ; is it leading byte?
  475.         pop     si
  476.         pop     ds
  477.         pop     ax
  478.  
  479. ; write DBCS cells
  480.         .if     <c>                     ; yes
  481.             xchg    ax,bx               ; BX = Leading Byte
  482.             mov     dl,epochDBCSLead         ; system byte
  483.             mov     dh,epochDBCSTrail OR epochDBCSLead
  484.             lodsw                       ; AX = Trailing Byte
  485.             shr     cx,1                ; CX = a pair of lead and trail byte
  486.             pushf                       ; save frag whether DBCS bisect
  487.             jcxz    @F                  ; 1990-08-02 updated
  488.                                         ;     fix for starting from max point
  489.             .repeat
  490.                 xchg    ax,bx                   ; flip trail/lead byte
  491.                 stosw                           ; copy leading char and 1st attr
  492. ;@B01           mov     byte ptr es:[di-1],dl   ; store leading system byte
  493.                 and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail  ;@B01
  494.                 or      byte ptr es:[di-1],dl   ; store leading system byte  ;@B01
  495.                 xchg    ax,bx                   ; flip lead/trail byte
  496.                 stosw                           ; copy trailing char and 1st attr
  497. ;@B01           mov     byte ptr es:[di-1],dh   ; store trailing system byte
  498.                 and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail  ;@B01
  499.                 or      byte ptr es:[di-1],dh   ; store trailing system byte ;@B01
  500.             .loop
  501.  
  502. ; if the cell count cause DBCS bisecting, store attribute only.
  503. @@:                                     ; 1990-08-02 updated
  504.                                         ;     fix for starting from max point
  505.             popf                        ; restore frag whether DBCS bisect
  506.             .if     <c>                 ; last cell is pointed to lead byte
  507.                 mov     al,CharBlank    ; last character is blank
  508.                 mov     ah,bh           ; last attribute is leading it
  509.                 stosw                   ; copy char and 1st attr
  510.                 and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail   ;@A04
  511.                                         ; store and system byte
  512.             .endif
  513.  
  514. ; write SBCS characters
  515.         .else short                     ; no
  516. IFDEF EPOCH
  517.             .if     <bit <word ptr [bp].shadow_Flags> and CGAAttr>
  518.                 push    cx
  519.                 push    ax
  520.                 xor     al,al           ; Ignore character byte
  521.                 xchg    al,ah
  522.                                         ; AL - Attr1
  523.                 Call    Translate       ; Common AX -> Epoch AL
  524.                 mov     cl,al           ; CL=AL
  525.                 pop     ax
  526.                 mov     ah,cl           ; AH=CL ( New Attr )
  527.                 pop     cx
  528.             .endif
  529. ENDIF
  530.             .repeat
  531.                 stosw                           ; copy char and 1st attr
  532.                 and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail  ;@B02
  533.                 or      byte ptr es:[di-1],dh   ; store system byte ;@A01
  534. ;@A01           mov     byte ptr es:[di-1],dh   ; store system byte
  535.             .loop
  536.         .endif
  537.  
  538. ; Check if next cell contains a trail byte, if so, erase
  539.         Erase2e
  540.  
  541.         ret
  542. UBNCellToLVB1E  ENDP
  543.  
  544.  
  545. ;Entry
  546. ;  ds:si - LVB pointer
  547. ;  es:di - user buffer pointer
  548. ;  cx    - char length (in byte)
  549.  
  550.  
  551. LVBCharToUB1E   PROC
  552.         public  LVBCharToUB1E
  553.  
  554. ; Check if first cell to copy contains a trail byte, if so, erase
  555.         mov     al,byte ptr [si]        ; AL = first character
  556.         Erase5e                         ; replace AL by blank if trail byte
  557.         dec     cx                      ; count down this character
  558.  
  559.         .if     <ncxz>                  ; branch if only 1 char total
  560.             stosb                       ; store character
  561.             add     si,2                ; skip 2 attributes
  562.             jmp short @F                ; jump into loop to do cx-1 iterations
  563.  
  564.             .repeat
  565.                 movsb                   ; copy character
  566.                 inc     si              ; skip 1 attribute
  567. @@:
  568.             .loop
  569.  
  570. ; Check if last cell to copy contains lead byte, if so, erase
  571. ; We check the source before copy, as then the following trail byte
  572. ; is still attached and we can use the system byte epochDBCSTrail to check.
  573.             mov al,[si]                 ; last character
  574.         .endif
  575.         Erase6e                         ; replace AL by blank if lead byte
  576.         stosb                           ; store character
  577.  
  578.         ret
  579. LVBCharToUB1E   ENDP
  580.  
  581.  
  582. ;Entry
  583. ;  ds:si - LVB pointer
  584. ;  es:di - user buffer pointer
  585. ;  cx    - cell length (in byte) / 2
  586.  
  587.  
  588. LVBCellToUB1E   PROC
  589.         public  LVBCellToUB1E
  590.  
  591. ; Check if first cell to copy contains a trail byte, if so, erase
  592.         mov     ax,[si]                 ; AL = first char, AH = first attr
  593.         Erase5e                         ; replace AL by blank if trail byte
  594.         dec     cx                      ; count down this cell
  595.  
  596.         .if     <ncxz>                  ; branch if this only cell to copy
  597.             stosw                       ; store character and attribute
  598.             add     si,2                ; skip first cell
  599.             jmp short @F                ; do cx-1 iterations
  600.  
  601.             .repeat
  602.                 movsw                   ; copy character and attribute
  603. @@:
  604.             .loop
  605.  
  606. ; Check if last cell to copy contains lead byte, if so, erase
  607. ; We check the source before copy, as then the following trail byte
  608. ; is still attached and we can use the system byte epochDBCSTrail to check.
  609.             mov     ax,[si]             ; last cell
  610.         .endif
  611.         Erase6e                         ; replace AL by blank if lead byte
  612.         stosw                           ; store character and attribute
  613.  
  614.         ret
  615. LVBCellToUB1E   ENDP
  616.  
  617.  
  618. ;Entry
  619. ;  ds:si - source LVB pointer
  620. ;  es:di - destination LVB pointer
  621. ;  cx    - cell length (in byte) / 2
  622. ;  dx    - reserved
  623.  
  624.  
  625. LVBCellToLVB1IE PROC NEAR
  626.         public  LVBCellToLVB1IE
  627.  
  628. ; Check if first source cell to copy contains a trail byte
  629. ; and if so, erase this DBCS character.
  630.         .if     <si ae 2> and
  631.         .if     <bit <byte ptr ds:[si+1]> and epochDBCSTrail>
  632.             mov     byte ptr ds:[si],CharBlank
  633.                                         ; copy blank into this trailing char
  634.             and     byte ptr ds:[si+1],NOT epochDBCSLead+epochDBCSTrail
  635.                                         ; and clear trailing bit
  636.             mov     byte ptr ds:[si-2],CharBlank
  637.                                         ; copy blank into this leading char
  638.             and     byte ptr ds:[si-1],NOT epochDBCSLead+epochDBCSTrail
  639.                                         ; and clear leading bit
  640.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  641.         .endif
  642.  
  643. ; check to see whether we are about to overwrite to a trailing byte
  644. ; and if so, erase preceding lead byte.
  645.         .if     <di ae 2 > and
  646.         .if     <bit <byte ptr es:[di+1]> and epochDBCSTrail>
  647.             mov     byte ptr es:[di-2],CharBlank
  648.                                         ; copy blank into this leading char
  649.             and     byte ptr es:[di-1],NOT epochDBCSLead+epochDBCSTrail
  650.  
  651.                                         ; and clear leading bit
  652.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  653.         .endif
  654.  
  655. ; move cells and DBCS flags
  656.         rep     movsw                   ; copy all remaining cells
  657.  
  658. ; Check if last source cell to copy contains a lead byte
  659. ; and if so, erase this DBCS character and leading character stored.
  660.         .if     <si b [bp].j_lvbsize> and
  661.         .if     <bit <byte ptr ds:[si+1]> and epochDBCSTrail>
  662.             mov     byte ptr ds:[si],CharBlank
  663.                                         ; copy blank into this trailing char
  664.             and     byte ptr ds:[si+1],NOT epochDBCSLead+epochDBCSTrail
  665.                                         ; and clear trailing bit
  666.             mov     byte ptr ds:[si-2],CharBlank
  667.                                         ; copy blank into this leading char
  668.             and     byte ptr ds:[si-1],NOT epochDBCSLead+epochDBCSTrail
  669.                                         ; and clear leading bit
  670.             and     byte ptr ds:[di-1],NOT epochDBCSLead+epochDBCSTrail
  671.                                         ; and clear stored leading bit
  672.             mov     byte ptr ds:[di-2],CharBlank
  673.                                         ; copy blank into stored leading char
  674.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  675.         .endif
  676.  
  677. ; Check if next destination cell contains a trail byte, if so, erase
  678.         .if     <di b [bp].j_lvbsize> and
  679.         .if     <bit <byte ptr es:[di+1]> and epochDBCSTrail>
  680.             mov     byte ptr es:[di],CharBlank
  681.                                         ; copy blank into this trailing char
  682.             and     byte ptr es:[di+1],NOT epochDBCSLead+epochDBCSTrail
  683.                                         ; and clear trailing bit
  684.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  685.         .endif
  686.  
  687.         ret
  688. LVBCellToLVB1IE ENDP
  689.  
  690.  
  691. ;Entry
  692. ;  ds:si - source LVB pointer
  693. ;  es:di - destination pointer
  694. ;  cx    - cell length (in byte) / 2
  695. ;  dx    - reserved
  696.  
  697.  
  698. LVBCellToLVB1DE PROC
  699.         public  LVBCellToLVB1DE
  700.  
  701. ; calculate the valid last cell pointer
  702.         mov     ax,[bp].j_lvbsize
  703.         .if     <ax eq 0FFFFh>          ; 64KB on AVIO
  704.             sub     ax,1
  705.         .else
  706.             sub     ax,2
  707.         .endif
  708.         push    ax                      ; save valid last cell pointer
  709.  
  710. ; Check if first source cell to copy contains a lead byte
  711. ; and if so, erase this DBCS character.
  712.         .if     <si b ax> and
  713.         .if     <bit <byte ptr ds:[si+3]> and epochDBCSTrail>
  714.             mov     byte ptr ds:[si],CharBlank
  715.                                         ; copy blank into this leading char
  716.             and     byte ptr ds:[si+1],NOT epochDBCSLead+epochDBCSTrail
  717.                                         ; and clear leading bit
  718.             mov     byte ptr ds:[si+2],CharBlank
  719.                                         ; copy blank into this trailing char
  720.             and     byte ptr ds:[si+3],NOT epochDBCSLead+epochDBCSTrail
  721.                                         ; and clear trailing bit
  722.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  723.         .endif
  724.  
  725. ; check to see whether we are about to overwrite to a leading byte
  726. ; and if so, erase next trail byte.
  727.         pop     ax                      ; restore valid last cell pointer
  728.         .if     <di b ax > and
  729.         .if     <bit <byte ptr es:[di+3]> and epochDBCSTrail>
  730.             mov     byte ptr es:[di+2],CharBlank
  731.                                         ; copy blank into this leading char
  732.             and     byte ptr es:[di+3],NOT epochDBCSLead+epochDBCSTrail
  733.                                         ; and clear leading bit
  734.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  735.         .endif
  736.  
  737. ; move cells and DBCS flags
  738.         rep     movsw                   ; copy all remaining cells
  739.  
  740. ; Check if last source cell to copy contains a trail byte
  741. ; and if so, erase this DBCS character and trailing character stored.
  742.         .if     <si ge 0> and
  743.         mov     al,byte ptr ds:[si+1]
  744.         and     al,(epochDBCSTrail or epochDBCSLead)
  745.         .if     <al eq epochDBCSLead>
  746.             mov     byte ptr ds:[si],CharBlank
  747.                                         ; copy blank into this leading char
  748.             and     byte ptr ds:[si+1],NOT epochDBCSLead+epochDBCSTrail
  749.                                         ; and clear leading bit
  750.             mov     byte ptr ds:[si+2],CharBlank
  751.                                         ; copy blank into this trailing char
  752.             and     byte ptr ds:[si+3],NOT epochDBCSLead+epochDBCSTrail
  753.                                         ; and clear trailing bit
  754.             and     byte ptr ds:[di+3],NOT epochDBCSLead+epochDBCSTrail
  755.                                         ; and clear stored trailing bit
  756.             mov     byte ptr ds:[di+2],CharBlank
  757.                                         ; copy blank into stored trailing char
  758.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  759.         .endif
  760.  
  761. ; Check if next destination cell contains a lead byte, if so, erase
  762.         .if     <di ge 0> and
  763.         mov     al,byte ptr es:[di+1]
  764.         and     al,(epochDBCSTrail or epochDBCSLead)
  765.         .if     <al eq epochDBCSLead>
  766.             mov     byte ptr es:[di],CharBlank
  767.                                         ; copy blank into this leading char
  768.             and     byte ptr es:[di+1],NOT epochDBCSLead+epochDBCSTrail
  769.                                         ; and clear trailing bit
  770.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  771.         .endif
  772.  
  773.         ret
  774. LVBCellToLVB1DE ENDP
  775.  
  776.  
  777. ; support CheckCharType of DBCS
  778. ;Entry
  779. ;  ds:si - LVB pointer
  780. ;  es:di - user buffer pointer
  781.  
  782. TypeSBCS        equ     0
  783. TypeDBCSLead    equ     2
  784. TypeDBCSTrail   equ     3
  785.  
  786.  
  787. LVBCharTypeToUB1E   PROC
  788.         public  LVBCharTypeToUB1
  789.  
  790.         mov     ah,byte ptr ds:[si+1]   ; get DBCS flag                 ;07Oct91
  791.         and     ah,(epochDBCSTrail or epochDBCSLead)
  792.                                         ; mask
  793.  
  794.         mov     al,TypeSBCS             ; default SBCS
  795.         .if     <ah eq epochDBCSLead>
  796.             mov     al,TypeDBCSLead     ; leading byte
  797.         .elseif <ah eq <epochDBCSTrail or epochDBCSLead>>
  798.             mov     al,TypeDBCSTrail    ; trailing byte
  799.         .endif
  800.  
  801.         xor     ah,ah
  802.         stosw                           ; store character type
  803.  
  804.         ret
  805. LVBCharTypeToUB1E   ENDP
  806.  
  807. ENDIF ;EPOCH
  808.  
  809. ;@A01 12Feb92 AN jc20 js02613
  810. ;@B01 25Feb92 AN jc20 js02800
  811. ;@B02 25Feb92 AN jc20 js02841
  812.  
  813. ;11/20/1992     KY01    Changed the codes accoring to Nakada-san's modification ;;KY01A
  814. ;                       to fix PTR #JS04457 by K. Yokomizo.                     ;;KY01A
  815.