forked from MightyPork/crsn
update examples to use the new const eval syntax
This commit is contained in:
+12
-13
@@ -10,23 +10,22 @@
|
|||||||
|
|
||||||
(def GENERATION_MS 200)
|
(def GENERATION_MS 200)
|
||||||
|
|
||||||
; Real pixel size
|
; Number of pixels
|
||||||
(sc-init 400 400)
|
|
||||||
; Upscaling factor (bug pixels)
|
|
||||||
(sc-opt SCREEN_UPSCALE 10)
|
|
||||||
|
|
||||||
; Number of big pixels
|
|
||||||
(def W 40)
|
(def W 40)
|
||||||
(def H 40)
|
(def H 40)
|
||||||
|
(def UPSCALE 10)
|
||||||
; !!! If you change size, also update the following constants.
|
|
||||||
; Compile-time math is not implemented yet.
|
|
||||||
|
|
||||||
(def XMAX 39) ; W-1
|
|
||||||
(def YMAX 39) ; H-1
|
|
||||||
(def NCELLS 1600) ; W*H
|
|
||||||
|
|
||||||
; --- end of config ---
|
; --- end of config ---
|
||||||
|
|
||||||
|
; Real pixel size
|
||||||
|
(sc-init (=mul UPSCALE W) (=mul UPSCALE H))
|
||||||
|
; Upscaling factor (bug pixels)
|
||||||
|
(sc-opt SCREEN_UPSCALE UPSCALE)
|
||||||
|
|
||||||
|
(def XMAX (=sub W 1))
|
||||||
|
(def YMAX (=sub H 1))
|
||||||
|
(def NCELLS (=mul W H))
|
||||||
|
|
||||||
(sc-opt SCREEN_AUTO_BLIT 0)
|
(sc-opt SCREEN_AUTO_BLIT 0)
|
||||||
|
|
||||||
(sc-erase 0) ; all black
|
(sc-erase 0) ; all black
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
(
|
(
|
||||||
(sc-init 800 600)
|
; High resolution mandelbrot
|
||||||
(sc-opt SCREEN_AUTOBLIT 0)
|
|
||||||
(def W 800)
|
(def W 800)
|
||||||
(def H 600)
|
(def H 600)
|
||||||
(def MAXITER 50)
|
(def MAXITER 50) ; Increase for more detail but slower render
|
||||||
|
|
||||||
|
(sc-init W H)
|
||||||
|
(sc-opt SCREEN_AUTOBLIT 0)
|
||||||
|
|
||||||
(sym gradient r9)
|
(sym gradient r9)
|
||||||
(sym asciigr r10)
|
(sym asciigr r10)
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
(
|
(
|
||||||
(sc-init 1024 768)
|
|
||||||
(sc-opt SCREEN_AUTOBLIT 0)
|
|
||||||
(def W 1024)
|
(def W 1024)
|
||||||
(def H 768)
|
(def H 768)
|
||||||
(sym MAXITER g0)
|
(def DEF_MAXITER 50)
|
||||||
(ld MAXITER 50)
|
|
||||||
|
; ---
|
||||||
|
|
||||||
|
(sc-init W H)
|
||||||
|
(sc-opt SCREEN_AUTOBLIT 0)
|
||||||
|
(sym maxiter g0)
|
||||||
|
|
||||||
|
(ld maxiter DEF_MAXITER)
|
||||||
|
|
||||||
(lds @cout "Interactive Mandelbrot\n")
|
(lds @cout "Interactive Mandelbrot\n")
|
||||||
(lds @cout "----------------------\n")
|
(lds @cout "----------------------\n")
|
||||||
@@ -86,7 +91,7 @@
|
|||||||
(ld x col)
|
(ld x col)
|
||||||
(:col)
|
(:col)
|
||||||
(call pixel x y px py scale)
|
(call pixel x y px py scale)
|
||||||
(sub r0 MAXITER 1)
|
(sub r0 maxiter 1)
|
||||||
(rcmp res0 1 r0
|
(rcmp res0 1 r0
|
||||||
(eq?
|
(eq?
|
||||||
(mod r0 res0 16)
|
(mod r0 res0 16)
|
||||||
@@ -166,16 +171,16 @@
|
|||||||
|
|
||||||
; R iter+
|
; R iter+
|
||||||
(sc-key r0 KEY_R (nz?
|
(sc-key r0 KEY_R (nz?
|
||||||
(add MAXITER 50)
|
(add maxiter 50)
|
||||||
(lds @cout "ITER=") (call printnum MAXITER) (ld @cout '\n')
|
(lds @cout "ITER=") (call printnum maxiter) (ld @cout '\n')
|
||||||
(mslp 200) ; Avoid unexpected rapid change
|
(mslp 200) ; Avoid unexpected rapid change
|
||||||
))
|
))
|
||||||
|
|
||||||
; F iter-
|
; F iter-
|
||||||
(sc-key r0 KEY_F (nz?
|
(sc-key r0 KEY_F (nz?
|
||||||
(cmp MAXITER 50)
|
(cmp maxiter 50)
|
||||||
(sub.gt MAXITER 50)
|
(sub.gt maxiter 50)
|
||||||
(lds @cout "ITER=") (call printnum MAXITER) (ld @cout '\n')
|
(lds @cout "ITER=") (call printnum maxiter) (ld @cout '\n')
|
||||||
(mslp 200) ; Avoid unexpected rapid change
|
(mslp 200) ; Avoid unexpected rapid change
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -258,7 +263,7 @@
|
|||||||
(sym iter r4)
|
(sym iter r4)
|
||||||
|
|
||||||
(:iter)
|
(:iter)
|
||||||
(cmp iter MAXITER)
|
(cmp iter maxiter)
|
||||||
(j.eq :end)
|
(j.eq :end)
|
||||||
(fmul r0 x x)
|
(fmul r0 x x)
|
||||||
(fmul r1 y y)
|
(fmul r1 y y)
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
(
|
(
|
||||||
(sc-init 1024 768)
|
(def PX_W 1024)
|
||||||
(sc-opt SCREEN_AUTOBLIT 0)
|
(def PX_H 768)
|
||||||
(sc-opt SCREEN_UPSCALE 8)
|
(def UPSCALE 8)
|
||||||
(def W 128)
|
|
||||||
(def H 96)
|
|
||||||
(def MAXITER 50)
|
(def MAXITER 50)
|
||||||
|
|
||||||
|
(sc-init PX_W PX_H)
|
||||||
|
(sc-opt SCREEN_AUTOBLIT 0)
|
||||||
|
(sc-opt SCREEN_UPSCALE UPSCALE)
|
||||||
|
(def W (=div PX_W UPSCALE))
|
||||||
|
(def H (=div PX_H UPSCALE))
|
||||||
|
|
||||||
(sym gradient r9)
|
(sym gradient r9)
|
||||||
(sym asciigr r10)
|
(sym asciigr r10)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user