Skip to content
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

New Emulator Integration Tutorial #169

Open
alexpalms opened this issue Jun 13, 2019 · 7 comments
Open

New Emulator Integration Tutorial #169

alexpalms opened this issue Jun 13, 2019 · 7 comments

Comments

@alexpalms
Copy link

Issue summary

I tried to integrate PSX emulator in gym-retro doing the following steps:

  • Add libretro emulator github repo as submodule inside repo-root/cores/
    • Add submodule in repo-root folder with appropriate name (e.g. psx) cd ./; git submodule add repo-url psx
    • Move it in the repo-root folder -> git mv psx cores/.
    • Edit .gitmodules adding ignore = dirty row and check paths and url
    • Verify the main folder including this repo as submodule has the correct folder structure, i.e. added submodule (psx) must be as other cores in ../.git/modules/custom-gym-retro/modules/
  • Add json file in repo-root/cores/
    • Edit struct high level name with emulator to be added name (e.g. Psx)
    • Edit lib attribute depending on the correspondent libretro Makefile TARGET_NAME variable (e.g. for the libretro-beetle-hw case TARGET_NAME = mednafen_psx )
    • Try to find ramBase value, the starting RAM address specific for the emulator (e.g. for snes9x is 0x7E0000 in hexadecimal = 8257536 in decimal, found in repo-root/cores/snes/libretro/libretro.h), delete the attribute from the JSON file if not found
    • Edit extension of ROMS (ext attribute), accordingly to the most diffused one
    • Edit keybinds, buttons and actions attributes accordingly to libretro controller listed in the specific emulator page
    • Edit types attribute TBD
  • Edit CMakeLists.txt file in repo-root
    • Add add_core(new-emulator-name lib-attribute) line around row 175, e.g. add_core(psx mednafen_psx)
  • Edit setup.py file in repo-root
    • Add emulator to platform_globs variable -> e.g. for Psx use platform_globs = ['*-%s/*' % plat for plat in ['Nes', 'Snes', 'Genesis', 'Psx', 'Atari2600', 'GameBoy', 'Sms', 'GameGear', 'PCEngine', 'GbColor', 'GbAdvance']]

Both the gym-retro-integration as well as the simple gym-retro are able to compile successfully, correctly showing also psx emulator. But both of them do not work, showing different, generic errors. Specifically the following one is obtained when executing python3 -m retro.examples.interactive --game GameName
Error:

Traceback (most recent call last):
  File "/home/alexpalms/anaconda3/envs/...lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/alexpalms/anaconda3/envs/.../lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/examples/interactive.py", line 262, in <module>
    main()
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/examples/interactive.py", line 257, in main
    ia = RetroInteractive(game=args.game, state=args.state, scenario=args.scenario)
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/examples/interactive.py", line 208, in __init__
    env = retro.make(game=game, state=state, scenario=scenario)
  File "/home/alexpalms/../aiw-gaming-platform/custom-gym-retro/retro/__init__.py", line 55, in make
    return RetroEnv(game, state, inttype=inttype, **kwargs)
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/retro_env.py", line 87, in __init__
    self.em = retro.RetroEmulator(rom_path)
RuntimeError: Could not load ROM

It would be great to have even a small tutorial on how to add a libretro emulator, or some indications on compatible commits/version of repo that can be found on libretro website.

System information

  • Mint 19
  • 3.6
  • 0.7.1
@alexpalms alexpalms changed the title New Emulator Integrator Tutorial New Emulator Integration Tutorial Jun 13, 2019
@alexpalms
Copy link
Author

PS: the rom I am using is a cue file where inside are listed 3 bin files (Tekken3)

@alexpalms
Copy link
Author

PPS:

System information
OS: Mint 19
Python version: 3.6
gym-retro version: 0.7.1

@christopherhesse
Copy link
Collaborator

If you build a simple C program that uses the core via the libretro API, are you able to load everything and run the ROM?

@alexpalms
Copy link
Author

Hello Christopher,

thanks for your reply. I didn't try it actually. I sense integrating another emulator already present in LibRetro shouldn't be so hard, for this reason I am suggesting adding a small section with a worked case in your docs. It would be of great help.

Maybe this step you are suggesting could also be described there as a preliminary development.

@christopherhesse
Copy link
Collaborator

Thanks for writing this guide! I agree it shouldn't be that hard, but definitely if you can't get the core to work without gym-retro, it won't be possible to get it to work with gym-retro.

@dota2heqiuzhi
Copy link

Hello Christopher,

thanks for your reply. I didn't try it actually. I sense integrating another emulator already present in LibRetro shouldn't be so hard, for this reason I am suggesting adding a small section with a worked case in your docs. It would be of great help.

Maybe this step you are suggesting could also be described there as a preliminary development.

Did you succeed in trying later? Do you need to modify the source code of gym-retro and then recompile it? I also want to run mame2003-plus-libretro in gym-retro, so I can train the game Double Dragon (Neo-Geo)

@MatPoliquin
Copy link

I recently integrated two emulators (Sega 32x and Saturn) into stable-retro (a fork of gym-retro)

I think this PR I made would help with your issues since it enables support for debug logging from within emulator cores. Moreover some cores will crash if they don't have log support (ex mame2003_plus)

Farama-Foundation/stable-retro#48

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

No branches or pull requests

4 participants