How And Why You Should Use PEEK (155) Instead Of GET
David M, Miller, Howard Beach, NY
In many two player action games, one player has a keyboard-screen control advantage over the other. By this I mean if player A holds down the "2" key for instance, and player B presses the "W" key, the PET will only acknowledge the depression of the "2." But if player B holds down the "W" first and player A presses the "2," the PET will again only be aware of the depression of the "2." This problem arises when you use the GET command. To illustrate this problem more clearly for those of you who are not familiar with it, type in the following program:
10 GET A$:IFA$ = "" THEN 10 20 PRINT A$: GOTO 10
If the "2" and "W" are pressed together (in action games it is likely that two keys may at the same time be depressed) the PET prints only the "2." Even if the "W" is pressed first, and then the "2," in the end, when both are depressed the PET will only print the "2." That, of course, gives player A a large advantage in the game.
The easiest way to overcome this unfairness is to use the memory content of PEEK(155) in Upgrade ROMs. I think it is PEEK (512) in Original ROMs, but I did not test it. Using this instead of GET gives both players an equal keyboard-screen control over his "man."
The only drawback using this method is that each player has control over only two keys each, so this feature would only be advantageous in certain games.
The left player must use the RVS key and SPACE key; the right player must use the left carat <, and left bracket [.
Memory 155 has a value of 255 unless one or more of the four keys mentioned above are depressed. When 2, 3, or all 4 keys are depressed independently or simultaneously, memory 155 has a special value which is given in the chart below.
|Key(s) Depressed||Value of PEEK(155)|
|RVS, SPACE, [||242|
|RVS, SPACE, <||241|
|RVS, SPACE, [, <||240|
|Note: PEEK(155) never has a value of 244.|
Using these values in your program you can branch off to a step which will carry out the required function. To illustrate how you can use this in a game situation, consider a game in which two players have two guns each. Part of the program may look as follows:
10 IF PEEK(155) = 254 THEN REM SHOOT TOP LEFT GUN 20 IF PEEK(155) = 249 THEN REM SHOOT TOP RIGHT AND BOTTOM LEFT GUN 30 IF PEEK(155) = 240 THEN REM SHOOT ALL FOUR GUNS
Using PEE K(155) in place of GET makes the keyboard-screen control, and, in effect, the entire game, fair and equal for both players. I hope you can take advantage of this feature in programming your next interactive action game, or revising an old one. If you have any comments on this idea, please send them directly to me.
149-45 83 St.
Howard Beach, NY 11414