;       SCCSID = @(#)bksdata.asm        6.1 90/11/16
;       SCCSID = @(#)bksdata.asm        6.9 90/08/08
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************
        PAGE    60,132
        TITLE   BKSDATA.ASM - Base Keyboard Subsystem Data Declaration

;******************************************************************************
;*******   C H A N G E       H I S T O R Y   **********************************
;
;       87/04/07  TPL   Comment out all unused data variables
;       87/05/10  TPL   Pull out Ctrl_U (delete line) function from table
;       87/07/09  TPL   Add per process variable - Open_Count.
;       88/04/18  TPL   @@TPL - Allow KbdSetCustXT with handle 0.
;P2847  88/06/01  THG   Call Win API with logical handle -or- Win_Handle
;P2981  88/06/15  THG   Add Proc_Hand field to IDSEG for KBD_Handle storage
;DCR357 04-24-89  THG   Ferrari Extended iff E0H charcode AND status bit 1 set
;B710438 11-06-89 THG   Add support for CS 243 codepage
;@T52   01-15-90  TPL   DCR 704 work
;B711338 02-15-90 THG   DCR704 combined GDSEG, so preallocate space for CPids
;@T73   07/27/90 TPL    Code/data reduction/optimization and swap tune
;******************************************************************************

        .xlist
        INCLUDE bksxxx.inc              ; Equates and structure template file
        INCLUDE viopord.inc             ; Whield ordinals               ;MDLL
        .list
        ;
        ;****************************************************************
        ;*  Global Data Area Default Values                             *
        ;****************************************************************
        ;
GDSEG   SEGMENT BYTE PUBLIC 'FAR_DATA'                                  ;@T52

        Shared_Handle   dw      0       ; Device handle explicit DosOpen
        Dev_Name        db  'KBD$    '  ; Name of device name
                        db      0       ; ASCIIZ string terminator
        Action_Taken    dw      0       ; Action taken from DosOpen

        ESCTAB          db      00      ; Ctrl_C or Ctrl_Break
                        db      59      ; F1  - Copy one character
                        db      60      ; F2  - Copy to character
                        db      61      ; F3  - Copy line
                        db      62      ; F4  - Skip to character
                        db      63      ; F5  - Re-edit line (new template)
                        db      64      ; F6  - Ctrl_Z
                        db      65      ; F7  - Escape character
                        db      75      ; <-  - Backspace
                        db      77      ; ->  - Copy one character
                        db      82      ; Ins - Insert mode toggle
                        db      83      ; Del - Skip one character
                        db      83      ; End of Table
        ESCTABLEN       EQU     $ - ESCTAB

        EDITTAB         db      "F"-"@"
                        db      DEL     ; Delete
                        db      BKSPACE ; Backspace
                        db      "W"-"@" ; Word Delete
                        db      LF      ; CRLF
                        db      ESCCHAR ; Escape
                        db      "Z"-"@" ; Ctrl_Z
                        db      LF      ; End of Table
        EDITTABLEN      EQU     $ - EDITTAB

;Winthorn Dynamic link module entry points and module names             CDB2
;The code is table driven and therefore care should be taken in         CDB2
;rearranging this table.                                                CDB2

                PUBLIC  WINCONSOLEREADKEYEVENT          ;               CDB2
                PUBLIC  WINCONSOLEFLUSHKEYEVENTS        ;               CDB2
                PUBLIC  WINCONSOLEOPENKBD               ;               CDB2
                PUBLIC  WINCONSOLECLOSEKBD              ;               CDB2
                PUBLIC  WINCONSOLESETSTATUS             ;               CDB2
                PUBLIC  WINCONSOLEGETSTATUS             ;               CDB2
                PUBLIC  WINCONSOLESETCP                 ;               CDB2
                PUBLIC  WINCONSOLEGETCP                 ;               CDB2
                PUBLIC  WINCONSOLEKBDXLATE              ;               CDB2
                PUBLIC  WINCONSOLESETCUSTXT             ;               CDB2
                PUBLIC  WINCONSOLEGETFOCUS              ;               CDB2
                PUBLIC  WINCONSOLEFREEFOCUS             ;               CDB2
                PUBLIC  WINSYNCWITHPS                   ;               CDB2
                PUBLIC  LOCKVIOPS                       ;               CDB2
                PUBLIC  UNLOCKVIOPS                     ;               CDB2
                PUBLIC  WINCONSOLEGETKBDHANDLE          ;               CDB2
                PUBLIC  ShieldEntries                   ;               CDB2
                PUBLIC  Shield_DLL                      ;               CDB2
                PUBLIC  ShieldHandle                    ;               MDLL
ShieldEntries   dw      16              ;Number of Shield Entries       CDB2
ShieldHandle    dw      0               ;SHIELD module handle           CDB2
WINSYNCWITHPS           dd      ORD_WINSYNCWITHPS                     ; MDLL
WINCONSOLEOPENKBD       dd      ORD_WINCONSOLEOPENKBD                 ; MDLL
WINCONSOLECLOSEKBD      dd      ORD_WINCONSOLECLOSEKBD                ; MDLL
WINCONSOLESETSTATUS     dd      ORD_WINCONSOLESETSTATUS               ; MDLL
WINCONSOLEGETSTATUS     dd      ORD_WINCONSOLEGETSTATUS               ; MDLL
WINCONSOLESETCP         dd      ORD_WINCONSOLESETCP                   ; MDLL
WINCONSOLEGETCP         dd      ORD_WINCONSOLEGETCP                   ; MDLL
WINCONSOLEKBDXLATE      dd      ORD_WINCONSOLEKBDXLATE                ; MDLL
WINCONSOLESETCUSTXT     dd      ORD_WINCONSOLESETCUSTXT               ; MDLL
WINCONSOLEGETFOCUS      dd      ORD_WINCONSOLEGETFOCUS                ; MDLL
WINCONSOLEFREEFOCUS     dd      ORD_WINCONSOLEFREEFOCUS               ; MDLL
WINCONSOLEREADKEYEVENT  dd      ORD_WINCONSOLEREADKEYEVENT            ; MDLL
WINCONSOLEFLUSHKEYEVENTS dd     ORD_WINCONSOLEFLUSHKEYEVENTS          ; MDLL
LOCKVIOPS               dd      ORD_LOCKVIOPS                         ; MDLL
UNLOCKVIOPS             dd      ORD_UNLOCKVIOPS                       ; MDLL
WINCONSOLEGETKBDHANDLE  dd      ORD_WINCONSOLEGETKBDHANDLE            ; MDLL
Shield_DLL      db      'PMVIOP',0,0    ;Name of SHIELD.DLL             MDLL

;********** Codepage Support ***********; @@ Version 1.1 data - BEGIN
;********** Codepage Support ***********;
        CDIB_Label      db      '\SHAREMEM\DOS\CDIB',NULL
        CDIB_Sel        dw      0       ; Codepage Data Information Block
                                        ;   selector
        Num_of_CP       dw      1       ; # of codepage(s) supported
        CP_InitFlag     db      0       ; xxxxxxx1 - codepage initialization
                                        ;            already occured
                                        ; xxxxxx1x - Codepage support
                        db      0       ; Word alignment                ;@T73
        Xlate_Handle    dw      0       ; Translate table file handle
        Xlate_Tbl_Start dw      0       ; Offset to the start of translation
                                        ;   table within buffer
        Xlate_Tbl_Sel   dw      0       ; Translate table buffer selector
        Xlate_Tbl_CP    dw      0       ; Translate table ID (codepage ID)
        Xlate_Tbl_Index dw      0       ; Translate table Index
        Cntry_ID        dw      0       ; Country ID
        Subtype         db 6 dup (0)    ; Country subtype
        UK166           db      'KU166 '; UK 166
        UK168           db      'KU168 '; UK 168
        FR189           db      'RF189 '; FR 189
        FR120           db      'RF120 '; FR 120
        IT141           db      'TI141 '; IT 141
        IT142           db      'TI142 '; IT 142
        CS243           db      'SC243 '; CS 243                       ;B710438
        CS245           db      'SC245 '; CS 245                       ;B710438
        PC_Model        db      0       ; PC model type
        PC_Submodel     db      0       ; PC sub-model type
;@@TPL --- Begin
        Handle0CP_Save  dw 16 dup (-1)  ; CP save area for handle 0 Custom CP
        Handle0CCP_PID  dw 16 dup (0)   ; PID save area for handle 0 Custom CP
;@@TPL --- End
        GlobalSeg       dw      0       ; Global information selector
        LocalSeg        dw      0       ; Local information selector
        LBaseSG         dw      0       ; Last base screen group #
;$$#END
        Kbd_CP0         dw      0       ; "ROM" codepage ID
        Kbd_CP1         dw      0       ; space for other codepage IDs ;B711338
        Kbd_CP2         dw      0       ;                              ;B711338
        Kbd_CP3         dw      0       ;                              ;B711338
        Kbd_CP4         dw      0       ;                              ;B711338
;********** Codepage Support ***********; @@ Version 1.1 data - END

GDSEG   ENDS
        PAGE
        ;
        ;****************************************************************
        ;*  Per Process Instance Data Area Default Values               *
        ;****************************************************************
        ;
IDSEG   SEGMENT BYTE PUBLIC 'DATA'

;$$#I001
        Shield_Scratch  dw      0       ;Scratch (work) area
        KBD_SG          dw      -1      ;Current Screen Group
        LastBaseSG      dw      0       ;Last (ie highest) Base CPDOS SG No.
        Cooked_Mode     db      8       ;4 = cooked (ascii), 8 = raw (binary)
                        db      0       ;Word alignment                 ;@T73
        Proc_Hand       dw      0       ;KBD_Handle of calling process  ;P2981
        Win_Handle      dw      0       ;Per-proc Winthorn console hand ;P2847
        hConsole        dw      0       ; Shield Console Handle ;@@DTF1
        moufilter       dw      0       ; Mouse Filter Mask     ;@@DTF1
        PS_Sel          dw      0       ; Base PS Selector ;@@DTF ;@@DTF1
;$$#END

        Dev_Handle      dw      0       ; To be used for DOSDEVIOCTL calls
        Echo_Mode       db      1       ;   1 = ECHO ON
                                        ;   2 = ECHO OFF
        Insert_Mode     db      0       ; Insert Mode toggle switch:
                                        ;   0 = REPLACE
                                        ;   1 = INSERT
        Entry_Count     db      0       ; Entry count for re-entrancy
        Sentinel        db      0       ; Termination indicator:
                                        ;   1 = ENTER   Normal termination
                                        ;               condition for COOKED
                                        ;               mode operation
        Transfer_Count  dw      ?       ; Character transfer count:
                                        ;  0x0H = No character available
                                        ;  0x1H = 1  character read
        StartPos        db      ?       ; Starting column position (Max. 255)
        CurrentPos      db      ?       ; Current column position (Max. 255)
        TA_Type         db      ?       ; TurnAround character type:
                                        ;   0 = Normal
                                        ;   1 = Extended
        TA_Char         db      CR      ; TurnAround character - Carriage Ret

                                        ; Temporary buffer used by
                                        ;   GetStringIn to hold the
                                        ;   Char record:   or   CPR record:
                                        ;                   |
        CPR_BufO        LABEL   WORD    ;                   |   Buffer offset
        Char_Code       db      ?       ;   Character Code  |
        Scan_Code       db      ?       ;   Scan Code       |
        CPR_BufS        LABEL   WORD    ;                   |   Buffer selector
        Status          db      ?       ;   Status:         |
                                        ;     01x00000 - Final Char, interim
                                        ;                character flag OFF
                                        ;     10x00000 - Interim Character
                                        ;     11x00000 - Final Char, interim
                                        ;                character flag ON
                                        ;     xx100000 - "on the spot"
                                        ;                conversion
                                        ;     xxxxxx1x - Ext. Enh. Key   ;DCR357
                                        ;     00x00001 - Shift State Report ON
                        db      ?       ;   NLS Shift State |
        CPR_Length      LABEL   BYTE    ;                   |   CPR length
        Shift_State     LABEL   WORD    ;   Shift State:    |
                        db      ?       ;     low byte =    |
                                        ;     xxxxxxx1 - Right Shift down
                                        ;     xxxxxx1x - Left Shift down
                                        ;     xxxxx1xx - Ctrl key down
                                        ;     xxxx1xxx - Alt key down
                                        ;     xxx1xxxx - Scroll Lock ON
                                        ;     xx1xxxxx - Num Lock ON
                                        ;     x1xxxxxx - Caps Lock ON
                                        ;     1xxxxxxx - Insert ON
        CPR_Action      LABEL   BYTE    ;                   |   CPR action
                        db      ?       ;     high byte =   |
                                        ;     xxxxxxx1 - Left Ctrl down
                                        ;     xxxxxx1x - Left Alt down
                                        ;     xxxxx1xx - Right Ctrl down
                                        ;     xxxx1xxx - Right Alt down
                                        ;     xxx1xxxx - Scroll Lock down
                                        ;     xx1xxxxx - Num Lock down
                                        ;     x1xxxxxx - Caps Lock down
                                        ;     1xxxxxxx - SysReq down
                                        ;                   |
                                        ;   Time Stamp:
        TimeStamp       db      0       ;     byte 1  -  Hours
                        db      0       ;     byte 2  -  Minutes
                        db      0       ;     byte 3  -  Seconds
                        db      0       ;     byte 4  -  1/100th second

        ANSI_State      db      OFF     ; ANSI ON/OFF indicator
                        db      0
        Buf_Position    dw  OFFSET KeyDefBuf ; Pointer to current character
                                             ;   in KeyDefBuf
        Buf_End         dw  OFFSET KeyDefBuf ; Pointer to the end KeyDefBuf
                                             ; ANSI KeyDef parameter block:
        KeyDefBufO      dw  OFFSET KeyDefBuf ;   KeyDefBuf buffer address
        KeyDefBufS      dw      ?            ;
        Buf_Length      db      ?            ;   End of KeyDefBuf buffer:
                                             ;     0 ==> Empty
        Action          db      READ         ;   Read indicator
        KeyDefChar      dw      ?            ;   Character to be check by ANSI
        KeyDefBuf       db  128 dup(0)  ; Buffer for ANSI key reassignment
        WorkBuf         db  255 dup(0)  ; Buffers for template or editing

;********** Codepage Support ***********; @@ Version 1.1 data - BEGIN
;********** Codepage Support ***********;
        Open_Count      dw      0       ; Open count for each KBDOPEN
        Bond_Handle     dw      0       ; Logical bond handle
        Flag            db      0       ; xxxxxxx0 - normal codepage in-use
                                        ; xxxxxxx1 - custom codepage in-use
        Custom_Tbl_Off  dw      0       ; Custom codepage address
        Custom_Tbl_Sel  dw      0       ;
        Previous_CP     dw      0       ; Previously active codepage ID
                                        ;   when custom codepage is in-use
        CP_Index        dw      0       ; Codepage Index
;********** Codepage Support ***********; @@ Version 1.1 data - END

;********** DBCS Enabling **************;
;********** DBCS Enabling       The following data area will be used
;********** DBCS Enabling       for DosGetDBCSEV call. The code range
;********** DBCS Enabling       of the 1st byte of DBCS double byte
;********** DBCS Enabling       character will be in CRange area.
;********** DBCS Enabling **************;
        CCode           dw      0       ; @  Country Code
        CP_ID           dw      0       ; @  Codepage ID
        CRange          db  10 dup (0)  ; DBCS code ranges
        LCRANGE         EQU     $ - CRange
        HALF_LCRANGE    EQU     LCRANGE/2
;********** DBCS Enabling **************;

IDSEG   ENDS
        PAGE



        PUBLIC  Action
        PUBLIC  Action_Taken
        PUBLIC  ANSI_State
        PUBLIC  Buf_End
        PUBLIC  Buf_Length
        PUBLIC  Buf_Position
        PUBLIC  Char_Code
;$$#I002
        PUBLIC  Cooked_Mode
;$$#END
        PUBLIC  CPR_Action
        PUBLIC  CPR_Length
        PUBLIC  CPR_BufO
        PUBLIC  CPR_BufS
        PUBLIC  CurrentPos
        PUBLIC  Dev_Handle
        PUBLIC  Dev_Name
        PUBLIC  Echo_Mode
        PUBLIC  EDITTAB
        PUBLIC  EDITTABLEN
        PUBLIC  Entry_Count
        PUBLIC  ESCTAB
        PUBLIC  ESCTABLEN
;$$#I003
        PUBLIC  GlobalSeg
        PUBLIC  hConsole
        PUBLIC  Win_Handle                                              ;P2847
;$$#END
        PUBLIC  Insert_Mode
;$$#I004
        PUBLIC  KBD_SG
        PUBLIC  LBaseSG
;$$#END
        PUBLIC  KeyDefBuf
        PUBLIC  KeyDefBufO
        PUBLIC  KeyDefBufS
        PUBLIC  KeyDefChar
;$$#I005
        PUBLIC  LastBaseSG
        PUBLIC  LocalSeg
        PUBLIC  Moufilter
        PUBLIC  PS_Sel          ;@@DTF
;$$#END
        PUBLIC  Scan_Code
        PUBLIC  Sentinel
        PUBLIC  Shared_Handle
;$$#I006
        PUBLIC  Shield_Scratch

;$$#END
        PUBLIC  Shift_State
        PUBLIC  StartPos
        PUBLIC  Status
        PUBLIC  TA_Type
        PUBLIC  TA_Char
        PUBLIC  TimeStamp
        PUBLIC  Transfer_Count
        PUBLIC  WorkBuf

;********** DBCS Enabling **************;
        PUBLIC  CCode                   ;
        PUBLIC  CP_ID                   ;
        PUBLIC  CRange                  ;
        PUBLIC  LCRANGE                 ;
        PUBLIC  HALF_LCRANGE            ;
;********** DBCS Enabling **************;

;********** Codepage Support ***********;
        PUBLIC  CDIB_Label              ;
        PUBLIC  CDIB_Sel                ;
        PUBLIC  Num_of_CP               ;
        PUBLIC  CP_InitFlag             ;
        PUBLIC  Xlate_Handle            ;
        PUBLIC  Xlate_Tbl_Start         ;
        PUBLIC  Xlate_Tbl_Sel           ;
        PUBLIC  Xlate_Tbl_CP            ;
        PUBLIC  Cntry_ID                ;
        PUBLIC  Subtype                 ;
        PUBLIC  UK166                   ;
        PUBLIC  FR189                   ;
        PUBLIC  IT141                   ;
        PUBLIC  CS243                   ;
        PUBLIC  PC_Model                ;
        PUBLIC  PC_Submodel             ;
;@@TPL --- Begin
        PUBLIC  Handle0CP_Save          ;
        PUBLIC  Handle0CCP_PID          ;
;@@TPL --- End
        PUBLIC  Xlate_Tbl_Index         ;
        PUBLIC  Kbd_CP0                 ;
        PUBLIC  Kbd_CP1                 ;
        PUBLIC  Kbd_CP2                 ;
        PUBLIC  Kbd_CP3                 ;
        PUBLIC  Kbd_CP4                 ;
        PUBLIC  Custom_Tbl_Off          ;
        PUBLIC  Custom_Tbl_Sel          ;
        PUBLIC  Previous_CP             ;
        PUBLIC  CP_Index                ;
        PUBLIC  Open_Count              ;
        PUBLIC  Bond_Handle             ;
        PUBLIC  Flag                    ;
        PUBLIC  Proc_Hand               ;caller's KBD_Handle            ;P2981
;********** Codepage Support ***********;

        END
