#include #include int main(int argc, char *argv[]) { FILE *dff; unsigned int offset, size; int header, vcount; int temp, dword; if (argc < 2) exit(1); if ((dff = fopen(argv[1], "r")) == NULL) exit(1); sscanf(argv[2], "%X", &offset); printf("starting at: %X\n", offset); fseek(dff, offset, 0); fread(&temp, 4, 1, dff); if (temp != 0x510) exit(1); fread(&size, 4, 1, dff); fseek(dff, 16, SEEK_CUR); printf("%X\n", ftell(dff)); printf("%X\n", size+offset); while ((size+offset) > (ftell(dff))) { temp = getc(dff) << 24; temp += getc(dff) << 16; temp += getc(dff) << 8; temp += getc(dff); header = temp & 0xffff00ff; switch (header) { case 0x00800068: vcount = (temp & 0x0000ff00) >> 8; printf("vertexheader detected, skipping,\ %d Vertices\n", vcount); fseek(dff, vcount*12, SEEK_CUR); if ((vcount * 12) % 16 != 0) fseek(dff, 16-(vcount * 12 % 16), SEEK_CUR); break; case 0x01800064: vcount = (temp & 0x0000ff00) >> 8; printf("UVheader detected, skipping, \ %d Vertices\n", vcount); fseek(dff, vcount*8, SEEK_CUR); if ((vcount * 8) % 16 != 0) fseek(dff, 16-(vcount * 8 % 16), SEEK_CUR); break; case 0x02C0006e: vcount = (temp & 0x0000ff00) >> 8; printf("Vertexcolorheader detected, skipping, \ %d Vertices\n", vcount); fseek(dff, vcount*4, SEEK_CUR); if ((vcount * 4) % 16 != 0) fseek(dff, 16-(vcount * 4 % 16), SEEK_CUR); break; case 0x0380006a: vcount = (temp & 0x0000ff00) >> 8; printf("Normalheader detected, skipping, \ %d Vertices\n", vcount); fseek(dff, vcount*3, SEEK_CUR); if ((vcount * 3) % 16 != 0) fseek(dff, 16-(vcount * 3) % 16, SEEK_CUR); break; default: printf("%X: %X\n", ftell(dff), temp); } } return 0; }