As another exercise with ZillaLib, I tried to port Blargg’s GME (Game Music Emulator). It was my first time using a third-party library extensively in a very long time.

The original GME library used SDL, which draws the oscillator by pixels. ZillaLib did not expose such a method, so at first I tried using DrawLine(), but unfortunately, drawing a line 512 times per frame (the amount of samples used for this demo’s audio buffer) was too heavy – the buffer was constantly starved of audio as the canvas struggles to draw the oscillator at best ~20FPS.

I then had the clever idea of using DrawPolygon() instead, which I believe uses a single draw call but with 512 vector points. The performance was vastly improved – almost 60FPS with very rare audio starving!

The controls this time are all available on the screen, for mobile-friendliness! However, if you want to use your keyboard:

Left / right arrow keys        = Prev/next track
1/2/3/4/5/6/7/8/9              = Toggle audio channel on/off
Spacebar                       = Toggle pause/resume
- / + keys                     = Decrease/increase speed
E                              = Toggle echo (this probably doesn't work...)
0                              = Reset audio channels and speed
Status: Loading...

At this point I’m satisfied with how easy-to-use ZillaLib is. I’ll try to make a simple game as a warm-up toward my pet project which I’ve been planning for months now… Probably an Asteroids or Flappy Bird clone.

The code for the ZillaLib GME can be found here.