Shopping Cart (0)

Now Presenting IRIXBASIC

IRIXBASIC Overview

This is the IRIXBASIC logo.

Created by Andrew Hazelden
Based upon uBASIC by Adam Dunkels

IRIXBASIC is a simple BASIC interpreter that was developed for the 2012 Summer RetroChallenge. IRIXBASIC is designed for the Silicon Graphics O2 system and provides a graphical basic interpreter. It supports the standard basic language drawing commands like plot, move to, line to, and circle. The program uses SDL for graphics along with the SDL_ttf and SDL_gfx libraries.

I was inspired to create this project for the retro challenge because my earliest childhood memories of computers is from the evenings I spent writing small BASIC programs on an Atari 400. It also seems appropriate that IRIXBASIC was launched on July 31, 2012. That is exactly 30 years to the day the Commodore 64 computer hit the market.

Screenshots

Here are a few screenshots of IRIXBASIC running on IRIX 6.5 on my Silicon Graphics O2 system.

This is the IRIXBASIC mega_circles.bas example running on my SGI O2 system.

This is the IRIXBASIC mega_circles.bas example running on my SGI O2 system.

IRIXBASIC feels right at home on IRIX 6.5.

IRIXBASIC feels right at home on IRIX 6.5.

There is a folder of examples that will get you started with IRIXBASIC in no time.

There is a folder of examples that will get you started with IRIXBASIC in no time.

The IRIXBASIC startup screen has a nice retro feel.

The IRIXBASIC startup screen has a nice retro feel.

This is the graphics output from the waves.bas example.

This is the graphics output from the waves.bas example.

Download IRIXBASIC

IRIXBASIC version 1.0 alpha now available for download. The download includes precompiled versions of IRIXBASIC for Silicon Graphics IRIX 6.5 and Mac OS X 10.6. The download includes example .bas scripts that are stored in the scripts folder. The source_code folder also has an untested Linux makefile for the adventurous types.

irixbasic-v1-alpha.zip (1.2 MB)

You can also explore the IRIXBASIC source code on GitHub.

Using IRIXBASIC

You need to launch IRIXBASIC from the command line so it knows the path to the IRIXBASIC font, default script, and the program icon.

When you run IRIXBASIC from the command line you have the following options:

Usage: irixbasic <script.bas> [options]

Options:

–window <width> <height> [-fullscreen]

Set the size of the main window

Here are several command line options you can explore:

You can start IRIXBASIC and it will launch the default program (scripts/default.bas):

./irixbasic

You can start IRIXBASIC and launch a specific .bas file:

./irixbasic scripts/waves.bas

You can start IRIXBASIC and launch the program in a resized window:

./irixbasic scripts/waves.bas –window 800 600

You can start IRIXBASIC and launch the program in fullscreen mode:

./irixbasic scripts/waves.bas –window 1280 720 -fullscreen

Once you start IRIXBASIC you will see a blue console window that lists the current script. To start running the script click in the blue console window. You can quit a script at any time by bringing the blue console window to the foreground and pressing the ESC (escape) key on your keyboard.

Language Syntax

IRIXBASIC works with a subset of the standard BASIC syntax. Here are a few examples to show what is possible.

Here is an example of a random number generator and the print command:

10 cls

20 n = random

30 print “Your lucky number is: “, n

40 sleep 1000

50 end

The print command writes text on the screen. You can use words in quotes, numbers, and integer variables. You can add a comma to insert a space between each item or a semicolon to keep the text together.

Here is an example that shows a for / next loop:

10 for x = 0 to 100 step 10

20 print “loop: “, x

30 next x

40 end

The step command is optional and can be used to increment the for / next loop faster.

Here is an example of an if / then comparison:

10 cls

20 c = 5

30 if c<10 then print “c is less than 10”

40 sleep 1000

50 end

Here is an example of a goto command:

10 print “Hello World!”

20 goto 10

30 end

IRIXBASIC Syntax Highlighting

I have created an IRIXBASIC Syntax highlighting module for TextWrangler and BBEdit. This module makes it easy to edit your IRIXBASIC .bas programs using the best text editors on the Mac. The irixbasic.plist codeless language module is based upon the uBASIC.plist created by John Bussjaeger.

You can now edit your IRIXBASIC programs with syntax highlighting on the Mac!

You can now edit your IRIXBASIC programs with syntax highlighting on the Mac!

You can download the IRIXBASIC language Module on GitHub.

Programming Notes

The IRIXBASIC scripts have to end with the .bas file extension.

The scripts need to use line numbers and the last line of every program should finish with a line number and the “end” command.

Variables in IRIXBASIC are the lowercase letters a-z.

The IRIXBASIC program works with integer based math.

If no script name is provided from the command line the default script will be run. The default script is called “default.bas” and is located in the relative file path:

scripts/default.bas

Note: The REM command doesn’t work at the moment so you can’t have comments in the file.

Graphics Commands

The following graphics commands are supported by IRIXBASIC:

cls / clear

Clear the screen using the current backcolor.

forecolor 255, 255, 255

Set the foreground drawing color using r g b values (0-255)

backcolor 255, 255, 255

Set the background drawing color using r g b values (0-255)

plot x, y

Draw a colored point using the current foreground color value.

line x1, y1, x2, y2

Draw a line onscreen using the current foreground color value.

moveto x1, y1

Move the position of the next graphics drawing command.

lineto x1, y1

Draw a line from the last drawing position to the current x / y position using the current foreground color value.

circle x1, y1, radius

Draws a circle using the current foreground color.

fcircle x1, y1, radius

Draw a filled circle using the current foreground color.

sleep 1000

Add a delay in milliseconds. ( 1000 ms = 1 second )

timer

Elapsed program runtime counter in seconds. ( The timer output may reset after running for a while. )

random

Generate a random number from 0 to 127.

srand 25

Use a random seed value to randomize the number generator.

cos 42

Returns a 7-bit integer cos value. An output of -127=-1,  0=0, and 127=1

sin 42

Returns a 7-bit integer sin value. An output of -127=-1,  0=0, and 127=1

button

Returns 1 if the mouse button is pressed and 0 if it is released.

Example IRIXBASIC Scripts

The following examples are included with IRIXBASIC to get you up and running:

boat.bas

Draws an ASCII art boat onscreen using the print command.

circles.bas

Draws random circles onscreen.

click.bas

This demonstrates the mouse “button” command. The script shows a green circle when you click the mouse button and a red circle when the mouse button is up.

countdown.bas

This is a countdown to launch example that uses the sleep command.

default.bas

This is the default program that is run if you don’t type in the name of a script.

hello.bas

Prints the words “Hello World” onscreen until you press the escape key to quit.

light-rays.bas

Draws colored lines onscreen using the forecolor, moveto, and lineto commands.

mega_circles.bas

Draws even more random circles onscreen.

random.bas

Prints off 10 random numbers. This demo doesn’t use the srand function so it has the same number sequence every time.

text.bas

Draws colored text using the forecolor command.

timer.bas

This script starts a 15 second countdown using the timer command.

waves.bas

This shows an integer based wave drawn using cosine.

IRIXBASIC Updates

Sept 9, 2012 – IRIXBASIC now works on Sun Solaris!

IRIXBASIC now runs on Solaris!

IRIXBASIC now runs on Solaris!

I have good news for Sun Solaris retro-computing fans. Mark Wickens has kindly provided a Solaris UNIX makefile for IRIXBASIC. You can now compile & run IRIXBASIC on your favorite Sun computer systems. Mark compiled and tested IRIXBASIC on a Sun Ultra 5 using the opencsw binary packages repository for Solaris 9.

Note: The SDL graphics library “SDL_GFX” isn’t in the opencsw repository and has to be compiled separately to use IRIXBASIC.

You can download the official IRIXBASIC for Sun Solaris makefile here:
Makefile.sunos

5 comments
  1. Thanks Mark! Please let me know if you have a chance to try IRIXBASIC on your SGI Indigo 2.

Comments are closed.