Skip to content

QR codes in PICO-8

Posted by Mabbees

My partner gifted me a Miyoo Mini Plus for Christmas last year. I love it! It’s such a cute little system. One of the best things about it is that with a little convincing, it can run PICO-8 natively.

I’ve enjoyed bringing it with me to indie game developer meetups and I showing off the PICO-8 games I’ve been working on. It’s been a fun way to share my portfolio. It’s made me realize it would be really convenient if I could pull up a QR code on the miyoo, then people could scan it and find the games online. So of course, I built a PICO-8 cart to generate QR codes. A saner person might have generated a QR code using an existing tool and simply imported it into PICO-8, but well… where’s the fun in that?

Implementation

I followed Thonky’s QR code tutorial to work out the implementation. To me, the most interesting part was learning about error-correcting codes. QR codes use a method called Reed-Solomon Error correction, which uses some clever number theory, and can be implemented efficiently using some clever programming tricks. Apart from that, there are a bunch of fiddly details that are easy to get wrong, but I did eventually get my program to make QR codes that my phone can scan. As coding exercises go, this one felt pretty rewarding.

I only implemented a subset of what QR codes are capable of. My cart always uses alphanumeric mode, error-correction level Q, and version 10 (57 × 57). That puts a limit on how long a message it can encode of 221 characters — still more than enough for sharing URLs.

The Cart

Here’s the cart. You can generate a QR code either by dragging and dropping a text file, by hard-coding a value, or by running the cart from the command-line.

PICO-8 Cartridge