Sphere & misc - Small sketches for the Playdate

Hello everyone.

I'm currently discovering the PlayDate, its capabilities, its SDK and a long lost love for 1-bit B&W graphics that have been there since I started programming on certain handheld monochrome devices. It sure is interesting to get a higher density and resolution screen this time.

Sphere

Among the small projects that I keep around to give a test on a platform and/or to see how it'd look on it, there is a small "sketch" I did years ago in Pico-8: Sphere.

playdate-20220321-224038

That's basically not much more than an animation playing in realtime, but it was a fun experiment in going back to C and squeeze the most out of the small little device and its tiny CPU. Under the engine, it's containing a good chunk of a viable 3D renderer written from scratch for absolutely no reason other than wanting to reinvent to wheel.

I think the hardest part was getting the projection matrix correct and remembering that an OpenGL-ish rendering system expects the Z coordinate (the one facing the camera) to be negative for a vertex to fall into the frustum. A mistake I also did in the original sketch!

If you're interested, the sketch is open source, so you can pry it up, tweak it and run your own version of it. I left some comments to give insights on the code and how it could be improved. For reference, I built it against the SDK v1.9.1.

I don't know if I'll continue working on this small project, it was mostly a warm up, I'll see in the near future if I can port or redo some older projects. I'm sorry, it's not really a game or anything interactive, I didn't find a more suitable forum category, there won't be many projects like those, or at least I'll gather them to avoid polluting the forum.

I'm attaching two zip files, one containing the binary/folder to run on the physical device, one for the simulator. Have a nice day!

sphere.simulator.pdx.zip (12.1 KB)
sphere.device.pdx.zip (11.0 KB)

Tunnel / Barrel

NOTE: this sketch contains quite a lot of moiré artifacts, so the GIF itself is under a spoiler tag.

playdate-20220429-224331

Inspired by one visual effect coming from Super Castlevania IV, I wanted to see if I could reproduce a similar effect on the PlayDate and keep it running smootly.

Looks like it works! By using a few tricks here and there, I could progressively optimize it under the frame time.

The principle of the effect is simple : imagine scaling a single bitmap horizontally line-per-line, following a sine curve with the apex at the center of the screen. Applied on a regular gris, it would look like this
grid

The rest of the trick was to read a source bitmap, extract the proper bits and blit them to the frame buffer while keeping it fast enough. To optimize the process, instead of keeping floating points all the way down, I resorted to a subset of fixed-point operations so I could squeeze even more cycles out of the machine by avoiding expensive trips between FP and integer registers. Some of the operations like fmod are relatively heavy, hence me using truncf often because it maps directly to a CPU instruction, hehe.

As with the previous sketch, the project is open source and you're free to look around and get inspired steal bits out of it! I'll link here to two pdx files, one for the simulator and one for the device. It should run smoothly enough (but I'm not sure about the last-moment tweaks I did, oopsie)
barrel_DEVICE.pdx.zip (12.4 KB)
barrel_SIMULATOR.pdx.zip (12.8 KB)

18 Likes

That is really pretty! I like the little circles especially :slight_smile:

Wow this is a super clean job. I really love it.

The dithering on the lines in the back is a really nice touch that gives a unique look at the demo. And the stars that are a trail in the back and switch to a bigger dot in front is super good. Lots of attention to details.

2 Likes

Wow this is so nice!!

This is just lovely. Inspiring, truly.

This is killer, thanks for sharing.

Thanks for all the replies and love, it's really appreciated.

I think I might reuse the thread for smaller prototypes I'll do in the same vein than this one, otherwise I'd feel too bad spamming this forum here.

Here's something I have in the works. A Super Castlevania IV-inspired small thingie imitating its tunnel effect. The source is currently located here. It's not yet tested on a physical device, I wonder how it'd run, hence the introduction without much fanfare like previous time. It might be a good exercise for lower-level optimization (pre-calculating the profile, blitting the mask on-the-fly, digging into cache prediction and massaging for performance, etc etc)

playdate-20220426-001105

It's behind a spoiler because the current version blits over a mask that cause stronger moiré patterns than I hoped and still needs some work to be polished.

Edit : check out the original post, it's now released!

2 Likes