A Six-Gun Shootout Game For The OSI C1P
Charles L. Stanford
The Six Gun Shootout game is a very pleasant and fun activity, particularly for the six to twelve or so age group. But this article concerns more than just the mechanics of writing another BASIC game for the C1P. When I originally wrote the program almost two years ago, we were reasonably satisfied with it. Sure, it was slow. Every time a player moved his gunfighter up or down the screen, the graphics POKEs took a lot longer than desired. And remembering that the "1" key was UP and the "2" key was down took a lot away. Those of you who have seen my articles on Fast Graphics (COMPUTE II Issue 3) and on interfacing the Atari Joystick to the C1P (COMPUTE Issue 7) can grasp what happened. Making that program work like it should has taught us more about the workings of the machine, over the past year, than any dozen manuals or articles.
This article, then, is a summing up of the methods we used to speed up both the software and the hardware to make BASIC games both more fun and much more saleable in the not inconsiderable Software marketplace.
BASIC Program Description
The game runs much as the early Arcade versions did. Each player has his gunfighter, who can shoot across the screen. Three Cacti obstruct some of the view, and move to a new location after each shot. Each player can move up or down, and shoot. Each gets 15 shots, and 5 hits wins.
The BASIC program shown in Listing 1 is fairly well annotated with REMs, but a few of the routines bear some discussion. The initialization starting at Line 5 sets the screen up as though no joysticks were available. This was deliberate, and makes the game more universally useful. It is a good idea to do this on all games, whether for paddles or for joysticks. The scoring from Line 200 is handled indirectly through the Fast Graphics Machine Language subroutine. Thus the POKEs of the ASCII characters are to that program rather than to the screen. One routine, the "man dead" sequence, is still done in BASIC POKEs as a delay is called for here anyway.
The Joystick Interface
As described in the previous article mentioned above, the joysticks are interfaced to the keyboard such that any position can be directly related to the pressing of one or two keys. While the Atari Joysticks have eight positions around the center, only two of them are used in this game, and the others are "masked" out of existance. This is done with the routines beginning at Lines 700 and 750. Line 710's POKE K, 127 activates only Row 7 of the Keyboard. The first statement of Line 720 ORs away any columns except 5, 4, and 3, by forcing 1s into the others. Thus only keys 3, 4, and 5 are accepted as valid inputs. The next two statements of that line mask all but Column 5, so that a "shoot" command gets precedence over a "move" command. Finally, the other two keys are examined in Lines 725 and 730, and one of the move routines is addressed.
The routine at 750 works the same, except that Row 6 is activated, and the other player gets his chance. Each player is queried in turn, so one guy can't stand there and fill the other full of holes. The joystick works the same way as the keyboard, and is certainly a lot easier to use without a lot of practice, especially by the younger players.
Fast Graphics for the Six Gunners
The machine language graphics is done exactly the same way as the Choo Choo Collision demonstration program of the other previous article. A standard routine, shown in Listing 2, addresses a table of graphics symbols. These symbols are tailored for any game or other graphics screen display as shown in Figure 1. First, the Graphics Reference Manual is used to "draw" the characters desired, using a grid of sufficient size. Don't worry about screen location. The BASIC program takes care of that, by POKEing the table. Just lay out the characters, Determine the addresses of each of the elements of each character relative to the upper left corner of its grid, and couple that with the character code in making up the table. Each character should be ended with an #$FE (if there are more characters) or an #$FF (for the last character, or to end the routine).
Going Farther
You can just enter this program as-is, and have another nice game for your collection. Or you can dig a lot deeper, and quite possibly learn some techniques that will improve both your programming ability and some of those other games that run a bit slow, or get tiresome because the keyboard sequence is hard to use and remember. Anyone wishing to gain a deeper understanding of either the hardware or the software concepts described here should most certainly look to the other articles referenced.
Figure 1. Graphics DevelopmentListing 1. Basic Program
5 FOR S = 0 TO 9 : PRINT : NEXT 7 REM - FOR ATARI JYSTKS 10 PRINT" SIX-GUN DUEL GAME 15 PRINT : PRINT : PRINT 20 PRINT "LEFT", "RIGHT" 25 PRINT "----", "----- 30 PRINT " 4 UP"," : 35 PRINT : PRINT" 3 DOWN"," 0 40 PRINT : PRINT" 5 SHOOT"," - 45 PRINT : PRINT : PRINT "You have 15shots each . 50 PRINT : PRINT : PRINT "Five hits wins ! 55 PRINT : PRINT : PRINT "Hit spacebar to start 60 GOSUB 100 65 GOSUB 800 70 Z = 1 : L = 0 : R = 0 : SL = 15 : SR = 15 75 POKE 530, 1 : K = 57088 : C = 53445 : D = 54009 80 POKE K, 253 : IF PEEK(K) = 239 THEN 90 85 GOTO 80 90 X = USR(X) : GOSUB200 95 GOTO 700 100 REM-MACH GRAPHICS 110 RESTORE 115 POKE 11, 34 : POKE 12, 2 : POKE 254, 96 : POKE 255, 2 120 FOR P = 0 γO 61 : READ M : POKE 546 + P, M : NEXT 130 DATA160, 0, 169, 32, 153, 0, 211, 153, 0, 210, 153, 0, 209, 153, 0 135 DATA208, 200, 208, 241, 234, 234, 234, 160, 0, 177, 254, 141, 86, 2, 200 140 DATA177, 254, 141, 87, 2, 200, 177, 254, 170, 200, 224, 254, 240, 236, 224, 255 145 DATA240, 8, 177, 254, 200, 157, 68, 209, 208, 236, 96, 234, 234, 234, 234, 234 148 REM-FIGURES NEXT 149 POKE133, 255 : POKE134, 31 : FORP = 0TO152 : READM : POKE 608 + P, M : NEXTP 150 DATA197, 208, 0, 128, 1, 187, 2, 128, 33, 161, 34, 174, 65, 149, 97, 187 155 DATA98, 131, 99, 180, 129, 187, 161, 136, 162, 190, 192, 5, 193, 136, 194, 143 160 DATA195, 8, 254, 170, 208, 0, 186, 2, 185, 32, 186, 33, 184, 34, 185, 65 165 DATA149, 254, 174, 209, 0, 186, 2, 185, 32, 186, 33, 184, 34, 185, 65, 149 170 DATA254, 178, 210, 0, 186, 2, 185, 32, 186, 33, 184, 34, 185, 65, 149, 254 175 DATA249, 210, 1, 128, 2, 187, 3, 128, 33, 173, 34, l61, 66, 149, 96, 181 180 DATA97, 131, 98, 187, 130, 187, 161, 189, 162, 143, 192, 5, 193, 136, 194, 143 185 DATA195, 8, 254, 136, 211, 0, 49, 1, 53, 4, 48, 10, 48, 13, 49, 14 190 DATA53, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 195 DATA0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 199 RETURN 200 REM-SCORE 210 POKE730, 48 + L : POKE732, 48 + R 220 IF L = 5 ORR = 5THEN290 230 M = INT(SL/10) : N = SL - M * 10 : IFM = 0THENM = -16 240 U = INT(SR/10) : V = SR - U * 10 : IF U = 0THENU = -16 250 POKE726, 48 + M : POKE728, 48 + N 260 POKE734, 48 + U : POKE736, 48 + V 270 IF SL = 0ANDSR = 0THEN290 280 RETURN 290 X = USR(X) : GOTO60 300 REM - LEFT MAN DEAD 305 C = C + 160 310 POKEC + 2, 32 : POKEC - 31, 32 : POKEC - 61, 32 : POKEC - 62, 32 : POKEC - 63, 32 315 POKEC - 95, 32 : POKEC - 126, 32 : POKEC - 127, 32 : POKEC - 158, 32 : POKEC - 159, 32 320 POKEC - 160, 32 325 POKEC, 143 : POKEC + 1, 171 : POKEC + 3, 140 330 POKEC + 32, 187 : POKEC + 33, 161 : POKEC + 34, 148 335 POKEC + 35, 187 : POKEC + 36, 187 : POKEC + 37, 128 340 POKEC + 38, 176 : POKEC + 64, 143 345 FORT = 0TO500 : NEXT : C = C - 160 : RETURN 350 REM - RIGHT MAN DEAD 355 D = D + 158 360 POKED + 3, 32 : POKED + 4, 32 : POKED - 28, 32 : POKED - 60, 32 : POKED - 61, 32 365 POKED - 62, 32 : POKED - 92, 32 : POKED - 124, 32 : POKED - 125, 32