From 987168daa51df301644643d61bafa716bc80113f Mon Sep 17 00:00:00 2001
From: pixel <pixel>
Date: Fri, 31 Jan 2003 16:53:44 +0000
Subject: ToD crap...

---
 Xenogears/mac2unix | 6 ++++++
 lib/lzss.cpp       | 7 ++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100644 Xenogears/mac2unix

diff --git a/Xenogears/mac2unix b/Xenogears/mac2unix
new file mode 100644
index 0000000..a09f655
--- /dev/null
+++ b/Xenogears/mac2unix
@@ -0,0 +1,6 @@
+tr '\0210' �
+tr '\0220' �
+tr '\0216' �
+tr '\0141' �
+tr '\0217' �
+tr '\0235' �
diff --git a/lib/lzss.cpp b/lib/lzss.cpp
index cc80778..36ec41d 100644
--- a/lib/lzss.cpp
+++ b/lib/lzss.cpp
@@ -52,7 +52,7 @@ const lzss::scheme_t lzss::schemes[] = {
     {"FF6 PSX",      0, 0, 0, 1, 1, 1, 0, 0,    0, 0x1f,  1, 0x00,  0, 0xe0, -4, 0xff,  4, 0x00,  0, 0x00,  0, 0x00,  0, 0x00,  0},
     {"Valkyrie-1",   0, 0, 0, 1, 1, 0, 0, 0,    0, 0x00,  0, 0xf0, -4, 0xff,  0, 0x0f,  8, 0x00,  0, 0x00,  0, 0x00,  0, 0x00,  0},
     {"Valkyrie-2",   0, 0, 0, 1, 1, 0, 0, 2,    0, 0x00,  0, 0xf0, -4, 0xff,  0, 0x0f,  8, 0x00,  0, 0x0f,  0, 0xff,  0, 0x00,  0},
-    {"ToD",          0, 0, 0, 0, 0, 0, 0, 0,    0, 0x00,  0, 0x0f,  0, 0xff,  0, 0xf0,  4, 0x00,  0, 0x00,  0, 0x00,  0, 0x00,  0},
+    {"ToD",          0, 0, 0,-1, 1, 0, 1, 0,    3, 0x00,  0, 0x0f,  0, 0xff,  0, 0xf0,  4, 0x00,  0, 0x00,  0, 0x00,  0, 0x00,  0},
     {0            ,  0, 0, 0, 0, 0, 0, 0, 0,    0,    0,  0,    0,  0,    0,  0,    0,  0, 0x00,  0, 0x00,  0, 0x00,  0, 0x00,  0}
 };
 
@@ -109,7 +109,7 @@ unsigned long lzss::lzss_decomp(Handle * f_source, Handle * f_cible, long true_l
     unsigned char valeur;
     unsigned char * text_buf;
     unsigned char val1, val2, val3;
-    int negative_error = scheme.negative_trick, overlap_error = scheme.overlap_trick;
+    int negative_error = scheme.negative_trick, overlap_error = scheme.overlap_trick == 1;
     int r = 0;
     int decomp_count;
     int decomp_length;
@@ -198,12 +198,13 @@ unsigned long lzss::lzss_decomp(Handle * f_source, Handle * f_cible, long true_l
 			decomp_offset = r - decomp_jump;
 			break;
 		    case 1:
-			decomp_offset = r - lzss_maxptr - 1 + decomp_jump;
+			decomp_offset = r - lzss_maxptr - 1 + decomp_jump - scheme.window_start;
 			break;
 		    case 2:
 			decomp_offset = decomp_jump - scheme.window_start;
 			break;
 		    }
+		    decomp_offset += scheme.overlap_trick == -1 ? decomp_length : 0;
 		    loop_length = decomp_offset + decomp_length;
 		    if ((loop_length >= r) && (!overlap_error)) {
 			if (!tolerate) {
-- 
cgit v1.2.3