Skip to content

Instantly share code, notes, and snippets.

@tomaes
Last active December 4, 2020 10:26
Show Gist options
  • Save tomaes/8868532aab19fcafc75ff427ae753aab to your computer and use it in GitHub Desktop.
Save tomaes/8868532aab19fcafc75ff427ae753aab to your computer and use it in GitHub Desktop.
A population quiz game in moreorless.io style (Commodore Plus/4 version)
0 rem _,/'%%&&&&&&&&&&&&&&&&&%%'\__
1 rem ((_country pop plus/4 version_))
2 rem \_\%%%%%%%%%%%%%%%%%%%%%%%/_/
7 : :
8 : v$ = "v1.2f, May/June 2020" :
9 : :
10 rem init '''''''''''''''''''''';
11 vol 5: n=20
12 dim c$(n),c(n),hi$(6),di(6)
13 dim ac$(n),ao$(n),ap(n),aa(n)
14 di(0)= 2: di(1)= 6: di(2)=8
15 di(3)=10: di(4)=14: di(5)=n: od=3
16 di$(5)="guru": di$(4)="hard": di$(3)="doable"
17 di$(2)="easy": di$(1)="kids": di$(0)="dummy"
18 color 0,7,1: color 4,7,1: print chr$(14)
19 gosub 600
20 :
21 rem hiscore init, read data
22 for i = 0 to 5
23 hi$(i)="No Rating yet": next
24 for i = 0 to n-1
25 read d1$, d2$, d3, d4
26 ac$(i) = d1$: ap(i) = d3
27 ao$(i) = d2$: aa(i) = d4
28 next
29 :
30 rem call settings menu ----
33 gosub 200
34 :
35 rem filter as needed ------
36 for i = 0 to n-1
37 c$(i) = ac$(i): c(i) = ap(i)
38 if oo = 1 then c$(i) = ao$(i)
39 if oa = 1 then c(i) = aa(i)
40 next
45 :
50 rem retry point ----------------------------------------------------------
51 color 1,8,7: print
52 if oa = 0 then print "Where do more people live?"
53 if oa = 1 then print "What territory is bigger?"
54 print "Get ready!"
56 for i=0 to 1999: next
58 tj = ti: r = 0
59 :
60 rem round cont -----------------------------------------------------------
61 r = r+1
62 p = int(rnd(1)*di(od))
63 q = int(rnd(1)*di(od)): if p = q then 63
64 :
65 sound 1,700 + int(r/5)*20, 10
66 print: color 1,4,7
67 print str$(r)". ";: if ot = 0 then print "[a] ";
68 color 1,2,7 :print c$(p); :color 1,4,7
69 print " vs. ";: if ot = 0 then print "[b] ";
70 color 1,2,7: print c$(q);: color 1,8,7
71 ok=0
72 if ot=1 then print:input ">";a$:else do: get a$: loop until a$="a"ora$="b"
73 if ot = 1 and a$ = c$(p) then a$="a": ok=1
74 if ot = 1 and a$ = c$(q) then a$="b": ok=1
75 if ot = 1 and ok = 0 then print " Fatal Typing!": goto 80
76 if a$ = "a" and c(p)>c(q) then print " "chr$(186)" OK!": goto 60
77 if a$ = "b" and c(q)>c(p) then print " "chr$(186)" Yep": goto 60
78 :
79 rem game over ------------------------------------------------------------
80 color 1,11,7 :print " X Fault!"
81 sound 1, 200, 20
82 :
83 color 1,4,7
84 print: print "> "c$(p)":"str$(c(p))"M vs "c$(q)":"str$(c(q))"M"
85 :
86 print: t = (ti-tj) / 60
87 print "Time total:"t"sec."
88 print "Time/Round:"t/r"sec."
89 r$ = "D": sound 1, 400, 20
90 if r > 5 and t < r*8 then sound 1, 300, 20: r$ = "C (zZz)"
91 if r > 10 and t < r*4 then sound 1, 500, 20: r$ = "B (Alright)"
92 if r > 20 and t < r*3 then sound 1, 600, 20: r$ = "A (Well done!)"
93 if r > 30 and t < r*2 then sound 1, 800, 20: r$ = "* (Impressive!)"
94 if r > 99 and t < r*3 then sound 1, 899, 20: r$ = "! (Amazing!)"
95 print "Rating: ";: color 1,2,7: print r$: color 1,4,7
96 if r$<hi$(od) then hi$(od)=r$: print "New best rating in '";di$(od);"'"
97 print: input "Retry (same config) or restart (y/n)";a$
98 if a$ = "y" then goto 50: else gosub 600: goto 30
99 :
200 rem welcome header ------------------------------------------------------
235 color 1,5,7: print " >> ";
236 color 1,8,7: print "Country Pop (Plus/4 version)"
237 color 1,5,7: print " ...a frantic geography quiz <<"
260 :
300 rem settings menu -------------------------------------------------------
303 print: color 1,14,7
305 print "Settings >";: color 1,4,7
306 print "Type the words in quotes.": print "."
310 print chr$(235)" Input: '";: if ot = 1 then color 1,2,7 :else color 1,4,6
315 print "Typing";: color 1,4,6 : print "' vs. slamming '";
316 if ot = 0 then color 1,2,7 :else color 1,4,6
317 print "Keys";: color 1,4,6 : print"'": color 1,4,7
318 :
320 print chr$(235)" Modes: '";: if oa = 0 then color 1,2,7 :else color 1,4,6
321 print "People";: color 1,4,6 : print "' vs. '";
322 if oa = 1 then color 1,2,7 :else color 1,4,6
323 print "Area";: color 1,4,6 : print "'": color 1,4,7
324 :
329 print chr$(235)" Style: '";: if oo = 1 then color 1,2,7 :else color 1,4,6
330 print "Olympics";: color 1,4,6: print "' vs. '";
331 if oo = 0 then color 1,2,7 :else color 1,4,6
332 print "Country";:
333 color 1,4,6 : print "' names": color 1,4,7
334 print chr$(235)" Skill: '";: if od = 4 then color 1,2,7 :else color 1,4,6
337 print "hard";: color 1,4,6 : print "','";
338 if od = 3 then color 1,2,7 :else color 1,4,6
339 print "doable";:color 1,4,6 : print "','";
340 if od = 2 then color 1,2,7 :else color 1,4,6
341 print "easy";: color 1,4,6 : print "','";
342 if od = 1 then color 1,2,7 :else color 1,4,6
343 print "kids";: color 1,4,6 : print "'"
344 :
345 a$=chr$(192): color 1,6,7
346 print chr$(237)a$a$a$a$a$a$"> 'play' vs. 'exit' or 'info'"
347 a$="": print: input ">";a$
348 :
350 if a$ = "Olympics"then oo = 1
351 if a$ = "Country" then oo = 0
352 if a$ = "Typing" then ot = 1
353 if a$ = "Keys" then ot = 0
354 if a$ = "People" then oa = 0
355 if a$ = "Area" then oa = 1
356 if a$ = di$(5) then od = 5
357 if a$ = di$(4) then od = 4
358 if a$ = di$(3) then od = 3
359 if a$ = di$(2) then od = 2
360 if a$ = di$(1) then od = 1
361 if a$ = di$(0) then od = 0
362 if a$ = "info" then gosub 700
363 if a$ = "col1" then color 0, 7,1: color 4, 7,1: goto 347
364 if a$ = "col2" then color 0,10,1: color 4,10,1: goto 347
365 if a$ = "col3" then color 0,12,1: color 4,12,1: goto 347
366 if a$ = "play" then return
368 if a$ = "tutorial"then gosub 666
369 if a$ = "ver" then print: print v$: goto 347
370 if a$ = "list" then gosub 380
371 if a$ = "help" then print "hint: CapiTaliZe!": goto 347
372 if a$ = "best" then gosub 750
374 if a$ = "load" then gosub 770
375 if a$ = "save" then gosub 780
376 if a$ = "exit" or a$="x" or a$="q" then 400
377 if a$ = "" then 347
378 goto 300
379 :
380 rem country listing -------------------------------------
382 color 1,2,7: print
383 print "Country" tab(13) "IOC" tab(21) "Pop." tab(30) "Area"
385 color 1,5,7
386 for i=0 to n-1
388 print "> "ac$(i) tab(12) "(" ao$(i) ")";
389 print using " ###.#"; ap(i); : print using " #.####"; aa(i)
392 next
393 color 1,2,7: print "press key": do: geta$: loop until a$<>""
394 return
396 :
399 rem quit ------------------------------------------------
400 color 1,1,0 : rem text (org)
401 color 0,2,7 : rem main (org)
402 color 4,15,6 : rem frame (org)
403 char ,0,24, chr$(142) + "bye!"
404 end
405 :
408 rem 2020 stats --------------------
409 rem - country --- ioc -- pop - area
410 data "Brazil", "BRA", 212.6, 8.52
412 data "Germany", "GER", 83.8, 0.36
420 data "Italy", "ITA", 60.5, 0.30
422 data "Cuba", "CUB", 11.3, 0.11
430 data "Canada", "CAN", 37.7, 9.98
432 data "S. Korea", "KOR", 51.3, 0.10
440 data "Argentina","ARG", 45.2, 2.78
442 data "Egypt", "EGY", 102.3, 1.00
450 data "Sweden", "SWE", 10.1, 0.45
452 data "Oman", "OMA", 5.1, 0.31
460 data "Jordan", "JOR", 10.2, 0.09
462 data "Fiji", "FIJ", 0.9, 0.018
470 data "Mongolia", "MGL", 3.3, 1.56
472 data "Botswana", "BOT", 2.4, 0.58
480 rem --------------------------------
500 data "Burundi", "BDI", 11.9, 0.029
502 data "Uzbekistan","UZB", 33.5, 0.45
504 data "Nepal", "NEP", 29.1, 0.15
506 data "Panama", "PAN", 4.3, 0.08
508 data "Malta", "MLT", 0.44, 0.0003
510 data "Sri Lanka", "SRI", 21.4, 0.066
550 :
599 rem boot logo ------------------------------------------------------------
600 print
601 color 1, 3,4: print" %%% %%% %% %% %%% %%%%% %%% % % P";
602 color 1,10,5: print"%% %% %% %% %% %% %% %%% %% % %%% O";
603 color 1, 8,7: print"%%%% %%%%% %%% %% %% %%% %% % % P";
610 color 1, 3,7
612 for i=0 to 4 step 2: print chr$(192)"-";: next: color 1, 9,7
614 for i=0 to 9 step 2: print chr$(192)"-";: next: color 1,11,7
616 for i=0 to 23 step 2: print chr$(192)"-";: next
618 for i=0 to 5: sound 1,780+int(sin(i*.05)*100),3: next
620 :
624 return
626 :
666 rem "tutorial" -----------------------------------------------------------
668 print: color 1,2,7
670 print "Type out the alphabet"
671 print "...as fast as possible!"
672 color 1,8,7: print "> ";: i = 0
680 get a$: if a$="" then 680
682 print a$;: if asc(a$)=65+i then i=i+1:sound 1,500+i*10,2: if i<26 then 680
684 if i = 26 then print " < ": color 1,4,7: print chr$(186)" Done!": return
686 print "?!"
688 print " ...better luck next time!"i"/ 26": a$="": return
690 :
700 rem info -------------------------------------------------
702 print: color 1,2: print "Country Pop Plus/4, the story"
703 print: color 1,4
704 print "After playing moreorless.io and"
705 print "looking at the Worldometers tables"
706 print "once too often, a micro game in BASIC"
707 print "emerged and from that a mini game for"
708 print "C64, that was ported to Plus/4, and"
709 print "further to the C128 ...and back again!"
711 print
712 print: color 1,2: print "...some additional keywords to try"
713 print: color 1,4
714 print "'colx' (x=1..3)", "change background"
716 print "'ver'",, "show version"
717 print "'tutorial'", "typing experience"
718 print "'list'",, "country data"
719 print "'best'",, "hi-score list"
721 print "'load','save'", "hi-score load/save"
722 print "'x' or 'q'", "quick exit": print
723 color 1,2,7: print "press key"
724 a$="": do: get a$: loop until a$<>""
725 return
730 :
750 rem hiscore ----------------------------------------------
752 color 1,2: print: print "skill","best rating"
753 color 1,4
754 for i=0 to 5: print di$(i), hi$(i): next
756 return
758 :
760 rem load/save best ratings ----------------
770 open 1, 8, 4, "country pop hi,s,r"
772 for i=0 to 5
774 : input#1, hi$(i): next
776 close 1
778 goto 790
780 open 1, 8, 4, "@:country pop hi,s,w"
782 for i=0 to 5
784 : print#1, hi$(i): next
788 close 1
790 open 1,8,15
792 input#1,ff$,fe$,fd$,fc$
794 print "drive status:"; fe$
796 close 1
798 return
999 :> tomaes'2o
@tomaes
Copy link
Author

tomaes commented Jun 16, 2020

VIC20 version

11 n=14:cl=646:sc=36879:s=sc-5:w=999
14 dimc$(n),c(n):dimac$(n),ao$(n),ap(n),aa%(n)
16 di(2)=8:di(3)=10:di(4)=14:od=3:pokesc,8
20 printchr$(14):fori=.ton-1:readd1$,d2$,d3,d4
26 ac$(i)=d1$:ap(i)=d3:ao$(i)=d2$:aa%(i)=d4:next   
29 :
30 gosub200:fori=.ton-1:c$(i)=ac$(i):c(i)=ap(i)
38 ifoo=1thenc$(i)=ao$(i)
39 ifoa=1thenc(i)=aa%(i)
40 next
50 :
51 pokecl,7:print:ifoa=0thenprint"Where do > folks live?"
53 ifoa=1thenprint"What terr. is bigger?":print"Get ready!"
54 fori=0tow*2:next:tj=ti:r=0
55 :
60 r=r+1:p=int(rnd(1)*di(od)):fx=200+(rand31):gosub800
62 q=int(rnd(1)*di(od)):ifp=qthen62
66 print:pokecl,3:printstr$(r)"."tab(4);:ifot=0thenprint"[a] ";
68 pokecl,1:printc$(p);:pokecl,3:print" vs.":printtab(4):ok=0
69 ifot=0thenprint"[b] ";:pokecl,1:printc$(q);:pokecl,7
71 ifot=1thenpokecl,1:print"   "c$(q):pokecl,3:input">";a$
72 ifot=0thenfori=.tow:geta$:ifa$<>"a"anda$<>"b"thennext
73 ifot=1anda$=c$(p)thena$="a":ok=1
74 ifot=1anda$=c$(q)thena$="b":ok=1
75 ifot=1andok=0thenpokecl,5:print" Fatal Typing!":goto80 
76 ifa$="a"andc(p)>c(q)thenprint" "chr$(186)" Ok":goto60
77 ifa$="b"andc(q)>c(p)thenprint" "chr$(186)" Jo":goto60
79 :
80 pokecl,2:print:print" Fault!":pokecl,3:print:fx=240:gosub800
82 m$="M":ifoa=1thenm$="T sq km"
84 printc$(p)":"str$(c(p))m$
85 printc$(q)":"str$(c(q))m$
86 print:t=(ti-tj)/60:print"Time all:"t
88 print"Time/#  :"t/r:r$="D" 
92 if r>5andt<r*8thenfx=200:r$="C=>zZz"
93 ifr>10andt<r*4thenfx=220:r$="B=>Alright"
94 ifr>20andt<r*3thenfx=240:r$="A=>Well done!"
95 ifr>30andt<r*2thenfx=255:r$="*=>Impressive!"
96 print"Rating  : ";:pokecl,1:printr$:pokecl,3:print:gosub800
97 input"Again or new (y/n)";a$:ifa$="y"then50
99 goto30
200 :
220 print:pokecl,2:print"%%%%%%%%%%%%%%%%%%%%"
236 pokecl,7:print"Country Pop (VIC-20)"
237 pokecl,1:print"a quirky geo quiz"
239 pokecl,2:print"%%%%%%%%%%%%%%%%%%%%":fx=200:gosub800
300 :
303 pokecl,3:print:print"Type what's (enclosed)"
310 ifot=1thenpokecl,1 
312 print"(";:ifot=0thenpokecl,3
313 print"Typing";:pokecl,3:print")  -  (";
314 ifot=0thenpokecl,1 
315 ifot=1thenpokecl,3
316 print"Keys";:pokecl,3:print")"
320 print"(";
321 ifoa=0thenpokecl,1
322 ifoa=1thenpokecl,3
323 print"People";:pokecl,3:print")  -  (";
324 ifoa=1thenpokecl,1
325 ifoa=0thenpokecl,3
326 print"Area";:pokecl,3:print")"
328 print"(";:ifoo=1thenpokecl,1 
329 ifoo=0thenpokecl,3
330 print"Olympia";:pokecl,3:print") -  (";
341 ifoo=0thenpokecl,1 
342 ifoo=1thenpokecl,3
342 print"Country"; 
343 pokecl,3:print")":print
344 print"(";:ifod=4thenpokecl,1
345 ifod<>4thenpokecl,3
346 print"hard";:pokecl,3:print"),(";:ifod=3thenpokecl,1 
347 ifod<>3thenpokecl,3
348 print"doable";:pokecl,3:print"),(";:ifod=2thenpokecl,1
349 ifod<>2thenpokecl,3
351 print"easy";:pokecl,3:print")";:pokecl,4:print"(play),(exit)"
354 pokecl,3:a$="":print:input">";a$
360 ifa$="Olympia"thenoo=1
361 ifa$="Country"thenoo=0
362 ifa$="Typing"thenot=1
363 ifa$="Keys"thenot=0
364 ifa$="People"thenoa=0
365 ifa$="Area"thenoa=1
367 ifa$="hard"thenod=4
368 ifa$="doable"thenod=3
369 ifa$="easy"thenod=2
372 ifa$="play"thenreturn
374 ifa$="help"thenprint"Hint: CapiTaliZe!"
375 ifa$="ver"thenprint"Crnchd VC20 v.; Jne'20"
382 ifa$="exit"ora$="x"then500
386 ifa$=""then357
389 goto300
500 pokecl,6:pokesc,27:fori=.to25:print:next:printchr$(142)"bye!":end
508 :
510 data"Brazil","BRA",212.4,8520,"Germany","GER",83.8,360
512 data"Italy","ITA",60.5,300,"Cuba","CUB",11.3,110
514 data"Canada","CAN",37.7,9980,"S. Korea","KOR",51.3,100
516 data"Argentina","ARG",45.2,2780,"Egypt","EGY",102.1,1002
518 data"Sweden","SWE",10.1,450,"Oman","OMA",5.1,310
520 data"Jordan","JOR",10.2,90,"Fiji","FIJ",0.9,18
522 data"Mongolia","MGL",3.3,1560,"Botswana","BOT",2.3,580
530 :
800 pokes+4,15:pokes+1,fx:fori=1to59:next:pokes+1,.:return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment