Load NON-PC rom with a script?
-
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. -
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
-
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 theemulators.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. -
@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 amy_own_script.sh
file that has the script command equivalent of "Load X specific SNES rom with thelr_snes9x
emulator"? 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
-
@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. -
@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
-
@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 usinglr-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.
-
@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
-
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 withlr_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
-
@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:
-
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
-
@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"
-
@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
-
@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
-
@clockwork42 My guess is that there's some ROM path quoting error at stake. Can you post your complete script, between code tags ?
-
@mitu Code tags? First I'm hearing of that. That's probably the thing I'm missing.
My
*.sh
file contains literally only the exact commands you quoted above. I know nothing about writing*.sh
files aside from what I've discussed with you in this thread.— CB
-
@clockwork42 said in Load NON-PC rom with a script?:
@mitu Code tags? First I'm hearing of that. That's probably the thing I'm missing.
No, it's not. I was referring to the
```
you put in forum posts to make code blocks stand out, not to the actual script content. -
@mitu said in Load NON-PC rom with a script?:
@clockwork42 said in Load NON-PC rom with a script?:
@mitu Code tags? First I'm hearing of that. That's probably the thing I'm missing.
No, it's not. I was referring to the
```
you put in forum posts to make code blocks stand out, not to the actual script content.Oh, sorry. My misunderstanding. At any rate, my
*.sh
file reads exactly the following:/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 triple-checked the path to be sure it's correct. To be clear, this is the code that seems to crash the loading process (where it's stuck on the gray box and I can't do anything).
Sorry again for the hassle. I appreciate your continued willingness to help.
— CB
-
@clockwork42 I know this thread is a few months old but figured out how to do exactly what I believe you are trying to do and I wanted to post it in case you or anyone else is still looking like I was up until recently.
I separated MSU-1 into a distinct system from the rest of SNES called "snesmsu1". Here is what my "/roms/snesmsu1" folder looks like:
For this setup you would also need to make a folder called "snesmsu1" at "/opt/retropie/configs/snesmsu1". You could copy the "snes" folder from "configs" as a starting point. I removed all emulators from "emulators.cfg" except for lr-snes9x and replaced the reference to "snes" with "snesmsu1" so that it looks like this:
lr-snes9x = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x/snes9x_libretro.so --config /opt/retropie/configs/snesmsu1/retroarch.cfg %ROM%" default = "lr-snes9x"
I also edit "retroarch.cfg" replacing the reference to "snes" with "snesmsu1" so that it looks like this:
# Settings made here will only override settings in the global retroarch.cfg if placed above the #include line input_remapping_directory = "/opt/retropie/configs/snesmsu1/" #include "/opt/retropie/configs/all/retroarch.cfg"
The crucial part that will make runcommand execute your 'rom.sh' files as scripts instead of trying to open them with the default emulator is the command node in your "es_systems.cfg" file. Here is what my system node for "snesmsu1" looks like, including the command:
<system> <name>snesmsu1</name> <fullname>Super Nintendo MSU1</fullname> <path>/home/pi/RetroPie/roms/snesmsu1</path> <extension>.sh .SH</extension> <command>bash %ROM%</command> <platform>snes</platform> <theme>snesmsu1</theme> </system>
With the above in your "es_systems.cfg" and a folder named snesmsu1 in your "roms" folder, you will have a separate section in EmulationStation for SNES MSU-1. You will also have to use a theme that has an "snesmsu1" section. Otherwise, you will have a blank, unthemed section for "snesmsu1".
Only '.sh' files in your "snesmsu1" folder will be displayed in this section in EmulationStation. Notice in my screenshot that the names of all the folders that contain the actual game files begin with a dot which makes them hidden in Linux so they aren't displayed in EmulationStaion. Your "gamelist.xml" file points to one of the '.sh' files in the "path" node for each game and then you can have all your metadata and media set up as well and everything will look pretty in EmulationStation.
Other than that, here is an example of what my 'Chrono Trigger (MSU-1).sh' looks like for launching the game:
#!/bin/bash "/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _SYS_ "snesmsu1" "/home/pi/RetroPie/roms/snesmsu1/.Chrono Trigger (MSU-1)/Chrono Trigger (MSU-1).sfc"
Because of the different commands in "es_systems.cfg" for launching regular SNES ROMs vs. running shell scripts, you really do need to separate MSU-1 into a different system from regular SNES. Actually, you could combine them, but if you want to keep things organized as described then you would have to create a similar shell script for each regular SNES ROM as well. I prefer to have them separated for aesthetics, organization and ease of use.
With everything configured as I described, EmulationStation looks nice and tidy and so does my "/roms/snesmsu1" folder. I hope this helps.
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.