From bfa5de7eccf4604ff8217f619e9685a09e80d545 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 27 Sep 2002 12:17:57 +0000 Subject: The week-without-the-network changes --- lib/lzss.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'lib/lzss.cpp') diff --git a/lib/lzss.cpp b/lib/lzss.cpp index b57f325..a991f07 100644 --- a/lib/lzss.cpp +++ b/lib/lzss.cpp @@ -26,12 +26,11 @@ #include "lzss.h" #include "Handle.h" -int lzss_maxsize = 18; -int lzss_maxptr = 0x0fff; -int tolerate = 1; -int blockb = 0; +lzss::lzss() : tolerate(1), blockb(0), scheme(schemes[0]), lzss_maxsize(18), lzss_maxptr(0x0fff) { + compute_limits(); +} -scheme_t schemes[] = { +const lzss::scheme_t lzss::schemes[] = { /* Nom 1 I J O N 16 P F W Lm1 Ls1 Lm2 Ls2 Jm1 Js1 Jm2 Js2 Fm1 Fs1 Fm2 Fs2 Vm1 Vs1 Vm2 Vs2 */ {"Xenogears", 1, 0, 0, 1, 0, 0, 0, 0, 0, 0x00, 0, 0xf0, -4, 0xff, 0, 0x0f, 8, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0}, {"DBZ RPG", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0f, 0, 0x00, 0, 0xf0, -4, 0xff, 4, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0}, @@ -46,20 +45,18 @@ scheme_t schemes[] = { {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} }; -scheme_t scheme = schemes[0]; - -char swap_bits(char i) { +Byte lzss::swap_bits(Byte i) { i = ((i >> 1) & 0x55) | ((i << 1) & 0xaa); i = ((i >> 2) & 0x33) | ((i << 2) & 0xcc); i = ((i >> 4) & 0x0f) | ((i << 4) & 0xf0); return i; } -unsigned int shift(unsigned int c, int s) { +unsigned int lzss::shift(unsigned int c, int s) { return s > 0 ? (c << s) : c >> (-s); } -void compute_limits(void) { +void lzss::compute_limits(void) { unsigned char val1, val2; val1 = val2 = 0xff; @@ -95,7 +92,7 @@ void compute_limits(void) { printm(M_INFO, "Computed values: maxsize = %i, maxptr = 0x%06x\n", lzss_maxsize, lzss_maxptr); } -unsigned long lzss_decomp(Handle * f_source, Handle * f_cible, long true_length) +unsigned long lzss::lzss_decomp(Handle * f_source, Handle * f_cible, long true_length) { unsigned char bitmap, fbitmap; unsigned char valeur; @@ -242,11 +239,11 @@ unsigned long lzss_decomp(Handle * f_source, Handle * f_cible, long true_length) return length; } -unsigned char lzss_rd(unsigned char * t, long p) { +unsigned char lzss::lzss_rd(unsigned char * t, long p) { return ((p < 0) ? 0 : (t[p])); } -long lzss_comp_strstr(unsigned char * needle, unsigned char * r, long * l, long sp) { +long lzss::lzss_comp_strstr(unsigned char * needle, unsigned char * r, long * l, long sp) { char redo[256]; long length, i, p, ptr, maxlength; @@ -291,9 +288,7 @@ long lzss_comp_strstr(unsigned char * needle, unsigned char * r, long * l, long return ptr; } -long blk, bitmap_count; - -unsigned char * lzss_memcomp(unsigned char * r, long * l, long * delta) { +unsigned char * lzss::lzss_memcomp(unsigned char * r, long * l, long * delta) { unsigned char bitmap, * comp; long ptr, needle, needle_length, comp_ptr, bitmap_ptr, val1, val2; long jump, farest, remaining; @@ -418,7 +413,7 @@ unsigned char * lzss_memcomp(unsigned char * r, long * l, long * delta) { return comp; } -void lzss_comp(Handle * f_source, Handle * f_cible, long * delta) { +void lzss::lzss_comp(Handle * f_source, Handle * f_cible, long * delta) { long length = f_source->GetSize(), l; unsigned char * r = (unsigned char *) malloc(length), * c; @@ -436,3 +431,12 @@ void lzss_comp(Handle * f_source, Handle * f_cible, long * delta) { free(c); free(r); } + +void lzss::change_scheme(scheme_t new_scheme) { + scheme = new_scheme; + compute_limits(); +} + +lzss::scheme_t lzss::get_scheme() { + return scheme; +} -- cgit v1.2.3