home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / MKEY10.ASM < prev    next >
Assembly Source File  |  1994-10-15  |  2KB  |  67 lines

  1.     page    66,132
  2. ;******************************** MKEY10.ASM *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. comment 
  13. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(MOUSE/KEY)
  14. KEY_PUT - put key back into BIOS buffer
  15. ;
  16. ; inputs:  ax = key
  17. ; output:  none
  18. ; Note: If keyboard buffer is full then the key will be ignored.
  19. ;* * * * * * * * * * * * * *
  20. 
  21. ;-----------------------
  22. key_head    equ    1ah        ;next get location
  23. key_tail    equ    1ch        ;next put location
  24. key_buf_top_ptr    equ    80h        ;location of key buffer in seg 40h
  25. key_buf_end_ptr    equ    82h        ;location of key buffer end
  26. ;-----------------------
  27.     public    key_put
  28. KEY_PUT    proc    far
  29.     apush    bx,ds
  30.     mov    bx,40h                ;setup
  31.     mov    ds,bx                ;  the segment
  32. ;
  33. ; check if room for another key, will key_tail + 2 = key_head?
  34. ;    
  35.     mov    bx,word ptr ds:[key_tail]
  36.     add    bx,2
  37.     cmp    bx,word ptr ds:[key_buf_end_ptr]
  38.     jb    KEY_PUT_1            ;jmp if no overflow
  39.     mov    bx,word ptr ds:[key_buf_top_ptr]
  40. KEY_PUT_1:
  41.     cmp    bx,word ptr ds:[key_head]    ;check if head=tail (no room)
  42.     je    KEY_PUT_exit            ; jmp if no room
  43.     push    bx                ;save stuff ptr
  44. ;
  45. ; convert this key to bios format
  46. ;
  47.     cmp    ah,0                ;check if normal ascii key
  48.     je    KEY_PUT_2            ; jmp if normal ascii
  49.     mov    ah,al                ;put scan code back in -ah-
  50.     mov    al,0                ;put flag in -al-
  51. KEY_PUT_2:        
  52. ;
  53. ; put this key at current tail location
  54. ;
  55.     mov    bx,word ptr ds:[key_tail]
  56.     mov    word ptr ds:[bx],ax        ;store this key
  57.     pop    bx
  58.     mov    word ptr ds:[key_tail],bx    ;store new tail
  59. KEY_PUT_exit:
  60.     apop    ds,bx
  61.     retf    
  62. KEY_PUT    endp        
  63.  
  64. LIBSEG    ENDS
  65.     end
  66.