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

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 modified runcommand.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 tried nohup 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's Tab 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 using nohup 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.shfile?



  • 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!


  • Global Moderator

    @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 of

    fbi -1 -t "$IMAGE_DELAY" -noverbose -a "$image" </dev/tty &>/dev/null
    

    in the runcommand.sh file, and

    launchpic="$(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.shfile 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!


  • Global Moderator

    @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.


  • Global Moderator

    @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 via nohup 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.



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.