2018-09-18 21:14:32 +00:00
|
|
|
%option enable_floats
|
|
|
|
|
|
|
|
~ main {
|
|
|
|
|
2018-09-30 16:49:58 +00:00
|
|
|
sub start() {
|
2018-09-18 21:14:32 +00:00
|
|
|
|
2018-09-23 00:42:42 +00:00
|
|
|
const word width = 320 // 2
|
|
|
|
const word height = 256 // 2
|
|
|
|
const word xoffset = 40
|
2018-10-02 23:11:28 +00:00
|
|
|
const word yoffset = 30
|
2018-09-18 21:14:32 +00:00
|
|
|
word pixelx
|
|
|
|
byte pixely
|
|
|
|
float xx
|
|
|
|
float yy
|
|
|
|
float x
|
|
|
|
float y
|
2018-09-26 23:35:35 +00:00
|
|
|
float xsquared
|
|
|
|
float ysquared
|
2018-09-18 21:14:32 +00:00
|
|
|
byte iter
|
|
|
|
word plotx
|
|
|
|
byte ploty
|
|
|
|
|
|
|
|
_vm_gfx_clearscr(11)
|
2018-10-02 23:11:28 +00:00
|
|
|
_vm_gfx_text(2, 1, 7, "Calculating Mandelbrot Fractal...")
|
2018-09-18 21:14:32 +00:00
|
|
|
|
2018-09-23 00:42:42 +00:00
|
|
|
for pixely in yoffset to yoffset+height-1 {
|
2018-09-26 23:35:35 +00:00
|
|
|
yy = flt((pixely-yoffset))/height/3.6+0.4
|
2018-09-23 00:42:42 +00:00
|
|
|
|
|
|
|
for pixelx in xoffset to xoffset+width-1 {
|
2018-09-26 23:35:35 +00:00
|
|
|
xx = flt((pixelx-xoffset))/width/3+0.2
|
2018-09-18 21:14:32 +00:00
|
|
|
|
2018-09-19 23:13:21 +00:00
|
|
|
x = 0.0
|
|
|
|
y = 0.0
|
2018-09-26 23:35:35 +00:00
|
|
|
xsquared = 0
|
|
|
|
ysquared = 0
|
2018-09-23 00:42:42 +00:00
|
|
|
iter = 0
|
2018-09-26 23:35:35 +00:00
|
|
|
while (iter<32 and xsquared+ysquared<4) {
|
2018-09-19 23:13:21 +00:00
|
|
|
y = x*y*2 + yy
|
2018-09-26 23:35:35 +00:00
|
|
|
x = xsquared - ysquared + xx
|
|
|
|
xsquared = x*x
|
|
|
|
ysquared = y*y
|
2018-09-23 00:42:42 +00:00
|
|
|
iter++
|
2018-09-18 21:14:32 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 23:13:21 +00:00
|
|
|
_vm_gfx_pixel(pixelx, pixely, iter)
|
2018-09-18 21:14:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-02 23:11:28 +00:00
|
|
|
_vm_gfx_text(11, 21, 7, "Finished!")
|
2018-09-18 21:14:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-09-28 19:28:16 +00:00
|
|
|
|
|
|
|
|
2018-10-02 23:11:28 +00:00
|
|
|
; ---- some weird testing 60hz irq handling routine------
|
2018-09-28 19:28:16 +00:00
|
|
|
|
|
|
|
~ irq {
|
|
|
|
|
|
|
|
memory byte jiffyclockHi = $a0
|
|
|
|
memory byte jiffyclockMid = $a1
|
|
|
|
memory byte jiffyclockLo = $a2
|
|
|
|
|
2018-09-30 16:49:58 +00:00
|
|
|
sub irq() {
|
2018-09-28 19:28:16 +00:00
|
|
|
_vm_gfx_pixel(jiffyclockLo,190,jiffyclockHi)
|
|
|
|
_vm_gfx_pixel(jiffyclockLo,191,jiffyclockMid)
|
|
|
|
_vm_gfx_pixel(jiffyclockLo,192,jiffyclockLo)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|