-
-
Notifications
You must be signed in to change notification settings - Fork 189
Tuto Introduction
First, you need to know that SGDK uses C language (assembly is also possible but not necessary) so it's highly recommended to be familiar with C programming before trying to develop with SGDK ! Trying to learn C language at same time than learning Sega Mega Drive programming is definitely too difficult and you will end nowhere.
It's also important to have, at least, a basic knowledge about the Sega Mega Drive hardware (specifically the video system). If that's not the case then i recommend you to read these documents:
- Sega Mega Drive Graphics guide page from Raster Scroll.
- Sega Mega Drive graphics guide page from Mega Cat Studios.
- Sik's Blog: more dedicated to assembly programming but explain a lot (and quite nicely) about the Sega Mega Drive hardware.
- Mega Drive Architecture: a nice article explaining the Mega Drive architecture.
- Genesis Software Manual which contains absolutely everything you need to know about the Sega Mega Drive.
These basic tutorials aim to give you the basis to start developing on the Sega Genesis / Mega Drive using SGDK, they will help you understanding how SGDK work and how to use it efficiently but they do not aim to learn you C language programming nor to explain you how the Sega Mega Drive works internally so take attention to the disclaimer.
Before starting you should now that you have a doxygen in the 'doc' folder of SGDK giving you a description for all SGDK functions and structures, so always dig in the doxygen (or in the SGDK .h files as the doxygen is created from them) when you want to know what a specific function does as these tutorials will only show you how to use some of them.
Another important point to know is that SGDK heavily relies on resources which are compiled through rescomp tool. You can read the rescomp.txt file to know which kind of resource you can use and how to declare them then you can check the 'sample' folder from SGDK and in particular the sonic sample which is a good showcase of SGDK usage in general (functions and resources).
Debugging is always an issue when you're developing on those old systems. Unfortunately emulators supposed to support GDB - the GNU debugger - doesn't seem to have complete support of it, at least i was never able to use it correctly with working breakpoints and execution stepping. If someone was able to sort it out and got it working correctly then i would be really interested in knowing the process :)
Hopefully you still have Gens KMod, this emulator supports some advanced debugging features and one of it is really useful: the message log capability.
**Before being able to use it, you need to enable the option **in the Options --> Debug... dialog:
Then you can use the KLog_xx(..) methods from SGDK to log messages / values to the Debug Message dialog (CPU --> Debug --> Messages menu):
This will really help you in examining if a specific action happened or see variable values for instance. It becomes even better when you're building in debug profile (see SGDK Usage page) as SGDK will also log some information in the Debug Message dialog which may be really useful to you. You can change the SGDK log level by changing definition of LIB_LOG_LEVEL in the config.h file then recompiling the library itself in debug profile.
It's not as convenient than real GDB debugging but still better than nothing :)
The problem of Gens Kmod is that it has some flaws, first it has some bugs / memory leaks and secondly it's quite inaccurate in general so be sure to always test on more accurate emulators when possible (as BlastEm) or directly on the real hardware. Another good emulator for its debugging features is Regen Debug version, while not being as accurate than BlastEm, it's still much better then Gens KMod in that aspect and it offers some exclusive debugging features.
If you feel ready then you can continue on the Hello World tutorial !