batocera-linux / batocera.linux

batocera.linux
https://batocera.org
Other
1.94k stars 497 forks source link

Batocera user config does not hash on both softName and media Type #11781

Open udance4ever opened 3 months ago

udance4ever commented 3 months ago

Batocera build version

39oup 2024/03/04 10:11

Your architecture

x86_64

Your Graphic Processor Unit(s) (GPU)

Integrated Intel Iris Graphics

Issue description

While defining a new MAME software list coco_cass.xml to complement new functionality in #11706, batocera.conf only hashes on software name:

adam["zaxxon.zip"].altromtype=cass1

So it is not possible to go into Advanced Game Options for both the cassette and cartridge formats and define altRomType to be both cass1 and flop1 independently in batocera.conf (grep zaxxon /usr/bin/mame/hash/adam*.xml):

adam_cass.xml:  <software name="zaxxon">
adam_flop.xml:  <software name="zaxxon">

The workaround for new software titles to use a unique name:

coco_cass.xml:  <software name="zaxxon1">
coco_flop.xml:  <software name="zaxxon">

Long-term, I feel it would be good to upgrade batocera.conf so it hashes on both software name and media type to support existing MAME software lists (eg. adam):

adam["zaxxon.zip",cass].altromtype=cass1
adam["zaxxon.zip",flop].altromtype=flop1

or something along these lines.

Detailed reproduction steps

  1. touch /userdata/roms/coco/zaxxon.zip (blank rom is okay to reproduce)
  2. touch /userdata/roms/coco/cas/zaxxon.zip
  3. update gamelists
  4. observe Batocera Linux is able to keep both softwares unique in ES
  5. go into Advanced Game Options for rom in step 3 and change it’s media type to “Cassette”
  6. go into Advanced Game Options for rom in step 2 and observe media type is already set to “Cassette”
  7. tail /userdata/system/batocera.conf
  8. last line should be:
    coco["zaxxon.zip"].altromtype=cass
  9. notice hash is only based on software name

Details of any attempts to fix this yourself

Use unique software names for new software:

coco_cass.xml:  <software name="zaxxon1">
coco_flop.xml:  <software name="zaxxon">

No known workaround exists for current software titles (eg. adam) where this is valid in MAME:

adam_cass.xml:  <software name="zaxxon">
adam_flop.xml:  <software name="zaxxon">

Details of any modifications you have made to Batocera.

  1. overlay - persist changes made for #11706
  2. pro - directory exists but pro-custom.sh is disabled
  3. user - CasaOS service

Logs and data

I can attach on request but I do think this issue can be reproduced very easily.

dmanlfc commented 3 months ago

@nadenislamarre something to consider...

nadenislamarre commented 3 months ago

basically, when you have 2 times the same game, in two different folders ?

udance4ever commented 3 months ago

to clarify: it happens when you have the same game (eg. Zaxxon) distributed on two different types of media (eg. disk and cassette) (which in turn, you are correct - must reside in two different folders to not clobber)

Perhaps an idea would be for batocera.conf to support lines like this:

coco["zaxxon.zip"].altromtype=flop1
coco["cas/zaxxon.zip"].altromtype=cass

it’s not pretty but do think it’s the easiest to implement. If anyone else has ideas, put them out there…

udance4ever commented 3 months ago

hey i was poking through our wiki and found syntax introduced in v34:

nes.folder["/userdata/roms/nes/Japan/"].shaderset=Mega-Bezel-Community-JP-Night

so I added these two lines in batocera.conf and rebooted:

coco.folder["/userdata/roms/coco/cas/"].softList=none
coco.folder["/userdata/roms/coco/cas/"].altromtype=cass

Tried to launch cas/zaxxon.zip but for some reason, it didn’t override:

coco[”zaxxon.zip”].softList=coco_flop

It was worth a try. In the meantime, I’ve added a “1” (eg. cas/zaxxon1.zip) to avoid clobbering as coco_cass.xml is not merged into the MAME distribution yet.

udance4ever commented 2 months ago

I drafted a pull request to init a new coco cassette software list in the general MAME distribution (mamedev/mame#12505) incorporating the workaround I implemented so cassettes were named zaxzon1.zip (to prevent clobbering disks named zaxxon.zip in Batocera) & got this feedback:

The appending of "1" to all software names will not be accepted. The issue should be addressed in Batocera rather than adding meaningless numbers to names.

So the ball remains in our court to ensure an identically named software item available in multiple media formats (eg cassette & disk) can peacefully co-exist & have independent options in batocera.conf

here is how MAME reportedly creates unique hashes (an implementation idea to enhance batocera.conf to use : perhaps):

MAME accepts a root XML as input of a SW item, so:

./mame coco3 coco_flop:zonx Will load the floppy version of Zonx, while

./mame coco3 coco_cass:zonx Will (hopefully) load the cassette version of it.

ICEknigh7 commented 2 months ago

Wouldn't the simplest way to handle this to just refer to software list items as softlist_name-item_name?

In the example above, the games would just become coco_flop-zonx and coco_cass-zonx.

udance4ever commented 2 months ago

Wouldn't the simplest way to handle this to just refer to software list items as softlist_name-item_name?

given softlist_name-item_name.zip is in itself a valid name of a piece of software, a different delimiter would need to be chosen.

I honestly think the simplest way out is to use subdirectory names (since this is exactly how it shows up in the EDIT METADATA popup for any game in ES):

IMG_2497

this technically uses the slash (/) as a natural delimiter in batocera.conf:

coco["zonx.zip"].altromtype=flop1
coco["cas/zonx.zip"].altromtype=cass

The enhancement implemented in this way would have the added benefit of making it possible for multiple MAME romsets to co-exist:

mame["cryptklr.zip"].core=mame
mame["cryptklr.zip"].emulator=mame
mame["mame2010/cryptklr.zip"].core=mame0139
mame["mame2010/cryptklr.zip"].emulator=libretro
udance4ever commented 2 months ago

ok i found the class method that hardcodes the basename of the ROM in settings: https://github.com/batocera-linux/batocera.linux/blob/6b94014d434280d12b2a18bec2f210b5d1fc0d42/package/batocera/core/batocera-configgen/configgen/configgen/Emulator.py#L77-L86

this should work for line 79:

rom = os.path.relpath(rom, batoceraFiles.ROMS + "/" + self.name)

and the parallel method in Batocera ES (es-app/src/FileData.cpp):

const std::string FileData::getConfigurationName()
{
    std::string gameConf = Utils::FileSystem::getFileName(getPath());
    gameConf = Utils::String::replace(gameConf, "=", "");
    gameConf = Utils::String::replace(gameConf, "#", "");
    gameConf = getSourceFileData()->getSystem()->getName() + std::string("[\"") + gameConf + std::string("\"]");
    return gameConf;
}

so line 113 is replaced with (taken from es-app/src/guis/GuiMetaDataEd.cpp)

std::string gameConf = Utils::FileSystem::createRelativePath(getPath(), getSourceFileData()->getSystem()->getRootFolder()->getPath(), true);
if (Utils::String::startsWith(gameConf, "./"))
        gameConf = gameConf.substr(2);
else
        gameConf = Utils::FileSystem::getFileName(getPath());