EmuELEC / EmuELEC

EmuELEC, retro emulation for Amlogic devices. Based on CoreELEC. https://emuelec.org or join us on Discord: https://discord.gg/jQWCFwTn5T
https://emuelec.org
2.42k stars 396 forks source link

updated from 4.6 to 4.7: AUTO LOAD for PSX games not working anymore. #1313

Closed beta-tester closed 7 months ago

beta-tester commented 7 months ago

Describe the bug i updated my official EmuELEC v4.6 (installed in december 2023) to v4.7. on v4.6 i had Savestates "AUTO SAVE/LOAD" enabled. after the update to v4.7, if i start a PSX game, where an auto save state exists, the PSX emulator is loading and closes immediately and jumps back to the EmuELEC game list.

i also tried to deleted all auto save states, in hope EE v4.7 creates new save states the PSX emulator can load with auto save/load as the version 4.6. but even the new save states made under v4.7 shows the same strange behavior.

To Reproduce Steps to reproduce the behavior:

  1. go to [Start] | Main Menu | Game Settings | Savestates and enable Auto Save/Load
  2. in the PSX game list start a game and play it
  3. exit the game as usual to create an auto save state
  4. back to the PSX game list, start the same game again
  5. the emulator is loading and is closing again - you are back to the PSX game list
  6. with the game selected, hit "X" on the game pad to show the list of save states.
  7. start the last save state of the game.
  8. the emulator is loading and is closing again - you are back to the PSX game list emuelec (from savestate - load last state).log
  9. with the game selected, hit "X" on the game pad to show the list of save states.
  10. from the save state menu, use "Start New Game" instead of an existing state.
  11. the emulator is loading and and you are at the same position in the game as the last save state left the game. emuelec (from savestate - start new game).log
  12. go to [Start] | Main Menu | Game Settings | Savestates and disable Auto Save/Load.
  13. in the PSX game list start a game and start it as normal
  14. the game starts as expected from power on / reset state.

after step 17., the steps 7. to 14. still shows the strange behavior.

Expected behavior

  1. if "auto save/load" is enabled i expect to continue the game from the state where i left the game last time. but i jumed back to the PSX game list.
  2. if i start the last saved state i expect to continue the game from the state where i left the game last time. but i jumped back to the PSX game list.
  3. if i select "Start New Game" from the savestate menu, i expect to start a new game from power on/reset state. but i continued the game at the state where is left the game last time

EmuELEC version:

Device (please complete the following information):

shantigilbert commented 7 months ago

can you upload this file?

"/storage/playlists/logs/PCSX-ReARMed 32Bit/my favorit private psx game (1).lrtl"

beta-tester commented 7 months ago

can you upload this file?

not much in

{
  "version": "1.0",
  "runtime": "1:13:31",
  "last_played": "2024-02-21 22:24:49"
}
shantigilbert commented 7 months ago

Thanks for the report, it seems its a wider issue, not only affecting PSX but others as well

beta-tester commented 7 months ago

maybe it is "just" an array index +1 offset issue. if "Last Save State" loads "nothing", and "Start New Game" loads the "Last Save State".

so everything is shifted by one position. since the update to 4.7 the key mapping altered for some functions, i don't know how to create a second save state during game play manually. but if a second save state exists and you select the fist to load, will it start the game from the fist save state or the second save state?

Langerz82 commented 7 months ago
Full arguments: /storage/roms/psx/my favorit private psx game (1).chd -Ppsx --core --emulator --controllers=-p1index 0 -p1guid 030003f05e0400008e02000010010000 -wheel  -autosave 1 -state_slot -99

The core and emulator arguments are not being supplied, hence why it cannot load anything it seems.

Langerz82 commented 7 months ago

https://github.com/EmuELEC/emuelec-emulationstation/blob/EmuELEC/es-app/src/SaveState.cpp#L75 -1 should be -2 I think so emulator and core arguments get supplied. I will test this out.

Langerz82 commented 7 months ago

For fix and a possible workaround,

Workaround: I have not tested this but to get it working on the previous code, set the emulator and core in advanced game options and then it may use the config values and run savestates ok.

See: https://github.com/EmuELEC/emuelec-emulationstation/pull/92/

Langerz82 commented 7 months ago
3. if i select "Start New Game" from the savestate menu, i expect to start a new game from power on/reset state.
but i continued the game at the state where is left the game last time

I dont think the fix I provided covers this. For now delete the autosave then select "Start new game" .

beta-tester commented 7 months ago

at the moment i use:

and then i select [START NEW GAME] to continue the game at last save state. [START NEW GAME] is already selected so with this procedure i just need to do one button click more than before - it is acceptable as workaround.

if i really want to start a game from power on state, i reset the game. but normally i want to continue where i left the game.

Langerz82 commented 7 months ago

Give me some time to work this out. All the code is new to me.

miwasp commented 7 months ago

Can someone please test something? Create a file ".config/emulationstation/es_savestates.cfg" with the following contents, restart ES and test again:

<?xml version="1.0" encoding="UTF-8"?>
<savestates>
  <emulator name="libretro" autosave="true" incremental="true">
    <directory>/storage/roms/savestates/{{system}}</directory>
    <file>{{romfilename}}.state{{slot}}</file>
    <image>{{romfilename}}.state{{slot}}.png</image>
    <autosave_file>{{romfilename}}.state.auto</autosave_file>
    <autosave_image>{{romfilename}}.state.auto.png</autosave_image>
  </emulator>
</savestates>
miwasp commented 7 months ago

Background is that there was a major refactoring of savestates, see here: https://github.com/EmuELEC/emuelec-emulationstation/commit/4e33901a5bb8d9e979b408d76d155e343a4e8009 There seems to be no fallback to the old way it worked (or at least it does not work in EmuELEC). But there is now a new config file for savestates.

If this works, it is by far not a solution, its just a pointer in the right direction.

shantigilbert commented 7 months ago

Background is that there was a major refactoring of savestates, see here: EmuELEC/emuelec-emulationstation@4e33901 There seems to be no fallback to the old way it worked (or at least it does not work in EmuELEC). But there is now a new config file for savestates.

If this works, it is by far not a solution, its just a pointer in the right direction.

That is actually a good find, we missed it completely! :/

But I actually think this is the solution, unless we add a fallback, or completely revert this change.

shantigilbert commented 7 months ago

To fully confirm this is the issue, we could change the log to debug, and then look for this:

LOG(LogError) << "Could not parse es_savestates.cfg file!";
        LOG(LogError) << res.description();
Langerz82 commented 7 months ago

@miwasp I was looking for that file on the net everywhere and couldnt find it. Thanks i'll include it in my testing.

Langerz82 commented 7 months ago

I think I have a fix, although when having auto save/load in ES, when you select start new game, it loads from the auto-save if one is present. It's not a huge deal as you can just reset the game in retroarch menu, but it would be nice for it to work perfectly. Or you can disable auto save/load and it will always start the game at the start and then you can load the state from the ra menu.

Langerz82 commented 7 months ago

@shantigilbert I can make it so when selecting "Start new game" and "Start new autosave" always load from the start, but I will have to modify ES, and the scripts somewhat. Do you want me to do that, or are you ok with these functions loading the autosave state by default if auto save/load is enabled for save states?

shantigilbert commented 7 months ago

Well we first have to figure out what is really going on, because if this is a new feature (es_savestates.cfg), I think we should go with it and adopt it as we did with es_features.cfg , as to not have to generate future headaches

beta-tester commented 7 months ago

Can someone please test something? Create a file ".config/emulationstation/es_savestates.cfg" with the following contents, restart ES and test again: ...

@miwasp , the file you provided is working for me as well. thank you very much!!!

Langerz82 commented 7 months ago

@beta-tester So no need for the PR fixes? The xml file makes everything work correctly? That makes it allot easier if it does haha.

Quantum1997 commented 7 months ago

Can someone please test something? Create a file ".config/emulationstation/es_savestates.cfg" with the following contents, restart ES and test again:

<?xml version="1.0" encoding="UTF-8"?>
<savestates>
  <emulator name="libretro" autosave="true" incremental="true">
    <directory>/storage/roms/savestates/{{system}}</directory>
    <file>{{romfilename}}.state{{slot}}</file>
    <image>{{romfilename}}.state{{slot}}.png</image>
    <autosave_file>{{romfilename}}.state.auto</autosave_file>
    <autosave_image>{{romfilename}}.state.auto.png</autosave_image>
  </emulator>
</savestates>

Can someone please test something? Create a file ".config/emulationstation/es_savestates.cfg" with the following contents, restart ES and test again:

<?xml version="1.0" encoding="UTF-8"?>
<savestates>
  <emulator name="libretro" autosave="true" incremental="true">
    <directory>/storage/roms/savestates/{{system}}</directory>
    <file>{{romfilename}}.state{{slot}}</file>
    <image>{{romfilename}}.state{{slot}}.png</image>
    <autosave_file>{{romfilename}}.state.auto</autosave_file>
    <autosave_image>{{romfilename}}.state.auto.png</autosave_image>
  </emulator>
</savestates>

After trying this, for me it opens the game from the EE 4.6 savestates in Game savestate menu (it wasn't opening it before, just like in the case of the person posting this). Savestates from EE 4.6 are set to auto automatically (alltough I previously saved them as slot 0). I can load them if manually loading auto from Retroarch quick menu, but when trying to launch game from Emulation Station from the savestate icon, it launches the game, but just as if I normally launched it, not from the savestate

Also, I still cannot make it for savestates to be shown in EmulationStation savestates menu (it shows as if I would not have any savestate at all), but they exist and can be normally launched from Retroarch while in game

Quantum1997 commented 7 months ago

Can someone please test something? Create a file ".config/emulationstation/es_savestates.cfg" with the following contents, restart ES and test again:

<?xml version="1.0" encoding="UTF-8"?>
<savestates>
  <emulator name="libretro" autosave="true" incremental="true">
    <directory>/storage/roms/savestates/{{system}}</directory>
    <file>{{romfilename}}.state{{slot}}</file>
    <image>{{romfilename}}.state{{slot}}.png</image>
    <autosave_file>{{romfilename}}.state.auto</autosave_file>
    <autosave_image>{{romfilename}}.state.auto.png</autosave_image>
  </emulator>
</savestates>

Can someone please test something? Create a file ".config/emulationstation/es_savestates.cfg" with the following contents, restart ES and test again:

<?xml version="1.0" encoding="UTF-8"?>
<savestates>
  <emulator name="libretro" autosave="true" incremental="true">
    <directory>/storage/roms/savestates/{{system}}</directory>
    <file>{{romfilename}}.state{{slot}}</file>
    <image>{{romfilename}}.state{{slot}}.png</image>
    <autosave_file>{{romfilename}}.state.auto</autosave_file>
    <autosave_image>{{romfilename}}.state.auto.png</autosave_image>
  </emulator>
</savestates>

After trying this, for me it opens the game from the EE 4.6 savestates in Game savestate menu (it wasn't opening it before, just like in the case of the person posting this). Savestates from EE 4.6 are set to auto automatically (alltough I previously saved them as slot 0). I can load them if manually loading auto from Retroarch quick menu, but when trying to launch game from Emulation Station from the savestate icon, it launches the game, but just as if I normally launched it, not from the savestate

Also, I still cannot make it for savestates to be shown in EmulationStation savestates menu (it shows as if I would not have any savestate at all), but they exist and can be normally launched from Retroarch while in game

Also, forgot to mention that I also tried to create savestate on auto slot, but it still doesn't show it in ES savestates menu, it only shows the savestates that were made in EE 4.6

shantigilbert commented 7 months ago

@Quantum1997 The autosaves not loading is another bug that has been identified, it's because retroarch now creates the savestates in folders, ES does not know how to handle that, there is a setting in Retroarch to turn this off, Sort Save States into Folders by Content Directory turn it off, then create a savestate, try it, please try it and let us know.

shantigilbert commented 7 months ago

@Quantum1997 settings should be as follows, with the file provided by @miwasp you need to enable advance settings on Retroarch and then go to the Saving menu 20240223193845891

beta-tester commented 7 months ago

@Quantum1997 settings should be as follows, with the file provided by @miwasp you need to enable advance settings on Retroarch and then go to the Saving menu !

@shantigilbert on my settings this option is OFF - is this a must have or a should have option? with the es_savestates.cfg file, EE4.7 is creating auto save states and can auto load or manually load them from EE UI / SaveState Manager - even this option is not ON.

did you a fresh installation of EE4.7 from scratch or an update from EE4.6 to EE4.7? maybe some of my options are different because of the update.

shantigilbert commented 7 months ago

Right now, for it to work it needs to be exactly as the screenshot I provided, all settings on and off should be the same, and use the es_savestate.cfg file. A proper fix will follow soon, but for now it's just a matter of finding the correct configuration of settings.

Quantum1997 commented 7 months ago

@Quantum1997 settings should be as follows, with the file provided by @miwasp you need to enable advance settings on Retroarch and then go to the Saving menu 20240223193845891

I tried all sorts of combos (starting, of course, with what the screenshot provided). Unfortunately, none of this worked, and the situation is still the same. Fortunately, this doesn't bother me that much, as I used to load savestates from Retroarch anyway, and I guess I can give up the EE 4.6 savestates (didn't have that many of them anyway, the more important were the GBA/PS1 saves, witch work how they should so far).

The bigger problem is that of the 2nd controller not working from issue #1320 (that issue only talks about PSX, but the problem happens to all other consoles as well, except for the SNES whitch works normally for some reason). I used to play some games with a family member, but now we just can't do this anymore.

shantigilbert commented 7 months ago

The bigger problem is that of the 2nd controller not working from issue https://github.com/EmuELEC/EmuELEC/issues/1320

please don't mix issues, keep that discussion on that thread.

Langerz82 commented 7 months ago

Ok so looks like we need es_savestates.cfg + an ES code change to parse the save state filename, and script change to accept the parameter for backwards support for 4.6 and below savestates.

removed as not working and spam

@shantigilbert I just checked my <4.6 autosave files and the autosave filenames was *.state.auto so that shouldn't be the issue should it?

Also here is some fixes for emulator/core argument replacements: https://github.com/Langerz82/emuelec-emulationstation/pull/7

shantigilbert commented 7 months ago

@Langerz82 @miwasp the solution is even simpler than that, if we don't want to use es_savestates.cfg we just have to change one line 175 https://github.com/EmuELEC/emuelec-emulationstation/blob/a28697fc21b729ddc620f29afead80e5391d67fa/es-app/src/SaveState.cpp#L75

change it to if (slot >= -1 && this->config != nullptr && !config->isActiveConfig(game) && !racommands)

This was fixed by f.caruso after I explained the situation, this restores functionality as it was before the change, IF the es_savestates.cfg file does not exist.

If the es_savestates.cfg exists, we need to change a lot more, we need to modify the setsettings.sh file (which I already have) to read the new arguments and create the .auto save state to load.

example provided by f.caruso as well: https://github.com/RetroBat-Official/emulatorlauncher/blob/master/emulatorLauncher/Generators/LibRetro.StateFileManager.cs

advantages of es_savestates.cfg is flexibility, as it supports more emulators than just libretro, but we need to determine if it's something we want to use or not.

shantigilbert commented 7 months ago

btw both solutions need this change in setsettings.sh anyways

echo 'savestates_in_content_dir = "false"' >> ${RACONF}
echo 'sort_savefiles_by_content_enable = false"' >> ${RACONF}
echo 'sort_savefiles_enable = "false"' >> ${RACONF}
echo 'sort_savestates_by_content_enable = "false"' >> ${RACONF}
echo 'sort_savestates_enable = "false"' >> ${RACONF}

as to keep the savestate manager happy and actually show the states.

merryroc commented 7 months ago

Thank you shantigilbert! I'll try your solution and test it.

merryroc commented 7 months ago

Fixed for me, thanks. with this procedure: https://github.com/EmuELEC/EmuELEC/issues/1313#issuecomment-1962196701 Be sure to do that 👍 https://github.com/EmuELEC/EmuELEC/issues/1313#issuecomment-1962206161

bitnykk commented 3 months ago

updating to 4.7 broke several things for me, updates clearly needs WAY more testings !

djibux commented 1 month ago

@Quantum1997 settings should be as follows, with the file provided by @miwasp you need to enable advance settings on Retroarch and then go to the Saving menu 20240223193845891

I just faced that issue and solved it using the config file shared above. Strangely I must not activate the two "folders by content directory" options otherwise save states are stored in a subfolder (gb/gb or psx/psx instead of simply gb or psx).