/* testFUZZAC() */ /* Rip_Fuzzac() */ /* Depack_Fuzzac() */ #include "globals.h" #include "extern.h" int16_t testFUZZAC ( void ) { PW_Start_Address = PW_i; /* test finetune */ for ( PW_k=0 ; PW_k<31 ; PW_k++ ) { if ( in_data[PW_Start_Address+72+PW_k*68] > 0x0F ) { return BAD; } } /* test volumes */ for ( PW_k=0 ; PW_k<31 ; PW_k++ ) { if ( in_data[PW_Start_Address+73+PW_k*68] > 0x40 ) { return BAD; } } /* test sample sizes */ PW_WholeSampleSize = 0; for ( PW_k=0 ; PW_k<31 ; PW_k++ ) { PW_j = (in_data[PW_Start_Address+66+PW_k*68]*256)+in_data[PW_Start_Address+67+PW_k*68]; if ( PW_j > 0x8000 ) { return BAD; } PW_WholeSampleSize += (PW_j * 2); } /* test size of pattern list */ if ( in_data[PW_Start_Address+2114] == 0x00 ) { return BAD; } return GOOD; } void Rip_Fuzzac ( void ) { /* PW_WholeSampleSize IS still the whole sample size */ PW_j = in_data[PW_Start_Address+2114]; PW_k = in_data[PW_Start_Address+2115]; OutputSize = PW_WholeSampleSize + (PW_j*16) + (PW_k*256) + 2118 + 4; CONVERT = GOOD; Save_Rip ( "Fuzzac packer module", Fuzzac ); if ( Save_Status == GOOD ) PW_i += (OutputSize - 2); /* -1 should do but call it "just to be sure" :) */ } /* * fuzzac.c 1997 (c) Asle / ReDoX * * Converts Fuzzac packed MODs back to PTK MODs * thanks to Gryzor and his ProWizard tool ! ... without it, this prog * would not exist !!! * * Note: A most worked-up prog ... took some time to finish this !. * there's what lot of my other depacker are missing : the correct * pattern order (most of the time the list is generated badly ..). * Dont know why I did it for this depacker because I've but one * exemple file ! :). * * Last update: 30/11/99 * - removed open() (and other fread()s and the like) * - general Speed & Size Optmizings * - memory leak bug corrected (thx to Thomas Neumann) * - SEnd ID bypassed REALLY now :) (Thomas Neumann again !) */ #define ON 1 #define OFF 2 void Depack_Fuzzac ( void ) { uint8_t c5; uint8_t PatPos; uint8_t *Whatever; uint8_t NbrTracks; uint8_t Track_Numbers[128][16]; uint8_t Track_Numbers_Real[128][4]; uint8_t Track_Datas[4][256]; uint8_t Status=ON; int32_t WholeSampleSize=0; int32_t i,j,k,l; int32_t Where = PW_Start_Address; FILE *out; if ( Save_Status == BAD ) return; BZERO ( Track_Numbers , 128*16 ); BZERO ( Track_Numbers_Real , 128*4 ); sprintf ( Depacked_OutName , "%d.mod" , Cpt_Filename-1 ); out = PW_fopen ( Depacked_OutName , "w+b" ); /* bypass ID */ /* bypass 2 unknown bytes */ Where += 6; /* write title */ Whatever = (uint8_t *) malloc (1024); BZERO ( Whatever , 1024 ); fwrite ( Whatever , 20 , 1 , out ); /*printf ( "Converting header ... " );*/ /*fflush ( stdout );*/ for ( i=0 ; i<31 ; i++ ) { /*sample name*/ fwrite ( &in_data[Where] , 22 , 1 , out ); WholeSampleSize += (((in_data[Where+60]*256)+in_data[Where+61])*2); fwrite ( &in_data[Where+60] , 2 , 1 , out ); fwrite ( &in_data[Where+66] , 2 , 1 , out ); fwrite ( &in_data[Where+62] , 2 , 1 , out ); Whatever[0] = in_data[Where+65]; if ( (in_data[Where+64]==0x00) && (in_data[Where+65]==0x00) ) Whatever[0] = 0x01; fwrite ( &in_data[Where+64] , 1 , 1 , out ); fwrite ( Whatever , 1 , 1 , out ); Where += 68; } /*printf ( "ok\n" );*/ /*printf ( " - Whole sample size : %ld\n" , WholeSampleSize );*/ /* read & write size of pattern list */ PatPos = in_data[Where++]; fwrite ( &PatPos , 1 , 1 , out ); /*printf ( " - size of pattern list : %d\n" , PatPos );*/ /* read the number of tracks */ NbrTracks = in_data[Where++]; /* write noisetracker byte */ Whatever[0] = 0x7f; fwrite ( Whatever , 1 , 1 , out ); /* place file pointer at track number list address */ Where = PW_Start_Address + 2118; /* read tracks numbers */ for ( i=0 ; i<4 ; i++ ) { for ( j=0 ; j