top of page

Written 25th June 2018, by S.A.Ray

How to make Megadrive/Genesis programs

​

The Megadrive( also known as "Genesis" ) needs little introduction in the world of gaming.  Its a 16-bit powerhouse that started the first great console war with Nintendo, sparring with both the NES and Super NES consoles.  They are still making clones of the console even to this day, and whether by means of emulation or FPGA technology will continue to do so...

​

The journey of writing a program for the Megadrive was challenging, but I ended up using a marvelous C sdk written by Stephane Dallongeville called SGDK or "Sega Genesis Development Kit". At this time of writting I have managed to put together a demo that can read the primary gamepad to move a sprite around the screen, scroll the foreground layer, load a bitmap created in Gimp and play a vgm created entirely in VGM Music Maker.

​

Although SGDK is fantastic and fairly easy to setup with Code::Blocks, the documentation is sadly in need of updating and also incomplete.  This tutorial series is intended to be a companion to the SGDK wiki on Github, so use that first and then if you hit a brick wall come back here for more guidence.

Assumptions and tools

I will assume that you are comfortable with the C language and some command line compiling( we require at least one command for converting music files ).  My development for the MD is done on a Windows 10 machine and using the Code::Blocks IDE.  As for SGDK I will assume you have it installed and all is dandy.  The instructions for installing Code::Blocks and SGDK on Windows are well documented and with the Github wiki installation guide you should be in good hands.  Just install SGDK to the root of your C drive, take extra care with adding to the PATH variable and you'll be fine.

​

Once you have the IDE setup you'll need some other things depending on the task at hand. For creating suitable bitmaps for your programs I recommend GiMP and for Music creation, hunt down VGM Music Maker. VMM is an old program but its all you need to create a Megadrive music file in the VGM format that we can then incorporate into our programs.

​

You will also need an emulator, but not just any emulator will do for our development needs.  Stehphane, in addition to SGDK, developed an emulator called "Gens".  The version you will need comes with an enhanced debugger which is extremely useful in displaying a visual representation of what is stored in the Megadrive's Video memory and how data is employed in the display layers.  This enhanced version is called Kmod Gens and was developed by "Kaneda". Who Kaneda is, I do not know, but without this mod I would never have figured out how the MD works.  That makes them very awesome indeed and therefore we salute them. ^_^

​

​

​

What about Assembly language?

I must address one myth about the Megadrive and its that one must use Assembly to write programs for it. That is simply not true and a working example is Sonic Spinball, released in late 1993, which used C instead of Assembly to ensure it was released in time for Christmas. From the work I have seen done using SGDK, I reckon its good enough for most graphical feats, but maybe not something as fast as say the scrolling in Sonic 2.  Playing it safe I'd also say that 3D is probably asking too much of the 16-bit wonder. 

​

Although the Megadrive was a powerful machine for its time, it still uses ancient hardware compared to today's machines like the XBox One, PC and Raspberry Pi...so for now keep your sights low and aim for demos and very basic games such as Space Invader clones.

Our ultimate goal and the first step towards it...

To be clear, I am not teaching you game development but simply how to program the Megadrive in C. If its stuff like collision detection, physics or AI then you won't find any of that here.  Instead our goal is to make a simple demo where you move a sprite around the screen using the primary gamepad, play a tune upon pressing an action button and produce a scrolling foreground against a static background.

​

This has been a long-winded introduction but necessary. The next installment will introduce displaying text and obtaining input from the Megadrive's primary gamepad and we will also be laying the foundation for the eventual demo.

​

Looking further into my crystal ball we might even explore colour palettes with the VDP...but only if you are good!

​

​

Have fun!  ^_^

​

...

bottom of page