Sega Saturn Homebrew with Game BASIC

Part 5: Tutorial Programs

This section will be a living document, slowly growing over time to cover the tutorial programs documented in the “Tutorial Manual” that comes with the complete Game BASIC package.  They’ll be organized into four sections: Basic Programming, 2D Graphics, 3D Graphics, and Sound.  If you haven’t already, start with Part 2 for several simple example programs.  These tutorials will not repeat some of the basic file operation commands that are covered there.

Section 1: Basic Programming

First, let’s start with some very simple output examples.  These commands should all be entered directly on the Saturn at the Ready prompt, rather than via BASTERM.  Type each in and hit Enter to see the results!

Text output

PRINT "HELLO!"

Numeric output

PRINT 1+2

Clear the screen

CLS

Assign numeric variables with LET

LET A=1
PRINT A

Assign numeric variables without LET and use arithmetic operations

X=2
Y=3
Z=X+Y
PRINT Z

Assign string (text) variables

A$="HELLO!"
PRINT A$

Assign string (text) variables and concatenate

A$="HELLO, "
B$="WORLD!"
PRINT A$+B$

Use line numbers to write and store a program into Work RAM

10 PRINT "HELLO!"
20 END
LIST
RUN
CLS
LIST

(See Part 2, Step 3 for more on editing programs in Work RAM.)

Clear the Work RAM and start a new program

NEW

From here on out, programs will have line numbers.  This means you can either enter them directly into the Saturn or use the techniques from Part 4, Option 1 to execute them from BASTERM.

A simple clock and loop

100 SCREEN 0
110 ZOOM 4,2,4
120 *LOOP
130 LOCATE 0,2:PRINT RIGHT$(DATE$,18)
140 GOTO *LOOP

IF/THEN logic

10 A=0
20 A=A+1
30 PRINT A
40 IF A=500 THEN GOTO 60
50 GOTO 20
60 END

Reformat and renumber programs

LIST
RENUM
LIST

(Run the above directly from the Saturn)

FOR/NEXT loops

10 A=0
20 FOR I=1 to 10
30 A=A+I
40 NEXT I
50 PRINT A
60 END

Nested FOR/NEXT loops

10 FOR I=0 to 10
20   FOR J=0 to 10
30         PRINT STR$(I)+","+STR$(J)
40   NEXT J
50 NEXT I
60 END

Using SUBs

100 GOSUB 200
110 FOR I=1 to 4
120 GOSUB 210:GOSUB 220
130 NEXT
140 GOSUB 210:GOSUB 200
150 END
200 PRINT "-----------------":RETURN
210 PRINT "|   |   |   |   |":RETURN
220 PRINT "|---|---|---|---|":RETURN

Using arrays

100 DIM BOX$(4)
110 BOX$(0)="CANDY"
120 BOX$(1)="MANJYU"
130 BOX$(2)="CHOCO"
140 BOX$(3)="SENBEI"
150 BOX$(4)="JERRY"
160 FOR I=0 TO 4
170 PRINT BOX$(I)
180 NEXT
190 END

READ/DATA commands

100 DIM BOX$(4)
110 FOR I=0 TO 4
120 READ BOX$(I)
130 PRINT BOX$(I)
140 NEXT
150 END
160 DATA CANDY,MANJYU,CHOCO,SENBEI,JERRY

Section 2: 2D Graphics

Coming soon…

Section 3: 3D Graphics

Coming soon…

Section 4: Sound

Coming soon…

Leave a Reply

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