update structure (not compiling yet)

This commit is contained in:
2024-09-01 09:06:35 +02:00
parent 530bae8d57
commit 1c6a2f748c
18 changed files with 151 additions and 300 deletions

View File

@@ -1,16 +1,7 @@
namespace SM64Lib.LIBMIO0;
public struct MIO0_Header
{
public uint dest_size;
public uint comp_offset;
public uint uncomp_offset;
public bool big_endian;
};
public class MIO0
{
private const int MIO0_HEADER_LENGTH = 16;
private static int GET_BIT(byte[] buf, int offset, int bit)
@@ -49,7 +40,7 @@ public class MIO0
/// decode MIO0 header<para/>
/// returns true if valid header, false otherwise
///</summary>
public static bool decode_header(byte[] buf, ref MIO0_Header head)
public static bool decode_header(byte[] buf, ref MIO0Header head)
{
byte[] mio0_ascii_be = new byte[] { 0x4D, 0x49, 0x4F, 0x30 };
byte[] mio0_ascii_le = new byte[] { 0x49, 0x4D, 0x30, 0x4F };
@@ -77,7 +68,7 @@ public class MIO0
///<summary>
/// encode MIO0 header from struct
///</summary>
public static void encode_header(byte[] buf, ref MIO0_Header head)
public static void encode_header(byte[] buf, ref MIO0Header head)
{
write_u32_be(buf, 0x4D494F30, 0); // write "MIO0" at start of buffer
write_u32_be(buf, head.dest_size, 4);
@@ -93,7 +84,7 @@ public class MIO0
public static byte[] mio0_decode(byte[] mio0_buf)
{
MIO0_Header head = new();
MIO0Header head = new();
uint bytes_written = 0;
int bit_idx = 0;
int comp_idx = 0;
@@ -144,5 +135,4 @@ public class MIO0
}
return decoded;
}
}