home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol05 / 05 / based / makanim.c < prev    next >
Text File  |  1990-09-01  |  3KB  |  113 lines

  1. // makanim.c RHS creates animation list from screen shots
  2.  
  3. #include<stdio.h>
  4. #include<dos.h>
  5. #include<fcntl.h>
  6. #include<malloc.h>
  7. #include<conio.h>
  8.  
  9. #include"list.h"
  10.  
  11. #define SCREENSIZE 4000
  12. #define SCREEN_ADDRESS 0xb8000000
  13.  
  14. void show_file(char *filename);
  15. void show_object(void far *object);
  16.  
  17.  
  18. void show_file(char *filename)
  19.     {
  20.     int fh;
  21.     unsigned bytes, doserror;
  22.     void far *screen = (void far *)SCREEN_ADDRESS;
  23.  
  24.     if(doserror = _dos_open(filename,O_RDONLY,&fh))
  25.         error_exit(doserror,"Unable to open screen file");
  26.     if((doserror = _dos_read(fh,screen,SCREENSIZE,&bytes)) ||
  27.             (bytes != SCREENSIZE))
  28.         error_exit(doserror,"Unable to read screen file");
  29.     _dos_close(fh);
  30.     }
  31.  
  32.  
  33. void show_object(void far *object)
  34.     {
  35.     unsigned i;
  36.     unsigned far *screen = (void far *)SCREEN_ADDRESS;
  37.     unsigned far *objptr = (unsigned far *)object;
  38.  
  39.     for(i = 0; i < SCREENSIZE/2; i++, screen++, objptr++)
  40.         *screen = *objptr;
  41.     }
  42.  
  43. void main(void)
  44.     {
  45.     void far *L;
  46.     void far *object;
  47.     char *screen = "APPART";
  48.     char name[20];
  49.     int fh;
  50.     unsigned doserror,bytes;
  51.  
  52.     if(L = ListInit(170,"ANIMATE"))
  53.         {
  54.       int i;
  55.  
  56.       for(i = 0; i < 22; i++)
  57.         {
  58.         sprintf(name,"%s%02d.ACP",screen,i);
  59.         if(object = _fmalloc(SCREENSIZE))
  60.             {
  61.             printf("Adding %s\n",name);
  62.             if(doserror = _dos_open(name,O_RDONLY,&fh))
  63.                 error_exit(doserror,"Unable to open screen file");
  64.             if((doserror = _dos_read(fh,object,SCREENSIZE,&bytes)) ||
  65.                     (bytes != SCREENSIZE))
  66.                 error_exit(doserror,"Unable to read screen file");
  67.             _dos_close(fh);
  68.             ListAdd(L,object,SCREENSIZE,name);
  69.             }
  70.         else
  71.             {
  72.             printf("Unable to allocate far memory: i=%d\n",i);
  73.             break;
  74.             }
  75.         }
  76.  
  77.       for(i = 20; i > 0; i--)
  78.         {
  79.         sprintf(name,"%s%02d.ACP",screen,i);
  80.         if(object = _fmalloc(SCREENSIZE))
  81.             {
  82.             printf("Adding %s\n",name);
  83.             if(doserror = _dos_open(name,O_RDONLY,&fh))
  84.                 error_exit(doserror,"Unable to open screen file");
  85.             if((doserror = _dos_read(fh,object,SCREENSIZE,&bytes)) ||
  86.                     (bytes != SCREENSIZE))
  87.                 error_exit(doserror,"Unable to read screen file");
  88.             _dos_close(fh);
  89.             ListAdd(L,object,SCREENSIZE,name);
  90.             }
  91.         else
  92.             {
  93.             printf("Unable to allocate far memory: i=%d\n",i);
  94.             break;
  95.             }
  96.         }
  97.       ListDump(L);
  98.       printf("Saving list...\n");
  99.       ListSave(L,"ANIMATE.LST");
  100.       printf("Destroying list...\n");
  101.       ListDestroy(L);
  102.       printf("Restoring list...\n");
  103.       if(L = ListRestore("ANIMATE.LST"))
  104.           {
  105.           printf("List restored\n");
  106.           ListDump(L);
  107.           }
  108.       }
  109.     }
  110.  
  111.  
  112.  
  113.