Expand description
Output formatting system for CLI memory dumps.
This module provides an extensible output format system using traits. Adding a new output format requires:
- Add a variant to
OutputFormatenum - Implement the
MemoryFormattertrait for the new format - Register it in
OutputFormat::formatter()
§Interpreted Data
OAM and nametable dumps include both raw data and interpreted structures:
- OAM: 64 sprites with position, tile index, attributes, flip flags
- Nametables: 4 nametables with tile IDs, attribute tables, and per-tile palettes
§Example: Adding a new format
ⓘ
// 1. Add enum variant in args.rs
pub enum OutputFormat {
Hex,
Json,
Toml,
Binary,
Xml, // New format
}
// 2. Implement the formatter
pub struct XmlFormatter;
impl MemoryFormatter for XmlFormatter {
fn format(&self, dump: &MemoryDump) -> Result<Vec<u8>, String> {
// ... format as XML ...
}
fn file_extension(&self) -> &'static str {
"xml"
}
}
// 3. Register in OutputFormat::formatter()
OutputFormat::Xml => Box::new(XmlFormatter),Structs§
- Binary
Formatter - Raw binary formatter
- HexFormatter
- Hexadecimal dump formatter (traditional hex dump format)
- Interpreted
Nametable - A single nametable (32x30 tiles + 64-byte attribute table).
- Interpreted
Nametables - Interpreted nametable data containing all 4 nametables.
- Interpreted
Oam - Interpreted OAM data containing all 64 sprites.
- Json
Formatter - JSON formatter
- Memory
Dump - A memory dump with metadata and optional interpreted data.
- OamSprite
- A single sprite entry from OAM (4 bytes interpreted).
- Output
Writer - Manages output writing with support for file and stdout.
- Toml
Formatter - TOML formatter
Enums§
- Memory
Type - Type of memory being dumped
Traits§
- Memory
Formatter - Trait for memory dump formatters.