diff options
Diffstat (limited to 'Xenogears')
| -rw-r--r-- | Xenogears/script-comp.cpp | 62 | ||||
| -rw-r--r-- | Xenogears/script-dec.cpp | 7 | 
2 files changed, 35 insertions, 34 deletions
diff --git a/Xenogears/script-comp.cpp b/Xenogears/script-comp.cpp index 363c63c..41fb00b 100644 --- a/Xenogears/script-comp.cpp +++ b/Xenogears/script-comp.cpp @@ -4,64 +4,64 @@  #include "lzss.h"  #include "fileutils.h" -void process_one_file(int  f, int  d, int n) { +void process_one_file(FILE * f, FILE * d, int n) {      char nom_du_fichier[100];      char zeros[4] = {0, 0, 0, 0}, * datas;      long script_position, true_length, delta, data_length; -    int  f_part; +    FILE * f_part;      fprintf(stderr, "  Copying header\n"); -    lseek(f, 0x14c, SEEK_SET); -    read(f, &script_position, 4); -    lseek(f, 0, SEEK_SET); +    fseek(f, 0x14c, SEEK_SET); +    fread(&script_position, 1, 4, f); +    fseek(f, 0, SEEK_SET);      copy(f, d, script_position); -    lseek(f, 0x150, SEEK_SET); -    read(f, &script_position, 4); -    lseek(f, script_position, SEEK_SET); +    fseek(f, 0x150, SEEK_SET); +    fread(&script_position, 1, 4, f); +    fseek(f, script_position, SEEK_SET);      data_length = filesize(f) - script_position;      datas = (char *) malloc(data_length); -    read(f, datas, data_length); +    fread(datas, 1, data_length, f);      fprintf(stderr, "  Processing script\n");      sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04i/script.comp", n); -    f_part = open(nom_du_fichier, O_RDONLY); +    f_part = fopen(nom_du_fichier, "r");      true_length = filesize(f_part); -    script_position = lseek(d, 0, SEEK_CUR); -    lseek(d, 0x14c, SEEK_SET); -    write(d, &script_position, 4); -    lseek(d, 0x128, SEEK_SET); -    write(d, &true_length, 4); -    lseek(d, 0, SEEK_END); +    script_position = fseek(d, 0, SEEK_CUR); +    fseek(d, 0x14c, SEEK_SET); +    fwrite(&script_position, 1, 4, d); +    fseek(d, 0x128, SEEK_SET); +    fwrite(&true_length, 1, 4, d); +    fseek(d, 0, SEEK_END);      lzss_comp(f_part, d, &delta); -    close(f_part); +    fclose(f_part); -    script_position = lseek(d, 0, SEEK_CUR); +    script_position = fseek(d, 0, SEEK_CUR);      if ((true_length = (script_position & 3))) { -        write(d, zeros, 4 - true_length); +        fwrite(zeros, 1, 4 - true_length, d);      }      fprintf(stderr, "  Processing extra datas\n"); -    script_position = lseek(d, 0, SEEK_CUR); -    lseek(d, 0x150, SEEK_SET); -    write(d, &script_position, 4); -    lseek(d, 0, SEEK_END); +    script_position = fseek(d, 0, SEEK_CUR); +    fseek(d, 0x150, SEEK_SET); +    fwrite(&script_position, 1, 4, d); +    fseek(d, 0, SEEK_END); -    write(d, datas, data_length); +    fwrite(datas, 1, data_length, d);      free(datas);  }  int main(int argc, char ** argv)  { -    int f_script_comp, f_new_script; +    FILE * f_script_comp, * f_new_script;      int i;      int num = 0;      char nom_du_fichier[100]; @@ -69,13 +69,13 @@ int main(int argc, char ** argv)      for (i = 384; i < 1844; i = i + 2) {  	fprintf(stderr, "CD1 - 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); +	f_script_comp = fopen(nom_du_fichier, "r");  	sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out-new", i); -	f_new_script = open(nom_du_fichier, O_WRONLY | O_CREAT | O_TRUNC, 00644); +	f_new_script = fopen(nom_du_fichier, "w");  	process_one_file(f_script_comp, f_new_script, num); -	close(f_script_comp); +	fclose(f_script_comp);  	num++;      }      num = 0; @@ -84,13 +84,13 @@ int main(int argc, char ** argv)      for (i = 379; i < 1838; i = i + 2) {  	fprintf(stderr, "CD2 - 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); +	f_script_comp = fopen(nom_du_fichier, "r");  	sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out-new", i); -	f_new_script = open(nom_du_fichier, O_WRONLY | O_CREAT | O_TRUNC, 00644); +	f_new_script = fopen(nom_du_fichier, "w");  	process_one_file(f_script_comp, f_new_script, num); -	close(f_script_comp); +	fclose(f_script_comp);  	num++;      }      fprintf(stderr, "Done !\n"); diff --git a/Xenogears/script-dec.cpp b/Xenogears/script-dec.cpp index 9d4faf3..ff7b356 100644 --- a/Xenogears/script-dec.cpp +++ b/Xenogears/script-dec.cpp @@ -1,13 +1,14 @@  #include <stdio.h>  #include <stdlib.h> -#include "lz77.h" +#include <unistd.h> +#include "lzss.h"  #include "fileutils.h" -void process_one_file(int  f, int d, int n) { +void process_one_file(FILE * f, int d, int n) {      char nom_du_fichier[100];      long script_position, true_length;      int i; -    int  f_out; +    FILE * f_out;      if (filesize(f) == 24) return;  | 
