Skip to content

Commit

Permalink
Fix: libretro System.dat BIOS assumption
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm committed Jul 11, 2024
1 parent c555d9a commit e363703
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
27 changes: 18 additions & 9 deletions src/modules/datScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,23 @@ export default class DATScanner extends Scanner {
return dat;
}

// Special case: if the DAT has only one game but a large number of ROMs, assume each of those
// ROMs should be a separate game. This is to help parse the libretro BIOS System.dat file
// which only has one game for every BIOS file, even though there are 90+ consoles.
if (dat.getGames().length === 1 && dat.getGames()[0].getRoms().length > 10) {
// Special case: if the DAT has only one BIOS game with a large number of ROMs, assume each of
// those ROMs should be a separate game. This is to help parse the libretro BIOS System.dat
// file which only has one game for every BIOS file, even though there are 90+ consoles.
if (dat.getGames().length === 1
&& dat.getGames()[0].isBios()
&& dat.getGames()[0].getRoms().length > 10
) {
const game = dat.getGames()[0];
dat = new LogiqxDAT(dat.getHeader(), dat.getGames()[0].getRoms().map((rom) => game.withProps({
name: rom.getName(),
rom: [rom],
})));
dat = new LogiqxDAT(dat.getHeader(), dat.getGames()[0].getRoms().map((rom) => {
// Use the ROM's filename without its extension as the game name
const { dir, name } = path.parse(rom.getName());
const gameName = path.format({ dir, name });
return game.withProps({
name: gameName,
rom: [rom],
});
}));
}

const size = dat.getGames()
Expand Down Expand Up @@ -348,7 +356,8 @@ export default class DATScanner extends Scanner {
name: gameName,
category: undefined,
description: game.description,
bios: undefined,
bios: cmproDat.clrmamepro?.author?.toLowerCase() === 'libretro'
&& cmproDat.clrmamepro?.name?.toLowerCase() === 'system' ? 'yes' : 'no',
device: undefined,
cloneOf: game.cloneof,
romOf: game.romof,
Expand Down
5 changes: 3 additions & 2 deletions src/types/dats/cmpro/cmProParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ExpectedError from '../../expectedError.js';
export interface DATProps extends CMProObject {
clrmamepro?: ClrMameProProps,
game?: GameProps | GameProps[],
resource?: GameProps | Resource[],
resource?: ResourceProps | ResourceProps[],
}

export interface ClrMameProProps extends CMProObject {
Expand Down Expand Up @@ -34,6 +34,7 @@ export interface GameProps extends CMProObject {
disk?: DiskProps | DiskProps[],
sample?: SampleProps | SampleProps[],
// NON-STANDARD PROPERTIES
comment?: string,
serial?: string,
publisher?: string,
releaseyear?: string,
Expand Down Expand Up @@ -61,7 +62,7 @@ export interface SampleProps extends CMProObject {
name: string,
}

export interface Resource extends GameProps {}
export interface ResourceProps extends GameProps {}

type CMProValue = CMProObject | string | undefined;

Expand Down

0 comments on commit e363703

Please sign in to comment.