One of the more difficult things that I’ve been attempting to figure out during all this is how to go about using threads on the Dreamcast. Initially, I was looking into the fiber interface that SEGA’s Shinobi library offers. There’s no documentation and it seems like it was added late for everyone else to use. It seemed promising, but after reading an article in Game Programming Gems 2 on implementing a lightweight thread system for x86, I figured; why not?
So far, I’m pleased with what I have. It’s not perfect, as when initialising the stack there’s the issue of storing the “holding” function for dead threads (still yet to remove dead threads) to avoid creating an infinite loop when the thread function ends. The solution is to have an initial setup call when switching threads to switch to pop the last thing in the stack (the holding function) off, otherwise use the default call. This isn’t great, as it requires the thread to be checked every time to see if it’s been started. A thread management system should help mitigate this issue by only calling the setup once and every time thereafter using the intended function as normal.
With this, I’m getting closer to being able to get started on the scripting system proper. I’ve hopped back to the editor side of things for saving and loading scenes in the interim. Again, the editor is my least favourite part as it’s so poorly written. I’m trying to rewrite it as I go, for clarity. Before I get back to the game, I’d really like to have geometry transform and entity editing up-and-running.