about summary refs log tree commit diff stats
path: root/409float.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-04 21:07:27 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-04 21:15:28 -0700
commit5c105a7acaae4a295716a6da68ae73b4378ad1cd (patch)
treefe3aee778d67d802cbaea1843641e03049490799 /409float.mu
parentf5e1656d15325b37c91ee110215e9a032e6cc1ce (diff)
downloadmu-5c105a7acaae4a295716a6da68ae73b4378ad1cd.tar.gz
6949 - snapshot of next raytracing milestone
Not yet right, but worth a snapshot just because it gives a cool result.
Here, try it out:
  $ ./translate_mu_debug apps/raytracing/3.mu
  $ ./a.elf > x.ppm
Now view x.ppm as an image.

In general, this was quite tedious to write. And a still-open question
is how to emit the progress bar to stderr. My options are to either duplicate
all my print-* functions (already proliferating) or add global variables
to Mu.
Diffstat (limited to '409float.mu')
-rw-r--r--409float.mu16
1 files changed, 16 insertions, 0 deletions
diff --git a/409float.mu b/409float.mu
new file mode 100644
index 00000000..ad94a8d3
--- /dev/null
+++ b/409float.mu
@@ -0,0 +1,16 @@
+# Some quick-n-dirty ways to create floats.
+
+fn fill-in-rational _out: (addr float), nr: int, dr: int {
+  var out/edi: (addr float) <- copy _out
+  var result/xmm0: float <- convert nr
+  var divisor/xmm1: float <- convert dr
+  result <- divide divisor
+  copy-to *out, result
+}
+
+fn fill-in-sqrt _out: (addr float), n: int {
+  var out/edi: (addr float) <- copy _out
+  var result/xmm0: float <- convert n
+  result <- square-root result
+  copy-to *out, result
+}