Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/tools/libmio0.h
7854 views
1
#ifndef LIBMIO0_H_
2
#define LIBMIO0_H_
3
4
// defines
5
6
#define MIO0_HEADER_LENGTH 16
7
8
// typedefs
9
10
typedef struct
11
{
12
unsigned int dest_size;
13
unsigned int comp_offset;
14
unsigned int uncomp_offset;
15
} mio0_header_t;
16
17
// function prototypes
18
19
// decode MIO0 header
20
// returns 1 if valid header, 0 otherwise
21
int mio0_decode_header(const unsigned char *buf, mio0_header_t *head);
22
23
// encode MIO0 header from struct
24
void mio0_encode_header(unsigned char *buf, const mio0_header_t *head);
25
26
// decode MIO0 data in memory
27
// in: buffer containing MIO0 data
28
// out: buffer for output data
29
// end: output offset of the last byte decoded from in (set to NULL if unwanted)
30
// returns bytes extracted to 'out' or negative value on failure
31
int mio0_decode(const unsigned char *in, unsigned char *out, unsigned int *end);
32
33
// encode MIO0 data in memory
34
// in: buffer containing raw data
35
// out: buffer for MIO0 data
36
// returns size of compressed data in 'out' including MIO0 header
37
int mio0_encode(const unsigned char *in, unsigned int length, unsigned char *out);
38
39
// decode an entire MIO0 block at an offset from file to output file
40
// in_file: input filename
41
// offset: offset to start decoding from in_file
42
// out_file: output filename
43
int mio0_decode_file(const char *in_file, unsigned long offset, const char *out_file);
44
45
// encode an entire file
46
// in_file: input filename containing raw data to be encoded
47
// out_file: output filename to write MIO0 compressed data to
48
int mio0_encode_file(const char *in_file, const char *out_file);
49
50
#endif // LIBMIO0_H_
51
52