]>
cvs.zerfleddert.de Git - rsbs2/blob - rsb-lz.c
9 #include "filesystem.h"
11 void err_exit(const char *fname
)
13 fprintf(stderr
,"%s: error extracting...\n", fname
);
18 unsigned char *start
; /* 0 */
19 unsigned char *stop
; /* 4 */
20 unsigned char bit
; /* 8 */
21 unsigned char x
; /* 9 */
29 unsigned char fn_597c8(struct data_in_s
*r6_data
)
50 unsigned int fn_59848(struct data_in_s
*r6_data
)
58 r6_data
->x
= fn_597c8(r6_data
);
79 unsigned int fn_598b4(struct data_in_s
*r11_data
, unsigned int r10_arg2
)
93 r1
= fn_597c8(r11_data
);
110 r11_data
->bit
= 0x80;
117 void fn_5980c(unsigned int arg1
, struct data_out_s
*data_out
)
126 printf("r1: 0x%08x, r2: 0x%08x\n", (unsigned int)r1
, (unsigned int)r2
);
136 void lz_expand(struct data_in_s
*r10_data
, struct data_out_s
*data_out
)
144 unsigned char arr_59b64
[2048];
150 r2
= fn_59848(r10_data
);
154 r2
= fn_598b4(r10_data
, 8) & 0xff;
157 fn_5980c(r4
, data_out
);
158 arr_59b64
[r5
] = r4
& 0xff;
165 r11
= fn_598b4(r10_data
, 0x0a);
169 r2
= fn_598b4(r10_data
, 0x04);
177 fn_5980c(r4
, data_out
);
188 unsigned int crc_check_59684(unsigned char *arg1
, unsigned int arg2
, unsigned int magic
)
200 r4
= *((unsigned int*)arg1
+ 0x20);
201 r5
= *((unsigned int*)arg1
+ 0x24);
203 printf("magic: 0x%08x <-> 0x%08x\n", r5
, magic
);
212 r5
= ~rsb_crc(~0x00, arg1
, r4
);
213 r3
= *((unsigned int*)(arg1
+ r4
));
214 printf("Checksums: 0x%02x <-> 0x%02x\n", r5
, r3
);
222 void extract_lz_file(unsigned char *inbuf
, unsigned char *name
)
225 unsigned char *outbuf
;
226 struct data_in_s data_in
;
227 struct data_out_s data_out
;
229 if (*((unsigned int*)inbuf
) != LZ_MAGIC
)
232 len
= *((unsigned int*)(inbuf
+ 4));
233 printf(", length: %d", len
);
235 if ((outbuf
= malloc(len
)) == NULL
) {
242 data_in
.start
= inbuf
+ 8;
243 data_in
.stop
= inbuf
+ len
;
247 data_out
.pos
= outbuf
;
248 data_out
.end
= outbuf
+ len
;
250 lz_expand(&data_in
, &data_out
);
253 /* This seems to still be completely broken */
255 r5
= *((unsigned int*)r3
);
257 if ((ret
= crc_check_59684(r7
, r5
, 0x46335053)) != 0) {
258 printf("crc_check return: %d\n", ret
);
263 write_file((char*)name
, outbuf
, len
);