about summary refs log tree commit diff stats
path: root/apps/raytracing/vec.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-03-03 22:09:50 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-03-03 22:21:03 -0800
commit71e4f3812982dba2efb471283d310224e8db363e (patch)
treeea111a1acb8b8845dbda39c0e1b4bac1d198143b /apps/raytracing/vec.mu
parentc6b928be29ac8cdb4e4d6e1eaa20420ff03e5a4c (diff)
downloadmu-71e4f3812982dba2efb471283d310224e8db363e.tar.gz
7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.

So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.

A couple of things have gotten dropped in this process:
  - I had old ways to run on just a Linux kernel, or with a Soso kernel.
    No more.
  - I had some old tooling for running a single test at the cursor. I haven't
    used that lately. Maybe I'll bring it back one day.

The reorg isn't done yet. Still to do:
  - redo documentation everywhere. All the README files, all other markdown,
    particularly vocabulary.md.
  - clean up how-to-run comments at the start of programs everywhere
  - rethink what to do with the html/ directory. Do we even want to keep
    supporting it?

In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
Diffstat (limited to 'apps/raytracing/vec.mu')
-rw-r--r--apps/raytracing/vec.mu135
1 files changed, 0 insertions, 135 deletions
diff --git a/apps/raytracing/vec.mu b/apps/raytracing/vec.mu
deleted file mode 100644
index 7caf7e88..00000000
--- a/apps/raytracing/vec.mu
+++ /dev/null
@@ -1,135 +0,0 @@
-type vec3 {
-  x: float
-  y: float
-  z: float
-}
-
-fn print-vec3 screen: (addr screen), _v: (addr vec3) {
-  var v/esi: (addr vec3) <- copy _v
-  print-string screen, "("
-  var tmp/eax: (addr float) <- get v, x
-  print-float-hex screen, *tmp
-  print-string screen, ", "
-  tmp <- get v, y
-  print-float-hex screen, *tmp
-  print-string screen, ", "
-  tmp <- get v, z
-  print-float-hex screen, *tmp
-  print-string screen, ")"
-}
-
-fn vec3-add-to _v1: (addr vec3), _v2: (addr vec3) {
-  var v1/edi: (addr vec3) <- copy _v1
-  var v2/esi: (addr vec3) <- copy _v2
-  # v1.x += v2.x
-  var arg1/eax: (addr float) <- get v1, x
-  var arg2/ecx: (addr float) <- get v2, x
-  var result/xmm0: float <- copy *arg1
-  result <- add *arg2
-  copy-to *arg1, result
-  # v1.y += v2.y
-  arg1 <- get v1, y
-  arg2 <- get v2, y
-  result <- copy *arg1
-  result <- add *arg2
-  copy-to *arg1, result
-  # v1.z += v2.z
-  arg1 <- get v1, z
-  arg2 <- get v2, z
-  result <- copy *arg1
-  result <- add *arg2
-  copy-to *arg1, result
-}
-
-fn vec3-subtract-from v1: (addr vec3), v2: (addr vec3) {
-  var tmp-storage: vec3
-  var tmp/eax: (addr vec3) <- address tmp-storage
-  copy-object v2, tmp
-  vec3-negate tmp
-  vec3-add-to v1, tmp
-}
-
-fn vec3-negate v: (addr vec3) {
-  var negative-one/eax: int <- copy -1
-  var negative-one-f/xmm0: float <- convert negative-one
-  vec3-scale-up v, negative-one-f
-}
-
-fn vec3-scale-up _v: (addr vec3), f: float {
-  var v/edi: (addr vec3) <- copy _v
-  # v.x *= f
-  var dest/eax: (addr float) <- get v, x
-  var result/xmm0: float <- copy *dest
-  result <- multiply f
-  copy-to *dest, result
-  # v.y *= f
-  dest <- get v, y
-  result <- copy *dest
-  result <- multiply f
-  copy-to *dest, result
-  # v.z *= f
-  dest <- get v, z
-  result <- copy *dest
-  result <- multiply f
-  copy-to *dest, result
-}
-
-fn vec3-scale-down _v: (addr vec3), f: float {
-  var v/edi: (addr vec3) <- copy _v
-  # v.x /= f
-  var dest/eax: (addr float) <- get v, x
-  var result/xmm0: float <- copy *dest
-  result <- divide f
-  copy-to *dest, result
-  # v.y /= f
-  dest <- get v, y
-  result <- copy *dest
-  result <- divide f
-  copy-to *dest, result
-  # v.z /= f
-  dest <- get v, z
-  result <- copy *dest
-  result <- divide f
-  copy-to *dest, result
-}
-
-fn vec3-unit in: (addr vec3), out: (addr vec3) {
-  var len/xmm0: float <- vec3-length in
-#?   print-string 0, "len: "
-#?   print-float-hex 0, len
-#?   print-string 0, "\n"
-  copy-object in, out
-  vec3-scale-down out, len
-}
-
-fn vec3-length v: (addr vec3) -> _/xmm0: float {
-  var result/xmm0: float <- vec3-length-squared v
-  result <- square-root result
-  return result
-}
-
-fn vec3-length-squared _v: (addr vec3) -> _/xmm0: float {
-  var v/esi: (addr vec3) <- copy _v
-  # result = v.x * v.x
-  var src/eax: (addr float) <- get v, x
-  var tmp/xmm1: float <- copy *src
-  tmp <- multiply tmp
-  var result/xmm0: float <- copy tmp
-  # result += v.y * v.y
-  src <- get v, y
-  tmp <- copy *src
-  tmp <- multiply tmp
-  result <- add tmp
-  # result += v.z * v.z
-  src <- get v, z
-  tmp <- copy *src
-  tmp <- multiply tmp
-  result <- add tmp
-  return result
-}
-
-fn vec3-dot _v1: (addr vec3), _v2: (addr vec3) -> _/xmm0: float {
-}
-
-fn vec3-cross _v1: (addr vec3), _v2: (addr vec3), out: (addr vec3) {
-}