|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Ads Donate Humor |
|
|
Mandelbrot escape time calculations on the H89, MBASICMicrosoft MBASIC program that calculates escape times for a 640 x 255 pixel Mandelbrot design, which you can display on a H-100 computer. The H89 cannot display the design because it has no pixel graphics capabilities. This BASIC program should be easy to convert (maybe no conversion required) to run under GWBASIC or BASICA, where it will run somewhat faster. Other (more practical) Mandelbrot program(s): |
|
10 'MBROT.BAS 11/19/93 11 'COPYRIGHT (C)1993 BY STEVEN WHITNEY. 12 'Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY. 13 'Initially published by http://25yearsofprogramming.com 20 'USES THE H89 TO CALCULATE THE ESCAPE TIMES FOR A MANDELBROT DESIGN FOR DISPLAY ON AN H100 COMPUTER. 21 'THE DIMENSIONS ARE 640 PIXELS WIDE BY 225 PIXELS HIGH. 22 'THE OUTPUT IS A .PIC FORMAT FILE. SEE THE H100 C SECTION FOR A DESCRIPTION OF THIS FILE FORMAT. 23 'WHEN I COMPILED THIS PROGRAM WITH THE MBASIC COMPILER, A SINGLE RUN OF THE MBROT.COM PROGRAM 24 'TOOK 10 DAYS TO COMPLETE! I NEVER TESTED THIS INTERPRETED VERSION, BUT IT MIGHT TAKE A MONTH OR MORE. 30 'Everything has to be double except iteration counters. 40 DEFDBL B-V,X-Z 50 DEFINT W 60 DEFSTR A 70 PRINT "This program creates data file for MBROT.EXE for the H100" 80 ' 90 'This pgm allows you to specify low and high values 100 'for both X and Y, meaning that you can select *ANY* area to plot. 110 'If area doesn't conform to proportions of H100 screen, image will 120 'be stretched or compressed in either direction to fit. 130 PRINT 140 PRINT "Output files exceed 144,000 bytes." 150 PRINT "Program overwrites existing files MANDEL.INF, MANDEL.PIC" 160 PRINT "Make sure EMPTY DISK is in drive D:" 170 PRINT 180 INPUT "LOW value for REAL axis (X)";LOWX 190 INPUT "HIGH value for REAL (X)";HIGHX 200 INPUT "LOW value for IMAGINARY (Y)";LOWY 210 INPUT "HIGH value for IMAGINARY(Y)";HIGHY 220 '-----enable 25th line, print message there 230 PRINT CHR$(27)"x1"CHR$(27)"Y"CHR$(56)CHR$(32)"Press <Q> to Quit"; 240 PRINT CHR$(27)"Y"CHR$(32)CHR$(32)CHR$(27)"E"CHR$(27)"v" 250 '-----Create info file with coordinates being plotted. 260 OPEN "O",1,"D:MANDEL.INF" 270 PRINT #1,"FOR REAL (X) FROM ";LOWX;" TO ";HIGHX 280 PRINT #1,"FOR IMAG.(Y) FROM ";LOWY;" TO ";HIGHY 290 CLOSE #1 300 '----- 310 OPEN "O",1,"D:MANDEL.PIC" 320 DX = (HIGHX-LOWX)/639# 330 DY = (HIGHY-LOWY)/224# 340 '-----value of i is the imaginary part of (c) being worked on 350 '-----value of j is the real part of (c) being worked on 355 WLINE = 0 360 I = HIGHY 370 WHILE I > LOWY 374 WLINE = WLINE + 1 375 PRINT "Starting line ";WLINE;" of 225." 380 J = LOWX 390 WHILE J < HIGHX 400 '-----this is mbrot.c's iterate() 410 ZREAL = 0# : ZIMAG = 0# 420 WITERATIONS = 1 430 '-----wtest is just a way of getting out of the loop 440 '-----any other way produces a while/wend error 450 WTEST = 1 460 WHILE WTEST 470 '-----old value needed after new is calculated 480 TEMPZREAL = ZREAL 490 ZREAL = (TEMPZREAL * TEMPZREAL) - (ZIMAG * ZIMAG) + J 500 '-----eliminated unnecessary computations 510 '-----get out of loop just as soon as we know we should 520 IF ABS(ZREAL) > 2# THEN WTEST = 0 : GOTO 570 530 ZIMAG = 2# * TEMPZREAL * ZIMAG + I 540 IF ABS(ZIMAG) > 2# THEN WTEST = 0 : GOTO 570 550 WITERATIONS = WITERATIONS + 1 560 IF WITERATIONS = 255 THEN WTEST = 0 570 WEND 580 PRINT WITERATIONS; 590 PRINT #1,CHR$(WITERATIONS); 600 J = J + DX 610 WEND 620 '-----allow user abort, but only check at end of each row of 640 630 '-----must keep this exit in, else big chunk of file gets lost on abort 640 A$ = INKEY$ 650 IF (A$ = "Q") THEN CLOSE #1 : PRINT CHR$(27)"z": END 660 I = I - DY 670 WEND 680 CLOSE #1 690 PRINT CHR$(27)"z" : REM TERMINAL RESET TO DEFAULT MODES 700 END
|
|
|
|
|
|