mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +00:00
tweak cx16 mandelbrots
This commit is contained in:
parent
e61818f194
commit
364ef3e55c
@ -30,7 +30,8 @@ asmsub fill_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
|
||||
bne +
|
||||
lda #147 ; clear screen
|
||||
jmp c64.CHROUT
|
||||
+ brk ; TODO fill screen with another character than space....
|
||||
+ ; TODO fill the screen with a different fillchar (not space) - not yet supported
|
||||
rts
|
||||
}}
|
||||
|
||||
}
|
||||
@ -118,9 +119,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) {
|
||||
jsr c64.CHROUT
|
||||
+ pla
|
||||
jsr conv.byte2decimal
|
||||
jsr print_ub._print_byte_digits
|
||||
plx
|
||||
rts
|
||||
jmp print_ub._print_byte_digits
|
||||
}}
|
||||
}
|
||||
|
||||
|
31
examples/cx16/mandelbrot-gfx.bas
Normal file
31
examples/cx16/mandelbrot-gfx.bas
Normal file
@ -0,0 +1,31 @@
|
||||
100 REM MANDELBROT GFX - BASIC VERSION FOR COMMANDERX16
|
||||
110 REM MANDELBROT COORDINATES
|
||||
120 XL=-2.000:XU=0.500
|
||||
130 YL=-1.100:YU=1.100
|
||||
140 MI%=16 :REM MAXIMUM ITERATIONS
|
||||
150 WI%=256:HI%=200 :REM SCREEN DIMENSIONS
|
||||
160 DX=(XU-XL)/WI%
|
||||
170 DY=(YU-YL)/HI%
|
||||
200 SCREEN $80:TI$="000000"
|
||||
500 REM MAIN LOOP
|
||||
520 X0=0:Y0=0:GOSUB2000
|
||||
530 FOR YY=0 TO HI%-1
|
||||
540 Y0=YL+DY*YY
|
||||
610 FOR XX=0 TO WI%-1
|
||||
620 X0=XL+DX*XX
|
||||
700 REM CALCULATE MANDELBROT
|
||||
710 X=0:Y=0:IT%=0
|
||||
720 X2=0:Y2=0
|
||||
730 XY=X*Y
|
||||
740 X=X2-Y2+X0
|
||||
750 Y=2*XY+Y0
|
||||
760 IT%=IT%+1
|
||||
770 X2=X*X:Y2=Y*Y
|
||||
780 IF (X2+Y2 <= 4) AND (IT% < MI%) THEN GOTO 730
|
||||
790 PSET XX,YY,MI%-IT%
|
||||
800 NEXT XX
|
||||
810 GOSUB2000
|
||||
820 NEXT YY
|
||||
1000 GOTO 1000
|
||||
2000 REM OUTPUT TIME SPENT
|
||||
2010 PRINT CHR$(19)SPC(33)TI$:RETURN
|
@ -5,7 +5,7 @@
|
||||
main {
|
||||
const uword width = 256
|
||||
const uword height = 200
|
||||
const ubyte max_iter = 32
|
||||
const ubyte max_iter = 16 ; 32 looks pretty nice
|
||||
|
||||
sub start() {
|
||||
initialize()
|
||||
@ -16,18 +16,24 @@ main {
|
||||
}
|
||||
|
||||
sub mandel() {
|
||||
const float XL=-2.000
|
||||
const float XU=0.500
|
||||
const float YL=-1.100
|
||||
const float YU=1.100
|
||||
float dx = (XU-XL)/width
|
||||
float dy = (YU-YL)/height
|
||||
ubyte pixelx
|
||||
ubyte pixely
|
||||
|
||||
for pixely in 0 to height-1 {
|
||||
float yy = (pixely as float)/0.35/height - 1.35
|
||||
float yy = YL+dy*pixely
|
||||
|
||||
cx16.r0 = 0
|
||||
cx16.r1 = pixely
|
||||
cx16.FB_cursor_position()
|
||||
|
||||
for pixelx in 0 to width-1 {
|
||||
float xx = (pixelx as float)/0.3/width - 2.2
|
||||
float xx = XL+dx*pixelx
|
||||
|
||||
float xsquared = 0.0
|
||||
float ysquared = 0.0
|
||||
@ -61,7 +67,8 @@ main {
|
||||
txt.plot(32, 9)
|
||||
txt.print("floats")
|
||||
txt.plot(32, 10)
|
||||
txt.print("32 iter")
|
||||
txt.print_b(max_iter)
|
||||
txt.print(" iter")
|
||||
|
||||
cx16.r0 = 0
|
||||
cx16.r1 = 0
|
||||
|
Loading…
Reference in New Issue
Block a user