/* tests sone in ThePlayer40.c */ /* Rip_P22A() */ /* Depack_P22() */ #include "globals.h" #include "extern.h" void Rip_P22A ( void ) { /* PW_k is the number of sample */ PW_l = ( (in_data[PW_Start_Address+16]*256*256*256) + (in_data[PW_Start_Address+17]*256*256) + (in_data[PW_Start_Address+18]*256) + in_data[PW_Start_Address+19] ); /* get whole sample size */ /* starting from the highest addy and adding the sample size */ PW_o = 0; for ( PW_j=0 ; PW_j PW_o ) { PW_o = PW_m; PW_n = ( (in_data[PW_Start_Address+24+PW_j*16]*256) + in_data[PW_Start_Address+25+PW_j*16] ); } } OutputSize = PW_l + PW_o + (PW_n*2) + 4; CONVERT = GOOD; Save_Rip ( "The Player 2.2A module", ThePlayer22a ); if ( Save_Status == GOOD ) PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ } /* * The_Player_2.2.c 2003 (c) Asle / ReDoX * * The Player 2.2a to Protracker. * * Update : 26 nov 2003 * - used htonl() so that use of addy is now portable on 68k archs */ void Depack_P22 ( void ) { Uchar c1,c2,c3,c4; Uchar *Whatever; Uchar PatPos = 0x00; Uchar Nbr_Sample = 0x00; Uchar poss[37][2]; Uchar sample,note,Note[2]; Uchar Pattern_Data[128][1024]; short Pattern_Addresses[128]; long Track_Data_Address = 0; long Track_Table_Address = 0; long Sample_Data_Address = 0; long WholeSampleSize = 0; long SampleAddress[31]; long SampleSize[31]; long i=0,j,k,l; long voice[4]; long Where = PW_Start_Address; FILE *out;/*,*debug;*/ if ( Save_Status == BAD ) return; BZERO ( Pattern_Addresses , 128*2 ); BZERO ( Pattern_Data , 128*1024 ); BZERO ( SampleAddress , 31*4 ); BZERO ( SampleSize , 31*4 ); fillPTKtable(poss); sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); out = PW_fopen ( Depacked_OutName , "w+b" ); /*debug = fopen ( "debug", "w+b" );*/ /* read check ID */ Where += 4; /* bypass Real number of pattern */ Where += 1; /* read number of pattern in pattern list */ PatPos = (in_data[Where++]/2) - 1; /* read number of samples */ Nbr_Sample = in_data[Where++]; /* bypass empty byte */ Where += 1; /**********/ /* read track data address */ Track_Data_Address = (in_data[Where]*256*256*256)+ (in_data[Where+1]*256*256)+ (in_data[Where+2]*256)+ in_data[Where+3]; Where += 4; /* read track table address */ Track_Table_Address = (in_data[Where]*256*256*256)+ (in_data[Where+1]*256*256)+ (in_data[Where+2]*256)+ in_data[Where+3]; Where += 4; /* read sample data address */ Sample_Data_Address = (in_data[Where]*256*256*256)+ (in_data[Where+1]*256*256)+ (in_data[Where+2]*256)+ in_data[Where+3]; Where += 4; /* write title */ Whatever = (Uchar *) malloc ( 1024 ); BZERO ( Whatever , 1024 ); fwrite ( Whatever , 20 , 1 , out ); /* sample headers stuff */ for ( i=0 ; i k ) continue; c1 = in_data[Where++]; c2 = in_data[Where++]; c3 = in_data[Where++]; c4 = in_data[Where++]; /*fprintf (debug,"[%2ld][%2d][%4x] - %2x,%2x,%2x,%2x -> ",j,voice[j],Where-4,c1,c2,c3,c4);*/ sample = ((c1<<4)&0x10) | ((c2>>4)&0x0f); BZERO ( Note , 2 ); note = c1 & 0x7f; Note[0] = poss[(note/2)][0]; Note[1] = poss[(note/2)][1]; switch ( c2&0x0f ) { case 0x08: c2 -= 0x08; break; case 0x05: case 0x06: case 0x0A: c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; break; default: break; } Pattern_Data[i][voice[j]*16+j*4] = (sample&0xf0) | (Note[0]&0x0f); Pattern_Data[i][voice[j]*16+j*4+1] = Note[1]; Pattern_Data[i][voice[j]*16+j*4+2] = c2; Pattern_Data[i][voice[j]*16+j*4+3] = c3; /*fprintf ( debug, "%2x,%2x,%2x,%2x",Pattern_Data[i][voice[j]*16+j*4],Pattern_Data[i][voice[j]*16+j*4+1],Pattern_Data[i][voice[j]*16+j*4+2],Pattern_Data[i][voice[j]*16+j*4+3]);*/ if ( (c4 > 0x00) && (c4 <0x80) ) { voice[j] += c4; /*fprintf ( debug, " <-- %d empty lines",c4 );*/ } /*fprintf ( debug, "\n" );*/ voice[j] += 1; } /* end of case 0x80 for first byte */ } } /* printf ( "ok\n" );*/ /* write pattern data */ /*printf ( "writing pattern data ... " );*/ /*fflush ( stdout );*/ for ( i=0 ; i