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

CMake: Add picosystem_asset for packing .16bpp into .o #29

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gadgetoid
Copy link
Member

@Gadgetoid Gadgetoid commented Oct 20, 2021

Use the linker to convert an asset into an .o file and include it in project sources.

TODO: Fix const resources/.rodata assets

Example

Add the following to your CMakeLists.txt:

# Link the platformer spritesheet
picosystem_asset(${PROJECT_NAME} ../assets/s4m_ur4i-platformer.16bpp)

And to your main .cpp:

extern char _binary_s4m_ur4i_platformer_16bpp_start[];
buffer_t *platformer = buffer(128, 128, (void *)_binary_s4m_ur4i_platformer_16bpp_start);

void init() {
    spritesheet(platformer);
}

⚠️ At the moment I can't seem to get this working with constant data, so it will eat 32K of RAM.

Use the linker to convert an asset into an .o file and include it in project sources.

TODO: Fix const resources/.rodata assets
@Fordi
Copy link
Contributor

Fordi commented Oct 20, 2021

Awesome! I'm going to try this in my scratch project.

[Edit: works as advertised, but my script (here) builds directly from an image, rather than a .16bpp binary, which makes the workflow a bit easier (though, I suppose I could run convert-image.py {pngfile} before make just as easily as ../tools/build-spritesheet.js {pngfile}).]

@Gadgetoid
Copy link
Member Author

Gadgetoid commented Oct 20, 2021

Our 32blit SDK has - effectively - a manifest of files which it slurps up and runs through the 32blit tool for packing/conversion. All very handy dandy and unlike this basic nonsense 😆

eg: https://github.com/32blit/rocks-and-diamonds/blob/main/assets.yml

BUT... where's the fun in that? 32blit users got to build their own empire... PicoSystem users can have some fun too!

(P.S. it's cool that you're putting together tools to serve your purposes, it's all part of the fun!)

@Fordi
Copy link
Contributor

Fordi commented Oct 20, 2021

...ooo, that's pretty. I wonder how that works.

@og-syn
Copy link

og-syn commented Oct 30, 2021

@Gadgetoid are you looking for input/feedback on this? I have a half baked patch (minus the cmae stuff, I'm generating .h files manually and including them) that does more or less this, but defines a robuffer_t and templatizes some functions to they can use it. That way all data ends up in ROM.

@Gadgetoid
Copy link
Member Author

That way all data ends up in ROM.

I was waiting until I had a moment to figure out how to do this. If you want to fork this branch for the CMake stuff and submit your own take on this PR I'd be happy to review it!

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

Successfully merging this pull request may close these issues.

3 participants