Monday, December 14, 2015

Day 5. Exporting a basic program from a D64.

I am following a thread on the somethingawful forums titled "Let's Play Learning BASIC (And Porting!)" (There could be a paywall in front of the thread, sometimes the mods put it up to encourage registration).  It's a quite interesting thread because the author shows a program in basic for the BBC and gives an assignment related to it. 

Doing the assignment I found that the Basic language is... clunky. Ok, it was 1983 and it was easier to tell the computer what's the order of the basic commands by using labels than by having a freeform source file with labels (am I wrong or Amiga Basic had named labels?).

To export the basic program I saved into a d64 I used Dirmaster by Style, a very cool windows application that allows you to have a listing of the virtual floppy and to check its files. I only had to convert to uppercase the listing, and to convert the Clr/Screen characters by hand.

I think I could clean up the source of the modified game, for example by cleaning up the decision block between 100 and 120 and adding a random seed based on time, but for now this will suffice.
10 PRINT "{CLR/SCREEN}"; 20 PRINT "STARSHIP TAKE-OFF" 21 PRINT "PRESS ANY KEY TO CONTINUE" 22 GET A$ :IF A$ ="" THEN 22 29 PRINT "{CLR/SCREEN}" 30 G = INT(20*RND(1)) + 1 40 W = INT(40*RND(1)) + 1 41 NF = 1 42 XF = 1 50 R = G * W 60 PRINT "GRAVITY = "; G 70 PRINT "TYPE IN THE THRUST" 80 FOR C = 1 TO 10 81 IF NF < 2 AND XF < 2 THEN 90 82 GOSUB 1000 83 PRINT R$ 90 INPUT F 91 PRINT "{CLR/SCREEN}" 100 IF F > R THEN PRINT "TOO HIGH"; 101 IF F > R AND F < XF THEN XF = F 102 IF F > R AND XF = 1 THEN XF = F 110 IF F < R THEN PRINT "TOO LOW"; 111 IF F < R AND F > NF THEN NF = F 112 IF F < R AND NF = 1 THEN NF = F 120 IF F = R THEN GOTO 190 130 IF C <> 10 THEN PRINT ", TRY AGAIN" 140 NEXT C 150 PRINT "" 160 PRINT "YOU FAILED!" 170 PRINT "THE ALIENS GOT YOU!" 180 END 190 PRINT "GOOD TAKE OFF! YOU WIN!" 200 END 1000 IF NF < 2 AND XF > 1 THEN 1002 1001 GOTO 1010 1002 R$ ="THRUST MUST BE UNDER " + STR$(XF) 1010 IF NF > 1 AND XF < 2 THEN 1012 1011 GOTO 1020 1012 R$="THRUST MUST BE OVER " + STR$(NF) 1020 IF NF < 2 OR XF <2 THEN 1040 1030 R$ = "THRUST MUST BE BETWEEN " + STR$(NF) + " AND " + STR$(XF) 1040 RETURN

No comments:

Post a Comment