]> git.zerfleddert.de Git - rsbs2/commitdiff
don't implement checksum algorithm twice
authorMichael Gernoth <michael@gernoth.net>
Fri, 30 Jan 2009 20:38:12 +0000 (21:38 +0100)
committerMichael Gernoth <michael@gernoth.net>
Fri, 30 Jan 2009 20:38:12 +0000 (21:38 +0100)
rsb-crc.c

index 00b341f85c48de4add23b2c3b7b7ef0348d9cd88..719d682d33534f69e13ba0d841cc770dbab58951 100644 (file)
--- a/rsb-crc.c
+++ b/rsb-crc.c
@@ -117,17 +117,9 @@ unsigned int rsb_crc(unsigned int r11_crc, unsigned char *r10_buf, unsigned int
 
 unsigned int rsb_crc2(unsigned char *r0_buf, unsigned int r1_buflen, unsigned int r2_magic, unsigned int *crc_out) {
        int r8_ret = 1;
-       unsigned int r3_pos = 0xc0000000;
        unsigned int r4_len;
        unsigned int r5_crc;
-       unsigned int r6;
-       unsigned int r9;
-       unsigned int carry;
-
-#if 0
-       if (r0_buf <= r3_pos)
-               return 1; /* Not in RAM */
-#endif
+       unsigned int file_crc;
 
        r4_len = *(unsigned int*)(r0_buf + 0x20);
 
@@ -139,36 +131,12 @@ unsigned int rsb_crc2(unsigned char *r0_buf, unsigned int r1_buflen, unsigned in
        
        r8_ret = 4;
 
-       r3_pos = (unsigned int)r0_buf;
-       r4_len += r3_pos;
-       
-       r5_crc = ~0x0;
-
-       while (r3_pos < r4_len) {
-               r9 = r3_pos & (~0x3);
-               r6 = *((unsigned int*)r9);
-               r9 = r3_pos & 0x3;
-               r9 = r9 << 0x3;
-               r6 = r6 >> r9;
-               r5_crc = r5_crc ^ (r6 << 24);
-               r6 = 0x8;
-
-               do {
-                       carry = r5_crc & 0x80000000;
-                       r5_crc = r5_crc << 1;
-                       if (carry)
-                               r5_crc = r5_crc ^ POLY;
-                       r6--;
-               } while(r6);
-               r3_pos++;
-       }
-
-       r5_crc = ~r5_crc;
+       r5_crc = ~rsb_crc(~0x0, r0_buf, r4_len);
        *crc_out = r5_crc;
 
-       r3_pos = *((unsigned int*)r4_len);
+       file_crc = *((unsigned int*)(r0_buf + r4_len));
 
-       if (r3_pos == r5_crc)
+       if (file_crc == r5_crc)
                r8_ret = 0;
 
        return r8_ret;
Impressum, Datenschutz