2020-12-30 05:08:05 +00:00
|
|
|
# Test out the video mode by filling in the screen with pixels.
|
|
|
|
#
|
|
|
|
# To build a disk image:
|
2021-04-17 03:26:42 +00:00
|
|
|
# ./translate ex2.mu # emits code.img
|
2020-12-30 05:08:05 +00:00
|
|
|
# To run:
|
2021-04-17 03:26:42 +00:00
|
|
|
# qemu-system-i386 code.img
|
2020-12-30 05:08:05 +00:00
|
|
|
# Or:
|
2021-04-17 03:26:42 +00:00
|
|
|
# bochs -f bochsrc # bochsrc loads code.img
|
2020-12-30 05:08:05 +00:00
|
|
|
|
2021-03-28 00:47:23 +00:00
|
|
|
fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
|
2020-12-30 05:08:05 +00:00
|
|
|
var y/eax: int <- copy 0
|
|
|
|
{
|
2021-02-07 08:17:17 +00:00
|
|
|
compare y, 0x300/screen-height=768
|
2020-12-30 05:08:05 +00:00
|
|
|
break-if->=
|
|
|
|
var x/edx: int <- copy 0
|
|
|
|
{
|
2021-02-07 08:17:17 +00:00
|
|
|
compare x, 0x400/screen-width=1024
|
2020-12-30 05:08:05 +00:00
|
|
|
break-if->=
|
2020-12-30 05:19:41 +00:00
|
|
|
var color/ecx: int <- copy x
|
|
|
|
color <- and 0xff
|
2021-05-23 15:06:03 +00:00
|
|
|
pixel screen x, y, color
|
2020-12-30 05:08:05 +00:00
|
|
|
x <- increment
|
|
|
|
loop
|
|
|
|
}
|
|
|
|
y <- increment
|
|
|
|
loop
|
|
|
|
}
|
|
|
|
}
|