Created
October 31, 2012 21:03
-
-
Save anonymous/3989841 to your computer and use it in GitHub Desktop.
Imphobia #12 content dumper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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