From 24fb33726eca4e8c5a88797adc9c17f4d541f543 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 4 May 2002 17:53:08 +0000 Subject: Initial revision --- Xenogears/script-dec.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Xenogears/script-dec.cpp (limited to 'Xenogears/script-dec.cpp') diff --git a/Xenogears/script-dec.cpp b/Xenogears/script-dec.cpp new file mode 100644 index 0000000..9d4faf3 --- /dev/null +++ b/Xenogears/script-dec.cpp @@ -0,0 +1,69 @@ +#include +#include +#include "lz77.h" +#include "fileutils.h" + +void process_one_file(int f, int d, int n) { + char nom_du_fichier[100]; + long script_position, true_length; + int i; + int f_out; + + if (filesize(f) == 24) return; + + sprintf(nom_du_fichier, "xeno_d%d/ROOMS/%04i", d, n); + MKDIR(nom_du_fichier); + + i = 7; +// for (i = 0; i < 9; i++) { +// fprintf(stderr, " Processing part %i\n", i); + sprintf(nom_du_fichier, "xeno_d%d/ROOMS/%04i/script.comp", d, n); +// sprintf(nom_du_fichier, "xeno_d%d/ROOMS/%04i/part-%i", d, n, i); + f_out = open(nom_du_fichier, O_WRONLY | O_TRUNC | O_CREAT, 00644); + lseek(f, 0x130 + i * 4, SEEK_SET); + read(f, &script_position, 4); + lseek(f, 0x10c + i * 4, SEEK_SET); + read(f, &true_length, 4); + lseek(f, script_position, SEEK_SET); + lz77_decomp(f, f_out, true_length); +// if (i == 7) { +// fseek(f_out, 0, SEEK_SET); +// fread(&true_length, 4, 1, f_out); +// fprintf(stderr, " (seems to be the script number %i)\n", true_length); +// } + close(f_out); +// } +} + +int main(void) +{ + int f_script_comp; + int i; + int num = 0; + char nom_du_fichier[100]; + + for (i = 384; i < 1844; i = i + 2) { + fprintf(stderr, "CD 1 - File %d -> Script %d\n", i, num); + sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out", i); + f_script_comp = open(nom_du_fichier, O_RDONLY); + + process_one_file(f_script_comp, 1, num); + + close(f_script_comp); + num++; + } + + num = 0; + + for (i = 379; i < 1838; i = i + 2) { + fprintf(stderr, "CD 2 - File %d -> Script %d\n", i, num); + sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out", i); + f_script_comp = open(nom_du_fichier, O_RDONLY); + + process_one_file(f_script_comp, 2, num); + + close(f_script_comp); + num++; + } + fprintf(stderr, "Done !\n"); +} -- cgit v1.2.3