home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
MOD15V12.ZIP
/
SOURCES
/
1531.C
next >
Wrap
C/C++ Source or Header
|
1996-01-15
|
3KB
|
111 lines
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <dos.h>
#include <stdlib.h>
char *destname (char *name) {
char *buf = " " ;
strcpy (buf, name) ;
buf[strlen(buf)-3] = 110 ; /* change the 3 last chars into "nst" */
buf[strlen(buf)-2] = 115 ;
buf[strlen(buf)-1] = 116 ;
return buf;
}
int main (int nbparam, char *param[] ) {
FILE *src, *dest ;
unsigned char buf1 [599], buf2 [479], buf3 [32000] ;
int i=0,j=0,s ;
printf ("\n > SoundTracker to ProTracker (NoiseTracker) Converter, ver 1.2 <\n") ;
printf (" Coded by Magic Fred / TFL-TDV \n \n") ;
if (nbparam != 2) {
printf ("\n It converts an old 15-Samples Amiga SoundTracker module\n") ;
printf (" into a 31-Samples ProTracker/FastTracker 4-channels module.") ;
printf ("\n \n Syntax: 1531 <filename> \n \n") ;
exit (0) ;
}
if (strcmp (destname (param [1]),param [1]) == 0) {
printf("This file's extension is already ""NST"" ! \n") ;
printf("Is this a 15-samples module ? If yes, rename it as ""*.MOD"".\n");
printf("\nMaybe the filename is just illegal. ") ;
printf("Please read info file. \n \n") ;
exit (1) ;
}
if ((src=fopen(param[1],"rb")) == NULL) {
printf ("File '%s' not found in current directory.\n",param[1]) ;
printf ("Type 1531 without any parameter for help\n \n");
exit (1) ;
}
if ((dest=fopen(destname(param[1]),"wb")) == NULL) {
printf ("Cannot open destination file. \n \n") ;
exit (1) ;
}
/* Convertion : */
/* To raise the header from 15 to 31 samples, a block of 480 zeroes
(names & parameters for 16 new samples) must be created. This is
created here, and my 'advertising' is inserted in sample names) */
for ( i=0 ; i<480 ; i++ )
buf2 [i] = 0 ;
memmove (buf2+180,"======================",22) ;
memmove (buf2+210,"I This Sound Tracker I",22) ;
memmove (buf2+240,"I (15samples) module I",22) ;
memmove (buf2+270,"I has been converted I",22) ;
memmove (buf2+300,"I into a Pro Tracker I",22) ;
memmove (buf2+330,"I (31samples) module I",22) ;
memmove (buf2+360,"I with MAGIC FRED's I",22) ;
memmove (buf2+390,"I mod15v12.zip , a I",22) ;
memmove (buf2+420,"I TFL-TDV release... I",22) ;
memmove (buf2+450,"======================",22) ;
/* Read module header */
for ( i=0 ; i<600 ; i++ ) {
buf1 [i] = getc (src) ;
if (feof(src) != 0) {
printf ("Too early eof error -Is this a mod ? \n \n") ;
exit (1) ;
} }
/* Insert 16 fake samplenames & parameters contained in buf2 */
for ( i=0 ; i<470 ; i++ )
putc ( buf1 [i] , dest ) ;
for ( i=0 ; i<480 ; i++ )
putc ( buf2 [i] , dest ) ;
for ( i=470 ; i<600 ; i++ )
putc ( buf1 [i] , dest ) ;
/* Add "M.K." label */
putc (77,dest) ;
putc (46,dest) ;
putc (75,dest) ;
putc (46,dest) ;
/* Copy rest of module */
while (feof(src) == 0) {
buf3 [j] = getc(src) ;
j++ ;
if (j == 32000) {
for (i=0 ; i<32000 ; i++) putc (buf3 [i] , dest) ;
j = 0 ;
}
}
for (i=0 ; i<=j ; i++)
putc (buf3 [i] , dest) ;
printf("Converted module is '%s'.\n\n",destname (param[1]) ) ;
return 0 ;
}