SGDK. Creating a Hello World application.

Preface

Sega Genesis Development Kit (SGDK) is a free set of tools needed to create a game for the Sega Megadrive console. This GDK contains a compiler of C code, and a set of libraries we need.

The purpose of this tutorial is to create the simplest application “Hello World“. But, first, you need to prepare the tools.

We prepare the tools.

First, download the latest version of SGDK, from the official GitHub repository (Link).

Then, move the contents of the archive to the C:/SGDK folder

Now, you need to create a system variables, for this click RMB(Right Mouse Button) on the “This computer” button. In the list, select “Properties”

Next, go to “Advanced System Settings” and click the “Environment Variables” button

And create a variable GDK_WIN

The variable is created. Don’t forget to click “OK” to confirm the action.

Write the code.

Download an empty project from MEGA.

And move it, anywhere. Then, open the main.c file in the src folder.

#include <genesis.h>

int main()
{

while(1)
    {
        VDP_waitVSync();
    }
    return (0);
}

It already has written the necessary basis, let’s analyze it.

#include <genesis.h>

Here, we have connected a library with the necessary functions.

int main()

The entry point to the program.

VDP_waitVSync();

This function is waiting for the frame to be rendered.

while(1)
{
   VDP_waitVSync();
}

The operation will be repeated an infinite number of times while(1).

Now, you need to add the inscription“Hello World”to the screen. To do this, add the following command, to the beginning of the main block.

VDP_drawText("Hello World", 1,1);

Let’s analyze the syntax.

VDP_drawText("message", x_tail, y_tail);
  • message – text displayed on the screen.
  • x_tail is a point x,on a tile grid.
  • y_tail – point y,on the tile grid.

Tile is an image of 8×8 pixels.

That is, in our case.

VDP_drawText("Hello World", 1,1);

So, we will display the message “Hello World“, at the coordinates:

  • x = 8
  • y = 8

Now, open compile.bat to compile the application.

After compilation, a rom.bin file should appear in the out folder of the project. Run.

Final result.

Пожалуйста отключи блокировщик рекламы, или внеси сайт в белый список!

Please disable your adblocker or whitelist this site!