Loading ROM completely while displaying launch image
-
Cheers,
inspired by @Fummlah's thread about Loading Rom completely while displaying video splash, I finally did something similar with launch images, which I wanted to do for quite some time.
Aaand like with many things, it was much easier than I thought. Just edit
/opt/retropie/supplementary/runcommand/runcommand.sh
and search for one of these lines (in the current version of the file, they're line #941 and #945):feh -F -N -Z -Y -q "$image" & &>/dev/null
… if you're running Retropie on an X desktop system, or
fbi -1 -t "$IMAGE_DELAY" -noverbose -a "$image" </dev/tty &>/dev/null
… if you're running the official Retropie image without a desktop "behind" it.
Simply add a
& disown
with a leading space at the end of this line. This will detach this command from the script, so that the latter won't wait for the image viewer to finish. Instead, it will continue to load the game while the image is displayed. As a nice bonus, the game will come up even if the launch image delay chosen in the Run Command Configuration is longer than the game needs to load.For anyone who may find this useful, please keep in mind that a) this is about the launch images whose names end with
-launching
, not the games' screenshots ending with-image
, and b) the modifiedruncommand.sh
may be overwritten by an update, so you'd have to add the&
again.Sure, it's sort of a dirty hack, but finally, the launch image won't waste precious time by pausing the loading of the game.
If anyone knows a more elegant way to do this (e.g. without modifying one of Retropie's official scripts), feel free to share it here.
-
Update: A single
&
did the job, but led to problems with keyboard inputs afterwards. This seems to be fixed by& disown
to truly disconnect the task from the script's terminal. I updated my opening post accordingly. (For the records, I triednohup
at the beginning of the line before, but the image wasn't visible then.) -
Update: Since editing Retropie's
runcommand.sh
is a dirty hack that can be reverted any time if this file is being updated by the developers, here's a way to use the runcommand-onstart.sh instead.One way to edit this file is the command
nano /opt/retropie/configs/all/runcommand-onstart.sh
. Add this at its end:launchpic="$(dirname ${3})/images/launching/$(basename $3 .zip)-launching.png" fbi -1 -t 12 -noverbose -a "$launchpic" </dev/tty &>/dev/null &
The first line will change the path and filename of the game's rom to that of the launch image. The second line invokes Retropie's framebuffer picture viewer like
runcommand.sh
does, albeit with a trailing&
that runs it as a background process so it doesn't pause the loading of the game.The above solution assumes that your launch images reside in a sub-subdirectory
images/launching
in your rom directory, e.g./home/pi/RetroPie/roms/arcade/images/launching
.However this will create a strange behavior of the keyboard's
Enter
key in the emulator, which is especially annoying in MAME'sTab
menu: Pressing Enter will either exit the Emulator or do other strange things like running Emulation Station a second time. It seems like another terminal is running in the background that reacts to the keyboard inputs in the running game. (?) I don't understand why simply running the image viewer as a background task will create this behaviour.Alas, and contrary to my last post,
& disown
will not fix it. After nearly two hours of research and testing, I'm giving up. My current workaround and recommendation is to use the first controller's button that also starts games in Emulation Station instead of the Enter key in MAME's Tab menu. It works without problems for me.If anyone can explain why putting
fbi
in the background leads to problems with the Enter key in at least RetroArch's MAME cores, or why usingnohup
doesn't display the image at all, and even with fbi's options-T
and-d
to choose a particular terminal or framebuffer, please share your wisdom with me and anyone else interested here. -
Thanks for this @Clyde. I actually like the first method much better, can you advise on what actions/processes will modify or reset the
runcommand.sh
file? -
I spoke too soon, the first method also completely detaches the keys being pressed from the display when entering console or quitting ES...
If I quit ES after running a game with the modification done to the
runcommand.sh
as specified in the original post, the keys I press don't show at all but they're there, if I press enter I'll get a message according that what was typed.The keyboard seems to behave properly on emulators though, keys register on Retroarch and games with a text parser like Sierra games in ScumVM or Amiga
Sorry to tag you @mitu, but is this something that can be explored as an enhancement? it would be great to have the launching image display while the rom is loading in the background, giving the impression of a faster load.
Thanks! -
@GeekOB said in Loading ROM completely while displaying launch image:
Sorry to tag you @mitu, but is this something that can be explored as an enhancement? it would be great to have the launching image display while the rom is loading in the background, giving the impression of a faster load.
Isn't this already supported - https://retropie.org.uk/docs/Runcommand/#adding-custom-launching-images ?
-
@mitu said in Loading ROM completely while displaying launch image:
Isn't this already supported - https://retropie.org.uk/docs/Runcommand/#adding-custom-launching-images ?
Thanks for replying @mitu, this is supported in the link you provide but to a degree, the rom doesn't start loading until the actual launching image has disappeared. The purpose of the hack above is to get the image to display the whole time while the rom loads.
The& disown
at the end offbi -1 -t "$IMAGE_DELAY" -noverbose -a "$image" </dev/tty &>/dev/null
in the
runcommand.sh
file, andlaunchpic="$(dirname ${3})/images/launching/$(basename $3 .zip)-launching.png" fbi -1 -t 12 -noverbose -a "$launchpic" </dev/tty &>/dev/null &
added to the
runcommand-onstart.sh
file do exactly that but they have undesirable keyboard side effects as explained above.We were wondering if there could be a cleaner way to achieve this?
Thanks! -
@GeekOB said in Loading ROM completely while displaying launch image:
Thanks for replying @mitu, this is supported in the link you provide but to a degree, the rom doesn't start loading until the actual launching image has disappeared. The purpose of the hack above is to get the image to display the whole time while the rom loads.
Honestly, I don't see the point of using a splash image while the rom loads.
I mean, if loading time/speed is an issue, then just disable the runcommand launch menu and the emulator will start right away. Using an image display program will 'swallow' the input anyway, so the runcommand launch menu wouldn't work reliably - might as well disable it. -
@mitu Maybe we just perceive differently what "right away" is. On my normal clocked Pi 3b, depending on the rom and emulator (mostly mame2003-plus, fbneo and some popular 8 & 16 bit consoles), I usually stare at a blank black screen for 10-15 seconds. That is long enough to make guests ask if the game crashed or something.
Instead, a loading image while the emulator starts would give us something interesting to look at. I'm using flyers and boxart for this, not mere logos or a "loading ..." image, so there's plenty to look at or read until the game actually starts.
Besides our differences about neccessity, do you happen to know why starting the image viewer as a background task leads to the strange effects @GeekOB and experienced, and how they could be addressed?
Thanks in advance for any enlightenment in this matter.
-
@Clyde said in Loading ROM completely while displaying launch image:
. On my normal clocked Pi 3b, depending on the rom and emulator (mostly mame2003-plus, fbneo and some popular 8 & 16 bit consoles), I usually stare at a blank black screen for 10-15 seconds.
That's abnormally long. Does this happen with the runcommand launch menu disabled ?
[..]
Besides our differences about neccessity, do you happen to know why starting the image viewer as a background task leads to the strange effects @GeekOB and experienced, and how they could be addressed?
My guess is that the STDIN (standard input) is 'stolen' by
fbi
, so any inputs (keyboard mainly) are not interpreted by the program which you expect (emulator or runcommand). Try running the command vianohup
and feed-it/dev/null
as STDIN/STDOUT. -
Thanks very much for the recommendation @mitu. @Clyde explains it much better than me. My wait time is definitely less than 10-15 seconds, more like 5-10, but that will vary with the emulator. Maybe you have a lot of emulator/system override customization @Clyde? this would slow the startup for sure.
Maybe this is not the case with a 3b+ and even less with the Pi4 but adding an image with useful information to read/look at helps with "masking" the wait time. -
Sorry for the long delay, my Retropie related activities were severely limited in the last months, and this issue wasn't among the urgent ones. That said, it is still nagging at me, so I'd like to give it another try.
@mitu said in Loading ROM completely while displaying launch image:
That's abnormally long. Does this happen with the runcommand launch menu disabled ?
It does, depending on the emulator. While most libretro console cores load in 7-9 seconds, lr-mame2003-plus and lr-fbneo take 10-13 seconds. I just tested it again to be sure, with the runcommand menu disabled, but artwork enabled to measure the time after the artwork disappears.
My guess is that the STDIN (standard input) is 'stolen' by
fbi
, so any inputs (keyboard mainly) are not interpreted by the program which you expect (emulator or runcommand). Try running the command vianohup
and feed-it/dev/null
as STDIN/STDOUT.Using
nohup
resulted in the image not being displayed, see my posts above:@Clyde said in Loading ROM completely while displaying launch image:
(For the records, I tried
nohup
at the beginning of the line before, but the image wasn't visible then.)@Clyde said in Loading ROM completely while displaying launch image:
If anyone can explain why putting
fbi
in the background leads to problems with the Enter key in at least RetroArch's MAME cores, or why usingnohup
doesn't display the image at all, and even with fbi's options-T
and-d
to choose a particular terminal or framebuffer, please share your wisdom with me and anyone else interested here.Although I'm planning to upgrade my cab to a Pi 4 in the near future, which hopefully should shorten the loading times, I am still interested to solve this irritant conundrum.
-
I'll preface this by saying that I am not a scripter/coder and I am sure there is a much better/cleaner way of doing it. I merely pieced things together that I found here and there. What's nice is that there is no modifications to any files that could be lost due to an update (i.e.
runcommand.sh
) and I am still convinced that this can all be made to work in a single script (runcommand-onstart.sh
)...right now I rely on a 2nd script to do the heavy lifting.I'd love for this to be a collaboration and maybe we can make this thing rock. :)
If you guys are still interested in this, I am going to post a how-to for how I am doing it. This is part of an overall solution that I am working on that will...
- Display the launch image until the game starts (not wait for the launch image to close before starting the game)
- Start the game...
a. Paused (via bash script). This can be skipped if you want the game to completely load past the initialization screens like arcade ROMS have.
b. Muted (via global Retroarch setting). I do this because I am unable to pause some games fast enough and they make noise in the background (i.e. Defender) - Display a bezel overlay that shows controls on first start
- Allow the user to continue by pressing a key/button after they have reviewed the controls
a. This button/key is mapped topause
(global) andoverlay_next
(overlay cfg file)
a. At that point, the game is unpaused, unmuted and the bezel overlay switches to a transparent one - The user can press the
pause/overlay_next
button/key at any point again to...
a. Pause the game
b. See the the controls (the bezel overlay is switched back to the controls one)
With any luck I'll have this ready for public consumption in the next day or two.
John
-
-
I know its not very welcome to answer to such an old thread but for anyone who has this "enter problem" because of the ampersand.
just after the fbi command use either
stty sane
or
reset
This clears up the ttyp egain
-
@freakzero Thanks! Alas, something seems to have changed in (my?) RetroPie since I developed the hack above. If I put those two lines in `runcommand-onstart.sh' now, the hack works like intended, but the emulator (e.g. lr-mame2003-plus) exits automatically after a couple of seconds – with or without your addition.
Since my Pi 4 loads noticeable faster than the Pi 3b I used back then, I have not much motivation to look into it more deeply. But maybe your help will benefit someone else. (@GeekOB perhaps?)
Thanks again for your contribution! 👍
edit: I also addressed the blank screen while the emulator is loading with a big "LOADING" in ascii art. 🤓
-
@clyde i have a custom solution for this since im running on ODROID with SDL2 and so if im not quitting the process soon enough im getting graphical glitches with on screen borders or other weird problems:
This is my solution by now - its not perfect since it can make problems when a rom cant load (then i have to restart the system) otherwise it works flawlessly on my ODROID with retropie:
Basically i have 2 scripts
runcommand-onstart.sh (mine did not exist since i installed retropie from the distro directly)pkill fbi pkill tail # the image i want to load loader="/etc/emulationstation/splashes/$1/launching.png" if [-f "$loader"]; then # if image is found - start fbi with the image and no timelimit, also start the check script in same directory fbi -1 -t 0 -noverbose -a "$loader" </dev/tty &>/dev/null & (/opt/retropie/configs/all/check.sh) & fi
and the check.sh script:
# you have to enable retroarch logs - always log everything input=/opt/retropie/configs/all/retroarch/logs/retroarch.log timeout 15 tail -f $input | while read LOGLINE # if any of this lines are seen - kill everything related to launchimages - in this case fbi and tail # "Found display server" is the first command in the log before the emulator kicks in do if [[ $LOGLINE == *"Found display server"* ]]; then pkill tail pkill fbi fi if [[ $LOGLINE == *"Failed to load content"* ]]; then pkill tail pkill fbi fi if [[ $LOGLINE == *"Bus error"* ]]; then pkill tail pkill fbi fi done
So what this is doing:
it starts FBI forever and the check script checks the logs for "exit tokens" - if a exit token is hit every process related to the imageloading gets killed.If the rom cant load before 15 seconds (timeout 15 - set this to the possible highest value) the process should get automatically killed.
works btw with the newest (current master in repo) mame-plus and mame emulators at my side. If you have "Enter Problems" - do what i said before - just add the clean commands for the tty additional to the pkill commands
maybe that idea/solution gives some ideas to you :)
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.