/* Definition des entetes */ #include #include #include #include #include /* Definition des constantes */ #define Donnee 0x378 #define Etat 0x379 #define Commande 0x37a #define ERROR 0x08 #define SLCT 0x10 #define PE 0x20 #define ACK 0x40 #define BUSY 0x80 #define STROBE 0x01 #define AUTOFEED 0x02 #define INIT 0x04 #define SLCTIN 0x08 #define IRQENABLE 0x10 #define SIZE_BLOCK 0x1a1 extern void transmit( char ); void transmit(char data) { // Verification du signal ACK asm mov dx, Etat waitreq: asm{ in al, dx and al, 040h je waitreq // Preparation de l'octet a transmettre mov al, data mov dx, Donnee out dx, al // Activation du signal STROBE mov dx, Commande in al, dx or al, 001h out dx, al // Attente de fin du signal ACK mov dx, Etat } endreq: asm{ in al, dx and al, 040h jne endreq // Desactivation du signal STROBE mov dx, Commande in al, dx and al, 0FEh out dx, al } } void main( int argc,char *argv[] ) { long total; unsigned int indice, indice_lu; unsigned char value[ 0x200 ],octet_cde,octet; FILE *fichier; unsigned char *ptrlec, *ptrecr; unsigned char buffer[ 4096 ]; struct ffblk ffblk; if (argc !=2) { printf(" Usage : player nomdefichier.mp3\n"); printf(" ou : player *.mp3\n\n"); exit( 1 ); } if (findfirst(argv[1],&ffblk,0) != 0) { printf( "Erreur ouverture %s\n",argv[1] ); exit( 1 ); } do { if ((fichier = fopen(ffblk.ff_name,"rb")) == NULL) { printf("\nErreur d'ouverture fichier %s",ffblk.ff_name); continue; } printf("\nEcoute du fichier %s ",ffblk.ff_name); octet_cde = inp( Commande ); total = ffblk.ff_fsize; while (total!=0) { if (total > SIZE_BLOCK) { fread(value,1,SIZE_BLOCK,fichier); total -= SIZE_BLOCK; indice_lu = SIZE_BLOCK; } else { fread(value,1,total,fichier); indice_lu = total; total = 0; } for(indice = 0; indice != indice_lu ; indice++) { transmit(value[indice]); } if ((total % 50) == 0) { if (kbhit()) { switch(getch()) { case 27 : fclose(fichier); exit(0); break; case ' ' : getch(); break; case 's' : case 'S' : total = 0; break; } } } } fclose( fichier ); } while (findnext(&ffblk) == 0); }