DIM fins$(101), c$(17)
DECLARE SUB sb (a$, b$)
ns$ = LCASE$(COMMAND$)
ns = INSTR(ns$, "/ns")
IF ns > 0 THEN ns = 1
ON ERROR GOTO noco
x = SCREEN(1, 1, 1)
dfc = (x AND 128) \ 8 + (x AND 15)
dbc = (x AND 112) \ 16
COLOR dfc, dbc
renoco:
ON ERROR GOTO 0
CLS
SCREEN 0
WIDTH 80
OPEN "o", #1, "con"
LOCATE 1, 27: PRINT #1, " Trivia     By Jim Kitchen"
k$ = DIR$("trivia.dat")
IF k$ = "" THEN GOTO nodat
IF ns = 1 THEN GOTO ns1
dt = 2: GOSUB delay
spt$(1) = "wplay": spt$(2) = "plany": spt$(3) = "nusound /v:10"
ON ERROR GOTO nocfg
OPEN "i", #2, "trivia.cfg"
INPUT #2, sd$
CLOSE #2
gotcfg:
sb sd$, "jetsbell"
ns1:
nof = 1
fins$(nof) = DIR$("*.stg")
IF fins$(nof) = "" THEN GOTO newgame
DO
nof = nof + 1
fins$(nof) = DIR$
LOOP UNTIL fins$(nof) = ""
nof = nof - 1
IF nof = 1 THEN GOTO nosort1
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
nosort1:
GOSUB cl
LOCATE 3, 1
PRINT #1, " Do you want to resume a saved game Y or N"
GOSUB gkey
IF g$ = "n" THEN GOTO sgnl
aaa:
GOSUB cl
LOCATE 3, 1: PRINT #1, " list of saved games"
GOSUB cl
x = 1: y = 5
FOR af = 1 TO nof
LOCATE y, x: PRINT #1, af;
p = LEN(fins$(af)) - 4
PRINT #1, "= " + LEFT$(fins$(af), p);
x = x + 15
IF x > 65 THEN x = 1: y = y + 1
NEXT af
LOCATE 3, 1: PRINT #1, " Please enter the number of the saved game that you want to play";
LOCATE 3, 70: LINE INPUT f$
f = VAL(f$)
IF f < 1 OR f > nof THEN GOTO aaa
GOSUB cl
LOCATE 3, 1: PRINT #1, " checking ";
p = LEN(fins$(f))
PRINT #1, LEFT$(fins$(f), p - 4);
PRINT #1, " saved game file please wait"
k$ = ""
k$ = LCASE$(DIR$("trivia.q&a"))
IF k$ = "trivia.q&a" THEN KILL "trivia.q&a"
j = LEN(fins$(f))
MID$(fins$(f), j - 2, 3) = "trv"
NAME "trivia.dat" AS "unzip.exe"
SHELL "unzip " + fins$(f) + " > nul"
NAME "unzip.exe" AS "trivia.dat"
OPEN "i", #2, "trivia.q&a"
DO
LINE INPUT #2, t$
LOOP UNTIL LCASE$(LEFT$(t$, 2)) = "t>"
DO
LINE INPUT #2, b$
LOOP UNTIL LCASE$(LEFT$(b$, 2)) = "b>"
CLOSE #2
rag2:
GOSUB cl
t = LEN(t$)
t$ = " " + RIGHT$(t$, t - 2) + " trivia"
LOCATE 3, 1: PRINT #1, t$
b = LEN(b$)
b$ = " By " + RIGHT$(b$, b - 2)
LOCATE 5, 1: PRINT #1, b$
LOCATE 7, 1: PRINT #1, " is this the game that you would like to play Y or N"
GOSUB gkey
IF dd = 27 THEN GOSUB eorn: GOTO rag2
IF dd = 59 THEN GOTO rag2
IF g$ <> "y" THEN GOTO aaa
GOTO restoregame
sgnl:
GOSUB cl
newgame:
nof = 1
fins$(nof) = DIR$("*.trv")
IF fins$(nof) = "" THEN GOTO notrv
DO
nof = nof + 1
fins$(nof) = DIR$
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:
GOSUB cl
LOCATE 3, 1: PRINT #1, " list of trivia files"
GOSUB cl
x = 1: y = 5
FOR af = 1 TO nof
LOCATE y, x: PRINT #1, af;
p = LEN(fins$(af)) - 4
PRINT #1, "= " + LEFT$(fins$(af), p);
x = x + 15
IF x > 65 THEN x = 1: y = y + 1
NEXT af
LOCATE 3, 1: PRINT #1, " Please enter the number of the trivia file that you want to play";
LOCATE 3, 67: LINE INPUT f$
f = VAL(f$)
IF f < 1 OR f > nof THEN GOTO aa
GOSUB cl
LOCATE 3, 1: PRINT #1, " checking ";
p = LEN(fins$(f))
PRINT #1, LEFT$(fins$(f), p - 4);
PRINT #1, " trivia data file please wait"
k$ = ""
k$ = LCASE$(DIR$("trivia.q&a"))
IF k$ = "trivia.q&a" THEN KILL "trivia.q&a"
NAME "trivia.dat" AS "unzip.exe"
SHELL "unzip " + fins$(f) + " > nul"
NAME "unzip.exe" AS "trivia.dat"
ON ERROR GOTO badqa
OPEN "i", #2, "trivia.q&a"
DO
LINE INPUT #2, t$
LOOP UNTIL LCASE$(LEFT$(t$, 2)) = "t>"
DO
LINE INPUT #2, b$
LOOP UNTIL LCASE$(LEFT$(b$, 2)) = "b>"
noq = 0
gq:
DO
LINE INPUT #2, q$
IF LCASE$(LEFT$(q$, 2)) <> "q>" THEN GOTO gq1
noq = noq + 1
LINE INPUT #2, w$
gq1:
LOOP UNTIL LCASE$(LEFT$(w$, 2)) = "c>" OR EOF(2)
IF EOF(2) THEN GOTO gotit
GOTO gq
gotit:
CLOSE #2
REDIM pq(noq + 1)
rag:
GOSUB cl
t = LEN(t$)
t$ = " " + RIGHT$(t$, t - 2) + " trivia"
LOCATE 3, 1: PRINT #1, t$
b = LEN(b$)
b$ = " By " + RIGHT$(b$, b - 2)
LOCATE 5, 1: PRINT #1, b$
LOCATE 7, 1: PRINT #1, " is this the game that you would like to play Y or N"
GOSUB gkey
IF dd = 27 THEN GOSUB eorn: GOTO rag
IF dd = 59 THEN GOTO rag
IF g$ <> "y" THEN GOTO aa
qc = 0
start:
ON ERROR GOTO 0
qc = qc + 1
RANDOMIZE TIMER
GOSUB cl
repick:
qn = INT(RND(1) * noq) + 1
IF qc = 1 THEN GOTO nc
bad = 0
FOR c = 1 TO qc
IF qn = pq(c) THEN bad = 1
NEXT c
IF bad = 1 THEN GOTO repick
nc:
pq(qc) = qn
OPEN "i", #2, "trivia.q&a"
FOR w = 1 TO qn
gq2:
LINE INPUT #2, q$
IF LCASE$(LEFT$(q$, 2)) <> "q>" THEN GOTO gq2
NEXT w
gr:
GOSUB cl
ann = 0
qln = 1
GOSUB cl
lq = LEN(q$)
ql$(1) = " " + RIGHT$(q$, lq - 2)
LOCATE 3, 1: PRINT #1, ql$(1)
pa:
LINE INPUT #2, q$
IF LCASE$(LEFT$(q$, 2)) = "a>" THEN GOTO ans
IF ann = 9 THEN GOTO pa
IF MID$(q$, 2, 1) <> ">" THEN qln = qln + 1: ql$(qln) = " " + q$: PRINT #1, " " + q$: GOTO el
ann = ann + 1
PRINT #1, " "
al = LEN(q$)
ann$(ann) = LEFT$(q$, 1) + " " + RIGHT$(q$, al - 2)
PRINT #1, ann$(ann)
el:
GOTO pa
ans:
coco = 0
goco:
coco = coco + 1
LINE INPUT #2, c$(coco)
co = LEN(c$(coco))
IF LCASE$(LEFT$(c$(coco), 2)) = "q>" THEN coco = coco - 1: GOTO goco2
IF coco = 1 THEN c$(1) = RIGHT$(c$(1), co - 2)
IF coco = 16 THEN GOTO goco2
IF EOF(2) THEN GOTO goco2
GOTO goco
goco2:
CLOSE #2
cann = VAL(MID$(q$, 3, 1))
PRINT #1, " "
aga:
PRINT #1, " press the number of your answer"
GOSUB gkey
IF dd = 59 THEN GOSUB rpq: GOTO aga
IF dd = 27 THEN GOSUB eorn: GOSUB rpq: GOTO aga
IF g < 1 OR g > ann THEN PRINT #1, " ": PRINT #1, " That was an invalid answer please try again": GOSUB rpq: GOTO aga
dnc = 0
gs = g
corn:
GOSUB cl
LOCATE 3, 1
IF gs = cann THEN GOTO ga
IF dnc = 1 THEN GOTO np1
IF ns = 1 THEN GOTO np1
sb sd$, "incorrec"
np1:
PRINT #1, " sorry your answer is incorrect"
IF dnc = 1 THEN GOTO aha
IF ns = 1 THEN GOTO aha
porn = INT(RND(1) * 5) + 1
IF porn <> 3 THEN GOTO aha
dt = 2: GOSUB delay
sb sd$, "db"
GOTO aha
ga:
PRINT #1, " Yes you got it"
IF dnc = 1 THEN GOTO aha
IF ns = 1 THEN GOTO aha
dt = 1.2: GOSUB delay
sb sd$, "correct"
porn = INT(RND(1) * 5) + 1
IF porn = 3 THEN sb sd$, "excell"
aha:
IF dnc = 0 THEN IF gs = cann THEN noca = noca + 1
PRINT #1, " "
PRINT #1, " The correct answer is"
PRINT #1, " "
PRINT #1, ann$(cann)
IF c$(1) = "" THEN GOTO nocom
PRINT #1, " "
FOR j = 1 TO coco
PRINT #1, " " + c$(j)
NEXT j
nocom:
PRINT #1, " "
PRINT #1, " Press E to end game s to save game or any other key to continue";
GOSUB gkey
IF g$ = "e" THEN GOTO gameover
IF g$ = "s" THEN GOTO savegame
dnc = 1
IF dd = 59 THEN GOTO corn
IF dd = 27 THEN GOSUB eorn: GOTO corn
IF qc = noq THEN GOTO gameover
GOTO start
gameover:
GOSUB cl
LOCATE 3, 1: PRINT #1, " In"
LOCATE 5, 1: PRINT #1, t$
LOCATE 7, 1: PRINT #1, b$
LOCATE 9, 1: PRINT #1, " You got";
PRINT #1, noca;
PRINT #1, "answers correct out of a possible";
PRINT #1, qc
pc = INT((noca * 100) / qc)
LOCATE 11, 1: PRINT #1, " That is";
PRINT #1, pc;
PRINT #1, "percent"
IF ns = 1 THEN GOTO ns2
dt = 6: GOSUB delay
IF pc < 70 THEN sb sd$, "db"
IF pc > 89 THEN sb sd$, "correct"
IF pc > 94 THEN sb sd$, "excell"
ns2:
LOCATE 13, 1: PRINT #1, " Would you like to play again Y or N"
GOSUB gkey
IF g$ = "y" THEN RUN
IF g$ = "n" THEN GOTO go2
GOTO gameover
go2:
CLS
GOSUB ccr
IF ns = 1 THEN GOTO ns3
sb sd$, "jetsbell"
ns3:
SYSTEM
nodat:
LOCATE 3, 1
PRINT #1, " sorry but I could not find the trivia.dat file"
PRINT #1, " this game can not run without it"
PRINT #1, " you may want to down-load a new copy of the trivia.zip file from my web page"
PRINT #1, " at http://www.now-online.com/jkitchen"
PRINT #1, " write me at jim.kitchen@pcohio.net"
PRINT #1, " my phone number is 1-440-286-6920"
GOSUB ccr
LOCATE 10, 1
SYSTEM
ccr:
CLOSE
k$ = LCASE$(DIR$("unzip.exe"))
IF k$ = "unzip.exe" THEN NAME "unzip.exe" AS "trivia.dat"
k$ = LCASE$(DIR$("trivia.q&a"))
IF k$ = "trivia.q&a" THEN KILL "trivia.q&a"
k$ = LCASE$(DIR$("trivia.tmp"))
IF k$ = "trivia.tmp" THEN KILL "trivia.tmp"
RETURN
notrv:
GOSUB cl
LOCATE 3, 1: PRINT #1, " Sorry but I couldn't find any files with a trv extention"
PRINT #1, " Please make sure to put this program in the same directory as the files"
PRINT #1, " that you down load or that came with the game"
PRINT #1, " You can find files for this trivia game on my web site at"
PRINT #1, "http://users.nowonline.net/jkitchen"
PRINT #1, " or write me at jim.kitchen@pcohio.net"
PRINT #1, " my phone number is 1-440-286-6920"
GOSUB ccr
LOCATE 11, 1
SYSTEM
badqa:
GOSUB cl
LOCATE 3, 1
PRINT #1, " There is a problem with the trivia.q&a file"
PRINT #1, " Please contact Jim Kitchen at jim.kitchen@pcohio.net"
PRINT #1, " or by phone at 1-440-286-6920"
GOSUB ccr
LOCATE 7, 1
SYSTEM
delay:
tit = TIMER + dt
DO
LOOP UNTIL TIMER > tit
RETURN
eorn:
LOCATE 25, 1: PRINT #1, " Do you really want to leave the program? Y or N";
DO: LOOP UNTIL INKEY$ = ""
DO
g$ = INKEY$
LOOP UNTIL g$ <> ""
g$ = LCASE$(g$)
IF g$ = "y" THEN GOTO go2
IF g$ <> "n" THEN GOTO eorn
LOCATE 25, 1: PRINT SPC(78);
RETURN
gkey:
DO: LOOP UNTIL INKEY$ = ""
DO
g$ = INKEY$
LOOP UNTIL g$ <> ""
g = VAL(g$)
dd = ASC(RIGHT$(g$, 1))
g$ = LCASE$(g$)
RETURN
cl:
FOR cl = 2 TO 25
LOCATE cl, 1
PRINT SPC(79);
NEXT cl
RETURN
rpq:
GOSUB cl
LOCATE 3, 1
FOR j = 1 TO qln
PRINT #1, ql$(j)
NEXT j
FOR j = 1 TO ann
PRINT #1, " "
PRINT #1, ann$(j)
NEXT j
PRINT #1, " "
RETURN
savegame:
IF ns = 1 THEN GOTO ns4
sb sd$, "savedata"
ns4:
j = LEN(fins$(f))
MID$(fins$(f), j - 2, 3) = "stg"
OPEN "o", #3, fins$(f)
PRINT #3, noq
PRINT #3, qc
PRINT #3, noca
FOR i = 1 TO qc
PRINT #3, pq(i)
NEXT i
CLOSE #3
GOTO gameover
restoregame:
j = LEN(fins$(f))
MID$(fins$(f), j - 2, 3) = "stg"
OPEN "i", #3, fins$(f)
INPUT #3, noq
REDIM pq(noq)
INPUT #3, qc
INPUT #3, noca
FOR i = 1 TO qc
INPUT #3, pq(i)
NEXT i
CLOSE #3
KILL fins$(f)
MID$(fins$(f), j - 2, 3) = "trv"
GOTO start
noco:
RESUME renoco
nocfg:
RESUME nc0
nc0:
ON ERROR GOTO 0
nc1:
LOCATE 8, 1: PRINT #1, " Please press the number of the sound player program to try"
LOCATE 10, 1: PRINT #1, " 1 = wplay"
LOCATE 11, 1: PRINT #1, " 2 = plany"
LOCATE 12, 1: PRINT #1, " 3 = nusound"
GOSUB gkey
IF (g < 1 OR g > 3) THEN GOTO nc1
sd$ = spt$(g)
nc2:
sb sd$, "aha"
sb sd$, "excell"
LOCATE 15, 1: PRINT #1, " Press y to use this sound player"
LOCATE 16, 1: PRINT #1, " or if you didn't hear anything then press n to try a different player"
GOSUB gkey
IF (dd > 58 AND dd < 64) THEN GOTO nc2
IF g$ <> "y" THEN GOTO nc1
OPEN "o", #2, "trivia.cfg"
PRINT #2, sd$
CLOSE #2
GOSUB cl
GOTO gotcfg

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

