- CEleste
- 18 Nov 2021 02:05:06 am
- Last edited by commandblockguy on 18 Nov 2021 10:27:57 am; edited 2 times in total
I've created a port of the PICO-8 platformer Celeste for the TI-84+CE. You can download it from GitHub or the Cemetech archives.
This mostly just involved hand-translating the code from the original version into C++ and then implementing the PICO-8's built-in functions. I did run into a few interesting challenges, though.
Firstly, the original program made extensive use of floating point numbers (which were actually 16.16 fixed point on the PICO-8). For speed reasons, I replaced every floating point operation with an integer one, and changed the way that speeds are stored from units of pixels to 1/256 of a pixel.
I also replaced the type object for each object with a class for each object type, which is significantly more sensible in C++. I disabled all of the sound code, for obvious reasons. If anyone gets an audio library working, I might revisit that.
The graphics are probably the most interesting part of this. The original game is 128x128, but I decided to scale it up 2x and trim off the top and bottom 8 pixels.
The LCD controller is actually in 4bpp mode, but I'm just using graphx and fontlibc for drawing the actual graphics. I left all the sprites in 8bpp mode, and converted them with a different palette, where the upper and lower nibbles of each palette entry are the same. This allows me to double the width of each pixel drawn while still using regular graphx functions.
This left spaces between lines, though, so at the end of the frame I copy each line down by one pixel to completely fill the screen. So, this allows pretty much free 2x scaling, so long as you have 16 or fewer colors.
Additionally, rather than redrawing the entire tilemap each frame, I generate it once and save it as an 128x128 RLET sprite.