Hacker News new | ask | show | jobs
by skrebbel 2113 days ago
If you want to see a variation of this concept in the wild, in active use by lots of people, check out PICO-8 cartidges.

PICO-8 is a virtual game console. I.e. it's an emulator for an oldschool game console that doesn't exist in reality. It's designed to be easy to code for while maintaining the limits and aesthetics of old game computers

PICO-8 games are, of course, distributed on cartridges. However because it's a virtual console, the cartridges are virtual too: they're PNG files.

Try browsing PICO-8 games here: https://www.lexaloffle.com/bbs/?sub=2&cat=7

Press the play button the play a game right inside the web browser, but be sure to click the little "Cart" link right below the playing area to see what's going on. You'll see it open a little PNG file.

That PNG file is the cartridge. It contains the entire game.

The file format is explained here: https://pico-8.fandom.com/wiki/P8PNGFileFormat. Obviously, because PICO-8 carts are purely digital, the format doesn't need any of the contrast, the error correction features or the orientation markers that QR-codes have. You can't take a picture of a cart with your phone and play it. You need the exact same, byte-for-byte PNG file. But it's still super cool.

8 comments

This is the coolest thing in ages. The game's code is steganographically embedded in a PNG image containing the screenshot of the game! Wow
Steganography is cooler for sure, but can't PNGs already store arbitrary data in the header? IIRC, the game Spore did that so you can exchange creatures by sending images.
I think the issue with that is that many image hosting sites optimize their images or at the least strip unnecessary data and EXIFs.

So at any point while being copied from person to person, that game data could be lost.

Games for the “Redshift” game console in the Zachtronics game Exapunks work the same way. They copied the idea from PICO-8: https://mobile.twitter.com/zachtronics/status/10277956046744...
This is very cool, and gives me a thought, what if you did it without "cheating"? That is, what if the whole game including its rules were in the picture? Something like Conway's game of Life but less shape-dependent, maybe utilizing the color to generate behaviors.
The closest thing I can think of is Piet: https://www.dangermouse.net/esoteric/piet.html
>Richard Mitton supplies this amazing program which calculates an approximation of pi... literally by dividing a circular area by the radius twice.

>Naturally, a more accurate value can be obtained by using a bigger program.

That's delightful

Nintendo back in 2001 came out with the e-Reader that would plug into a Gameboy Advance and read cards with data printed on them. You'd have to scan a few "stripes" of data, but it there were several NES games that you could run if you had the right cards. The cards held the data for the games, rather than them being already on the cartridge https://en.wikipedia.org/wiki/Nintendo_e-Reader
I was always gutted that thing never came out in Europe. I had tons of Pokémon cards with the stripes and nothing to use them with.
You should turn this comment into a blog post. Your writing is captivating. You made this ecosystem sound a lot cooler than the web pages you linked to.
Thanks! I'm humbled :-)

That said, I think the PICO-8 ecosystem is a lot cooler than I made it sound :-)

EDIT, try watching this demo for example: https://www.youtube.com/watch?v=UR3MXKIefAI It's a demo, not a game, so not interactive and hence youtubeable. Tell me that isn't cool (and remember, it fits in is cartridge png).

I don't know if I'm stupid, but those anyone have an example PICO-8 PNG? I can't find one in either of the two links you sent, nor on the internet. Am i missing something here?
Click "Cart" on the bottom left of the BBS entries.

E.g. on https://www.lexaloffle.com/bbs/?tid=29967

Takes you to https://www.lexaloffle.com/bbs/cposts/4/44467.p8.png

Huh, so the PNG actually looks like a real cartridge? How are they able to do that? Is the data section hidden in a non-visible part of the file, or are they able to somehow encode it in there while still having it look visually like a cartridge?
https://pico-8.fandom.com/wiki/P8PNGFileFormat

The images are RGBA PNGs. So for each display pixel there's a byte for each color channel and the alpha channel. The two least significant bits in each byte are a quarter of a PICO-8 data byte. Those bits are read from a channel byte and concatenated in RGBA order to get a data byte.

Using the LSBs for each channel means the those swizzled bits won't contribute very much to that pixel's color value. At worst it would just look like noise in the image.

Also by putting the data inside the image data of a PNG it won't be stripped off by some optimizer or hosting service.

that 'top-down adventure tutorial' is great. basically teaches you everything. thanks for sharing pico-8.
This was the first thing that came to mind. If PICO-8 ever comes out with a mobile version, having a way to load a game by QR Code or some sort of game image would be cool.