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)
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;
unsigned int r6;
unsigned int r7;
unsigned int r11;
- unsigned char arr_59b64[2048];
+ unsigned char arr_59b64[1024];
r5 = 1;
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);
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;
return 4;
}
+#endif
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);