home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / PIBTERM / PIBT41S4.ARC / STUFFKBD.MOD < prev    next >
Encoding:
Text File  |  1987-12-02  |  2.9 KB  |  63 lines

  1. (*---------------------------------------------------------------------*)
  2. (*       Clr_Kbd_Buf --- Clear contents of keyboard buffer             *)
  3. (*---------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Clr_Kbd_Buf;
  6.  
  7. VAR
  8.    Kbd_Head  : BYTE ABSOLUTE $0000:$041A;
  9.    Kbd_Tail  : BYTE ABSOLUTE $0000:$041C;
  10.  
  11. BEGIN (* Clr_Kbd_Buf *)
  12.  
  13.    Kbd_Head := Kbd_Tail;
  14.  
  15. END   (* Clr_Kbd_Buf *);
  16.  
  17. (*---------------------------------------------------------------------*)
  18. (*       Stuff_Kbd_Buf --- Stuff a character in keyboard buffer        *)
  19. (*---------------------------------------------------------------------*)
  20.  
  21. PROCEDURE Stuff_Kbd_Buf( In_Chr: INTEGER; Clr_Kbd : BOOLEAN );
  22.  
  23. VAR
  24.    Bool_Val : BOOLEAN;
  25.  
  26.     {  Causes a character to be received as if a key had been pressed.
  27.        In_Chr is an integer representing the character to be received.
  28.        If the character is an ASCII character or part of the extended
  29.        character set (#128..#255) the integer will be in the range
  30.        0..255. If a `special' key, function key or Alt key combination
  31.        is to be received In_Chr should equal the scan code of the
  32.        desired key * 256. e.g. The scan code for <Alt><1> is 120 decimal
  33.        $78 hex, so In_Chr should be 30720 decimal or $7800 hex to produce
  34.        the effect of pressing <Alt><1>. }
  35.  
  36. BEGIN (* Stuff_Kbd_Buf *)
  37.                                    (* Clear keyboard if desired *)
  38.    IF Clr_Kbd THEN
  39.       Clr_Kbd_Buf;
  40.  
  41.    INLINE
  42.       ($1E/             (*      PUSH    DS          Save DS and change it      *)
  43.        $B8/$40/$00/     (*      MOV     AX,0040     to point to seg 0040:      *)
  44.        $8E/$D8/         (*      MOV     DS,AX                                  *)
  45.        $FA/             (*      CLI                 Clear interrupt flag       *)
  46.        $8B/$46/$06/     (*      MOV     AX,[BP+06]  Move character to AX       *)
  47.        $8B/$1E/$1C/$00/ (*      MOV     BX,[001Ch]  Move kb buf tail Ofs to BX *)
  48.        $89/$07/         (*      MOV     [BX],AX     Put character in buffer.   *)
  49.        $83/$C3/$02/     (*      ADD     BX,+2       Increment tail pntr by 2.  *)
  50.        $3B/$1E/$82/$00/ (*      CMP     BX,[0082h]  Compare BX with [0040:0082]*)
  51.        $74/$07/         (*      JZ      CIRC        Jump if end of buffer.     *)
  52.        $89/$1E/$1C/$00/ (*      MOV     [001Ch],BX  Update address of tail.    *)
  53.        $EB/$09/$90/     (*      JMP     EXIT        Exit                       *)
  54.        $8B/$1E/$80/$00/ (*CIRC: MOV     BX,[0080h]  Set BX to start of buffer. *)
  55.        $89/$1E/$1C/$00/ (*      MOV     [001Ch],BX  Update address of tail.    *)
  56.        $FB/             (*EXIT: STI                 Set interrupt flag.        *)
  57.        $1F);            (*      POP     DS          Restore DS.                *)
  58.  
  59.                                    (* Ensure keyboard input noticed *)
  60.    Bool_Val := PibTerm_KeyPressed;
  61.  
  62. END    (* Stuff_Kbd_Buf *);
  63.