• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Load NON-PC rom with a script?

Scheduled Pinned Locked Moved Help and Support
script requestshell scriptloading gamessnes
24 Posts 3 Posters 2.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    clockwork42
    last edited by 25 Feb 2020, 02:53

    Hello all!

    I've been enhancing a bunch of SNES roms with MSU-1 recently. For those who don't know, this entails having a bunch of large files in the same exact folder as the rom itself. Because of this, my choices are to either keep thousands of large files in my /snes/ directory, or to house each MSU rom in its own subdirectory.

    Neither of these is particularly appetizing as an option. I'd vastly prefer emulationstation to display my folder as if every rom was in the /snes/ directory. Which leads me to the question at hand.

    I was wondering if I could just stick my MSU roms into subfolders hidden from emulationstation (say... /snes2/) and just call them with scripts, as one might do for a PC game. If memory serves, emulationstation might hide *.sh and similar extensions in the /snes/ folder. I've found a bunch of info here and elsewhere regarding how to set this up for PC games, but I'm still a newbie at this and have no idea how to call a SNES game from a script. Seems like there's not much call for that sort of thing......

    Anyway, if someone could provide me some help putting together basic script to call a SNES game rom and remind me how to make the emulationstation folder display that type of script file, that would be absolutely fantastic.

    Thanks for being such a great resource, guys!

    — CB

    1 Reply Last reply Reply Quote 0
    • M
      mitu Global Moderator
      last edited by 25 Feb 2020, 06:01

      The list of extensions shown in the gamelist is a per-system configuration - look in /etc/emulationstation/es_systems.cfg. For SNES, the .sh extension is not taken into account, so files with these extension are 'hidden' in the list. If you want additional files to be shown (besides the ones already configured), you'll have to modify the es_systems.cfg - it's detailed in the Docs.

      Anyway, if someone could provide me some help putting together basic script to call a SNES game rom and remind me how to make the emulationstation folder display that type of script file, that would be absolutely fantastic.

      How are you running the MSU games ? Aren't they just regular ROMs ?

      1 Reply Last reply Reply Quote 0
      • C
        clockwork42
        last edited by 25 Feb 2020, 06:12

        Thanks Mitu!

        Yes, they are regular SNES roms. The only necessity is that they have to boot with plain lr-snes9x as the newer snes9x versions do not support MSU-1. I've set them to do this from each game's individual launch menu, but I don't know if that's important for the script.

        Thanks!

        — CB

        1 Reply Last reply Reply Quote 0
        • M
          mitu Global Moderator
          last edited by 25 Feb 2020, 06:15

          lr-snes9x IS the latest SNES9x version and the one supporting MSU games.
          If you've already configured the ROMs to start with lr-snes9x, isn't that what you wanted ? Why you need an extra launching script in this case ?

          C 1 Reply Last reply 25 Feb 2020, 06:21 Reply Quote 0
          • C
            clockwork42 @mitu
            last edited by clockwork42 25 Feb 2020, 06:21

            @mitu Each MSU-enabled game has 40+ individual files that need to be placed in the exact same directory. If I want all of my games to be listed without folders in emulationstation, then I have to find a workaround.

            I thought that if I could create a new folder in the roms directory (like /roms/snes-msu1/ or similar), I could store the game files in there, individually foldered and separated, while using scripts in the /roms/snes/ directory to load their games. That way, everything could be organized, but all the games would be listed in emulationstation without the need for folders (especially since emulationstation hides the other files, so each game folder would appear to have only one file in it).

            Hope that helps!

            — CB

            P.S. -- My mistake about lr-snes9x. I thought the ones with the years were newer rather than older. Hence my having to install lr-snes9x manually.

            1 Reply Last reply Reply Quote 0
            • M
              mitu Global Moderator
              last edited by mitu 25 Feb 2020, 06:41

              Since .msu and .pcm files are not valid SNES games extensions, can't you just copy them next to the patched .sfc files, without a game folder ? Only the .sfc file would be listed and no folders are necessary.

              C 1 Reply Last reply 25 Feb 2020, 06:52 Reply Quote 0
              • C
                clockwork42 @mitu
                last edited by 25 Feb 2020, 06:52

                That would in theory work out fine, aside from that the \snes\ directory would look insane if I ever needed to access the pi directly to find anything in there. Right now I've got at least a dozen MSU games, so it's probably somewhere in the realm of 600-800+ individual files. All of that in one folder is a daunting prospect for me.

                That was the reason I was interested in the scripting. It just struck me as an elegant workaround to get the best of both worlds. I just have no idea what an appropriate script setup or the appropriate commands would be. I've tried to search here and elsewhere, but to no avail, hence posting. Anything you can point me to on that front would be greatly appreciated.

                — CB

                1 Reply Last reply Reply Quote 0
                • M
                  mitu Global Moderator
                  last edited by 25 Feb 2020, 18:05

                  Well, the launcher used by RetroPie is called runcommand - see https://retropie.org.uk/docs/Runcommand/. It's responsible for knowing which emulator to run (and what parameters are needed) and much more.
                  Now, runcommand is far too complex to modify it, but it provides a a way to run your particular emulator. For a system, the list of emulators available are listed in the system's configuration folder, in the emulators.cfg file. For instance, for SNES, it's in \\retropie\configs\snes\emulators.cfg.
                  You can add your own script - as an emulator - and in that script perform any actions you want (change folders, hide/unhide files, etc.).

                  Let's say you want to launch a SNES game. You add your own script as an emulator in the emulators.cfg:

                  lr-snes9x2002 = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x2002/snes9x2002_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg %ROM%"
                  lr-snes9x2005 = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x2005/snes9x2005_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg %ROM%"
                  lr-snes9x2010 = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x2010/snes9x2010_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg %ROM%"
                  default = "lr-snes9x"
                  lr-snes9x = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg %ROM%"
                  
                  # your own emulator
                  snes9x-msu = "/home/pi/scripts/my_own_script.sh %ROM%"
                  

                  In the my_own_script.sh file, you can perform any operations you want, then - at the end of the script - just call the real emulator start command:

                  #!/usr/bin/env bash
                  #... you own commands
                  # start the real emulator
                  /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg "$1"

                  Once your script is ready - test it from the command line, outside of EmulationStation - it can be chosen from the Runcommand launch menu, just like you've chosen lr-snes9x for those MSU games.

                  C 1 Reply Last reply 26 Feb 2020, 03:45 Reply Quote 0
                  • C
                    clockwork42 @mitu
                    last edited by 26 Feb 2020, 03:45

                    @mitu Thanks! That's definitely the sort of info I was looking for, but I'm not sure that I made my request totally clear. I'll try to keep it simple.

                    Let's say I don't change anything in the emulators.cfg file. Instead of messing with that, can I just hypothetically write a my_own_script.sh file that has the script command equivalent of "Load X specific SNES rom with the lr_snes9xemulator"? So every time I click that script or run it from the command line, it just loads one specifically designated game in snes9x?

                    I wasn't intending to make a script that makes sure all msu games load with lr_snes9x. Rather, I was just trying to figure out how to make an individual script that upon activation simply loads one pre-specified SNES rom with that emulator.

                    I hope that helps. I'm very sorry if this has been frustrating. That was absolutely not my intention. Thank you very much for your patience with my bizzare request.

                    — CB

                    M 1 Reply Last reply 26 Feb 2020, 04:32 Reply Quote 0
                    • M
                      mitu Global Moderator @clockwork42
                      last edited by 26 Feb 2020, 04:32

                      @clockwork42 said in Load NON-PC rom with a script?:

                      I wasn't intending to make a script that makes sure all msu games load with lr_snes9x. Rather, I was just trying to figure out how to make an individual script that upon activation simply loads one pre-specified SNES rom with that emulator.

                      But this is exactly what runcommand.sh does - you can choose which emulator runs for each ROM. This association is saved after the first configuration, so you don't have to do it twice. You can remove the per-ROM emulator setting anytime by entering the Runcommand launch menu again (when launching a ROM) and removing the association.

                      C 1 Reply Last reply 26 Feb 2020, 15:08 Reply Quote 0
                      • C
                        clockwork42 @mitu
                        last edited by 26 Feb 2020, 15:08

                        @mitu OK. Then that part I'm pretty good with. I've already set each of my MSU roms to open with snes9x by pushing a button when the game loads, going into the menu and making sure snes9x is the default for that rom.

                        So then the question becomes this: Is there a way to create a hypothetical my_own_script.sh that when accessed just loads a specific rom? I think at this point, that's all I need now. You explained how to load PC games that way to me some time ago, but I'm sure that the commands are drastically different for SNES roms since we don't have to worry about mounting drives, changing directories, and so on.

                        Thanks again for your time.

                        — CB

                        M 1 Reply Last reply 26 Feb 2020, 15:30 Reply Quote 0
                        • M
                          mitu Global Moderator @clockwork42
                          last edited by 26 Feb 2020, 15:30

                          @clockwork42 If you're looking for the exact command to start a ROM, you can look in emulators.cfg to see the complete command used. For instance, starting a SNES ROM using lr-snes as emulator is done by executing

                          /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg _ROM_PATH_
                          

                          Otherwise, I don't understand what's the question here.

                          1 Reply Last reply Reply Quote 0
                          • C
                            clockwork42
                            last edited by 27 Feb 2020, 02:22

                            @mitu said in Load NON-PC rom with a script?:

                            /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so --config /opt/retropie/configs/snes/retroar

                            I'm pretty sure that's all I was looking for. I didn't realize it was in the emulators.cfg file unless you said that before and I missed it. That should just about do it. Thanks again.

                            I'll try doing what I need to do and if I run into any issues, I'll let you know here.

                            — CB

                            1 Reply Last reply Reply Quote 0
                            • C
                              clockwork42
                              last edited by 27 Feb 2020, 19:46

                              @mitu

                              OK, I got most of the way there. I edited my es_systems.cfg to be sure *.sh files aren't hidden in the \snes\ directory.

                              So I wrote an *.sh file to try to run the Chrono Trigger rom with lr_snes9x as we discussed. The file consists of just the code you wrote in your latest reply to me, excepting that I put my actual rom path instead of where you wrote _ROM_PATH_. However, the file will not boot. I get the gray box that you normally get before booting a rom (press a button to config), but it never actually loads.

                              Here is the exact code of my present document, chrono_test.sh:

                              /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg /home/pi/RetroPie/roms/snes/Chrono Trigger/chrono_msu1.sfc
                              

                              I'm sure it's some kind of silly and easily-corrected error, but I have no idea where that error is. I know that the capitalization is correct. Perhaps it's the space in the "Chrono Trigger" file folder that's causing the issue?

                              Once the game loads, I'll be good. Thanks again for your patience with me!

                              — CB

                              M 1 Reply Last reply 27 Feb 2020, 19:56 Reply Quote 0
                              • M
                                mitu Global Moderator @clockwork42
                                last edited by 27 Feb 2020, 19:56

                                @clockwork42 said in Load NON-PC rom with a script?:

                                Perhaps it's the space in the "Chrono Trigger" file folder that's causing the issue?

                                Yes, you need to quote the ROM name:

                                /opt/retropie/emulators/retroarch/bin/retroarch \
                                -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so \
                                --config /opt/retropie/configs/snes/retroarch.cfg \
                                "/home/pi/RetroPie/roms/snes/Chrono Trigger/chrono_msu1.sfc:
                                C 1 Reply Last reply 27 Feb 2020, 22:50 Reply Quote 0
                                • C
                                  clockwork42 @mitu
                                  last edited by clockwork42 27 Feb 2020, 22:50

                                  @mitu

                                  I put in the code you listed, and it seems like snes9x loads, but the rom itself doesn't. I definitely make it into the emulator because I can use hotkey commands (e.g. fast-forward) and pull up the Retroarch menu, but it's just a black screen and nothing ever happens or loads.

                                  Also, I thought that the colon in your code after the rom path might have been a typo and meant to be a close-quotation, so I tried that, but it led to the same result. I also tried putting everything in a new path with no spaces in it. That didn't seem to change anything, and I'm sure the new path listed in the *.sh file is correct.

                                  To be clear, the code you copied above is the only code in my *.sh file, save for the adjusted path.

                                  We're definitely getting there. Thanks again for your help and patience.

                                  — CB

                                  M 1 Reply Last reply 28 Feb 2020, 05:16 Reply Quote 0
                                  • M
                                    mitu Global Moderator @clockwork42
                                    last edited by 28 Feb 2020, 05:16

                                    @clockwork42 The colon : at the end is a mistake, it supposed to be a closed quote.

                                    /opt/retropie/emulators/retroarch/bin/retroarch \
                                    -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so \
                                    --config /opt/retropie/configs/snes/retroarch.cfg \
                                    "/home/pi/RetroPie/roms/snes/Chrono Trigger/chrono_msu1.sfc"
                                    C 1 Reply Last reply 28 Feb 2020, 23:54 Reply Quote 0
                                    • C
                                      clockwork42 @mitu
                                      last edited by 28 Feb 2020, 23:54

                                      @mitu said in Load NON-PC rom with a script?:

                                      /opt/retropie/emulators/retroarch/bin/retroarch
                                      -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so
                                      --config /opt/retropie/configs/snes/retroarch.cfg
                                      "/home/pi/RetroPie/roms/snes/Chrono Trigger/chrono_msu1.sfc"

                                      I copied and pasted exactly this to my shell file, restarted the pi, and tried it. It still brings me to a black screen, but I can load the Retroarch menu and input any function assigned to hotkeys. The path you listed is correct, and the game loads fine if I click on it from the /snes/folder, so I have no idea what is keeping the script from fully loading the game.

                                      — CB

                                      1 Reply Last reply Reply Quote 0
                                      • C
                                        clockwork42
                                        last edited by clockwork42 3 Jan 2020, 04:04 1 Mar 2020, 04:02

                                        @mitu
                                        A slight correction because I realized I altered something.

                                        I made a wholly new *.sh file and used your code as-is (with corrected quotations) just to be sure I didn't screw something up. Entering into Emulationstation, picking Super Nintendo, and then selecting the *.sh file has the following effect. It looks like it's loading a rom. I get the gray text box that says:

                                        Launching chrono_test (lr-snes9x2010) ...
                                        
                                        Press a button to configure
                                        
                                        Errors are logged to /dev/shm/runcommand.log
                                        

                                        If I do not press a button quickly, this seems to freeze. The only way I know to escape this is to manually turn the Pi off and on again.

                                        If I press a button quickly and configure it then to select lr_snes9x, I can get past the gray box and the emulator seems to load, but the game doesn't. THAT is what brings me to the black screen where Retroarch and hotkey options are enabled, but I otherwise cannot do anything.

                                        Hope that helps diagnose the problems a bit better.

                                        — CB

                                        M 1 Reply Last reply 1 Mar 2020, 10:36 Reply Quote 0
                                        • M
                                          mitu Global Moderator @clockwork42
                                          last edited by 1 Mar 2020, 10:36

                                          @clockwork42 My guess is that there's some ROM path quoting error at stake. Can you post your complete script, between code tags ?

                                          C 1 Reply Last reply 1 Mar 2020, 16:49 Reply Quote 0
                                          3 out of 24
                                          • First post
                                            3/24
                                            Last post

                                          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.

                                            This community forum collects and processes your personal information.
                                            consent.not_received