The Wii U's wacky PowerPC architecture highlighted a cool
platform-dependency: the boss rendering code only properly works on
platforms where `char` is signed by default.
Granted, it's possible Pixel explicitly marked this variable as
signed. Who knows. Either way, CSE2 didn't, and now that's been
fixed.
This uses basic hardware-acceleration to bounce the software-rendered
frame to both the gamepad *and* the TV!
The previous method only supported the gamepad, suffered from V-tear,
and used slightly more CPU (my test with the end of Egg Corridor ran
at 52FPS, while this new method runs at 55FPS).
With GLFW, you're supposed to `#include` your extension loader before
it, but this header made that extremely awkward. The previous "fix"
would cause build errors on Windows when compiling the software
renderer.
There's a new bug I've noticed: sometimes, an instrument will just
'disappear', and refuse to ever play again.
This stuff is practically impossible to debug, so I'm just throwing
things at the wall. This time, I'm going to make more use of the
`AXVoiceBegin` and `AXVoiceEnd` functions. I have no idea what
they're meant to do: code I found online uses it inconstently, and
Decaf doesn't have it implemented at all!
Hopefully, all of my problems have just been race conditions caused
by not using these guard functions (assuming that's what they are).
The previous method wasn't good enough: we were still maxing-out at
96 (did the Decaf devs misread that as hex? Is that why the
emulator's limit is 150 instead?).
Anyway, this new solution is a little brutish, but I can't think of
anything else that would work: right now, I have the Organya thread
constantly polling a linked-list of the currently-loaded sounds, and
checking if their voices have finished playing or not. If they've
finished, they get freed.
When AudioBackend_PlaySound is called, if checks if the sound's voice
has been freed or not, and reallocates it if it has.
There doesn't seem to be a noticable overhead to this, and it keeps
the number of currently-allocated voices *very* low (from 10 to 20 on
average).
I'm getting some rare audio hangs. I tried doing some
regression-testing, but it's so random that I'm getting anomalous
results. That said, there were suspicious results around this change
(and also the way `mix_data` is initialised/cleared), so I'm
reverting this for now, and restoring it next time I encounter a
hang.