Skip to content

Instantly share code, notes, and snippets.

Created October 31, 2012 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3989841 to your computer and use it in GitHub Desktop.
Save anonymous/3989841 to your computer and use it in GitHub Desktop.
Imphobia #12 content dumper
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int num = 1;
void readArticle(FILE * f)
{
int unknown1 = 0;
fread(&unknown1,2,1,f); // this is probably the length of one single row
int numPages = 0;
fread(&numPages,4,1,f);
// these three lines below is a hack because I couldn't find how do detect the row count properly
int rowCount = 15;
if (unknown1 / numPages != 40) rowCount = 12;
if (num>=187) rowCount = 15;
int trailingData = 0;
fread(&trailingData,2,1,f);
printf("%04d | %4d / %4d = %4d -> %4d | %4d\n",num,unknown1,numPages,unknown1 / numPages,rowCount,trailingData);
unsigned char columnWidths[36];
fread(columnWidths,36,1,f);
char outfile[64];
_snprintf(outfile,64,"dump/%08d.dat",num++);
FILE * out = fopen(outfile,"wt");
for(int i=0; i<rowCount; i++)
{
for(int j=0; j<numPages; j++)
{
int oneLine = columnWidths[j];
unsigned char * p = new unsigned char[oneLine + 1];
memset(p,0,oneLine + 1);
fread(p,oneLine,1,f);
for(int x=0; x<oneLine; x++) p[x] += 0x20;
fprintf(out,"%s",(char*)p);
delete[] p;
}
fprintf(out,"\n");
}
fclose(out);
fseek(f,trailingData * 4,SEEK_CUR); // no idea what this is, i think it's the color/font changes
}
void main() {
FILE * f = fopen("NFO12.DAT","rb");
fseek(f,26,SEEK_CUR);
for (int i=0; i<254; i++)
{
readArticle(f);
}
fclose(f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment