feat(saves): save profiles on the title menu, each player with their own saves #1753

Open
scampsgt wants to merge 1 commit from scampsgt/Longshot:feat/save-profiles into main
First-time contributor

Type: feat · Risk: medium · Tested on: Windows 11, RTX 4070 Laptop (NVIDIA 617) · Needs: Linux, any GPU

TL;DR

Several people in one house share one Longshot install, so they overwrite each other's saves or rename folders by hand (#1742). This PR adds Choose Profile to the title menu, under Options. It opens a list of three named profiles, like the N64's three files, and each profile has its own autosaves, manual saves and options. I played it on Windows with a pad, the keyboard and the mouse: naming, switching, Copy and Erase all work, and the saves players already have show up as Profile 1, unchanged.

Breakdown

  • Who it helps: families and housemates who share one PC and one copy of the game.
  • What was wrong: the game has a single console user, so there is a single save folder for everyone.
  • What changes: a fourth title line, Choose Profile. It opens a game-styled list of three profiles, and picking another restarts the game as that profile.
  • What does not change: existing saves (they are Profile 1, in the same folder), the defaults, and every other menu. With one profile nothing looks different apart from the new line.
  • How it was checked: played on Windows on this branch built on current main, and on a v3.0.0 build with the same change. The game-free suite passes on Linux, apart from checks that also fail on main here (no clang++, tmp permissions).
  • What is still open: the Linux build and run.
  • Risk: medium: it touches the account HLEs, input and the menu overlay. A mistake shows up on the title screen or as the wrong save folder.

Why

On the N64 each player had their own file. Here everyone shares one save, so a second player has to back up and rename the save folder to keep their own adventure. #1742 asks for exactly this: "multiple savegame profiles or easier switching so we have it like the original game had".

What changed

Each profile is its own console user, uid {N, 0x5a3c9e1f0b7d2468}, and host/nn_fs.c already names save folders by uid. So Profile 1 is the user every build has had, and Profile N saves to save\5a3c9e1f0b7d2468000000000000000N. The title layout already has a fourth button, Pa_Button_03, that the game never shows. It is shown through the UI library's own visibility update, so the game aligns it and its own navigation reaches it. The renderer's overlay draws the line's words and the profile list.

  • account: host/nn_applet.c: TryOpenPreselectedUser, GetUserId, GetUserExistence and ListAllUsers answer with the chosen profile's uid (profile_uid, derived from user_uid). The first call waits until a profile is chosen.
  • profiles: new host/oot_files.c: the chosen profile (hos_file_wait, HOS_FILE, files.ini's last=), the title line's input gate (hos_profile_input: A on the line, and everything while the list is open, go to the list), and the row's position and mouse handed to the overlay.
  • title menu: host/oot_menu.c title_show_fourth / title_row_tick: shows Pa_Button_03 (wrapper flags +0xa8 bit 0, then f_8154c890, the library's visibility update) and places the row. While the list is open, mouse_tick_locked hands the pointer to the list instead of moving the title's focus.
  • input: host/nn_hid.c: hos_pad_poll (the pads read now) and the hos_profile_input call after hos_title_input.
  • overlay: gpu/vk/vk_menu.cpp namespace files: the profile list (names, last saved, Playing now, Copy, Erase to erased-files, an N64-style letter grid) with keys, pads (the game's bindings) and the mouse. profiles_tick restarts the game for another profile with the menu's Restart now (WM_APP + 9). Also draw_title_row, and menu_record / menu_record_image draw both.
  • gpu/vk/vk_replay.cpp present_image: stores the picture's rect (files_picture_rect) so the row and list sit on the game's picture in a letterboxed window.
  • ABI: gpu/vk/vk_api.h: MkwVkHost gains user_dir, pad_poll, file_chosen, title_row, profile_list_asked, profile_list_closed, current_file, profile_buttons and profile_pointer; MKWVK_API_VERSION 36. host/rx_backend.c fills them.
  • start: host/display.c calls hos_file_default after rx_start (window and headless). gpu/vk/vk_main.cpp starts as the last profile.
  • switches: HOS_FILE row in gpu/vk/switches.def. Docs: README, "Where the files go".
  • tests: fixtures that cut the changed functions get stand-ins for the new calls (input_background_test.c, present_geometry_trace_test.cpp, test_present_aspect.py, windows_display_startup_test.c). test_fps_overlay_order.py now also checks the order with the row and the list.

Measurements

Nothing to measure: a title-menu feature with no work in play (the title hook returns at once on other screens, and the overlay draws nothing while neither the row nor the list shows).

Flags and settings

One new diagnostic switch, for test runs.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
HOS_FILE starts the run as profile 1, 2 or 3 not read unset: the profile played last (Profile 1 when none) the run's save folder, without the menu helps scripted runs and the Test Farm keep to one profile leave unset for players

Testing

Tested: Windows 11, RTX 4070 Laptop, NVIDIA 617.

This branch built on current main (this PR @ 1e68fe4, the Builder running nx2/make_game.py from this tree): the title shows Choose Profile. I opened the list with the pad and clicked Profile 2 with the mouse. files.ini got last=2, the game restarted by itself, and the new run mounted save\5a3c9e1f0b7d24680000000000000002 and showed Choose Profile again.

Earlier, the full flow on a v3.0.0 build with the same change:

  • Down from Options reaches Choose Profile with the game's own focus, and A or a click opens the list. B, Esc or a right-click closes it with the focus left on the line.
  • Hovering and clicking the profiles, Copy, Erase, Yes/No, the letter grid, Back and End all work, as do the pad and the keys.
  • Naming Profile 2 on the grid writes files.ini. Choosing it restarts the game, which mounts ...0002, and the title shows New Game and Options with no Continue (no save yet). Choosing Profile 1 again brings back the original saves.
  • Copy copies a profile's saves, and Erase moves them to erased-files.

Game-free: python -I -B tests/run_all.py on Linux (WSL, gcc, no clang++). Every check this change touched passes: test_env_on, test_switch_table, test_fps_overlay_order, test_menu_text_field, test_options_budget_once, test_input_background, test_present_aspect, test_present_geometry_trace, test_windows_display_startup. The other failures here also fail on main in this environment (clang++ missing, tmp permissions). The changed host files compile with llvm-mingw clang (-fsyntax-only -Wall -Wextra, no new warnings).

Not tested:

  • Linux: the profile list's file handling and the restart use Win32 calls (CreateDirectoryA, MoveFileExA, PostMessageA), so it may need the POSIX side.
  • A save copied across profiles while the game writes one.

Must be tested:

  • Windows, any GPU: build this branch, press Down from Options to Choose Profile, name Profile 2, choose it, and save in game, expecting the save in save\5a3c9e1f0b7d24680000000000000002 and Profile 1's saves untouched (Test Farm: @Beanstalk windows, Choose Profile on the title: name and switch to Profile 2, then save).
  • Linux, any GPU: build and start, expecting the build to pass and the title to show Choose Profile; on a failure, the profile list's Win32 calls need their POSIX stand-ins (by hand: a Linux contributor, the build log and the title screen).

Risks

What could break: the title screen (the fourth line's visibility and focus), the account HLEs (a wrong uid means the wrong save folder: Profile 1 is uid 1, as before), input on the title while the row or list has it, and the Linux build (Win32 calls in the list).

Turning it off: revert the commit. Never opening Choose Profile keeps Profile 1, the existing saves.

Compatibility: saves are unchanged: Profile 1 is the existing folder, and new profiles add folders beside it plus save\files.ini. MKWVK_API_VERSION goes to 36, so the host and renderer must come from the same build (the builder builds both). longshot_options.ini is unchanged. Going back to a build without this PR plays Profile 1's saves, and the other profiles' folders are kept and ignored.

Issues

See #1742

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • MKWVK_API_VERSION bumped (gpu/vk/vk_api.h's MkwVkHost or MkwVkRenderer changed).
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Docs updated.
**Type:** feat · **Risk:** medium · **Tested on:** Windows 11, RTX 4070 Laptop (NVIDIA 617) · **Needs:** Linux, any GPU ## TL;DR Several people in one house share one Longshot install, so they overwrite each other's saves or rename folders by hand (#1742). This PR adds **Choose Profile** to the title menu, under Options. It opens a list of three named profiles, like the N64's three files, and each profile has its own autosaves, manual saves and options. I played it on Windows with a pad, the keyboard and the mouse: naming, switching, Copy and Erase all work, and the saves players already have show up as Profile 1, unchanged. ## Breakdown - **Who it helps:** families and housemates who share one PC and one copy of the game. - **What was wrong:** the game has a single console user, so there is a single save folder for everyone. - **What changes:** a fourth title line, Choose Profile. It opens a game-styled list of three profiles, and picking another restarts the game as that profile. - **What does not change:** existing saves (they are Profile 1, in the same folder), the defaults, and every other menu. With one profile nothing looks different apart from the new line. - **How it was checked:** played on Windows on this branch built on current `main`, and on a v3.0.0 build with the same change. The game-free suite passes on Linux, apart from checks that also fail on `main` here (no clang++, tmp permissions). - **What is still open:** the Linux build and run. - **Risk:** medium: it touches the account HLEs, input and the menu overlay. A mistake shows up on the title screen or as the wrong save folder. ## Why On the N64 each player had their own file. Here everyone shares one save, so a second player has to back up and rename the save folder to keep their own adventure. #1742 asks for exactly this: "multiple savegame profiles or easier switching so we have it like the original game had". ## What changed Each profile is its own console user, uid `{N, 0x5a3c9e1f0b7d2468}`, and `host/nn_fs.c` already names save folders by uid. So Profile 1 is the user every build has had, and Profile N saves to `save\5a3c9e1f0b7d2468000000000000000N`. The title layout already has a fourth button, `Pa_Button_03`, that the game never shows. It is shown through the UI library's own visibility update, so the game aligns it and its own navigation reaches it. The renderer's overlay draws the line's words and the profile list. - account: `host/nn_applet.c`: `TryOpenPreselectedUser`, `GetUserId`, `GetUserExistence` and `ListAllUsers` answer with the chosen profile's uid (`profile_uid`, derived from `user_uid`). The first call waits until a profile is chosen. - profiles: new `host/oot_files.c`: the chosen profile (`hos_file_wait`, `HOS_FILE`, `files.ini`'s `last=`), the title line's input gate (`hos_profile_input`: A on the line, and everything while the list is open, go to the list), and the row's position and mouse handed to the overlay. - title menu: `host/oot_menu.c` `title_show_fourth` / `title_row_tick`: shows `Pa_Button_03` (wrapper flags +0xa8 bit 0, then `f_8154c890`, the library's visibility update) and places the row. While the list is open, `mouse_tick_locked` hands the pointer to the list instead of moving the title's focus. - input: `host/nn_hid.c`: `hos_pad_poll` (the pads read now) and the `hos_profile_input` call after `hos_title_input`. - overlay: `gpu/vk/vk_menu.cpp` `namespace files`: the profile list (names, last saved, Playing now, Copy, Erase to `erased-files`, an N64-style letter grid) with keys, pads (the game's bindings) and the mouse. `profiles_tick` restarts the game for another profile with the menu's Restart now (`WM_APP + 9`). Also `draw_title_row`, and `menu_record` / `menu_record_image` draw both. - `gpu/vk/vk_replay.cpp` `present_image`: stores the picture's rect (`files_picture_rect`) so the row and list sit on the game's picture in a letterboxed window. - ABI: `gpu/vk/vk_api.h`: `MkwVkHost` gains `user_dir`, `pad_poll`, `file_chosen`, `title_row`, `profile_list_asked`, `profile_list_closed`, `current_file`, `profile_buttons` and `profile_pointer`; `MKWVK_API_VERSION` 36. `host/rx_backend.c` fills them. - start: `host/display.c` calls `hos_file_default` after `rx_start` (window and headless). `gpu/vk/vk_main.cpp` starts as the last profile. - switches: `HOS_FILE` row in `gpu/vk/switches.def`. Docs: README, "Where the files go". - tests: fixtures that cut the changed functions get stand-ins for the new calls (`input_background_test.c`, `present_geometry_trace_test.cpp`, `test_present_aspect.py`, `windows_display_startup_test.c`). `test_fps_overlay_order.py` now also checks the order with the row and the list. ## Measurements Nothing to measure: a title-menu feature with no work in play (the title hook returns at once on other screens, and the overlay draws nothing while neither the row nor the list shows). ### Flags and settings One new diagnostic switch, for test runs. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `HOS_FILE` | starts the run as profile 1, 2 or 3 | not read | unset: the profile played last (Profile 1 when none) | the run's save folder, without the menu | helps scripted runs and the Test Farm keep to one profile | leave unset for players | ## Testing **Tested:** Windows 11, RTX 4070 Laptop, NVIDIA 617. This branch built on current `main` (this PR @ 1e68fe4, the Builder running `nx2/make_game.py` from this tree): the title shows Choose Profile. I opened the list with the pad and clicked Profile 2 with the mouse. `files.ini` got `last=2`, the game restarted by itself, and the new run mounted `save\5a3c9e1f0b7d24680000000000000002` and showed Choose Profile again. Earlier, the full flow on a v3.0.0 build with the same change: - Down from Options reaches Choose Profile with the game's own focus, and A or a click opens the list. B, Esc or a right-click closes it with the focus left on the line. - Hovering and clicking the profiles, Copy, Erase, Yes/No, the letter grid, Back and End all work, as do the pad and the keys. - Naming Profile 2 on the grid writes `files.ini`. Choosing it restarts the game, which mounts `...0002`, and the title shows New Game and Options with no Continue (no save yet). Choosing Profile 1 again brings back the original saves. - Copy copies a profile's saves, and Erase moves them to `erased-files`. Game-free: `python -I -B tests/run_all.py` on Linux (WSL, gcc, no clang++). Every check this change touched passes: `test_env_on`, `test_switch_table`, `test_fps_overlay_order`, `test_menu_text_field`, `test_options_budget_once`, `test_input_background`, `test_present_aspect`, `test_present_geometry_trace`, `test_windows_display_startup`. The other failures here also fail on `main` in this environment (clang++ missing, tmp permissions). The changed host files compile with llvm-mingw clang (`-fsyntax-only -Wall -Wextra`, no new warnings). **Not tested:** - Linux: the profile list's file handling and the restart use Win32 calls (`CreateDirectoryA`, `MoveFileExA`, `PostMessageA`), so it may need the POSIX side. - A save copied across profiles while the game writes one. **Must be tested:** - Windows, any GPU: build this branch, press Down from Options to Choose Profile, name Profile 2, choose it, and save in game, expecting the save in `save\5a3c9e1f0b7d24680000000000000002` and Profile 1's saves untouched (Test Farm: @Beanstalk windows, Choose Profile on the title: name and switch to Profile 2, then save). - Linux, any GPU: build and start, expecting the build to pass and the title to show Choose Profile; on a failure, the profile list's Win32 calls need their POSIX stand-ins (by hand: a Linux contributor, the build log and the title screen). ## Risks **What could break:** the title screen (the fourth line's visibility and focus), the account HLEs (a wrong uid means the wrong save folder: Profile 1 is uid 1, as before), input on the title while the row or list has it, and the Linux build (Win32 calls in the list). **Turning it off:** revert the commit. Never opening Choose Profile keeps Profile 1, the existing saves. **Compatibility:** saves are unchanged: Profile 1 is the existing folder, and new profiles add folders beside it plus `save\files.ini`. `MKWVK_API_VERSION` goes to 36, so the host and renderer must come from the same build (the builder builds both). `longshot_options.ini` is unchanged. Going back to a build without this PR plays Profile 1's saves, and the other profiles' folders are kept and ignored. ## Issues See #1742 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] `MKWVK_API_VERSION` bumped (`gpu/vk/vk_api.h`'s `MkwVkHost` or `MkwVkRenderer` changed). - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Docs updated.
feat(saves): save profiles on the title menu, each player with their own saves
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
1e68fe4994
The title menu gets a fourth line, Choose Profile, under Options (the layout's Pa_Button_03, which the game never
shows, shown through the UI library's own visibility update). It opens a list drawn as the title's lines: three
profiles with names, Copy and Erase, a letter grid to name one, keys, pads and the mouse. Each profile is its own
console user, uid {N, 0x5a3c9e1f0b7d2468}, so profile 1 is the saves players already have and every autosave,
manual save and in-game option of another profile lives in its own save folder. Choosing another profile restarts
the game as it (the menu's Restart now). files.ini in the save folder keeps the names and the last profile.
HOS_FILE=1..3 picks one for test runs. MKWVK_API_VERSION 36.

See #1742.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dypn3L2qNTumSW4aRfXF8Y
Author
First-time contributor

Tested in game: Windows 11, RTX 4070 Laptop, NVIDIA 617, on a v3.0.0 build with this change (before the clean rebase onto main): title screen, Choose Profile with pad, keys and mouse; named Profile 2, switched to it (game restarted, mounted ...0002, no Continue), switched back to Profile 1 with its saves intact; Copy and Erase checked. A run of this branch's own main build is still to come.

Tested in game: Windows 11, RTX 4070 Laptop, NVIDIA 617, on a v3.0.0 build with this change (before the clean rebase onto main): title screen, Choose Profile with pad, keys and mouse; named Profile 2, switched to it (game restarted, mounted ...0002, no Continue), switched back to Profile 1 with its saves intact; Copy and Erase checked. A run of this branch's own main build is still to come.
Member

Possibly related, for context:

  • issue #229 Idea: multi profile support (Discord Idea) — Earlier request for named per-player save profiles
  • issue #913 Idea: Store save files per user account — Related request for save separation across OS accounts
Possibly related, for context: - issue #229 Idea: multi profile support (Discord Idea) — Earlier request for named per-player save profiles - issue #913 Idea: Store save files per user account — Related request for save separation across OS accounts
Author
First-time contributor

Ran this branch built on current main (@ 1e68fe4) on Windows 11, RTX 4070 Laptop: Choose Profile shows on the title; the list opened with the pad, a mouse click on Profile 2 restarted the game into save\5a3c9e1f0b7d24680000000000000002 with files.ini last=2. Description updated; Linux is still untested.

Ran this branch built on current main (@ 1e68fe4) on Windows 11, RTX 4070 Laptop: Choose Profile shows on the title; the list opened with the pad, a mouse click on Profile 2 restarted the game into save\5a3c9e1f0b7d24680000000000000002 with files.ini last=2. Description updated; Linux is still untested.
scampsgt changed title from WIP: feat(saves): save profiles on the title menu, each player with their own saves to feat(saves): save profiles on the title menu, each player with their own saves 2026-11-19 16:37:19 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
This pull request has changes conflicting with the target branch.
  • README.md
  • gpu/vk/vk_api.h
  • gpu/vk/vk_menu.cpp
  • gpu/vk/vk_menu.h
  • host/rx_backend.c
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/save-profiles:scampsgt-feat/save-profiles'
git switch 'scampsgt-feat/save-profiles'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1753
No description provided.