Log In  

I wrote a new tool that turns carts upside down.

% ./p8upsidedown jelpi.p8.png

Cart #16098 | 2015-11-02 | Code ▽ | Embed ▽ | No License

The tool is built with the picotool library (discussion). This version of the tool inverts the sprites, inverts the map, and translates the code to use inverted coordinates for drawing functions.

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!

-- Dan

P#16099 2015-11-01 19:45 ( Edited 2015-11-03 06:53)

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.

P#16101 2015-11-01 21:07 ( Edited 2015-11-02 02:07)

Very cool. Could you add also optional argument that would flip controls as well?

P#16105 2015-11-02 06:39 ( Edited 2015-11-02 11:39)

Sure thing! I also added a reverse sfx option. Here you go:

./p8upsidedown --flipbuttons --flipsounds jelpi.p8.png

P#16147 2015-11-03 01:32 ( Edited 2015-11-03 06:32)

That reversed music is awesome.

P#16148 2015-11-03 01:53 ( Edited 2015-11-03 06:53)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-02-21 14:43:04 | 0.012s | Q:18