;       SCCSID = @(#)bksxlate.asm	6.1 90/11/16
;       SCCSID = @(#)bksxlate.asm	6.5 90/02/14
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************
        PAGE    60,132
        TITLE   BKSXLATE.ASM - Translate Scan Code to ASCII

;******************************************************************************
;*******   C H A N G E       H I S T O R Y   **********************************
;
;       86/12/11  TPL   Change KBDGETXT to KBDGETCP
;       87/02/25  TPL   Use 0 to indicate current codepage should be used
;                       to translate the record passed.  Input Parmlist
;                       will contain the address to a word of zero.
;@T52   90/01/15  TPL   DCR 704 work
;******************************************************************************

        .286p                           ; 286 Protect Mode instructions

        .xlist
        INCLUDE struc.inc               ; Structured Macros
        INCLUDE bksxxx.inc              ; Equates and structure template file
        INCLUDE bksextrn.inc            ; External data declaration file
        .list

CSEG    SEGMENT BYTE PUBLIC 'CODE'
CSEG    ENDS

IDSEG   SEGMENT BYTE PUBLIC 'DATA'      ; Per process instance data segment
IDSEG   ENDS
;
;       System services routine name(s)
;
        EXTRN   DOSDEVIOCTL:FAR         ; Translate Scan Code to ASCII
        EXTRN   KBDGETCP:FAR            ; Get in-use codepage ID

;$$#I000
        EXTRN WINCONSOLEKBDXLATE:DWORD  ;CDB2
        GDSEG SEGMENT BYTE PUBLIC 'FAR_DATA'                            ;@T52
        GDSEG ENDS
;$$#END

        PUBLIC  Translate

CSEG    SEGMENT BYTE PUBLIC 'CODE'
        ASSUME  CS:CSEG,DS:NOTHING,ES:NOTHING
        PAGE

;********************START OF SPECIFICATIONS****************************
;
; SUBROUTINE NAME:      Translate
;
; DESCRIPTIVE NAME:     Translate Scan Code to ASCII
;
; FUNCTION:     Translate a Scan Code along with Shift State into
;               an ASCII Code.
;
; ENTRY POINT:          Translate
;
;    LINKAGE:           Near Call
;
; INPUT PARAMETERS
;    SYMBOLIC NAME:     KBD_Handle
;
;    DESCRIPTION:       Keyboard Handle
;
;    TYPE:              Word (on stack)
;
;    USAGE:             Keyboard device handle
;
;    SYMBOLIC NAME:     XlateRecAdr
;
;    DESCRIPTION:       Address of Translation Record
;
;    TYPE:              Selector-Offset (on stack) pointing to
;                       a record
;
;    USAGE:             Translation buffer
;
; EXIT-NORMAL:          AX  =   0
;
; EXIT-ERROR:           AX  =   none
;
; INTERNAL REFERENCES:  IDSEG       - Per Process Instance Data Segment
;          ROUTINES:    none
;
; EXTERNAL REFERENCES:  none
;          ROUTINES:    DosDevIOCtl - Translate Scan Code to ASCII
;                       KbdGetCP    - Get in-use codepage ID
;
;******************END OF SPECIFICATIONS********************************
;
;
;Translate PROC  NEAR
; CALLFAR DOSDEVIOCTL                   ; Translate Scan Code to ASCII
; ret                                   ;   using current codepage
;
;Translate ENDP
        PAGE



Translate PROC  NEAR                    ; @@ Version 1.1 code - BEGIN
        ASSUME  DS:IDSEG
;
;************************************************************************
;*  On entry:  DS = IDSEG   ES = GDSEG   AX = 0   DX = KBD_SG           *
;************************************************************************
;

;$$#I001
       .IF <dx A LastBaseSG>
           push  hConsole               ;@@DTF1
           push  [bp].KBD_Handle
           push  [bp].XlateRecSel
           push  [bp].XlateRecOff
           call  ES:WINCONSOLEKBDXLATE  ;CDB2
       .ELSE
;$$#END

        mov     CP_ID,ax                ; Use current codepage to translate
        push    [bp].XlateRecSel        ; Setup:  Address of DATA Parmlist
        push    [bp].XlateRecOff        ;           (translation record)
        push    ds                      ;         Address of INPUT Parmlist
        push    OFFSET CP_ID            ;           (codepage ID)
        push    79H                     ;         Function code
        push    KEYBOARD                ;         Category code
        push    Dev_Handle              ;         Device handle
        call    DOSDEVIOCTL             ; Translate Scan code to ASCII

;$$#I002
       .ENDIF
;$$#END

        ret

Translate ENDP                          ; @@ Version 1.1 code - END

CSEG    ENDS
        END
