batocera-linux / batocera.linux

batocera.linux
https://batocera.org
Other
1.83k stars 466 forks source link

[v36][x86_64] RetroArch core settings saved without "retroarch" or "retroarchcore" prefix to batocera.conf by EmulationStation menu #8033

Open joerg-knitter opened 1 year ago

joerg-knitter commented 1 year ago

Out of curiosity how the Batocera configuration works in detail, I made experiments with the RetroArch C64 core.

Background information: The Batocera 36 settings for Libretro-VICE cores have the core parameter "vice_jiffydos" enabled by default. JiffyDOS is a fast loader that uses special kernal files to speed up the loading of disk games, but might make problems because it replaces the standard C64 kernal and does not support tape loading (according to Wiki information). If the files for JiffyDOS exist in the BIOS path, JiffyDOS will be enabled, and the start screen message of the C64 will show "JiffyDOS", otherwise, you get the original C64 start screen.

I created a file called "es_features_c64.cfg" in "/userdata/system/configs/emulationstation" with the following content to be able to enable or disable JiffyDOS via ES menu instead of adding a fixed line to the batocera.conf: `<?xml version="1.0" encoding="UTF-8" ?>

` In fact, the menu is being shown and I can enable and disable the JiffyDOS setting now.

But the line written to the batocera.conf, "c64.vice_jiffydos=disabled", seems to be incorrect because it does not work.

This is a summary of my testings:

It also confuses me, that if I enable the core option for cropping, the following is written to the batocera.conf - and in this case, it works withtout the "retroarchcore" in the middle: c64.vice_zoom_mode=small

Do you have any explanation for this behaviour?

Tested with Batocera 64-devel on SteamDeck.

EDIT: I might have found the reason: In the configgen file, you apparently only check for some keys like "vice_zoom_mode" with system.isOptSet and system.config, but not for all keys. "vice_jiffydos" is just set as RetroArch config with coreSettings.save without prior check in the batocera.conf. A working solution is to add the "retroarchcore" in front of the value parameter, i.e. set the parameter line to: <feature name="JiffyDOS" group="ADVANCED OPTIONS" value="retroarchcore.vice_jiffydos" description="Enable or disable the usage of the JiffyDOS kernal.">

nadenislamarre commented 1 year ago

not sure to understand all.

c64.retroarch.vice_jiffydos=disabled will add the vice_jiffydos option in the retroarch.cfg file with the disable value (you can check in /userdata/system/config/retroarch but i guess that what you want must go in a different file (not retroarch.cfg), something like the core.cfg or a name i don't remember. not sure there is a way to write on it.

see https://github.com/batocera-linux/batocera.linux/blob/master/package/batocera/core/batocera-configgen/configgen/configgen/generators/libretro/libretroConfig.py#L778

hum, maybe this one is a solution for you: https://github.com/batocera-linux/batocera.linux/blob/master/package/batocera/core/batocera-configgen/configgen/configgen/generators/libretro/libretroOptions.py#L2371

joerg-knitter commented 1 year ago

In my edit paragraph, you find the solution. When I added it, I was not sure if I should close the ticket. But I decided to keep it open because I think there is a problem with (in-)consistency of the settings (and lack of documentation at this moment). The JiffyDOS thing is just an example.

I want to explain the history of it: I was not aware myself what JiffyDOS was and how to use it until I learned that I had to copy the appropriate kernal files from https://restore-store.de/89-jiffydos to the bios/vice folder to be able to use it in general. What I did not expected was, that it is enabled by default, if the files are found. Therefore I wanted to disable it because it is a "special" extension that the minority of C64 users might have used back in the 80ies and might even cause incompatibilities.

The "Advanced Retroarch Settings" Wiki page says:

[...] Most RetroArch settings not mentioned in the default batocera.conf can be edited and saved from within RetroArch itself (accessed by pressing [HOTKEY] + South button (B SNES) while in-game in a Libretro core), these will be saved to /userdata/system/configs/retroarch/retroarchcustom.cfg (with core options being saved to retroarch/cores/retroarch-core-options.cfg instead), however the vast majority of RetroArch settings will be overridden by Batocera at emulator launch.

In order to use the configuration generator to create a RetroArch setting (letting Batocera know which value is being used, avoiding it being overwritten), follow the global.retroarch.retroarch_setting=value syntax. Batocera supports the massive majority of RetroArch's settings, but for the few that it doesn't (such as bleeding edge new features or obscure/forgotten ones), those settings can still be adjusted by editing them directly into /userdata/system/configs/retroarch/retroarchcustom.cfg as they will not be overwritten (at least, until Batocera supports them as well).

Therefore, I first changed the JiffyDOS setting in RetroArch and exited it, hoping that this was changed, but it always apparently got overwritten (it works if I save it as folder or game core setting, but not globally). On the other hand, no ES menu entry actually exists for this option. And so, the search for the reason began...

I followed the information on the mentioned page about setting core options. I added _global.retroarchcore.vicejiffydos=disabled to the batocera.conf, and this worked. But then, I am not able to change it on a per-game basis using EmulationStation.

Then, I started modifying the es_features.cfg and later learned from a discussion with Atari on your Discord channel that I can also use the overlay functionality to create custom es_features.cfg files in the userdata dir (not yet documented directly, but using a custom es_systems.cfg is explained in the Wiki...).

At this time, I used

\<feature name="JiffyDOS" group="ADVANCED OPTIONS" value="vice_jiffydos" description="Enable or disable the usage of the JiffyDOS kernal.>

i.e. no "prefix" to the "vice_jiffydos" parameter, and wonderered why it does not work while all other values in the original "es_features.cfg" also don´t use prefixes like "retroarch" or "retroarchcore". More confusing: Changing the core´s crop settings was possible from ES, but then, a line "c64.vice_zoom_mode=small" was added that worked, even though the "retroarchcore" prefix was missing.

This is rather confusing, and in the end, it is/was the libretroOptions.py:

coreSettings.save('vice_jiffydos', '"enabled"') ... if system.isOptSet('vice_zoom_mode'): if system.config['vice_zoom_mode'] == 'automatic': coreSettings.save('vice_crop', '"auto"') else: coreSettings.save('vice_crop', system.config['vice_zoom_mode']) else: coreSettings.save('vice_crop', '"auto_disable"')

So apparently, compared to the "vice_jiffydos" option, it is checked if there is a "vice_zoom_mode" option in the batocera.conf, and it is also set like this from the EmulationStation option.

In my opinion, the right behaviour would be that libretroOptions.py checks for "retroarchcore.vice_zoom_mode" and EmulationStation also writes "retroarchcore.vice_zoom_mode" instead of just "vice_zoom_mode". And regarding JiffyDOS: To the advanced user (not plug & play-only user), it is not clear when the global core options made in RetroArch are ignored i.e. reset by configgen. So a golden rule could be to add an option to ES whenever an option is pre-set by configgen.

So, to summarize it: The question of an advanced user might be:

My request could be to adjust the libretroOptions.py and es_features.cfg accordingly, and regarding the default C64 and C128 parameters, I might give some suggestions in a different ticket.