Skip to content

Added support for multiple transferpak games #570

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

JPZV
Copy link

@JPZV JPZV commented Mar 9, 2025

Description

This PR adds support for loading different GB games on transferpak for each controller. This allows, for example, to play Pokemon Red for P1, Blue for P2, and Yellow for P3 on Pokemon Stadium

How it works (For the End-User)

Until now, you had to have both the .gb and .sav files alongside the N64 ROM (and with the same name), having this structure:

roms/
  n64/
    pokemon stadium.z64
    pokemon stadium.z64.gb
    pokemon stadium.z64.sav

But now you have to create a .pak folder and inside place the .gb and .sav files for every controller, naming them from 1.gb to 4.gb. For example:

roms/
  n64/
    pokemon stadium.z64
    pokemon stadium.z64.pak/
      1.gb
      1.sav
      2.gb
      2.sav
      3.gb
      3.sav
      4.gb
      4.sav

Also, you can combine both the old and the new methods (the newer one has higher priority). For example:

roms/
  n64/
    pokemon stadium.z64
    pokemon stadium.z64.gb
    pokemon stadium.z64.sav
    pokemon stadium.z64.pak/
      1.gb
      1.sav

With that, only the first player will have a different ROM while other players will use the same pokemon stadium.z64.gb ROM.

How it's implemented (for Libretro maintainers)

Now the global variables retro_transferpak_rom_path and retro_transferpak_ram_path are string arrays of fixed length of 4 (one for each controller). Then, on startup, the core will search for each .gb and .sav file (naming from 1 to 4) inside the {GAME_FILE_NAME}.pak folder. If there is no .gb or .sav file for that controller, then it'll rollback to the old method and, in case there are those files, it'll assign those files for that specific controller.

So, in pseudo code, it'd be something like this:

rom_path[4], ram_path[4] as array of char*;
for (i = 0 to 4)
{
  if (file_exists("{GAME_FILENAME}.pak/{i}.gb")
  {
    rom_path[i] = "{GAME_FILENAME}.pak/{i}.gb";
    if (file_exists("{GAME_FILENAME}.pak/{i}.sav")
    {
      ram_path[i] = "{GAME_FILENAME}.pak/{i}.sav";
    }
  }
  if (empty(rom_path[i]) or empty(ram_path[i]))
  {
    if (file_exists("{GAME_FILENAME}.gb")
    {
      rom_path[i] = "{GAME_FILENAME}.gb";
      if (file_exists("{GAME_FILENAME}.sav")
      {
        ram_path[i] = "{GAME_FILENAME}.sav";
      }
    }
  }
}

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.

1 participant