Sega Saturn Homebrew with Game BASIC

Part 2: Hello, Saturn!

Step 1: Our First Program

Let’s start our Game BASIC adventure in the same place as most programming tutorials: Hello, world!  But we’re doing this on Saturn, right?  So, let’s mix it up a bit…

Boot Game BASIC on your Saturn and you should see a screen like this:

Now type in the following, either with your connected keyboard or with your controller using the virtual keyboard (hit L+R+Start to bring it up).

10 PRINT "HELLO, SATURN!"
20 GOTO 10
RUN

Once you hit Enter after entering RUN, your Saturn should output something like this:

Congratulations, you’re now a Saturn programmer!  Hit Ctrl+C on your keyboard or A+Start on your controller to cancel the program and return to the prompt.

Step 2: Loading a Program from CD

Now here’s where things get more interesting.  Game BASIC makes it really easy to read from devices, such as the CD-ROM drive.  Type the following and hit Enter:

FILES "CD:"

You should see a whole list of files scroll by.  These are all the sample files available on the CD!  So, let’s explore one.  Type the following and hit Enter:

LOAD "CD:CLOCK.B"

You should hear the CD spin up momentarily, then you’ll be returned to the “Ready” prompt.  Type the following and hit Enter:

RUN

Cool, huh!?  Assuming you’ve set your Saturn’s internal clock correctly, you should see today’s date and time!  Hit Ctrl+C or A+Start to cancel the program and return to the prompt.

But… uh, oh.  Something doesn’t look right, does it?  Cancelling out of a program often leaves Game BASIC in a strange state, especially if the program you’re running messes with the various screen modes.  Bring everything back to normal with a simple press of “F12” and we’re good to go. (F12 is available via the virtual keyboard if you don’t have a physical one connected.)

Step 3: Editing a Program

Okay, the clock is pretty cool, but how does it work?  Well, you can review the code for any loaded program with the following command:

LIST

List out the clock program, and you can see it’s pretty simple.  It switches the Saturn to a display mode called SCREEN 0, zooms in a bit to make everything look bigger, retrieves the date from the Saturn and formats it to look nice, then loops forever to keep it updated to the second.

But what if you don’t like that and want it to work differently?  Cancel the program (you should know how to do that by now) and run the trusty LIST command again.  Now, you can use the Page Up (P.↑) and Page Down (P.↓) commands to navigate the code!  Change this line:

110 ZOOM 4,2,4

To this:

110 ZOOM 4,1,4

VERY IMPORTANT: Once you make the edit, you must hit Enter while on the line you’ve just edited!  If you don’t do this, your change won’t be saved to memory and you’ll have to do it over again.

Now use the arrow keys or A+D-pad to navigate the cursor to the start of a blank line and LIST your program again.  If all went well, you should see your edits and be able to RUN the program and see what changed!  This was a minor modification, but you get the idea.

Step 4: Saving a Program to BRAM

That was a lot of hard work, wasn’t it?  You wouldn’t want to lose such important stuff, would you?  So, let’s save it and make sure we can cherish it forever!  This is where the Saturn’s internal memory really comes in handy.  Back at the “Ready” prompt, type the following and hit Enter:

FILES "BRAM:"

You’ve already seen the FILES command, but this time, we’re telling it to look at the Saturn’s internal backup memory.  This command will list out any file in memory that ends with the “.B” extension.  Since this is your first time using Game BASIC, there won’t be any results.  Let’s change that.  Now type the following and hit Enter:

SAVE "BRAM:TEST.B"

Now run the FILES command again, and you should see your program listed!

FILES "BRAM:"

Your program can now be loaded back at any time.  In fact, let’s prove it.  If you want, you can turn your Saturn off and back on again and you’ll still see your program in the file listing (assuming you have a working battery in your system…).  You can even exit to the Saturn’s internal memory manager and your program will show up there, just like any other save file.

But let’s shortcut all that and run the following three commands:

LIST
NEW
LIST

This should demonstrate that your program is gone from the Work RAM and needs to be reloaded, just as if we had power-cycled the system. (The “NEW” command replaces the loaded program with a new, blank one.)  Enter the following commands:

LOAD "BRAM:TEST.B"
LIST

And there you have it; your program is back!  RUN it or edit it to your heart’s content.  If you ever get tired of the program or need to free up space, you can always delete it from the Saturn’s built-in memory manager, or just run the following:

KILL "BRAM:TEST.B"

Run our old friend the FILES command to verify that it is, in fact, gone.

NOTE: The FILES, LOAD, SAVE, and KILL commands can all read from multiple devices.  If you have an external memory cartridge that supports direct-save, or even a Saturn Floppy Disk Drive, you can work directly with those!  Here are the different options:

  • BRAM – Internal, battery-backup RAM
  • CRAM – External, cartridge RAM
  • FD0 – Saturn Floppy Disk Drive, side 1
  • FD1 – Saturn Floppy Disk Drive, side 2
  • COM – Your PC’s temporary folder (if you have a serial connection set up)

Just substitute those in where we used “BRAM” in the examples, and you’re good to go.  For example, to save to cartridge RAM, use the following:

SAVE "CRAM:TEST.B"

Step 5: Explore the CD’s Demo Programs

Okay, yeah, nothing we’ve done so far is super impressive.  Let’s start exploring some cooler stuff!  Remember all those programs we saw when we used the FILES command on the CD drive?  Let’s do that again, but this time, we’ll add a wildcard to look at only executable programs:

FILES "CD:*.B"

See the one called “LAUNCH.B”?  That’s what we’re interested in.  You should know now how to load and run it, but if you need a refresher, here are the commands:

LOAD "CD:LAUNCH.B"
RUN

(Protip: If you have a keyboard attached, hitting Shift+F1 automatically launches the LAUNCH.B program without having to type any of the above!)

This program is a friendly browser that allows you to navigate all of the demo programs on the disc!  I recommend just exploring and having fun with what it provides.  Some of the programs are excellent examples of how powerful Game BASIC really is.  I recommend DEMO.B, G_JUMP.B, G_MAZE.B, G_THESEU.B, and G_MOBIL.B.

Many of the demos require peripherals, such as the multi-tap, light gun, 3D controller, Shuttle Mouse, or Mission Stick.  For example, G_JUMP_A.B is a version of G_JUMP.B that uses the analog pad of the 3D controller, and G_JUMP_M.B uses the Mission Stick.  If you don’t have the right peripheral attached when you launch a demo, you’ll usually get an error message in Japanese.  If you don’t speak any Japanese, you’ll just have to experiment.  But hey, that’s what the Lab is all about, right?

That’s it for Part 2!  Technically, you have everything you need to start writing Saturn games!  Between the tutorials in Part 5, additional documentation in Part 7, and LISTing the code from the demo programs on the CD, you can learn a lot and start programming your own Saturn applications.  But it’s kind of tedious working directly off of the Saturn, isn’t it?  If you’re lucky enough to own the Saturn-to-PC serial cable that comes with the complete kit, continue on to Part 3 to really level-up your Saturn development!

Leave a Reply

Your email address will not be published. Required fields are marked *