#!/usr/bin/env python3 """ ROM Farmer Project Report Generator Generates a self-contained HTML report showcasing ROM Farmer's capabilities. Mermaid diagrams are rendered to PNG and embedded as base64 for portability. """ import base64 from datetime import datetime from pathlib import Path from playwright.sync_api import sync_playwright OUTPUT_DIR = Path("/path/to/rom-farmer/docs") OUTPUT_DIR.mkdir(exist_ok=True) def render_mermaid_to_base64(mermaid_code: str, width: int = 800) -> str: """Render Mermaid diagram to base64-encoded PNG using Playwright.""" html_template = f"""
{mermaid_code}
""" with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page(viewport={"width": width, "height": 600}) page.set_content(html_template) page.wait_for_timeout(2000) # Wait for Mermaid to render # Get the mermaid element and screenshot it element = page.query_selector(".mermaid") if element: png_bytes = element.screenshot() else: png_bytes = page.screenshot() browser.close() return base64.b64encode(png_bytes).decode('utf-8') # ═══════════════════════════════════════════════════════════════════════════════ # REPORT CONTENT # ═══════════════════════════════════════════════════════════════════════════════ MERMAID_ARCHITECTURE = """ flowchart TB subgraph Sources["📦 Source Management"] M[Myrient Archive] I[Internet Archive] R[Redump DATs] N[No-Intro DATs] end subgraph Pipeline["⚙️ ROM Farmer Pipeline"] DAT[DAT Validation] FILTER[1G1R Filtering] LISTS[Best-Of Lists] EXTRACT[Smart Extraction] COMPRESS[Optimal Compression] META[Metadata + Media] ORG[Organization] end subgraph Targets["🎮 Target Devices"] BAT[Batocera/EmuELEC] ROCK[ROCKNIX] FLASH[Flash Carts] STEAM[Steam Deck] end M --> DAT I --> DAT R --> DAT N --> DAT DAT --> FILTER --> LISTS --> EXTRACT --> COMPRESS --> META --> ORG ORG --> BAT ORG --> ROCK ORG --> FLASH ORG --> STEAM """ MERMAID_PIPELINE = """ flowchart LR subgraph Stage1["Stage 1"] S1[📋 DAT Filter] S1D["Validate ROMs against\nNo-Intro/Redump DATs\nMD5 hash verification"] end subgraph Stage2["Stage 2"] S2[🌍 1G1R Filter] S2D["One Game One ROM\nEnglish priority\nRetool processed"] end subgraph Stage3["Stage 3"] S3[⭐ Best-Of Lists] S3D["Curated game lists\nPer-platform selection\n54+ lists included"] end subgraph Stage4["Stage 4"] S4[📤 Extract] S4D["Smart extraction\nCartridge vs Disc\nFormat-aware"] end subgraph Stage5["Stage 5"] S5[🗜️ Compress] S5D["Target-optimal format\nZIP/7z/CHD/RVZ\nMax compression"] end subgraph Stage6["Stage 6"] S6[🎨 Metadata] S6D["gamelist.xml\nBoxart & videos\nPre-scraped DB"] end S1 --> S2 --> S3 --> S4 --> S5 --> S6 """ MERMAID_TIERS = """ flowchart TD subgraph Budget["💾 Storage Budget System"] B1[Parse Budget: 512GB] B1 --> B2[Account Overhead: ~456GB usable] B2 --> B3[Order by Tier Priority] end subgraph Tiers["📊 Platform Tiers"] T1["🟢 Tier 1: Tiny\nGB, GBC, GG, NGP, etc.\n~500MB total"] T2["🟡 Tier 2: Small\nNES, SNES, GBA, Genesis\n~2GB total"] T3["🟠 Tier 3: Medium\nPSX, Saturn, N64\n5-15GB each"] T4["🔴 Tier 4: Large\nDreamcast, PSP, NDS\n20-50GB each"] T5["⚫ Tier 5: Massive\nPS2, GameCube, Wii, PS3\n100GB+ each"] end B3 --> T1 --> T2 --> T3 --> T4 --> T5 """ MERMAID_TARGETS = """ flowchart TB subgraph Composition["🎯 Composed Targets"] F[Frontend Config] D[Device Config] F --> CT[Composed Target] D --> CT end subgraph Frontend["Frontend Examples"] F1[Batocera] F2[ROCKNIX] F3[EmuELEC] F4[Everdrive] end subgraph Device["Device Examples"] D1[R36S] D2[Steam Deck] D3[RGB10 Max3] D4[X55] end subgraph Result["Result: rocknix-r36s"] R1["✓ ZIP compression"] R2["✓ Skip N64, Saturn, DC"] R3["✓ 256GB budget profile"] R4["✓ Balanced organization"] end F1 & F2 --> CT D1 & D2 --> CT CT --> R1 & R2 & R3 & R4 """ CAPABILITIES = [ { "icon": "🎯", "name": "DAT-Driven Validation", "description": "Every ROM validated against official No-Intro and Redump DAT files using MD5 hashes. No guessing, no bad dumps, no wrong regions.", "details": ["Auto-discovers DAT files by platform name", "Supports Retool-processed 1G1R DATs", "MD5 hash database for fast lookups", "Reports match rates and rejections"] }, { "icon": "🌍", "name": "1G1R Smart Filtering", "description": "One Game, One ROM. Automatically selects the best version of each game based on region priority (USA → Europe → Japan) and revision.", "details": ["Retool pre-filtered DATs supported", "English language prioritized", "Latest revisions preferred", "No duplicates, no clones"] }, { "icon": "⭐", "name": "Curated Best-Of Lists", "description": "54+ hand-curated platform lists ensure you get the cream of each library. When storage is limited, quality over quantity.", "details": ["PSX: 60 essential games", "NDS: 57 must-plays", "Dreamcast: 27 classics", "Auto-rescue from filtered sets"] }, { "icon": "💾", "name": "Storage Budget System", "description": "Define your storage limit and ROM Farmer intelligently prioritizes platforms by tier. Tier 1-2 always included, Tier 3+ uses best-of when space is tight.", "details": ["Parses '512GB' → ~456GB usable", "5-tier priority system", "Real-time size tracking", "Learns from previous builds"] }, { "icon": "🗜️", "name": "Target-Aware Compression", "description": "Different targets need different formats. ROM Farmer picks the optimal compression for each target automatically.", "details": ["ZIP for fast loading (handhelds)", "7z for maximum compression", "CHD for disc images", "XISO, RVZ for specific consoles"] }, { "icon": "🎨", "name": "Pre-Scraped Metadata", "description": "Skip the ScreenScraper rate limits. ROM Farmer includes a pre-built database with artwork, videos, and game info ready to go.", "details": ["gamelist.xml generation", "Boxart, screenshots, videos", "Wheels and marquees", "MD5-based accurate matching"] }, { "icon": "📱", "name": "Composed Device Targets", "description": "Combine Frontend (Batocera, ROCKNIX) + Device (R36S, Steam Deck) into smart targets that know what works and what doesn't.", "details": ["Auto-skip unsupported platforms", "Device-specific compression", "Storage profile selection", "Frontend folder structure"] }, { "icon": "🔄", "name": "Resumable Builds", "description": "Interrupted? No problem. Full state tracking lets you resume exactly where you left off. No re-processing completed platforms.", "details": ["Build state persistence", "Per-platform checkpoints", "Error recovery", "Progress reporting"] }, ] PLATFORM_SUPPORT = { "Cartridge Systems (Tier 1-2)": [ "NES", "SNES", "N64", "Game Boy", "GBC", "GBA", "NDS", "3DS", "Genesis", "Master System", "Game Gear", "32X", "SG-1000", "TurboGrafx-16", "Neo Geo Pocket", "NGPC", "WonderSwan", "WSC", "Atari 2600", "5200", "7800", "Jaguar", "Lynx", "Virtual Boy", "ColecoVision", "Intellivision", "Vectrex" ], "Disc Systems (Tier 3-5)": [ "PlayStation", "PS2", "PS3", "PSP", "Sega CD", "Saturn", "Dreamcast", "TurboGrafx-CD", "PC Engine CD", "GameCube", "Wii", "Wii U", "Xbox", "Xbox 360", "3DO", "CD-i" ], "Special Format Handling": [ "Multi-disc → Auto M3U playlists", "PS1/Saturn/etc → CHD compression", "Xbox/360 → XISO extraction", "GameCube/Wii → RVZ compression", "PS3 → JB folder structure" ] } STATS = { "platforms": "40+", "best_of_lists": "54", "compression_formats": "8", "device_profiles": "5+", "stages": "8", } def generate_html_report(): """Generate the complete HTML report with embedded diagrams.""" print("🎨 Rendering Mermaid diagrams to PNG...") # Render all diagrams print(" - Architecture diagram...") arch_png = render_mermaid_to_base64(MERMAID_ARCHITECTURE, width=1000) print(" - Pipeline diagram...") pipeline_png = render_mermaid_to_base64(MERMAID_PIPELINE, width=1100) print(" - Tier system diagram...") tier_png = render_mermaid_to_base64(MERMAID_TIERS, width=900) print(" - Targets diagram...") targets_png = render_mermaid_to_base64(MERMAID_TARGETS, width=900) # Generate capability cards capability_cards = "" for cap in CAPABILITIES: details_html = "".join(f"
  • {d}
  • " for d in cap["details"]) capability_cards += f"""
    {cap["icon"]}

    {cap["name"]}

    {cap["description"]}

    """ # Generate platform lists platform_html = "" for category, platforms in PLATFORM_SUPPORT.items(): platform_html += f'

    {category}

    ' for p in platforms: platform_html += f'{p}' platform_html += '
    ' # Stats cards stats_html = "" stat_labels = { "platforms": "Platforms Supported", "best_of_lists": "Curated Lists", "compression_formats": "Compression Formats", "device_profiles": "Device Profiles", "stages": "Pipeline Stages" } for key, value in STATS.items(): stats_html += f"""
    {value}
    {stat_labels[key]}
    """ html = f""" ROM Farmer - Project Report

    🌾 ROM Farmer

    The configuration-driven ROM collection pipeline that maximizes great games per gigabyte

    Project Report • {datetime.now().strftime('%B %d, %Y')}

    {stats_html}

    🎯 What is ROM Farmer?

    A complete solution for building optimized retro gaming collections

    💡 Core Philosophy

    "EVERYTHING is really about getting the best compression ratio so that we can have more great games than anyone else for the storage space."

    ROM Farmer transforms ROM collection management from tedious manual work into a streamlined, configuration-driven process. Define your target device and storage budget in YAML, and ROM Farmer handles everything else: validation, filtering, compression, metadata, and organization.

    ROM Farmer Architecture

    End-to-end pipeline from source archives to deployment-ready collections

    ⚙️ The Pipeline

    8 stages process your ROMs with surgical precision

    ROM Farmer Pipeline
    1

    DAT Validation

    Verify every ROM against official No-Intro/Redump DAT files using MD5 hashes

    2

    1G1R Filtering

    One Game, One ROM - select best version per title with English priority

    3

    Selection Filters

    Apply curated best-of lists or custom selection criteria

    4

    List Processing

    Delete unwanted titles, add extras from Myrient/other sources

    5

    Smart Extraction

    Extract cartridge ROMs from ZIPs, handle disc images appropriately

    6

    Optimal Compression

    Target-aware format selection: ZIP, 7z, CHD, RVZ, or uncompressed

    7

    Organization

    Arrange files using flat, alphabetical, or rich subdirectory structures

    8

    Metadata Generation

    Create gamelist.xml with artwork, videos, and game information

    ✨ Key Capabilities

    Everything you need for professional-grade ROM management

    {capability_cards}

    💾 Smart Storage Management

    Intelligent tier-based prioritization ensures quality over quantity

    Tier System

    5-tier system ensures must-have platforms always fit

    How It Works

    Define a storage budget like "256GB" and ROM Farmer calculates usable space (accounting for filesystem overhead), then processes platforms in tier order. Tier 1-2 platforms are always included in full. When space gets tight, Tier 3+ platforms automatically switch to "best-of" mode, including only curated essential games instead of full libraries.

    🎯 Composed Targets

    Smart device profiles that know what works and what doesn't

    Composed Targets

    Frontend Configs

    Define how the frontend organizes and accesses ROMs:

    • Preferred compression format
    • Folder structure expectations
    • Metadata format (gamelist.xml)
    • Media types supported

    Device Configs

    Define hardware capabilities and limitations:

    • Unsupported platforms (auto-skip)
    • Storage capacity profiles
    • Performance characteristics
    • Display considerations
    # Example: rocknix-r36s-handheld.yaml name: rocknix-r36s-handheld target: rocknix-r36s # Combines rocknix frontend + r36s device profile: handheld storage: budget: 256gb platforms: - nes # Tier 2 - full library - snes # Tier 2 - full library - gb # Tier 1 - full library - gbc # Tier 1 - full library - gba # Tier 2 - full library - psx # Tier 3 - best-of list (60 games) - genesis # Tier 2 - full library # n64, saturn, dreamcast auto-skipped (R36S can't emulate well)

    🎮 Platform Support

    40+ platforms with format-specific handling

    {platform_html}

    🚀 Why ROM Farmer?

    The problems we solve

    ❌ The Old Way

    • • Download massive full sets blindly
    • • Write custom scripts per platform
    • • Manually run scraper for hours
    • • Guess at compression formats
    • • Delete random games when out of space
    • • Start over when something breaks
    • • Different process for each device

    ✅ The ROM Farmer Way

    • • DAT-validated, 1G1R filtered ROMs
    • • Single YAML config for all platforms
    • • Pre-scraped metadata database
    • • Target-aware optimal compression
    • • Tier-based intelligent selection
    • • Full resume support
    • • Composed targets for any device

    🏆 The Result

    More great games, better organized, with full metadata and media, optimized for your specific device — all from a single YAML configuration file. Build once, deploy anywhere.

    """ output_path = OUTPUT_DIR / "rom-farmer-report.html" output_path.write_text(html) print(f"\n✅ Report generated: {output_path}") print(f" File size: {output_path.stat().st_size / 1024:.1f} KB") return output_path if __name__ == "__main__": generate_html_report()