corrupt! but it produces pixels
This commit is contained in:
parent
b4721ae46b
commit
ae9dd0674d
1 changed files with 27 additions and 37 deletions
64
mandel.s
64
mandel.s
|
@ -168,7 +168,7 @@ color_map:
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro add32 dest, arg1, arg2
|
.macro add32 dest, arg1, arg2
|
||||||
add 2, dest, arg2, dest
|
add 4, dest, arg2, dest
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
; 2 + 9 * byte cycles
|
; 2 + 9 * byte cycles
|
||||||
|
@ -422,6 +422,13 @@ next:
|
||||||
|
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
.macro shift_round_16 arg, shift
|
||||||
|
.repeat shift
|
||||||
|
shl32 arg
|
||||||
|
.endrepeat
|
||||||
|
round16 arg
|
||||||
|
.endmacro
|
||||||
|
|
||||||
.proc mandelbrot
|
.proc mandelbrot
|
||||||
; input:
|
; input:
|
||||||
; cx: position scaled to 4.12 fixed point - -8..+7.9
|
; cx: position scaled to 4.12 fixed point - -8..+7.9
|
||||||
|
@ -445,64 +452,48 @@ initloop:
|
||||||
bne initloop
|
bne initloop
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
; 1939 - 3007 cyc
|
; iter++ & max-iters break
|
||||||
|
inc iter
|
||||||
; iter++ & max-iters break = 7 cyc
|
bne keep_going
|
||||||
inc iter ; 5 cyc
|
|
||||||
bne keep_going ; 2 cyc
|
|
||||||
rts
|
rts
|
||||||
keep_going:
|
keep_going:
|
||||||
|
|
||||||
; 4.12: (-8 .. +7.9)
|
; 4.12: (-8 .. +7.9)
|
||||||
; zx = zx_2 - zy_2 + cx = 3 * 20 = 60 cyc
|
; zx = zx_2 - zy_2 + cx
|
||||||
sub16 zx, zx_2, zy_2
|
sub16 zx, zx_2 + 2, zy_2 + 2
|
||||||
add16 zx, zx, cx
|
add16 zx, zx, cx
|
||||||
|
|
||||||
; zy = zx_zy + zx_zy + cy = 3 * 20 = 60 cyc
|
; zy = zx_zy + zx_zy + cy
|
||||||
sub16 zy, zx_zy, zx_zy
|
add16 zy, zx_zy + 2, zx_zy + 2
|
||||||
add16 zy, zy, cy
|
add16 zy, zy, cy
|
||||||
|
|
||||||
; 8.24: (-128 .. +127.9)
|
; 8.24: (-128 .. +127.9)
|
||||||
; zx_2 = zx * zx = 518 - 828 cyc
|
; zx_2 = zx * zx
|
||||||
imul16 zx_2, zx, zx
|
imul16 zx_2, zx, zx
|
||||||
|
|
||||||
; zy_2 = zy * zy = 518 - 828 cyc
|
; zy_2 = zy * zy
|
||||||
imul16 zy_2, zy, zy
|
imul16 zy_2, zy, zy
|
||||||
|
|
||||||
; zx_zy = zx * zy = 518 - 828 cyc
|
; zx_zy = zx * zy
|
||||||
imul16 zx_zy, zx, zy
|
imul16 zx_zy, zx, zy
|
||||||
|
|
||||||
; dist = zx_2 + zy_2 = 38 cyc
|
; dist = zx_2 + zy_2
|
||||||
add32 dist, zx_2, zy_2
|
add32 dist, zx_2, zy_2
|
||||||
|
|
||||||
; if dist >= 4 break, else continue iterating = 7 cyc
|
; if dist >= 4 break, else continue iterating
|
||||||
lda dist + 3 ; 3 cyc
|
lda dist + 3
|
||||||
cmp #4 ; 2 cyc
|
cmp #4
|
||||||
bmi still_in ; 2 cyc
|
bmi still_in
|
||||||
rts
|
rts
|
||||||
still_in:
|
still_in:
|
||||||
|
|
||||||
; shift and round zx_2 to 4.12 = (60 + 5) - (60 + 28) = 65 - 88 cyc
|
shift_round_16 zx_2, 4
|
||||||
.repeat 4 ; 60 cyc
|
shift_round_16 zy_2, 4
|
||||||
shl24 zx_2 ; 15 cyc
|
shift_round_16 zx_zy, 4
|
||||||
.endrepeat
|
|
||||||
round16 zx_2 ; 5-28 cycles
|
|
||||||
|
|
||||||
; shift and round zy_2 to 4.12 = (20 + 5) - (20 + 28) = 65 - 88 cyc
|
|
||||||
.repeat 4 ; 60 cyc
|
|
||||||
shl24 zy_2 ; 15 cyc
|
|
||||||
.endrepeat
|
|
||||||
round16 zy_2 ; 5-28 cycles
|
|
||||||
|
|
||||||
; shift and round zx_zy to 4.12 = (20 + 5) - (20 + 28) = 65 - 88 cyc
|
|
||||||
.repeat 4 ; 60 cyc
|
|
||||||
shl24 zx_zy ; 15 cyc
|
|
||||||
.endrepeat
|
|
||||||
round16 zx_zy ; 5-28 cycles
|
|
||||||
|
|
||||||
; if may be in the lake, look for looping output with a small buffer
|
; if may be in the lake, look for looping output with a small buffer
|
||||||
; as an optimization vs running to max iters
|
; as an optimization vs running to max iters
|
||||||
jmp loop ; 3 cycles
|
jmp loop
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
@ -708,7 +699,6 @@ loop_sx:
|
||||||
zoom_factor cx, sx, zoom, aspect_x
|
zoom_factor cx, sx, zoom, aspect_x
|
||||||
zoom_factor cy, sy, zoom, aspect_y
|
zoom_factor cy, sy, zoom, aspect_y
|
||||||
jsr mandelbrot
|
jsr mandelbrot
|
||||||
inc iter
|
|
||||||
jsr pset
|
jsr pset
|
||||||
|
|
||||||
clc
|
clc
|
||||||
|
|
Loading…
Reference in a new issue