aboutsummaryrefslogtreecommitdiff
path: root/docs/history/15-o3/code/examples/mandel.zc
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:09:21 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:09:21 +0330
commitdc7f7407e08f54e4a2a3c1d1723b2a7d6959532d (patch)
treed1de9f471a99951c57896f85b5e5523eeb96cee1 /docs/history/15-o3/code/examples/mandel.zc
parenttodo: sync docs, examples and fixtures with the include format, and test acto... (diff)
docs: archive the frozen stage code as one compressed tarball
docs/history kept six stages with a full copy of the project under code/, 3.8 mb of sources duplicated from stage to stage and already superseded. store them as docs/history/code-snapshots.tar.gz, 0.66 mb, and extract one in place to read it. every stage's notes.md stays browsable, and the index says where the code went and how to get it back. the top-level README points at the archive too. its other two links into docs/history, 21-micro and 35-bench, were notes that were never kept and do not resolve; the index now records that.
Diffstat (limited to 'docs/history/15-o3/code/examples/mandel.zc')
-rw-r--r--docs/history/15-o3/code/examples/mandel.zc36
1 files changed, 0 insertions, 36 deletions
diff --git a/docs/history/15-o3/code/examples/mandel.zc b/docs/history/15-o3/code/examples/mandel.zc
deleted file mode 100644
index 5810397..0000000
--- a/docs/history/15-o3/code/examples/mandel.zc
+++ /dev/null
@@ -1,36 +0,0 @@
-// the mandelbrot set in 16.16 fixed point. the cpu has no fixed-point
-// multiply, so one gets wired in: a 32x32 -> 64 bit multiply, keeping the
-// middle 32 bits. the jit inlines it as two native multiplies and a shift.
-enhance fmul(a, b) micro
- "r2 = mul a b; r3 = mulhs a b"
- "; r3 = shl r3 16; r2 = shr r2 16; a = or r3 r2";
-
-const ONE = 65536, W = 72, H = 28, MAXIT = 40;
-let shades = " .,:;-=+*%#@";
-
-int escape(int cx, int cy) {
- int x = 0, y = 0, i = 0;
- while (i < MAXIT) {
- int xx = fmul(x, x), yy = fmul(y, y);
- if (xx + yy > 4 * ONE) return i;
- y = 2 * fmul(x, y) + cy;
- x = xx - yy + cx;
- i++;
- }
- return MAXIT;
-}
-fn main()
-{
- int row = 0;
- while (row < H) {
- int col = 0, cy = (row * 2400 / (H - 1) - 1200) * ONE / 1000;
- while (col < W) {
- int cx = (col * 3200 / (W - 1) - 2200) * ONE / 1000, it = escape(cx, cy);
- putc(it == MAXIT ? '@' : shades[it * 11 / MAXIT]);
- col++;
- }
- putc(10);
- row++;
- }
- return 0;
-}