// Converts 640x512 .RAW files (8-bit) to compressed .GFM format for // Gravity Force Maps for Sony's Black PlayStation, the Net Yaroze // Can use whole 8-bit palette -- only black areas are compressed // Written in Turbo C++ for DOS #include int main() { printf("\n\nRAW to GFM file converter for Gravity Force.\n\nUsage: RAW2GFM \n\n"); printf("Converts ONLY 640x512 8-bit RAW data to a unique compressed file format.\n"); printf("Alternatively buy an old Amiga and play the proper version of this classic\n"); printf("game! For now, call and this will make .GFM overwriting\n"); printf("existing files. DOH, too late.\n\n"); FILE *rawfile, *gfmfile; unsigned char inbyte, outbyte, count = 0; unsigned char h00 = 0x00, hFF = 0xFF; // Byte variables if ((rawfile = fopen("dogfite1.raw", "rb")) == NULL) // rEAD bYTES { printf("\nFile not found: DOGFITE1.RAW\n\n"); return 1; } gfmfile = fopen("dogfite1.gfm","wb"); // wRITE bYTES for (long i=0; i < 327680; i++) // 640 x 512 { fread(&inbyte, 1, 1, rawfile); // read byte if (inbyte) // Non-zero colour { if (count) // counting.. { fwrite(&count, 1, 1, gfmfile); count = 0; // reset counter } fwrite(&inbyte, 1, 1, gfmfile); // Write byte } else if (count) { if (count == 255) { fwrite(&hFF, 1, 1, gfmfile); // counter reached 255, auto reset fwrite(&h00, 1, 1, gfmfile); // write zero byte count = 1; } else count++; } else { fwrite(&h00, 1, 1, gfmfile); // write zero byte count = 1; // and begin counting } } fclose(rawfile); fclose(gfmfile); return 0; }