Listing 2 (int70.cpp)

 1: /*
 2: INT70.CPP
 3:
 4: Source for interrupt 70 driver
 5: Paul A. Cornelius, August 1991
 6: */
 7:
 8: #include <dos.h>
 9: #include <io.h>
10: #include <time.h>
11:
12: #include "int70.hpp"
13:
14: extern "C" int int_70(INT_DATA*)
15: {
16:     const long int poke_count = 0xffff;
17:     const unsigned COUNT_SEGMENT = 0x40,
18:      COUNT_OFFSET = 0x9C;
19:     poke(COUNT_SEGMENT,COUNT_OFFSET,&poke_count,
20:      sizeof(long));
21:
22:     handle_tick();  // application-specific
23:
24:     return 0;
25: }
26:
27: static unsigned dummy;
28: int start_timer()
29: {
30:     const unsigned STACK_SIZE = 3000;
31:     int_intercept(0x70,int_70,STACK_SIZE);
32:     REGS r,rout;
33:     SREGS sr;
34:     // getDS returns data segment
35:     sr.es = getDS();
36:     // ES:BX points to dummy
37:     // code OK for small memory model only
38:     r.x.bx = (unsigned)(&dummy);
39:     // Function 0x83: SET INTERVAL
40:     r.h.ah = 0x83;
41:     r.h.al = 0;
42:     // CX:DX = arbitrary large 4-byte value
43:     r.x.cx = 0x500;
44:     r.x.dx = 0;
45:
46:     // call interrupt 0x15
47:     int86x(0x15,&r,&rout,&sr);
48:     // check carry flag per documentation
49:     if (rout.x.cflag == 1)
50:         return 1;
51:
52:     // Real Time Clock INT 0x70 is now on!
53:     return 0;
54: }
55:
56: int stop_timer()
57: {
58:     int_restore(0x70);
59:     msleep(200);            // 200 millisecond delay
60:     if (dummy == 0)
61:         return 1;           // error
62:
63:     // Real Time Clock INT 0x70 is now off!
64:     return 0;
65: }

// End of File