home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 470 / rccl082 < prev    next >
Text File  |  1987-03-02  |  2KB  |  141 lines

  1. #include <stdio.h>
  2. #include "../h/rtc.h"
  3. #include "../h/umac.h"
  4.  
  5. #define MAX     2000            /* 1 mn at tick 4 */
  6.  
  7.  
  8. extern int Magic_Circus;
  9.  
  10. extern struct chg chg;
  11.  
  12. short pts[MAX * 7];
  13.  
  14. int     check();
  15. int     play();
  16. short   *idx = pts;
  17. int     nbp;
  18. int     enough = NO;
  19.  
  20. main(argc, argv)
  21. int argc;
  22. char **argv;
  23. {
  24.     extern int terminate;
  25.     int fi = -1;
  26.     int q, rate = 2;
  27.  
  28.     switch (argc) {
  29.     case 1 :
  30.         fi = 0;
  31.         break;
  32.     case 2 :
  33.         fi = open(*(argv+1), 0);
  34.         if (fi < 0) {
  35.             printf("can't open input file\n");
  36.             exit(1);
  37.         }
  38.         break;
  39.     default :
  40.         printf("bad arg\n");
  41.         exit(2);
  42.         break;
  43.     }
  44.     nbp = read(fi, pts, MAX * 14);
  45.     if (nbp == MAX * 14) {
  46.         printf("file too big\n");
  47.         exit(3);
  48.     }
  49.     if (nbp % 7) {
  50.         printf("invalid file\n");
  51.         exit(4);
  52.     }
  53.     nbp /= 14;
  54.  
  55.     printf("%d points\n",nbp);
  56.  
  57.     Magic_Circus = NO;
  58.     control(check, play);
  59.     while (!enough) {
  60.         printf(" more ? ");
  61.         QUERY(q);
  62.         if (q == 'n') {
  63.             enough = YES;
  64.             break;
  65.         }
  66.         dsprate(rate);
  67.         printf(" slower ? ");
  68.         QUERY(q);
  69.         if (q == 'y') {
  70.             if (rate < 4) {
  71.                 ++rate;
  72.                 chg.g_rate.valg = rate;
  73.                 chg.g_rate.set = YES;
  74.             }
  75.         }
  76.         dsprate(rate);
  77.         printf(" faster ? ");
  78.         QUERY(q);
  79.         if (q == 'y') {
  80.             if (rate > 2) {
  81.                 --rate;
  82.                 chg.g_rate.valg = rate;
  83.                 chg.g_rate.set = YES;
  84.             }
  85.         }
  86.     }
  87.     while (!terminate) {
  88.         nap(10);
  89.     }
  90.     release("ok\n");
  91. }
  92.  
  93.  
  94. dsprate(r)
  95. int r;
  96. {
  97.     switch (r) {
  98.     case 2:
  99.         printf(" normal speed");
  100.         break;
  101.  
  102.     case 3:
  103.         printf(" half speed ");
  104.         break;
  105.  
  106.     case 4:
  107.         printf(" quater speed ");
  108.         break;
  109.     }
  110. }
  111.  
  112.  
  113. check()
  114. {
  115. }
  116.  
  117.  
  118. play()
  119. {
  120.     static int count = 0;
  121.     register int i;
  122.     short shdi;
  123.  
  124.     if (count == 0) {
  125.         if (enough) {
  126.             terminate = YES;
  127.             return;
  128.         }
  129.         idx = pts;
  130.         count = nbp;
  131.     }
  132.     --count;
  133.     for (i = 0; i < NJOINTS; ++i) {
  134.         chg.a_motion.vala[i] = *idx++;
  135.     }
  136.     chg.a_motion.set = POS;
  137.     shdi = (*idx++) >> 4;
  138.     chg.g_hand.set = YES;
  139.     chg.g_hand.valg = shdi;
  140. }
  141.