]> git.zerfleddert.de Git - rsbs2/commitdiff
more lz cleanups...
authorMichael Gernoth <michael@gernoth.net>
Mon, 2 Feb 2009 22:17:13 +0000 (23:17 +0100)
committerMichael Gernoth <michael@gernoth.net>
Mon, 2 Feb 2009 22:17:13 +0000 (23:17 +0100)
rsb-lz.c

index 7d20942c5af1ed230af33010b15fa66f65ab889a..644e8bb0e98976998edf1cada054297e678721ad 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -39,15 +39,15 @@ unsigned char get_next_in_byte(struct data_in_s *data_in)
        return byte;
 }
 
-unsigned int fn_59848(struct data_in_s *data_in)
+unsigned char fn_59848(struct data_in_s *data_in)
 {
-       unsigned int r5;
+       unsigned char r5;
 
        if (data_in->bit == 0x80) {
                data_in->x = get_next_in_byte(data_in);
        }
 
-       r5 = data_in->bit & data_in->x & 0xff;
+       r5 = data_in->bit & data_in->x;
 
        data_in->bit >>= 1;
        if (data_in->bit == 0) {
@@ -62,35 +62,24 @@ unsigned int fn_59848(struct data_in_s *data_in)
 
 unsigned int fn_598b4(struct data_in_s *r11_data, unsigned int r10_arg2)
 {
-       unsigned int r1;
-       unsigned int r2;
        unsigned int r6;
        unsigned int r7;
 
-       r1 = r10_arg2 - 1;
-       r6 = 1 << r1;
+       r6 = 1 << (r10_arg2 - 1);
 
        r7 = 0;
        while (r6 != 0) {
-               r1 = r11_data->bit;
-               if (r1 == 0x80) {
-                       r1 = get_next_in_byte(r11_data);
-                       r11_data->x = r1;
+               if (r11_data->bit == 0x80) {
+                       r11_data->x = get_next_in_byte(r11_data);
                }
-               r1 = r11_data->bit;
-               r2 = r11_data->x;
-               r1 = r1 & r2;
-               if (r1 != 0)
+               if ((r11_data->bit & r11_data->x) != 0)
                        r7 = r7 | r6;
 
                r6 = r6 >> 1;
 
-               r2 = r11_data->bit;
-               r2 = r2 >> 1;
-               r11_data->bit = r2;
+               r11_data->bit >>= 1;
 
-               r1 = r11_data->bit;
-               if(r1 == 0) {
+               if(r11_data->bit == 0) {
                        r11_data->bit = 0x80;
                }
        }
@@ -98,23 +87,14 @@ unsigned int fn_598b4(struct data_in_s *r11_data, unsigned int r10_arg2)
        return r7;
 }
 
-void fn_5980c(unsigned int arg1, struct data_out_s *data_out)
+void write_byte(unsigned char byte, struct data_out_s *data_out)
 {
-       unsigned char *r1;
-       unsigned char *r2;
-
-       r1 = data_out->pos;
-       r2 = data_out->end;
-
-       if (r1 > r2) {
-               printf("r1: 0x%08x, r2: 0x%08x\n", (unsigned int)r1, (unsigned int)r2);
+       if (data_out->pos > data_out->end) {
                err_exit(__func__);
        }
 
-       *r1 = arg1 & 0xff;
-
-       r1++;
-       data_out->pos = r1;
+       *(data_out->pos) = byte;
+       data_out->pos++;
 }
 
 void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out)
@@ -137,7 +117,7 @@ void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out)
 
                        r2 = fn_598b4(r10_data, 8) & 0xff;
 
-                       fn_5980c(r2, data_out);
+                       write_byte(r2, data_out);
                        arr_59b64[r5] = r2 & 0xff;
                        r5 = (r5 + 1) & 0x3ff;
                }
@@ -152,7 +132,7 @@ void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out)
                while (r6 <= r7) {
                        r2 = (r6 + r11) & 0x3ff;
                        r4 = arr_59b64[r2];
-                       fn_5980c(r4, data_out);
+                       write_byte(r4, data_out);
                        arr_59b64[r5] = r4;
                        r5 = (r5 + 1) & 0x3ff;
                        r6++;
Impressum, Datenschutz