Jump to content



1

Arjak's Adventures in Atari BASIC


7 replies to this topic

#1 Arjak OFFLINE  

Arjak

    Chopper Commander

  • 129 posts

Posted Mon Apr 25, 2011 11:17 PM

Having just gotten an Atari XEGS, I decided I might as well TRY to learn BASIC so I could explore everything the system has to offer. My first program went off without a hitch, and my dad was quite impressed. Here's my first program in Atari BASIC ever!

10 DIM NAME$(25)
15 PRINT "WHAT IS YOUR NAME?"
20 INPUT NAME$
25 PRINT "HELLO, "; NAME$;"!"

It's not much, but it's a start! I've already begun work on a much more complex project. Please check this thread every once in a while to see my progress!

#2 Kylev OFFLINE  

Kylev

    Star Raider

  • 83 posts
  • Location:U.S.A - West Coast

Posted Tue Apr 26, 2011 4:25 PM

Arjak,

Welcome to the world of BASIC programming. The friendly folks here at Atari Age are ready to help you if/when you get stuck. Just ask in any of the appropriate forums and someone will step up and lend a hand.

I will restate a common rule for these things. Programming an Atari is fun. Keep it in mind when you are going through your projects and you will find the experience highly rewarding.

Good luck,

Russ

#3 Arjak OFFLINE  

Arjak

    Chopper Commander

  • 129 posts

Posted Fri Sep 9, 2011 7:49 AM

Alright, I've finally found a project that I think will make lives better for both my programming skills, as well as gamers (and Trekkers) everywhere.

I am currently attempting to port the seminal classic BASIC game, Super Star Trek, to Atari BASIC. Here is my code so far (I haven't gotten too far):

10 REM INSTRUCTIONS FOR 'SUPER STAR TREK'

20 FOR I=1 TO 12:PRINT:NEXT I

21 PRINT "     *************************"

22 PRINT "     *                       *"

23 PRINT "     *                       *"

30 PRINT "     * *  SUPER STAR TREK  * *"

31 PRINT "     *                       *"

32 PRINT "     *                       *"

35 PRINT "     *************************"

36 PRINT:PRINT "   ORIGINAL PROGRAM BY DAVID AHL"
37 PRINT "          AND MARY COLE"
38 PRINT:PRINT " ATARI CONVERSION BY COLLIN PIERCE"
39 PRINT:PRINT:PRINT
40 DIM K$(1):PRINT "DO YOU NEED INSTRUCTIONS (Y/N)":INPUT K$:IF K$="N" THEN 2000

45 PRINT

50 PRINT " INSTRUCTIONS FOR 'SUPER STAR TREK'"

60 PRINT

70 PRINT "1. WHEN YOU SEE 'COMMAND ?' PRINTED,"
80 PRINT "   ENTER ONE OF THE LEGAL COMMANDS"
90 PRINT "   (NAV, SRS, LRS, PHA, TOR, SHE,"
100 PRINT "   DAM,COM, OR XXX)."

110 PRINT "2. IF YOU SHOULD TYPE IN AN ILLEGAL"
120 PRINT "   COMMAND, YOU'LL GET A SHORT LIST"
130 PRINT "   OF LEGAL COMMANDS PRINTED OUT."

140 PRINT "3. SOME COMMANDS REQUIRE YOU TO"
150 PRINT "   ENTER DATA (FOR EXAMPLE, THE"

160 PRINT "   'NAV' COMMAND COMES BACK WITH"
170 PRINT "   'COURSE? (1-9)'). IF YOU TYPE IN"
180 PRINT "   ILLEGAL DATA (LIKE NEGATIVE"
190 PRINT "   NUMBERS), THAT COMMAND WILL BE"
200 PRINT "   ABORTED."

210 PRINT:PRINT:PRINT:PRINT:PRINT "PRESS SPACE BAR TO CONTINUE."
220 IF PEEK(764)<>33 THEN GOTO 220

The hardest part by far was trying to get the program to wait for input from the player at Line 220. I finally, after much research on atariarchives.com, learned how to take a PEEK at the keyboard input. The reason I went through so much trouble is because this isn't even all of the instructions program! There's not enough room to have all of the instructions on the screen at once, so I had to find a way to allow the player to read before moving onward. PEEK was the answer.

If you try to enter this code or just know how BASIC works, yes, I am aware that typing "N" at the instructions prompt causes a fatal error at this point. I haven't gotten far enough for the code to point anywhere!

I plan to do more porting today. :)

#4 Synthpopalooza OFFLINE  

Synthpopalooza

    Moonsweeper

  • 299 posts
  • Location:knoxville, TN

Posted Sat Sep 10, 2011 5:44 PM

Quicker way to read keyboard input for press any key (and it seems to work better for me):

10 IF NOT PEEK(555) THEN 10

I think 555 is like a keyboard timer ... it is nonzero anytime a key is pressed, 0 otherwise.

You don't have to clear the keyboard register for this ... and I have found 555 to be a helpful location in this regard. :) You also don't have to open an IOCB on the "K:" device either.

However for a specific keypress (like the spacebar), there are two ways to do it. First one is of course reading 764 as you have done, though you should always POKE 764,255 before scanning the keyboard to clear the register.

Second is something like this:

at the beginning of your program: OPEN #1,4,0,"K:"

Then use GET #1,K if you want to scan for a keypress, K will return the ATASCII value of the key pressed. Again, clear the KB buffer at 764 before you do this.

Good luck with that program!

Edited by Synthpopalooza, Sat Sep 10, 2011 5:47 PM.


#5 therealbountybob OFFLINE  

therealbountybob

    River Patroller

  • 3,235 posts
  • Lost
  • Location:In Space

Posted Sun Sep 11, 2011 4:25 PM

:thumbsup: :cool:

#6 Arjak OFFLINE  

Arjak

    Chopper Commander

  • 129 posts

Posted Sun Sep 11, 2011 11:39 PM

Thanks, Synth. Your suggestion should save me some unnecessary instructions (and grief) down the line.

I'm making progress...here's what I've got now:

10 REM INSTRUCTIONS FOR 'SUPER STAR TREK'
20 FOR I=1 TO 12:PRINT:NEXT I

21 PRINT "     *************************"

22 PRINT "     *                       *"

23 PRINT "     *                       *"

30 PRINT "     * *  SUPER STAR TREK  * *"

31 PRINT "     *                       *"

32 PRINT "     *                       *"

35 PRINT "     *************************"

36 PRINT:PRINT "   ORIGINAL PROGRAM BY DAVID AHL"
37 PRINT "          AND MARY COLE"
38 PRINT:PRINT " ATARI CONVERSION BY COLLIN PIERCE"
39 PRINT:PRINT:PRINT
40 DIM K$(1):PRINT "DO YOU NEED INSTRUCTIONS (Y/N)":INPUT K$:IF K$="N" THEN GOTO 2000

45 PRINT

50 PRINT " INSTRUCTIONS FOR 'SUPER STAR TREK'"

60 PRINT

70 PRINT "1. WHEN YOU SEE 'COMMAND ?' PRINTED,"
80 PRINT "   ENTER ONE OF THE LEGAL COMMANDS"
90 PRINT "   (NAV, SRS, LRS, PHA, TOR, SHE,"
100 PRINT "   DAM, COM, OR XXX)."

110 PRINT "2. IF YOU SHOULD TYPE IN AN ILLEGAL"
120 PRINT "   COMMAND, YOU'LL GET A SHORT LIST"
130 PRINT "   OF LEGAL COMMANDS PRINTED OUT."

140 PRINT "3. SOME COMMANDS REQUIRE YOU TO"
150 PRINT "   ENTER DATA (FOR EXAMPLE, THE"

160 PRINT "   'NAV' COMMAND COMES BACK WITH"
170 PRINT "   'COURSE? (1-9)'). IF YOU TYPE IN"
180 PRINT "   ILLEGAL DATA (LIKE NEGATIVE"
190 PRINT "   NUMBERS), THAT COMMAND WILL BE"
200 PRINT "   ABORTED."

210 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
220 IF NOT PEEK(555) THEN GOTO 220
230 PRINT:PRINT "   THE GALAXY IS DIVIDED INTO AN 8 X 8"
240 PRINT "   QUADRANT GRID, AND EACH QUADRANT"
250 PRINT "   IS FURTHER DIVIDED INTO AN 8 X 8"
260 PRINT "   SECTOR GRID."

270 PRINT

280 PRINT "   YOU WILL BE ASSIGNED A STARTING"
290 PRINT "   POINT SOMEWHERE IN THE GALAXY TO"
300 PRINT "   BEGIN A TOUR OF DUTY AS CAPTAIN"
310 PRINT "   OF THE STARSHIP 'ENTERPRISE';"
320 PRINT "   YOUR MISSION: TO SEEK AND DESTROY"
330 PRINT "   THE FLEET OF KLINGON WARSHIPS"
340 PRINT "   WHICH ARE MENACING THE UNITED"
350 PRINT "   FEDERATION OF PLANETS."

360 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
370 IF NOT PEEK(555) THEN GOTO 370
380 PRINT:PRINT "   YOU HAVE THE FOLLOWING COMMANDS"
390 PRINT "   AVAILABLE TO YOU AS CAPTAIN OF"
400 PRINT "   THE ENTERPRISE:"

410 PRINT

420 PRINT "'NAV' COMMAND = WARP ENGINE CONTROL"

430 PRINT "     COURSE IS SET UP IN A CIRCULAR"
440 PRINT "     NUMERICAL VECTOR ARRANGEMENT AS"
450 PRINT "     SHOWN. INTEGER AND REAL VALUES"
460 PRINT "     MAY BE USED. (THUS COURSE 1.5"
470 PRINT "     HALFWAY BETWEEN 1 AND 2)"
480 PRINT
490 PRINT "     VALUES MAY APPROACH 9.0, WHICH"
500 PRINT "     IS EQUAL TO 1.0."

510 PRINT
520 PRINT "     ONE WARP FACTOR IS THE SIZE OF"

530 PRINT "     ONE QUADRANT. THEREFORE, TO GET"

540 PRINT "     FROM QUADRANT 6,5 TO 5,5, YOU"

550 PRINT "     WOULD USE COURSE 3, WARP FACTOR"
560 PRINT "     1."

570 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
580 IF NOT PEEK(555) THEN GOTO 610
590 PRINT:PRINT "     IF CONFUSED, CONSULT THE"
600 PRINT "     FOLLOWING DIAGRAM:"
610 PRINT
620 PRINT "           4  3  2"
630 PRINT "            \ | /"
640 PRINT "             \|/"
650 PRINT "         5 ---*--- 1"
660 PRINT "             /|\"
670 PRINT "            / | \"
680 PRINT "           6  7  8"
690 PRINT
700 PRINT "           COURSE"
710 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
720 IF NOT PEEK(555) THEN GOTO 720


#7 Irgendwer OFFLINE  

Irgendwer

    Dragonstomper

  • 565 posts
  • Location:Germany

Posted Mon Sep 12, 2011 12:29 PM

View PostArjak, on Sun Sep 11, 2011 11:39 PM, said:

...
210 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
220 IF NOT PEEK(555) THEN GOTO 220
...
360 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
370 IF NOT PEEK(555) THEN GOTO 370
...
570 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
580 IF NOT PEEK(555) THEN GOTO 610
...
710 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
720 IF NOT PEEK(555) THEN GOTO 720

What about this:

210 GOSUB 30000
360 GOSUB 30000
570 GOSUB 30000
710 GOSUB 30000

30000 PRINT:PRINT "PRESS ANY KEY TO CONTINUE."
30010 IF NOT PEEK(555) THEN GOTO 30010
30020 RETURN

?

#8 Arjak OFFLINE  

Arjak

    Chopper Commander

  • 129 posts

Posted Mon Sep 12, 2011 1:04 PM

Ah, yes. I think I might have considered using a sub-routine to hand all of that, but didn't think too much about it. I'll implement that; it'll save me time and memory space. Thanks! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users