• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
Retro Game Coders

Retro Game Coders

Retro computer/console game + dev community

  • About
    • Retro Computer Collection
    • Contact
  • Blog
  • Retro Resources
    • Retro Gaming Timeline
    • Online Retro IDE
    • Retro Pixel Art Editor
    • Dungeon Loom Map Editor
    • 6502 Programmer’s Reference
    • Emulators
      • Acorn Electron
      • Amstrad CPC Emulator
      • Online BBC Micro Emulator
      • Commodore PET Emulator
      • Browser C64 Emulator
      • DOSBox/DOS PC emulator
      • Tandy CoCo/Dragon
    • Best Retro YouTube Channels
    • New Retro Books
    • Raspberry Pi Amiga Emulation
    • MiSTer FPGA Tutorial
    • BMC64 C64 Pi
  • Community

Home » Retro Game Coders Blog » Retro Gaming News and Reviews

Run a Modern + Commodore-Style BASIC Anywhere with RGC-BASIC (Not an Emulator)

RGC-BASIC basic interpreter for windows mac linux

RGC-BASIC is a modern BASIC interpreter that runs on Windows, Mac, and Linux. Write and run BASIC code on your PC or in a web browser without an emulator.

Ever wanted to write a quick script or utility for your Windows, Mac, or Linux computer and wished you could just use your familiar BASIC instead of Python, BASH, C, Golang, or NodeJS?

I’ve been working on a project called RGC-BASIC, a Commodore BASIC–style interpreter written in C, but with modern conveniences.

Originally I called the project CBM-BASIC due to its roots, but it turns out there already was a project by that name, plus the scope rapidly expanded to go way beyond mere retro BASIC parity to become a truly cross-platform Retro Game Coding BASIC!

It’s inspired by the BASIC you’d find on machines like the C64, and it runs in the terminal as a normal program for your modern computer or even in your web browser.

Just to set expectations early:

  • this is not an emulator
  • in fact, it doesn’t simulate hardware at all
  • no attempt has been made to be identical to Commodore V2 (eg. commands have been added and most C64 POKEs don’t work on your PC)
  • it just runs BASIC (with some modern conveniences and structured programming features added)

That turns out to be more fun and useful than it sounds.

Join Retro Game Coders Community
Join the Retro Game Coders Community

How it Started

This started as an experiment based on a PDP 11/BSD project by David Plummer (check his video below, it’s worth a watch).

From there I kept extending it, mostly because it was fun. But at some point it crossed over into something I also found practical:

  • read and write real file system files
  • work with standard input and output
  • supports command line arguments
  • you can code non-trivial BASIC programs
  • execute system commands and launch applications

At that point it stopped being a demo and became something I actually use in day-to-day life.

You can now follow the tutorials and edit the code right in your web browser with the Online Retro IDE

– No downloads, configuration, etc necessary, and it is free!

Using RGC-BASIC

Download and extract the .Zip file for your system. There are executables for Windows, Mac, and Linux. If you need/prefer, you should also be able to compile using the source code for other systems too.

Then create a text file called hello.bas and run it as a BASIC program directly from your terminal:

./basic hello.bas
10 PRINT "HELLO, WORLD!"
20 END

That’s a trivial example, but you can also refer to the interpreter and create shell scripts if you do this:

#!/usr/bin/env basic
A$="abcdefghijklmnopq"
print right$(a$,5)
print left$(a$,5)

Once the .bas file is given executable permissions, eg. chmod +x script.bas you can execute it just the same as any shell script or batch file, like so:

./script.bas

BASIC as a scripting language – Not Just “Retro BASIC”

This keeps the cozy feel of Commodore BASIC, but adds just enough to make it actually practical for a modern system.

You can also pipe data in and out:

echo 42 | ./basic program.bas
10 INPUT A
20 PRINT A*2

💬 Questions or comments? Head over to the community to discuss!

Command-line Arguments and Launching Programs:

  • ARGC() and ARG$(n) are used for command line arguments
  • SYSTEM() to run shell commands and receive error codes back
  • EXEC$() to capture resulting string command output

So you can do things like:

10 U$ = EXEC$("whoami")
20 PRINT "HELLO ";U$

That’s not very 1980s, but it is very handy. Take a look at my script that helps me manage my Github repositories:

5 REM Delete a git tag vX.Y.Z locally and on origin
10 IF ARGC() <> 1 THEN GOTO 40
20 VER$ = ARG$(1)
30 GOTO 70
40 PRINT "Usage: delete-tag.bas version"
50 PRINT "Example: delete-tag.bas 1.1.3"
60 END
70 TAG$ = "v" + VER$
80 PRINT "Deleting local tag "; TAG$
90 CMD$ = "git tag -d " + TAG$
100 RC = SYSTEM(CMD$)
110 PRINT "SYSTEM returned "; RC
120 PRINT "Deleting remote tag "; TAG$
130 CMD$ = "git push origin --delete " + TAG$
140 RC = SYSTEM(CMD$)
150 PRINT "SYSTEM returned "; RC

Yes, it uses GOTO – OH NO! Let’s rewrite it in a more familiar style:

#!/usr/bin/env basic
# OPTION petscii
REM Delete a git tag vX.Y.Z locally and on origin
REM Check command line argument count
IF ARGC() = 0 THEN
    PRINT "{reverse on}Usage{reverse off}: delete-tag.bas version"
    PRINT "{reverse on}Example{reverse off}: delete-tag.bas 1.1.3"
ELSE 
    REM Do the delete command
    VER$ = ARG$(1)
    TAG$ = "v" + VER$
    PRINT "Deleting local tag "; TAG$
    CMD$ = "git tag -d " + TAG$
    RC = SYSTEM(CMD$)
    IF RC <> 0 THEN
        PRINT "Warning: local delete failed (exit "; RC; "). Tag may not exist."
    END IF
    PRINT "Deleting remote tag "; TAG$
    CMD$ = "git push origin --delete " + TAG$
    RC = SYSTEM(CMD$)
    IF RC <> 0 THEN
        PRINT "Error: remote delete failed (exit "; RC; "). Check origin and network."
        END
    END IF
    PRINT TAG$; " deleted."
END IF

If you supply no arguments it tells you how to execute the program. When you do pass an argument it concatenates the string to pass to Github as the tag to delete and checks the response back from the git command to see if it worked.

How about an example of using cURL to get the current time in London using an internet time server:

Launching curl to get the current date and time in london
e$ = "curl -s -f 'https://timeapi.io/api/timezone/zone?TIMEZONE=EUROPE/LONDON'"
r$ = EXEC$(e$)
ft$ = MID$(r$, instr(r$, "currentLocalTime")+19, 19)
d$ = LEFT$(ft$, 10)
t$ = MID$(ft$, 12, 8)
print "": print "The current date and time in London is: {white}{reverse on}";
print d$ + "{reverse off} {reverse on}" + t$ + "{reverse off}"
print ""

Working with Your File System

You can read and write files on your actual filesystem:

10 OPEN 1,1,1,"test.txt"
20 PRINT#1,"HELLO FILE"
30 CLOSE 1

It behaves like classic BASIC, just without the tape or 1541 5 1/4″ disk loading delays.

Commands:
    OPEN   - open a file for reading or writing
    PRINT# - write numbers and strings to a file
    INPUT# - read from a file into variables
    CLOSE  - close a file when done (always close to avoid losing data!)
OPEN uses: file number, device, access, "filename"
    - File number: 1 to 255 (like a handle; use it in PRINT#/INPUT#)
    - Device 1 = disk/file (normal file on your computer)
    - R/W/A: 0 = read, 1 = write, 2 = append (add to end of file)
    - Filename: path in current directory, eg. "DATA.TXT"

Structured Programming & Keeping BASIC Readable

You can write line-numbered programs and use GOTO, mainly for where you have existing code, but you’re not forced to.

Instead, you get:

  • named labels
  • long variable names
  • arrays and multi-dimensional data
  • #include your own custom code libraries
  • structured flow with
    • IF ELSE END IF,
    • FOR,
    • GOSUB,
    • WHILE,
    • and user-defined FUNCTIONs

So it still feels like BASIC, just a bit easier to live with.

#INCLUDE "tutorial_lib.bas"
PRINT "=== Math Helpers Menu ==="
PRINT " 1. Factorial"
PRINT " 2. GCD of two numbers"
PRINT " 3. Check if prime"
PRINT " 4. Quit"
PRINT
done = 0
WHILE done = 0
  INPUT "Choice (1-4)"; c
  IF c = 1 THEN
    INPUT "Number"; n
    PRINT "factorial("; n; ") ="; factorial(n)
  END IF
  IF c = 2 THEN
    INPUT "First number"; a
    INPUT "Second number"; b
    PRINT "gcd("; a; ","; b; ") ="; gcd(a, b)
  END IF
  IF c = 3 THEN
    INPUT "Number"; n
    p = is_prime(n)
    PRINT n; " -> "; p; " (1=prime, 0=not)"
  END IF
  IF c = 4 THEN
    PRINT "Goodbye!"
    done = 1
  END IF
  IF c < 1 OR c > 4 THEN
    PRINT "Invalid choice"
  END IF
  PRINT
WEND
END

PETSCII (without the mess-cii)

Instead of this:

PRINT CHR$(147);"HELLO";CHR$(28);"WORLD"

You can also write:

PRINT "{CLR}HELLO {RED}WORLD"

Those {TOKENS} are expanded at load time into the equivalent CHR$() calls, so the program behaves the same but stays readable

You can also instead use the added COLOR and BACKGROUND commands to use the numbered colours if you like.

TEXTAT/LOCATE (Simple Screen Control)

You can position text and build simple text UIs:

LOCATE 10,5
PRINT "HELLO"
TEXTAT 0,0,"SCORE: " + STR$(S)

With colour support mapped onto the command console, it’s enough to build terminal-based games and tools without needing a full graphics system.

Example: Star Trek

Port of Super Star Trek
Port of Super Star Trek

One of the included examples is a port of the classic Star Trek game ported from the conversion created by Electron Greg. It’s a good test because it exercises quite a lot of the interpreter:

  • input handling
  • arrays
  • control flow
  • screen output
  • etc

Run it like this:

./basic -petscii examples/trek.bas

Using -petscii helps a lot here, as it maps colours and control codes so things look closer to a period-appropriate machine.

Example: A Cross-Platform Text Adventure

Another nice use case is text adventures as they are, as the name suggests, text-based.

Use my text adventure framework to create your own games

If you’ve followed my earlier guide about text adventure programming you’ll recognise the structure straight away.

Here’s a very cut-down idea of what I mean:

10 PRINT "YOU ARE IN A ROOM"
20 INPUT A$
30 IF A$="LOOK" THEN PRINT "THERE IS A DOOR"
40 IF A$="GO" THEN PRINT "YOU LEAVE"

The version I’ve included in the download builds on that into something more structured. It’s enough foundation to build a real game and is an idea for where you can take this:

  • write a game once
  • run it on Windows, macOS, Linux
  • keep it close to classic BASIC but with modern performance

It’s a simple framework for building something bigger without needing any complex tools or an emulator.

Who This Is For

This is clearly not for everyone (as the negative reaction from some purists and BASIC-haters already proved) but will probably make sense if you:

  • enjoy programming in BASIC and want a modern way to use it
  • are building retro-style projects
  • want a lightweight scripting alternative to BASH
  • like experimenting with interpreters or languages (the C code is all there for you to analyse or expand)

Remember this isn’t about recreating the C64 – If you want full hardware “cycle” accuracy and C64 memory map, an emulator is still the right tool.

What’s Next

Phase one of this project was making it useful. Phase two is making it better for games.

On the to-do list:

  • more accurate PETSCII representation DONE! ✅
  • improved visual output (possibly bitmap-style) DONE! ✅
  • sound support
  • more game-oriented features

Longer term, I’d like to explore compiling to WebAssembly/JavaScript, so BASIC programs can run directly in the browser as well as the terminal.

Write once, run anywhere, but still programmed in BASIC.

Right after publishing I set to work on a graphical version of the interpreter and now we have, amongst other improvements, full PETSCII support via bitmap rendering. Under the hood it uses Raylib, so it is still fully Windows, Linux, and Mac compatible.

Full bitmap-based PETSCII output

Try It Yourself

You can grab releases or the source code here:

https://github.com/omiq/rgc-basic

Then run one of the examples:

./basic -petscii examples/trek.bas

Or even more fun, try your own programs!

Credits

The original idea was based on a PDP/BSD BASIC project by David Plummer:

Category: Programming, Retro Gaming News and ReviewsTag: basic programming, RGC-BASIC
Previous Post:Commodore PET shoot em up part 5Advanced PET Screen Drawing Techniques
Next Post:RGC-BASIC Update: Easy, Modern BASIC in Your Browser Has Sprites NowRGC-BASIC basic update now with sprites

Retro Game Coders

Retro computer/console game + dev programming community by Chris Garrett

  • Facebook
  • Twitter
  • Instagram
  • YouTube

Maker Hacks ・ D6Combat・chrisg.com

© Copyright 2025 Chris Garrett

Privacy ﹒ Terms of Service

Return to top