home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / graphics / utility / raymovi2.lzh / RAYMOVI2 / BLASTRAM.C (.txt) next >
C/C++ Source or Header  |  1988-12-21  |  4KB  |  165 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3.  
  4. int XMIN, YMIN, XMAX, YMAX;
  5.  
  6. wOnewSize(x,y, w,h)
  7. int x,y, w,h;
  8. {    XMIN = x;    YMIN = y;
  9.     XMAX = x+w+2;    YMAX = y+h+2;
  10. }
  11.  
  12. #define colors(r,g,b) 1000*(2*(r)+1)/16, 1000*(2*(g)+1)/16, 1000*(2*(b)+1)/16
  13. int oldClut[16][3], newClut[16][3] = {
  14. colors(7,7,7),    /* all white-ish */
  15. colors(0,0,0),    /* black */
  16. colors(0,0,1),    /* somewhat lighter */
  17. colors(1,1,1),
  18. colors(1,1,2),
  19. colors(2,2,2),
  20. colors(2,2,3),
  21. colors(3,3,3),
  22. colors(3,3,4),
  23. colors(4,4,4),
  24. colors(4,4,5),
  25. colors(5,5,5),
  26. colors(5,5,6),
  27. colors(6,6,6),
  28. colors(6,6,7),
  29. colors(6,7,7)};    /* almost white */
  30.  
  31. int wHandle;
  32. FILE *fp, *fopen();
  33. char outname[] = "blastram";
  34. long orig_base;
  35. float speed = 12000.0;
  36. long Ispeed = 12000;
  37.  
  38. #define bytesPscreen 32000
  39.  
  40. main (argc, argv) 
  41. int argc;
  42. char *argv[];
  43. {    long mem_avail, l;
  44.     char *mem_for_screen;
  45.     char (*Pscreen)[bytesPscreen];
  46.     int i, j, Nscreens, screens_read, delay;
  47.     char fname[20];
  48.  
  49.     if (argc != 2)
  50.         panic("usage: blastram <fname_prefix> (sans the XXX.PI1)\n");
  51.     wHandle = w_open(0, "pearle", 0);    /* open window (typeless, menueless) */
  52.     w_lClut(newClut, oldClut);
  53.     v_hide_c(wHandle);
  54.     orig_base = Physbase();
  55.  
  56.     mem_avail = Malloc((long)-1);
  57.     mem_for_screen = Malloc (mem_avail);
  58.     printf("\033E%ld bytes memory available.\n", mem_avail);
  59.  
  60.     Nscreens = (mem_avail - 0x100 - ((long)mem_for_screen & 0xff)) 
  61.                             / bytesPscreen;
  62.     Pscreen = (char *) (((long)mem_for_screen | 0xff) + 1);
  63.  
  64.     printf("%d screens Max.\n\n", Nscreens);
  65.  
  66.     for (i=1; i<999 & Nscreens > 0;)
  67.     {    sprintf(fname,"%s%03d.pi1", argv[1], i);
  68.         printf("file %s -- ", fname);
  69.         if (f_read(fname, Pscreen+screens_read) >= 0)
  70.         {    screens_read++;
  71.             --Nscreens;
  72.             printf("to screen %d.\n", screens_read);
  73.             i++;
  74.         }
  75.         else
  76.         {    printf("not found.\n");
  77.             if (screens_read)        
  78.             {    char key;
  79. reask:                printf("\nType 'c', 'd' or 'e':\n");
  80.                 printf("c: CONTINUE with another diskette\n");
  81.                 printf("d: DISPLAY what's been loaded\n");
  82.                 printf("e: EXIT\n");
  83.                 key = Cconin();
  84.                 printf("\n");
  85.                 Mediach('a'-'a'); 
  86.                 if (key == 'c')
  87.                     continue;
  88.                 else if (key == 'd')
  89.                     break;
  90.                 else if (key == 'e')
  91.                     exit(0);
  92.                 else
  93.                 {    printf("\nAnswer 'c', 'd', or 'e'\n\n");
  94.                     goto reask;
  95.     }    }    }    }
  96.     for (i=0; 1; i = (i + kbd() + screens_read)%screens_read)
  97.     {    Setscreen((long)-1, Pscreen + i, -1);
  98.         for (l=0; l < Ispeed; l++)    
  99.             delay++;
  100. }    }
  101.  
  102. int freeze = 0;
  103.  
  104. kbd()
  105. {    char key, fname[20];
  106.     int found_first = 0, fr1;
  107.  
  108.     if (Cconis() == 0 && freeze==0)
  109.         return(1);
  110.  
  111.     key = Cconin();
  112.     while (1)
  113.     {    switch(key)
  114.         {   case ('?'):    /* help */
  115.             Setscreen((long)-1, orig_base, -1);
  116.             printf("\033E\n\n       BLASTRAM.C\n\
  117.             \n '-' back up one frame\
  118.             \n '+' forward one frame\
  119.             \n ' ' freeze on frame\
  120.             \n 'f' faster\
  121.             \n 's' slower\
  122.             \n <all else> play forward\
  123.             \n use reset to exit\
  124.             \n");
  125.             key = Cconin();
  126.             printf("\033E");
  127.             break;
  128.             case ('-'):                /* back up one */
  129.             freeze = 1;
  130.             return (-1);
  131.             case ('+'): case ('='):        /* forward one */
  132.             freeze = 1;
  133.             return (1);
  134.             case (' '):                /* freeze on */
  135.             freeze = 1;
  136.             return (0);
  137.             case ('f'):                /* faster */
  138.             speed /= 1.2;
  139.             Ispeed = speed;
  140.             return (1);
  141.             case ('s'):                /* slower */
  142.             speed *= 1.2;
  143.             Ispeed = speed;
  144.             return (1);
  145. /*            case ('e'):
  146.             Setscreen((long)-1, orig_base, -1);
  147.             w_lClut(oldClut, (long)0);
  148.             w_close();
  149.             exit(0);/* the above leaves desktop in a wierd state */
  150.             default:
  151.             freeze = 0;
  152.             return (1);
  153. }    }    }
  154.     
  155. panic(s,l1,l2)
  156. char *s;
  157. long l1,l2;
  158. {    printf("\n***** FATAL ERROR *****\n");
  159.     printf(s,l1,l2);
  160.     printf("\nPress any key to continue\n");
  161.     Cconin();
  162.     exit();
  163.     atoi();
  164. }
  165.