summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/faskbhit.c
blob: 5c14022b6a7925316526f5aa508b35093729801f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
**  by David Goodenough & Bob Stout
*/

#ifdef __TURBOC__
 #define FAR far
#else
 #define FAR _far
#endif

#ifndef MK_FP
 #define MK_FP(seg,offset) \
        ((void FAR *)(((unsigned long)(seg)<<16) | (unsigned)(offset)))
#endif
 
#define biosseg 0x40

int fast_kbhit(void)
{
      return *((unsigned FAR *)MK_FP(biosseg, 0x1a)) -
            *((unsigned FAR *)MK_FP(biosseg, 0x1c));
}

void fast_kbflush(void)
{
      *((unsigned FAR *)MK_FP(biosseg, 0x1a)) =
            *((unsigned FAR *)MK_FP(biosseg, 0x1c));
}