I wrote a new tool that turns carts upside down.
% ./p8upsidedown jelpi.p8.png
This is meant as a hack/demo and is known not to work with every cart. It works with many carts, and some of the failures are interesting. Notably:
The code translation increases the token count, so large carts (Celeste, Dusk Child) can't be turned upside down.
This version doesn't support spr/sspr calls that draw a rectangle of tiles. This wouldn't be too difficult to support: it'd need to flip the entire spritesheet not just individual sprites, translate the sprite IDs in the map, and extend the code to rewrite sprite ID args. But I have other things to do this weekend. :)
The print function will always print left to right, so we compromise and merely relocate the y coordinate for print / cursor calls. There's nothing the tool can do with carts that call multiple coordinate-less prints.
- I wrote this to exercise and demonstrate the picotool libraries for mutating Lua code via the AST. The lib doesn't know how to write out an arbitrary AST and preserve other comments/spaces, so p8upsidedown generates hideous code. Unfortunately the luafmt writer isn't entirely up to snuff either so it's not much help. This is mostly not an issue to Pico-8, though I did find a bug where Pico-8's special "t += val" syntax rejects a newline between the "+=" and the "val", which p8upsidedown might accidentally introduce.
Anyway, a fun weekend hack with picotool. Enjoy!
What has science wrought...
You know, vertical and/or horizontal screen flipping should really just be a video mode setting you could poke to 0x5f2c. :| It would probably be more useful than the mirroring modes it currently provides... marginally.
[Please log in to post a comment]