﻿ rem -----------------------------------------------------------------------------------------------------------------
 rem -- MUSICAL - Atari 2600 Touch Me! v3 Annual Vintage BASIC Programming Contest for 70 and 80's Micro computers. --
 rem -- v3 is the wild category, includes an AI player (press button) but is now more than 10 lines
 rem -----------------------------------------------------------------------------------------------------------------
 rem init section: color screen pattern and colored note for each of the 4 programmable Simon/Touch me color tones 
 rem 8 byte sprite arrays (static) and 54 byte array for user programmable simon says pattern: 
 

0 if g=0 then for g=0 to 239:virtualworld(g)=255:i=g/24:rowcolors(i)=g:next g:scrollvirtualworldtoggle=1:p=0 else goto 2
1 for i=0 to 7:player1(i)=pl(i):next i:NUSIZ1=63:data sim 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 rem end init runs 1x

 rem  variables - f framecounter, p pattern index, t 1/0 toggle
 rem              i frequenccy value to seed or check for if array element is 0
 rem              r > direction from player, or AI cheats and reads it from an array 
 rem              s > SimonSaysTouchMe AI is active

 
2 if joy0fire=1 and s=0 then s=random(f):return:rem don't require p=0 so AI can take over mid turn if player desires
 if f>30 then f=0:i=0:r=0 else f=f+1:t=1-t:SUSTAINFORFRAMES=SUSTAINFORFRAMES+t:vwpixel(x,y,bindplayer1):goto 9:rem Mr SQL


 if s=0 then goto continue:rem AI computer opponent:
 COLUBK=255:rem debug yellow
 e=p+1:r=sim(e)
 if r=0 then r=s
 goto 3:rem new item 

 rem end AI computer opponent

continue
 if joy0up=1 then r=29:goto 3 
 if joy0right=1 then r=15:goto 4
 if joy0down=1 then r=26:goto 5
 if joy0left=1 then r=14:goto 6

3 if r=29 then SUSTAINFORFRAMES=15:AUDC1=4:AUDF1=29:AUDV1=29:p=p+1:i=29:COLUP1=$ba:x=8:y=1:COLUBK=0:goto7:rem Atari
4 if r=15 then SUSTAINFORFRAMES=15:AUDC1=12:AUDF1=15:AUDV1=18:p=p+1:i=15:COLUP1=64:x=15:y=4:COLUBK=0:goto 7
5 if r=26 then SUSTAINFORFRAMES=15:AUDC0=12:AUDF0=26:AUDV0=15:p=p+1:i=26:COLUP1=$72:x=8:y=8:COLUBK=0:goto 7
6 if r=14 then SUSTAINFORFRAMES=15:AUDC0=4:AUDF0=14:AUDV0=0:p=p+1:i=14:COLUP1=255:x=1:y=4:COLUBK=0:rem Touch Me!
 rem - repeat the pattern if it is finished and build the score bar:
7 if sim(p)=0 and p>0 then sim(p)=i:COLUBK=$62:vwpixel(p,9,flip):p=0:s=0:data s2 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 rem - check for error and queue repeat if game is over
8 if sim(p)<>i and i>0 and p>0 then AUDF1=31:AUDC1=3:AUDV1=20:SUSTAINFORFRAMES=20:p=0:data pl 24,60,60,28,4,5,7,6
 rem check reset:
9 if SWCHB|254<>255 then COLUBK=$52:g=0:for i=0 to 51:sim(i)=0:next i:SUSTAINFORFRAMES=10:AUDC0=3:AUDF0=17:AUDV0=31 

 data random 29,15,26,14,26,14,26,15,29,15,14,15,26,14,26,14,26,15,29,15,29,15,26,14,26,14,26,15,29,15,26,14


111111111100000000001111111111000000000011111111110000000000111111111100000000001111111111000000000011111111110000000000
