Write your own program on c64.ninja. It takes a minute.
Go to the front page and type these three lines, one at a time, pressing Enter after each:
NEW 10 PRINT "HELLO FROM ME" RUN
Done. You have written a program.
If you type something without a line number it happens immediately. Type the same thing with a line number and it is put away for later, and only runs when you type RUN.
PRINT 2+2 → answers 4 right away 10 PRINT 2+2 → silent; saved as line 10
The numbers do not have to follow each other. Count in tens — 10, 20, 30 — and you leave room to squeeze a line in between later.
LIST shows the program as it looks right now.NEW empties the whole machine.A variable is a box with a name. Names ending in $ hold text, the rest hold numbers.
10 A=5 20 B$="CAT" 30 PRINT A;" ";B$
Only the first two letters of the name count — COUNT and COUSIN are the same box. That was true on the real machine too.
10 FOR I=1 TO 5 20 PRINT I 30 NEXT I
To jump several steps at a time, add STEP: FOR I=0 TO 10 STEP 2.
10 A=7 20 IF A>5 THEN PRINT "BIG" 30 IF A<=5 THEN PRINT "SMALL"
GOTO jumps to a line number, and GOSUB jumps there and comes back when the line RETURN is reached.
10 INPUT "WHAT IS YOUR NAME";N$ 20 PRINT "HELLO ";N$
The program stops and waits for an answer. Type and press Enter.
Three addresses in the machine's memory control the colours, and they work here exactly as they did in 1982. The number is 0–15.
POKE 53280,5 the border POKE 53281,0 the background POKE 646,7 the text from here on
PEEK is the way back: it reads an address instead of writing to it. PRINT PEEK(646) answers with the colour you just set. Address 162 is the machine's clock and counts up sixty times a second all by itself:
10 PRINT PEEK(162) 20 GOTO 10
POKEd yourself into something unreadable? COLOR on the front page resets the screen.
INPUT stops the program and waits. If you would rather read keys while it keeps going — the way a game does — the queue sits at address 198. It holds the number of keys pressed, and the characters themselves from 631 onwards.
10 IF PEEK(198)=0 THEN 10 20 PRINT CHR$(PEEK(631)); 30 POKE 198,0 40 GOTO 10
Line 10 spins until someone presses something. Line 20 prints the character, and POKE 198,0 on line 30 empties the queue so the next key shows up. You have built a typewriter.
The program never stops on its own — press STOP on the front page to break it.
What you type lives only in the browser's memory and is otherwise lost when you reload the page.
SAVE "MINE" save DIR see what is there LOAD "MINE" fetch it back SCRATCH "MINE" delete
The programs are saved in your own browser, not on the server. They do not travel to another computer, and they disappear if you clear the browser's data.
On the disk there is a small program to start from. Load it, read the code and change it — it will not break.
LOAD "DEMO" LIST RUN
?SYNTAX ERROR means the machine did not understand the line. Look for a missing quotation mark or a comma in the wrong place, and type the line again.
If you have written an endless loop, break it with Escape. The machine then tells you which line it was on.
HELP on the front page lists everything you can type.
Back to the machine · or take a look at the arcade and the puzzle.
← C64.NINJA