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

    PICO-8: Retroarch lr-retro8 core installation script

    Scheduled Pinned Locked Moved Ideas and Development
    pico8
    87 Posts 10 Posters 16.2k 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.
    • L
      LN_RC @Folly
      last edited by LN_RC

      @folly @dmmarti I think the issue with reading the .p8.png files has to do with the way Retroarch works. I've used Retroarch on mobile and computer to load Pico-8 games, and I find that I have to specifically select the core (retro8) before opening a file in order for the game to launch instead of the image viewer. Perhaps that core selection phase will need to be programmed in somehow in order for the launch to work properly? I'm still pretty new to Retropie so I don't know how that'd work, just trying to find some hints!

      Also, when I zip my .p8.png files and the emulator tries to open them, my load freezes up. I can type with a keyboard to enter the retroarch emulator (where I can quit properly with hotkeys), but all I get is a black screen. I may have some issues because I installed the Pico-8 core first using this forum thread, but I don't know what would cause the total freeze. Right now, I have two cores listed, lr-retro8 and pico8_dyn. Would love to use the libretro emulator so I can save progress (if that feature works!)

      F 1 Reply Last reply Reply Quote 1
      • F
        Folly @LN_RC
        last edited by

        @ln_rc said in PICO-8: Retroarch lr-retro8 core installation script:

        @folly @dmmarti I think the issue with reading the .p8.png files has to do with the way Retroarch works. I've used Retroarch on mobile and computer to load Pico-8 games, and I find that I have to specifically select the core (retro8) before opening a file in order for the game to launch instead of the image viewer. Perhaps that core selection phase will need to be programmed in somehow in order for the launch to work properly?

        Basically the core is loaded when a selected rom is loaded.
        You can see the "command" in /opt/retropie/configs/pico8/emulators.cfg
        So I think it's something else.
        We can try and remove the .png extension part and see how RetroArch will react on that.

        I'm still pretty new to Retropie so I don't know how that'd work, just trying to find some hints!

        Thank you for giving the hints and indeed perhaps we can find some useful leads ;-)

        Also, when I zip my .p8.png files and the emulator tries to open them, my load freezes up. I can type with a keyboard to enter the retroarch emulator (where I can quit properly with hotkeys), but all I get is a black screen. I may have some issues because I installed the Pico-8 core first using this forum thread, but I don't know what would cause the total freeze. Right now, I have two cores listed, lr-retro8 and pico8_dyn. Would love to use the libretro emulator so I can save progress (if that feature works!)

        Some games will not work.
        I had that issue too in the beginning.
        Have you tried more games ?

        1 Reply Last reply Reply Quote 1
        • L
          LN_RC
          last edited by LN_RC

          @folly I think I see what you mean, though I don't totally understand the code. Let me try to explain better what I see on Windows Retroarch, because the Retroarch also launches the console, but the games launch differently based on how you open them.

          Run Method 1:

          • Open RetroArch
          • Drag .p8.png file straight into RetroArch
          • File loads with retro8 engine, but only shows the png file

          Run Method 2:

          • Open Retroarch
          • Click "Load Core"
          • Click "Retro8"
          • Drag .p8.png file straight into RetroArch
          • Game loads properly with retro8 engine

          The process looks basically the same since the retro8 engine is set to run in both cases, but for some reason, the manual selection makes the games work while the automatic selection does not.

          As with the games, yes I see that some work and some do not. I was able to make some simpler games function such as Tiny Parkour and Picoban. However, many other games don't open. Celeste opened but the music and graphics are very glitchy.

          When I try these games in PC RetroArch, the issue is the same, so it seems like the lr-retro8 engine is not fully developed. There's not much we can do about that I don't think. Too bad, I was hoping to play Islander and save my progress with RetroArch. Maybe one day!

          F 1 Reply Last reply Reply Quote 0
          • L
            LN_RC
            last edited by LN_RC

            To follow up here, I figured out a way to use lr-retro8 and pico8_dyn (the official raspberry pi Pico-8 emulator) interchangeably.

            This is how my config file looks

            default = "pico8_dyn"
            pico8_dyn = "/home/pi/RetroPie/roms/pico8/pico8_dyn -run %ROM%"
            lr-retro8 = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-retro8/retro8_libretro.so --config /opt/retropie/configs/pico8/retroarch.cfg %ROM%"
            
            

            In the roms/pico8/ folder, I put all of the core data files to run the emulator. These include:

            • pico8
            • pico8.dat
            • pico-8.txt
            • pico8_dyn
            • pico8_gpio
              (I did not need lexaloffle-pico8.png)

            However, pico8_dyn does not open .zip files, only .p8.png. Now I've got .p8.png AND .zip files in my roms folder, one for pico_dyn and one for lr-retro8. It's a bit of a mess in there, but I figure this is a temporary fix until either lr-retro8 can run more games or the lr-retro8 emulator can open .p8.png files directly.

            1 Reply Last reply Reply Quote 0
            • F
              Folly @LN_RC
              last edited by Folly

              @ln_rc

              Good posts, explaining from your side.

              For now, I can't put my finger on it why it doesn't work the way we think it should.
              In time I will look at it once more to see if I get the AHA.

              Just renamed a file from .p8.png to .p8
              This works on my end.
              So it seems the core or retroarch is reacting on the .png part.
              Basically we did already know this.

              To be continued.......

              L 1 Reply Last reply Reply Quote 0
              • L
                LN_RC @Folly
                last edited by

                @folly Excellent! I can confirm that the .p8 files without the .png end can be opened with both the libretro engine and the pico8_dyn engine. Now I have freedom of choice. Huzzah!

                F 1 Reply Last reply Reply Quote 0
                • F
                  Folly @LN_RC
                  last edited by

                  @ln_rc

                  Nice to hear.
                  So .p8 should be added to the module-script.
                  I will add it when I can.

                  1 Reply Last reply Reply Quote 1
                  • F
                    Folly
                    last edited by

                    https://github.com/FollyMaddy/RetroPie-Share/commit/7ed4f67efbdb8872ea679136322ea356268eacac

                    BuZzB 1 Reply Last reply Reply Quote 2
                    • BuZzB
                      BuZz administrators @Folly
                      last edited by BuZz

                      @folly this module looks good btw minus maybe a couple of tweaks but please feel free to submit it as a PR. Thanks.

                      To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                      1 Reply Last reply Reply Quote 2
                      • T
                        theofficialgman
                        last edited by

                        you can disable the retroarch image viewer in order to allow retroarch to load the .p8.png files

                        in retropie, this looks like a retroarch.cfg like this

                        # Settings made here will only override settings in the global retroarch.cfg if placed above the #include line
                        
                        builtin_imageviewer_enable = "false"
                        
                        #include "/opt/retropie/configs/all/retroarch.cfg"
                        
                        BenMcLeanB 1 Reply Last reply Reply Quote 2
                        • BenMcLeanB
                          BenMcLean @theofficialgman
                          last edited by BenMcLean

                          Wow! It looks like great minds think alike! I have been trying to implement a nicer experience of playing pico8 on retropie too!

                          I have made a logo for the default EmulationStation skin for pico8:
                          p8logo_best[1].png

                          It comes from this post. I used Aseprite to put a 1 pixel black border around the white version so that the logo will show no matter what color the background is. It would be nice for someone to also make one of those red outline graphics for it too.

                          The Retro8 core for RetroArch will run many pico8 games but not all. It'd be nice to give people the option to choose between the Retro8 core or the official Pico8 binary if they've placed it on their system just like how people can choose between the ppsspp official binary or the ppsspp retroarch core by holding the "A" button after they select a game in EmulationStation to get that little menu. I'm still not entirely clear on how that all works.

                          In my opinion:

                          We need to figure out how to set RetroArch to run the games correctly whether they're .p8 or .p8.png or just .png.. Those are all correct pico8 cart filenames.

                          Also, always display the cart itself as the image for the cart in the EmulationStation menu. Even if the cart is .p8 -- it should display it as a png image anyway.

                          My thought was that I'd have a little python script that runs every time you exit Splore which updates the gamelist.xml with whatever new games you added so they'll show in the EmulationStation menu with their little cartridge pictures. I was even trying to make it use picotool to scrape the metadata from the code inside the cartridge but I couldn't get that to work right.

                          BenMcLeanB 1 Reply Last reply Reply Quote 1
                          • BenMcLeanB
                            BenMcLean @BenMcLean
                            last edited by BenMcLean

                            Here's the little Python script I wrote to make a gamelist.xml for pico8 carts:

                            import argparse, io, os, lxml
                            from lxml.etree import ElementTree
                            from lxml.etree import Element
                            from lxml.etree import SubElement
                            from glob import glob
                            parser = argparse.ArgumentParser(description='Input XML file')
                            parser.add_argument('file', metavar='file', type=str, nargs='+', help='Input XML file')
                            filename = parser.parse_args().file[0]
                            path = os.path.dirname(os.path.abspath(filename))
                            et = ElementTree.parse(filename).getroot() if os.path.exists(filename) else ElementTree(Element('gameList'))
                            files = glob(os.path.join(path, '*.png')) + glob(os.path.join(path, '*.p8')) + glob(os.path.join(path, '*.p8.png'))
                            for file in files:
                                relativeFile = os.path.join('.', os.path.basename(file))
                                foundit = False
                                for game in et.getroot().iter('game'):
                                    if (game.find('path').text == relativeFile):
                                        foundit = True
                                        break
                                if (not foundit):
                                    game = SubElement(et.getroot(), 'game')
                                    gamePath = SubElement(game, 'path')
                                    gamePath.text = relativeFile
                                    gameName = SubElement(game, 'name')
                                    gameName.text = os.path.basename(file).removesuffix('.png').removesuffix('.p8')
                                    gameImage = SubElement(game, 'image')
                                    gameImage.text = relativeFile
                            lxml.etree.indent(et.getroot(), space='\t')
                            with io.open(filename, "w", encoding="utf-8") as f:
                                f.write(lxml.etree.tostring(et, encoding='unicode', pretty_print=True))
                            

                            It requires lxml.

                            A known issue: I should make the file extensions case insensitive somehow.

                            There are probably cleaner and faster ways to do this. I'm not real experienced with Python.

                            1 Reply Last reply Reply Quote 2
                            • F
                              Folly
                              last edited by

                              Hi guy's we are in the middle of a pull request.
                              Hopefully we can merge pico-8 this week ;-)

                              @theofficialgman @BenMcLean
                              When I can I will try both your input.
                              Really great !

                              BenMcLeanB 1 Reply Last reply Reply Quote 1
                              • BenMcLeanB
                                BenMcLean @Folly
                                last edited by

                                @folly said in PICO-8: Retroarch lr-retro8 core installation script:

                                Hi guy's we are in the middle of a pull request.
                                Hopefully we can merge pico-8 this week ;-)

                                @theofficialgman @BenMcLean
                                When I can I will try both your input.
                                Really great !

                                The question for me is: should I be continuing to try to work on this, perhaps in some capacity to help with what you're doing or have you got this and I should just wait for your version?

                                F 1 Reply Last reply Reply Quote 1
                                • F
                                  Folly @BenMcLean
                                  last edited by Folly

                                  @benmclean said in PICO-8: Retroarch lr-retro8 core installation script:

                                  @folly said in PICO-8: Retroarch lr-retro8 core installation script:

                                  Hi guy's we are in the middle of a pull request.
                                  Hopefully we can merge pico-8 this week ;-)

                                  @theofficialgman @BenMcLean
                                  When I can I will try both your input.
                                  Really great !

                                  The question for me is: should I be continuing to try to work on this, perhaps in some capacity to help with what you're doing or have you got this and I should just wait for your version?

                                  I have asked @buzz if he can finish the merging in the pull request of pico-8, because there are things that become too difficult for me.
                                  Btw. : This work is focussed on the module-script.

                                  Your part is something different and it's not something that can be included into the module-script, I think.
                                  So please continue.

                                  The theme for carbon that is something that should be worked on. Preferably the "system" picture should be a vector image. (.svg)
                                  Is that something you can do ?

                                  BenMcLeanB 1 Reply Last reply Reply Quote 1
                                  • BenMcLeanB
                                    BenMcLean @Folly
                                    last edited by

                                    @folly said in PICO-8: Retroarch lr-retro8 core installation script:

                                    The theme for carbon that is something that should be worked on. Preferably the "system" picture should be a vector image. (.svg)
                                    Is that something you can do ?

                                    Yes, I am familiar with InkScape for SVGs and can definitely come up with something.
                                    It might be just a vector outline of that same pico8 logo but I figure that should be close enough, right?
                                    I'll look at what the SVGs for the other systems are like for reference.

                                    BenMcLeanB 1 Reply Last reply Reply Quote 2
                                    • BenMcLeanB
                                      BenMcLean @BenMcLean
                                      last edited by

                                      I believe blocky is the program I need to convert the pico8 logo (which is indexed png pixel art) to SVG. I should report back with results after I get that working.

                                      BenMcLeanB 1 Reply Last reply Reply Quote 2
                                      • BenMcLeanB
                                        BenMcLean @BenMcLean
                                        last edited by BenMcLean

                                        blocky is pretty awful: making a gazillion little rectangles in the SVG instead of merging the same color together in contiguous areas like such a program should. I could click on every single rectangle and try to merge them by hand but I expect there's got to be a better script out there which does this properly.

                                        BenMcLeanB 1 Reply Last reply Reply Quote 2
                                        • BenMcLeanB
                                          BenMcLean @BenMcLean
                                          last edited by BenMcLean

                                          It turned out that the right script to use is actually Jirinrin/pixel2svg-outlines.

                                          I don't know whether the scaling might need to be adjusted for EmulationStation to match the other systems or not so for now, I'm just going to upload the raw untouched output from pixel2svg-outlines. However, it is clear that the shapes are correct from examining it in InkScape, plus the file size being appropriately tiny.

                                          BenMcLeanB 1 Reply Last reply Reply Quote 2
                                          • BenMcLeanB
                                            BenMcLean @BenMcLean
                                            last edited by BenMcLean

                                            Apparently that source image I was working from is actually a little bit distorted in its dimensions. It makes the diamond symbol of the colors a little bit taller than it should be. So there's probably going to be some more revisions before the final version.

                                            BenMcLeanB 1 Reply Last reply Reply Quote 1
                                            • 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.