home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ST-Computer Leser-CD 1999 January
/
STC_CD_01_1999.iso
/
wdr
/
anip_202
/
prog
/
startani.c
Wrap
Text File
|
2000-01-08
|
6KB
|
157 lines
/* PROGRAMME DE DEMONSTRATION LANCEMENT ANIPLAYER AVEC CONTROLE */
/* 16, 256 COULEURS, OU TRUE COLOR OBLIGATOIRE SANS CHANGEMENT DE RESOLUTION */
/* DEMO PROGRAMM FOR START ANIPLAYER WITH CONTROL */
/* 16, 256 COLORS, OR TRUE COLOR IS REQUIRED WITHOUT CHANGE VIDEO DISPLAY */
/* MEQUIGNON Didier - June 1997 */
#include <stdio.h>
#include <string.h>
#include <tos.h>
#include <aes.h>
#define MAX_PICTURES 100
int event(void);
int ap_id,picture=0,pause=0,single_step=0;
struct infos
{
int width;
int height;
int planes;
int frames_second;
long total_frames;
long id_picture_compression; /* cvid for example */
int quality; /* B0: mono(0)/stereo(1) B1: 8 bits(0)/16 bits(1) */
unsigned int frequency_file;
unsigned int frequency_machine;
long total_samples;
long id_sound_compression; /* ima4 for example */
int version_player; /* version of Aniplayer */
};
void main()
{
int i,ret,x,y,w,h;
static char cmde[256],path_info[80],path[80],name[12];
static char select[]="*.*";
static struct infos infos;
ap_id=appl_init();
path[0]=Dgetdrv()+'A';path[1]=':';Dgetpath(path+2,Dgetdrv()+1);
strcat(path,"\\");strcat(path,select);
fsel_input(path,name,&ret);
if(ret) /* OK */
{
i=strlen(path)-1;
while(path[i]!='\\')
path[i--]=0;
strcat(path,name); /* path with name */
strcpy(path_info,path);
/* returns informations about movie */
sprintf(cmde," -e +z%ld",(long)&infos.width);
strcat(cmde,path_info); /* command ligne with path */
cmde[0]=strlen(cmde); /* pascal format ! */
Pexec(0,"ANIPLAY.PRG",cmde,""); /* get infos */
/* test movie */
wind_get(0,WF_WORKXYWH,&x,&y,&w,&h); /* desktop */
if(infos.id_picture_compression /* 0 if unknown picture */
&& infos.id_sound_compression /* 0 if unknown sound */
&& infos.width <= w /* size picture */
&& infos.height <= h)
{
wind_update(BEG_UPDATE);
wind_update(BEG_MCTRL); /* control keyboard for EVNT_MULTI */
x=(x+((w-infos.width)/2)+15) & 0xfff0; /* 16 pixels alignement */
y=y+((h-infos.height)/2); /* X,Y center */
/* options & adress command line for start movie */
sprintf(cmde," +x%d +y%d +d -e -i +m +p +q +r +s +a%ld",x,y,(long)event);
/* +annnnnnnnnn: adress for control programm (10 numbers max) */
/* +bnnnnn: force number of planes for screen (5 numbers max) */
/* +d: with dsp (-d: without dsp) */
/* +e: display errors (-e: without, default +e) */
/* +hnnnnn: force height of screen (5 numbers max) */
/* +i: loop (-i: without) */
/* +m: with pictures (-m: sound only) */
/* +p: with sound (-p: shut-off sound) */
/* +q: with quality (-q: without quality) */
/* +r: resample sound (-r: without) */
/* +s: pass pictures (-s: all pictures) */
/* +wnnnnn: force width of screen (5 numbers max) */
/* +xnnnnn, +ynnnnn: movie position (5 numbers max, default center) */
/* +znnnnnnnnnn: adress informations about movie (10 numbers max) */
strcat(cmde,path); /* command ligne with path */
cmde[0]=strlen(cmde); /* pascal format ! */
Pexec(0,"ANIPLAY.PRG",cmde,""); /* start player */
/* FRANCAIS: Vous pouvez aussi inclure ANIPLAY.PRG si vous le relogez */
/* ENGLISH: You can also include ANIPLAY.PRG if you relocate it */
wind_update(END_MCTRL);
form_dial(FMD_FINISH,x,y,infos.width,infos.height,x,y,infos.width,infos.height);
wind_update(END_UPDATE); /* redraw */
}
}
appl_exit();
}
int event(void)
{
int ret,mmx,mmy,mmb,mmk,key,mb;
/* FRANCAIS: Attention, les options sont dans la ligne de commande ! */
/* En 16 couleurs, le tramage est fait avec les 8 premières couleurs système */
/* En 256 couleurs, les premières couleurs ne sont pas modifiés si possible */
/* Le curseur de la souris est effacé en dehors de ces lignes */
/* L'écran est sauvé au lancement et restauré à la fin sauf en affichage X,Y */
/* Cet exemple utilise le GEM mais vous pouvez utiliser le GEMDOS ou (X)BIOS ! */
/* Le player utilise seulement le GEMDOS, XBIOS et LINEA pour le curseur souris */
/* Attention, vous devez optimiser ces lignes pour un affichage rapide ! */
/* ENGLISH: Warning, options are in command ligne ! */
/* In 16 colors, dithering is made with 8 first system colors */
/* In 256 colors, the player don't modify the first colors if is possible */
/* The mouse is hidden out of this lines */
/* The screen is saved at start and restored at end except in X,Y display */
/* This example use the GEM but you can use GEMDOS or (X)BIOS ! */
/* The player use only GEMDOS, XBIOS, and LINEA for hide mouse cursor */
/* Warning, you must optimized this lines for fast display ! */
if(picture>MAX_PICTURES) /* time-out for example */
return(0x1b); /* ESC: stop */
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);
if(ret & MU_KEYBD)
{
if(key==0x4b34 /* SHIFT + (-10S) */
|| key==0x4d36) /* SHIFT + (+10S) */
{
picture=0;
return(key); /* control key (H:scan-code L:code ASCII) */
}
switch(key & 0xff) /* code ASCII */
{
case 0x1b: /* ESC: stop */
return(key); /* control key (H:scan-code L:code ASCII) */
case ' ': /* pause/play */
pause++; pause&=1;
if(!pause)
single_step=0;
return(key); /* control key (H:scan-code L:code ASCII) */
case '.': /* single step */
single_step=pause=1;
picture++;
return(key); /* control key (H:scan-code L:code ASCII) */
}
}
if(!pause && !single_step)
picture++;
return(0); /* continue */
}