RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Loading ROM completely while displaying launch image

    Scheduled Pinned Locked Moved Ideas and Development
    launch imagesruncommandonstart
    17 Posts 5 Posters 3.9k 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.
    • ClydeC
      Clyde
      last edited by Clyde

      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.

      1 Reply Last reply Reply Quote 3
      • ClydeC
        Clyde
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • ClydeC
          Clyde
          last edited by Clyde

          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.

          GeekOBG ClydeC 2 Replies Last reply Reply Quote 0
          • GeekOBG
            GeekOB @Clyde
            last edited by

            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?

            1 Reply Last reply Reply Quote 0
            • GeekOBG
              GeekOB
              last edited by GeekOB

              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!

              mituM 1 Reply Last reply Reply Quote 0
              • mituM
                mitu Global Moderator @GeekOB
                last edited by

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

                GeekOBG 1 Reply Last reply Reply Quote 0
                • GeekOBG
                  GeekOB @mitu
                  last edited by GeekOB

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

                  mituM 1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator @GeekOB
                    last edited by

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

                    ClydeC 1 Reply Last reply Reply Quote 1
                    • ClydeC
                      Clyde @mitu
                      last edited by Clyde

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

                      mituM 1 Reply Last reply Reply Quote 0
                      • mituM
                        mitu Global Moderator @Clyde
                        last edited by mitu

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

                        GeekOBG 1 Reply Last reply Reply Quote 1
                        • GeekOBG
                          GeekOB @mitu
                          last edited by GeekOB

                          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.

                          1 Reply Last reply Reply Quote 0
                          • ClydeC
                            Clyde @Clyde
                            last edited by

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

                            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.

                            1 Reply Last reply Reply Quote 0
                            • johnodonJ
                              johnodon
                              last edited by johnodon

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

                              1. Display the launch image until the game starts (not wait for the launch image to close before starting the game)
                              2. 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)
                              3. Display a bezel overlay that shows controls on first start
                              4. Allow the user to continue by pressing a key/button after they have reviewed the controls
                                a. This button/key is mapped to pause (global) and overlay_next (overlay cfg file)
                                a. At that point, the game is unpaused, unmuted and the bezel overlay switches to a transparent one
                              5. 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

                              1 Reply Last reply Reply Quote 2
                              • johnodonJ
                                johnodon
                                last edited by

                                See here: https://retropie.org.uk/forum/topic/27041/my-modified-rom-loading-process-launch-images-bezel-overlays-pause

                                1 Reply Last reply Reply Quote 0
                                • F
                                  FreaKzero
                                  last edited by

                                  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

                                  ClydeC 1 Reply Last reply Reply Quote 1
                                  • ClydeC
                                    Clyde @FreaKzero
                                    last edited by Clyde

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

                                    F 1 Reply Last reply Reply Quote 0
                                    • F
                                      FreaKzero @Clyde
                                      last edited by FreaKzero

                                      @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 :)

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        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.