diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-18 15:39:34 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-18 15:39:34 -0700 |
commit | e170b35d8b37901903318851803e3cab5e09cde0 (patch) | |
tree | 3b6c56e3210d22aebb8d138cec4d746be6a81350 /apps/texture.mu | |
parent | dc0e03e4a52adf914d8ed55ca5f833947cc264d3 (diff) | |
download | mu-e170b35d8b37901903318851803e3cab5e09cde0.tar.gz |
7054
Diffstat (limited to 'apps/texture.mu')
-rw-r--r-- | apps/texture.mu | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/texture.mu b/apps/texture.mu new file mode 100644 index 00000000..bd76c49a --- /dev/null +++ b/apps/texture.mu @@ -0,0 +1,49 @@ +# Playing with emitting cool textures. +# +# To run (on Linux): +# $ git clone https://github.com/akkartik/mu +# $ cd mu +# $ ./translate_mu apps/texture.mu +# $ ./a.elf > a.ppm + +fn main -> exit-status/ebx: int { +#? var width/esi: int <- copy 0x190 # 400 +#? var height/edi: int <- copy 0xe1 # 225; aspect ratio 16:9 + var width/esi: int <- copy 0xff + var height/edi: int <- copy 0xff + print-string 0, "P3\n" + print-int32-decimal 0, width + print-string 0, " " + print-int32-decimal 0, height + print-string 0, "\n" + print-string 0, "65535\n" # color depth + var row/ecx: int <- copy 0 + { + compare row, height + break-if->= + var col/edx: int <- copy 0 + { + compare col, width + break-if->= + # r + var tmp/eax: int <- copy col + tmp <- multiply col + print-int32-decimal 0, tmp + print-string 0, " " + # g + tmp <- copy row + tmp <- multiply row + print-int32-decimal 0, tmp + print-string 0, " " + # b + tmp <- copy 0 + print-int32-decimal 0, tmp + print-string 0, "\n" + col <- increment + loop + } + row <- increment + loop + } + exit-status <- copy 0 +} |