Added WAD packing command to rustii CLI

Also added lots of required library magic to make WAD packing possible. This includes the high-level Title object from libWiiPy, the ability to set content in a WAD, the ability to generate a WADHeader from a WADBody, and more.
This commit is contained in:
2025-03-19 18:50:37 -04:00
parent 6ab9993dd9
commit 62f6e6c0ec
10 changed files with 358 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ use std::io::{Cursor, Read, Write};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
#[derive(Debug)]
#[derive(Clone)]
pub struct ContentRecord {
pub content_id: u32,
pub index: u16,
@@ -44,6 +45,7 @@ pub struct TMD {
}
impl TMD {
/// Creates a new TMD instance from the binary data of a TMD file.
pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
let mut buf = Cursor::new(data);
let signature_type = buf.read_u32::<BigEndian>()?;
@@ -129,6 +131,7 @@ impl TMD {
})
}
/// Dumps the data in a TMD back into binary data that can be written to a file.
pub fn to_bytes(&self) -> Result<Vec<u8>, std::io::Error> {
let mut buf: Vec<u8> = Vec::new();
buf.write_u32::<BigEndian>(self.signature_type)?;