Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run PNG cartridges using libretro core #2048

Closed
Shatur opened this issue Dec 12, 2022 · 7 comments
Closed

Unable to run PNG cartridges using libretro core #2048

Shatur opened this issue Dec 12, 2022 · 7 comments

Comments

@Shatur
Copy link

Shatur commented Dec 12, 2022

When I open a PNG cartridge using RetroArch I have code is empty error message. I use the latest release at the time of writing (v1.0.2164, compiled it myself). The same cartridge run perfectly using tic-80 utility.
Also my RetroArch configuration can run pico-8 cartridges without any problem. But I had to disable built-in RetroArch image viewer for it.

@bztsrc
Copy link
Contributor

bztsrc commented Dec 13, 2022

There's a PR that might fix your issue by providing a reliable way to store cartridge data in PNGs. (I'm just guessing, in lack of sample PNG and detailed error messages I don't know what is causing your problem.)

@bztsrc
Copy link
Contributor

bztsrc commented Dec 13, 2022

Ok, I've debugged that. The reason why it isn't working, is because this hasn't been implemented.

The libretro code uses retro_load_game function to load a cartridge.

That function in turn calls tic80_load, which in turn, calls tic_cart_load, but that last one is only for .tic files.

The way how the command line does it, goes like this: when the command is entered, onLoadCommandConfirmed checks if the cartridge data was loaded, and calls tic_cart_load to parse it. However if that's not true, then it checks the file's extension, and calls loadPngCart instead.

As you can see, there's no loadPngCart call in tic80_load, that function directly calls tic_cart_load, so no wonder that PNG cartridges don't work for you.

My guess is, one should add the same tic_cart_load / loadPngCart logic you see in console.c to tic80_load to get PNG cartridges working with libretro core.

Or maybe, as an alternative, PNG check should be added to tic_cart_load as I've originally suggested here, that would work with all frontends (sokol, sdl etc.), not just libretro (but that code isn't good any more, because the cart data is zlib compressed in the chunk; it's just that's the right place where loadPngCart should be called, and not multiplied in start.c, console.c, surf.c etc. IMHO. Alternatively if those sources gets rewritten to use tic80_load like all the other frontends, then tic80_load would be the ultimate best place for detecting cartridge type).

Cheers,
bzt

@Shatur
Copy link
Author

Shatur commented Dec 13, 2022

Thanks for such a detailed breakdown!
I agree with you. Let's see what the maintainers think.

@bztsrc
Copy link
Contributor

bztsrc commented Dec 14, 2022

I've added a little change to the PR which will solve your issue, should the PR get merged. Other than that I see no resolution, as linpng isn't linked into libtic80core.a, but that's absolutely needed with the current steganography method.

Cheers,
bzt

@Shatur
Copy link
Author

Shatur commented Jan 12, 2023

@bztsrc your PR was merged, can we close this?

@bztsrc
Copy link
Contributor

bztsrc commented Jan 13, 2023

@bztsrc your PR was merged, can we close this?

Unfortunately no, I've just added the fix in the PR's comments, because this issue did not existed when I opened the PR. But now I've added a new PR that actually fixes this.

Cheers,
bzt

@RobLoach
Copy link
Contributor

Following up on this year-old issue. In addition to the PNG fix, TIC-80 has a number of languages that have had to be disabled in the libretro buildbot TIC-80 core. If you attempt to load a cart that uses one of those languages, it'll report code is empty. QuickJS, and MRuby, for instance, are two languages that have had issues compiling across all the platforms on buildbot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants