#include #include #include "../librw/rw.h" int main(int argc, char *argv[]) { FILE *img, *dir; char name[24]; char tex[64], alpha[64]; int filecount; int bpp, filterflags; int start; int end; short texcount; int txdcount; int temp; int compression; int issinglefile; int width, height; rwheader rwh; if (argc < 2) { fprintf(stderr, "usage: %s img [dir]\n", argv[0]); exit(1); } else if (argc > 2) issinglefile = 0; else issinglefile = 1; if ((img = fopen(argv[1], "rb")) == NULL) { fprintf(stderr, "Could not open file: %s\n", argv[1]); exit(1); } if (!issinglefile) { if ((dir = fopen(argv[2], "rb")) == NULL) { fprintf(stderr, "Could not open file: %s\n", argv[2]); exit(1); } fseek(dir, 0, SEEK_END); filecount = ftell(dir) / 32; fseek(dir, 0, 0); } else { filecount = 1; strcpy(name, argv[1]); } end = 0; txdcount = 0; printf("bpp filter format compression platform: filename texture alpha\n"); while (filecount--) { if (!issinglefile) { fread(&start, 4, 1, dir); fseek(dir, 4, SEEK_CUR); fread(name, 24, 1, dir); fseek(img, start*2048, 0); } rwh = ReadHeader(img); if (rwh.type != 0x16) continue; rwh = ReadHeader(img); fread(&texcount, 2, 1, img); fseek(img, 2, SEEK_CUR); for (; texcount > 0; texcount--) { /* Texture Native */ rwh = ReadHeader(img); end = rwh.size + ftell(img); ReadHeader(img); fread(&temp, 4, 1, img); fread(&filterflags, 4, 1, img); if (temp != 0x00325350) { fread(tex, 32, 1, img); fread(alpha, 32, 1, img); fread(&temp, 4, 1, img); fseek(img, 8, SEEK_CUR); bpp = getc(img); fseek(img, 2, SEEK_CUR); compression = getc(img); printf("%d %X %X %d Non-PS2: %s %s %s\n", bpp, filterflags, temp, compression, name, tex, alpha); fseek(img, end, 0); continue; } /* Texture names */ rwh = ReadHeader(img); fread(tex, rwh.size, 1, img); rwh = ReadHeader(img); fread(alpha, rwh.size, 1, img); if (alpha[0] == '\0') strcpy(alpha, "--none--"); fseek(img, 24, SEEK_CUR); fread(&width, 4, 1, img); fread(&height, 4, 1, img); fread(&bpp, 4, 1, img); printf("%d %d %d %X 0 0 PS2 %s %s %s\t\n", bpp, width, height, filterflags, name, tex, alpha); fseek(img, end, 0); } end = 1; txdcount++; } printf("bpp filter format compression platform: filename texture alpha\n"); return 0; }