home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Program..: Tickerc.c
- ** Author...: Brenton Farmer
- ** Date.....: 10/10/91
- **
- ** Purpose..: C code to support Clipper ticker functions.
- **
- ** int C10ckSet( iTime)
- ** void C10ckISR( INTERRUPT_REGS r)
- */
-
- #include "extend.h"
- #include <dos.h>
-
- typedef struct {
- unsigned es, ds, di, si, bp, sp, bx, dx, cx, ax, ip, cs, flags;
- } INTERRUPT_REGS;
-
- void ( interrupt far *old_int8)();
- void interrupt far C10ckISR( INTERRUPT_REGS);
-
- extern void ( interrupt far *_getvector( unsigned int))();
- extern void _setvector( unsigned int, void( interrupt far *)());
- extern char * _getindosAddress();
-
- int Ticks = 0; // Call Clipper routine every Ticks
- int TickerCount = 0; // How many ticks have elapsed
- int Busy = 0; // Flag to prevent Ticker recursion
-
- char far *indos = 0;
-
- CLIPPER C10ckSet()
- {
- int ReturnValue = 0;
- int TickValue = 0;
-
- if ( PCOUNT == 1 && ISNUM(1))
- {
- ReturnValue = 1;
- if ( ( TickValue = _parni( 1)) != 0) // If TickValue != 0 Setup Timer
- {
- Ticks = TickValue; // Activate my isr every ( Ticks)
- TickerCount = 0; // Time elapsed in ticks
- Busy = 0; // Busy Flag used by my isr
-
- indos = _getindosAddress(); // Get indos address
-
- old_int8 = _getvector( 0x08); // Get current int 8 isr
- _setvector( 0x08, C10ckISR); // Set int 8 to my isr
- }
- else
- _setvector( 0x08, old_int8);
- }
- _retl( ReturnValue);
- }
-
-
- void interrupt far C10ckISR( INTERRUPT_REGS r)
- {
- (*old_int8)(); // Execute old handler
-
- if ( !Busy) // Busy must be 0 (Prevents recursion)
- {
- ++Busy; // Increment Busy flag
- if ( ++TickerCount >= Ticks) // Has the appropriate time passed
- {
- _intenable(); // Re-Enable Interrupts
- if (! *indos) {
- C10ckEval(); // Call Clipper function (_C10ckEval)
- TickerCount = 0; // Reset Ticker Timer
- }
- }
- --Busy; // Decrement Busy Flag
- }
- }
-
-