/* 22 mar 2003 * GnuPlayer.c * based on XtC's description ! ... good job ! :). * */ /* testGnuPlayer() */ /* Rip_GnuPlayer() */ /* Depack_GnuPlayer() */ #include "globals.h" #include "extern.h" short testGnuPlayer ( void ) { /* test #1 */ if ( PW_i < 0x92 ) { /*printf ( "#0 (start:%ld) \n", PW_i - 0x92 );*/ return BAD; } /* test #2 smp size and loop start */ PW_WholeSampleSize = 0; PW_o = 0; /* will hold the number of non-null samples */ PW_Start_Address = PW_i - 0x92; for ( PW_k=0 ; PW_k<31 ; PW_k++ ) { PW_j = (in_data[PW_Start_Address+20+PW_k*4]*256) + in_data[PW_Start_Address+21+PW_k*4]; PW_l = (in_data[PW_Start_Address+22+PW_k*4]*256) + in_data[PW_Start_Address+23+PW_k*4]; if ( PW_l > (PW_j+1) ) { /*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ return BAD; } if ( PW_j != 0 ) PW_o += 1; PW_WholeSampleSize += PW_j; } return GOOD; } void Rip_GnuPlayer ( void ) { /*PW_WholeSampleSize is the whole sample size */ /*but it seems to be a fake sample values */ /* size of 1st track + header */ PW_k = (in_data[PW_Start_Address + 0x96]*256)+in_data[PW_Start_Address + 0x97] + 0x96; /* size of 2nd track */ PW_j = (in_data[PW_k]*256) + in_data[PW_k+1] + PW_k; /* PW_j points now to the first sample size */ /*printf ( "\nWhere before 1st sample : %ld\n" , PW_j);*/ /* real sample sizes */ PW_m = 0; while ( PW_m < PW_o ) { PW_k = (in_data[PW_Start_Address+PW_j]*256) + in_data[PW_Start_Address+PW_j+1]; PW_j += (PW_k + 2); PW_m += 1; /*printf ( "sample %ld : siz:%ld where:%ld\n", PW_m,PW_k,PW_j ); fflush (stdout);*/ } OutputSize = PW_j; CONVERT = GOOD; Save_Rip ( "GnuPlayer module", GnuPlayer ); if ( Save_Status == GOOD ) PW_i += 0x96; } /* * GnuPlayer.c 2003 (c) Asle@free.fr * */ #define MAXI(a,b) (a>b?a:b) void Depack_GnuPlayer ( void ) { Uchar *Whatever; long i=0,j=0,k=0,l=0; long Where = PW_Start_Address; Uchar * Pattern; Uchar poss[37][2]; FILE *out;/*,*info;*/ long SizOfTrack,len1,len2; long SmpSizes[31]; long NbrSmp = 0; short SfxNbr=0; if ( Save_Status == BAD ) return; fillPTKtable(poss); sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); out = PW_fopen ( Depacked_OutName , "w+b" ); /*info = fopen ( "info", "w+b" );*/ /* read and write title */ fwrite ( &in_data[Where] , 20 , 1 , out ); /* get global sample rate */ /* for ( SmpRate=0x00 ; i<37 ; SmpRate+=0x01 ) if ( (poss[SmpRate][0] == in_data[Where + 0x90]) && (poss[SmpRate][1] == in_data[Where + 0x91])) break; */ /*take care of pattern right now*/ Pattern = (Uchar *) malloc (65536); BZERO (Pattern, 65536); Where = PW_Start_Address + 0x96; /* track 1 & 2 */ SizOfTrack = (in_data[Where]*256) + in_data[Where+1]; /* size of track 1 */ /*fprintf ( info, "Size of track 1 : %ld (%x)\n", SizOfTrack,SizOfTrack );*/ Where += 2; len1=0;l=0; for ( i=0 ; i>4)&0x0f; if ( samp & 0x08 ) samp -= 0x10; Whatever[k++] = (Whatever[k-1] + samp); samp = in_data[Where] & 0x0f; if ( samp & 0x08 ) samp -= 0x10; Whatever[k++] = (Whatever[k-1] + samp); Where += 1; } Where -= 1; fwrite ( &Whatever[0], out_end, 1, out ); } free ( Whatever ); /* crap */ Crap ( " GnuPlayer " , BAD , BAD , out ); fflush ( out ); fclose ( out ); /*fclose ( info );*/ printf ( "done\n" ); return; /* useless ... but */ }