Skip to main content

Module output

Module output 

Source
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:

  1. Add a variant to OutputFormat enum
  2. Implement the MemoryFormatter trait for the new format
  3. 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§

BinaryFormatter
Raw binary formatter
HexFormatter
Hexadecimal dump formatter (traditional hex dump format)
InterpretedNametable
A single nametable (32x30 tiles + 64-byte attribute table).
InterpretedNametables
Interpreted nametable data containing all 4 nametables.
InterpretedOam
Interpreted OAM data containing all 64 sprites.
JsonFormatter
JSON formatter
MemoryDump
A memory dump with metadata and optional interpreted data.
OamSprite
A single sprite entry from OAM (4 bytes interpreted).
OutputWriter
Manages output writing with support for file and stdout.
TomlFormatter
TOML formatter

Enums§

MemoryType
Type of memory being dumped

Traits§

MemoryFormatter
Trait for memory dump formatters.