about summary refs log tree commit diff stats
path: root/apps/raytracing/3.mu
diff options
context:
space:
mode:
Diffstat (limited to 'apps/raytracing/3.mu')
-rw-r--r--apps/raytracing/3.mu19
1 files changed, 11 insertions, 8 deletions
diff --git a/apps/raytracing/3.mu b/apps/raytracing/3.mu
index 359b5c9b..28640c7b 100644
--- a/apps/raytracing/3.mu
+++ b/apps/raytracing/3.mu
@@ -212,6 +212,8 @@ fn main -> exit-status/ebx: int {
         ray-color r, c
         # write color
         print-rgb 0, c
+#?         print-rgb-raw 0, c
+#?         print-string 0, "\n"
       }
       i <- increment
       loop
@@ -257,27 +259,28 @@ type rgb {
 # print translating to [0, 256)
 fn print-rgb screen: (addr screen), _c: (addr rgb) {
   var c/esi: (addr rgb) <- copy _c
-  var n/ecx: int <- copy 0xff  # turns out 255 works just as well as 255.999, which is lucky because we don't have floating-point literals
-  var xn/xmm1: float <- convert n
-  # print 255 * c->r
+  var xn: float
+  var xn-addr/ecx: (addr float) <- address xn
+  fill-in-rational xn-addr, 0x3e7ff, 0x3e8  # 255999 / 1000
+  # print 255.999 * c->r
   var result/xmm0: float <- copy xn
   var src-addr/eax: (addr float) <- get c, r
   result <- multiply *src-addr
-  var result-int/edx: int <- convert result
+  var result-int/edx: int <- truncate result
   print-int32-decimal screen, result-int
   print-string screen, " "
-  # print 255 * c->g
+  # print 255.999 * c->g
   src-addr <- get c, g
   result <- copy xn
   result <- multiply *src-addr
-  result-int <- convert result
+  result-int <- truncate result
   print-int32-decimal screen, result-int
   print-string screen, " "
-  # print 255 * c->b
+  # print 255.999 * c->b
   src-addr <- get c, b
   result <- copy xn
   result <- multiply *src-addr
-  result-int <- convert result
+  result-int <- truncate result
   print-int32-decimal screen, result-int
   print-string screen, "\n"
 }