diff options
Diffstat (limited to 'Xenogears/script-comp.cpp')
-rw-r--r-- | Xenogears/script-comp.cpp | 218 |
1 files changed, 109 insertions, 109 deletions
diff --git a/Xenogears/script-comp.cpp b/Xenogears/script-comp.cpp index 01f6bdd..4e835a7 100644 --- a/Xenogears/script-comp.cpp +++ b/Xenogears/script-comp.cpp @@ -1,109 +1,109 @@ -#include "lzss.h"
-#include "Input.h"
-#include "Output.h"
-#include "generic.h"
-#include "Main.h"
-
-CODE_BEGINS
-public:
-Appli() : lzss_o(new lzss()) {}
-virtual ~Appli() { delete lzss_o; }
-private:
-
-lzss * lzss_o;
-
-void process_one_file(Handle * f, Handle * d, Handle * f_part, int n) {
- String nom_du_fichier;
- char zeros[4] = {0, 0, 0, 0}, * datas;
- int script_position, true_length, delta, data_length;
- printm(M_BARE, " Copying header\n");
-
- f->seek(0x14c);
- f->read(&script_position, 4);
- f->seek(0);
- copy(f, d, script_position);
-
- f->seek(0x150);
- f->read(&script_position, 4);
- f->seek(script_position);
-
- data_length = f->GetSize() - script_position;
-
- datas = (char *) malloc(data_length);
- f->read(datas, data_length);
-
- printm(M_BARE, " Processing script\n");
-
- true_length = f_part->GetSize();
-
- script_position = d->tell();
- d->seek(0x14c);
- d->write(&script_position, 4);
- d->seek(0x128);
- d->write(&true_length, 4);
- d->seek(0, SEEK_END);
-
- lzss_o->lzss_comp(f_part, d, &delta);
-
- script_position = d->tell();
- if ((true_length = (script_position & 3))) {
- d->write(zeros, 4 - true_length);
- }
-
- printm(M_BARE, " Processing extra datas\n");
- script_position = d->tell();
- d->seek(0x150);
- d->write(&script_position, 4);
-
- d->seek(0,SEEK_END);
- d->write(datas, data_length);
-
- free(datas);
-}
-
-virtual int startup() throw (GeneralException)
-{
- Handle * f_script_comp, * f_old_script, * f_new_script;
- int i;
- int num = 0;
- String nom_du_fichier;
-
- for (i = 384; i < 1844; i = i + 2) {
- printm(M_BARE, "CD1 - File %d -> Script %d\n", i, num);
- nom_du_fichier.set("xeno_d1/ROOMS/%04d.out", i);
- f_old_script = new Input(nom_du_fichier);
- nom_du_fichier.set("xeno_d1/ROOMS/%04d.out-new", i);
- f_new_script = new Output(nom_du_fichier);
- nom_du_fichier.set("xeno_d1/ROOMS/%04d/script.comp", num);
- f_script_comp = new Input(nom_du_fichier);
-
- process_one_file(f_old_script, f_new_script, f_script_comp, num);
-
- delete f_script_comp;
- delete f_new_script;
- delete f_old_script;
- num++;
- }
- num = 0;
-
- for (i = 379; i < 1838; i = i + 2) {
- printm(M_BARE, "CD2 - File %d -> Script %d\n", i, num);
- nom_du_fichier.set("xeno_d2/ROOMS/%04d.out", i);
- f_old_script = new Input(nom_du_fichier);
- nom_du_fichier.set("xeno_d2/ROOMS/%04d.out-new", i);
- f_new_script = new Output(nom_du_fichier);
- nom_du_fichier.set("xeno_d2/ROOMS/%04d/script.comp", num);
- f_script_comp = new Input(nom_du_fichier);
-
- process_one_file(f_old_script, f_new_script, f_script_comp, num);
-
- delete f_script_comp;
- delete f_new_script;
- delete f_old_script;
- num++;
- }
- printm(M_BARE, "Done !\n");
-
- return 0;
-}
-CODE_ENDS
+#include "lzss.h" +#include "Input.h" +#include "Output.h" +#include "generic.h" +#include "Main.h" + +CODE_BEGINS +public: +Appli() : lzss_o(new lzss()) {} +virtual ~Appli() { delete lzss_o; } +private: + +lzss * lzss_o; + +void process_one_file(Handle * f, Handle * d, Handle * f_part, int n) { + String nom_du_fichier; + char zeros[4] = {0, 0, 0, 0}, * datas; + int script_position, true_length, delta, data_length; + printm(M_BARE, " Copying header\n"); + + f->seek(0x14c); + f->read(&script_position, 4); + f->seek(0); + copy(f, d, script_position); + + f->seek(0x150); + f->read(&script_position, 4); + f->seek(script_position); + + data_length = f->GetSize() - script_position; + + datas = (char *) malloc(data_length); + f->read(datas, data_length); + + printm(M_BARE, " Processing script\n"); + + true_length = f_part->GetSize(); + + script_position = d->tell(); + d->seek(0x14c); + d->write(&script_position, 4); + d->seek(0x128); + d->write(&true_length, 4); + d->seek(0, SEEK_END); + + lzss_o->lzss_comp(f_part, d, &delta); + + script_position = d->tell(); + if ((true_length = (script_position & 3))) { + d->write(zeros, 4 - true_length); + } + + printm(M_BARE, " Processing extra datas\n"); + script_position = d->tell(); + d->seek(0x150); + d->write(&script_position, 4); + + d->seek(0,SEEK_END); + d->write(datas, data_length); + + free(datas); +} + +virtual int startup() throw (GeneralException) +{ + Handle * f_script_comp, * f_old_script, * f_new_script; + int i; + int num = 0; + String nom_du_fichier; + + for (i = 384; i < 1844; i = i + 2) { + printm(M_BARE, "CD1 - File %d -> Script %d\n", i, num); + nom_du_fichier.set("xeno_d1/ROOMS/%04d.out", i); + f_old_script = new Input(nom_du_fichier); + nom_du_fichier.set("xeno_d1/ROOMS/%04d.out-new", i); + f_new_script = new Output(nom_du_fichier); + nom_du_fichier.set("xeno_d1/ROOMS/%04d/script.comp", num); + f_script_comp = new Input(nom_du_fichier); + + process_one_file(f_old_script, f_new_script, f_script_comp, num); + + delete f_script_comp; + delete f_new_script; + delete f_old_script; + num++; + } + num = 0; + + for (i = 379; i < 1838; i = i + 2) { + printm(M_BARE, "CD2 - File %d -> Script %d\n", i, num); + nom_du_fichier.set("xeno_d2/ROOMS/%04d.out", i); + f_old_script = new Input(nom_du_fichier); + nom_du_fichier.set("xeno_d2/ROOMS/%04d.out-new", i); + f_new_script = new Output(nom_du_fichier); + nom_du_fichier.set("xeno_d2/ROOMS/%04d/script.comp", num); + f_script_comp = new Input(nom_du_fichier); + + process_one_file(f_old_script, f_new_script, f_script_comp, num); + + delete f_script_comp; + delete f_new_script; + delete f_old_script; + num++; + } + printm(M_BARE, "Done !\n"); + + return 0; +} +CODE_ENDS |