mu/linux/apps/texture.mu

59 lines
1.4 KiB
Forth
Raw Permalink Normal View History

2020-10-18 22:39:34 +00:00
# Playing with emitting cool textures.
#
# To run (on Linux):
# $ git clone https://github.com/akkartik/mu
# $ cd mu
2021-07-16 15:09:42 +00:00
# $ ./translate apps/texture.mu
2020-10-18 22:39:34 +00:00
# $ ./a.elf > a.ppm
2020-11-02 06:17:40 +00:00
fn main -> _/ebx: int {
2020-10-18 22:39:34 +00:00
#? 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/screen, "P3\n"
print-int32-decimal 0/screen, width
print-string 0/screen, " "
print-int32-decimal 0/screen, height
print-string 0/screen, "\n"
print-string 0/screen, "255\n" # color depth
2020-10-18 22:39:34 +00:00
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
2020-10-18 22:49:20 +00:00
tmp <- multiply row
2020-10-19 03:18:51 +00:00
tmp <- and 0x7f
tmp <- add 0x80
tmp <- copy 0xff
print-int32-decimal 0/screen, tmp
print-string 0/screen, " "
2020-10-18 22:39:34 +00:00
# g
tmp <- copy row
2020-10-18 22:49:20 +00:00
tmp <- multiply col
2020-10-19 03:18:51 +00:00
tmp <- and 0x7f
tmp <- add 0x80
#? tmp <- copy 0xcf
print-int32-decimal 0/screen, tmp
print-string 0/screen, " "
2020-10-18 22:39:34 +00:00
# b
2020-10-18 22:49:20 +00:00
tmp <- copy row
tmp <- multiply col
2020-10-19 03:18:51 +00:00
tmp <- and 0x7f
tmp <- add 0x80
print-int32-decimal 0/screen, tmp
print-string 0/screen, "\n"
2020-10-18 22:39:34 +00:00
col <- increment
loop
}
row <- increment
loop
}
2020-11-02 06:17:40 +00:00
return 0
2020-10-18 22:39:34 +00:00
}