diff options
Diffstat (limited to 'apps/raytracing/color.mu')
-rw-r--r-- | apps/raytracing/color.mu | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/raytracing/color.mu b/apps/raytracing/color.mu index 3b1ff419..86b3d0b6 100644 --- a/apps/raytracing/color.mu +++ b/apps/raytracing/color.mu @@ -8,24 +8,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 - var xn/xmm1: float <- convert n - var tmp/xmm0: float <- copy xn - var tmp-a/eax: (addr float) <- get c, r - tmp <- multiply *tmp-a - var tmp2/edx: int <- convert tmp - print-int32-decimal screen, tmp2 + 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 <- truncate result + print-int32-decimal screen, result-int print-string screen, " " - tmp-a <- get c, g - tmp <- copy xn - tmp <- multiply *tmp-a - tmp2 <- convert tmp - print-int32-decimal screen, tmp2 + # print 255.999 * c->g + src-addr <- get c, g + result <- copy xn + result <- multiply *src-addr + result-int <- truncate result + print-int32-decimal screen, result-int print-string screen, " " - tmp-a <- get c, b - tmp <- copy xn - tmp <- multiply *tmp-a - tmp2 <- convert tmp - print-int32-decimal screen, tmp2 + # print 255.999 * c->b + src-addr <- get c, b + result <- copy xn + result <- multiply *src-addr + result-int <- truncate result + print-int32-decimal screen, result-int print-string screen, "\n" } |