Update README.md
[sm64pc.git] / tools / libsm64.h
blob9209970ccfcbd5cb265078f577f5c158629d278b
1 #ifndef LIBSM64_H_
2 #define LIBSM64_H_
4 #define MIO0_DIR "mio0files"
6 // typedefs
7 typedef enum
9 ROM_INVALID, // not valid SM64 ROM
10 ROM_SM64_BS, // SM64 byte-swapped (BADC)
11 ROM_SM64_BE, // SM64 big-endian (ABCD)
12 ROM_SM64_LE, // SM64 little-endian
13 ROM_SM64_BE_EXT, // SM64 big-endian, extended
14 } rom_type;
16 typedef enum
18 VERSION_UNKNOWN,
19 VERSION_SM64_U,
20 VERSION_SM64_E,
21 VERSION_SM64_J,
22 VERSION_SM64_SHINDOU,
23 } rom_version;
25 typedef struct
27 char *in_filename;
28 char *ext_filename;
29 unsigned int ext_size;
30 unsigned int padding;
31 unsigned int alignment;
32 char fill;
33 char dump;
34 } sm64_config;
36 // determine ROM type based on data
37 // buf: buffer containing raw SM64 ROM file data
38 // length: length of 'buf'
39 // returns SM64 ROM type or invalid
40 rom_type sm64_rom_type(unsigned char *buf, unsigned int length);
42 // determine SM64 ROM type based on cksum data
43 // buf: buffer containing raw SM64 ROM file data
44 // returns SM64 ROM version or unknown
45 rom_version sm64_rom_version(unsigned char *buf);
47 // find and decompress all MIO0 blocks
48 // config: configuration to determine alignment, padding and size
49 // in_buf: buffer containing entire contents of SM64 data in big endian
50 // length: length of in_buf
51 // out_buf: buffer containing extended SM64
52 void sm64_decompress_mio0(const sm64_config *config,
53 unsigned char *in_buf,
54 unsigned int in_length,
55 unsigned char *out_buf);
57 // update N64 header checksums
58 // buf: buffer containing ROM data
59 // checksums are written into the buffer
60 void sm64_update_checksums(unsigned char *buf);
62 #endif // LIBSM64_H_