🎮 ROM Farmer 1G1R Filtering System

Table of Contents

Executive Summary

The 1G1R (One Game, One ROM) philosophy ensures that only the best version of each game is retained, eliminating duplicates, inferior revisions, and regional variants. ROM Farmer implements this through a sophisticated multi-layered approach combining external DAT filtering tools and internal scoring algorithms.


System Architecture Overview

flowchart TD subgraph External["External Pre-Filtering"] A[("No-Intro / Redump
Full DAT Sets")] B["Retool Tool"] C[("Retool 1G1R DATs
(Pre-filtered)")] A --> B B --> C end subgraph Internal["ROM Farmer Internal Filtering"] D["Filter1G1RStage
(No DAT Mode)"] E["OneGameOneRomFilter
Class"] F["Scoring Algorithm"] D --> E E --> F end subgraph Selection["Final Selection"] G{{"Best Version
Per Game"}} end C --> G F --> G style External fill:#e8f5e9 style Internal fill:#e3f2fd style Selection fill:#fff3e0

Two Approaches to 1G1R

ROM Farmer supports two fundamentally different approaches to achieving 1G1R filtering:

Approach 1: Pre-Filtered Retool DATs (Recommended)

The preferred method uses externally pre-filtered DAT files created by the Retool tool.

What is Retool?

Retool is a specialized tool that processes standard No-Intro and Redump DAT files to:

Available DAT Sources

DAT Source Description Pre-filtering Applied
RETOOL_1G1R_ENG No-Intro with English preference ✅ 1G1R + Language
RETOOL_1G1R_USA No-Intro with USA preference ✅ 1G1R + Region
RETOOL_1G1R_ALL No-Intro all languages ✅ 1G1R only
REDUMP_RETOOL_1G1R_ENG Redump with English preference ✅ 1G1R + Language
REDUMP_RETOOL_1G1R_USA Redump with USA preference ✅ 1G1R + Region
NOINTRO_STANDARD Unfiltered No-Intro ❌ Full set
REDUMP_STANDARD Unfiltered Redump ❌ Full set

Retool DAT Format

Retool DATs follow the Logiqx XML format with enhancements:

<game name="Super Mario Bros. (USA)">
    <category>Games</category>
    <description>Super Mario Bros. (USA)</description>
    <rom name="Super Mario Bros. (USA).nes" 
         size="40976" 
         crc="3337ec46" 
         md5="811b027eaf99c2def7b933c5208636de" 
         sha1="4612c5b84e5a2f4388f9e798c99d58c898b7c0b6"/>
</game>

Approach 2: Runtime 1G1R Filtering (Fallback)

When no DAT file is available, ROM Farmer applies its own 1G1R filtering at runtime using the OneGameOneRomFilter class.

flowchart LR subgraph Input["Input Files"] A["All ROMs
from Source"] end subgraph Grouping["Grouping Phase"] B["Extract Base Names"] C["Group by
Unique Game"] end subgraph Scoring["Scoring Phase"] D["Calculate
Region Score"] E["Calculate
Language Score"] F["Calculate
Parent/Clone Score"] G["Calculate
Revision Score"] H["Composite Score"] end subgraph Output["Output"] I["Best Version
Per Game"] end A --> B --> C --> D C --> E C --> F C --> G D --> H E --> H F --> H G --> H H --> I style Scoring fill:#e3f2fd

The Scoring Algorithm

Score Composition

The 1G1R filter calculates a composite score for each ROM variant:

Score = (Region × 1000) + (Language × 100) + (Parent × 10) + (Revision)

This weighting ensures:

  1. Region is the most important factor
  2. Language breaks ties between same-region variants
  3. Parent status prefers original releases over clones/alternates
  4. Revision selects the latest version within identical criteria

Region Priority System

Regions are prioritized based on typical collector preferences for English-speaking audiences:

graph LR subgraph High["High Priority (100-90)"] A["USA
100"] B["World
95"] C["Europe
90"] end subgraph Medium["Medium Priority (85-70)"] D["Japan
85"] E["Asia
80"] F["Korea
75"] G["China
70"] end subgraph Lower["Lower Priority (65-50)"] H["Brazil
65"] I["Australia
60"] J["Germany
55"] K["France
50"] end A --> B --> C --> D --> E --> F --> G --> H --> I --> J --> K style High fill:#c8e6c9 style Medium fill:#fff9c4 style Lower fill:#ffccbc

Complete Region Priority Table

RegionScoreRegionScore
USA100Taiwan45
World95Netherlands40
Europe90Scandinavia35
Japan85Unknown30
Asia80Proto20
Korea75Unl (Unlicensed)10
China70
Brazil65
Australia60
Germany55
France50

Language Priority System

LanguageScoreCode Pattern
English100En
Japanese85Ja
French80Fr
German75De
Spanish70Es
Italian65It
Portuguese60Pt
Dutch55Nl
Swedish50Sv
Norwegian45No
Danish40Da
Finnish35Fi
Chinese30Zh
Korean25Ko
Russian20Ru

Multi-Language Handling

ROMs with multiple languages (e.g., "En,Fr,De") receive the highest score among their languages:

# Example: "Super Mario Bros. (Europe) (En,Fr,De)"
# Languages found: En (100), Fr (80), De (75)
# Final language score: 100 (highest wins)

Base Name Grouping

How Games are Grouped

The filter groups ROMs by base name - the core game title stripped of all variant tags:

flowchart TD subgraph Original["Original Filenames"] A["Super Mario Bros. (USA).nes"] B["Super Mario Bros. (Europe).nes"] C["Super Mario Bros. (Japan).nes"] D["Super Mario Bros. (USA) (Rev 1).nes"] E["Super Mario Bros. (USA) (Rev A).nes"] end subgraph Extraction["Base Name Extraction"] F["Strip Region Tags"] G["Strip Language Tags"] H["Strip Version Tags"] I["Strip Clone Indicators"] end subgraph Result["Grouping Result"] J[("'Super Mario Bros.'
5 variants")] end A --> F B --> F C --> F D --> F E --> F F --> G --> H --> I --> J style Original fill:#e8f5e9 style Result fill:#fff3e0

Tag Patterns Removed

CategoryExamplesRegex Pattern
Region(USA), (Europe), (Japan)\(USA\), \(Europe\), etc.
Language(En), (En,Fr,De), (Ja)\([A-Z][a-z](,[A-Z][a-z])*\)
Revision(Rev 1), (Rev A), (v1.1)\(Rev [0-9A-Z]+\), \(v[0-9.]+\)
Clone Indicators[!], [a], [b], [h], [t]\[[!abhftpo]\]
Misc Tags(Proto), (Beta), (Demo)\(Proto\), \(Beta\), etc.

Revision Detection

Version Parsing

The filter parses revision/version information from ROM names:

flowchart LR subgraph Patterns["Detected Patterns"] A["Rev N
(Rev 1, Rev 2)"] B["Rev Letter
(Rev A, Rev B)"] C["Version
(v1.0, v1.1)"] end subgraph Scoring["Score Calculation"] D["Rev 1 → 1"] E["Rev 2 → 2"] F["Rev A → 1"] G["Rev B → 2"] H["v1.0 → 10"] I["v1.1 → 11"] end A --> D A --> E B --> F B --> G C --> H C --> I style Patterns fill:#e3f2fd style Scoring fill:#c8e6c9

Revision Score Examples

ROM NameParsed RevisionScore
Super Mario Bros. (USA).nesNone0
Super Mario Bros. (USA) (Rev 1).nesRev 11
Super Mario Bros. (USA) (Rev 2).nesRev 22
Zelda (USA) (Rev A).nesRev A1
Zelda (USA) (Rev B).nesRev B2
Sonic (USA) (v1.0).nesv1.010
Sonic (USA) (v1.1).nesv1.111
Sonic (USA) (v2.0).nesv2.020

Parent vs Clone Detection

Clone Indicators

The GoodTools naming convention uses bracketed codes to indicate ROM variants:

CodeMeaningIs Clone?
[!]Verified good dumpNo
[a]AlternateYes
[b]Bad dumpYes
[c]CrackedYes
[f]FixedYes
[h]HackYes
[o]OverdumpYes
[p]PirateYes
[t]Trained (cheats)Yes

Parent Preference Logic

flowchart TD A["ROM Name"] --> B{Has clone
indicator?} B -->|"No"| C["Is Parent
(+10 points)"] B -->|"Yes [a][b][h][t]..."| D["Is Clone
(+0 points)"] style C fill:#c8e6c9 style D fill:#ffccbc

When prefer_parents=True (default), parent ROMs receive a 10-point bonus.


Complete Scoring Example

Let's walk through scoring for a hypothetical game with multiple variants:

Input Variants

VariantRegionLanguageParentRevision
Game (USA).nesUSA-YesNone
Game (USA) (Rev 1).nesUSA-YesRev 1
Game (Europe) (En,Fr,De).nesEuropeEn,Fr,DeYesNone
Game (Japan).nesJapan-YesNone
Game (USA) [a].nesUSA-NoNone

Score Calculation

flowchart TD subgraph Variant1["Game (USA).nes"] A1["Region: USA = 100"] A2["Language: Default = 0"] A3["Parent: Yes = 10"] A4["Revision: None = 0"] A5["Total: 100,010"] end subgraph Variant2["Game (USA) (Rev 1).nes ✓ WINNER"] B1["Region: USA = 100"] B2["Language: Default = 0"] B3["Parent: Yes = 10"] B4["Revision: Rev 1 = 1"] B5["Total: 100,011"] end subgraph Variant3["Game (Europe) (En,Fr,De).nes"] C1["Region: Europe = 90"] C2["Language: En = 100"] C3["Parent: Yes = 10"] C4["Revision: None = 0"] C5["Total: 100,010"] end style Variant2 fill:#c8e6c9

Winner Selection

VariantCalculationFinal Score
Game (USA).nes100×1000 + 0×100 + 10 + 0100,010
Game (USA) (Rev 1).nes100×1000 + 0×100 + 10 + 1100,011 ✓
Game (Europe) (En,Fr,De).nes90×1000 + 100×100 + 10 + 0100,010
Game (Japan).nes85×1000 + 0×100 + 10 + 085,010
Game (USA) [a].nes100×1000 + 0×100 + 0 + 0100,000

Winner: Game (USA) (Rev 1).nes - highest score due to revision bonus


DAT Matching Strategies

When matching ROMs against DAT entries, multiple strategies are employed:

flowchart TD A["ROM File"] --> B{Try Match
Strategies} B --> C["1. Exact Filename"] C --> D{Match?} D -->|Yes| E["✓ Matched"] D -->|No| F["2. Inner Filename
(in archives)"] F --> G{Match?} G -->|Yes| E G -->|No| H["3. CRC Match"] H --> I{Match?} I -->|Yes| E I -->|No| J["4. MD5 Match"] J --> K{Match?} K -->|Yes| E K -->|No| L["5. SHA1 Match"] L --> M{Match?} M -->|Yes| E M -->|No| N["✗ No Match"] style E fill:#c8e6c9 style N fill:#ffccbc

Match Strategy Priority

  1. EXACT_FILENAME: Direct filename comparison
  2. INNER_FILENAME: Check filenames inside archives (ZIP, 7z)
  3. CRC_MATCH: CRC32 hash comparison (fast)
  4. MD5_MATCH: MD5 hash comparison
  5. SHA1_MATCH: SHA1 hash comparison (most reliable)

Summary: Decision Tree

flowchart TD A["Start: Select Best ROM"] --> B{DAT File
Available?} B -->|"Yes"| C{Retool
Pre-filtered?} B -->|"No"| D["Run OneGameOneRomFilter"] C -->|"Yes"| E["Use DAT as-is
(Already 1G1R)"] C -->|"No"| F["Match against DAT
+ Apply Filter"] D --> G["1. Group by Base Name"] G --> H["2. Score Each Variant"] H --> I["3. Select Highest Score"] F --> J["Verify Hashes"] J --> K["Use Matched ROMs"] E --> L["Best ROM Selected"] I --> L K --> L style L fill:#c8e6c9

Key Takeaways

  1. Retool DATs are preferred - Pre-filtering by Retool ensures consistent, well-tested 1G1R results
  2. Scoring is deterministic - The weighted formula always produces consistent results
  3. Region trumps all - USA ROMs are strongly preferred over other regions
  4. Later revisions win - Bug fixes and improvements are automatically selected
  5. Parents over clones - Original releases beat alternate dumps and hacks
  6. Multiple match strategies - Hash-based matching catches renamed files

Code References

ComponentFilePurpose
OneGameOneRomFiltersrc/romfarmer/dat/filter.pyCore 1G1R scoring algorithm
Filter1G1RStagesrc/romfarmer/stages/filter_1g1r.pyPipeline stage wrapper
DATSourcesrc/romfarmer/config/models.pyDAT source type enumeration
RetoolDATParsersrc/romfarmer/dat_parser/parser.pyParses Retool-enhanced DATs
ROMMatchersrc/romfarmer/dat_parser/matcher.pyMulti-strategy ROM matching
DatGamesrc/romfarmer/dat/__init__.pyGame model with parent/clone

Generated for ROM Farmer v2.0