Try it

Open the C64 from the home page, or in its own tab on the Internet Archive.

Handy keys

RETURN (Enter) finishes a line
RUN/STOP (usually Esc) stops a program
LIST shows your program

Welcome to the Hamsterdome, in BASIC

The Commodore 64 boots straight into BASIC, a programming language made to be easy for beginners. Let's write a little program that welcomes you to the Hamsterdome, one step at a time. Type each line exactly as shown and press RETURN at the end.

Tip: the C64 shows everything in capital letters, and that's normal. If a key types something unexpected, the emulator may be matching your keyboard to the C64's layout (on a real C64, the quote mark is SHIFT + 2).

★★★★★★★★★★★★

1. Say hello

Every line starts with a line number. BASIC runs the lines in order, from smallest to biggest.

10 PRINT "WELCOME TO THE HAMSTERDOME!"
RUN

You'll see:

WELCOME TO THE HAMSTERDOME!
READY.

PRINT writes text on the screen, and RUN starts your program. Type LIST any time to see the program you've typed so far.

2. Say it again (and again)

A FOR loop repeats lines. This one prints the greeting 5 times. Typing a line number that already exists replaces that line, so line 10 below replaces your old one.

10 FOR I = 1 TO 5
20 PRINT "WELCOME TO THE HAMSTERDOME!"
30 NEXT I
RUN

Want it to go forever? Change line 30 to 30 GOTO 20, which jumps back to line 20 over and over. Press RUN/STOP to make it stop.

3. Add some color

The C64 has 16 colors. POKE writes a number straight into the computer's memory, and two special memory spots control the border and background colors.

5 POKE 53280,0 : POKE 53281,6
6 PRINT CHR$(147)
7 PRINT CHR$(158)
RUN

POKE 53280,0 makes the border black, POKE 53281,6 makes the background blue, CHR$(147) clears the screen, and CHR$(158) switches the text to yellow. Lines 5, 6 and 7 slot in before line 10, so they happen first.

4. Say your name

INPUT asks a question and stores the answer in a variable. Variables that hold text end in a dollar sign ($).

8 INPUT "WHAT IS YOUR NAME"; N$
20 PRINT "WELCOME TO THE HAMSTERDOME, "; N$; "!"
RUN

Line 20 now glues together the greeting, your name and an exclamation mark.

5. All together

Here's the whole program. Type NEW first to clear out the old one, then type it all in:

NEW
5 POKE 53280,0 : POKE 53281,6
6 PRINT CHR$(147)
7 PRINT CHR$(158)
8 INPUT "WHAT IS YOUR NAME"; N$
10 FOR I = 1 TO 5
20 PRINT "WELCOME TO THE HAMSTERDOME, "; N$; "!"
30 NEXT I
40 PRINT "HAMMY SAYS HI! :)"
RUN

That's a real C64 program, written the same way people did in 1982! Try changing the numbers, the colors (0 to 15) or the words, and see what happens. 🐹

Want to go further? The original Commodore 64 User's Guide from 1982 teaches BASIC from scratch, and the C64-Wiki lists every command.