;       SCCSID = @(#)bvsdbcs.inc	6.1 90/11/16
;SCCSID = @(#)bvsdbcs.inc	6.3 90/01/30
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************

; OEM specific values and macros

TRUE	equ	1
FALSE	equ	0

; Check Lead byte
; al= potential lead byte
; exit: Cy set if lead byte
;
CheckLeadByte macro

	push	si
	push	dx
	push	cx
	clc				;clear carry flag
	mov	cx,size bvs_DBCSEvBuff/2 ; set loop count
	mov	si,OFFSET bvs_DBCSEvBuff

	.repeat
	    mov     dx,[si]		;Get one table entry
	    inc     si
	    inc     si

	    .if     <zero dx>
	    .leave
	    .endif

	    .if     <al ae dl> and	;Start value ;@@A
	    .if     <al be dh>		;Stop value
		stc			;Set carry flag
	    .leave
	    .endif
	.loop

	pop	cx
	pop	dx
	pop	si
	endm

; Check Not Single Cell DBCS
;
; This macro needs to be fast as fast as possible. It is in the
; inner loop of the BvsWrtTTY function.
;
; AX= DBCS value
; Exit: Cy set - Not Single Cell
;
CheckNotSingleCell macro

	.if	<[bx].bvs_dbcstbllen ae 4> ;@TB11 at least one full entry

	    push    cx			; save cx
	    push    bx			; save bx
	    mov     cx,[bx].bvs_dbcstbllen ; (cx) = length of the table
	    shr     cx,2		; (cx) = number of iterations

	    .repeat
		cmp	ax,[bx].bvs_dbcstbl ; could the character be in this range?
		inc	bx		; do not affect carry flag
		inc	bx		; do not affect carry flag
		.if	<nc>		;   no, go to the next range

		    cmp     [bx].bvs_dbcstbl,ax ; Is the character in the double cell range?
		    cmc 		;@TB11 Yes => (dbcstbl[bx] >= AX) => NC
		.leave	<c>		;   yes, exit

		.endif
		add	bx,2		; (bx) = table offset, carry clear
	    .loop			; more of the table to examine

	    pop     bx			; restore bx, do not change carry
	    pop     cx			; restore cx, do not change carry
	.endif
	endm

;@TB11 = 05/24/89 TLB, Changes requested by PhilipL via PTR B783954.
