Classic Computer Magazine Archive A.N.A.L.O.G. ISSUE 78 / NOVEMBER 1989 / PAGE 9

MEMORY MATCH


TYPING IT IN
    Type in Listing 1, using BASIC Editor II to verify your work, and save the program as MEMATCH.BAS. Then Type in Listing 2, again using BASIC Editor to verify your work, and save a copy to disk. Listing 2 creates a file named MEM.LST, which contains some hard-to-type lines that should be merged with Listing 1. To merge the lines: LOAD "D:MEMATCH.BAS", ENTER "D:MEM.LST" and finally SAVE "D: MEMATCH. BAS".

PLAYING THE GAME
    Memory Match can be played by one or two players. A one-player game requires a joystick plugged into port 0. Plug another joystick into port 1 for a two-player game. Press Select to change the number of players. Press Option to turn the sound effects off, if you like. Press Start to play.
    The goal is to match all the cards in the fewest number of turns. Rank yourself according to the number of turns it takes you to complete the game.
    12-22 turns: You must have ESP!
    23-29 turns: Not bad.
    30+ turns: Are the sound effects distracting you?

screen shot

ABOUT THE PROGRAM
    Memory Match is written in BASIC and uses a machine language USR routine contained in the string MM$. The routine copies a string of memory to a new location. The call format is X=USR(ADR(MM$), MEM1,MEM2,NUM), where MEM1 is the address of memory to copy from, MEM2 is the address of memory to copy to and NUM is the number of bytes to copy. This routine is used to move the modified character-set data (lines 9010-9070) to an area of memory that begins four pages (each page is 256 bytes long) below the last usable address of RAM. The routine also copies the DLI (display-list interrupt) data in line 9080 to page 6 and copies the cursor data in PL$ to player/missile memory (line 20).

CONCLUSION
    I hope you enjoy Memory Match. It's a fun game in which the graphics and sound effects enhance the playing experience. What better way to improve your memory?    




    Joe Brzuszek is majoring in computer science at the University of Pittsburgh and has owned his Atari 800 since 1983. He uses his Atari as a VT-100 terminal to communicate with a VAX mainframe computer system.

LISTING 1: BASIC

Note: Blue indicates inverse video

WO 1 REM ******************************
PB 2 REM *       MEMORY MATCH         *
PS 3 REM *      by Joe Brzuszek       *
ZD 4 REM *                            *
IN 5 REM *      COPYRIGHT 1989        *
PM 6 REM *    BY ANALOG COMPUTING     *
WU 7 REM ******************************
NN 8 REM
HT 10 POKE 566,143:POKE 567,231:RESTORE 9
   000:GOSUB 8000
PT 15 POKE 53277,6
ZA 20 POKE 53248,X:7=USR(ADR(MM$),ADR(PL$
   ),P1+Y,V4):T=USR(ADR(MM$),ADR("♥"),
   P1+Y,V4):T=SICK(S)
WS 30 X=X+20*((T=7)-(T=11)):Y=Y+24*((T=13
   )-(T=14)):T1=STRIG(S):IF X>53 AND X<19
   5 AND Y>61 AND Y<111 AND T1 THEN 20
WI 40 IF Y<62 THEN Y=62
XA 50 IF Y>110 THEN Y=110
XG 60 POKE 53278,Z:T=USR(ADR(MM$),ADR(PL$
   ),P1+Y,V4):IF X<54 THEN X=54
KT 70 IF X>194 THEN X=194
IE 80 IF NOT T1 THEN POKE 53277,V2:IF PE
   EK(53252) THEN 160
TO 90 GOTO 15
QL 100 SOUND Z,V1,V2,V12:50UND Z,Z,Z,Z:X1
   =INT(0.25*(X-54))+V1:Y1=0.125*(Y-62)+6
   :K=((X1-V1)/5+V1+V8*(Y-62)/24)
NZ 110 POKE 77,Z:I2=ASC(MIX$(K)):I=V1+6*I
   2:T=USR(ADR(MM$),ADR(""),P1+Y,V4):
   IF MIX$(K,K)=" " THEN 15
RD 120 POSITION X1,Y1:? CARD$(I,I+2);"↓←
   ";CARD$(I+3,I+5)
SC 130 TN=TN+V1:IF TN=V2 AND K1=K THEN TN
   =V1:GOTO 15
RD 140 ON  NOT SO GOSUB 500+I2*20:IF TN=V
   1 THEN K1=K:I1=I:X2=X1:Y2=Y1:GOTO 15
JL 150 N=N+V1:TN=Z:IF I1=I THEN 300
SB 180 FOR I=Z TO 425:NEXT I:POSITION X2,
   Y2:? C1$:POSITION X1,Y1:? C1$:ON  NOT
   PL GOTO 15:S=S+V1:IF S=V2 THEN S=Z
XG 190 POSITION 6,V2:IF S=Z THEN ? "PLAYE
   R 1   PLAYER 2":POKE 704,60:GOTO 15
DV 200 ? "PLAYER 1   PLAYER 2":POKE 704
   ,172:GOTO 15
YI 300 RESTORE :MIX$(K,K)=" ":MIX$(K1,K1)
   =" "
DE 310 TRAP 320:READ I:FOR K=14 TO 5 STEP
    -V1:SOUND Z,I,V10,K:NEXT K:GOTO 310:D
   ATA 66,60,47,40,47,40,F
TA 320 FOR K=Z TO 30:NEXT K:SOUND Z,Z,Z,Z
   :S1=S1+V2:IF S THEN S2=S2+V2:S1=S1-V2
VC 330 POSITION 6,3:? S1;"   ";S2
DA 340 FOR I=Z TO 300:NEXT I:POSITION X1,
   Y1:? "      ":POSITION X2,Y2:? "
       ":IF S1+S2<24 THEN 15
NV 350 FOR I=Z TO 250:POKE 709,I:POKE 532
   79,Z:POKE 53279,V8:NEXT I
UR 360 POSITION Z,Z:? "↑↑↓↓  IT TOOK YOU
   ";N;" TURNS. PRESS STARTFOR A NE
   W GAME."
RV 370 ON PEEK(53279)=7 GOTO 370:GOSUB 80
   60:GOTO 15
EA 500 FOR J=V12 TO V4 STEP -V1:FOR H=J T
   O Z STEP -1:SOUND Z,200,V10,H:NEXT H:N
   EXT J:RETURN
RA 520 FOR J=15 TO Z STEP -0.5:SOUND Z,V2
   ,V2,V8:SOUND Z,Z,Z,Z:NEXT J:SOUND Z,Z,
   Z,Z:RETURN
HN 540 FOR J=V12 TO Z STEP -2:FOR H=V12 T
   O Z STEP -1.5:SOUND Z,19+H*2,V10,J:NEX
   T H:NEXT J:SOUND Z,Z,Z,Z:RETURN
QS 560 SOUND V2,19,V4,V4:FOR H=V1 TO V2:F
   OR J=Z TO 30:SOUND Z,V2,V2,V12:NEXT J:
   SOUND Z,Z,Z,Z:NEXT H
JP 570 SOUND V2,Z,Z,Z:RETURN
ZC 580 FOR J=15 TO Z STEP -1.5:SOUND Z,J,
   V10,J:NEXT J:SOUND Z,Z,Z,Z:RETURN
AZ 600 FOR J=V12 TO Z STEP -0.4:SOUND Z,1
   05,V10,J:NEXT J:FOR J=V12 TO Z STEP -0
   .45:SOUND Z,132,V10,J:NEXT J:RETURN
HQ 620 FOR H=15 TO Z STEP -V1:SOUND Z,H,V
   10,H:SOUND Z,Z,Z,Z:NEXT H:RETURN
JB 640 FOR J=50 TO 60 STEP 6:SOUND Z,J,V1
   0,V8:NEXT J:FOR J=60 TO 30 STEP -V4:SO
   UND Z,J,V10,V8:NEKT J:SOUND Z,Z,Z,Z
ZM 650 RETURN
YC 660 SOUND Z,49,V8,V8:SOUND V1,50,V8,V8
   :FOR J=1 TO 300:NEXT J:SOUND Z,Z,Z,Z:S
   OUND V1,Z,Z,Z:RETURN
FR 680 RESTORE 690:TRAP 690
TM 685 READ I2,J:FOR H=Z TO J:SOUND Z,I2,
   V10,V12:NEXT H:GOTO 685
FR 690 RETURN :DATA 91,8,108,8,136,20,108
   ,20,91,20,68,30,0,0,F
GL 700 FOR J=15 TO Z STEP -V2:SOUND Z,V2,
   V4,V12:FOR H=Z TO J:NEXT H:SOUND Z,V2,
   V8,V12:NEXT J:SOUND Z,Z,Z,Z:RETURN
GY 720 FOR J=15 TO Z STEP -0.5:SOUND Z,29
   ,V10,J:NEXT J:SOUND Z,Z,Z,Z:RETURN
UJ 8000 READ V1,V2,V4,V8,V10,V12:P=PEEK(1
   06)-V8:POKE 106,P:DIM MM$(63),PL$(9),C
   ARD$(100),MIX$(24),C1$(13)
SZ 8010 GRAPHICS Z:POKE 559,Z:DL=PEEK(560
   )+PEEK(561)*256:POKE DL+V8,130
GY 8020 POKE DL+19,65:POKE DL+20,PEEK(560
   ):POKE DL+21,PEEK(561):P1=P*256+512:FO
   R X=Z TO 128:POKE P1+X,Z:NEXT X
EZ 8040 FOR X=Z TO 6:READ CARDS:Y=USR(ADR
   (MM$),ADR(CARD$),(P+V4)*256+X*100,LEN(
   CARD$)):NEXT X
PF 8050 READ CARD$:Y=USR(ADR(MM$),ADR(CAR
   D$),1536,LEN(CARD$)):X=USR(1536)
IO 8060 POKE 53248,Z:POKE 1563,224:FOR X=
   9 TO 18:POKE DL+X,7:NEXT X:POKE 708,36
   :POKE 709,42:POKE 710,V2:POKE 711,40
CO 8070 POKE 82,V1:POKE 752,V1:? "MEM
   ORY MATCH    by       Joe Brzu
   szek"
FQ 8071 PL$="1 PLAYER":IF PL THEN PL$="2"
UW 8072 MIXS="ON":IF SO THEN MIXS="OFF"
AX 8080 POKE 84,5:? "OPTION / SOUND ";MIX
   $:? "select / ";PLS:? "start  / PLAY G
   AME":POKE 559,34
ZE 8090 X=PEEK(53279):ON X=7 GOTO 8080:SO
   UND Z,29,V10,V10:SOUND Z,29,V2,V10:SOU
   ND Z,Z,Z,Z:ON X=6 GOTO 8150
FX 8100 ON X=3 GOTO 8120:PL=PL+V1:PLS="©
   E":IF PL=V2 THEN PL=Z:PLS="El
    "
TZ 8110 GOTO 8080
RM 8120 SO=SO+V1:MIX$="OFF":IF SO=V2 THEN
    SO=Z:MIX$="ON "
UF 8130 GOTO 8080
YG 8150 POKE 559,Z:FOR X=9 TO 18:POKE DL+
   X,S:NEXT X:FOR X=V1 TO 25:CARD$(X)=CHR
   $(X):NEXT X:POKE 1563,P+V4
CY 8160 PLS="":C1$="'()*+,→→↑"
XL 8170 POKE 708,68:POKE 709,26:POKE 711,
   214:FOR X=Z TO 11:FOR Y=V1 TO V2:SOUND
    Z,5,V8,V8:SOUND Z,Z,Z,Z
RY 8180 X1=INT(RND(VI)*(LEN(CARD$)-V1))+V
   1:Y1=ASC(CARD$(X1)):CARD$(X1)=CARD$(X1
   +V1):MIX$(Y1,Y1)=CHR$(X):NEXT Y:NEXT X
VC 8200 ? "MEMORY MATCHPLAYER 1
      PLAYER 20   0":POKE 559,46
EI 8210 FOR Y=Z TO V2:FOR X=V1 TO V8:? C1
   $;:NEXT X:? "":NEXT Y
YA 8220 POKE 704,60:POKE 54279,P:POKE 532
   77,V2:POKE 623,Z:X=114:Y=62:S1=Z:S2=Z:
   N=Z:RETURN
GR 9000 DATA 1,2,4,8,10,12


LISTING 2: BASIC

AB 1 REM MEMORY MATCH - LISTING2
NS 2 REM by Joe D. Brzuszek
PZ 3 REM Creates lines 8030, 8190, 9010-9
   080
SN 4 REM and saves then in "D:MEM.LST"
NK 5 REM
OF 6 REM ENTER "D:MEM.LST" to load
NM 7 REM
JG 10 DIM H$(101):LINE=600:LAST=780
SN 20 GRAPHICS Z:POKE 752,1:POKE 710,2
SV 30 OPEN #1,8,Z,"D:MEM.LST":? "OPENING
   D:MEM.LST FOR OUTPUT":TRAP 380
DG 40 READ H$:IF LEN(H$)<>100 AND LINE<>L
   AST THEN ? "DATA LENGTH ERROR IN LINE
   ";LINE:GOTO 400
KC 50 LN=PEEK(183)+PEEK(184)*256:IF LN<>L
   INE THEN ? "LINE ";LINE;" IS MISSING!"
   :GOTO 400
DL 60 ? "CHECKING LINE ";LINE:FOR x=1 TO
   99 STEP 2:Y1=ASC(H$(X,X))-48:Y2=ASC(H$
   (x+1,x+13)-48
IW 70 IF Y1>9 THEN Y1=Y1-7:IF Y1>15 THEN
   390
LV 80 IF Y2>9 THEN Y2=Y2-7:IF Y2>15 THEN
   390
LG 90 PUT #1,Y2+Y1*16:NEXT X:LINE=LINE+10
   :GOTO 40
TZ 380 IF PEEK(195)=5 AND LINE=LAST THEN
   ? "NO ERRORS FOUND, BUT SAVE LISTING2
   AS A BACKUP JUST IN CASE!":GOTO 400
OE 390 ? "ERROR AT LINE ";LINE
XT 400 ? "CLOSING FILE":POKE 752,Z:END
JF 600 DATA 383033304D4D243D22686885CC688
   5CB6885CE6885CD681865CE85DB681865CD85C
   F9002E6D0A000B1CB91CDE6CBD002E6CC
JC 610 DATA E6CDD002E6CEA5CDC5CFDBEAA5CEC
   5D0D0E460229B3831393043415244243D225D5
   E5F000102030405060708898A8B8C8D8E
CB 620 DATA 0F1011121314ADAEAFB0B1B233343
   5363738B9BABBBCBDBE3F40414243444546474
   8494A4B4C4D4E4F50515253545556D7D8
FA 630 DATA D9DADBDC229B39303136444154410
   000000000000000FFDSDFDDDDDDDDDDFF55FF5
   5FFD7D7D7FF57F77777777777DDDDDDDD
ZU 640 DATA DDDFD5FFD7D7D7FF55FF55FF77777
   77777F757FFAABFBABBBBBBBBBBAAFFAAFFAAB
   EBEBEAAFEAEEEEEEEEEEEBBBBBBBBBBBA
BX 650 DATA BFAABEBEBEAAFFAAFFAAEEEEEEEE9
   B3930323044415441EEAEFEAA00000303002A0
   90500FBFC3FFFFF7F5F00000000C0F0FC
IR 660 DATA FC0505050100000A0857555555554
   08A88FFFF7F7F5C4C808000000000000202020
   00028AAAAAAAAAA000000000000808002
QD 670 DATA 020202010A2A00AAAAAAAA55AAAA0
   28080808040A0A8809B3930333044415441000
   A033A3FFFAFAF0000F0FFFFFFFFFF0000
LA 680 DATA 0000C0F0FCFF2B0B0203CF3CC300E
   AEAFBC0000F030CBFFCF0FC3CFCF0300000000
   00000030300003030FCFCFFFF00000000
QP 690 DATA 000000000F0E3A3A3A0E0300FFFFF
   FFFBFAFFF00CBC0F0F0F0C00000000000009B3
   9303430444154410000030F003C283C3C
LA 700 DATA FFFFFF000000000000C0F03FFFFCF
   000000300FF3C3C3C3CFFFF3CFCFF3FBF0000C
   000FFEEFBEEFBEEFBEEFDEEBDEEBDEEBD
TH 710 DATA EE55AA55AA55AA55AAFFAA55AA55A
   A55AAFDAA55AASSAAS5AA55AA55AA55AA55AA0
   0020A24AA2A0A029B3930353044415441
QT 720 DATA AAAAAAA00080A0A8AAA0000000000
   000000000020A200000AA2AAAA000000000008
   000000000000000000000000000000030
MY 730 DATA 3C3F3F3F33330000000000C0C0C00
   00000000F3F3F0F30303030F0F0F0C0C0C0000
   0000000000000000005171F5F0000007F
TH 740 DATA 9B3930363044415441FFFEFFFF000
   00000F0FCBCFF5F5F571715050000FFFFFFFF7
   F555500FFFFFFF4D4500006033CFFFFFF
IL 750 DATA FFFF3CC2F23238E8E8A8288A08A82
   2EEEE222202280AA22A8A2020AAA240A080000
   000A8A08000000000003F3D3FFEFEFEFE
NC 760 DATA 3EC0FF7FDDBFAEAE8C9B393037304
   4415441FCDC7FEFAFAFAFAC3F3FFFFFFDF2F33
   FAEEEFF226655FFFFBCFFFF3F4F63F3FC
HI 770 DATA 010707070707070755F7F7F7F7F7F
   7F754F5F5F5F5F5F5F51595955140444011555
   555555555410055555545011101449B39
AD 780 DATA 3038304441544168A9068D0102A91
   18D0002A9C08D0ED46048A9868D0AD48D18D0A
   9E08D09D468409B