Skip to content

Commit

Permalink
Feature: "only" ROM filtering options for every "no" option (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Jul 24, 2023
1 parent 4a4508f commit 8569246
Show file tree
Hide file tree
Showing 6 changed files with 580 additions and 321 deletions.
82 changes: 39 additions & 43 deletions docs/rom-filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,44 +76,38 @@ Spain:

A game can only have one primary region. The first region detected is what is used.

### Only BIOS
### BIOS

```text
--only-bios
--no-bios, --only-bios
```

Games that are marked `bios="yes"` in the DAT, or contain `[BIOS]` in their name, e.g.:
Filter out, or only include games that are marked `bios="yes"` in the DAT, or contain `[BIOS]` in their name, e.g.:

```text
[BIOS] Nintendo Game Boy Boot ROM (World) (Rev 1)
[BIOS] Nintendo Game Boy Color Boot ROM (World) (Rev 1)
```

This option is best used for collating all BIOS files across all consoles to one directory.
!!! tip

### No BIOS
`--only-bios` is a great option to collate all BIOS files across all consoles to one directory.

```text
--no-bios
```

Opposite of the above. This will filter out files that are not games.

### No MAME devices
### MAME devices

```text
--no-device
--no-device, --only-device
```

Filters out [MAME devices](https://wiki.mamedev.org/index.php/MAME_Device_Basics). MAME devices typically represent physical devices, such as microcontrollers, video display controllers, sounds boards, and more. Many MAME devices don't have any associated ROM files.
Filter out, or only include [MAME devices](https://wiki.mamedev.org/index.php/MAME_Device_Basics). MAME devices typically represent physical devices, such as microcontrollers, video display controllers, sounds boards, and more. Many MAME devices don't have any associated ROM files.

### No unlicensed
### Unlicensed

```text
--no-unlicensed
--no-unlicensed, --only-unlicensed
```

Filters out games that contain `(Unl)` or `(Unlicensed)` in their name, e.g.:
Filter out, or only include games that contain `(Unl)` or `(Unlicensed)` in their name, e.g.:

```text
4 in 1 (Europe) (4B-002, Sachen) (Unl)
Expand Down Expand Up @@ -194,91 +188,91 @@ Enables all the following `--no-*` options, as well as filtering out games that
R-Type DX (U) [C][t2]
```

### No demos
### Demos

```text
--no-demo
--no-demo, --only-demo
```

Filters out games that contain `(Demo)` in their name, e.g.:
Filter out, or only include games that contain `(Demo)` in their name, e.g.:

```text
Coria and the Sunken City (Unknown) (Demo)
Two Hearts (Japan) (Demo) (Unl)
```

### No betas
### Betas

```text
--no-beta
--no-beta, --only-beta
```

Filters out games that contain `(Beta)` in their name, e.g.:
Filter out, or only include games that contain `(Beta)` in their name, e.g.:

```text
Cosmo Tank (Japan) (Beta)
F-15 Strike Eagle II (USA, Europe) (Beta) (July, 1992)
```

### No samples
### Samples

```text
--no-sample
--no-sample, --only-sample
```

Filters out games that contain `(Sample)` in their name, e.g.:
Filter out, or only include games that contain `(Sample)` in their name, e.g.:

```text
Mega Man III (USA) (Sample)
Shin Nihon Pro Wrestling - Toukon Sanjuushi (Japan) (Sample)
```

### No prototypes
### Prototypes

```text
--no-prototype
--no-prototype, --only-prototype
```

Filters out games that contain `(Proto)` or `(Prototype)` in their name, e.g.:
Filter out, or only include games that contain `(Proto)` or `(Prototype)` in their name, e.g.:

```text
Philip & Marlowe in Bloomland (USA) (Proto)
Sword of Hope, The (Europe) (Proto)
```

### No test ROMs
### Test ROMs

```text
--no-test-roms
--no-test-roms, --only-test-roms
```

Filters out games that contain `(Test)` in their name, e.g.:
Filter out, or only include games that contain `(Test)` in their name, e.g.:

```text
2097 ROM Pack II (USA) (Test Program)
Game Boy Test Cartridge (USA, Europe) (Proto) (Test Program)
```

### No homebrew
### Homebrew

```text
--no-homebrew
--no-homebrew, --only-homebrew
```

Filters out games that contain `(Homebrew)` in their name, e.g.:
Filter out, or only include games that contain `(Homebrew)` in their name, e.g.:

```text
Game Boy Camera Gallery 2022, The (World) (Aftermarket) (Homebrew)
GB-Wordyl (World) (Aftermarket) (Homebrew)
```

### No unverified dumps
### Unverified dumps

```text
--no-unverified
--no-unverified, --only-unverified
```

Filters out games that do _not_ contain `[!]` in their name, e.g.:
Filter out, or only include games that do _not_ contain `[!]` in their name, e.g.:

```text
Getaway, The (U)
Expand All @@ -287,23 +281,25 @@ Golf (W) [o1]
Grand Theft Auto (E) (M5) [C][t1]
```

Note that this is a [GoodTools](https://emulation.gametechwiki.com/index.php/GoodTools#Good_codes) naming convention, other groups such as [No-Intro](https://no-intro.org/) never include `[!]` in their names!
!!! warning

This is a [GoodTools](https://emulation.gametechwiki.com/index.php/GoodTools#Good_codes) naming convention, other groups such as [No-Intro](https://no-intro.org/) never include `[!]` in their names!

### No bad dumps
### Bad dumps

```text
--no-bad
--no-bad, --only-bad
```

Filters out games that contain `[b]` or `[b#]` in their name, e.g.:
Filter out, or only include games that contain `[b]` or `[b#]` in their name, e.g.:

```text
[MIA] Aprilia - DiTech Interface (Unknown) (Unl) [b]
Great Greed (U) [b1]
Gremlins 2 - The New Batch (W) [b2]
```

And also filters out games that contain `[c]` or `[x]` and are _not_ verified dumps (above), e.g.:
as well as games that contain `[c]` or `[x]` and are _not_ verified dumps (above), e.g.:

```text
Brian Lara Cricket 96 (E) [a1][x]
Expand Down
117 changes: 47 additions & 70 deletions src/modules/argumentsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,80 +364,57 @@ export default class ArgumentsParser {
type: 'string',
coerce: (val: string) => val.split(','),
requiresArg: true,
})
.option('only-bios', {
group: groupRomFiltering,
description: 'Filter to only BIOS files',
type: 'boolean',
conflicts: ['no-bios'],
})
.option('no-bios', {
group: groupRomFiltering,
description: 'Filter out BIOS files',
type: 'boolean',
conflicts: ['only-bios'],
})
.option('no-device', {
group: groupRomFiltering,
description: 'Filter out MAME devices',
type: 'boolean',
})
.option('no-unlicensed', {
group: groupRomFiltering,
description: 'Filter out unlicensed ROMs',
type: 'boolean',
})
});
[
['bios', 'BIOS files'],
['device', 'MAME devies'],
['unlicensed', 'unlicensed ROMs'],
].forEach(([key, description]) => {
yargsParser
.option(`no-${key}`, {
group: groupRomFiltering,
description: `Filter out ${description}, opposite of --only-${key}`,
type: 'boolean',
conflicts: [`only-${key}`],
})
.option(`only-${key}`, {
type: 'boolean',
conflicts: [`no-${key}`],
hidden: true,
});
});
yargsParser
.option('only-retail', {
group: groupRomFiltering,
description: 'Filter to only retail releases, enabling all the following options',
type: 'boolean',
})
.option('no-demo', {
group: groupRomFiltering,
description: 'Filter out demo ROMs',
type: 'boolean',
})
.option('no-beta', {
group: groupRomFiltering,
description: 'Filter out beta ROMs',
description: 'Filter to only retail releases, enabling all the following "no" options',
type: 'boolean',
})
.option('no-sample', {
group: groupRomFiltering,
description: 'Filter out sample ROMs',
type: 'boolean',
})
.option('no-prototype', {
group: groupRomFiltering,
description: 'Filter out prototype ROMs',
type: 'boolean',
})
.option('no-test-roms', {
group: groupRomFiltering,
description: 'Filter out test ROMs',
type: 'boolean',
})
.option('no-aftermarket', {
group: groupRomFiltering,
description: 'Filter out aftermarket ROMs',
type: 'boolean',
})
.option('no-homebrew', {
group: groupRomFiltering,
description: 'Filter out homebrew ROMs',
type: 'boolean',
})
.option('no-unverified', {
group: groupRomFiltering,
description: 'Filter out un-verified ROMs',
type: 'boolean',
})
.option('no-bad', {
group: groupRomFiltering,
description: 'Filter out bad ROM dumps',
type: 'boolean',
})
});
[
['demo', 'demo ROMs'],
['beta', 'beta ROMs'],
['sample', 'sample ROMs'],
['prototype', 'prototype ROMs'],
['test-roms', 'test ROMs'],
['aftermarket', 'aftermarket ROMs'],
['homebrew', 'homebrew ROMs'],
['unverified', 'unverified ROMs'],
['bad', 'bad ROM dumps'],
].forEach(([key, description]) => {
yargsParser
.option(`no-${key}`, {
group: groupRomFiltering,
description: `Filter out ${description}, opposite of --only-${key}`,
type: 'boolean',
conflicts: [`only-${key}`],
})
.option(`only-${key}`, {
type: 'boolean',
conflicts: [`no-${key}`],
hidden: true,
});
});

yargsParser
.option('single', {
group: groupRomPriority,
alias: 's',
Expand Down
16 changes: 15 additions & 1 deletion src/modules/candidateFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import Module from './module.js';
* {@link Parent}.
*
* This class may be run concurrently with other classes.
*
* TODO(cemmer): this should be a DAT filter, there's nothing ReleaseCandidate specific about this,
* it doesn't do anything based on found files.
*/
export default class CandidateFilter extends Module {
private readonly options: Options;
Expand Down Expand Up @@ -96,20 +99,31 @@ export default class CandidateFilter extends Module {
&& this.options.getFilterRegexExclude()?.test(game.getName()),
this.noLanguageAllowed(releaseCandidate),
this.regionNotAllowed(releaseCandidate),
this.options.getOnlyBios() && !game.isBios(),
this.options.getNoBios() && game.isBios(),
this.options.getOnlyBios() && !game.isBios(),
this.options.getNoDevice() && game.isDevice(),
this.options.getOnlyDevice() && !game.isDevice(),
this.options.getOnlyRetail() && !game.isRetail(),
this.options.getNoUnlicensed() && game.isUnlicensed(),
this.options.getOnlyUnlicensed() && !game.isUnlicensed(),
this.options.getNoDemo() && game.isDemo(),
this.options.getOnlyDemo() && !game.isDemo(),
this.options.getNoBeta() && game.isBeta(),
this.options.getOnlyBeta() && !game.isBeta(),
this.options.getNoSample() && game.isSample(),
this.options.getOnlySample() && !game.isSample(),
this.options.getNoPrototype() && game.isPrototype(),
this.options.getOnlyPrototype() && !game.isPrototype(),
this.options.getNoTestRoms() && game.isTest(),
this.options.getOnlyTestRoms() && !game.isTest(),
this.options.getNoAftermarket() && game.isAftermarket(),
this.options.getOnlyAftermarket() && !game.isAftermarket(),
this.options.getNoHomebrew() && game.isHomebrew(),
this.options.getOnlyHomebrew() && !game.isHomebrew(),
this.options.getNoUnverified() && !game.isVerified(),
this.options.getOnlyUnverified() && game.isVerified(),
this.options.getNoBad() && game.isBad(),
this.options.getOnlyBad() && !game.isBad(),
].filter((val) => val).length === 0;
}

Expand Down
Loading

0 comments on commit 8569246

Please sign in to comment.