Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option for user-provided .cmd file for libretroMAME #13216

Merged

Conversation

tsankuanglee
Copy link
Contributor

@tsankuanglee tsankuanglee commented Jan 12, 2025

MAME supports many different systems with variations in parameter logic. Currently libretroMAMEConfig captures common cases but there are still too many exceptions.

(edit: now incorporating @dmanlfc's suggestion)

Custom .cmd file contents

This PR adds the possibility to let user provide custom raw parameters to pass to libretroMAME in a custom .cmd file.For example, the file /userdata/roms/apple2/Where in the World is Carmen Sandiego (1985)/Where in the World is Carmen Sandiego (disc 1).dsk.cmd has the following contents:

apple2ee -gameio joy -flop1 "/userdata/roms/apple2/Where in the World is Carmen Sandiego (1985)/Where in the World is Carmen Sandiego (disc 1).dsk" -flop2 "/userdata/roms/apple2/Where in the World is Carmen Sandiego (1985)/Where in the World is Carmen Sandiego (disc 2).dsk" -rompath "/userdata/bios/" -ui_active -cfg_directory "/userdata/saves/mame/cfg/apple2ee" -inipath "/userdata/saves/mame/mame/ini"

In this example, when users launches disk 1 from the menu, disk 2 is also loaded in floopy 2. There is no need to pause the game, change game/menu focus, open retroarch/MAME's file manager from the menu to change disks back and forth, close the menu, restore the focus, and then resume the game. (The particular game above is a good example since it requires such a change for each round.)

Other use cases include user provided hard drive image for booting plus a menu-selected CD-ROM image, multiple hard drives with multiple floppy drives, different hardware requirement for different games, etc.

Location of the .cmd file

If provided, this .cmd file needs to reside beside the ROM file, but with an additional .cmd extension. For example, for the floppy disk image:

/userdata/roms/apple2/Where in the World is Carmen Sandiego (1985)/Where in the World is Carmen Sandiego (disc 1).dsk

Batcoera will look for the cmd file at:

/userdata/roms/apple2/Where in the World is Carmen Sandiego (1985)/Where in the World is Carmen Sandiego (disc 1).dsk.cmd

@dmanlfc
Copy link
Collaborator

dmanlfc commented Jan 12, 2025

this requires users to manually update the .conf file which is not ideal.
probably a better solution is to detect the .cmd file and use that automatically...

@tsankuanglee
Copy link
Contributor Author

@dmanlfc good point. I'll add that as well.

@tsankuanglee
Copy link
Contributor Author

Thanks @dmanlfc . I added your suggestion and updated the original description above.

cmdFile.write(' '.join(str(item) for item in commandLine))
cmdFile.close()
# Check to see whether user provided a custom cmd file, at either a default location, or specified in batocera.conf
defaultCustomCmdFilepath = f'{rom}.cmd'
Copy link
Contributor

@bryanforbes bryanforbes Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If use rom.with_suffix(f'{rom.suffix}.cmd'), you'll get a path object and won't need to use Path() on the next line

Copy link
Contributor Author

@tsankuanglee tsankuanglee Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename variable is used again in line 460 when copying. If we use that, we'll have to construct the filename again for line 460, no?

That said, I condensed this section for brevity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my bad. I see your point now. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol. too late. I have other stuff to push and will include this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryanforbes

To me, the current version

if Path(defaultCustomCmdFilepath := f"{rom}.cmd").is_file():

is slightly easier to understand than:

if (defaultCustomCmdFilepath := rom.with_suffix(f"{rom.suffix}.cmd")).is_file():

I did look into pathlib's source code and saw that a new construction is fairly cheap so the performance isn't really an issue.

I see you have another PR about using the Path object throughout. I think I'll leave this one for you to decide.

@dmanlfc
Copy link
Collaborator

dmanlfc commented Jan 16, 2025

@tsankuanglee we shouldn't need system.isOptSet("cmdfile"): as i said earlier it means people have to modify the batocera.conf file manually which is not good. i would prefer that it just uses the associated .cmd file in the rom directory.

@tsankuanglee
Copy link
Contributor Author

tsankuanglee commented Jan 16, 2025

@dmanlfc Feature removed as advised.

The way I saw it: users who need advanced options, such as assigning two harddrives, or any changes not available through the UI, will have to edit batocera.conf anyway.

However, I now agree with you that offering too much customization might be too confusing.

@dmanlfc dmanlfc merged commit cbcc288 into batocera-linux:master Jan 16, 2025
@tsankuanglee tsankuanglee deleted the custom-cmdfile-for-libretroMAME branch January 16, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants