/* ***************************************************** MaxDrive Duo save extractor to SC format ****************************************************** */ #include #include #include #include #define PROG_NAME "max2sc.exe" typedef unsigned char u8; typedef unsigned int u32; char *outputFilename = NULL; void usage() { printf("-------------------------------\n"); printf("Invalid command line.\n"); printf("Usage:\n\t%s infile.*\n", PROG_NAME); printf("-------------------------------\n"); } int main(int argc, char *argv[]) { int count = 0; u32 i, total, bytes = 0; FILE *in1, *out; /* In and out FILE Streams to read/write data */ if((argc != 2) || (argv[1] == NULL)) { /* Error check the command line */ usage(); /* Display Usage Information on error */ return 0; /* Exit Program returning 0 - no error */ } if (( in1 = fopen(argv[1], "rb")) == NULL) /* Error Check File Streams */ { printf("Error opening %s.\n", argv[1]); } outputFilename = argv[1]; strcat (outputFilename,".out"); if (( out = fopen(outputFilename, "wb")) == NULL) { printf("Error opening *.out.\n"); } i=0; //get first 500 bytes and skip them while (i < 500) { getc(in1); i++; } //write next bytes to outfile till EOF of in file while((count = getc(in1)) != EOF) // add the data { bytes++; // Increment counter of filesize putc(count, out); } printf("%d gamedata bytes read and copied\n", bytes); //pad outfile to 262144 (256k) - infile bytes total = 262144; while (bytes < total) { putc('\0', out); bytes++; } printf("%d bytes written to outfile", bytes); fclose(in1); fclose(out); return 0; }