home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 1999 January / STC_CD_01_1999.iso / wdr / anip_202 / prog / startani.c
Text File  |  2000-01-08  |  6KB  |  157 lines

  1.  
  2. /* PROGRAMME DE DEMONSTRATION LANCEMENT ANIPLAYER AVEC CONTROLE              */
  3. /* 16, 256 COULEURS, OU TRUE COLOR OBLIGATOIRE SANS CHANGEMENT DE RESOLUTION */
  4.  
  5. /* DEMO PROGRAMM FOR START ANIPLAYER WITH CONTROL                            */
  6. /* 16, 256 COLORS, OR TRUE COLOR IS REQUIRED WITHOUT CHANGE VIDEO DISPLAY    */
  7.  
  8. /* MEQUIGNON Didier - June 1997 */
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <tos.h>
  13. #include <aes.h>
  14.  
  15. #define MAX_PICTURES    100
  16.  
  17. int event(void);
  18.  
  19. int ap_id,picture=0,pause=0,single_step=0;
  20.  
  21. struct infos
  22. {
  23.     int width;
  24.     int height;
  25.     int planes;
  26.     int frames_second;
  27.     long total_frames;
  28.     long id_picture_compression;    /* cvid for example */
  29.     int quality;    /* B0: mono(0)/stereo(1)  B1: 8 bits(0)/16 bits(1) */
  30.     unsigned int frequency_file;
  31.     unsigned int frequency_machine;
  32.     long total_samples;
  33.     long id_sound_compression;        /* ima4 for example */
  34.     int version_player;                /* version of Aniplayer */
  35. };
  36.  
  37. void main()
  38.  
  39. {
  40.     int i,ret,x,y,w,h;
  41.     static char cmde[256],path_info[80],path[80],name[12];
  42.     static char select[]="*.*";
  43.     static struct infos infos;
  44.     ap_id=appl_init();
  45.     path[0]=Dgetdrv()+'A';path[1]=':';Dgetpath(path+2,Dgetdrv()+1);
  46.     strcat(path,"\\");strcat(path,select);
  47.     fsel_input(path,name,&ret);
  48.     if(ret)                                            /* OK */
  49.     {
  50.         i=strlen(path)-1;    
  51.         while(path[i]!='\\')
  52.             path[i--]=0;
  53.         strcat(path,name);                            /* path with name */
  54.         strcpy(path_info,path);
  55.         
  56.         /* returns informations about movie */
  57.  
  58.         sprintf(cmde," -e +z%ld",(long)&infos.width);    
  59.         strcat(cmde,path_info);                        /* command ligne with path */
  60.         cmde[0]=strlen(cmde);                        /* pascal format !         */
  61.         Pexec(0,"ANIPLAY.PRG",cmde,"");                /* get infos */
  62.  
  63.         /* test movie */
  64.  
  65.         wind_get(0,WF_WORKXYWH,&x,&y,&w,&h);        /* desktop */
  66.         if(infos.id_picture_compression                /* 0 if unknown picture */
  67.          && infos.id_sound_compression                /* 0 if unknown sound   */
  68.          && infos.width <= w                        /* size picture */
  69.          && infos.height <= h)
  70.         {
  71.             wind_update(BEG_UPDATE);
  72.             wind_update(BEG_MCTRL);                    /* control keyboard for EVNT_MULTI */
  73.             x=(x+((w-infos.width)/2)+15) & 0xfff0;    /* 16 pixels alignement */
  74.             y=y+((h-infos.height)/2);                /* X,Y center           */ 
  75.             
  76.             /* options & adress command line for start movie */
  77.  
  78.             sprintf(cmde," +x%d +y%d +d -e -i +m +p +q +r +s +a%ld",x,y,(long)event);
  79.             /* +annnnnnnnnn: adress for control programm (10 numbers max)       */
  80.             /* +bnnnnn: force number of planes for screen (5 numbers max)       */ 
  81.             /* +d: with dsp (-d: without dsp)                                   */
  82.             /* +e: display errors (-e: without, default +e)                     */
  83.             /* +hnnnnn: force height of screen (5 numbers max)                  */
  84.              /* +i: loop (-i: without)                                           */
  85.             /* +m: with pictures (-m: sound only)                               */
  86.             /* +p: with sound (-p: shut-off sound)                              */
  87.             /* +q: with quality (-q: without quality)                           */
  88.             /* +r: resample sound (-r: without)                                 */
  89.             /* +s: pass pictures (-s: all pictures)                             */
  90.             /* +wnnnnn: force width of screen (5 numbers max)                   */
  91.             /* +xnnnnn, +ynnnnn: movie position (5 numbers max, default center) */
  92.             /* +znnnnnnnnnn: adress informations about movie (10 numbers max)   */
  93.             strcat(cmde,path);                        /* command ligne with path  */
  94.             cmde[0]=strlen(cmde);                    /* pascal format !          */
  95.             Pexec(0,"ANIPLAY.PRG",cmde,"");            /* start player */ 
  96.             /* FRANCAIS: Vous pouvez aussi inclure ANIPLAY.PRG si vous le relogez */
  97.             /* ENGLISH: You can also include ANIPLAY.PRG if you relocate it       */  
  98.  
  99.             wind_update(END_MCTRL);
  100.             form_dial(FMD_FINISH,x,y,infos.width,infos.height,x,y,infos.width,infos.height);
  101.             wind_update(END_UPDATE);                /* redraw */
  102.         }            
  103.     }
  104.     appl_exit();
  105. }
  106.  
  107. int event(void)
  108.  
  109. {
  110.     int ret,mmx,mmy,mmb,mmk,key,mb;
  111.     /* FRANCAIS: Attention, les options sont dans la ligne de commande !                      */
  112.     /*           En 16 couleurs, le tramage est fait avec les 8 premières couleurs système    */
  113.     /*           En 256 couleurs, les premières couleurs ne sont pas modifiés si possible     */ 
  114.     /*           Le curseur de la souris est effacé en dehors de ces lignes                   */
  115.     /*           L'écran est sauvé au lancement et restauré à la fin sauf en affichage X,Y    */ 
  116.     /*           Cet exemple utilise le GEM mais vous pouvez utiliser le GEMDOS ou (X)BIOS !  */
  117.     /*           Le player utilise seulement le GEMDOS, XBIOS et LINEA pour le curseur souris */
  118.     /*           Attention, vous devez optimiser ces lignes pour un affichage rapide !        */
  119.     /* ENGLISH: Warning, options are in command ligne !                                       */
  120.     /*          In 16 colors, dithering is made with 8 first system colors                    */
  121.     /*          In 256 colors, the player don't modify the first colors if is possible        */
  122.     /*          The mouse is hidden out of this lines                                         */
  123.     /*          The screen is saved at start and restored at end except in X,Y display        */
  124.     /*          This example use the GEM but you can use GEMDOS or (X)BIOS !                  */
  125.     /*          The player use only GEMDOS, XBIOS, and LINEA for hide mouse cursor            */
  126.     /*          Warning, you must optimized this lines for fast display !                     */ 
  127.     if(picture>MAX_PICTURES)    /* time-out for example */
  128.         return(0x1b);            /* ESC: stop            */
  129.     ret=evnt_multi(MU_TIMER+MU_KEYBD,0,0,0,0,0,0,0,0,0,0,0,0,0,0L,0,0,&mmx,&mmy,&mmb,&mmk,&key,&mb);
  130.     if(ret & MU_KEYBD)
  131.     {
  132.         if(key==0x4b34            /* SHIFT +   (-10S) */
  133.          || key==0x4d36)        /* SHIFT +   (+10S) */
  134.         {
  135.             picture=0;
  136.             return(key);        /* control key (H:scan-code L:code ASCII) */
  137.         }
  138.         switch(key & 0xff)        /* code ASCII    */
  139.         {
  140.         case 0x1b:                /* ESC: stop     */
  141.             return(key);        /* control key (H:scan-code L:code ASCII) */
  142.         case ' ':                /* pause/play    */
  143.             pause++; pause&=1;
  144.             if(!pause)
  145.                 single_step=0;
  146.             return(key);        /* control key (H:scan-code L:code ASCII) */
  147.         case '.':                /* single step   */
  148.             single_step=pause=1;
  149.             picture++;
  150.             return(key);        /* control key (H:scan-code L:code ASCII) */
  151.         }
  152.     }
  153.     if(!pause && !single_step)
  154.         picture++;
  155.     return(0);                    /* continue  */
  156. }
  157.