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