Skip to content

My First Commodore Basic Programme in About 30 Years

I like watching videos on YouTube. Well, who doesn't? ;-) I especially like watching videos concerning old and obsolete hardware. Retro is kind of a hype right now. But that's OK, there are a whole generation of kids out there who have never seen one line of BASIC code and never sat in front of a C64 waiting for that damn tape to load already! But that is what we did when I was young.

There are some projects out there trying to recreate that '80s feeling, but the one I find most interesting was created by The 8-Bit Guy, mostly because I know that when he sets his mind to something he most likely will get a working result. (As you can see in this old posting I also supported him when he kickstarted his Planet X3 project.) So now he is trying to build a computer that is almost but not entirely unlike the C64/C128. It will be called Commander X16.

I will spare you the technical details, but it sounds very interesting. At least to me. And about two days ago he released the first version of an emulator which can be used to play around with. So naturally I wrote a little programme for it. You can find it in the Extended Article below. It works, in a way, but is far from perfect. But for something I whipped up in three hours or so without any plan or concept or documentation...

You can just copy&paste it into the emulator and run it. Have fun. ;-)

0 REM -
1 REM - STREAM SWIMMER
2 REM - WRITTEN FOR X16EMU V.29 BY JAN BEINERSDORF 2019
3 REM - VERSION 2
9 REM -
10 REM - FOR STEERING USE < AND > (, AND . ON A GERMAN KEYBOAD)
11 REM -
12 REM - INIT GAME
13 REM - C IS CENTER OF STREAM
14 REM - P IS POSITION OF SWIMMER
15 REM - R IS ROUND COUNTER
16 REM - CR IS CHAR AT SWIMMER'S NEXT POSITION
17 REM - SP IS SPEED, 10 IS SLOWEST
18 REM - W IS WIDTH
19 REM - SE IS STATE OF STREAM (ISLAND OR OTHER EVENT)
20 C=39:P=39:R=0:CR=32:SP=10:W=10:SC=0:SE=0
30 PRINT CHR$(147)
40 FOR I=0 TO 59
50 PRINT "-----------------------------------     ";
60 PRINT "     ------------------------------"
70 NEXT

90 REM -
91 REM - DRAW STREAM
92 REM - LR IS RANDOM TURN IN STREAM
99 REM -
100 LR=0:IF S=0 OR S>2 AND S<8 THEN LR=INT(RND(1)*3)-1
110 C=C+LR
120 IF C<10 THEN C=10
130 IF C>60 THEN C=60

140 EV=0:IF SE=0 THEN EV=INT(RND(1)*30)
150 IF EV=1 THEN SE=1:REM - ONE IN THIRTY CHANCE
160 IF SE=1 OR SE=10 THEN GOSUB 2200:REM - SPLIT/MERGE STREAM
180 IF SE>=2 AND SE<=9 THEN GOSUB 2400:REM - ISLAND
190 IF SE=0 THEN GOSUB 2000:REM - DRAW NORMAL STREAM

290 REM -
291 REM - TEST POSITION AHEAD
291 REM -
300 PP=P*2
310 CR=VPEEK(0,PP)
320 IF CR<>32 THEN GOTO 1020

291 REM -
291 REM - GET INPUT FROM KEYBOARD, MOVE SWIMMER
291 REM -
400 FOR I=0 TO SP*2
410 GET A$
420 IF A$="," THEN GOSUB 1100
430 IF A$="." THEN GOSUB 1200

440 REM -
441 REM - DRAW SWIMMER, POSSIBLY ADJUST SPEED
442 REM -
450 VPOKE 0,(P*2),42
460 NEXT I
470 IF R=100 THEN GOSUB 1300
480 IF SP<3 THEN SP=3

990 REM -
991 REM - CR SHOULD ALWAYS BE 32 AT THIS POINT
992 REM - INCREASE ROUND AND SCORE
992 REM -
1000 IF SE=0 THEN R=R+1
1005 SC=SC+1
1010 IF CR=32 THEN GOTO 100
1020 PRINT "SCORE:";SC
1030 END

1090 REM -
1091 REM - MOVE TO LEFT REQUESTED, TEST IF STILL IN STREAM
1092 REM -
1100 VPOKE 0,(P*2),32
1110 P=P-1
1120 PP=P*2
1130 CR=VPEEK(0,PP)
1140 IF CR<>32 THEN PRINT "SCORE:";SC:END
1150 RETURN

1090 REM -
1091 REM - SAME FOR MOVE TO RIGHT
1092 REM -
1200 VPOKE 0,(P*2),32
1210 P=P+1
1220 PP=P*2
1230 CR=VPEEK(0,PP)
1240 IF CR<>32 THEN PRINT "SCORE:";SC:END
1250 RETURN

1290 REM -
1291 REM - INCREASE SPEED, REDUCE WIDTH
1292 REM -
1300 R=0
1310 SP=SP-1
1320 W=W-1
1330 IF W<2 THEN W=2
1340 RETURN

1990 REM -
1991 REM - NORMAL STREAM, NO ISLAND
1992 REM -
2000 FOR I=0 TO (C-INT(W/2))
2010 PRINT "-";
2020 NEXT I
2030 FOR I=1 TO W
2040 PRINT " ";
2050 NEXT I
2060 FOR I=(C+INT(W/2)) TO (75-W)
2070 PRINT "-";
2080 NEXT I
2090 PRINT "-":REM PRINT " SP:";(10-SP)
2100 RETURN

2190 REM -
2191 REM - STREAM SPLITS IN TWO OR MERGE IT
2192 REM -
2200 FOR I=0 TO (C-INT(W/2)-1)
2210 PRINT "-";
2220 NEXT I
2230 FOR I=1 TO INT(W/2)+1
2240 PRINT " ";
2250 NEXT I
2260 PRINT "-";
2270 FOR I=INT(W/2) TO W
2280 PRINT " ";
2290 NEXT I
2300 FOR I=(C-INT(W/2)-1) TO (63-W)
2310 PRINT "-";
2320 NEXT I
2330 IF SE=1 THEN SE=2
2340 IF SE>9 THEN SE=0
2350 PRINT "-":REM PRINT " SE:";SE
2360 RETURN

2390 REM -
2391 REM - ISLAND
2392 REM -
2400 FOR I=0 TO (C-INT(W/2)-2)
2410 PRINT "-";
2420 NEXT I
2430 FOR I=1 TO INT(W/2)+1
2440 PRINT " ";
2450 NEXT I
2460 PRINT "---";
2470 FOR I=INT(W/2) TO W
2480 PRINT " ";
2490 NEXT I
2500 FOR I=(C-INT(W/2)) TO (63-W)
2510 PRINT "-";
2520 NEXT I
2530 SE=SE+1
2540 PRINT "-":REM PRINT " SE:";SE
2550 RETURN

Trackbacks

Keine Trackbacks

Kommentare

Ansicht der Kommentare: Linear | Verschachtelt

Noch keine Kommentare

Kommentar schreiben

Umschließende Sterne heben ein Wort hervor (*wort*), per _wort_ kann ein Wort unterstrichen werden.
Standard-Text Smilies wie :-) und ;-) werden zu Bildern konvertiert.

Um maschinelle und automatische Übertragung von Spamkommentaren zu verhindern, bitte die Zeichenfolge im dargestellten Bild in der Eingabemaske eintragen. Nur wenn die Zeichenfolge richtig eingegeben wurde, kann der Kommentar angenommen werden. Bitte beachten Sie, dass Ihr Browser Cookies unterstützen muss, um dieses Verfahren anzuwenden.
CAPTCHA

Formular-Optionen

Kommentare werden erst nach redaktioneller Prüfung freigeschaltet!