-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathth07.cpp
More file actions
36 lines (33 loc) · 926 Bytes
/
th07.cpp
File metadata and controls
36 lines (33 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* th07.cpp
*
* Created on: 2010-5-9
* Author: Argon
*/
#include "common.h"
void th07decode(char *file, unsigned char * buffer, unsigned int flength) {
char frec[50];
char fraw[50];
unsigned char *rawdata = &buffer[0x54], *decodedata;
unsigned int i, length, dlength, rlength, checksum;
unsigned char base;
base = *((unsigned char*) (&buffer[0x0d]));
sprintf(frec, "%s.txt", file);
sprintf(fraw, "%s.raw", file);
for (i = 0x10; i < flength; ++i) {
buffer[i] -= base;
base += 7;
}
checksum = 0x3f000318;
for (i = 0x0d; i < flength; ++i)
checksum += buffer[i];
length = *((unsigned int*) (&buffer[0x14]));
dlength = *((unsigned int*) (&buffer[0x18]));
decodedata = new unsigned char[dlength];
rlength = decompress(rawdata, decodedata, length);
FILE *fpraw = fopen(fraw, "wb");
fwrite(decodedata, rlength, 1, fpraw);
fclose(fpraw);
printf("Decompression done.");
delete[] decodedata;
}