2020-09-20 21:49:36 +00:00
|
|
|
%import textio
|
|
|
|
%import floats
|
2020-08-29 21:55:26 +00:00
|
|
|
%zeropage basicsafe
|
|
|
|
|
|
|
|
main {
|
|
|
|
const uword width = 256
|
2022-03-28 20:28:39 +00:00
|
|
|
const uword height = 240
|
2020-08-31 21:00:53 +00:00
|
|
|
const ubyte max_iter = 16 ; 32 actually looks pretty nice but takes longer
|
2020-08-29 21:55:26 +00:00
|
|
|
|
|
|
|
sub start() {
|
2020-08-30 17:31:20 +00:00
|
|
|
initialize()
|
|
|
|
mandel()
|
|
|
|
repeat {
|
|
|
|
; do nothing
|
|
|
|
}
|
|
|
|
}
|
2020-08-29 21:55:26 +00:00
|
|
|
|
2020-08-30 17:31:20 +00:00
|
|
|
sub mandel() {
|
2022-03-28 20:28:39 +00:00
|
|
|
const float XL=-2.200
|
|
|
|
const float XU=0.800
|
|
|
|
const float YL=-1.300
|
|
|
|
const float YU=1.300
|
2023-03-20 21:41:58 +00:00
|
|
|
const float dx = (XU-XL)/width
|
|
|
|
const float dy = (YU-YL)/height
|
2020-08-29 21:55:26 +00:00
|
|
|
ubyte pixelx
|
|
|
|
ubyte pixely
|
|
|
|
|
|
|
|
for pixely in 0 to height-1 {
|
2020-08-30 22:36:40 +00:00
|
|
|
float yy = YL+dy*(pixely as float)
|
2020-08-29 21:55:26 +00:00
|
|
|
|
2020-12-21 19:38:00 +00:00
|
|
|
cx16.FB_cursor_position(0, pixely)
|
2020-08-29 21:55:26 +00:00
|
|
|
|
|
|
|
for pixelx in 0 to width-1 {
|
2020-08-30 22:36:40 +00:00
|
|
|
float xx = XL+dx*(pixelx as float)
|
2020-08-29 21:55:26 +00:00
|
|
|
|
|
|
|
float xsquared = 0.0
|
|
|
|
float ysquared = 0.0
|
|
|
|
float x = 0.0
|
|
|
|
float y = 0.0
|
|
|
|
ubyte iter = 0
|
|
|
|
|
|
|
|
while iter<max_iter and xsquared+ysquared<4.0 {
|
|
|
|
y = x*y*2.0 + yy
|
|
|
|
x = xsquared - ysquared + xx
|
|
|
|
xsquared = x*x
|
|
|
|
ysquared = y*y
|
|
|
|
iter++
|
|
|
|
}
|
|
|
|
cx16.FB_set_pixel(max_iter-iter)
|
|
|
|
}
|
2020-08-30 17:31:20 +00:00
|
|
|
|
|
|
|
print_time()
|
2020-08-29 21:55:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-30 17:31:20 +00:00
|
|
|
|
|
|
|
sub initialize() {
|
2022-03-31 16:17:28 +00:00
|
|
|
void cx16.screen_mode($80, false)
|
2020-08-30 17:31:20 +00:00
|
|
|
|
|
|
|
txt.plot(32, 5)
|
2022-03-28 20:28:39 +00:00
|
|
|
txt.print("256*240")
|
2020-08-30 17:31:20 +00:00
|
|
|
txt.plot(32, 6)
|
|
|
|
txt.print("mandel-")
|
|
|
|
txt.plot(33, 7)
|
|
|
|
txt.print("brot")
|
|
|
|
txt.plot(32, 9)
|
|
|
|
txt.print("floats")
|
|
|
|
txt.plot(32, 10)
|
2020-08-30 21:50:31 +00:00
|
|
|
txt.print_b(max_iter)
|
|
|
|
txt.print(" iter")
|
2020-08-30 17:31:20 +00:00
|
|
|
|
2020-12-21 19:38:00 +00:00
|
|
|
cx16.clock_set_date_time(0, 0, 0, 0)
|
2020-08-30 17:31:20 +00:00
|
|
|
|
|
|
|
cx16.r0=0
|
|
|
|
cx16.FB_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
sub print_time() {
|
2020-12-21 19:38:00 +00:00
|
|
|
void cx16.clock_get_date_time()
|
2020-08-30 17:31:20 +00:00
|
|
|
txt.plot(33, 12)
|
|
|
|
if lsb(cx16.r2) < 10
|
2023-04-28 21:13:03 +00:00
|
|
|
txt.chrout('0')
|
2020-08-30 17:31:20 +00:00
|
|
|
txt.print_ub(lsb(cx16.r2))
|
2023-04-28 21:13:03 +00:00
|
|
|
txt.chrout(':')
|
2020-08-30 17:31:20 +00:00
|
|
|
if msb(cx16.r2) < 10
|
2023-04-28 21:13:03 +00:00
|
|
|
txt.chrout('0')
|
2020-08-30 17:31:20 +00:00
|
|
|
txt.print_ub(msb(cx16.r2))
|
|
|
|
}
|
2020-08-29 21:55:26 +00:00
|
|
|
}
|