Skip to content

Conversation

@imsys
Copy link
Contributor

@imsys imsys commented Sep 11, 2025

No description provided.

@imsys
Copy link
Contributor Author

imsys commented Sep 11, 2025

I verified that the way to inform multiple extensions is by using pipe by doing this search: https://github.com/search?q=info-%3Evalid_extensions&type=code&p=3

@imsys
Copy link
Contributor Author

imsys commented Sep 11, 2025

Although I'm just trying to load Bone Knight png cart through the libretro core and it fails, but it works in the standalone. I will do more checks later.

@imsys imsys marked this pull request as draft September 11, 2025 18:06
@imsys
Copy link
Contributor Author

imsys commented Sep 11, 2025

I found why the libretro doesn't load PNGs:

the standalone binary first calls tic.c - tic80_load() to call the TIC startup screen.
But it then calls studio/screens/console.c - cmdLoadCart(Console* console, const char* path) to load the file, and this deals with the PNG, unpacks it and sends the unpacked PNG to tic.c - tic80_load().

[DEBUG] tic_cart_load: Received buffer of size 20739.
[DEBUG] tic_cart_load: Received buffer of size 20739.

 TIC-80 tiny computer
 version 1.2.3028-dev Pro (dd62ffa)
 https://tic80.com (C) 2017-2025
[DEBUG] cmdLoadCart
[DEBUG] tic_tool_has_ext png
[DEBUG] loadPngCart
[DEBUG] tic_cart_load: Received buffer of size 169565.

The libretro version sends the PNG directly to tic.c - tic80_load(), and it fails to load.

[libretro DEBUG] [TIC-80] retro_load_game: Loading content of size 111543 bytes.
[DEBUG] tic_cart_load: Received buffer of size 111543.
[DEBUG] tic_cart_load: PNG magic number found!
[DEBUG] tic_cart_load: Found PNG chunk 'IHDR' with size 13.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 8192.
[DEBUG] tic_cart_load: Found PNG chunk 'IDAT' with size 4834.
[DEBUG] tic_cart_load: Found PNG chunk 'IEND' with size 0.
[DEBUG] tic80_load: Code chunk starts with: ''
[TIC-80]: the code is empty
[INFO] [Environ]: SET_MESSAGE: the code is empty
[INFO] [Environ]: SHUTDOWN.

I will see if I can make a patch to fix this.

Moved loadPngCart from studio.c to cart.c
The standalone binary loads carts from this stack:
studio.c: studio_create()
console.c: initConsole()
console.c: cmdLoadCart()

cmdLoadCart() had a working PNG cart load,
but libretro uses `tic.c: tic80_load()` directlty, but that had a
incompete PNG load.

So I tried to combine and bring the aproach from cmdLoadCart() to
tic80_load() by letting them both use the same PNG loading function.
@imsys imsys marked this pull request as ready for review September 15, 2025 00:41
@imsys
Copy link
Contributor Author

imsys commented Sep 15, 2025

I tested it locally on my Linux, on Android standalone and retroarch. All seems to be working as expected, to load .tic and .png files.

@imsys
Copy link
Contributor Author

imsys commented Sep 15, 2025

This patch will also make it easier to fix BUILD_EDITORS=OFF in a future patch.

@nesbox
Copy link
Owner

nesbox commented Sep 15, 2025

If you want to run a tic80 binary built with the BUILD_EDITORS=OFF option, you need to embed the cart binary into it.
You can find here https://github.com/nesbox/TIC-80/blob/main/src/studio/screens/start.c#L189 how we load the embedded cart. And here https://github.com/nesbox/TIC-80/blob/main/src/studio/screens/console.c#L2070, is how we embed it.

@github-project-automation github-project-automation bot moved this to In progress in dev version 1.2 Sep 15, 2025
@nesbox nesbox merged commit 2cc226b into nesbox:main Sep 15, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in dev version 1.2 Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants