From: Michael Gernoth Date: Mon, 2 Feb 2009 22:07:42 +0000 (+0100) Subject: cleanup more parts to get rid of all those assembler remains X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/6b2c0993a746ebda6ae633e75a8a82533c50b506 cleanup more parts to get rid of all those assembler remains --- diff --git a/rsb-lz.c b/rsb-lz.c index b45f0f8..7d20942 100644 --- a/rsb-lz.c +++ b/rsb-lz.c @@ -26,48 +26,32 @@ struct data_out_s { unsigned char *end; }; -unsigned char fn_597c8(struct data_in_s *r6_data) +unsigned char get_next_in_byte(struct data_in_s *data_in) { - unsigned char *r0; - unsigned char *r1; - unsigned char r5; - - r5 = 0; + unsigned char byte; - r0 = r6_data->start; - r1 = r6_data->stop; - - if (r1 < r0) + if (data_in->stop < data_in->start) err_exit(__func__); - r5 = *r0; - r0++; - r6_data->start = r0; + byte = *(data_in->start); + data_in->start++; - return r5; + return byte; } -unsigned int fn_59848(struct data_in_s *r6_data) +unsigned int fn_59848(struct data_in_s *data_in) { - unsigned char r1; - unsigned char r2; unsigned int r5; - r1 = r6_data->bit; - if (r1 == 0x80) { - r6_data->x = fn_597c8(r6_data); + if (data_in->bit == 0x80) { + data_in->x = get_next_in_byte(data_in); } - r1 = r6_data->bit; - r2 = r6_data->x; - r1 = r1 & r2; - r5 = r1 & 0xff; - - r1 = r6_data->bit; - r1 = r1 >> 1; - r6_data->bit = r1; - if (r1 == 0) { - r1 = 0x80; - r6_data->bit = r1; + + r5 = data_in->bit & data_in->x & 0xff; + + data_in->bit >>= 1; + if (data_in->bit == 0) { + data_in->bit = 0x80; } if (r5 == 0) @@ -90,7 +74,7 @@ unsigned int fn_598b4(struct data_in_s *r11_data, unsigned int r10_arg2) while (r6 != 0) { r1 = r11_data->bit; if (r1 == 0x80) { - r1 = fn_597c8(r11_data); + r1 = get_next_in_byte(r11_data); r11_data->x = r1; } r1 = r11_data->bit; @@ -141,7 +125,7 @@ void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out) unsigned int r6; unsigned int r7; unsigned int r11; - unsigned char arr_59b64[2048]; + unsigned char arr_59b64[1024]; r5 = 1; @@ -152,14 +136,10 @@ void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out) break; r2 = fn_598b4(r10_data, 8) & 0xff; - r4 = r2; - fn_5980c(r4, data_out); - arr_59b64[r5] = r4 & 0xff; - r2 = r5 + 1; - r2 = r2 << 22; - r2 = r2 >> 22; - r5 = r2; + fn_5980c(r2, data_out); + arr_59b64[r5] = r2 & 0xff; + r5 = (r5 + 1) & 0x3ff; } r11 = fn_598b4(r10_data, 0x0a); @@ -170,21 +150,18 @@ void lz_expand(struct data_in_s *r10_data, struct data_out_s *data_out) r7 = r2 + 1; r6 = 0; while (r6 <= r7) { - r2 = r6 + r11; - r2 = r2 << 22; - r2 = r2 >> 22; + r2 = (r6 + r11) & 0x3ff; r4 = arr_59b64[r2]; fn_5980c(r4, data_out); arr_59b64[r5] = r4; - r2 = r5 + 1; - r2 = r2 << 22; - r2 = r2 >> 22; - r5 = r2; + r5 = (r5 + 1) & 0x3ff; r6++; } } } +/* Checksum is only used for the compressed firmware in 'firmware' */ +#if 0 unsigned int crc_check_59684(unsigned char *arg1, unsigned int arg2, unsigned int magic) { unsigned int r3; @@ -218,6 +195,7 @@ unsigned int crc_check_59684(unsigned char *arg1, unsigned int arg2, unsigned in return 4; } +#endif void extract_lz_file(unsigned char *inbuf, unsigned char *name) { @@ -250,7 +228,7 @@ void extract_lz_file(unsigned char *inbuf, unsigned char *name) lz_expand(&data_in, &data_out); #if 0 - /* This seems to still be completely broken */ + /* Checksum is only used for the compressed firmware in 'firmware' */ r3 = r7 + 0x20; r5 = *((unsigned int*)r3);