Lab Notes: Releasing PETI 3.0

Last Updated: 2021-07-27 14:00:00 -0500

Circumstance and mood have conspired to make this, the final week of July, on of two periods of paid leave from work which I’ll be able to take this summer. As a result, I spent monday night and a good chunk of yesterday updating and recompiling PETI’s firmware. Last night I published this firmware update’s source [here (permalink)] as the 0.0.3 release. This version adds a new demo functionality, replacing the old demo with a menu which allows you to cycle through the various forms PETI can take, and view all four of their currently-supported animations: idle, face right, face left, and eating. I’ll go back through and add support for the sleeping animation at around the same time I add sleeping into the game.

Using 0.0.3’s Enhanced Demo

If you have access to the hardware used in PETI and can flash the current firmware onto it, you too can play with the demo mode, which will appear after the clock has been set and the 5 minute period of watching the egg hatch has passed.

To use it, simply use the A and B buttons to cycle backward and forward through life stages. The C button will cycle forward through the animations, and the D button toggles between natural and inverted colour.

Why?

I wrote this demo to be able to quickly and easily test the animations for all the different pets at once. It will likely eventually be moved into (and form a key part of) a debugging menu, continued access to which constitutes one of the three puzzles/secrets baked into the PETI design.

What’s Next?

A bit of a break agian, I suppose. Next-next will be about documentation, commenting, and potential refactoring. I picked up a bit of lore (below) about the correct use of C and now I want to go back through the code and tidy up other instances that would be cleaner if so used. The project documentation is also simply dreadful right now. There’s almost certainly going to need to to be updates to the documentation, especially around the workflow of going from character design on paper to characters in the font16x16 font through fontedit, then into the evo_data.c definitions, and further out into the game itself.

In terms of “next” for next features, I want to tackle the hunger and fun meters. Hunger and fun are the main depleting-replenishing mechanic stats, and their existance underpins a lot of the other functionality the pet will have, like evolution, dying, illness, and so forth. That would be the first development of an actual gameplay mechanic.

Lesson Learned: Why we use seperate C and H files.

In c, there are essentially two types of source files: c source files and h header files. I’m dramatically oversimplifying.

Because I was able to successfully create the font.h file and reference it for so long, I assumed it was perfectly valid to do this for any type of file where I needed a reference array or value, and in the 0.0.2 release that worked, because only main_game.c referenced the evo_data.h file and only the calendar_menu.c file referenced the enCA_strings.h file.

This turned out to be massively incorrect. As soon as I included references to those files into the new version of demo_mode.c, I started getting compiler errors yelling about redefinition.

Turns out, this is a classic trap for young players in C. The solution is to only expose/declare the symbol in the .h file, but to do the actual definition in a matching .c file.

If you view the commit here you should have a better understanding of what exactly I mean.


PETI is a major project intended to design and construct a virtual pet from Open Source Hardware and Software, and to encourage others to modify and tinker with similar projects.If you would like to support the development of this, or any of the other projects I’m working on for Arcana Labs, and you wanted to show your support financially, your best avenue is via my Github Sponsors account or by making a one-time donation to Arcana Labs via Ko-Fi.com or through other avenues detailed here. Github Sponsors also get access to a special patrons-only section of the Arcana Labs Discord Server, where we talk about the ongoing super-secret project.