/* * SGT-Packer.c * 2006 (C) Sylvain "Asle" Chipaux */ /* testSGT() */ /* Rip_SGT() */ /* Depack_SGT() */ #include "globals.h" #include "extern.h" /* rudimentary tests .. shall add others */ int16_t testSGT ( void ) { /* test 1 */ if ( (PW_i<43) || ((PW_Start_Address+43)>PW_in_size) ) { return BAD; } /* test 2 */ PW_Start_Address = PW_i-43; PW_k = in_data[PW_Start_Address+30]; for ( PW_j=0 ; PW_j 64 ? */ if ( in_data[PW_Start_Address+43+PW_j*16] > 0x40 ) { return BAD; } /* pad val != 00h ? */ if ( in_data[PW_Start_Address+42+PW_j*16] != 0x00 ) { return BAD; } } return GOOD; } /**/ void Rip_SGT ( void ) { /* PW_k = number of samples, but we don't care. */ /* get whole sample size */ PW_WholeSampleSize = ((in_data[PW_Start_Address+5]*256*256)+ (in_data[PW_Start_Address+6]*256)+ in_data[PW_Start_Address+7]); /* get add of sample data */ PW_k = ((in_data[PW_Start_Address+1]*256*256)+ (in_data[PW_Start_Address+2]*256)+ in_data[PW_Start_Address+3]); OutputSize = PW_k + PW_WholeSampleSize; CONVERT = GOOD; Save_Rip ( " SGT-Packer ", SGTPacker ); if ( Save_Status == GOOD ) PW_i += (OutputSize - 44); /* 43 should do but call it "just to be sure" :) */ } /* * SGT-Packer.c 2006 (c) Asle * */ void Depack_SGT ( void ) { uint8_t *Whatever; /* uint8_t c1=0x00,c2=0x00;*/ uint8_t poss[37][2]; /* uint8_t Max=0x00;*/ /* uint8_t Note,Smp,Fx,FxVal;*/ uint8_t PatternTableSize=0x00; uint8_t NbrPat; int32_t i=0,j=0,l=0,z; int32_t WholeSampleSize; int32_t SmpAddy,PatlistAddy,PatdataAddy; int32_t SmpAddies[31], SmpSizes[31]; int32_t NbrSmp; int32_t Where = PW_Start_Address; FILE *out; /*,*debug;*/ if ( Save_Status == BAD ) return; sprintf ( Depacked_OutName , "%d.mod" , Cpt_Filename-1 ); out = PW_fopen ( Depacked_OutName , "w+b" ); fillPTKtable(poss); WholeSampleSize = ((in_data[Where+5]*256*256)+ (in_data[Where+6]*256)+ in_data[Where+7]); SmpAddy = ((in_data[Where]*256*256*256)+ (in_data[Where+1]*256*256)+ (in_data[Where+2]*256)+ in_data[Where+3])+8+Where; PatlistAddy = ((in_data[Where+20]*256*256*256)+ (in_data[Where+21]*256*256)+ (in_data[Where+22]*256)+ in_data[Where+23])+8+Where; PatdataAddy = ((in_data[Where+24]*256*256*256)+ (in_data[Where+25]*256*256)+ (in_data[Where+26]*256)+ in_data[Where+27])+8+Where; PatternTableSize = in_data[Where+28]; NbrPat = in_data[Where+31]; NbrSmp = in_data[Where+30]; /* debug = fopen ( "debug" , "w+b" );*/ Whatever = (uint8_t *) malloc (1024); BZERO (Whatever , 1024); /* title */ fwrite ( &Whatever[0] , 20 , 1 , out ); /* read/write sample headers */ Where += 32; for ( i=0 ; i