diff options
author | pixel <pixel> | 2004-11-27 21:44:15 +0000 |
---|---|---|
committer | pixel <pixel> | 2004-11-27 21:44:15 +0000 |
commit | 50f0dd331f8168fb5b2cd60c70178fad627b7fb6 (patch) | |
tree | 65fcec7bd507791f0db8a3af1b60ad9ac631f4a7 /Xenogears | |
parent | f1df76865d1751469deff19e62255d50a814f183 (diff) |
Large dos2unix commit...
Diffstat (limited to 'Xenogears')
-rw-r--r-- | Xenogears/Decrypt.cpp | 1026 | ||||
-rw-r--r-- | Xenogears/Translate.cpp | 512 | ||||
-rw-r--r-- | Xenogears/archive.cpp | 74 | ||||
-rw-r--r-- | Xenogears/build-sector-2.cpp | 28 | ||||
-rw-r--r-- | Xenogears/build-sector.cpp | 28 | ||||
-rw-r--r-- | Xenogears/main_dump.cpp | 566 | ||||
-rw-r--r-- | Xenogears/reinsert.cpp | 580 | ||||
-rw-r--r-- | Xenogears/script-comp.cpp | 208 | ||||
-rw-r--r-- | Xenogears/script-dec.cpp | 164 | ||||
-rw-r--r-- | Xenogears/test-dlzss.cpp | 14 | ||||
-rw-r--r-- | Xenogears/test-lzss.cpp | 14 |
11 files changed, 1607 insertions, 1607 deletions
diff --git a/Xenogears/Decrypt.cpp b/Xenogears/Decrypt.cpp index 0683078..7cdb1aa 100644 --- a/Xenogears/Decrypt.cpp +++ b/Xenogears/Decrypt.cpp @@ -1,513 +1,513 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include "generic.h" -#include "Input.h" -#include "Output.h" -#include "Main.h" - -CODE_BEGINS -void init_table(long table[5000]) -{ - long i; - - for (i = 0; i < 5000; i++) { - table[i] = 0; - } -} - -char found_position(long table[5000], int number, FILE * f_source) -{ - long position; - long i; - - position = ftell(f_source); - - for (i = 0; i < number; i++) { - if (table[i] <= position) - return (1); - } - return (0); -} - -long found_next(long table[5000], long script_number, long max_script) -{ - long i; - long next = 0xFFFF; - long actual = table[script_number]; - - for (i = 0; i < script_number; i++) { - if (table[i] > actual) { - if (table[i] < next) - next = table[i]; - } - } - - for (i = script_number + 1; i < max_script; i++) { - if (table[i] > actual) { - if (table[i] < next) - next = table[i]; - } - } - - return (next); -} - -void dump_text(FILE * f_source, FILE * f_cible, long table[5000], long script_number, - long max_script, unsigned char *length_table, unsigned char *line_table) -{ - long next; - unsigned char val; - char temp_string[2] = {0, 0}; - long position; - unsigned char temp1 = 0; - unsigned char temp2 = 0; - - next = found_next(table, script_number, max_script); - - fseek(f_source, table[script_number], SEEK_SET); - - fprintf(f_cible, "<Text_block lines:%d width:%d>\n", - line_table[script_number], length_table[script_number]); - - position = ftell(f_source); - - while (position < next) { - val = 0; - - fread((unsigned char *) &val, 1, 1, f_source); - - if (val == 0x00) // "<Close>" - { - break; - } else if (val == 0x01) // "\n" - { - fprintf(f_cible, "\n"); - } else if (val == 0x02) // "<New>" - { - fprintf(f_cible, "<New>\n"); - } else if (val == 0x03) // "<Wait>" - { - fprintf(f_cible, "<Wait>"); - } else if (val == 0x0F) // Extended opcode. Reads two more bytes. - { - fread((unsigned char *) &temp1, 1, 1, f_source); - fread((unsigned char *) &temp2, 1, 1, f_source); - if (temp1 == 0) { - fprintf(f_cible, "<Delay %d>", temp2); - } else if (temp1 == 5) { - switch (temp2) { - case 0: - fprintf(f_cible, "<Fei>"); - break; - case 1: - fprintf(f_cible, "<Elly>"); - break; - case 2: - fprintf(f_cible, "<Citan>"); - break; - case 3: - fprintf(f_cible, "<Bart>"); - break; - case 4: - fprintf(f_cible, "<Billy>"); - break; - case 5: - fprintf(f_cible, "<Rico>"); - break; - case 6: - fprintf(f_cible, "<Emeralda>"); - break; - case 7: - fprintf(f_cible, "<Chu-Chu>"); - break; - case 8: - fprintf(f_cible, "<Maria>"); - break; - case 9: - fprintf(f_cible, "<Citan2>"); - break; - case 10: - fprintf(f_cible, "<Emeralda2>"); - break; - case 11: - fprintf(f_cible, "<Weltall>"); - break; - case 12: - fprintf(f_cible, "<Weltall-2>"); - break; - case 13: - fprintf(f_cible, "<Vierge>"); - break; - case 14: - fprintf(f_cible, "<Heimdal>"); - break; - case 15: - fprintf(f_cible, "<Brigandier>"); - break; - case 16: - fprintf(f_cible, "<Renmazuo>"); - break; - case 17: - fprintf(f_cible, "<Stier>"); - break; - case 18: - fprintf(f_cible, "<BigChu-chu>"); - break; - case 19: - fprintf(f_cible, "<Seibzehn>"); - break; - case 20: - fprintf(f_cible, "<Crescens>"); - break; - case 21: - fprintf(f_cible, "<Regurus>"); - break; - case 22: - fprintf(f_cible, "<Fenrir>"); - break; - case 23: - fprintf(f_cible, "<Andvari>"); - break; - case 24: - fprintf(f_cible, "<Renmazuo>"); - break; - case 25: - fprintf(f_cible, "<Stier-2>"); - break; - case 26: - fprintf(f_cible, "<Xenogears>"); - break; - case 27: - fprintf(f_cible, "<BARTHOS>"); - break; - case 28: - fprintf(f_cible, "<Yggdra>"); - break; - case 128: - fprintf(f_cible, "<Perso1>"); - break; - case 129: - fprintf(f_cible, "<Perso2>"); - break; - case 130: - fprintf(f_cible, "<Perso3>"); - break; - default: - fprintf(f_cible, "<Gear %d>", temp2); - } - } else { - fprintf(f_cible, "<Opcode %d %d>", temp1, temp2); - } - } else if (val == 0x10) // " " - { - fprintf(f_cible, " "); - } else if (val == 0x11) // "+" - { - fprintf(f_cible, "+"); - } else if (val == 0x12) // "," - { - fprintf(f_cible, ","); - } else if (val == 0x13) // "-" - { - fprintf(f_cible, "-"); - } else if (val == 0x14) // "." - { - fprintf(f_cible, "."); - } else if (val == 0x15) // "/" - { - fprintf(f_cible, "/"); - } else if ((val >= 0x16) && (val <= 0x1F)) // "0-9" - { - temp_string[0] = val + 0x1A; - fprintf(f_cible, temp_string); - } else if ((val >= 0x20) && (val <= 0x39)) // "A-Z" - { - temp_string[0] = val + 0x21; - fprintf(f_cible, temp_string); - } else if (val == 0x3A) // "[" - { - fprintf(f_cible, "["); - } else if (val == 0x3B) // "]" - { - fprintf(f_cible, "]"); - } else if (val == 0x3C) // "=" - { - fprintf(f_cible, "="); - } else if ((val >= 0x3D) && (val <= 0x56)) // "a-z" - { - temp_string[0] = val + 0x24; - fprintf(f_cible, temp_string); - } else if (val == 0x57) // "!" - { - fprintf(f_cible, "!"); - } else if (val == 0x58) // "\"" - { - fprintf(f_cible, "\""); - } else if (val == 0x59) // "#" - { - fprintf(f_cible, "#"); - } else if (val == 0x5A) // "%" - { - fprintf(f_cible, "%%"); - } else if (val == 0x5B) // "&" - { - fprintf(f_cible, "&"); - } else if (val == 0x5C) // "'" - { - fprintf(f_cible, "'"); - } else if (val == 0x5D) // "(" - { - fprintf(f_cible, "("); - } else if (val == 0x5E) // ")" - { - fprintf(f_cible, ")"); - } else if (val == 0x5F) // ":" - { - fprintf(f_cible, ":"); - } else if (val == 0x60) // "?" - { - fprintf(f_cible, "?"); - } else if (val == 0x61) // "<0>" - { - fprintf(f_cible, "<0>"); - } else if (val == 0x62) // "<1>" - { - fprintf(f_cible, "<1>"); - } else if (val == 0x63) // "<2>" - { - fprintf(f_cible, "<2>"); - } else if (val == 0x64) // "<3>" - { - fprintf(f_cible, "<3>"); - } else if (val == 0x65) // "<4>" - { - fprintf(f_cible, "<4>"); - } else if (val == 0x66) // "<5>" - { - fprintf(f_cible, "<5>"); - } else if (val == 0x67) // "<6>" - { - fprintf(f_cible, "<6>"); - } else if (val == 0x68) // "<7>" - { - fprintf(f_cible, "<7>"); - } else if (val == 0x69) // "<8>" - { - fprintf(f_cible, "<8>"); - } else if (val == 0x6A) // "<9>" - { - fprintf(f_cible, "<9>"); - } else if (val == 0x6B) // "<%>" - { - fprintf(f_cible, "<%%>"); - } else if (val == 0x6C) // "<&>" - { - fprintf(f_cible, "<&>"); - } else if (val == 0x6D) // "*" - { - fprintf(f_cible, "*"); - } else if (val == 0x6E) // "<C>" - { - fprintf(f_cible, "<C>"); - } else if (val == 0x6F) // "<S>" - { - fprintf(f_cible, "<S>"); - } else if (val == 0x70) // "<T>" - { - fprintf(f_cible, "<T>"); - } else if (val == 0x71) // "<*>" - { - fprintf(f_cible, "<*>"); - } else if (val == 0x72) // "<R>" - { - fprintf(f_cible, "<R>"); - } else if (val == 0x73) // "<L>" - { - fprintf(f_cible, "<L>"); - } else if (val == 0x74) // "<U>" - { - fprintf(f_cible, "<U>"); - } else if (val == 0x75) // "<U>" - { - fprintf(f_cible, "<D>"); - } else if (val == 0x76) // "<.>" - { - fprintf(f_cible, "<.>"); - } else if (val == 0x77) // "<:>" - { - fprintf(f_cible, "<:>"); - } else if (val == 0x79) // "</>" - { - fprintf(f_cible, "</>"); - } else if (val == 0x7A) // "<..>" - { - fprintf(f_cible, "<..>"); - } else if (val == 0x7B) // "<`>" - { - fprintf(f_cible, "<`>"); - } else if (val == 0x7D) // "<+>" - { - fprintf(f_cible, "<+>"); - } else if (val == 0x7E) // "<->" - { - fprintf(f_cible, "<->"); - } else if (val == 0x7F) // "<X>" - { - fprintf(f_cible, "<X>"); - } else if (val == 0x80) // "<[>" - { - fprintf(f_cible, "<[>"); - } else if (val == 0x81) // "<]>" - { - fprintf(f_cible, "<]>"); - } else if (val == 0x82) // "<%>" - { - fprintf(f_cible, "<%%>"); - } else if (val == 0x83) // "<&>" - { - fprintf(f_cible, "<&>"); - } else if (val == 0x84) // "<(>" - { - fprintf(f_cible, "<(>"); - } else if (val == 0x85) // "<)>" - { - fprintf(f_cible, "<)>"); - } else if (val == 0x86) // "<#>" - { - fprintf(f_cible, "<#>"); - } else if (val == 0x87) // "`" - { - fprintf(f_cible, "`"); - } else if (val == 0x88) // "°" - { - fprintf(f_cible, "°"); - } else if (val == 0x89) // "<=>" - { - fprintf(f_cible, "<=>"); - } else if (val == 0x8A) // "<?>" - { - fprintf(f_cible, "<?>"); - } else if (val == 0x8B) // "<!>" - { - fprintf(f_cible, "<!>"); - } else if (val == 0x8C) // "_" - { - fprintf(f_cible, "_"); - } else if (val == 0x8D) // "~" - { - fprintf(f_cible, "~"); - } else if (val == 0x8E) // "<...>" - { - fprintf(f_cible, "<...>"); - } else if (val == 0x8F) // "<'>" - { - fprintf(f_cible, "<'>"); - } else if (val == 0xFE) // "<Extra1 X> - { - fread((unsigned char *) &temp1, 1, 1, f_source); - fprintf(f_cible, "<Extra1 %d>", temp1); - } else if (val == 0xFF) // "<Extra2 X> - { - fread((unsigned char *) &temp1, 1, 1, f_source); - fprintf(f_cible, "<Extra2 %d>", temp1); - } else { - fprintf(f_cible, "<Bare %X>", val); - } - - position = ftell(f_source); - } - fprintf(f_cible, "\n<End_of_block>\n\n"); -} - -int decrypt(FILE * f_source, FILE * f_cible, int room_number) -{ - long i, j; - long table[5000]; - unsigned char line_table[5000]; - unsigned char length_table[5000]; - long script_number = 0; - long temp = 0; - char temp_char; - int counter = 0; - - fread((long *) &script_number, 4, 1, f_source); - - if (script_number == 0x0000FFFF) - return (1); - - script_number = (script_number++); - - fprintf(f_cible, "<Blocks:%li>\n", script_number); - init_table(table); - - i = j = 0; - - while (i < script_number) { - fread((long *) &temp, 2, 1, f_source); - if (table[j - 1] != temp) - table[j++] = temp; - i++; - } - - script_number = j; - - for (i = 0; i < script_number; i++) { - fread((unsigned char *) &length_table[i], 1, 1, f_source); - fread((unsigned char *) &line_table[i], 1, 1, f_source); - } - - fseek(f_source, table[script_number - 1], SEEK_SET); - - do { - fread((char *) &temp_char, 1, 1, f_source); - counter++; - } while (temp_char != 0); - - table[script_number] = ftell(f_source); - - for (i = 0; i < script_number; i++) { - dump_text(f_source, f_cible, table, i, script_number, length_table, line_table); - } - - return (0); -} - -int startup(void) throw (GeneralException) -{ - int i; - char file_name[100]; - FILE *f_source, *f_cible; - - for (i = 0; i < 730; i++) { - printf("%d\n", i); - sprintf(file_name, "xeno_d1/ROOMS/%04d/script.comp", i); - f_source = fopen(file_name, "rb"); - - sprintf(file_name, "xeno_d1/ROOMS/%04d/script.txt", i); - - if (f_source != NULL) { - f_cible = fopen(file_name, "w"); - decrypt(f_source, f_cible, 5); - fclose(f_source); - fclose(f_cible); - } - } - for (i = 0; i < 730; i++) { - printf("%d\n", i); - sprintf(file_name, "xeno_d2/ROOMS/%04d/script.comp", i); - f_source = fopen(file_name, "rb"); - - sprintf(file_name, "xeno_d2/ROOMS/%04d/script.txt", i); - - if (f_source != NULL) { - f_cible = fopen(file_name, "w"); - decrypt(f_source, f_cible, 5); - fclose(f_source); - fclose(f_cible); - } - } - - return 0; -} -CODE_ENDS +#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "generic.h"
+#include "Input.h"
+#include "Output.h"
+#include "Main.h"
+
+CODE_BEGINS
+void init_table(long table[5000])
+{
+ long i;
+
+ for (i = 0; i < 5000; i++) {
+ table[i] = 0;
+ }
+}
+
+char found_position(long table[5000], int number, FILE * f_source)
+{
+ long position;
+ long i;
+
+ position = ftell(f_source);
+
+ for (i = 0; i < number; i++) {
+ if (table[i] <= position)
+ return (1);
+ }
+ return (0);
+}
+
+long found_next(long table[5000], long script_number, long max_script)
+{
+ long i;
+ long next = 0xFFFF;
+ long actual = table[script_number];
+
+ for (i = 0; i < script_number; i++) {
+ if (table[i] > actual) {
+ if (table[i] < next)
+ next = table[i];
+ }
+ }
+
+ for (i = script_number + 1; i < max_script; i++) {
+ if (table[i] > actual) {
+ if (table[i] < next)
+ next = table[i];
+ }
+ }
+
+ return (next);
+}
+
+void dump_text(FILE * f_source, FILE * f_cible, long table[5000], long script_number,
+ long max_script, unsigned char *length_table, unsigned char *line_table)
+{
+ long next;
+ unsigned char val;
+ char temp_string[2] = {0, 0};
+ long position;
+ unsigned char temp1 = 0;
+ unsigned char temp2 = 0;
+
+ next = found_next(table, script_number, max_script);
+
+ fseek(f_source, table[script_number], SEEK_SET);
+
+ fprintf(f_cible, "<Text_block lines:%d width:%d>\n",
+ line_table[script_number], length_table[script_number]);
+
+ position = ftell(f_source);
+
+ while (position < next) {
+ val = 0;
+
+ fread((unsigned char *) &val, 1, 1, f_source);
+
+ if (val == 0x00) // "<Close>"
+ {
+ break;
+ } else if (val == 0x01) // "\n"
+ {
+ fprintf(f_cible, "\n");
+ } else if (val == 0x02) // "<New>"
+ {
+ fprintf(f_cible, "<New>\n");
+ } else if (val == 0x03) // "<Wait>"
+ {
+ fprintf(f_cible, "<Wait>");
+ } else if (val == 0x0F) // Extended opcode. Reads two more bytes.
+ {
+ fread((unsigned char *) &temp1, 1, 1, f_source);
+ fread((unsigned char *) &temp2, 1, 1, f_source);
+ if (temp1 == 0) {
+ fprintf(f_cible, "<Delay %d>", temp2);
+ } else if (temp1 == 5) {
+ switch (temp2) {
+ case 0:
+ fprintf(f_cible, "<Fei>");
+ break;
+ case 1:
+ fprintf(f_cible, "<Elly>");
+ break;
+ case 2:
+ fprintf(f_cible, "<Citan>");
+ break;
+ case 3:
+ fprintf(f_cible, "<Bart>");
+ break;
+ case 4:
+ fprintf(f_cible, "<Billy>");
+ break;
+ case 5:
+ fprintf(f_cible, "<Rico>");
+ break;
+ case 6:
+ fprintf(f_cible, "<Emeralda>");
+ break;
+ case 7:
+ fprintf(f_cible, "<Chu-Chu>");
+ break;
+ case 8:
+ fprintf(f_cible, "<Maria>");
+ break;
+ case 9:
+ fprintf(f_cible, "<Citan2>");
+ break;
+ case 10:
+ fprintf(f_cible, "<Emeralda2>");
+ break;
+ case 11:
+ fprintf(f_cible, "<Weltall>");
+ break;
+ case 12:
+ fprintf(f_cible, "<Weltall-2>");
+ break;
+ case 13:
+ fprintf(f_cible, "<Vierge>");
+ break;
+ case 14:
+ fprintf(f_cible, "<Heimdal>");
+ break;
+ case 15:
+ fprintf(f_cible, "<Brigandier>");
+ break;
+ case 16:
+ fprintf(f_cible, "<Renmazuo>");
+ break;
+ case 17:
+ fprintf(f_cible, "<Stier>");
+ break;
+ case 18:
+ fprintf(f_cible, "<BigChu-chu>");
+ break;
+ case 19:
+ fprintf(f_cible, "<Seibzehn>");
+ break;
+ case 20:
+ fprintf(f_cible, "<Crescens>");
+ break;
+ case 21:
+ fprintf(f_cible, "<Regurus>");
+ break;
+ case 22:
+ fprintf(f_cible, "<Fenrir>");
+ break;
+ case 23:
+ fprintf(f_cible, "<Andvari>");
+ break;
+ case 24:
+ fprintf(f_cible, "<Renmazuo>");
+ break;
+ case 25:
+ fprintf(f_cible, "<Stier-2>");
+ break;
+ case 26:
+ fprintf(f_cible, "<Xenogears>");
+ break;
+ case 27:
+ fprintf(f_cible, "<BARTHOS>");
+ break;
+ case 28:
+ fprintf(f_cible, "<Yggdra>");
+ break;
+ case 128:
+ fprintf(f_cible, "<Perso1>");
+ break;
+ case 129:
+ fprintf(f_cible, "<Perso2>");
+ break;
+ case 130:
+ fprintf(f_cible, "<Perso3>");
+ break;
+ default:
+ fprintf(f_cible, "<Gear %d>", temp2);
+ }
+ } else {
+ fprintf(f_cible, "<Opcode %d %d>", temp1, temp2);
+ }
+ } else if (val == 0x10) // " "
+ {
+ fprintf(f_cible, " ");
+ } else if (val == 0x11) // "+"
+ {
+ fprintf(f_cible, "+");
+ } else if (val == 0x12) // ","
+ {
+ fprintf(f_cible, ",");
+ } else if (val == 0x13) // "-"
+ {
+ fprintf(f_cible, "-");
+ } else if (val == 0x14) // "."
+ {
+ fprintf(f_cible, ".");
+ } else if (val == 0x15) // "/"
+ {
+ fprintf(f_cible, "/");
+ } else if ((val >= 0x16) && (val <= 0x1F)) // "0-9"
+ {
+ temp_string[0] = val + 0x1A;
+ fprintf(f_cible, temp_string);
+ } else if ((val >= 0x20) && (val <= 0x39)) // "A-Z"
+ {
+ temp_string[0] = val + 0x21;
+ fprintf(f_cible, temp_string);
+ } else if (val == 0x3A) // "["
+ {
+ fprintf(f_cible, "[");
+ } else if (val == 0x3B) // "]"
+ {
+ fprintf(f_cible, "]");
+ } else if (val == 0x3C) // "="
+ {
+ fprintf(f_cible, "=");
+ } else if ((val >= 0x3D) && (val <= 0x56)) // "a-z"
+ {
+ temp_string[0] = val + 0x24;
+ fprintf(f_cible, temp_string);
+ } else if (val == 0x57) // "!"
+ {
+ fprintf(f_cible, "!");
+ } else if (val == 0x58) // "\""
+ {
+ fprintf(f_cible, "\"");
+ } else if (val == 0x59) // "#"
+ {
+ fprintf(f_cible, "#");
+ } else if (val == 0x5A) // "%"
+ {
+ fprintf(f_cible, "%%");
+ } else if (val == 0x5B) // "&"
+ {
+ fprintf(f_cible, "&");
+ } else if (val == 0x5C) // "'"
+ {
+ fprintf(f_cible, "'");
+ } else if (val == 0x5D) // "("
+ {
+ fprintf(f_cible, "(");
+ } else if (val == 0x5E) // ")"
+ {
+ fprintf(f_cible, ")");
+ } else if (val == 0x5F) // ":"
+ {
+ fprintf(f_cible, ":");
+ } else if (val == 0x60) // "?"
+ {
+ fprintf(f_cible, "?");
+ } else if (val == 0x61) // "<0>"
+ {
+ fprintf(f_cible, "<0>");
+ } else if (val == 0x62) // "<1>"
+ {
+ fprintf(f_cible, "<1>");
+ } else if (val == 0x63) // "<2>"
+ {
+ fprintf(f_cible, "<2>");
+ } else if (val == 0x64) // "<3>"
+ {
+ fprintf(f_cible, "<3>");
+ } else if (val == 0x65) // "<4>"
+ {
+ fprintf(f_cible, "<4>");
+ } else if (val == 0x66) // "<5>"
+ {
+ fprintf(f_cible, "<5>");
+ } else if (val == 0x67) // "<6>"
+ {
+ fprintf(f_cible, "<6>");
+ } else if (val == 0x68) // "<7>"
+ {
+ fprintf(f_cible, "<7>");
+ } else if (val == 0x69) // "<8>"
+ {
+ fprintf(f_cible, "<8>");
+ } else if (val == 0x6A) // "<9>"
+ {
+ fprintf(f_cible, "<9>");
+ } else if (val == 0x6B) // "<%>"
+ {
+ fprintf(f_cible, "<%%>");
+ } else if (val == 0x6C) // "<&>"
+ {
+ fprintf(f_cible, "<&>");
+ } else if (val == 0x6D) // "*"
+ {
+ fprintf(f_cible, "*");
+ } else if (val == 0x6E) // "<C>"
+ {
+ fprintf(f_cible, "<C>");
+ } else if (val == 0x6F) // "<S>"
+ {
+ fprintf(f_cible, "<S>");
+ } else if (val == 0x70) // "<T>"
+ {
+ fprintf(f_cible, "<T>");
+ } else if (val == 0x71) // "<*>"
+ {
+ fprintf(f_cible, "<*>");
+ } else if (val == 0x72) // "<R>"
+ {
+ fprintf(f_cible, "<R>");
+ } else if (val == 0x73) // "<L>"
+ {
+ fprintf(f_cible, "<L>");
+ } else if (val == 0x74) // "<U>"
+ {
+ fprintf(f_cible, "<U>");
+ } else if (val == 0x75) // "<U>"
+ {
+ fprintf(f_cible, "<D>");
+ } else if (val == 0x76) // "<.>"
+ {
+ fprintf(f_cible, "<.>");
+ } else if (val == 0x77) // "<:>"
+ {
+ fprintf(f_cible, "<:>");
+ } else if (val == 0x79) // "</>"
+ {
+ fprintf(f_cible, "</>");
+ } else if (val == 0x7A) // "<..>"
+ {
+ fprintf(f_cible, "<..>");
+ } else if (val == 0x7B) // "<`>"
+ {
+ fprintf(f_cible, "<`>");
+ } else if (val == 0x7D) // "<+>"
+ {
+ fprintf(f_cible, "<+>");
+ } else if (val == 0x7E) // "<->"
+ {
+ fprintf(f_cible, "<->");
+ } else if (val == 0x7F) // "<X>"
+ {
+ fprintf(f_cible, "<X>");
+ } else if (val == 0x80) // "<[>"
+ {
+ fprintf(f_cible, "<[>");
+ } else if (val == 0x81) // "<]>"
+ {
+ fprintf(f_cible, "<]>");
+ } else if (val == 0x82) // "<%>"
+ {
+ fprintf(f_cible, "<%%>");
+ } else if (val == 0x83) // "<&>"
+ {
+ fprintf(f_cible, "<&>");
+ } else if (val == 0x84) // "<(>"
+ {
+ fprintf(f_cible, "<(>");
+ } else if (val == 0x85) // "<)>"
+ {
+ fprintf(f_cible, "<)>");
+ } else if (val == 0x86) // "<#>"
+ {
+ fprintf(f_cible, "<#>");
+ } else if (val == 0x87) // "`"
+ {
+ fprintf(f_cible, "`");
+ } else if (val == 0x88) // "°"
+ {
+ fprintf(f_cible, "°");
+ } else if (val == 0x89) // "<=>"
+ {
+ fprintf(f_cible, "<=>");
+ } else if (val == 0x8A) // "<?>"
+ {
+ fprintf(f_cible, "<?>");
+ } else if (val == 0x8B) // "<!>"
+ {
+ fprintf(f_cible, "<!>");
+ } else if (val == 0x8C) // "_"
+ {
+ fprintf(f_cible, "_");
+ } else if (val == 0x8D) // "~"
+ {
+ fprintf(f_cible, "~");
+ } else if (val == 0x8E) // "<...>"
+ {
+ fprintf(f_cible, "<...>");
+ } else if (val == 0x8F) // "<'>"
+ {
+ fprintf(f_cible, "<'>");
+ } else if (val == 0xFE) // "<Extra1 X>
+ {
+ fread((unsigned char *) &temp1, 1, 1, f_source);
+ fprintf(f_cible, "<Extra1 %d>", temp1);
+ } else if (val == 0xFF) // "<Extra2 X>
+ {
+ fread((unsigned char *) &temp1, 1, 1, f_source);
+ fprintf(f_cible, "<Extra2 %d>", temp1);
+ } else {
+ fprintf(f_cible, "<Bare %X>", val);
+ }
+
+ position = ftell(f_source);
+ }
+ fprintf(f_cible, "\n<End_of_block>\n\n");
+}
+
+int decrypt(FILE * f_source, FILE * f_cible, int room_number)
+{
+ long i, j;
+ long table[5000];
+ unsigned char line_table[5000];
+ unsigned char length_table[5000];
+ long script_number = 0;
+ long temp = 0;
+ char temp_char;
+ int counter = 0;
+
+ fread((long *) &script_number, 4, 1, f_source);
+
+ if (script_number == 0x0000FFFF)
+ return (1);
+
+ script_number = (script_number++);
+
+ fprintf(f_cible, "<Blocks:%li>\n", script_number);
+ init_table(table);
+
+ i = j = 0;
+
+ while (i < script_number) {
+ fread((long *) &temp, 2, 1, f_source);
+ if (table[j - 1] != temp)
+ table[j++] = temp;
+ i++;
+ }
+
+ script_number = j;
+
+ for (i = 0; i < script_number; i++) {
+ fread((unsigned char *) &length_table[i], 1, 1, f_source);
+ fread((unsigned char *) &line_table[i], 1, 1, f_source);
+ }
+
+ fseek(f_source, table[script_number - 1], SEEK_SET);
+
+ do {
+ fread((char *) &temp_char, 1, 1, f_source);
+ counter++;
+ } while (temp_char != 0);
+
+ table[script_number] = ftell(f_source);
+
+ for (i = 0; i < script_number; i++) {
+ dump_text(f_source, f_cible, table, i, script_number, length_table, line_table);
+ }
+
+ return (0);
+}
+
+int startup(void) throw (GeneralException)
+{
+ int i;
+ char file_name[100];
+ FILE *f_source, *f_cible;
+
+ for (i = 0; i < 730; i++) {
+ printf("%d\n", i);
+ sprintf(file_name, "xeno_d1/ROOMS/%04d/script.comp", i);
+ f_source = fopen(file_name, "rb");
+
+ sprintf(file_name, "xeno_d1/ROOMS/%04d/script.txt", i);
+
+ if (f_source != NULL) {
+ f_cible = fopen(file_name, "w");
+ decrypt(f_source, f_cible, 5);
+ fclose(f_source);
+ fclose(f_cible);
+ }
+ }
+ for (i = 0; i < 730; i++) {
+ printf("%d\n", i);
+ sprintf(file_name, "xeno_d2/ROOMS/%04d/script.comp", i);
+ f_source = fopen(file_name, "rb");
+
+ sprintf(file_name, "xeno_d2/ROOMS/%04d/script.txt", i);
+
+ if (f_source != NULL) {
+ f_cible = fopen(file_name, "w");
+ decrypt(f_source, f_cible, 5);
+ fclose(f_source);
+ fclose(f_cible);
+ }
+ }
+
+ return 0;
+}
+CODE_ENDS
diff --git a/Xenogears/Translate.cpp b/Xenogears/Translate.cpp index 3f85437..1edef8b 100644 --- a/Xenogears/Translate.cpp +++ b/Xenogears/Translate.cpp @@ -1,256 +1,256 @@ -#include <stdio.h> -#include <string.h> - -void dump_text(FILE * f_source, FILE * f_cible) -{ - unsigned char val; - unsigned char temp1 = 0; - unsigned char temp2 = 0; - - while (!feof(f_source)) { - val = 0; - - fread((unsigned char *) &val, 1, 1, f_source); - - if (val == 0x00) // "<Close>" - { -// break; - fprintf(f_cible, "<EOF>\n"); - } else if (val == 0x01) // "\n" - { - fprintf(f_cible, "\n"); - } else if (val == 0x02) // "<New>" - { - fprintf(f_cible, "<New>\n"); - } else if (val == 0x03) // "<Wait>" - { - fprintf(f_cible, "<Wait>"); - } else if (val == 0x0F) // "<Delay X> - { - fread((unsigned char *) &temp1, 1, 1, f_source); - fread((unsigned char *) &temp2, 1, 1, f_source); - if (temp1 == 0) { - fprintf(f_cible, "<Delay %d>", temp2); - } else if (temp1 == 5) { - fprintf(f_cible, "<Gear %d>", temp2); - } else { - fprintf(f_cible, "<Opcode %d %d>", temp1, temp2); - } - } else if (val == 0x10) // " " - { - fprintf(f_cible, " "); - } else if (val == 0x11) // "+" - { - fprintf(f_cible, "+"); - } else if (val == 0x12) // "," - { - fprintf(f_cible, ","); - } else if (val == 0x13) // "-" - { - fprintf(f_cible, "-"); - } else if (val == 0x14) // "." - { - fprintf(f_cible, "."); - } else if (val == 0x15) // "/" - { - fprintf(f_cible, "/"); - } else if ((val >= 0x16) && (val <= 0x1F)) // "0-9" - { - fprintf(f_cible, "%c", val + 0x1a); - } else if ((val >= 0x20) && (val <= 0x39)) // "A-Z" - { - fprintf(f_cible, "%c", val + 0x21); - } else if (val == 0x3A) // "[" - { - fprintf(f_cible, "["); - } else if (val == 0x3B) // "]" - { - fprintf(f_cible, "]"); - } else if (val == 0x3C) // "=" - { - fprintf(f_cible, "="); - } else if ((val >= 0x3D) && (val <= 0x56)) // "a-z" - { - fprintf(f_cible, "%c", val + 0x24); - } else if (val == 0x57) // "!" - { - fprintf(f_cible, "!"); - } else if (val == 0x58) // "\"" - { - fprintf(f_cible, "\""); - } else if (val == 0x59) // "#" - { - fprintf(f_cible, "#"); - } else if (val == 0x5A) // "%" - { - fprintf(f_cible, "%%"); - } else if (val == 0x5B) // "&" - { - fprintf(f_cible, "&"); - } else if (val == 0x5C) // "'" - { - fprintf(f_cible, "'"); - } else if (val == 0x5D) // "(" - { - fprintf(f_cible, "("); - } else if (val == 0x5E) // ")" - { - fprintf(f_cible, ")"); - } else if (val == 0x5F) // ":" - { - fprintf(f_cible, ":"); - } else if (val == 0x60) // "?" - { - fprintf(f_cible, "?"); - } else if (val == 0x61) // "<0>" - { - fprintf(f_cible, "<0>"); - } else if (val == 0x62) // "<1>" - { - fprintf(f_cible, "<1>"); - } else if (val == 0x63) // "<2>" - { - fprintf(f_cible, "<2>"); - } else if (val == 0x64) // "<3>" - { - fprintf(f_cible, "<3>"); - } else if (val == 0x65) // "<4>" - { - fprintf(f_cible, "<4>"); - } else if (val == 0x66) // "<5>" - { - fprintf(f_cible, "<5>"); - } else if (val == 0x67) // "<6>" - { - fprintf(f_cible, "<6>"); - } else if (val == 0x68) // "<7>" - { - fprintf(f_cible, "<7>"); - } else if (val == 0x69) // "<8>" - { - fprintf(f_cible, "<8>"); - } else if (val == 0x6A) // "<9>" - { - fprintf(f_cible, "<9>"); - } else if (val == 0x6B) // "<%>" - { - fprintf(f_cible, "<%%>"); - } else if (val == 0x6C) // "<&>" - { - fprintf(f_cible, "<&>"); - } else if (val == 0x6D) // "*" - { - fprintf(f_cible, "*"); - } else if (val == 0x6E) // "<C>" - { - fprintf(f_cible, "<C>"); - } else if (val == 0x6F) // "<S>" - { - fprintf(f_cible, "<S>"); - } else if (val == 0x70) // "<T>" - { - fprintf(f_cible, "<T>"); - } else if (val == 0x71) // "<*>" - { - fprintf(f_cible, "<*>"); - } else if (val == 0x72) // "<R>" - { - fprintf(f_cible, "<R>"); - } else if (val == 0x73) // "<L>" - { - fprintf(f_cible, "<L>"); - } else if (val == 0x74) // "<U>" - { - fprintf(f_cible, "<U>"); - } else if (val == 0x75) // "<U>" - { - fprintf(f_cible, "<D>"); - } else if (val == 0x76) // "<.>" - { - fprintf(f_cible, "<.>"); - } else if (val == 0x77) // "<:>" - { - fprintf(f_cible, "<:>"); - } else if (val == 0x79) // "</>" - { - fprintf(f_cible, "</>"); - } else if (val == 0x7A) // "<..>" - { - fprintf(f_cible, "<..>"); - } else if (val == 0x7B) // "<`>" - { - fprintf(f_cible, "<`>"); - } else if (val == 0x7D) // "<+>" - { - fprintf(f_cible, "<+>"); - } else if (val == 0x7E) // "<->" - { - fprintf(f_cible, "<->"); - } else if (val == 0x7F) // "<X>" - { - fprintf(f_cible, "<X>"); - } else if (val == 0x80) // "<[>" - { - fprintf(f_cible, "<[>"); - } else if (val == 0x81) // "<]>" - { - fprintf(f_cible, "<]>"); - } else if (val == 0x82) // "<%>" - { - fprintf(f_cible, "<%%>"); - } else if (val == 0x83) // "<&>" - { - fprintf(f_cible, "<&>"); - } else if (val == 0x84) // "<(>" - { - fprintf(f_cible, "<(>"); - } else if (val == 0x85) // "<)>" - { - fprintf(f_cible, "<)>"); - } else if (val == 0x86) // "<#>" - { - fprintf(f_cible, "<#>"); - } else if (val == 0x87) // "`" - { - fprintf(f_cible, "`"); - } else if (val == 0x88) // "°" - { - fprintf(f_cible, "°"); - } else if (val == 0x89) // "<=>" - { - fprintf(f_cible, "<=>"); - } else if (val == 0x8A) // "<?>" - { - fprintf(f_cible, "<?>"); - } else if (val == 0x8B) // "<!>" - { - fprintf(f_cible, "<!>"); - } else if (val == 0x8C) // "_" - { - fprintf(f_cible, "_"); - } else if (val == 0x8D) // "~" - { - fprintf(f_cible, "~"); - } else if (val == 0x8E) // "<...>" - { - fprintf(f_cible, "<...>"); - } else if (val == 0x8F) // "<'>" - { - fprintf(f_cible, "<'>"); - } else if (val == 0xFE) // "<Extra1 X> - { - fread((unsigned char *) &temp1, 1, 1, f_source); - fprintf(f_cible, "<Extra1 %d>", temp1); - } else if (val == 0xFF) // "<Extra2 X> - { - fread((unsigned char *) &temp1, 1, 1, f_source); - fprintf(f_cible, "<Extra2 %d>", temp1); - } else { - fprintf(f_cible, "<Bare %X>", val); - } - } -} - -int main(void) { - dump_text(stdin, stdout); -} +#include <stdio.h>
+#include <string.h>
+
+void dump_text(FILE * f_source, FILE * f_cible)
+{
+ unsigned char val;
+ unsigned char temp1 = 0;
+ unsigned char temp2 = 0;
+
+ while (!feof(f_source)) {
+ val = 0;
+
+ fread((unsigned char *) &val, 1, 1, f_source);
+
+ if (val == 0x00) // "<Close>"
+ {
+// break;
+ fprintf(f_cible, "<EOF>\n");
+ } else if (val == 0x01) // "\n"
+ {
+ fprintf(f_cible, "\n");
+ } else if (val == 0x02) // "<New>"
+ {
+ fprintf(f_cible, "<New>\n");
+ } else if (val == 0x03) // "<Wait>"
+ {
+ fprintf(f_cible, "<Wait>");
+ } else if (val == 0x0F) // "<Delay X>
+ {
+ fread((unsigned char *) &temp1, 1, 1, f_source);
+ fread((unsigned char *) &temp2, 1, 1, f_source);
+ if (temp1 == 0) {
+ fprintf(f_cible, "<Delay %d>", temp2);
+ } else if (temp1 == 5) {
+ fprintf(f_cible, "<Gear %d>", temp2);
+ } else {
+ fprintf(f_cible, "<Opcode %d %d>", temp1, temp2);
+ }
+ } else if (val == 0x10) // " "
+ {
+ fprintf(f_cible, " ");
+ } else if (val == 0x11) // "+"
+ {
+ fprintf(f_cible, "+");
+ } else if (val == 0x12) // ","
+ {
+ fprintf(f_cible, ",");
+ } else if (val == 0x13) // "-"
+ {
+ fprintf(f_cible, "-");
+ } else if (val == 0x14) // "."
+ {
+ fprintf(f_cible, ".");
+ } else if (val == 0x15) // "/"
+ {
+ fprintf(f_cible, "/");
+ } else if ((val >= 0x16) && (val <= 0x1F)) // "0-9"
+ {
+ fprintf(f_cible, "%c", val + 0x1a);
+ } else if ((val >= 0x20) && (val <= 0x39)) // "A-Z"
+ {
+ fprintf(f_cible, "%c", val + 0x21);
+ } else if (val == 0x3A) // "["
+ {
+ fprintf(f_cible, "[");
+ } else if (val == 0x3B) // "]"
+ {
+ fprintf(f_cible, "]");
+ } else if (val == 0x3C) // "="
+ {
+ fprintf(f_cible, "=");
+ } else if ((val >= 0x3D) && (val <= 0x56)) // "a-z"
+ {
+ fprintf(f_cible, "%c", val + 0x24);
+ } else if (val == 0x57) // "!"
+ {
+ fprintf(f_cible, "!");
+ } else if (val == 0x58) // "\""
+ {
+ fprintf(f_cible, "\"");
+ } else if (val == 0x59) // "#"
+ {
+ fprintf(f_cible, "#");
+ } else if (val == 0x5A) // "%"
+ {
+ fprintf(f_cible, "%%");
+ } else if (val == 0x5B) // "&"
+ {
+ fprintf(f_cible, "&");
+ } else if (val == 0x5C) // "'"
+ {
+ fprintf(f_cible, "'");
+ } else if (val == 0x5D) // "("
+ {
+ fprintf(f_cible, "(");
+ } else if (val == 0x5E) // ")"
+ {
+ fprintf(f_cible, ")");
+ } else if (val == 0x5F) // ":"
+ {
+ fprintf(f_cible, ":");
+ } else if (val == 0x60) // "?"
+ {
+ fprintf(f_cible, "?");
+ } else if (val == 0x61) // "<0>"
+ {
+ fprintf(f_cible, "<0>");
+ } else if (val == 0x62) // "<1>"
+ {
+ fprintf(f_cible, "<1>");
+ } else if (val == 0x63) // "<2>"
+ {
+ fprintf(f_cible, "<2>");
+ } else if (val == 0x64) // "<3>"
+ {
+ fprintf(f_cible, "<3>");
+ } else if (val == 0x65) // "<4>"
+ {
+ fprintf(f_cible, "<4>");
+ } else if (val == 0x66) // "<5>"
+ {
+ fprintf(f_cible, "<5>");
+ } else if (val == 0x67) // "<6>"
+ {
+ fprintf(f_cible, "<6>");
+ } else if (val == 0x68) // "<7>"
+ {
+ fprintf(f_cible, "<7>");
+ } else if (val == 0x69) // "<8>"
+ {
+ fprintf(f_cible, "<8>");
+ } else if (val == 0x6A) // "<9>"
+ {
+ fprintf(f_cible, "<9>");
+ } else if (val == 0x6B) // "<%>"
+ {
+ fprintf(f_cible, "<%%>");
+ } else if (val == 0x6C) // "<&>"
+ {
+ fprintf(f_cible, "<&>");
+ } else if (val == 0x6D) // "*"
+ {
+ fprintf(f_cible, "*");
+ } else if (val == 0x6E) // "<C>"
+ {
+ fprintf(f_cible, "<C>");
+ } else if (val == 0x6F) // "<S>"
+ {
+ fprintf(f_cible, "<S>");
+ } else if (val == 0x70) // "<T>"
+ {
+ fprintf(f_cible, "<T>");
+ } else if (val == 0x71) // "<*>"
+ {
+ fprintf(f_cible, "<*>");
+ } else if (val == 0x72) // "<R>"
+ {
+ fprintf(f_cible, "<R>");
+ } else if (val == 0x73) // "<L>"
+ {
+ fprintf(f_cible, "<L>");
+ } else if (val == 0x74) // "<U>"
+ {
+ fprintf(f_cible, "<U>");
+ } else if (val == 0x75) // "<U>"
+ {
+ fprintf(f_cible, "<D>");
+ } else if (val == 0x76) // "<.>"
+ {
+ fprintf(f_cible, "<.>");
+ } else if (val == 0x77) // "<:>"
+ {
+ fprintf(f_cible, "<:>");
+ } else if (val == 0x79) // "</>"
+ {
+ fprintf(f_cible, "</>");
+ } else if (val == 0x7A) // "<..>"
+ {
+ fprintf(f_cible, "<..>");
+ } else if (val == 0x7B) // "<`>"
+ {
+ fprintf(f_cible, "<`>");
+ } else if (val == 0x7D) // "<+>"
+ {
+ fprintf(f_cible, "<+>");
+ } else if (val == 0x7E) // "<->"
+ {
+ fprintf(f_cible, "<->");
+ } else if (val == 0x7F) // "<X>"
+ {
+ fprintf(f_cible, "<X>");
+ } else if (val == 0x80) // "<[>"
+ {
+ fprintf(f_cible, "<[>");
+ } else if (val == 0x81) // "<]>"
+ {
+ fprintf(f_cible, "<]>");
+ } else if (val == 0x82) // "<%>"
+ {
+ fprintf(f_cible, "<%%>");
+ } else if (val == 0x83) // "<&>"
+ {
+ fprintf(f_cible, "<&>");
+ } else if (val == 0x84) // "<(>"
+ {
+ fprintf(f_cible, "<(>");
+ } else if (val == 0x85) // "<)>"
+ {
+ fprintf(f_cible, "<)>");
+ } else if (val == 0x86) // "<#>"
+ {
+ fprintf(f_cible, "<#>");
+ } else if (val == 0x87) // "`"
+ {
+ fprintf(f_cible, "`");
+ } else if (val == 0x88) // "°"
+ {
+ fprintf(f_cible, "°");
+ } else if (val == 0x89) // "<=>"
+ {
+ fprintf(f_cible, "<=>");
+ } else if (val == 0x8A) // "<?>"
+ {
+ fprintf(f_cible, "<?>");
+ } else if (val == 0x8B) // "<!>"
+ {
+ fprintf(f_cible, "<!>");
+ } else if (val == 0x8C) // "_"
+ {
+ fprintf(f_cible, "_");
+ } else if (val == 0x8D) // "~"
+ {
+ fprintf(f_cible, "~");
+ } else if (val == 0x8E) // "<...>"
+ {
+ fprintf(f_cible, "<...>");
+ } else if (val == 0x8F) // "<'>"
+ {
+ fprintf(f_cible, "<'>");
+ } else if (val == 0xFE) // "<Extra1 X>
+ {
+ fread((unsigned char *) &temp1, 1, 1, f_source);
+ fprintf(f_cible, "<Extra1 %d>", temp1);
+ } else if (val == 0xFF) // "<Extra2 X>
+ {
+ fread((unsigned char *) &temp1, 1, 1, f_source);
+ fprintf(f_cible, "<Extra2 %d>", temp1);
+ } else {
+ fprintf(f_cible, "<Bare %X>", val);
+ }
+ }
+}
+
+int main(void) {
+ dump_text(stdin, stdout);
+}
diff --git a/Xenogears/archive.cpp b/Xenogears/archive.cpp index 6701c2c..286fa43 100644 --- a/Xenogears/archive.cpp +++ b/Xenogears/archive.cpp @@ -1,37 +1,37 @@ -#include <stdio.h> -#include <values.h> -#include <stdlib.h> -#include "fileutils.h" - -void dearchive(FILE * f) { - long nb; - long * address; - char fname[100]; - int i; - FILE * f_out; - - fread(&nb, 4, 1, f); - nb++; - fprintf(stderr, "Reading index... (%li elements)\n", nb); - - address = (long *) malloc(nb * sizeof(long) + 1); - - for (i = 0; i < nb; i++) { - fread(address + i, 4, 1, f); - } - address[nb] = MAXINT; - - for (i = 0; i < nb; i++) { - fprintf(stderr, "Dumping file %i\n", i); - sprintf(fname, "part-%i.lz", i); - f_out = fopen(fname, "wb"); - copy(fileno(f), fileno(f_out), address[i + 1] - address[i]); - fclose(f_out); - } - - free(address); -} - -int main(void) { - dearchive(stdin); -} +#include <stdio.h>
+#include <values.h>
+#include <stdlib.h>
+#include "fileutils.h"
+
+void dearchive(FILE * f) {
+ long nb;
+ long * address;
+ char fname[100];
+ int i;
+ FILE * f_out;
+
+ fread(&nb, 4, 1, f);
+ nb++;
+ fprintf(stderr, "Reading index... (%li elements)\n", nb);
+
+ address = (long *) malloc(nb * sizeof(long) + 1);
+
+ for (i = 0; i < nb; i++) {
+ fread(address + i, 4, 1, f);
+ }
+ address[nb] = MAXINT;
+
+ for (i = 0; i < nb; i++) {
+ fprintf(stderr, "Dumping file %i\n", i);
+ sprintf(fname, "part-%i.lz", i);
+ f_out = fopen(fname, "wb");
+ copy(fileno(f), fileno(f_out), address[i + 1] - address[i]);
+ fclose(f_out);
+ }
+
+ free(address);
+}
+
+int main(void) {
+ dearchive(stdin);
+}
diff --git a/Xenogears/build-sector-2.cpp b/Xenogears/build-sector-2.cpp index 6ab7835..1b1be62 100644 --- a/Xenogears/build-sector-2.cpp +++ b/Xenogears/build-sector-2.cpp @@ -1,14 +1,14 @@ -#include <stdio.h> -#include "yazedc.h" - -int main(void) { - unsigned char datas[2352]; - - fread(datas, 2352, 1, stdin); - minute = datas[12]; - second = datas[13]; - frame = datas[14]; - fprintf(stderr, "Sector info: %2i:%02i:%04i\n", minute, second, frame); - do_encode_L2(datas, MODE_2, 0); - fwrite(datas, 2352, 1, stdout); -} +#include <stdio.h>
+#include "yazedc.h"
+
+int main(void) {
+ unsigned char datas[2352];
+
+ fread(datas, 2352, 1, stdin);
+ minute = datas[12];
+ second = datas[13];
+ frame = datas[14];
+ fprintf(stderr, "Sector info: %2i:%02i:%04i\n", minute, second, frame);
+ do_encode_L2(datas, MODE_2, 0);
+ fwrite(datas, 2352, 1, stdout);
+}
diff --git a/Xenogears/build-sector.cpp b/Xenogears/build-sector.cpp index 3effc35..744a087 100644 --- a/Xenogears/build-sector.cpp +++ b/Xenogears/build-sector.cpp @@ -1,14 +1,14 @@ -#include <stdio.h> -#include "yazedc.h" - -int main(void) { - unsigned char datas[2352]; - - fread(datas, 2352, 1, stdin); - minute = datas[12]; - second = datas[13]; - frame = datas[14]; - fprintf(stderr, "Sector info: %2i:%02i:%04i\n", minute, second, frame); - do_encode_L2(datas, MODE_2_FORM_1, 0); - fwrite(datas, 2352, 1, stdout); -} +#include <stdio.h>
+#include "yazedc.h"
+
+int main(void) {
+ unsigned char datas[2352];
+
+ fread(datas, 2352, 1, stdin);
+ minute = datas[12];
+ second = datas[13];
+ frame = datas[14];
+ fprintf(stderr, "Sector info: %2i:%02i:%04i\n", minute, second, frame);
+ do_encode_L2(datas, MODE_2_FORM_1, 0);
+ fwrite(datas, 2352, 1, stdout);
+}
diff --git a/Xenogears/main_dump.cpp b/Xenogears/main_dump.cpp index 1610ec1..e2f5058 100644 --- a/Xenogears/main_dump.cpp +++ b/Xenogears/main_dump.cpp @@ -1,283 +1,283 @@ -/* - * Xenogears extractor by Nicolas "Pixel" Noble (nicolas@nobis-crew.org) - * Highly based upon Yazoo's Chrono Cross CD extractor - * - * ******** Original disclaimer by Yazoo ******** - * - * Chrono Cross CD extractor Copyright 2000-2001 by Yazoo (hamm@efrei.fr) Revision 0.1b ANSI C - * - * - * Features: - * - * Dump the complete content of Chrono Chross CD1/CD2 US and Japanese version It requires a iso - * named Chrono1.iso in the same directory - * - * Todo list: - * - * Find a way to locate end of the last file Better support for CD2 Dump in subdirectory according - * to CD1/CD2 repartition Recompilation in Visual C++ 6 for disk speed optimisation Source comment - * and reorganisation Log feature (Optional since you can redirect output with > ) Progression - * indicator Better detection of the ISO with error control Major code optimisation Integration in - * main Chrono Cross Hacking tool - * - * ******** End of original disclaimer by Yazoo ******** - * - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include "cdutils.h" -#include "generic.h" -#include "Input.h" -#include "Output.h" -#include "Main.h" -#include "cdabstract.h" - -CODE_BEGINS -public: -Appli() : tourne(0), nb_seqs(0), f_def(0), f_iso(0), cdutil(0) {} -virtual ~Appli() { - delete cdutil; - delete f_def; - delete f_iso; - delete f_out; -} -private: - -unsigned int tourne; - -struct t_index_tab { - unsigned long address; - long size; - long type; - long index; -}; - -struct t_sequence { - unsigned int n; - unsigned int sum; - String prefix; - String name; - int type; -}; - -String title, iso_filename, prefix; -unsigned long iso_size; -unsigned int nb_records, nb_seqs; -struct t_sequence sequences[100]; -Handle * f_def, * f_iso, * f_out; - -cdutils * cdutil; - -Byte user_data[2352]; - -virtual int startup() throw (GeneralException) -{ - - verbosity = 3; - - printm(M_BARE, -"Xenogears File Extractor by Nicolas \"Pixel\" Noble\n" -"Highly based upon the Chrono Cross File Extractor By Yazoo\n\n"); - - if (argc != 3) { - printm(M_BARE, "Usage: %s <definition_file.sqr> <iso_file_name>\nSee readme.txt for details\n", - argv[0]); - exit(-1); - } - - printm(M_STATUS, "Processing file %s...\n", argv[1]); - - f_def = new Input(argv[1]); - - if (process_def_file()) { - printm(M_ERROR, "Unable to process the definition file \"%s\"...\n", argv[1]); - exit(-1); - } - - iso_filename = argv[2]; - - printm(M_STATUS, "Begin processing iso file.\n"); - f_iso = cdabstract::open_cd(iso_filename); - - if (check_iso()) { - printm(M_ERROR, "Invalid iso file for " + title + "\n"); - printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n"); - } else { - printm(M_INFO, "Genuine " + title + " iso detected.\n"); - } - - cdutil = new cdutils(f_iso); - - printm(M_STATUS, "Entering files read sequence\n"); - read_files(); - return 0; -} - -/* - * Ugly but working... for now - */ -int process_def_file() -{ - String t; - unsigned int n, sum = 0; - - *f_def >> t; - printm(M_INFO, "Read title: " + t + "\n"); - title = t; - - *f_def >> t; - iso_size = t.to_int(); - printm(M_INFO, "Read iso size: %lu bytes\n", iso_size); - - *f_def >> t; - printm(M_INFO, "Read global directory prefix: " + t + "\n"); - prefix = t; - - *f_def >> t; - nb_records = t.to_int(); - printm(M_INFO, "Read total of records: %u\n", nb_records); - - while (1) { - *f_def >> t; - n = t.to_int(); - if (!n) { - if (sum == nb_records) { - printm(M_INFO, "Definition file seems coherent\n"); - return 0; - } else { - printm(M_ERROR, "Definition file incoherent\n"); - return 1; - } - } - sum += n; - sequences[nb_seqs].n = n; - sequences[nb_seqs].sum = sum; - *f_def >> t; - sequences[nb_seqs].prefix = t; - *f_def >> t; - n = t.to_int(); - sequences[nb_seqs].type = n; - *f_def >> t; - sequences[nb_seqs].name = t; - printm(M_INFO, "Read definition of sequence %i:\n===> %5i (sum = %5i) chunks of " + t + - " (" + sequences[nb_seqs].prefix + ")\n", nb_seqs, n, sum); - nb_seqs++; - } -} - -long check_iso() -{ - unsigned long length; - - length = f_iso->GetSize(); - if (length < 0) { - printm(M_INFO, "Can not get file size, assuming reading from CD.\n"); - } else { - printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length); - if (length != iso_size) { - return 1; - } - } - return 0; -} - -void read_files() -{ - t_index_tab index_tab[10000]; - unsigned char t[8]; - unsigned long i; - unsigned long j; - unsigned int seq = 0; - unsigned long indexer; - struct t_index_tab *p = (struct t_index_tab *) t; - - Byte fat[32768]; - -#define INDEXPOS 24 - - cdutil->sector_seek(INDEXPOS); - for (i = INDEXPOS; i < (INDEXPOS + 16); i++) { - printm(M_INFO, "Reading fat sector %lu\n", i); - cdutil->read_sector(&fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); - } - - indexer = 0; - for (j = 0; j < 32768; j = j + 7) { - t[0] = 0; - bcopy((char *) &fat[j], (char *) t + 1, 7); - p->address >>= 8; - index_tab[indexer] = *p; - if (p->size > 0 && p->address != 0) { - index_tab[indexer].index = j / 7; - printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu, size %3li\n", - indexer, index_tab[indexer].address, index_tab[indexer].size); - indexer++; - if (indexer == nb_records) - break; - } else { - printm(M_WARNING, "Ignored invalid index chunk number %4lu (size = %lu) (%02x %02x %02x %02x %02x %02x %02x)\n", - j / 7, -index_tab[indexer].size, t[0], t[1], t[2], t[4], t[5], t[6], t[7]); - } - } - printm(M_STATUS, "Index file generation complete.\n\n"); - - for (i = 0; i < nb_records; i++) { - if (sequences[seq].sum == i) - seq++; - index_tab[i].type = sequences[seq].type; - if (sequences[seq].type == 0) { - printm(M_INFO, "%6lu (%10lu): ignored\n", index_tab[i].address, index_tab[i].size); - } else { - printm(M_INFO, "%6lu (%10lu): ", index_tab[i].address, index_tab[i].size); - file_dump(index_tab[i].address, index_tab[i].size, i, seq); - if (verbosity >= M_INFO) { - fprintf(stderr, "\n"); - } - } - } - fprintf(stderr, "\n"); -} - -void file_dump(unsigned long debut, unsigned long taille, long num, int seq) -{ - long i; - long nbsects; - String nom; - String extension = ".out"; - String nom_t; - char type = sequences[seq].type; - char ptitbidule[] = "-\\|/"; - - nom_t.set("%04ld", num); - - nom = "./" + prefix + "/"; - - MKDIR(nom.to_charp()); - - nom += sequences[seq].prefix + "/"; - MKDIR(nom.to_charp()); - - nom += nom_t + extension;; - - f_out = new Output(nom); - nbsects = taille / sec_sizes[type]; - if (taille % sec_sizes[type]) - nbsects++; - cdutil->sector_seek(debut); - for (i = 0; i < nbsects; i++) { - if (verbosity < M_INFO) - fprintf(stderr, " (%c)\010\010\010\010\010", ptitbidule[((tourne++) >> 8) % 4]); - cdutil->read_sector(user_data, type); - if (i != (nbsects - 1)) { - f_out->write(user_data, sec_sizes[type]); - } else { - f_out->write(user_data, taille % sec_sizes[type] ? taille % sec_sizes[type] : sec_sizes[type]); - } - } - delete f_out; - f_out = 0; - printm(M_BARE, " (*) Dumped file number %4ld - type \"" + sequences[seq].name + "\" \r", num); -} -CODE_ENDS +/*
+ * Xenogears extractor by Nicolas "Pixel" Noble (nicolas@nobis-crew.org)
+ * Highly based upon Yazoo's Chrono Cross CD extractor
+ *
+ * ******** Original disclaimer by Yazoo ********
+ *
+ * Chrono Cross CD extractor Copyright 2000-2001 by Yazoo (hamm@efrei.fr) Revision 0.1b ANSI C
+ *
+ *
+ * Features:
+ *
+ * Dump the complete content of Chrono Chross CD1/CD2 US and Japanese version It requires a iso
+ * named Chrono1.iso in the same directory
+ *
+ * Todo list:
+ *
+ * Find a way to locate end of the last file Better support for CD2 Dump in subdirectory according
+ * to CD1/CD2 repartition Recompilation in Visual C++ 6 for disk speed optimisation Source comment
+ * and reorganisation Log feature (Optional since you can redirect output with > ) Progression
+ * indicator Better detection of the ISO with error control Major code optimisation Integration in
+ * main Chrono Cross Hacking tool
+ *
+ * ******** End of original disclaimer by Yazoo ********
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "cdutils.h"
+#include "generic.h"
+#include "Input.h"
+#include "Output.h"
+#include "Main.h"
+#include "cdabstract.h"
+
+CODE_BEGINS
+public:
+Appli() : tourne(0), nb_seqs(0), f_def(0), f_iso(0), cdutil(0) {}
+virtual ~Appli() {
+ delete cdutil;
+ delete f_def;
+ delete f_iso;
+ delete f_out;
+}
+private:
+
+unsigned int tourne;
+
+struct t_index_tab {
+ unsigned long address;
+ long size;
+ long type;
+ long index;
+};
+
+struct t_sequence {
+ unsigned int n;
+ unsigned int sum;
+ String prefix;
+ String name;
+ int type;
+};
+
+String title, iso_filename, prefix;
+unsigned long iso_size;
+unsigned int nb_records, nb_seqs;
+struct t_sequence sequences[100];
+Handle * f_def, * f_iso, * f_out;
+
+cdutils * cdutil;
+
+Byte user_data[2352];
+
+virtual int startup() throw (GeneralException)
+{
+
+ verbosity = 3;
+
+ printm(M_BARE,
+"Xenogears File Extractor by Nicolas \"Pixel\" Noble\n"
+"Highly based upon the Chrono Cross File Extractor By Yazoo\n\n");
+
+ if (argc != 3) {
+ printm(M_BARE, "Usage: %s <definition_file.sqr> <iso_file_name>\nSee readme.txt for details\n",
+ argv[0]);
+ exit(-1);
+ }
+
+ printm(M_STATUS, "Processing file %s...\n", argv[1]);
+
+ f_def = new Input(argv[1]);
+
+ if (process_def_file()) {
+ printm(M_ERROR, "Unable to process the definition file \"%s\"...\n", argv[1]);
+ exit(-1);
+ }
+
+ iso_filename = argv[2];
+
+ printm(M_STATUS, "Begin processing iso file.\n");
+ f_iso = cdabstract::open_cd(iso_filename);
+
+ if (check_iso()) {
+ printm(M_ERROR, "Invalid iso file for " + title + "\n");
+ printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n");
+ } else {
+ printm(M_INFO, "Genuine " + title + " iso detected.\n");
+ }
+
+ cdutil = new cdutils(f_iso);
+
+ printm(M_STATUS, "Entering files read sequence\n");
+ read_files();
+ return 0;
+}
+
+/*
+ * Ugly but working... for now
+ */
+int process_def_file()
+{
+ String t;
+ unsigned int n, sum = 0;
+
+ *f_def >> t;
+ printm(M_INFO, "Read title: " + t + "\n");
+ title = t;
+
+ *f_def >> t;
+ iso_size = t.to_int();
+ printm(M_INFO, "Read iso size: %lu bytes\n", iso_size);
+
+ *f_def >> t;
+ printm(M_INFO, "Read global directory prefix: " + t + "\n");
+ prefix = t;
+
+ *f_def >> t;
+ nb_records = t.to_int();
+ printm(M_INFO, "Read total of records: %u\n", nb_records);
+
+ while (1) {
+ *f_def >> t;
+ n = t.to_int();
+ if (!n) {
+ if (sum == nb_records) {
+ printm(M_INFO, "Definition file seems coherent\n");
+ return 0;
+ } else {
+ printm(M_ERROR, "Definition file incoherent\n");
+ return 1;
+ }
+ }
+ sum += n;
+ sequences[nb_seqs].n = n;
+ sequences[nb_seqs].sum = sum;
+ *f_def >> t;
+ sequences[nb_seqs].prefix = t;
+ *f_def >> t;
+ n = t.to_int();
+ sequences[nb_seqs].type = n;
+ *f_def >> t;
+ sequences[nb_seqs].name = t;
+ printm(M_INFO, "Read definition of sequence %i:\n===> %5i (sum = %5i) chunks of " + t +
+ " (" + sequences[nb_seqs].prefix + ")\n", nb_seqs, n, sum);
+ nb_seqs++;
+ }
+}
+
+long check_iso()
+{
+ unsigned long length;
+
+ length = f_iso->GetSize();
+ if (length < 0) {
+ printm(M_INFO, "Can not get file size, assuming reading from CD.\n");
+ } else {
+ printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length);
+ if (length != iso_size) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+void read_files()
+{
+ t_index_tab index_tab[10000];
+ unsigned char t[8];
+ unsigned long i;
+ unsigned long j;
+ unsigned int seq = 0;
+ unsigned long indexer;
+ struct t_index_tab *p = (struct t_index_tab *) t;
+
+ Byte fat[32768];
+
+#define INDEXPOS 24
+
+ cdutil->sector_seek(INDEXPOS);
+ for (i = INDEXPOS; i < (INDEXPOS + 16); i++) {
+ printm(M_INFO, "Reading fat sector %lu\n", i);
+ cdutil->read_sector(&fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1);
+ }
+
+ indexer = 0;
+ for (j = 0; j < 32768; j = j + 7) {
+ t[0] = 0;
+ bcopy((char *) &fat[j], (char *) t + 1, 7);
+ p->address >>= 8;
+ index_tab[indexer] = *p;
+ if (p->size > 0 && p->address != 0) {
+ index_tab[indexer].index = j / 7;
+ printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu, size %3li\n",
+ indexer, index_tab[indexer].address, index_tab[indexer].size);
+ indexer++;
+ if (indexer == nb_records)
+ break;
+ } else {
+ printm(M_WARNING, "Ignored invalid index chunk number %4lu (size = %lu) (%02x %02x %02x %02x %02x %02x %02x)\n",
+ j / 7, -index_tab[indexer].size, t[0], t[1], t[2], t[4], t[5], t[6], t[7]);
+ }
+ }
+ printm(M_STATUS, "Index file generation complete.\n\n");
+
+ for (i = 0; i < nb_records; i++) {
+ if (sequences[seq].sum == i)
+ seq++;
+ index_tab[i].type = sequences[seq].type;
+ if (sequences[seq].type == 0) {
+ printm(M_INFO, "%6lu (%10lu): ignored\n", index_tab[i].address, index_tab[i].size);
+ } else {
+ printm(M_INFO, "%6lu (%10lu): ", index_tab[i].address, index_tab[i].size);
+ file_dump(index_tab[i].address, index_tab[i].size, i, seq);
+ if (verbosity >= M_INFO) {
+ fprintf(stderr, "\n");
+ }
+ }
+ }
+ fprintf(stderr, "\n");
+}
+
+void file_dump(unsigned long debut, unsigned long taille, long num, int seq)
+{
+ long i;
+ long nbsects;
+ String nom;
+ String extension = ".out";
+ String nom_t;
+ char type = sequences[seq].type;
+ char ptitbidule[] = "-\\|/";
+
+ nom_t.set("%04ld", num);
+
+ nom = "./" + prefix + "/";
+
+ MKDIR(nom.to_charp());
+
+ nom += sequences[seq].prefix + "/";
+ MKDIR(nom.to_charp());
+
+ nom += nom_t + extension;;
+
+ f_out = new Output(nom);
+ nbsects = taille / sec_sizes[type];
+ if (taille % sec_sizes[type])
+ nbsects++;
+ cdutil->sector_seek(debut);
+ for (i = 0; i < nbsects; i++) {
+ if (verbosity < M_INFO)
+ fprintf(stderr, " (%c)\010\010\010\010\010", ptitbidule[((tourne++) >> 8) % 4]);
+ cdutil->read_sector(user_data, type);
+ if (i != (nbsects - 1)) {
+ f_out->write(user_data, sec_sizes[type]);
+ } else {
+ f_out->write(user_data, taille % sec_sizes[type] ? taille % sec_sizes[type] : sec_sizes[type]);
+ }
+ }
+ delete f_out;
+ f_out = 0;
+ printm(M_BARE, " (*) Dumped file number %4ld - type \"" + sequences[seq].name + "\" \r", num);
+}
+CODE_ENDS
diff --git a/Xenogears/reinsert.cpp b/Xenogears/reinsert.cpp index bf60cb4..fb7460e 100644 --- a/Xenogears/reinsert.cpp +++ b/Xenogears/reinsert.cpp @@ -1,290 +1,290 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include "cdutils.h" -#include "generic.h" -#include "Input.h" -#include "Output.h" -#include "Main.h" - -CODE_BEGINS -public: -Appli() : tourne(0), nb_seqs(0), f_def(0), f_iso_r(0), f_iso_w(0), f_in(0), cdutil(0), slus_index(-1), force(0) {} -virtual ~Appli() { - delete cdutil; - delete f_def; - delete f_iso_r; - delete f_iso_w; - delete f_in; -} -private: - -unsigned int tourne; - -struct t_index_tab { - unsigned long address; - long size; - long type; - long index; -}; - -struct t_sequence { - unsigned int n; - unsigned int sum; - String prefix; - String name; - int type; -}; - -String title, iso_filename, prefix, in_filename; -unsigned long iso_size; -unsigned int nb_records, nb_seqs; -struct t_sequence sequences[1000]; -Handle * f_def, * f_iso_r, * f_iso_w, * f_in; -cdutils * cdutil; - -int slus_index, force; - -unsigned char user_data[2352]; - -void usage() throw (GeneralException) { - printm(M_BARE, "Usage: %s <definition_file.sqr> <iso_file_name> <file_index> <filename> [-f]\nSee readme.txt for details\n", - argv[0]); - throw Exit(-1); -} - -virtual int startup() throw (GeneralException) -{ - int fileindex; - - verbosity = 1; - - printm(M_BARE, "Xenogears File Insertor by Nicolas \"Pixel\" Noble\n\n"); - - if ((argc != 5) && (argc != 6)) { - usage(); - } - - if (argc == 6) { - if (strcmp(argv[5], "-f")) { - usage(); - } else { - force = 1; - } - } - - printm(M_STATUS, "Processing file %s...\n", argv[1]); - - f_def = new Input(argv[1]); - - if (process_def_file(f_def)) { - printm(M_ERROR, "Unable to process the definition file \"%s\"...\n", argv[1]); - throw Exit(-1); - } - - iso_filename = argv[2]; - - printm(M_STATUS, "Begin processing iso file.\n"); - f_iso_r = new Input(iso_filename); - f_iso_w = new Output(iso_filename, 0, 0); - f_iso_w->seek(0, SEEK_SET); - - cdutil = new cdutils(f_iso_r, f_iso_w); - - if (check_iso()) { - printm(M_ERROR, "Invalid iso file for " + title + "\n"); - printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n"); - throw Exit(-1); - } else { - printm(M_INFO, "Genuine " + title + " iso detected.\n"); - } - - fileindex = atoi(argv[3]); - in_filename = argv[4]; - f_in = new Input(in_filename); - - printm(M_STATUS, "Entering files write sequence\n"); - write_files(fileindex); - return 0; -} - -/* - * Ugly but working... for now - */ -int process_def_file(Handle * f_def) -{ - unsigned int n, sum = 0; - String t; - - *f_def >> t; - printm(M_INFO, "Read title: " + t + "\n"); - title = t; - - *f_def >> t; - iso_size = t.to_int(); - printm(M_INFO, "Read iso size: %lu bytes\n", iso_size); - - *f_def >> t; - printm(M_INFO, "Read global directory prefix: " + t + "\n"); - prefix = t; - - *f_def >> t; - nb_records = t.to_int(); - printm(M_INFO, "Read total of records: %u\n", nb_records); - - while (1) { - *f_def >> t; - n = t.to_int(); - if (!n) { - if (sum == nb_records) { - printm(M_INFO, "Definition file seems coherent\n"); - return 0; - } else { - printm(M_ERROR, "Definition file incoherent\n"); - return 1; - } - } - sum += n; - sequences[nb_seqs].n = n; - sequences[nb_seqs].sum = sum; - *f_def >> t; - sequences[nb_seqs].prefix = t; - *f_def >> t; - n = t.to_int(); - sequences[nb_seqs].type = n; - *f_def >> t; - sequences[nb_seqs].name = t; - printm(M_INFO, "Read definition of sequence %i:\n===> %5i (sum = %5i) chunks of " + t + - " (" + sequences[nb_seqs].prefix + ")\n", nb_seqs, n, sum); - nb_seqs++; - } -} - -long check_iso() -{ - unsigned long length; - - length = f_iso_r->GetSize(); - printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length); - if (length != iso_size) { - return 1; - } - return 0; -} - -#define INDEXPOS 24 - -void rewrite_fat(Byte * new_fat) { - unsigned char old_fat[34816]; - int i; - - cdutil->sector_seek(INDEXPOS); - for (i = INDEXPOS; i < (INDEXPOS + 16); i++) { - printm(M_INFO, "Writing fat sector %lu\n", i); - cdutil->write_sector(&new_fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); - } - - cdutil->sector_seek(slus_index + 1); - for (i = slus_index + 1; i < (slus_index + 18); i++) { - printm(M_INFO, "Reading SLUS sector %lu\n", i); - cdutil->read_sector(&old_fat[2048 * (i - slus_index - 1)], MODE_2_FORM_1); - } - - bcopy((char *) new_fat, (char *) old_fat + 4, 32768); - cdutil->sector_seek(slus_index + 1); - for (i = slus_index + 1; i < (slus_index + 18); i++) { - printm(M_INFO, "Writing SLUS sector %lu\n", i); - cdutil->write_sector(&old_fat[2048 * (i - slus_index - 1)], MODE_2_FORM_1); - } -} - -void write_files(int fileindex) throw (GeneralException) -{ - t_index_tab index_tab[10000]; - unsigned char t[8]; - unsigned long i; - unsigned long j; - unsigned int seq = 0; - unsigned long indexer; - struct t_index_tab *p = (struct t_index_tab *) t; - - long old_file_size, new_file_size, old_nb_sects, new_nb_sects; - unsigned char fat[32768]; - - cdutil->sector_seek(INDEXPOS); - for (i = INDEXPOS; i < (INDEXPOS + 16); i++) { - printm(M_INFO, "Reading fat sector %lu\n", i); - cdutil->read_sector(&fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); - } - - indexer = 0; - for (j = 0; j < 32768; j = j + 7) { - t[0] = 0; - bcopy((char *) &fat[j], (char *) t + 1, 7); - p->address >>= 8; - index_tab[indexer] = *p; - if (p->size > 0 && p->address != 0) { - index_tab[indexer].index = j / 7; - printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu, size %3li\n", - indexer, index_tab[indexer].address, index_tab[indexer].size); - indexer++; - if (indexer == nb_records) - break; - } else { - printm(M_WARNING, "Ignored invalid index chunk number %4lu (size = %lu) (%02x %02x %02x %02x %02x %02x %02x)\n", - j / 7, -index_tab[indexer].size, t[0], t[1], t[2], t[4], t[5], t[6], t[7]); - } - } - printm(M_STATUS, "Index file generation complete.\n\n"); - - for (i = 0; i < nb_records; i++) { - if (sequences[seq].sum == i) - seq++; - index_tab[i].type = sequences[seq].type; - if (sequences[seq].prefix == "SLUS") { - if (slus_index >= 0) { - printm(M_ERROR, "Two SLUS files defined\n"); - throw Exit(-1); - } - slus_index = index_tab[i].address; - } - } - - if (slus_index < 0) { - printm(M_ERROR, "No SLUS file defined\n"); - throw Exit(-1); - } - - printm(M_INFO, "SLUS file found at sector %6i\n", slus_index); - - new_file_size = f_in->GetSize(); - old_file_size = index_tab[fileindex].size; - - new_nb_sects = new_file_size / sec_sizes[index_tab[fileindex].type]; - old_nb_sects = old_file_size / sec_sizes[index_tab[fileindex].type]; - - if (new_file_size % sec_sizes[index_tab[fileindex].type]) { - new_nb_sects++; - } - - if (old_file_size % sec_sizes[index_tab[fileindex].type]) { - old_nb_sects++; - } - - if (new_nb_sects > old_nb_sects) { - printm(M_ERROR, "New file too big.\n"); - if (!force) { - throw Exit(-1); - } - } - - printm(M_INFO, "New file size: %12li, old file size: %12li\n", new_file_size, old_file_size); - printm(M_INFO, "New file ssize: %12li, old file ssize: %12li\n", new_nb_sects, old_nb_sects); - - printm(M_INFO, "File address: %6i\n", index_tab[fileindex].address); - - cdutil->write_file(f_in, index_tab[fileindex].type, index_tab[fileindex].address); - *((long *)(&fat[index_tab[fileindex].index * 7 + 3])) = new_file_size; - rewrite_fat(fat); -} -CODE_ENDS +#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "cdutils.h"
+#include "generic.h"
+#include "Input.h"
+#include "Output.h"
+#include "Main.h"
+
+CODE_BEGINS
+public:
+Appli() : tourne(0), nb_seqs(0), f_def(0), f_iso_r(0), f_iso_w(0), f_in(0), cdutil(0), slus_index(-1), force(0) {}
+virtual ~Appli() {
+ delete cdutil;
+ delete f_def;
+ delete f_iso_r;
+ delete f_iso_w;
+ delete f_in;
+}
+private:
+
+unsigned int tourne;
+
+struct t_index_tab {
+ unsigned long address;
+ long size;
+ long type;
+ long index;
+};
+
+struct t_sequence {
+ unsigned int n;
+ unsigned int sum;
+ String prefix;
+ String name;
+ int type;
+};
+
+String title, iso_filename, prefix, in_filename;
+unsigned long iso_size;
+unsigned int nb_records, nb_seqs;
+struct t_sequence sequences[1000];
+Handle * f_def, * f_iso_r, * f_iso_w, * f_in;
+cdutils * cdutil;
+
+int slus_index, force;
+
+unsigned char user_data[2352];
+
+void usage() throw (GeneralException) {
+ printm(M_BARE, "Usage: %s <definition_file.sqr> <iso_file_name> <file_index> <filename> [-f]\nSee readme.txt for details\n",
+ argv[0]);
+ throw Exit(-1);
+}
+
+virtual int startup() throw (GeneralException)
+{
+ int fileindex;
+
+ verbosity = 1;
+
+ printm(M_BARE, "Xenogears File Insertor by Nicolas \"Pixel\" Noble\n\n");
+
+ if ((argc != 5) && (argc != 6)) {
+ usage();
+ }
+
+ if (argc == 6) {
+ if (strcmp(argv[5], "-f")) {
+ usage();
+ } else {
+ force = 1;
+ }
+ }
+
+ printm(M_STATUS, "Processing file %s...\n", argv[1]);
+
+ f_def = new Input(argv[1]);
+
+ if (process_def_file(f_def)) {
+ printm(M_ERROR, "Unable to process the definition file \"%s\"...\n", argv[1]);
+ throw Exit(-1);
+ }
+
+ iso_filename = argv[2];
+
+ printm(M_STATUS, "Begin processing iso file.\n");
+ f_iso_r = new Input(iso_filename);
+ f_iso_w = new Output(iso_filename, 0, 0);
+ f_iso_w->seek(0, SEEK_SET);
+
+ cdutil = new cdutils(f_iso_r, f_iso_w);
+
+ if (check_iso()) {
+ printm(M_ERROR, "Invalid iso file for " + title + "\n");
+ printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n");
+ throw Exit(-1);
+ } else {
+ printm(M_INFO, "Genuine " + title + " iso detected.\n");
+ }
+
+ fileindex = atoi(argv[3]);
+ in_filename = argv[4];
+ f_in = new Input(in_filename);
+
+ printm(M_STATUS, "Entering files write sequence\n");
+ write_files(fileindex);
+ return 0;
+}
+
+/*
+ * Ugly but working... for now
+ */
+int process_def_file(Handle * f_def)
+{
+ unsigned int n, sum = 0;
+ String t;
+
+ *f_def >> t;
+ printm(M_INFO, "Read title: " + t + "\n");
+ title = t;
+
+ *f_def >> t;
+ iso_size = t.to_int();
+ printm(M_INFO, "Read iso size: %lu bytes\n", iso_size);
+
+ *f_def >> t;
+ printm(M_INFO, "Read global directory prefix: " + t + "\n");
+ prefix = t;
+
+ *f_def >> t;
+ nb_records = t.to_int();
+ printm(M_INFO, "Read total of records: %u\n", nb_records);
+
+ while (1) {
+ *f_def >> t;
+ n = t.to_int();
+ if (!n) {
+ if (sum == nb_records) {
+ printm(M_INFO, "Definition file seems coherent\n");
+ return 0;
+ } else {
+ printm(M_ERROR, "Definition file incoherent\n");
+ return 1;
+ }
+ }
+ sum += n;
+ sequences[nb_seqs].n = n;
+ sequences[nb_seqs].sum = sum;
+ *f_def >> t;
+ sequences[nb_seqs].prefix = t;
+ *f_def >> t;
+ n = t.to_int();
+ sequences[nb_seqs].type = n;
+ *f_def >> t;
+ sequences[nb_seqs].name = t;
+ printm(M_INFO, "Read definition of sequence %i:\n===> %5i (sum = %5i) chunks of " + t +
+ " (" + sequences[nb_seqs].prefix + ")\n", nb_seqs, n, sum);
+ nb_seqs++;
+ }
+}
+
+long check_iso()
+{
+ unsigned long length;
+
+ length = f_iso_r->GetSize();
+ printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length);
+ if (length != iso_size) {
+ return 1;
+ }
+ return 0;
+}
+
+#define INDEXPOS 24
+
+void rewrite_fat(Byte * new_fat) {
+ unsigned char old_fat[34816];
+ int i;
+
+ cdutil->sector_seek(INDEXPOS);
+ for (i = INDEXPOS; i < (INDEXPOS + 16); i++) {
+ printm(M_INFO, "Writing fat sector %lu\n", i);
+ cdutil->write_sector(&new_fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1);
+ }
+
+ cdutil->sector_seek(slus_index + 1);
+ for (i = slus_index + 1; i < (slus_index + 18); i++) {
+ printm(M_INFO, "Reading SLUS sector %lu\n", i);
+ cdutil->read_sector(&old_fat[2048 * (i - slus_index - 1)], MODE_2_FORM_1);
+ }
+
+ bcopy((char *) new_fat, (char *) old_fat + 4, 32768);
+ cdutil->sector_seek(slus_index + 1);
+ for (i = slus_index + 1; i < (slus_index + 18); i++) {
+ printm(M_INFO, "Writing SLUS sector %lu\n", i);
+ cdutil->write_sector(&old_fat[2048 * (i - slus_index - 1)], MODE_2_FORM_1);
+ }
+}
+
+void write_files(int fileindex) throw (GeneralException)
+{
+ t_index_tab index_tab[10000];
+ unsigned char t[8];
+ unsigned long i;
+ unsigned long j;
+ unsigned int seq = 0;
+ unsigned long indexer;
+ struct t_index_tab *p = (struct t_index_tab *) t;
+
+ long old_file_size, new_file_size, old_nb_sects, new_nb_sects;
+ unsigned char fat[32768];
+
+ cdutil->sector_seek(INDEXPOS);
+ for (i = INDEXPOS; i < (INDEXPOS + 16); i++) {
+ printm(M_INFO, "Reading fat sector %lu\n", i);
+ cdutil->read_sector(&fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1);
+ }
+
+ indexer = 0;
+ for (j = 0; j < 32768; j = j + 7) {
+ t[0] = 0;
+ bcopy((char *) &fat[j], (char *) t + 1, 7);
+ p->address >>= 8;
+ index_tab[indexer] = *p;
+ if (p->size > 0 && p->address != 0) {
+ index_tab[indexer].index = j / 7;
+ printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu, size %3li\n",
+ indexer, index_tab[indexer].address, index_tab[indexer].size);
+ indexer++;
+ if (indexer == nb_records)
+ break;
+ } else {
+ printm(M_WARNING, "Ignored invalid index chunk number %4lu (size = %lu) (%02x %02x %02x %02x %02x %02x %02x)\n",
+ j / 7, -index_tab[indexer].size, t[0], t[1], t[2], t[4], t[5], t[6], t[7]);
+ }
+ }
+ printm(M_STATUS, "Index file generation complete.\n\n");
+
+ for (i = 0; i < nb_records; i++) {
+ if (sequences[seq].sum == i)
+ seq++;
+ index_tab[i].type = sequences[seq].type;
+ if (sequences[seq].prefix == "SLUS") {
+ if (slus_index >= 0) {
+ printm(M_ERROR, "Two SLUS files defined\n");
+ throw Exit(-1);
+ }
+ slus_index = index_tab[i].address;
+ }
+ }
+
+ if (slus_index < 0) {
+ printm(M_ERROR, "No SLUS file defined\n");
+ throw Exit(-1);
+ }
+
+ printm(M_INFO, "SLUS file found at sector %6i\n", slus_index);
+
+ new_file_size = f_in->GetSize();
+ old_file_size = index_tab[fileindex].size;
+
+ new_nb_sects = new_file_size / sec_sizes[index_tab[fileindex].type];
+ old_nb_sects = old_file_size / sec_sizes[index_tab[fileindex].type];
+
+ if (new_file_size % sec_sizes[index_tab[fileindex].type]) {
+ new_nb_sects++;
+ }
+
+ if (old_file_size % sec_sizes[index_tab[fileindex].type]) {
+ old_nb_sects++;
+ }
+
+ if (new_nb_sects > old_nb_sects) {
+ printm(M_ERROR, "New file too big.\n");
+ if (!force) {
+ throw Exit(-1);
+ }
+ }
+
+ printm(M_INFO, "New file size: %12li, old file size: %12li\n", new_file_size, old_file_size);
+ printm(M_INFO, "New file ssize: %12li, old file ssize: %12li\n", new_nb_sects, old_nb_sects);
+
+ printm(M_INFO, "File address: %6i\n", index_tab[fileindex].address);
+
+ cdutil->write_file(f_in, index_tab[fileindex].type, index_tab[fileindex].address);
+ *((long *)(&fat[index_tab[fileindex].index * 7 + 3])) = new_file_size;
+ rewrite_fat(fat);
+}
+CODE_ENDS
diff --git a/Xenogears/script-comp.cpp b/Xenogears/script-comp.cpp index 964b350..01f6bdd 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); - +#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(); - +
+ 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->seek(0x14c);
d->write(&script_position, 4);
+ d->seek(0x128);
+ d->write(&true_length, 4);
+ d->seek(0, SEEK_END);
- 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; - + 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 + 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
diff --git a/Xenogears/script-dec.cpp b/Xenogears/script-dec.cpp index 55edb31..0285013 100644 --- a/Xenogears/script-dec.cpp +++ b/Xenogears/script-dec.cpp @@ -1,82 +1,82 @@ -#include <stdio.h> -#include <stdlib.h> -#include "lzss.h" -#include "BString.h" -#include "Input.h" -#include "Output.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, int d, int n) { - String nom_du_fichier; - long script_position, true_length; - int i; - Handle * f_out; - - if (f->GetSize() == 24) return; - - nom_du_fichier.set("xeno_d%d/ROOMS/%04i", d, n); - MKDIR(nom_du_fichier.to_charp()); - - i = 7; -// for (i = 0; i < 9; i++) { -// printm(M_BARE, " Processing part %i\n", i); - nom_du_fichier.set("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 = new Output(nom_du_fichier); - f->seek(0x130 + i * 4); - f->read(&script_position, 4); - f->seek(0x10c + i * 4); - f->read(&true_length, 4); - f->seek(script_position); - lzss_o->lzss_decomp(f, f_out, true_length); -// if (i == 7) { -// fseek(f_out, 0, SEEK_SET); -// fread(&true_length, 4, 1, f_out); -// printm(M_BARE, " (seems to be the script number %i)\n", true_length); -// } - delete f_out; -// } -} - -virtual int startup() throw (GeneralException) -{ - Handle * f_script_comp; - int i; - int num = 0; - char nom_du_fichier[100]; - - for (i = 384; i < 1844; i = i + 2) { - printm(M_BARE, "CD 1 - File %d -> Script %d\n", i, num); - sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out", i); - f_script_comp = new Input(nom_du_fichier); - - process_one_file(f_script_comp, 1, num); - - delete f_script_comp; - num++; - } - - num = 0; - - for (i = 379; i < 1838; i = i + 2) { - printm(M_BARE, "CD 2 - File %d -> Script %d\n", i, num); - sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out", i); - f_script_comp = new Input(nom_du_fichier); - - process_one_file(f_script_comp, 2, num); - - delete f_script_comp; - num++; - } - printm(M_BARE, "Done !\n"); - return 0; -} -CODE_ENDS +#include <stdio.h>
+#include <stdlib.h>
+#include "lzss.h"
+#include "BString.h"
+#include "Input.h"
+#include "Output.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, int d, int n) {
+ String nom_du_fichier;
+ long script_position, true_length;
+ int i;
+ Handle * f_out;
+
+ if (f->GetSize() == 24) return;
+
+ nom_du_fichier.set("xeno_d%d/ROOMS/%04i", d, n);
+ MKDIR(nom_du_fichier.to_charp());
+
+ i = 7;
+// for (i = 0; i < 9; i++) {
+// printm(M_BARE, " Processing part %i\n", i);
+ nom_du_fichier.set("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 = new Output(nom_du_fichier);
+ f->seek(0x130 + i * 4);
+ f->read(&script_position, 4);
+ f->seek(0x10c + i * 4);
+ f->read(&true_length, 4);
+ f->seek(script_position);
+ lzss_o->lzss_decomp(f, f_out, true_length);
+// if (i == 7) {
+// fseek(f_out, 0, SEEK_SET);
+// fread(&true_length, 4, 1, f_out);
+// printm(M_BARE, " (seems to be the script number %i)\n", true_length);
+// }
+ delete f_out;
+// }
+}
+
+virtual int startup() throw (GeneralException)
+{
+ Handle * f_script_comp;
+ int i;
+ int num = 0;
+ char nom_du_fichier[100];
+
+ for (i = 384; i < 1844; i = i + 2) {
+ printm(M_BARE, "CD 1 - File %d -> Script %d\n", i, num);
+ sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out", i);
+ f_script_comp = new Input(nom_du_fichier);
+
+ process_one_file(f_script_comp, 1, num);
+
+ delete f_script_comp;
+ num++;
+ }
+
+ num = 0;
+
+ for (i = 379; i < 1838; i = i + 2) {
+ printm(M_BARE, "CD 2 - File %d -> Script %d\n", i, num);
+ sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out", i);
+ f_script_comp = new Input(nom_du_fichier);
+
+ process_one_file(f_script_comp, 2, num);
+
+ delete f_script_comp;
+ num++;
+ }
+ printm(M_BARE, "Done !\n");
+ return 0;
+}
+CODE_ENDS
diff --git a/Xenogears/test-dlzss.cpp b/Xenogears/test-dlzss.cpp index ecd0f7e..4591b9d 100644 --- a/Xenogears/test-dlzss.cpp +++ b/Xenogears/test-dlzss.cpp @@ -1,7 +1,7 @@ -#include <stdio.h> -#include "lzss.h" - -int main(void) { - lzss_decomp(0, 1); - return 0; -} +#include <stdio.h>
+#include "lzss.h"
+
+int main(void) {
+ lzss_decomp(0, 1);
+ return 0;
+}
diff --git a/Xenogears/test-lzss.cpp b/Xenogears/test-lzss.cpp index 0257e99..b92808c 100644 --- a/Xenogears/test-lzss.cpp +++ b/Xenogears/test-lzss.cpp @@ -1,7 +1,7 @@ -#include <stdio.h> -#include "lzss.h" - -int main(void) { - lzss_comp(0, 1); - return 0; -} +#include <stdio.h>
+#include "lzss.h"
+
+int main(void) {
+ lzss_comp(0, 1);
+ return 0;
+}
|