1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "lzss.h"
#include "fileutils.h"
void process_one_file(FILE * f, int d, int n) {
char nom_du_fichier[100];
long script_position, true_length;
int i;
FILE * 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 = fopen(nom_du_fichier, "w");
fseek(f, 0x130 + i * 4, SEEK_SET);
fread(&script_position, 1, 4, f);
fseek(f, 0x10c + i * 4, SEEK_SET);
fread(&true_length, 1, 4, f);
fseek(f, script_position, SEEK_SET);
lzss_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);
// }
fclose(f_out);
// }
}
int main(void)
{
FILE * 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 = fopen(nom_du_fichier, "r");
process_one_file(f_script_comp, 1, num);
fclose(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 = fopen(nom_du_fichier, "r");
process_one_file(f_script_comp, 2, num);
fclose(f_script_comp);
num++;
}
fprintf(stderr, "Done !\n");
}
|