]> cvs.zerfleddert.de Git - rsbs2/blobdiff - rsb-lz.c
update .gitignore (forgot it after last renaming...)
[rsbs2] / rsb-lz.c
index 7b94aef32eee61587a2866bc23a211a7c8b8d4cc..93e9d79f2acfd41001d31febb9b4412f97b55ed6 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -98,45 +98,39 @@ void write_byte(unsigned char byte, struct data_out_s *data_out)
        data_out->pos++;
 }
 
-void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out)
+void lz_expand(struct data_in_s *data_in, struct data_out_s *data_out)
 {
-       unsigned int r5;
-       unsigned int r2;
-       unsigned char r4;
-       unsigned int r6;
-       unsigned int r7;
-       unsigned int r11;
-       unsigned char window[1024];
+       unsigned int pos;
+       unsigned int offset;
+       unsigned int i;
+       unsigned char byte;
+       unsigned int num;
+       unsigned char buf[1024];
 
-       r5 = 1;
+       pos = 1;
 
        while (1) {
                while (1) {
-                       r2 = get_next_bit(r10_data);
-                       if (r2 == 0)
+                       if (get_next_bit(data_in) == 0)
                                break;
 
-                       r2 = get_next_bits(r10_data, 8) & 0xff;
+                       byte = get_next_bits(data_in, 8);
 
-                       write_byte(r2, data_out);
-                       window[r5] = r2 & 0xff;
-                       r5 = (r5 + 1) & 0x3ff;
+                       write_byte(byte, data_out);
+                       buf[pos] = byte;
+                       pos = (pos + 1) & 0x3ff;
                }
 
-               r11 = get_next_bits(r10_data, 0x0a);
-               if(r11 == 0)
+               offset = get_next_bits(data_in, 0x0a);
+               if(offset == 0)
                        return;
 
-               r2 = get_next_bits(r10_data, 0x04);
-               r7 = r2 + 1;
-               r6 = 0;
-               while (r6 <= r7) {
-                       r2 = (r6 + r11) & 0x3ff;
-                       r4 = window[r2];
-                       write_byte(r4, data_out);
-                       window[r5] = r4;
-                       r5 = (r5 + 1) & 0x3ff;
-                       r6++;
+               num = get_next_bits(data_in, 0x04) + 1;
+               for (i = 0; i <= num; i++) {
+                       byte = buf[(offset + i) & 0x3ff];
+                       write_byte(byte, data_out);
+                       buf[pos] = byte;
+                       pos = (pos + 1) & 0x3ff;
                }
        }
 }
Impressum, Datenschutz