diff options
-rw-r--r-- | VP/main_dump.cpp | 53 | ||||
-rwxr-xr-x | Xenogears/map2sqr | 3 | ||||
-rw-r--r-- | cdutils.cpp | 14 | ||||
-rw-r--r-- | cdutils.h | 1 |
4 files changed, 44 insertions, 27 deletions
diff --git a/VP/main_dump.cpp b/VP/main_dump.cpp index cf6197d..47c90ac 100644 --- a/VP/main_dump.cpp +++ b/VP/main_dump.cpp @@ -35,7 +35,7 @@ unsigned int tourne = 0; struct t_index_tab { unsigned long address; - long size; + unsigned char flags; long type; long index; }; @@ -64,7 +64,7 @@ int main(int argc, char **argv) { FILE * f_def, * f_iso; - verbosity = 3; + verbosity = M_STATUS; fprintf(stderr, "Valkyrie Profile File Extractor by Nicolas \"Pixel\" Noble\n" @@ -184,52 +184,63 @@ long check_iso(FILE * f_iso) void read_files(FILE * f_iso) { t_index_tab index_tab[10000]; - unsigned char t[8]; unsigned long i; unsigned long j; unsigned int seq = 0; unsigned long indexer; - struct t_index_tab *p = (struct t_index_tab *) t; - unsigned char fat[32768]; + unsigned char fat[20480]; + unsigned char key[256]; -#define INDEXPOS 24 +#define INDEXPOS 150 sector_seek(f_iso, INDEXPOS); - for (i = INDEXPOS; i < (INDEXPOS + 16); i++) { + for (i = INDEXPOS; i < (INDEXPOS + 10); i++) { printm(M_INFO, "Reading fat sector %lu\n", i); read_sector(f_iso, &fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); } + memcpy(key, fat + 0x4f00, 256); + + printm(M_INFO, "Decrypting.\n"); + for (i = 0; i < 20480; i++) { + fat[i] ^= key[i % 256]; + } + indexer = 0; - for (j = 0; j < 32768; j = j + 7) { - t[0] = 0; - bcopy((char *) &fat[j], (char *) t + 1, 7); - p->address >>= 8; - index_tab[indexer] = *p; - if (p->size > 0 && p->address != 0) { - index_tab[indexer].index = j / 7; - printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu, size %3li\n", - indexer, index_tab[indexer].address, index_tab[indexer].size); + for (j = 4; j < 20480; j += 4) { + unsigned char m, s, f; + m = fat[j]; + s = fat[j + 1]; + f = fat[j + 2]; + index_tab[indexer].address = from_MSF(m, s, f); + if (m || s || f) { + index_tab[indexer].index = j / 4; + index_tab[indexer].flags = fat[j + 3]; + printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu - flags = %02x\n", + indexer, index_tab[indexer].address, fat[j + 3]); indexer++; if (indexer == nb_records) break; } else { - printm(M_WARNING, "Ignored invalid index chunk number %4lu (size = %lu) (%02x %02x %02x %02x %02x %02x %02x)\n", - j / 7, -index_tab[indexer].size, t[0], t[1], t[2], t[4], t[5], t[6], t[7]); + printm(M_WARNING, "Ignored invalid index chunk number %4lu\n", j / 4); } } printm(M_STATUS, "Index file generation complete.\n\n"); + index_tab[indexer].address = filesize(f_iso) / 2352; for (i = 0; i < nb_records; i++) { if (sequences[seq].sum == i) seq++; index_tab[i].type = sequences[seq].type; if (sequences[seq].type == 0) { - printm(M_INFO, "%6lu (%10lu): ignored\n", index_tab[i].address, index_tab[i].size); + printm(M_INFO, "%6lu - %02x: ignored\n", index_tab[i].address, index_tab[i].flags); } else { - printm(M_INFO, "%6lu (%10lu): ", index_tab[i].address, index_tab[i].size); - file_dump(f_iso, index_tab[i].address, index_tab[i].size, i, seq); + int size; + printm(M_INFO, "%6lu - %02x: ", index_tab[i].address, index_tab[i].flags); + size = index_tab[i + 1].address - index_tab[i].address; + size *= sec_sizes[index_tab[i].type]; + file_dump(f_iso, index_tab[i].address, size, i, seq); if (verbosity >= M_INFO) { fprintf(stderr, "\n"); } diff --git a/Xenogears/map2sqr b/Xenogears/map2sqr index 4621d54..a5739a0 100755 --- a/Xenogears/map2sqr +++ b/Xenogears/map2sqr @@ -22,7 +22,8 @@ NR > 4 { print d; d = $4; print d; - for (i = 5; i < NR; i++) { + + for (i = 5; i <= NF; i++) { $(i - 4) = $i; } NF -= 4; diff --git a/cdutils.cpp b/cdutils.cpp index d697b52..bba473a 100644 --- a/cdutils.cpp +++ b/cdutils.cpp @@ -34,7 +34,7 @@ char * sec_modes[5] = {"MODE 0 (no mode)", "MODE 1", "MODE 2", "MODE 2 FORM 1", struct DirEntry rootDir; unsigned char from_BCD(unsigned char x) { - return ((x & 0xff) + ((x & 0xff00) >> 4) * 10); + return ((x & 0xf) + ((x & 0xf0) >> 4) * 10); } unsigned char to_BCD(unsigned char x) { @@ -45,13 +45,17 @@ int is_valid_BCD(unsigned char x) { return (((x & 15) < 10) && ((x >> 4) < 10)); } +unsigned long from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start) { + return (from_BCD(m) * 60 + from_BCD(s)) * 75 + from_BCD(f) - start; +} + unsigned long from_MSF(unsigned long msf, unsigned long start) { unsigned char - f = from_BCD(msf & 0xff), - s = from_BCD((msf >> 8) & 0xff), - m = from_BCD((msf >> 16) & 0xff); + f = msf & 0xff, + s = (msf >> 8) & 0xff, + m = (msf >> 16) & 0xff; - return (m * 60 + s) * 75 + f - start; + return from_MSF(m, s, f, start); } FILE * open_ppf(char * ppf, FILE * iso, char * comment) { @@ -79,5 +79,6 @@ unsigned char from_BCD(unsigned char x); unsigned char to_BCD(unsigned char x); int is_valid_BCD(unsigned char x); unsigned long from_MSF(unsigned long msf, unsigned long start = 150); +unsigned long from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start = 150); #endif |