;       SCCSID = @(#)bksflush.asm	6.1 90/11/16
;       SCCSID = @(#)bksflush.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   BKSFLUSH.ASM - Flush Keyboard Input Buffer.

;******************************************************************************
;*******   C H A N G E       H I S T O R Y   **********************************
;******************************************************************************
;@T52   01-15-90  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'
IDSEG   ENDS

        EXTRN   DOSDEVIOCTL:FAR         ; DOS Generic IOCTL

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

        PUBLIC  FlushBuffer

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

;************************ START OF SPECIFICATIONS ***********************
;*                                                                      *
;*  SUBROUTINE NAME:    FlushBuffer                                     *
;*                                                                      *
;*  DESCRIPTIVE NAME:   Flush keyboard input buffer.                    *
;*                                                                      *
;*  FUNCTION:   Discard all character from the keyboard input buffer.   *
;*                                                                      *
;*  NOTES:      Executes on level 3 - Protect Mode ONLY                 *
;*                                                                      *
;*  ENTRY POINT:        FlushBuffer                                     *
;*      LINKAGE:        call near                                       *
;*                                                                      *
;*  INPUT:      Input parameters are on stack                           *
;*                                                                      *
;*                      KBD_Handle      word                            *
;*                                                                      *
;*  EXIT NORMAL:        AX = 0                                          *
;*                                                                      *
;*  EXIT ERROR:         AX = ERROR_BAD_COMMAND                          *
;*                                                                      *
;*  INTERNAL REFERENCES:  Dev_Handle                                    *
;*           ROUTINES:    None                                          *
;*                                                                      *
;*  EXTERNAL REFERENCES:  None                                          *
;*           ROUTINES:    DOSDEVIOCTL                                   *
;*                                                                      *
;************************* END OF SPECIFICATIONS ************************



FlushBuffer PROC   NEAR
        ASSUME  DS:IDSEG
;
;************************************************************************
;*  On entry:  DS = IDSEG   AX = 0                                      *
;*             ES = GDSEG   DX = KBD_SG                                 *
;************************************************************************
;

;$$#I001
       .IF <dx A LastBaseSG>            ; Winthorn screen group?
           push  hConsole               ;@@DTF1
           push  [bp].KBD_Handle
           call  ES:WINCONSOLEFLUSHKEYEVENTS ;CDB2
       .ELSE
;$$#END
        push    ax                      ; Dummy Data parameter
        push    ax
        push    ds                      ; Dummy ParmList parameter
        push    ax
        push    01H                     ; Function: flush input buffer
        push    0BH                     ; Category: Device buffer control
        push    Dev_Handle              ; Setup parameter - place 'KBD:'
                                        ;   device handle on the stack
        call    DOSDEVIOCTL
;$$#I002
       .ENDIF

;$$#END
        ret

FlushBuffer ENDP

CSEG    ENDS
        END
