#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, int n) { String nom_du_fichier; char zeros[4] = {0, 0, 0, 0}, * datas; long script_position, true_length, delta, data_length; Handle * f_part; char tmpNm[256]; 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"); char tmpNm[256]; sprintf(tmpNm,"xeno_d1/ROOMS/%04d/script.comp",n); nom_du_fichier = String(tmpNm); f_part = new Input(nom_du_fichier); 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); delete f_part; 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_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_script_comp = new Input(nom_du_fichier); nom_du_fichier.set("xeno_d1/ROOMS/%04d.out-new", i); f_new_script = new Output(nom_du_fichier); process_one_file(f_script_comp, f_new_script, num); delete f_script_comp; delete f_new_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_script_comp = new Input(nom_du_fichier); nom_du_fichier.set("xeno_d2/ROOMS/%04d.out-new", i); f_new_script = new Output(nom_du_fichier); process_one_file(f_script_comp, f_new_script, num); delete f_script_comp; delete f_new_script; num++; }*/ printm(M_BARE, "Done !\n"); return 0; } CODE_ENDS