Pansy - Program ANalysis SYstem format for comprehensive assembly metadata exchange
The ๐ผ Pansy command-line interface provides tools for inspecting, searching, and analyzing Pansy metadata files.
# Build the CLI
cd src/Pansy.Cli
dotnet build
# Run commands
dotnet run -- <command> [options]
# Or use the built executable
./bin/Debug/net10.0/Pansy.Cli <command> [options]All commands support:
--help- Show command-specific help-v,--verbose- Enable verbose output (where applicable)
Shows comprehensive information about a Pansy file including header details, content statistics, and memory regions.
Usage:
dotnet run --project src/Pansy.Cli -- info <file> [-v|--verbose]Arguments:
<file>- Path to the Pansy file
Options:
-v,--verbose- Show additional details
Example:
$ dotnet run --project src/Pansy.Cli -- info game.pansy
๐ผ Pansy File Viewer
โญโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฎ
โ Property โ Value โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ Format Version โ 0100 โ
โ Platform โ NES โ
โ ROM Size โ 32768 bytes (32K) โ
โ ROM CRC32 โ 12345678 โ
โ Flags โ None โ
โฐโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโฏ
Content Statistics:
โข Symbols: 7
โข Comments: 3
โข Code Offsets: 7
โข Data Offsets: 0
โข Jump Targets: 2
โข Subroutines: 3
โข Memory Regions: 2
โข Cross-refs: 4
Memory Regions:
โญโโโโโโโโฌโโโโโโโโฌโโโโโโโฌโโโโโโโฌโโโโโโโโโโโโโโโโโฎ
โ Start โ End โ Bank โ Type โ Name โ
โโโโโโโโโผโโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโโโโโโโโโโโค
โ $8000 โ $bfff โ 0 โ 1 โ PRG-ROM Bank 0 โ
โ $c000 โ $ffff โ 1 โ 1 โ PRG-ROM Bank 1 โ
โฐโโโโโโโโดโโโโโโโโดโโโโโโโดโโโโโโโดโโโโโโโโโโโโโโโโโฏOutput:
- File header (version, platform, ROM size/CRC, flags)
- Content statistics (symbol counts, code/data coverage)
- Memory regions table (if any)
- Project metadata (if present)
Lists all symbols defined in a Pansy file with addresses and names.
Usage:
dotnet run --project src/Pansy.Cli -- symbols <file> [--sort address|name] [--filter <pattern>]Arguments:
<file>- Path to the Pansy file
Options:
--sort address- Sort by address (default)--sort name- Sort alphabetically by name--filter <pattern>- Filter symbols by pattern (case-insensitive)
Example:
$ dotnet run --project src/Pansy.Cli -- symbols game.pansy
๐ผ Symbols in game.pansy
Total: 7 symbols
โญโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฎ
โ Address โ Name โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ $8000 โ Reset โ
โ $8003 โ NMI_Handler โ
โ $8006 โ IRQ_Handler โ
โ $8010 โ Main_Loop โ
โ $8050 โ Update_Graphics โ
โ $8100 โ Read_Controller โ
โ $8150 โ Play_Sound โ
โฐโโโโโโโโโโดโโโโโโโโโโโโโโโโโโฏOutput:
- Table of addresses and symbol names
- Total symbol count
Searches for symbols and comments matching a pattern. Supports plain text, regex, and wildcard patterns.
Usage:
dotnet run --project src/Pansy.Cli -- find <file> <pattern> [options]Arguments:
<file>- Path to the Pansy file<pattern>- Search pattern
Options:
-c,--comments- Search comments only-s,--symbols- Search symbols only-i,--case-insensitive- Case-insensitive search-r,--regex- Treat pattern as a regex-w,--wildcard- Treat pattern as a wildcard (* and ?)
Pattern Modes:
- Plain text (default): Matches if the pattern appears anywhere in the text
- Example:
MainmatchesMain_Loop,Update_Main
- Example:
- Regex (
-r): Full regular expression support- Example:
^NMI_.*Handler$matches exactlyNMI_Handler
- Example:
- Wildcard (
-w): Simple wildcard patterns*matches any characters (zero or more)?matches any single character- Example:
*LoopmatchesMain_Loop,Update_Loop
Examples:
# Plain text search
$ dotnet run --project src/Pansy.Cli -- find game.pansy "Handler"
๐ผ Search results for 'Handler' (text, case-sensitive)
Symbols:
โญโโโโโโโโโโฌโโโโโโโโโโโโโโฎ
โ Address โ Name โ
โโโโโโโโโโโผโโโโโโโโโโโโโโค
โ $8003 โ NMI_Handler โ
โ $8006 โ IRQ_Handler โ
โฐโโโโโโโโโโดโโโโโโโโโโโโโโฏ
Found 2 match(es)
# Regex search
$ dotnet run --project src/Pansy.Cli -- find game.pansy "^NMI_.*" -r
# Wildcard search (case-insensitive)
$ dotnet run --project src/Pansy.Cli -- find game.pansy "*Main*" -w -i
# Search only symbols
$ dotnet run --project src/Pansy.Cli -- find game.pansy "Loop" -sOutput:
- Matching symbols table (if searching symbols)
- Matching comments table (if searching comments)
- Total match count
Displays cross-references for a specific address or performs cross-reference analysis across the entire file.
Usage:
# Show references for a specific address
dotnet run --project src/Pansy.Cli -- xrefs <file> <address>
# Analysis commands
dotnet run --project src/Pansy.Cli -- xrefs <file> --stats
dotnet run --project src/Pansy.Cli -- xrefs <file> --most-called [n]
dotnet run --project src/Pansy.Cli -- xrefs <file> --unreferenced
dotnet run --project src/Pansy.Cli -- xrefs <file> --type <type>Arguments:
<file>- Path to the Pansy file<address>- Address to query (decimal format, e.g., 32784 for $8010)
Options:
--stats- Show cross-reference statistics summary--most-called [n]- Show top N most referenced addresses (default: 10)--unreferenced- Show subroutines with no incoming references--type <type>- Filter by reference type (Jsr, Jmp, Branch, Read, Write, DataRef)
Analysis Examples:
# Show overall cross-reference statistics
$ dotnet run --project src/Pansy.Cli -- xrefs game.pansy --stats
๐ผ Cross-Reference Statistics
Total cross-references: 47
By Type:
โข Jsr: 23 (48.9%)
โข Jmp: 12 (25.5%)
โข Branch: 8 (17.0%)
โข Read: 3 (6.4%)
โข Write: 1 (2.1%)
# Show top 5 most called addresses
$ dotnet run --project src/Pansy.Cli -- xrefs game.pansy --most-called 5
๐ผ Top 5 Most Referenced Addresses
โญโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโฎ
โ Address โ Symbol โ Refs โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโค
โ $8100 โ Read_Controller โ 12 โ
โ $8050 โ Update_Graphics โ 8 โ
โ $8150 โ Play_Sound โ 5 โ
โ $8010 โ Main_Loop โ 3 โ
โ $8200 โ Wait_VBlank โ 2 โ
โฐโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโฏ
# Show unreferenced subroutines (dead code detection)
$ dotnet run --project src/Pansy.Cli -- xrefs game.pansy --unreferenced
๐ผ Unreferenced Subroutines
โญโโโโโโโโโโฌโโโโโโโโโโโโโโโฎ
โ Address โ Symbol โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ $8300 โ Debug_Print โ
โ $8400 โ Old_Handler โ
โฐโโโโโโโโโโดโโโโโโโโโโโโโโโฏ
Found 2 unreferenced subroutines (potential dead code)
# Filter by reference type
$ dotnet run --project src/Pansy.Cli -- xrefs game.pansy --type Jsr
๐ผ Cross-References of Type: Jsr
โญโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฎ
โ From โ To โ Target Symbol โ
โโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ $8015โ $8100 โ Read_Controller โ
โ $8020โ $8050 โ Update_Graphics โ
โ $8025โ $8150 โ Play_Sound โ
โฐโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโฏ
Found 23 Jsr referencesAddress Query Example:
$ dotnet run --project src/Pansy.Cli -- xrefs game.pansy 32784
๐ผ Cross-references for $8010
Symbol: Main_Loop
References TO this address:
โญโโโโโโโโฌโโโโโโโฌโโโโโโโโโฎ
โ From โ Type โ Symbol โ
โโโโโโโโโผโโโโโโโผโโโโโโโโโค
โ $8070 โ Jmp โ โ
โฐโโโโโโโโดโโโโโโโดโโโโโโโโโฏ
Total: 1 incoming, 0 outgoingOutput:
- Target address and symbol name (if any)
- Incoming references table (FROM โ TO this address)
- Outgoing references table (FROM this address โ TO)
- Total counts
Note: Addresses must be specified in decimal. To convert hex to decimal:
$8000= 32768$8010= 32784$C000= 49152
Compares two Pansy files and shows differences in headers, symbols, comments, and cross-references.
Usage:
dotnet run --project src/Pansy.Cli -- diff <file1> <file2> [--summary]Arguments:
<file1>- Path to first Pansy file<file2>- Path to second Pansy file
Options:
--summary- Show only summary, not detailed differences
Example:
$ dotnet run --project src/Pansy.Cli -- diff original.pansy modified.pansy
๐ผ Comparing Pansy Files
Header Comparison:
โญโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฎ
โ Property โ File 1 โ File 2 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ Platform โ NES โ NES โ
โ ROM Size โ 32768 โ 32768 โ
โ ROM CRC โ 12345678 โ 12345678 โ
โฐโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโฏ
Symbol Changes:
โข Added: 3
โข Removed: 1
โข Modified: 0
Symbols Added:
$8200: New_Function
$8210: Helper_Routine
$8220: Data_Table
Symbols Removed:
$8150: Old_FunctionOutput:
- Header comparison table
- Change statistics
- Added/removed/modified symbols
Shows detailed statistics and analysis of a Pansy file's contents.
Usage:
dotnet run --project src/Pansy.Cli -- stats <file>Arguments:
<file>- Path to the Pansy file
Output:
- Symbol count by type (Label, Function, Constant, etc.)
- Comment count by type (Inline, Block, Todo)
- Code/data map flag counts
- Cross-reference counts by type
- Memory region summary
Merges two Pansy files using a base + overlay strategy with intelligent deduplication.
Usage:
dotnet run --project src/Pansy.Cli -- merge <base> <overlay> [-o|--output <file>]Arguments:
<base>- Base Pansy file (provides ROM info and foundation)<overlay>- Overlay Pansy file (adds or supplements data)
Options:
-o,--output <file>- Output path (default:merged.pansy)
Merge Strategies:
- Symbols/Comments: Union of all entries, base-first ordering, duplicates removed
- Code/Data Map: Flag union (OR of all flags)
- Cross-references: Deduplicated by (from, to, type)
- Memory Regions: Overlay wins on name conflicts
- Metadata: Overlay wins with fallback to base
Example:
$ dotnet run --project src/Pansy.Cli -- merge base.pansy overlay.pansy -o merged.pansy
๐ผ Merging Pansy files
Base: base.pansy
Overlay: overlay.pansy
Output: merged.pansy
Merge Results:
Symbols: 125 (base: 100, overlay: 50, merged: 125)
Comments: 80 (base: 60, overlay: 30, merged: 80)
Cross-refs: 200 (base: 150, overlay: 100, merged: 200)
โ
Merged successfully: merged.pansy (4,521 bytes)Validates the internal structure and consistency of a Pansy file.
Usage:
dotnet run --project src/Pansy.Cli -- validate <file>Arguments:
<file>- Path to the Pansy file
Output:
- Header validation (magic, version, platform)
- Section integrity checks
- Content consistency verification
- Pass/fail status
Exports cross-reference data as a DOT graph for visualization.
Usage:
dotnet run --project src/Pansy.Cli -- graph <file> [-o|--output <file>] [--format <format>]Arguments:
<file>- Path to the Pansy file
Options:
-o,--output <file>- Output path (default:graph.dot)--format <format>- Output format:dot(default),mermaid
Analyzes ROM coverage using CDL data and optionally detects data patterns in unclassified gaps.
Usage:
dotnet run --project src/Pansy.Cli -- analyze <pansy-file> [rom-file] [-p|--patterns]Arguments:
<pansy-file>- Path to the Pansy file[rom-file]- Optional path to the ROM file (enables full analysis)
Options:
-p,--patterns- Enable pattern detection in gaps (requires ROM file)
Without ROM file: CDL-only coverage analysis using code/data map flags.
With ROM file: Full analysis including gap detection and optional pattern detection.
Detected Patterns:
- Fill regions - Blocks of repeated bytes (e.g.,
$ffpadding) - ASCII strings - Text data with printable characters
- Pointer tables - Arrays of addresses (platform-aware: NES 16-bit, SNES 24-bit, GBA 32-bit)
- Tile data - Graphics tile patterns (NES 2bpp, SNES/SMS 4bpp)
Example:
$ dotnet run --project src/Pansy.Cli -- analyze game.pansy game.nes --patterns
๐ผ ROM Coverage Analysis
File: game.pansy
โญโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโฎ
โ Metric โ Value โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโค
โ Total Bytes โ 32,768 โ
โ Classified Bytes โ 24,576 โ
โ Unclassified Bytes โ 8,192 โ
โ Coverage โ 75.0% โ
โฐโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโฏ
Detected Patterns (3)
โญโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฎ
โ Offset โ Kind โ Length โ Confidence โ Description โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ $006000 โ Fill โ 4,096 โ 100% โ Fill: $ff x 4096 โ
โ $007000 โ PointerTable โ 512 โ 95% โ 256 NES addresses โ
โ $007200 โ Ascii โ 128 โ 90% โ ASCII: "HELLO..." โ
โฐโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโฏ- Added/removed comments
- Cross-reference differences
All commands return exit codes:
0- Success1- Error (file not found, invalid format, etc.)
Error messages are displayed in red with the Error: prefix.
Example:
$ dotnet run --project src/Pansy.Cli -- info missing.pansy
Error: File not found: missing.pansyCommands output to stdout and can be piped:
# Count symbols
dotnet run --project src/Pansy.Cli -- symbols game.pansy | grep -c '^โ'
# Search for specific pattern
dotnet run --project src/Pansy.Cli -- symbols game.pansy | grep "Handler"
# Save output to file
dotnet run --project src/Pansy.Cli -- info game.pansy > analysis.txtProcess multiple files with shell scripting:
# PowerShell: Check all .pansy files
Get-ChildItem *.pansy | ForEach-Object {
dotnet run --project src/Pansy.Cli -- info $_.FullName
}
# Bash: Find files with symbols count
for file in *.pansy; do
echo "$file:"
dotnet run --project src/Pansy.Cli -- info "$file" | grep "Symbols:"
doneExport symbols to Mesen label file format (coming soon):
# Convert Pansy to Mesen MLB
dotnet run --project src/Pansy.Cli -- convert game.pansy --to mesen --output game.mlbUse in continuous integration to verify analysis:
# GitHub Actions example
- name: Verify Pansy metadata
run: |
dotnet run --project src/Pansy.Cli -- info game.pansy
if [ $? -ne 0 ]; then
echo "Invalid Pansy file"
exit 1
fi- Use Tab Completion: Most shells support path completion for file arguments
- Verbose Mode: Add
-vto see additional details during processing - Hex Addresses: Remember to convert hex to decimal for the
xrefscommand - Large Files: For ROMs over 1MB, expect slightly longer loading times
- Symbol Naming: Use consistent naming conventions for better searchability
Problem: Command not recognized
Error: Unknown command: infpSolution: Check spelling - valid commands are info, symbols, find, xrefs, diff
Problem: File format error
Error: Invalid Pansy file: bad magic numberSolution: Verify the file is a valid Pansy file (not corrupted or different format)
Problem: Address out of range
Error: Invalid address: 0x8010Solution: Use decimal addresses, not hex format:
- Instead of
0x8010, use32784 - Instead of
$C000, use49152
- File Format Specification - Complete format documentation
- GitHub Issues - Report bugs or request features