Merge pull request #438 from s4Ys369/revert-434-patch-1
[sm64pc.git] / tools / libmio0.h
blob5b38ac77178c70451565c0ead1866ea2d64d21ef
1 #ifndef LIBMIO0_H_
2 #define LIBMIO0_H_
4 // defines
6 #define MIO0_HEADER_LENGTH 16
8 // typedefs
10 typedef struct
12 unsigned int dest_size;
13 unsigned int comp_offset;
14 unsigned int uncomp_offset;
15 } mio0_header_t;
17 // function prototypes
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);
23 // encode MIO0 header from struct
24 void mio0_encode_header(unsigned char *buf, const mio0_header_t *head);
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);
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);
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);
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);
50 #endif // LIBMIO0_H_