Skip to content

gui: remember last played game when it is the first list entry - #435

Merged
Wolf3s merged 1 commit into
ps2homebrew:wOPL-basefrom
DarthMotzkus:fix/remember-last-played-first-entry
Sep 13, 2026
Merged

Wolf3s merged 1 commit into
ps2homebrew:wOPL-basefrom
DarthMotzkus:fix/remember-last-played-first-entry

Conversation

@DarthMotzkus

Copy link
Copy Markdown
Contributor

Problem

With "remember last played" enabled, exactly one game per device list is never restored,
and the Last Played Auto Start countdown never fires for it. Which game that is looks
arbitrary from the outside: it is whichever entry ends up at index 0 of the unsorted list,
which in practice is usually the most recently copied ISO.

Cause

updateMenuFromGameList() flags the remembered game with submenu.selected, and
GUI_OP_APPEND_MENU turns that flag into menu->remindLast. That branch is chained as an
else if to the "first subitem in list" case:

if (!item->menu.menu->submenu) { // first subitem in list
    ...
} else if (item->submenu.selected) { // remember last played game feature
    ...
    item->menu.menu->remindLast = 1;

When the remembered game is the first item appended, the first branch consumes it and
remindLast is never set. GUI_OP_SORT then runs:

if (!item->menu.menu->remindLast)
    item->menu.menu->current = item->menu.menu->submenu;

and the cursor goes back to the top of the alphabetically sorted list. The same branch
also holds the DisableCron = 0 that releases the auto start counter, so that never fires
for this entry either.

Which entry sits at index 0 is not visible to the user: sbReadList() stores the ul.cfg
entries first, and scanForISO() prepends each entry while walking the directory, so the
last file readdir() returns is the one that ends up first.

Fix

Split the chain into two independent ifs. Behaviour is unchanged for every other entry;
for index 0 the second block simply re-assigns the same node and raises remindLast.

Testing

Reproduced on real hardware with the most recently copied ISO on an MMCE device: the game
id was written to wopl_last_played.cfg correctly, but the list always opened on the first
entry and no auto start countdown appeared. With this patch the same game is restored as
the selected item and the countdown shows up. Every other game in the list behaves exactly
as before.

🤖 Generated with Claude Code

The last played game is flagged with submenu.selected while the list is
being appended, and GUI_OP_APPEND_MENU turns that flag into remindLast.
That branch is an "else if" chained to the "first subitem in list" case,
so when the remembered game happens to be index 0 of the unsorted list
the first branch consumes it and remindLast is never set. GUI_OP_SORT
then sees remindLast == 0 and resets current to the head of the sorted
list, so that one game is never restored, and the Last Played Auto Start
counter is never released for it either.

Which entry is index 0 is not visible to the user: sbReadList() places
ul.cfg entries first and scanForISO() prepends while walking the
directory, so it is typically the most recently copied ISO.

Split the chain into two independent ifs. Behaviour is unchanged for
every other entry; for index 0 the second block just re-assigns the same
node and raises remindLast.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Wolf3s

Wolf3s commented Sep 12, 2026

Copy link
Copy Markdown
Member

Problem

With "remember last played" enabled, exactly one game per device list is never restored, and the Last Played Auto Start countdown never fires for it. Which game that is looks arbitrary from the outside: it is whichever entry ends up at index 0 of the unsorted list, which in practice is usually the most recently copied ISO.

Cause

updateMenuFromGameList() flags the remembered game with submenu.selected, and GUI_OP_APPEND_MENU turns that flag into menu->remindLast. That branch is chained as an else if to the "first subitem in list" case:

if (!item->menu.menu->submenu) { // first subitem in list
    ...
} else if (item->submenu.selected) { // remember last played game feature
    ...
    item->menu.menu->remindLast = 1;

When the remembered game is the first item appended, the first branch consumes it and remindLast is never set. GUI_OP_SORT then runs:

if (!item->menu.menu->remindLast)
    item->menu.menu->current = item->menu.menu->submenu;

and the cursor goes back to the top of the alphabetically sorted list. The same branch also holds the DisableCron = 0 that releases the auto start counter, so that never fires for this entry either.

Which entry sits at index 0 is not visible to the user: sbReadList() stores the ul.cfg entries first, and scanForISO() prepends each entry while walking the directory, so the last file readdir() returns is the one that ends up first.

Fix

Split the chain into two independent ifs. Behaviour is unchanged for every other entry; for index 0 the second block simply re-assigns the same node and raises remindLast.

Testing

Reproduced on real hardware with the most recently copied ISO on an MMCE device: the game id was written to wopl_last_played.cfg correctly, but the list always opened on the first entry and no auto start countdown appeared. With this patch the same game is restored as the selected item and the countdown shows up. Every other game in the list behaves exactly as before.

🤖 Generated with Claude Code

I will review it by tomorrow.

@Wolf3s
Wolf3s merged commit 4ae7414 into ps2homebrew:wOPL-base Sep 13, 2026
27 checks passed
@Wolf3s

Wolf3s commented Sep 13, 2026

Copy link
Copy Markdown
Member

Merged, it seems fine.

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.

2 participants