Logik (Number Grid Duel)

Type
Game
Category
Two-player strategy game
Published in
Flop (Czech disk magazine for 8-bit Atari), issue 5 (B&B Soft, 1990)
Year
1990
Language
Atari BASIC
Requirements
Atari with 48K or more (fixed addresses assume RAMTOP at 40960), Atari BASIC, two joysticks

About the program

This Logik (credited on screen to B&B SOFT, with a closing REM dated 1990) is a duel of nerves for two players. The screen shows a 9×9 grid of numbers from −9 to 9. The REMs explain: NASBIREJ CO NEJVIC BODU, "collect as many points as you can", and ZAPORNA CISLA JSOU ZOBRAZENA INVERZNE, "negative numbers are shown in inverse". Player 1 may only move up and down the current column. Player 2 may only move left and right along the current row. Whatever you take decides where your opponent must choose next, so a greedy grab of a +9 can hand the other player an even better number, or leave them nothing but negatives. It appeared on the Czech disk magazine Flop 5.

On-screen text

Czech English
MOMENT prosim One moment, please
HRAC 1 / HRAC 2 Player 1 / Player 2 (whose turn)
KONEC HRY Game over
GRATULUJI HRACI 1 (2) Congratulations, player 1 (2)

A ! in front of a score means it is negative.

Typing it in

The listing is plain ASCII, so there are no special characters to worry about. Pay attention to these lines:

  • Lines 40–60 use the screen editor's forced-read trick. On the first RUN, the program builds its character set and then prints 25 G.100 and POKE 842,12:CON. on the screen. Line 50 sets location 842 to 13 and stops, so the editor "types" those lines itself. That adds a new line 25 (GOTO 100) and continues. From then on the slow set-up is skipped. If you SAVE after a game, line 25 is saved too. Delete it if you change the font code.
  • Lines 5095–5105 and 10010–10040 copy the ROM font to page 140 ($8C00) and redefine some characters as the grid lines and cursor. Line 5111 pokes a patch into the GRAPHICS 1 display list at the fixed address 39799. Both addresses assume the usual 48K/64K memory layout, so the program won't work on a 16K or 32K machine.

How to play

Plug in two joysticks. A cursor appears under a random square. Player 1 (joystick 1) moves it up and down and presses fire to take the number. Player 2 (joystick 2) then moves along that number's row and takes one. Then it's player 1's turn again in the new column, and so on. You can't pick an empty square. The game ends when the player to move has nothing left in their line, and the higher total wins. Press fire on either stick to start a new grid.

How it works

Numbers are stored in the array A(9,9) and printed as characters: digit code n+16 for positive values, and ABS(n)+6 for negatives. The routine at 5105 makes inverted copies of the digit shapes at those codes, so negatives appear in inverse on the GRAPHICS 1 screen. The 40-byte routine in S$ copies four pages of the ROM font at $E000 into RAM in a fraction of a second. Each turn, lines 270–280 and 370–380 scan the opponent's line for a non-zero entry, and if there isn't one they jump to KONEC ("end", line 7100).

Listing

1 REM *** PROGRAM LOGIK ***
2 REM *** NASBIREJ CO NEJVIC BODU ***
3 REM *** ZAPORNA CISLA JSOU ***
4 REM *** ZOBRAZENA INVERZNE. ***
5 DIM Q$(20),A(10,10),A$(1),S$(44)
6 KONEC=7100
10 GRAPHICS 17:POSITION 7,8:? #6;"MOMENT":POSITION 7,12:? #6;"prosim"
20 Q$=" B&B SOFT "
30 GOSUB 5000
40 ?:?:? "25 G.100":? "POKE 842,12:CON."
50 POKE 842,13:POSITION 0,0:STOP
60 GOTO 10
100 FOR I=0 TO 8:FOR P=0 TO 8
110 A(I,P)=INT(RND(0)*19-9):IF A(I,P)=0 THEN 110
120 NEXT P:NEXT I
125 GOSUB 5110:K1=0:K2=0
127 POSITION 3,21:? #6;"0 0"
130 FOR I=0 TO 8:FOR P=0 TO 8
140 IF A(I,P)<0 THEN A=ABS(A(I,P))+6:GOTO 160
150 A=A(I,P)+16
160 POSITION I*2+1,P*2+1:? #6;CHR$(A)
170 NEXT P:NEXT I
190 I=INT(RND(0)*9):P=INT(RND(0)*9):COLOR 192:PLOT I*2+1,P*2+2
200 POSITION 1,20:? #6;"HRAC 1 ":POKE 77,0
205 A=STICK(0)
210 IF A=13 THEN COLOR 0:PLOT I*2+1,P*2+2:P=P+1:GOSUB 6000:IF P=9 THEN P=0
220 IF A=14 THEN COLOR 0:PLOT I*2+1,P*2+2:P=P-1:GOSUB 6000:IF P<0 THEN P=8
230 COLOR 192:PLOT I*2+1,P*2+2
240 IF STRIG(0)=1 THEN 205
250 IF A(I,P)=0 THEN SOUND 1,100,12,8:FOR Q=0 TO 40:NEXT Q:SOUND 1,0,0,0:GOTO 205
260 K1=K1+A(I,P):A(I,P)=0:COLOR 0:PLOT I*2+1,P*2+1:GOSUB 6100
265 POSITION 3,21:? #6;ABS(K1);" ":IF K1<0 THEN POSITION 2,21:? #6;"!"
267 IF K1>=0 THEN POSITION 2,21:? #6;" "
270 FOR ZP=0 TO 8:IF A(ZP,P)<>0 THEN 300
280 NEXT ZP:GOTO KONEC
290 GOTO 205
300 POSITION 1,20:? #6;" HRAC 2"
305 A=STICK(1)
310 IF A=7 THEN COLOR 0:PLOT I*2+1,P*2+2:I=I+1:GOSUB 6000:IF I=9 THEN I=0
320 IF A=11 THEN COLOR 0:PLOT I*2+1,P*2+2:I=I-1:GOSUB 6000:IF I<0 THEN I=8
330 COLOR 192:PLOT I*2+1,P*2+2
340 IF STRIG(1)=1 THEN 300
350 IF A(I,P)=0 THEN SOUND 1,100,12,8:FOR Q=0 TO 40:NEXT Q:SOUND 1,0,0,0:GOTO 300
360 K2=K2+A(I,P):A(I,P)=0:COLOR 0:PLOT I*2+1,P*2+1:GOSUB 6100
365 POSITION 15,21:? #6;ABS(K2);" ":IF K2<0 THEN POSITION 14,21:? #6;"!"
367 IF K2>=0 THEN POSITION 14,21:? #6;" "
370 FOR ZP=0 TO 8:IF A(I,ZP)<>0 THEN 200
380 NEXT ZP:GOTO KONEC
390 GOTO 200
4999 STOP
5000 GOSUB 10000
5010 DATA 0,0,0,255,0,0,0,0
5020 DATA 0,0,0,31,16,16,16,16
5030 DATA 16,16,16,31,0,0,0,0
5040 DATA 16,16,16,16,16,16,16,16
5050 DATA 16,16,16,240,0,0,0,0
5060 DATA 0,0,0,240,16,16,16,16
5070 DATA 0,24,60,126,24,24,24,0
5080 DATA 28,54,28,56,111,102,59,0
5090 DATA 0,0,0,126,0,0,0,0
5095 RESTORE 5090:FOR I=140*256+8 TO 140*256+15:READ A:POKE I,A:NEXT I
5100 RESTORE 5010:FOR I=140*256+8*26 TO 140*256+33*8-1:READ A:POKE I,A:NEXT I
5105 FOR I=0 TO 8:FOR P=0 TO 7:POKE 140*256+7*8+I*8+P,255-PEEK(140*256+17*8+I*8+P):NEXT P:NEXT I
5106 RETURN
5110 GRAPHICS 17:POKE 756,140
5111 RESTORE 7000:FOR I=39799 TO 39805:READ A:POKE I,A:NEXT I
5120 ? #6;CHR$(27);:FOR I=0 TO 16:? #6;CHR$(26);:NEXT I:? #6;CHR$(31)
5130 POSITION 0,19:? #6;CHR$(28);:FOR I=0 TO 16:? #6;CHR$(26);:NEXT I:? #6;CHR$(30)
5140 FOR I=1 TO 18:POSITION 0,I:? #6;CHR$(29):POSITION 18,I:? #6;CHR$(29):NEXT I
5150 FOR I=1 TO 19:POSITION 19,I:? #6;Q$(I,I):NEXT I
5190 RETURN
6000 FOR ZP=0 TO 15:SOUND 1,70,10,6
6010 NEXT ZP
6020 SOUND 1,0,0,0
6030 RETURN
6100 FOR ZP=100 TO 70 STEP -1:SOUND 1,ZP,10,6:NEXT ZP
6110 SOUND 1,0,0,0
6120 RETURN
7000 DATA 112,6,112,112,65,32,156
7100 POSITION 1,20:? #6;" KONEC HRY "
7110 IF K1>K2 THEN K=1:GOTO 7130
7120 K=2
7130 POSITION 1,22:? #6;"GRATULUJI HRACI ";K
7140 IF STRIG(0)=1 AND STRIG(1)=1 THEN 7140
7150 GOTO 10
10000 REM
10010 DATA 104,162,0,189,0,224,157,0,140,232,208,247
10020 DATA 189,0,225,157,0,141,232,208,247
10030 DATA 189,0,226,157,0,142,232,208,247
10040 DATA 189,0,227,157,0,143,232,208,247,96
10100 RESTORE 10000
10110 FOR I=0 TO 39:READ A
10120 POKE ADR(S$)+I,A
10130 NEXT I
10140 A=USR(ADR(S$))
10150 RETURN
11110 REM ********** 1990 ***********
11111 REM ********** KONEC ***********

Credits