gfoot wrote:
The real problem however is with the bounds check on lines 230-240:
Code:
230A%=T%: P%=A%/F%:Q%=B%/F%
240IF ((P%*P%)+(Q%*Q%))>=5 GOTO 280
P% and Q% suffer badly from rounding here, as you're dividing by the fixed point factor. You can use floating point for P and Q, or better, do the comparison in the fixed point space:
Code:
230A%=T%
240IF ((A%*A% DIV F%)+(B%*B% DIV F%))>=5*F% GOTO 280
This may suffer different problems if it ends up overflowing the maximum integer width - 16 bits is pretty narrow - I haven't thought much about what the worst-case inputs would be though!
WOZ BASIC errored out almost immediately with your modification, but was able to render a less accurate version of Gordon's original in about 696 seconds @ 1 MHz:
Code:
100 REM PR#3 FROM > PROMPT FIRST!
105 PRINT "MANDELBROT - WOZ BASIC"
110 PRINT "START"
130 DIM Z$(17):Z$=".:,;-=+^/%&S$X#@ "
140 F=50
150 FOR Y=-12 TO 12
160 FOR X=-49 TO 29
170 C=X*229/100
180 D=Y*416/100
190 A=C:B=D:I=1
200 Q=B/F:S=B-Q*F
210 T=(A*A-B*B)/F+C
220 B=2*(A*Q+A*S/F)+D
230 A=T:P=A/F:Q=B/F
240 IF P*P+Q*Q>4 THEN 280
250 I=I+1: IF I<17 THEN 200
280 PRINT Z$(I,I);: NEXT X
300 PRINT : NEXT Y
330 PRINT "FINISHED";
350 END
Attachment:
MAND_WOZ.PNG [ 6.59 KiB | Viewed 4216 times ]
Applesoft renders a much better image, but takes about 860 seconds @ 1 MHz:
Code:
100 REM PR#3 FROM ] PROMPT FIRST!
105 PRINT "MANDELBROT - APPLESOFT"
110 PRINT "START"
130 Z$ = ".:,;-=+^/%&S$X#@ "
140 F = 50
150 FOR Y = - 12 TO 12
160 FOR X = - 49 TO 29
170 C = X * 229 / 100
180 D = Y * 416 / 100
190 A = C:B = D:I = 1
200 Q = B / F:S = B - Q * F
210 T = (A * A - B * B) / F + C
220 B = 2 * (A * Q + A * S / F) + D
230 A = T:P = A / F:Q = B / F
240 IF P * P + Q * Q > 4 THEN 280
250 I = I + 1: IF I < 17 THEN 200
280 PRINT MID$ (Z$,I,1);: NEXT X
300 PRINT : NEXT Y
330 PRINT "FINISHED";
350 END
Attachment:
MAND_A2+.PNG [ 6.6 KiB | Viewed 4213 times ]
_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some
VTL02C on it and see how it grows on you!
Mike B.
(about me) (learning how to github)