home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1986 May & June
/
rerun-1986-05-06.d64
/
arithme-sketch
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
246 lines
10 printchr$(142):goto560
30 rem arithme-sketch by ted jean & jim pellechi
80 rem right answer
90 pokev,15:fortt=1to3:poked,10:poker,64+11:pokesu,23:pokes1,23:pokeu,4
100 pokew,21:fort=1to50:next:pokew,20
110 fort=1to16:poke53280,peek(53280)+1and15:next:next:poke53280,14:return
120 : key pressed
130 pokev,15:pokeu,110:poked,15:poker,9:pokew,17:fort=1to90:next:pokev,0
140 fort=0to24:pokeb+t,0:next:return
150 : wrong answer
160 poke53280,9:fortt=1to25:pokev,10
170 fort=1to3:next:pokev,0:fori=1to3:next:next:poke53280,14:return
180 rem large numbers
190 on(a+1) gosub200,210,220,230,240,250,260,270,280,290:printchr$(29);:return
200 print" [157][145] [157][145] [157] [157] [157] [157] [157][157] [157][157] [157][145] [145]";:return: 0
210 print"[145][145] [157] [157] [157] [157] [145][145]";:return: 1
220 print"[145][145] [157] [157] [157][157] [157][157] [157] [157] [145][145]";:return: 2
230 print"[145][145] [157] [157] [157][157] [157][157] [157] [157][145] [145]";:return: 3
240 print"[145][145] [157] [157] [145][145][157] [157] [157] [157] [145][145]";:return: 4
250 print"[145][145] [157][157][157] [157] [157] [157][157][157] [145][145]";:return: 5
260 print"[145][145] [157] [157] [157][157][157] [157] [145][157] [145]";:return: 6
270 print"[145] [157][145] [157] [157] [157] [157] [145][145]";:return: 7
280 print" [157][145] [157][145] [157] [157] [157] [157] [157][157] [157][157] [157][145] [145] ";:return: 8
290 print" [157][145] [157][145] [157] [157] [157] [157] [157][157] [157][157] [145][145] ";:return: 9
300 on gl goto310,320,330,340,350
310 s=8:sl=15:ll= 8:return
320 s=6:sl=13:ll=12:return
330 s=4:sl=12:ll=15:return
340 s=2:sl=10:ll=19:return
350 s=0:sl= 8:ll=23:return
360 rem clipboard
370 poke53280,14:poke53281,7
380 print"[149] [180][213][201][170] ";
390 print" [205][202][203][206] ";
400 print" [146][169] [223] [146]"
410 print" [146] [221][149] [206] [205] "
420 print" [146] [221][149] [183][183][183][183][183][183] [145]":fora=0to9
430 print" [146] [221][149] "
440 print" [146][163][163][221][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][149] [145]":next
450 fora=1308to1948step320:pokea,81:next:return
460 rem title screen
470 gosub370
480 print line$(8)spc(14)"arithme-sketch"
490 print line$(9)spc(14);
500 for a=1to14:print chr$(183);:next
510 print line$(12)spc(10)"what kind of problems ?"
520 print line$(16)spc(7)"press + for addition"
530 print line$(18)spc(7)"press - for subtraction"
540 print line$(22)spc(12)"your choice ";:return
550 rem cursor control
560 dim line$(25)
570 line$(1)=chr$(19)
580 for a=2to25
590 line$(a)=line$(a-1)+chr$(17):next
600 rem constants
610 zz=1:sc=1065:co=54272:cl=0
620 rem joystick table
630 for a=0to10:read xy(a):next
640 data 0,-40,40,0,-1,-41
650 data 39,0,1,-39,41
660 rem keyboard table
670 dim key(64)
680 for a=0to64:key(a)=0:next
690 key(08)=11:key(11)=15:key(16)=5
700 key(19)=6:key(24)=7:key(27)=8
710 key(56)=1:key(59)=2
720 rem ml
730 ad=49152
740 read a:ifa<>-1thenpokead,a:ad=ad+1:goto740
750 data 162,4,160,196,32,30,192
760 data 162,216,160,200,32,30
770 data 192,96,162,196,160,4
780 data 32,30,192,162,200,160
790 data 216,32,30,192,96
800 data 142,42,192,140,45,192
810 data 160,4,162,0,189,0,0
820 data 157,0,0,202,208,247
830 data 238,42,192,238,45,192
840 data 136,208,238,96,-1
850 rem sound
860 b=54272:fort=0to24:pokeb+t,0:next
870 v=b+24:w=b+4:u=b+1:d=b+5:r=b+6:s1=b+14:su=b+15
880 rem display title
890 print"[147]":gosub470:poke198,0
900 print"?"chr$(149)chr$(157);:if peek(162)and32 then printchr$(158);
910 getan$:ifan$<>"+"andan$<>"-"then900
920 printchr$(149)an$:gosub130:for a=1to500:next
930 rem difficulty level
940 gosub370
950 print line$(6)spc(11)"select grade level"
960 print line$(10)spc(11)chr$(18)"1"spc(5)chr$(146)" first grade"
970 print line$(12)spc(11)chr$(18)"2"spc(5)chr$(146)"second grade"
980 print line$(14)spc(11)chr$(18)"3"spc(5)chr$(146)" third grade"
990 print line$(16)spc(11)chr$(18)"4"spc(5)chr$(146)"fourth grade"
1000 print line$(18)spc(11)chr$(18)"5"spc(5)chr$(146)" fifth grade"
1010 print line$(24)spc(9)"pick any grade"chr$(149)" 1 - 5"
1020 ifpeek(162)and32thenprintchr$(158);
1030 geta$:on-(a$<"1"ora$>"5"ora$="")goto1010:gosub130
1040 nn=10^(val(a$))-1:mm=nn
1050 :
1060 rem instructions
1070 gosub370
1080 print line$(8)spc(10)"you will now get 5"
1090 print line$(10)spc(10)chr$(18);
1100 ifan$="+"then print"addition problems.":goto1120
1110 print"subtraction problems."
1120 print line$(12)spc(10)"for every right answer,"
1130 print line$(14)spc(10)"you will get 1 minute"
1140 print line$(16)spc(10)"of drawing time."
1150 print line$(20)spc(15);
1160 for a=1to11:print chr$(175);:next
1170 print line$(21)spc(15)chr$(18)" good luck "
1180 print line$(22)spc(15);
1190 for a=1to11:print chr$(163);:next:poke198,0
1200 print line$(24)spc(8)"press "
1210 print line$(24)spc(14)"any key"chr$(149)" to continue"
1220 ifpeek(162)and32thenprintchr$(158);
1230 geta$:on-(a$="")goto1210:gosub130
1240 rem begin math
1250 prob=1:tl=0:poke198,0
1260 gosub1900:try=0
1270 gosub370
1280 rem math problems
1290 print line$(05)spc(6)"problem"spc(35)"#"prob:gosub300
1300 printline$(09)spc(12)spc((gl-ln)*4+s);
1310 on ln goto1370,1360,1350,1340,1330,1320
1320 a=n(1):gosub190
1330 a=n(2):gosub190
1340 a=n(3):gosub190
1350 a=n(4):gosub190
1360 a=n(5):gosub190
1370 a=n(6):gosub190
1380 printline$(15)spc(12)spc((gl-lm)*4+s);
1390 on lm goto1450,1440,1430,1420,1410,1400
1400 a=m(1):gosub190
1410 a=m(2):gosub190
1420 a=m(3):gosub190
1430 a=m(4):gosub190
1440 a=m(5):gosub190
1450 a=m(6):gosub190
1460 printline$(16)spc(sl);
1470 if an$="+"then print" [157][157][145] [157] ":goto1490
1480 print "[175][175]"
1490 printline$(18)spc(sl);
1500 for a=0to ll:print chr$(185);:next
1510 print line$(22)spc((sl+ll)-2);
1520 gosub2050:rem digit 1
1530 ans=val(a$)
1540 if n3<10 then1690
1550 gosub2050:rem digit 2
1560 ans=ans+(val(a$)*10)
1570 if n3<100 then1690
1580 gosub2050:rem digit 3
1590 ans=ans+(val(a$)*100)
1600 if n3<1000 then1690
1610 gosub2050:rem digit 4
1620 ans=ans+(val(a$)*1000)
1630 if n3<10000 then1690
1640 gosub2050:rem digit 5
1650 ans=ans+(val(a$)*10000)
1660 if n3<100000 then1690
1670 gosub2050:rem digit 6
1680 ans=ans+(val(a$)*100000)
1690 printchr$(18);:if n3=ans then1770
1700 gosub160:try=try+1:if try=2 then1730
1710 print line$(1)spc(3)"incorrect !!"spc(11)" try again "
1720 for a=1to2000:next:goto1270
1730 print line$(1)spc(2)"wrong again ..."spc(6)" the answer is "
1740 printline$(2)spc(24);:ifgl<4thenprint" ";:ifgl=1thenprint" ";
1750 print"*** "mid$(str$(n3),2)" ***"
1760 goto1790
1770 tl=tl+1
1780 print line$(1)spc(4)" excellent "spc(10)" answer !!!":gosub90
1790 printchr$(146):for a=1to1400:next
1800 prob=prob+1:if prob<6 then1260
1810 poke53280,14:poke53281,2
1820 poke646,1:print chr$(147)
1830 print line$(6)spc(10)"you got "tl" right!"
1840 print line$(9)spc(8)"now it is time to draw."
1850 print line$(16)spc(8)"use joystick in control"
1860 print line$(18)spc(15)"port # 2"
1870 for a=1to4000:next
1880 goto2110
1890 rem random numbers
1900 forx=1to6:n(x)=-1:next
1910 forx=1to6:m(x)=-1:next
1920 n=int((rnd(0)* nn)+1)
1930 m=int((rnd(0)* mm)+1)
1940 if an$="+"then n3=n+m:goto1980
1950 if n=m then1930
1960 if n<m then n3=n:n=m:m=n3
1970 n3=n-m
1980 n1$=str$(n):ln=len(n1$)-1
1990 x=1:fora=(7-ln)to6:n(a)=val(mid$(n1$,x+1,1)):x=x+1:next
2000 m1$=str$(m):lm=len(m1$)-1
2010 x=1:fora=(7-lm)to6:m(a)=val(mid$(m1$,x+1,1)):x=x+1:next
2020 if ln-lm<0then gl=lm:return
2030 gl=ln:return
2040 rem get digit
2050 poke198,0
2060 print"?"chr$(149)chr$(157);:ifpeek(162)and32thenprintchr$(158);
2070 geta$:ifa$<"0"ora$>"9"then2060
2080 a=val(a$):printchr$(158)chr$(160)chr$(149)chr$(157)chr$(157);:gosub190
2090 fora=0to6:print chr$(157);:next:gosub130:return
2100 rem
2110 rem dr