COMMON SHARED dyx
DECLARE SUB lp (a#, b#, a$)
DECLARE SUB sb (a$, b$)
DECLARE SUB dy (a#, dyx)
DIM me(100), you(100)
DIM fins$(101)
co$ = COMMAND$
IF co$ = "" THEN dyx = 1: GOTO godyx
j = INSTR(co$, "/D")
IF j = 0 THEN dyx = 1: GOTO godyx
dyx = VAL(MID$(co$, j + 3, 5)) / 100
godyx:
x = SCREEN(1, 1, 1)
dfc = (x AND 128) \ 8 + (x AND 15)
dbc = (x AND 112) \ 16
COLOR dfc, dbc
nof = 1
fins$(nof) = DIR$("*.zip")
IF fins$(nof) = "" THEN GOTO nozips
IF fins$(nof) = "DOSIMON2.ZIP" THEN nof = 0
DO
nof = nof + 1
skim:
fins$(nof) = DIR$
IF fins$(nof) = "DOSIMON2.ZIP" THEN GOTO skim
LOOP UNTIL fins$(nof) = ""
nof = nof - 1
IF nof = 1 THEN GOTO aa
FOR sort1 = 1 TO nof - 1
FOR sort2 = sort1 TO 1 STEP -1
IF fins$(sort2 + 1) < fins$(sort2) THEN SWAP fins$(sort2), fins$(sort2 + 1) ELSE EXIT FOR
NEXT sort2
NEXT sort1
aa:
IF DIR$("SIMON.CFG") = "" THEN GOTO nocfg
OPEN "i", #2, "simon.cfg"
LINE INPUT #2, sd$
CLOSE #2
gotcfg:
OPEN "o", #1, "con"
CLS
ts:
sb sd$, "ttl"
lp 1, 27, " Simon     By Jim Kitchen"
dy 1, dyx
lp 23, 9, " would you like to read the instructions ( Y or N )"
GOSUB gkey
IF g$ = "y" THEN GOSUB inpage: GOTO bfi
IF g$ <> "n" THEN GOTO ts
bfi:
GOSUB pickset
IF bad = 1 THEN GOSUB badwaveset: GOTO bfi
GOSUB soundtest
GOSUB clss
starg:
LOCATE 23, 1: PRINT SPC(78);
LOCATE 10, 1: PRINT SPC(78);
lp 10, 10, " Please enter the number of players"
LOCATE 10, 46: LINE INPUT nop$
nop = VAL(nop$)
IF nop < 1 THEN lp 10, 10, " 0 is not a valid number of players. please try again": GOTO starg
IF nop > 7 THEN lp 10, 10, " sorry that is too many players 7 is the maximum": GOTO starg
x = 11
FOR gn = 1 TO nop
x = x + 1
LOCATE x, 1: PRINT #1, " Enter the name of player number" + STR$(gn)
LOCATE x, 37: LINE INPUT plam$(gn)
NEXT gn
getdif:
LOCATE 22, 1: PRINT SPC(79);
lp 22, 1, " Please enter the difficulty factor 1 = easy 2 = medium 3 = hard 4= expert"
LOCATE 22, 76: LINE INPUT df$
df = VAL(df$)
IF df < 1 OR df > 4 THEN lp 22, 1, " that was an invalid difficulty factor. please try again": GOTO getdif
nos = 2
IF df = 1 THEN dfa = 4
IF df = 2 THEN dfa = 4
IF df = 3 THEN dfa = 6
IF df = 4 THEN dfa = 9
mainloop:
CLS
IF nout = nop THEN GOTO gameover
i3 = i3 + 1
IF i3 > 3 THEN nos = nos + 1: i3 = 1
round = round + 1
lp 1, 1, " Round"
PRINT #1, round;
PRINT #1, " will have";
PRINT #1, nos;
PRINT #1, " tones per turn"
lp 2, 1, " Press space bar to start round number"
PRINT #1, round
GOSUB gkey
FOR turn = 1 TO nop
IF plout(turn) = 1 THEN GOTO nt
RANDOMIZE TIMER
CLS
lp 1, 1, " " + plam$(turn)
lp 2, 1, " It is your turn"
lp 3, 1, " Press space bar to start"
GOSUB gkey
FOR picks = 1 TO nos
repick:
me(picks) = INT(RND(1) * dfa) + 1
IF round = 1 AND me(1) = me(2) THEN GOTO repick
NEXT picks
DO: LOOP UNTIL INKEY$ = ""
CLS
LOCATE 24, 1
FOR ply = 1 TO nos
IF df <> 1 THEN GOTO skip
PRINT #1, me(ply)
LOCATE 25, 1: PRINT
dy .6, dyx
skip:
ws$ = RIGHT$(STR$(me(ply)), 1)
sb sd$, ws$
NEXT ply
sb sd$, "go"
ck = 0
sttm = TIMER
DO
GOSUB gkey
ck = ck + 1
you(ck) = g
LOOP UNTIL ck = nos
tm = TIMER - sttm
CLS
DO: LOOP UNTIL INKEY$ = ""
cc = 0: bd = 0
FOR check = 1 TO nos
IF me(check) = you(check) THEN cc = cc + 1: GOTO ok
bd = bd + 1
mis(bd) = check
ok:
NEXT check
IF cc = nos THEN GOTO good
DO: LOOP UNTIL INKEY$ = ""
sb sd$, "bad"
lp 1, 1, " Sorry " + plam$(turn) + " but you missed on tone number"
LOCATE 2, 1
FOR pm = 1 TO bd
PRINT #1, mis(pm);
IF bd > 1 AND pm < bd THEN PRINT #1, "and";
NEXT pm
lp 22, 1, " Sorry but you are out of the game on round number"
PRINT #1, round
nout = nout + 1
plout(turn) = 1
GOTO ntak
good:
DO: LOOP UNTIL INKEY$ = ""
sb sd$, "tada"
lp 1, 1, " You got it " + plam$(turn)
lp 2, 1, " Your time was"
LOCATE 2, 17: PRINT #1, USING "###.##"; tm
lp 2, 23, " seconds"
lp 3, 1, " Your average time per tone was"
LOCATE 3, 32: PRINT #1, USING "###.##"; tm / nos;
PRINT #1, " seconds"
nott(turn) = nott(turn) + nos
ttm(turn) = ttm(turn) + tm
lp 4, 1, " with"
PRINT #1, nott(turn);
PRINT #1, " tones completed your total time is";
PRINT #1, USING "###.##"; ttm(turn);
PRINT #1, " seconds"
lp 5, 1, " For an average time per tone of"
PRINT #1, USING "###.##"; ttm(turn) / nott(turn);
PRINT #1, " seconds"
ntak:
lp 24, 1, " Press space bar to continue"
GOSUB gkey
nt:
NEXT turn
GOTO mainloop
gameover:
sb sd$, "gameover"
CLS
FOR po = 1 TO nop
PRINT #1, plam$(po)
PRINT #1, " You completed";
PRINT #1, nott(po);
PRINT #1, "tones correctly with a total time of";
PRINT #1, USING "###.##"; ttm(po);
PRINT #1, " seconds"
PRINT #1, "for an average time per tone of";
IF nott(po) = 0 THEN av = 0: GOTO sk2
av = ttm(po) / nott(po)
sk2:
PRINT #1, USING "###.##"; av;
PRINT #1, " seconds"
NEXT po
IF nop = 1 THEN win(1) = 1: GOTO bad1
hs = 0
FOR po = 1 TO nop
IF nott(po) > hs THEN hs = nott(po)
NEXT po
tc = 0
FOR po = 1 TO nop
IF hs <> nott(po) THEN GOTO nw
tc = tc + 1
win(tc) = po
nw:
NEXT po
IF tc = 1 THEN GOTO pwin
lt = ttm(win(1))
wlt = win(1)
FOR po = 1 TO nop
IF ttm(win(po)) > lt THEN GOTO sk
lt = ttm(win(po))
wlt = win(po)
sk:
NEXT po
win(1) = wlt
pwin:
lp 25, 1, " Press space bar"
GOSUB gkey
lp 23, 1, " The winner is "
dy 1.5, dyx
sb sd$, "tada"
PRINT #1, plam$(win(1))
dy 1, dyx
sb sd$, "clap"
bad1:
lp 24, 1, " getting record scores"
l = LEN(fins$(wavset)) - 4
recnam$ = LEFT$(fins$(wavset), l) + ".REC"
IF DIR$(recnam$) = "" THEN GOSUB norec
OPEN "i", #2, recnam$
FOR p = 1 TO 4
INPUT #2, rectone(p)
INPUT #2, rectime(p)
LINE INPUT #2, recnam$(p)
NEXT p
CLOSE #2
lp 24, 1, " Press space bar          "
GOSUB gkey
CLS
lp 1, 1, " The record number of correct tones for difficulty level number"
PRINT #1, df;
lp 2, 1, " Is"
PRINT #1, rectone(df)
lp 3, 1, " By "
PRINT #1, recnam$(df)
lp 4, 1, " With a total time of "
PRINT #1, USING "###.##"; rectime(df);
PRINT #1, " seconds"
lp 5, 1, " For an average time per tone of "
IF rectime(df) = 0 THEN av = 0: GOTO av0
av = rectime(df) / rectone(df)
av0:
PRINT #1, USING "###.##"; av;
PRINT #1, " seconds"
IF rectone(df) = nott(win(1)) THEN GOTO checktime
IF rectone(df) > nott(win(1)) THEN GOTO bad2
newrec:
lp 8, 1, plam$(win(1))
lp 9, 1, " Your total number of correct tones of"
PRINT #1, nott(win(1))
lp 10, 1, " With a total time of "
PRINT #1, USING "###.##"; ttm(win(1));
PRINT #1, " seconds"
lp 11, 1, " For an average time per tone of "
av = ttm(win(1)) / nott(win(1))
PRINT #1, USING "###.##"; av;
PRINT #1, " seconds"
lp 12, 1, " Is the new record for difficulty level"
PRINT #1, df
lp 14, 1, " It is being saved as such"
rectone(df) = nott(win(1))
rectime(df) = ttm(win(1))
recnam$(df) = plam$(win(1))
OPEN "o", #2, recnam$
FOR p = 1 TO 4
PRINT #2, rectone(p)
PRINT #2, rectime(p)
PRINT #2, recnam$(p)
NEXT p
CLOSE #2
dy 16, dyx
sb sd$, "clap"
GOTO bad2
checktime:
IF ttm(win(1)) < rectime(df) THEN GOTO newrec
bad2:
lp 25, 1, " Would you like to play again ( Y or N )"
GOSUB gkey
IF g$ = "y" THEN RUN
IF g$ <> "n" THEN GOTO bad2
et:
GOSUB erwaves
CLS
sb sd$, "ttl"
SYSTEM
clss:
FOR cl = 2 TO 23
LOCATE cl, 1
PRINT SPC(79); :
NEXT cl
RETURN
nozips:
CLS
lp 2, 1, " Sorry but there were no sets of simon wave files found"
LOCATE 10, 1, 1
SYSTEM
erwaves:
FOR erw = 1 TO 9
c4$ = RIGHT$(STR$(erw), 1) + ".WAV"
c5$ = DIR$(c4$)
IF c4$ = c5$ THEN KILL c4$
NEXT erw
c4$ = DIR$("READ-ME.TXT")
IF c4$ = "READ-ME.TXT" THEN KILL c4$
RETURN
askesr:
lp 24, 1, " Press e to exit program s to shell to dos or r to return to program"
GOSUB gkey
IF g$ = "s" THEN GOTO shellpro
IF g$ = "e" THEN GOTO et
IF g$ = "r" THEN RETURN
GOTO askesr
shellpro:
kps$ = CURDIR$
CLS
PRINT #1, " O K shelling to dos"
PRINT #1, " "
SHELL "command /k prompt=Type exit to return to the simon game.$_$p$g"
FOR rep = 333 TO 666 STEP 111
SOUND rep, 2
NEXT rep
rdr$ = LEFT$(kps$, 2)
SHELL rdr$
ps = LEN(kps$)
rcd$ = "cd" + RIGHT$(kps$, (ps - 2))
SHELL rcd$
lp 1, 1, " Press a key"
CLS
GOTO gkey
gkey:
DO
g$ = INKEY$
LOOP UNTIL g$ <> ""
dd = ASC(RIGHT$(g$, 1))
IF dd = 27 THEN GOTO askesr
g$ = LCASE$(g$)
g = VAL(g$)
RETURN
pickset:
GOSUB clss
lp 3, 1, " Enter the number for the set of wave files that you want to use"
drow = 5: dcol = 1
FOR dpicks = 1 TO nof
dpl = LEN(fins$(dpicks))
dp$ = LEFT$(fins$(dpicks), dpl - 4)
LOCATE drow, dcol: PRINT #1, dpicks;
PRINT #1, dp$;
IF dpicks < 10 THEN dcol = dcol + 11 ELSE dcol = dcol + 12
IF dcol > 70 THEN dcol = 1: drow = drow + 1
NEXT dpicks
LOCATE 3, 66: LINE INPUT wavset$
wavset = VAL(wavset$)
IF wavset < 1 OR wavset > nof THEN lp 23, 1, " Sorry that was an invalid number, please try again": GOTO pickset
GOSUB clss
LOCATE 3, 1: PRINT #1, " unzipping the " + fins$(wavset) + " set of wave files"
GOSUB erwaves
bad = 0
FOR nw = 1 TO 9
unwv$ = RIGHT$(STR$(nw), 1) + ".WAV"
SHELL "unzip " + fins$(wavset) + " " + unwv$ + " > nul"
cw$ = DIR$(unwv$)
IF cw$ <> unwv$ THEN bad = 1
NEXT nw
RETURN
badwaveset:
GOSUB erwaves
LOCATE 5, 1: PRINT #1, " Sorry but the " + fins$(wavset) + " zip file"
LOCATE 6, 1: PRINT #1, " doesn't seem to be a set of wave files for the simon game"
LOCATE 8, 1: PRINT #1, " Press e to exit game or any other key"
DO: LOOP UNTIL INKEY$ = ""
DO
g$ = INKEY$
LOOP UNTIL g$ <> ""
IF LCASE$(g$) = "e" THEN GOTO et
RETURN
inpage:
CLS
lp 1, 27, " Simon     By Jim Kitchen"
lp 6, 5, " The object of this game is to listen to the tones then when you"
lp 7, 5, " hear a little drip sound you then type in the number"
lp 8, 5, " of each tone in the same sequence that they were played.  The"
lp 9, 5, " person who gets the most tones correct wins, but only completed"
lp 10, 5, " rounds count.  The time that it takes you to type in the"
lp 11, 5, " sequence will be a tie breaker in case two or more people get"
lp 12, 5, " the same number of completed tones."
lp 13, 5, " "
lp 14, 5, " There are four difficulty levels.  Level 1 (easy) and 2"
lp 15, 5, " (medium) have four tones.  Level 1 displays the number of the"
lp 16, 5, " tones as they are played.  Level 2 and up does not.  Level 3"
lp 17, 5, " (hard) has 6 tones and level 4 (expert) has 9 tones."
lp 23, 1, " Press the f1 key to repeat the instructions or any other key to continue"
GOSUB gkey
IF dd = 59 THEN GOTO inpage
RETURN
soundtest:
GOSUB clss
lp 3, 1, " Press f1 to repeat this message"
lp 5, 7, " f2 to hear sounds 1 through 4"
lp 7, 7, " f3 to hear sound 5 and 6"
lp 9, 7, " f4 to hear sounds 7, 8 and 9"
lp 11, 7, " or the enter key to start"
GOSUB gkey
IF dd = 13 THEN RETURN
dd = dd - 58
IF dd < 1 OR dd > 4 THEN GOTO soundtest
ON dd GOTO soundtest, f2, f3, f4
f2:
c1 = 1: c2 = 4
f2a:
FOR p = c1 TO c2
lp 24, 1, " here is tone number"
PRINT #1, p;
dy 1.6, dyx
sb sd$, RIGHT$(STR$(p), 1)
dy .2, dyx
NEXT p
GOTO soundtest
f3:
c1 = 5: c2 = 6
GOTO f2a
f4:
c1 = 7: c2 = 9
GOTO f2a
norec:
OPEN "o", #2, recnam$
FOR p = 1 TO 4
PRINT #2, rectone(1)
PRINT #2, rectime(1)
PRINT #2, "nobody"
NEXT p
CLOSE #2
RETURN
nocfg:
sd$ = "plany"
OPEN "o", #2, "simon.cfg"
PRINT #2, "plany"
CLOSE #2
GOTO gotcfg

SUB dy (a#, dyx)
st = TIMER + (a# * dyx)
DO
LOOP UNTIL TIMER > st
END SUB

SUB lp (a#, b#, a$)
LOCATE a#, b#
PRINT #1, a$;
END SUB

SUB sb (a$, b$)
SHELL a$ + " " + b$ + ".wav > nul"
END SUB

