Learn Commodore 64 BASIC Programming - Type-In Text-Based Games

BASIC, and BASIC computers - the Commodore 64, the Commodore PET

When I bought my C64 Mini, I was very interested to discover that it didn’t just have pre-loaded games, but also included C64 BASIC. BASIC is the original programming language designed for the average person, and it’s still a great way to play some fun games while you learn about coding logic.

Want to learn how to actually program your C64 Mini or Commodore 64, and type in some games? BASIC is easy to learn, and was created to make it simple for regular people to learn programming. I will teach you classic BASIC programming, with a selection of text-based games you can type in.

Table of Contents

In the late 70s, and early 80s, BASIC was the go-to answer for programming on any number of popular home computers that started coming out. In fact, most of them just went straight to BASIC as soon as you turned them on. It was so unavoidable, that at some point, everyone dabbled and did a little something like:


20 GOTO 10

(If you don’t know what this does, time to jump in. Type this into BASIC, including the line numbers, and hitting ENTER at the end of each line. Type RUN after you have both lines in. Press ESC on your USB keyboard to stop it from running, or RUN/STOP if you're using an OG C64.)

Don’t have BASIC handy? Use this online C64 emulator. Hit ESC to stop running the program.

Already know BASIC? Jump straight to the resources.

In the Beginning Was Text (-Based Games)

Before we had the firepower to do game graphics, we had text-only interfaces. Naturally, the geeks using these machines weren’t satisfied to just do serious computation work. They wanted to have some fun, too. This meant creating games that worked within that text-based paradigm. They used words and numbers to describe things, ask questions, and respond back with results to decisions made by players. It was what people had, and they made some clever and fun games. For those raised on games that represent everything with onscreen graphics, this throwback to text-based games can be a surprising new way to look at things.

The 1977 Trinity - TRS-80 Model I, Apple II, Commodore PET
The 1977 Trinity - comprised of the TRS-80 Model I, Apple II, Commodore PET

This early text-based gaming created a culture where people wrote and freely shared their games. Since one of the promises of the early home computers (from the Commodore PET to the C64, to the Ataris, Apple II, TRS-80s, and more) was that you could learn, an explosion of text-based BASIC games was the result. BASIC is easy, games are fun, and you can get some free entertainment combined with the joy of learning something cool (and impressing friends!).

It’s also important to realize that text-based games strip games down to their essence - concept and gameplay. They let you really focus on what the point of the game is, and how it works. And because there is no complicated apparatus for the things that graphical games require, the workings are much simpler to tinker with. Think you can make a game better? Get inspired by something and want to hash out your own take on it? Programming text-based BASIC games means there’s very little in your way if you want to dive in. Just have at it!

Worth noting here: With the increasing technical complexity that characterizes today’s world, many people are returning to simpler, oldschool ways of doing things. Playing a simple board game with friends helps you to slow down, and enjoy something uncomplicated. Playing vinyl records has a ritualistic quality to it that is imposed by its inherently less-efficient way of playing music. Typing in, playing, and modifying BASIC games has a similar quality. Find the beauty of simplicity as you dig into this oldschool pursuit (and be the hipster all your friends envy).

My Commodore PET running a simple pattern generator in BASIC
Pictured is the Commodore PET I have in my home office. This thing is all retro charm, and sports a text-only interface. On the right is the source for a sweet little BASIC program you can type into your C64 Mini to produce a very cool generated pattern.

The Benefits of Learning the Hard Way

In the early days, there was no downloading, or internet to download from. If you were lucky, you had a cassette drive for data storage, or if you had some money, you might have had a floppy disk drive. The most popular way to share these games though (and yes, they were shared, and open source, since that was the way we rolled) was in print.


Magazines and books were the source for type-in BASIC games

Yeah. Magazines and books regularly published pages upon pages of BASIC code printed out. Want to play the game? You have to type that baby in, bug check (no one is a perfect typist), and then you can play. It took some focus, and a little time, but at the end, you found BASIC was rubbing off on you. You started to see how the game creators were doing things, and you started modifying the games… then making your own from scratch. Making games? Yep. And because it’s just text, it’s not complicated to do.

Keep in mind, that while I will teach you how to download BASIC programs and get them onto your C64 Mini, you learn nothing from just downloading. As tedious as it might feel, the act of typing the stuff in by hand is where the learning happens (you absorb it better by doing, not just looking). It’s also where that quiet focus comes in. Slowness in itself can be a great thing in a hurried world.

Wax on, Daniel-san!

Daniel and Mr. Miyagi in The Karate Kid

The Basics of Starting in Commodore BASIC

Let’s jump in now. Most of what we’ll talk about here should work for anything you have that runs BASIC, but there were sometimes variations in how to do things between say Commodore’s BASIC, and Atari’s, or IBM’s. All of this code should function with just a few (or maybe no) tweaks on something other than a Commodore, but for the sake of focusing, I am going to concentrate specifically on the Commodore 64, and the C64 Mini.

  • To get started on the Commodore 64, just turn it on. There. Now you’re in BASIC, and can start typing in a game. Please wait a moment though, while the rest of us catch up.
  • To get started on the C64 Mini, turn it on, then scroll through the carousel of games until you find C64 BASIC. Select that like you would any other game, and start it. Now plug a USB keyboard into the C64 Mini, and you’re ready to go.

Before we start typing in games, I want to cover a few things that will help you out.

BASIC uses line numbers, as seen above in the example with lines 10 and 20. The instructions are executed line-by-line in numbered order. You can type them out in any order you like though. (No one types in game listings out of sequence, but it means you can go back and add or change lines after the fact.) You type in a line from a listing, like:


And then hit ENTER at the end. That enters the line, and BASIC now remembers it. Type LIST, and watch BASIC kick out what you typed. This lets you review what you have so far. You can also tell it to list only a section of your code when your game grows longer. Just type LIST 100 - 200, and it will list the code from line 100 through 200.

By the way - it’s just a convention to type BASIC code out in all caps. Early computers had no lowercase, and BASIC on new computers is not case sensitive. Just type. C64s will output PETSCII characters on the screen if you hit SHIFT or CAPS LOCK when typing. If you see lots of little graphical shapes that are not letters or numbers, it’s because you’ve tried inputting capital letters.

If you need to change a line, you can just type it over again, and it will overwrite the old one.  You can also LIST a line (LIST 120 to see line 120), and use arrow keys to go back up to it and make changes. Be sure to hit ENTER at the end of the line.

Have you totally blown it and just want to start over? Type NEW.

It’s not necessary for each line to go by tens like 10, 20, 30, etc. It’s just convention for cleaner reading, and so you can go back and insert extra lines between things, if needed, like: 10, 15, 20, 25, 27, 30.

A line with REM is a remark - it has no instructions to the computer, just notes to people looking at the program code. PRINT tells BASIC to output something to the screen. INPUT tells BASIC to wait for a user to type something in.

A variable is something that can hold a value, like a bit of text, or a number. This is assigned like POWER = 5. Now if you have a line with PRINT POWER + POWER, you get 10. If you have NAME$ = "DAVE" and then a line with PRINT NAME$ + NAME$, you get DAVEDAVE written out on the screen.

It’s worth taking a moment to briefly explain a programming concept that is a little weird to the non-programmer. A string can be a single letter/number/punctuation/etc or many, and is treated by the computer as a sequence of characters. It can be a single character, or many. Variables that hold strings are marked with a $. Hence the NAME$ variable above. And the strings themselves that you assign to a string variable must be marked with double quotes ("). Understand that this is NOT the same as the typographic curly quotes you get in a word processor (”).

So then any of the following are allowed:

  • NAME$ = "DAVE"
  • NAME$ = "JOHNNY 5"
  • NAME$ = "R2-D2"

Sooooo... and this is the bit that makes non-programmers think we’re crazy, but it makes perfect sense if you think about it... if NUMBER$ = "5" and you do PRINT NUMBER$ + NUMBER$, you get 55. While if NUMBER (no $) is set to 5 (not the string "5"), then NUMBER + NUMBER gives you 10. The first example is treated as an arbitrary set of characters, the second example is numbers that can have mathematical operations performed. Understand this, and save yourself frustration down the road.

A FOR loop tells BASIC to run through a set of instructions multiple times. GOTO tells it to redirect and start running code on another line number.

With that, the following should be at least vaguely understandable.

For a more in-depth understanding and detailed language reference:

Time to Program That Commodore and Type In Your First Text-Based Game

Make sure your machine is fired up and ready to go. If you don’t have one handy at the moment, don’t let that stop you. Launch this snazzy little Commodore 64 BASIC emulator, and get coding on your first game.

PRO TIP: This whole typing thing can be streamlined if you use two people. Have one read off the lines of code, and the other one type. It can make things smoother, and improve accuracy.



30 PRINT "======="


50 PRINT "=======":PRINT





100 NUM = INT(100*RND(1))

110 PRINT:PRINT "====================":PRINT


130 FOR COUNT = 1 TO 7


150 INPUT ": "; GUESS$









240 GOTO 270




280 INPUT "PLAY AGAIN? (Y/N) "; A$

290 IF A$ = "Y" THEN GOTO 100

300 END

When you’ve got it all in, type RUN, and play the game. To stop the game, hit ESC, and it will quit (saying “BREAK IN 10” or whatever line number) and then say READY. You’re back in BASIC, and can start coding again. You’ll likely need to do this as you run into unexpected behaviors dues to typos (A software bug! Squash it!). It’s also handy as you decide you want to make modifications to try something new.

10 Great Text-Based BASIC Games to Get Started With

Remember that the real value here is sitting down and typing things in. Consider this: woodcarving can be an enjoyable hobby. But buying a carving is not at all the same thing. We’ll get to the process of downloading BASIC games in a little bit. That can be handy for trying things out quickly. But take your time now, and have fun learning.

Note that these are all selected from David Ahl’s immensely popular BASIC Computer Games books, which were written expecting that the computer would have an 80 column (80 characters wide) screen. The Commodore 64 has a 40 column screen. This means that if used as-is, some will format strangely, with the long lines wrapping around. This is usually easy to fix, and good practice for making modifications. To fix long lines of text, break the PRINT statements into multiple lines like so:







The first few are from his first book BASIC Computer Games, published in 1978, which was the first computer book to sell over a million copies. Lyle Kopnicky over at the Vintage BASIC site (with express permission from Mr. Ahl), has converted these over to text files (not just scans of the book pages), and tightened them up a bit to run in his own version of BASIC. I have tried out several of these, and they’ve all run cleanly, except for the aforementioned 80 column/40 column screen formatting,

And before we get going, I must mention that half the charm of Ahl’s books is the very cool robot illustrations done by George Beker. I have included two here.

Beker Bot illustrations from BASIC Computer Games

The games will start off with some simpler ones, and then mix in more sophisticated ones. Super Star Trek and Eliza at the end are both rather involved.

The following games are from David Ahl’s follow-up book More BASIC Computer Games, published in 1979. Note that these are just the scanned book pages, and do not have accompanying text files. Maybe you can share after typing them in?

One final note about these games. These programs hail from the 1970s, and are sourced from different contributors that sent them in to Mr. Ahl. Styles, structure, and line number as well as other conventions vary. Some are pretty tight, and others have little oddities in how they were created. This is long before the present day, in which programmers are often OCD about their adherence to detailed coding styles. Consider any wackiness you find in your digital archaeology just artifacts of the era.

These final two are long programs. Type them in for the full experience of going oldschool, or use the instructions below to download them and get them into your C64 Mini.

The following games are from David Ahl’s follow-up book More BASIC Computer Games, published in 1979. Note that these are just the scanned book pages, and do not have accompanying text files. Maybe you can share after typing them in?

These final two are long programs. Type them in for the full experience of going oldschool, or use the instructions below to download them and get them into your C64 Mini.

See all of David Ahl’s BASIC Computer Games

See all of the BASIC Computer Games text files

See all of David Ahl’s More BASIC Computer Games

My USB thumb drive plugged into the C64 Mini

How to Save and Load Your Typed-In BASIC Games on the C64 Mini

If you’re going to type in some games, you’re going to need a way to save your work. Who wants to turn the machine off and lose what you did?

Saving Your Typed-In Text Game

On the C64 Mini, you have two handy ways to save your BASIC programs. We’ll skip the first, since it’s limited to just four save slots (like the built in save game slots). The better way to save is to have a USB thumb drive formatted to FAT 32 (see my other post on C64 Mini Homebrew Games for how to format in FAT 32). Plug in the USB drive, and once you have your program the way you want it, type:


That 8 at the end is the Commodore way of telling it which device it should save to - in this case, the main (virtual) floppy drive. It should respond with:


If it doesn’t already exist, the C64 Mini will create a disk image (a file that looks like a floppy disk to the C64) and call it THEC64-drive8.d64. That .d64 extension on the end is the C64 disk image file type. Keep in mind - this file is NOT your program you just saved. It’s a virtual disk that has your program in it. You can (and will, of course) save multiple things to this virtual floppy disk.

If you ever need to create a disk image just so you can import some stuff you downloaded from the internet (see below), just save a simple 1 line program in order to make the C64 Mini create the disk image that you can open on your computer, and then save your downloaded stuff to.

Viewing the Disk Image Contents

It’s important to be able to see what’s in your disk image. If you come back in the future after saving a few things, you may not remember exactly what’s in there, or what everything is called. Type:

LOAD ”$”,8

Again, that 8 tells it to look at the main (virtual) floppy disk drive. Telling it to LOAD”$” is the command to get a listing of the drive’s contents. It will say:


Now it has the list of the disk contents, but you have to tell it to show it to you:


…and you’ll see:

0 ”THEC64            “ 01 2A
1        “ZERO”          PRG

Excellent. Now that you know it’s saved for you, let’s practice loading.

Loading Your BASIC Game Back Into the C64 Mini

Once you have confirmed your work is saved, type:


and then


You should see that the NEW command has wiped your program from memory. You are now clear to load it back in with:


The Mini should respond with:


So now type:


And you should see that your program is back.

Other Handy Tricks for Saving Your Work

Do you want to save some revisions you made over an existing file? Add @0: to the front of the file name to tell the Mini to replace the existing.

SAVE “@0:ZERO”,8

If you want to verify a saved program, you can type:


And it will respond with:


Get Downloaded Text-Based BASIC Games Onto Your C64 Mini Using VICE

This will not be a tutorial on using VICE (the desktop Commodore 64 emulator), but just the steps necessary to get downloaded games into the virtual disk image you created on a USB thumb drive. Haven’t done that yet? Jump back up to to that part of the post and create your disk image by saving something to your USB thumb drive. If you already have a thumb drive with a disk image on it, then proceed to the next step.

Download & Install VICE - The Commodore 64 Emulator

You’ll need to download and unzip the appropriate version for your operating system:

Download VICE for OSX - I used the one called vice-macosx-cocoa-x86_64-10.12-3.1.dmg, since I am on OSX 10.12, and the SDL version would not even open for me. Your experience may be different. When you try this, there may be a newer version.

Download VICE for Windows - I used the one called WinVICE-3.1-x64.7z since my Windows machine is 64-bit. I got the native one, and not the SDL version, since the SDL one for OSX didn’t work. Note that the file ends in .7z, which tells you it’s a 7-Zip file, not a regular zip file. When you double click it to open it, you may be told you don’t have an application to open it. In the little notice that comes up, double click the option to find an application in the Windows store. From there, I just picked a free app that opens 7-Zip files. Run your new 7-Zip application, and open the VICE file you just downloaded.

Run the VICE Commodore 64 emulator by double clicking on the x64 icon (x64.app on OSX). Now mount the virtual disk from your USB thumb drive like so:

File > Attach Disk Image > #8… and locate the THEC64-drive8.d64 file on your thumb drive. If you recall from before, we load and save with a ,8 on the end to tell it the device to work with - our main (virtual) floppy drive. This is the same reason we just opened this THEC64-drive8.d64 virtual disk image using Unit #8. We’re putting the virtual floppy into the virtual main floppy drive.

Once you’ve done that, use the commands you learned above to get the listing of the disk’s contents:


You’ll see the contents of your virtual disk - whatever you saved in order to create the disk image (see above again for more details).

Now grab the source of what you want to import. Let’s grab the CHOMP game we talked about above. You’ll see that link takes you to a plain text file called chomp.bas. This is not an HTML page, but plain text, which is what we want. Click on the code, and hit CMD+A (OSX) or CTRL+A (Windows) to select everything. Now hit CMD+C (OSX) or CTRL+C (Windows) to copy it.

Now here’s the tricky bit. We’re going to paste this into the VICE window, only there’s one problem. Try it, and you’ll see that you get a gobbledy-gook of special characters, not the program. What’s the problem? Even though VICE shows everything in ALL CAPS, it does that just because that’s what C64s do. If you put in real caps by pasting or holding shift and typing, you get these C64 special characters. What it wants is lower case. Ugh. Does that mean you have to retype this? Nope - just use ConvertCase.net or similar tool. Paste your ALL CAPS code into the window on ConvertCase (CMD+V or CTRL+V), and then click the “lower case” tab. Voila! Now click the “copy to clipboard” tab, and go back to the VICE window.

Click into the VICE window, and paste in your copied text. Be sure to hit ENTER at the end to enter the last line.

Now use what we learned before to save this to our virtual disk:


BAM! You’ve got it. Now close VICE, and properly eject your USB drive. Take it to your C64 Mini, plug it in, and then in BASIC, type:


LIST it, and see that you’ve got it! Now run that baby.

Pro tip: If you find you’re enjoying modifying or writing your own BASIC programs, you may find it more efficient to work on your computer in a text editor, and then save out your work and move it to the C64 Mini. If you’re getting really serious, and want to test on your computer, so you only take it to the C64 Mini when it’s all finished, then load up Chipmunk BASIC using the instructions below. Need a good text editor (you can’t use a word processor, it has to do plain text)? Try Atom.

BONUS: Install BASIC on Your Computer

While BASIC was nearly unavoidable in 80s personal computing, you’re unlikely to find it on contemporary computers. But that doesn’t mean you’re out of luck. There are new implementations of BASIC that have been created for your present day machine. Chipmunk BASIC is a great option that’s easy to set up and use. First, grab the appropriate download for your machine, and unzip it (double click).


You can double-click Chipmunk Basic.app like any other application, and it will open a window where you can go ahead and start typing. To exit a running program, use CMD+C.

The file simply called basic is for use on the command line. Open Terminal, navigate to the folder where it is, and run it by typing ./basic at the command prompt. To exit a running program, use CTRL+C. Handy tip: use the free Go2Shell to open a Terminal at the current folder you have open in Finder.

For Windows

You can double-click the chipmunkbasic application like any other application, and it will open a window where you can go ahead and start typing. To exit a running program, use CTRL+C.

The file simply called basic (or basic.exe if file extensions are turned on) is for use on the command line. Open the command line in Windows 10 by hitting WINDOWS KEY+R to get a run box, and type cmd into the box and hit ENTER. Navigate to the folder where basic.exe is, and run it by typing basic.exe at the command prompt. To exit a running program, use CTRL+C.

Loading & Saving in Chipmunk BASIC

If I’m writing in the Chipmunk BASIC app, I can save my work by typing:

SAVE “AWESOME.BAS” (or it could be in lower, or mixed case, since you’re on a modern computer, but I’ll stick with all caps for consistency)

On OSX, this saves AWESOME.BAS to the current user’s Documents folder. Now I can open that in my text editor, and edit to my heart’s content, resave (or save a new version), and then reload the changes into Chipmunk BASIC by typing:


So now you can easily work in a modern text editor with all of its conveniences, and then test locally in Chipmunk BASIC. When you have your work perfected, you can use the process outlined above to import your work into the C64 Mini via VICE.

Note that in Windows, saving your file saves it out to the same folder basic is in, which actually makes more sense.

Another Option: Vintage BASIC

Vintage BASIC is an application from Lyle Kopnicky, the fellow who provided the BASIC source code text files we used above. It works a bit differently. It doesn’t provide an editing interface the way Chipmunk BASIC does, but is designed with the idea that you will be using a modern text editor, and then just using vintage BASIC to run your programs. Download and unzip the proper version for your operating system, and then at the command line, type:

vintbas [BASIC program filename]

On OSX, to run test.bas, type:

./vintbas test.bas

On Windows:

vintbas test.bas

It’s a different way of working, aimed at modern workflows.

Keep in mind that there can be variations between some of the details in different BASIC version. When in doubt, check documentation on the sites.

BONUS 2: Because You’re Still Reading This

Here are a couple of special somethings for you since you’re still here:

Another of David Ahl’s books, BASIC Computer Adventures, unpacks how to create various adventure games, with complete source code for typing in. These aren’t what are normally referred to as text adventures, but they are a different and interesting take on an adventure premise within a BASIC game.

Ahl’s book Big Computer Games goes in for larger, more complex game programs. If you want to see how they used to code up more sophisticated BASIC games, this is the place to look.

Feeling a desire for some computer history? Check out a PDF of the original BASIC manual from Dartmouth, in 1964 (the birth place and year of BASIC).