BLOG

1 | 2 | 3

Sega Genesis Development?!

Posted July 23, 2022

I'm starting to feel like I say this every time, but it's been a long time since the last blog post...again. I've still been recharging my batteries after the six-month long, fairly grueling development of the Darkness Never Dies demo. But, I've been feeling that developer itch again, and my recent creative wanderings have taken me in an unexpected and intriguing direction.

The short version is, I was feeling the frustration of building cross-platform games and wishing I could develop games for fixed hardware -- which means consoles. But, consoles tend be replaced relatively quickly (every few years or so), and dev kits for them tend to cost a small fortune. Besides, my greatest interest, both as a developer and as a player, is in retro gaming. Some online wanderings down this trail led to me wondering how difficult it would be to develop a game for a retro console like the Sega Genesis (or Mega Drive for you international folks).

To my surprise, I discovered someone created a modern, C-based software development kit (SDK) for the Sega Genesis called SGDK, which can be used to develop Genesis games using modern tools instead of having to code everything at an extremely low level in assembly like developers had to do back in the 90s. I came across a couple other exciting and key discoveries as well:

In other words, there exists a modern SDK for writing Genesis games in C instead of assembly, and one can purchase hardware that constitutes a developer's kit for just north of $100. Being such a nerd, it is hard to express just how excited I am over the prospect of being able to develop games that run on a Sega Genesis. It's basically a childhood dream come true -- and there's just something way cooler about developing a game that runs on a retro console rather than modern computers. Not to mention, in a weird kind of way, you get total cross-platform compatibility for free -- Genesis emulators exist for every major operating system, so if you create a game that runs on a Genesis, by extension it will also run on any modern computer system! Total win!

With all that in mind, I immediately placed orders for the items above, downloaded the SGDK, and commenced getting it set up and working. Based on my historical experience with such things, I expected it to be much more difficult, but the process actually proved to be remarkably smooth and easy.

The installation process, though it says it's for Windows, looked remarkably Linux-like. Make file? Executables with no file extension? But it turns out the executable does have an .exe extension and the tutorial just didn't mention it. Compiling the SDK went off without a hitch, which was the first of many pleasant surprises.

There's a nice Hello World tutorial which is great for verifying that you can compile ROMs that will run on Genesis hardware, which to me is the most important thing -- if you can compile an "executable" (or the equivalent) that will run on the real thing, the rest is just details. 🙂

There are directions for how to compile on the command line. I had to tweak a couple of the paths shown in the commands, but otherwise, these likewise worked perfectly. With that, I was able to get the Hello World tutorial to compile and run the resultant ROM on a Genesis emulator!


For Great Justice!

To the layman, this may seem like much ado about nothing. What's so great about just displaying some text? But the point is, the code compiled into a valid ROM that runs on a Genesis emulator (and so, presumably, would run on a real, physical Genesis as well), and it executes and does what it's supposed to do. That is a big deal. It is literally the biggest hurdle. As I said above, having proven that I can compile valid, runnable Genesis ROMs with this SDK, now I can do anything. It's just a matter of time and effort.

(My Genesis hardware and dev cart haven't arrived yet, but I'll certainly verify that my compiled ROMs run on them the moment they arrive).

For a project like this, just using basic text editors to write the code would be an impediment. Having some nice IDE features like autocomplete and immediate detection of syntax and semantic errors would be highly valuable. Unfortunately, the official guide doesn't explain how to set up SGDK to work with my favorite IDE, VSCode. I found a "third-party" guide that does explain this, but it leads to a compilation error about missing "libres.h". Turns out its includes are not sufficient and you also need to include "${default}" and SGDK's "res" folder (in addition to its "inc" folder). But just add those, and SGDK development can be done in VSCode no problem. 🙂

So what's next? Time to start teaching myself all the hardware details about the Genesis that I'll need to know to develop effectively for it, as well as all the functionality provided by SGDK. Then I'll be able to dive into Genesis game development proper.

More soon? Hopefully!

1 | 2 | 3