;       SCCSID = @(#)demfcb.asm	6.2 91/07/12
;
;   Revisions:
;
;Local  DCR/
;Tag    PTM(R)  Who     When/What
;               danno   03-Mar-1989
;                       Created for MVDM
;
;   GetLet
;   TESTKANJ

.xlist
include v86seg.inc

.xcref
include basemaca.inc
include osmaca.inc
include oldmaca.inc
include demmac.inc
include demdbcs.inc
include dossymc.inc
include doscntry.inc
include dos34.inc
include struc30.inc
.cref
.list


TableLook = -1          ; Uses tables for character matching

    .386p

        ReferV86    SpaceFlag,BYTE
        ReferV86    DOS34_Flag,WORD
        ReferV86    File_UCase_Tab,BYTE
        ReferV86    Country_CdPg,BYTE


V86CODE SEGMENT
        ASSUME  CS:V86GROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING

        EXTRN   GetVisDrv:NEAR



Break   <GETLET, DELIM -- CHECK CHARACTERS AND CONVERT>

If TableLook
ChType  Macro   ch,bits
        ORG     CharType-Zero+ch
        db      bits
        ENDM

V86TABLE   SEGMENT

Zero    label   byte

        PUBLIC  CharType
Public FCB001S,FCB001E
FCB001S  label byte
CharType    DB  256 dup (-1)
        ChType  ".", <LOW (NOT (     fChk))>
        ChType  '"', <LOW (NOT (fFCB+fChk))>
        ChType  "/", <LOW (NOT (fFCB+fChk))>
        ChType  "\", <LOW (NOT (fFCB+fChk))>
        ChType  "[", <LOW (NOT (fFCB+fChk))>
        ChType  "]", <LOW (NOT (fFCB+fChk))>
        ChType  ":", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  "<", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  "|", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  ">", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  "+", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  "=", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  ";", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  ",", <LOW (NOT (fFCB+fChk+fDelim))>
        ChType  0,   <LOW (NOT (fFCB+fChk))>           ; NUL
        ChType  1,   <LOW (NOT (fFCB+fChk))>           ; ^A
        ChType  2,   <LOW (NOT (fFCB+fChk))>           ; ^b
        ChType  3,   <LOW (NOT (fFCB+fChk))>           ; ^c
        ChType  4,   <LOW (NOT (fFCB+fChk))>           ; ^d
        ChType  5,   <LOW (NOT (fFCB+fChk))>           ; ^e
        ChType  6,   <LOW (NOT (fFCB+fChk))>           ; ^f
        ChType  7,   <LOW (NOT (fFCB+fChk))>           ; ^g
        ChType  8,   <LOW (NOT (fFCB+fChk))>           ; ^h
        ChType  9,   <LOW (NOT (fFCB+fChk+fDelim+fSpChk))> ; Tab
        ChType  10,  <LOW (NOT (fFCB+fChk))>           ; ^j
        ChType  11,  <LOW (NOT (fFCB+fChk))>           ; ^k
        ChType  12,  <LOW (NOT (fFCB+fChk))>           ; ^l
        ChType  13,  <LOW (NOT (fFCB+fChk))>           ; ^m
        ChType  14,  <LOW (NOT (fFCB+fChk))>           ; ^n
        ChType  15,  <LOW (NOT (fFCB+fChk))>           ; ^o
        ChType  16,  <LOW (NOT (fFCB+fChk))>           ; ^p
        ChType  17,  <LOW (NOT (fFCB+fChk))>           ; ^q
        ChType  18,  <LOW (NOT (fFCB+fChk))>           ; ^r
        ChType  19,  <LOW (NOT (fFCB+fChk))>           ; ^s
        ChType  20,  <LOW (NOT (fFCB+fChk))>           ; ^t
        ChType  21,  <LOW (NOT (fFCB+fChk))>           ; ^u
        ChType  22,  <LOW (NOT (fFCB+fChk))>           ; ^v
        ChType  23,  <LOW (NOT (fFCB+fChk))>           ; ^w
        ChType  24,  <LOW (NOT (fFCB+fChk))>           ; ^x
        ChType  25,  <LOW (NOT (fFCB+fChk))>           ; ^y
        ChType  26,  <LOW (NOT (fFCB+fChk))>           ; ^z
        ChType  27,  <LOW (NOT (fFCB+fChk))>           ; ^[
        ChType  28,  <LOW (NOT (fFCB+fChk))>           ; ^\
        ChType  29,  <LOW (NOT (fFCB+fChk))>           ; ^]
        ChType  30,  <LOW (NOT (fFCB+fChk))>           ; ^^
        ChType  31,  <LOW (NOT (fFCB+fChk))>           ; ^_
        ChType  " ", <LOW (NOT (     fChk+fDelim+fSpChk))>
        ChType  255, -1
FCB001E label byte
V86TABLE   ENDS
ENDIF
;
; Get a byte from [SI], convert it to upper case, and compare for delimiter.
; ZF set if a delimiter, CY set if a control character (other than TAB).
;
; DOS 3.3 modification for file char upper case.    F.C. 5/29/86
        procedure   GetLet,NEAR
        LODSB
  entry GetLet2                             ;AN000;; called by uCase
        PUSH    BX
        MOV     BX,OFFSET V86GROUP:FILE_UCASE_TAB+2
  getget:
        CMP     AL,"a"
        JB      short CHK1
        CMP     AL,"z"
        JA      short CHK1
        SUB     AL,20H          ; Convert to upper case
CHK1:
        CMP     AL,80H          ; DOS 3.3
        JB      short GOTIT     ; DOS 3.3
        SUB     AL,80H          ;translate to upper case with this index
;
        XLAT    BYTE PTR CS:[BX]
If TableLook
GOTIT:
        PUSH    AX
        MOV     BX,OFFSET V86GROUP:CharType
        XLAT    BYTE PTR CS:[BX]

        TEST    AL,fChk
        POP     AX
        POP     BX
        RET
  entry GetLet3                              ;AN000; called by uCase
        PUSH    BX                           ;AN000;
        JMP     getget                       ;AN000;

ELSE
GOTIT:
        POP     BX
        CMP     AL,"."
        retz
        CMP     AL,'"'
        retz
        CALL    PATHCHRCMP
        retz
        CMP     AL,"["
        retz
        CMP     AL,"]"
        retz
ENDIF

entry   DELIM

IF TableLook
        PUSH    AX
        PUSH    BX
        MOV     BX,OFFSET V86GROUP:CharType
        XLAT    BYTE PTR CS:[BX]
        TEST    AL,fDelim
        POP     BX
        POP     AX
        RET
ELSE
        CMP     AL,":"
        retz

        CMP     AL,"<"
        retz
        CMP     AL,"|"
        retz
        CMP     AL,">"
        retz

        CMP     AL,"+"
        retz
        CMP     AL,"="
        retz
        CMP     AL,";"
        retz
        CMP     AL,","
        retz
ENDIF
entry SPCHK
IF  TableLook
        PUSH    AX
        PUSH    BX
        MOV     BX,OFFSET V86GROUP:CharType
        XLAT    BYTE PTR CS:[BX]
        TEST    AL,fSpChk
        POP     BX
        POP     AX
        RET
ELSE
        CMP     AL,9            ; Filter out tabs too
        retz
; WARNING! " " MUST be the last compare
        CMP     AL," "
        return
ENDIF
EndProc GetLet


 IF  DBCS
;---------------------  2/12/KK
; Function: Check if an input byte is in the ranges of DBCS vectors.
;
;   Input:   AL ; Code to be examined
;
;  Output:   ZF = 1 :  AL is SBCS      ZF = 0 : AL is a DBCS leading byte
;
;  Register:  All registers are unchanged except FL
;
procedure   TESTKANJ,NEAR                                                       ;AN000;
        call    Chk_DBCS                                                        ;AN000;
        jc      short TK_DBCS                                                         ;AN000;
        cmp     AL,AL           ; set ZF                                        ;AN000;
        return                                                                  ;AN000;
TK_DBCS:
        PUSH    AX                                                              ;AN000;
        XOR     AX,AX           ;Set ZF                                         ;AN000;
        INC     AX              ;Reset ZF                                       ;AN000;
        POP     AX                                                              ;AN000;
        return                                                                  ;AN000;
EndProc TESTKANJ                                                                ;AN000;
;
Chk_DBCS        PROC                                                            ;AN000;
        PUSH    DS                                                              ;AN000;
        PUSH    SI                                                              ;AN000;
        PUSH    BX                                                              ;AN000;
        Context DS                                                              ;AN000;
        MOV     BX,offset V86GROUP:COUNTRY_CDPG.ccSetDBCS                       ;AN000;
        LDS     SI,[BX+1]               ; set EV address to DS:SI               ;AN000;
        ADD     SI,2                    ; Skip length                           ;AN000;
DBCS_LOOP:
        CMP     WORD PTR [SI],0         ; terminator ?                          ;AN000;
        JE      short NON_DBCS          ; if yes, no DBCS                       ;AN000;
        CMP     AL,[SI]                 ; else                                  ;AN000;
        JB      short DBCS01            ; check if AL is                        ;AN000;
        CMP     AL,[SI+1]               ; in a range of Ev                      ;AN000;
        JA      short DBCS01            ; if yes, DBCS                          ;AN000;
        STC                             ; else                                  ;AN000;
        JMP     short DBCS_EXIT         ; try next DBCS Ev                      ;AN000;
DBCS01:
        ADD     SI,2                                                            ;AN000;
        JMP     DBCS_LOOP                                                       ;AN000;
NON_DBCS:
        CLC                                                                     ;AN000;
DBCS_EXIT:
        POP     BX                                                              ;AN000;
        POP     SI                                                              ;AN000;
        POP     DS                                                              ;AN000;
        RET                                                                     ;AN000;
Chk_DBCS        ENDP                                                            ;AN000;
 ENDIF                                                                          ;AN000;


V86CODE ENDS

        END
