home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / MJRDEVEL.ARC / RTKICK.C < prev    next >
Text File  |  1989-03-01  |  2KB  |  60 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   RTKICK.C                                                              *
  4.  *                                                                         *
  5.  *   Copyright (C) 1987-1989 GALACTICOMM, Inc.    All Rights Reserved.     *
  6.  *                                                                         *
  7.  *   This is the real-time kicktable handler, used to kick off a selected  *
  8.  *   subroutine a specified number of seconds from the present time.       *
  9.  *                                                                         *
  10.  *                                            - T. Stryker 6/24/86         *
  11.  *                                                                         *
  12.  ***************************************************************************/
  13.  
  14. #define KTSIZE 30                  /* kicktable size                       */
  15.  
  16. struct kook {                      /* kicktable entry layout               */
  17.      int countr;                   /*   number of seconds yet to go        */
  18.      int (*dest)();                /*   subroutine address to invoke       */
  19. } kcktbl[KTSIZE];
  20.  
  21. inirtk()                           /* initialize real-time kicktable       */
  22. {
  23.      int i;
  24.      struct kook *kckptr;
  25.  
  26.      for (i=0,kckptr=kcktbl ; i < KTSIZE ; i++,kckptr++) {
  27.           kckptr->countr=0;
  28.      }
  29. }
  30.  
  31. rtkick(delay,dstrou)               /* real-time kicktable handler          */
  32. int delay;
  33. int (*dstrou)();
  34. {
  35.      int i;
  36.      struct kook *kckptr;
  37.  
  38.      for (i=0,kckptr=kcktbl ; i < KTSIZE ; i++,kckptr++) {
  39.           if (kckptr->countr == 0) {
  40.                kckptr->countr=delay;
  41.                kckptr->dest=dstrou;
  42.                return;
  43.           }
  44.      }
  45.      catastro("RTKICK: KCKTBL OVERFLOW");
  46. }
  47.  
  48. prcrtk()                           /* call an rtkick's specified routine   */
  49. {
  50.      int i;
  51.      struct kook *kckptr;
  52.  
  53.      for (i=0,kckptr=kcktbl ; i < KTSIZE ; i++,kckptr++) {
  54.           if (kckptr->countr != 0 && --(kckptr->countr) == 0) {
  55.                (*(kckptr->dest))();
  56.           }
  57.      }
  58. }
  59.  
  60.