8-Bit Software Online Conversion
Faults Graphics Program - Listing
10 MODE129
20 INPUT"PICTURE NUMBER";P
25 INPUT"HEIGHT EXAGGERATION % +/-";H
E
26 CP=(100+HE)/100
30 R=RND(-P)
40 INPUT"WATER HIGHT , % (RETURN FOR
AVERAGE HIGHT)";PRR
44 PRR=PRR/100
45 PER=TRUE
50 IF PRR=0 PER=FALSE
60 INPUT"NUMBER OF BLOCKS ALONG EACH
SIDE ";C
70 GY=640/(C-1):GX=200/(C-1)
80E$="M*X+CC-Y"
81 CLS
90DIMCO%(C*C),BLUE%(6),COLS%(9):PROCS
ETUP
100FOR N=1TOC*C:CO%(N)=50:NEXT
110VDU19,2,2,0,0,0
120VDU19,1,4,0,0,0
130 PROCFAULT
140DEFPROCSCREENUP
150LO=100000:HI=-1000000:TT=0
160 LO2=10000
170CLS
180FORG=1TOC*C
190 IF CO%(G)<LO2 LO2=CO%(G)
200NEXT
210FORG=1TOC-1:FOR J=1TOC-1:GG=G+((J-1
)*C)
220AF=(CO%(GG)+CO%(GG+1)+CO%(GG+C)+CO%
(GG+C+1))/4
230IFAF<LO LO=AF
240IFAF>HI HI=AF
250TT=TT+AF
260NEXT,
270AVER=TT/(C*C)
280 IF PER AVER=LO+PRR*(HI-LO)
290INC=(HI-AVER)/10
300WINC=(AVER-LO)/6
310IF INC<1 INC=1
320IF WINC<0 WINC=1
330FOR G=1TO(C-1)^2
340PROCLOCATE2(G)
350A=ROW
360B=SP
370X=(GX*C*2)-(GX*B)-(GX*A)
380Y=640+(GY*B)-(GY*A)
390AV=(CO%(UP)+CO%(RI)+CO%(LE)+CO%(DO)
)/4
400PAT=(INT(((AV-AVER)/INC)))-1:IF PAT
<0 PAT=0
410VDU23,12:FOR TH=1TO8:VDU(COLS%(PAT)
AND 3*(4^(TH-1)))/(4^(TH-1))
420NEXT
430PROCWC
440NEXT:PROCFINOFF
450 G$=GET$:IF G$="D":*GDUMP
460 END
470DEFPROCTRI1
480GCOL16,0:MOVEY,X+CO%(UP):DRAW Y+GY,
X-GX+CO%(RI):PLOT 85,Y-GY,X-GX+CO%(LE)
490ENDPROC
500DEFPROCTRI2
510GCOL 16,0:MOVE Y,X-GX-GX+CO%(DO):DR
AW Y+GY,X-GX+CO%(RI):PLOT 85,Y-GY,X-GX+C
O%(LE)
520ENDPROC
530DEFPROCSETUP
540FOR N=1TO10:FOR M=1TO8
550READ A:COLS%(N-1)=COLS%(N-1)+A*(4^(
M-1))
560NEXT,
570FOR N=1TO 7:FOR M=1TO8
580READ A:BLUE%(N-1)=BLUE%(N-1)+A*(4^(
M-1))
590NEXT,
600ENDPROC
610DATA 0,2,2,0,0,2,2,0
620DATA 2,2,2,0,2,2,2,0
630DATA 2,2,2,0,2,2,2,0
640DATA 2,2,2,2,2,2,2,2
650DATA 2,2,2,2,2,2,2,2
660DATA 2,2,2,3,2,2,2,3
670DATA 2,2,2,3,2,2,2,3
680DATA 2,3,3,2,2,3,3,2
690DATA 2,3,3,3,2,3,3,3
700DATA 3,3,3,3,3,3,3,3
710DATA 1,0,0,1,1,0,0,1
720DATA 1,1,1,0,1,1,1,0
730DATA 1,1,1,1,1,1,1,1
740DATA 1,1,1,1,1,1,1,1
750DATA 1,1,1,1,1,1,1,1
760DATA 1,1,1,3,1,1,1,3
770DATA 3,1,1,3,3,1,1,3
780ENDPROC
790DEFPROCFAULT
800INPUT"NO. OF FAULTS";FAL
810 TIME=0
820FOR D=1TOFAL
830 PRINTTAB(1,1);" FAULTS=";D;" "
840 IF D=2 PRINTTAB(1,3);"PREDICTED TI
ME NEEDED=";INT(FAL*TIME/100);" SECONDS"
850 IF D>1 PRINTTAB(1,4);"TIME TAKEN="
;INT(TIME/100)
860CHANGE=(RND(60*CP)-CP*.5)
870R=RND(2)
880IF R=2 GOTO 1050
890X1=RND(C):Y1=1
900X2=RND(C):Y2=C
910IF (Y2-Y1)=0 M=1000000:GOTO 930
920M=(X2-X1)/(Y2-Y1)
930CC=(Y2-(M*X2))
940R=RND(6)
950ON R GOTO 960,1050,1080,1110,1140,1
170
960FOR X=1TOC:FOR Y=1TOC
970IF EVAL(E$)>=0 CO%(X+((Y-1)*C))=CO%
(X+((Y-1)*C))+CHANGE
980NEXT,
990NEXT
1000ENDPROC
1010FOR X=1TOC:FOR Y=1TOC
1020IF 0>=EVAL(E$) CO%(X+((Y-1)*C))=CO%
(X+((Y-1)*C))+CHANGE
1030NEXT,
1040GOTO 990
1050Y1=RND(C):X1=1
1060Y2=RND(C):X2=C
1070GOTO 910
1080Y1=RND(C):X1=1
1090Y2=C:X1=RND(C)
1100GOTO 910
1110Y1=RND(C):X1=C
1120Y2=C:X2=RND(C)
1130GOTO 910
1140Y1=RND(C):X1=C
1150Y2=1:X2=RND(C)
1160GOTO 910
1170Y1=RND(C):X1=1
1180Y2=1:X2=RND(C)
1190GOTO 910
1200DEFPROCFIND(Z1,X1,Y1,Z2,X2,Y2)
1210IF X1-X2=0 M=100000:GOTO 1230
1220M=(Z1-Z2)/(X1-X2)
1230CC=Z1-(M*X1)
1240IF M=0 X0=X1 : GOTO 1270
1250X0=(-CC+AVER)/M
1260IF Y1-Y2=0 M=100000 : GOTO 1280
1270M=(Z1-Z2)/(Y1-Y2)
1280CC=Z1-(M*Y1)
1290IF M=0 Y0=Y1 : ENDPROC
1300Y0=(-CC+AVER)/M
1310ENDPROC
1320DEFPROCWC
1330WACOL=INT((AV-LO)/WINC)
1340IF WACOL>6 WACOL=6
1350VDU 23,13:FOR EW=1TO8:VDU ((BLUE%(W
ACOL) AND 3*(4^(EW-1)))/(4^(EW-1))):NEXT
1360PROCWATERF
1370 IF L<>0 AND L<>7 GCOL 0,3:MOVE Y3,
X3:DRAW Y0,X0
1380PROCWATERS
1390 IF L<>0 AND L<>7 GCOL 0,3:MOVE Y3,
X3:DRAW Y0,X0
1400ENDPROC
1410DEFPROCWATERF
1420 L=-((CO%(UP)<AVER)+2*(CO%(LE)<AVER
)+4*(CO%(RI)<AVER))
1430 IF L=0 PROCTRI1:ENDPROC
1440 ON L GOTO 1940,1800,1660,1870,1730
,1580,1450
1450PROCTRI1
1460MOVEY,X+AVER:MOVE Y-GY,X-GX+AVER
1470GCOL32,0:PLOT 85,Y+GY,X-GX+AVER:END
PROC
1480PROCTRI2
1490MOVEY,X+AVER-GX-GX:MOVE Y-GY,X-GX+A
VER
1500GCOL32,0:PLOT 85,Y+GY,X-GX+AVER:END
PROC
1510ENDPROC
1520DEFPROCWATERS
1530 L=-((CO%(DO)<AVER)+2*(CO%(LE)<AVER
)+4*(CO%(RI)<AVER))
1540 IF L=0 PROCTRI2:ENDPROC
1550 ON L GOTO 2190,2110,2330,2030,2260
,2460,1480
1560PROCTRI2
1570ENDPROC
1580PROCFIND(CO%(UP),X,Y,CO%(RI),X-GX,Y
+GY)
1590X3=X0+AVER:Y3=Y0
1600PROCFIND(CO%(UP),X,Y,CO%(LE),X-GX,Y
-GY)
1610X0=X0+AVER
1620PROCTRI1
1630GCOL32,0:MOVE Y3,X3:MOVE Y-GY,X-GX+
AVER:PLOT 85,Y+GY,X-GX+AVER
1640MOVEY0,X0:MOVE Y3,X3:PLOT 85,Y-GY,X
-GX+AVER
1650ENDPROC
1660PROCFIND(CO%(RI),X-GX,Y+GY,CO%(UP),
X,Y)
1670X3=X0+AVER:Y3=Y0
1680PROCFIND(CO%(RI),X-GX,Y+GY,CO%(LE),
X-GX,Y-GY)
1690X0=X0+AVER
1700PROCTRI1
1710GCOL32,0:MOVE Y3,X3:MOVE Y0,X0:PLOT
85,Y-GY,X-GX+AVER:MOVE Y3,X3:PLOT 85,Y,
X+AVER
1720ENDPROC
1730PROCFIND(CO%(LE),X-GX,Y-GY,CO%(RI),
X-GX,Y+GY)
1740X3=X0+AVER:Y3=Y0
1750PROCFIND(CO%(LE),X-GX,Y-GY,CO%(UP),
X,Y)
1760X0=X0+AVER
1770PROCTRI1
1780GCOL32,0:MOVE Y0,X0:MOVE Y3,X3:PLOT
85,Y,X+AVER:PLOT 85,Y+GY,X-GX+AVER
1790ENDPROC
1800PROCFIND(CO%(LE),X-GX,Y-GY,CO%(RI),
X-GX,Y+GY)
1810X3=X0+AVER:Y3=Y0
1820PROCFIND(CO%(LE),X-GX,Y-GY,CO%(UP),
X,Y)
1830X0=X0+AVER
1840PROCTRI1
1850GCOL32,0:MOVE Y0,X0:MOVE Y3,X3:PLOT
85,Y-GY,X-GX+AVER
1860ENDPROC
1870PROCFIND(CO%(RI),X-GX,Y+GY,CO%(LE),
X-GX,Y-GY)
1880X3=X0+AVER:Y3=Y0
1890PROCFIND(CO%(RI),X-GX,Y+GY,CO%(UP),
X,Y)
1900X0=X0+AVER
1910PROCTRI1
1920GCOL32,0:MOVE Y0,X0:MOVE Y3,X3:PLOT
85,Y+GY,X-GX+AVER
1930ENDPROC
1940PROCFIND(CO%(UP),X,Y,CO%(LE),X-GX,Y
-GY)
1950X3=X0+AVER:Y3=Y0
1960PROCFIND(CO%(UP),X,Y,CO%(RI),X-GX,Y
+GY)
1970X0=X0+AVER
1980PROCTRI1
1990GCOL32,0:MOVE Y0,X0:MOVE Y3,X3:PLOT
85,Y,X+AVER
2000GCOL16,0:MOVE Y0,X0:MOVE Y3,X3:PLOT
85,Y+GY,X-GX+CO%(RI)
2010PLOT85,Y-GY,X-GX+CO%(LE)
2020ENDPROC
2030PROCFIND(CO%(RI),X-GX,Y+GY,CO%(DO),
X-GX-GX,Y)
2040X3=X0+AVER:Y3=Y0
2050PROCFIND(CO%(RI),X-GX,Y+GY,CO%(LE),
X-GX,Y-GY)
2060X0=X0+AVER
2070PROCTRI2
2080GCOL32,0:MOVE Y3,X3:MOVE Y0,X0:PLOT
85,Y+GY,X-GX+AVER
2090GCOL16,0:MOVE Y3,X3:MOVE Y0,X0:PLOT
85,Y,X-GX-GX+CO%(DO):PLOT 85,Y-GY,X-GX+
CO%(LE)
2100ENDPROC
2110PROCFIND(CO%(LE),X-GX,Y-GY,CO%(DO),
X-GX-GX,Y)
2120X3=X0+AVER:Y3=Y0
2130PROCFIND(CO%(LE),X-GX,Y-GY,CO%(RI),
X-GX,Y+GY)
2140X0=X0+AVER
2150PROCTRI2
2160GCOL32,0:MOVE Y3,X3:MOVE Y0,X0:PLOT
85,Y-GY,X-GX+AVER
2170GCOL16,0:MOVE Y3,X3:MOVE Y0,X0:PLOT
85,Y,X-GX-GX+CO%(DO):PLOT 85,Y+GY,X-GX+
CO%(RI)
2180ENDPROC
2190PROCFIND(CO%(DO),X-GX-GX,Y,CO%(LE),
X-GX,Y-GY)
2200X3=X0+AVER:Y3=Y0
2210PROCFIND(CO%(DO),X-GX-GX,Y,CO%(RI),
X-GX,Y+GY)
2220X0=X0+AVER
2230PROCTRI2
2240GCOL32,0:MOVEY3,X3:MOVEY0,X0:PLOT 8
5,Y,X-GX-GX+AVER
2250ENDPROC
2260PROCFIND(CO%(LE),X-GX,Y-GY,CO%(DO),
X-GX-GX,Y)
2270X3=X0+AVER:Y3=Y0
2280PROCFIND(CO%(LE),X-GX,Y-GY,CO%(RI),
X-GX,Y+GY)
2290X0=X0+AVER
2300PROCTRI2
2310GCOL32,0:MOVE Y,X-GX-GX+AVER:MOVE Y
3,X3:PLOT 85,Y+GY,X-GX+AVER:PLOT 85,Y0,X
0
2320ENDPROC
2330PROCFIND(CO%(RI),X-GX,Y+GY,CO%(LE),
X-GX,Y-GY)
2340X3=X0+AVER:Y3=Y0
2350PROCFIND(CO%(RI),X-GX,Y+GY,CO%(DO),
X-GX-GX,Y)
2360X0=X0+AVER
2370PROCTRI2
2380GCOL32,0:MOVE Y,X-GX-GX+AVER:MOVE Y
0,X0:PLOT 85,Y-GY,X-GX+AVER:PLOT 85,Y3,X
3
2390ENDPROC
2400DEFPROCLOCATE2(SNO)
2410ROW=((SNO-1) MOD (C-1))+1
2420SP=((SNO-1) DIV (C-1))+1
2430UP=ROW+((SP-1)*C)
2440LE=UP+1:RI=UP+C:DO=UP+C+1
2450ENDPROC
2460PROCFIND(CO%(DO),X-GX-GX,Y,CO%(LE),
X-GX,Y-GY)
2470X3=X0+AVER:Y3=Y0
2480PROCFI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 GCOL 0,3:MOVE S1+N*GY,B2-(N*GX)+CO
%(LE):DRAW S1+GY+N*GY,B2-GX-(N*GX)+CO%(R
I)
2710MOVES2-(GY*N),B2-(N*GX)+CO%(RI2):DR
AWS2-GY-(N*GY),B2-GX-(N*GX)+CO%(LE2)
2720NEXT
2730DRAW 640,B2-(C*GX)+LO2
2740 ENDPROC