home *** CD-ROM | disk | FTP | other *** search
/ News-Disk 1 / News_Disk_Issue_01_19xx___BASIC.atr / code.doc < prev    next >
Text File  |  2023-02-26  |  3KB  |  2 lines

  1. ⇩12 ⇦4 ◆1     5 
  2. 0  10 ②70 ③2 ④12 ⑨132¢¢CODE-BREAKER DOCS. BY DEAN GARRAGHTY, 1989.¢¢¢     Code-breaker is not a new or original idea for a game. I've written it for those of you who are learning Turbo-Basic. I've written it in both Atari Basic, and in Turbo-Basic so that you can compare the two. The Turbo version uses many of the new commands available. I could have used more, but I think I've got the right balance here.¢¢     The programs are not difficult to follow, and use fairly standard commands. Let me first explain how it was done in Atari Basic. Lines 20 to 50 set up the random code and put it in CODE$. Line 60 changes a graphics 0 screen into a graphics 1 (ANTIC 6) screen, leaving the top line as graphics 0 for some text. Lines 90 to 270 form the main get and check part. You have 5 tries at breaking the code, and so this loop is done 5 times (or less if you get the code before try 5). The code is entered using key handler codes (shadow location 764). Each number of the code is checked as it is entered and then the relavent number is stored in the next characte of TRY$. Line 225 prints the contents of TRY$ on the correct line of the screen. Lines 230 to 250 check each number of the two strings to see if any are the same. If one (or more) is the same then 128 is added to its ASCII code (this makes it inverse, and so changes colour). This lets you know which numbers are correct. Line 260 checks to see if the two strings are the same (which means the code has been entered correctly) and if they are the loop is terminated (with the very useful POP command), and a "well done" message is displayed. If you fail to get the code in 5 tries, you will be told what the code was. In both cases you will then be told to press start which is checked on line 315. Then the whole thing starts again.¢¢     The Turbo version is basically the same but uses some of the new commands available. In line 120 DPEEK has been used instead of the clumsy way in the Atari Basic version. In line 150 I have seperated the rest of the code in a procedure called GOT_ONE. In lines 370 and 380 I have used the INSTR command to check if the two strings are the same. This wasn't absolutely neccessary, but shows a use for it. Line 380 also uses a label instead of the usual GOTO command. The press start routine also uses a label. Line 510 also uses a label to re-start the game. The label is on line 70. And it's all as simple as that!!¢¢     Now that you know how it works, I'd better tell you what you have to do! The object of the game is to guess a random 5 figure code. Each number in the code is a number from 1 to 7. Just press a key (1 to 7) for each number. When you have typed the 5th number, any that are correct will turn blue. You have 5 tries at getting the code. If you fail you will be told the code. Press start to re-play when the prompt appears. And there we are, have fun!!¢