diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-03 20:24:14 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-03 20:24:14 -0700 |
commit | f6eba67645cdc4e103f9e13d61750ca2a15cf7eb (patch) | |
tree | 5c3174bc50a17506b7d2f934cb5ba42a98ec9051 /apps | |
parent | 6112864aeac32ec21bd27bfce6b9c44d6a74d45c (diff) | |
download | mu-f6eba67645cdc4e103f9e13d61750ca2a15cf7eb.tar.gz |
6937
Diffstat (limited to 'apps')
-rw-r--r-- | apps/raytracing/2.mu | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/apps/raytracing/2.mu b/apps/raytracing/2.mu index baa29622..69bc9a40 100644 --- a/apps/raytracing/2.mu +++ b/apps/raytracing/2.mu @@ -60,24 +60,27 @@ 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 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 - 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 + # print 255 * 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 + 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 * c->g + src-addr <- get c, g + result <- copy xn + result <- multiply *src-addr + result-int <- convert 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 * c->b + src-addr <- get c, b + result <- copy xn + result <- multiply *src-addr + result-int <- convert result + print-int32-decimal screen, result-int print-string screen, "\n" } |