Sparc-16: Devlog #1

This is a little side project I've had going for a while and I thought it was time to start sharing the progress I make on it and talk a little about what I've got and what I'm trying to accomplish.

Sparc-16 is a platform and API for making retro games inspired by and designed to feel like consoles of the 16-bit era. Sparc's limitations and features have been carefully chosen to be in line with those consoles, but still be relatively easy to develop for as well as cross-platform. Sparc runs on SDL2 with pure software rendering and supports Javascript as the scripting language of choice.


Sparc-16, like many older consoles, uses sprites and tilemaps rather than geometry-based rendering. In Sparc, you get four tilemap layers and four sprite layers. Additionally, you get up to 256 sprite objects at a time. Colors are always indexed in Sparc. A palette can hold 15 colors plus transparency, and there are 16 palettes available.

Sparc can load sprites directly from 1-bit, 2-bit, or 4-bit per pixel indexed PNG images, and also has built-in support for loading JSON tilemaps exported from the popular Tiled tilemap editing tool.

You also can register both vertical sync and horizontal sync callbacks in Sparc. In fact, you can even modify the graphics state per-scanline, since the graphics in Sparc are purely software rendered. This means you can easily implement all sorts of effects employed by older games (such as the wavy effect shown in the video at the end of this post).


Sparc-16 exposes a virtual controller which is laid out nearly identical to a SNES controller. You get directional buttons, start & select, ABXY face buttons, and left+right shoulder buttons. These currently map to the keyboard with a layout borrowed from the ZSNES emulator, and will eventually map to buttons on Xbox 360, Xbox One, and PS3 gamepads.


In Sparc, I went with a hybrid audio solution that is somewhere in between the Mega Drive and the SNES. You get 8 channels of audio in total. Each channel can have either an FM synth voice, or a PCM voice. FM synthesis is a simple 2-operator architecture, and PCM voices can play back 8khz pcm data with optional looping. You can use whatever you want for making music - all PCM, all FM, or a mix of both (possibly FM for most instruments and PCM for the instruments which FM doesn't do well). You'll also be able to play back PCM sound effects during gameplay through any of the 8 channels (which will, of course, temporarily replace whatever is playing in that channel for the duration of the sound).

I'll be working on a custom-written music tracker for Sparc games, and tempo will be controlled by two parameters in tandem - you'll have a Clock Rate value, which is number of ticks per second (default 60Hz), and also a Speed value, which is number of ticks per row.

Additionally, inspired by expansion modules such as the Sega CD, and the Turbografx 16 CD addon, you'll also be able to play back a single 32khz background music track directly from an OGG file on top of the 8 channels of synthesized sounds.

Current Progress

Here's what I've currently got for Sparc. This is a graphics test for Sparc, showing off the sprite and tile features as well as the scripting support (nearly all of the logic here is running in Javascript, with the main render core implemented in native C++):

Also, as mentioned earlier, a neat graphical effect is shown off here - the Javascript code has registered a horizontal sync callback, and is modifying the position of the sprite and the tilemap per-scanline. This sort of technique was used all the time by older games for all sorts of things (for example, the water effects in Sonic).

Audio is also being worked on at the moment. It's being prototyped in Unity. The audio core is nearly finished, and after the playback system is written it will be ported over to C++ in Sparc.

Currently, Sparc is a C++ SDL2 app for Windows. However, I've carefully chosen libraries for portability so after Sparc's main feature set is complete, I will take a look at porting the runtime over to other platforms. The good news is that, because Sparc's spec has already been finalized, all of the assets and JS code of a game can simply be dropped into any other port of Sparc and work flawlessly.

Posted in Coding & Dev on Jun 16, 2016

blog comments powered by Disqus
Subscribe for updates