https://github.com/akkartik/mu/blob/main/apps/ex13.mu
 1 # Load an image from disk and display it on screen.
 2 #
 3 # Build the code disk:
 4 #   $ ./translate apps/ex13.mu                       # generates code.img
 5 # Load a pbm, pgm or ppm image (no more than 255 levels) in the data disk
 6 #   $ dd if=/dev/zero of=data.img count=20160
 7 #   $ dd if=___ of=data.img conv=notrunc
 8 # Run:
 9 #   $ qemu-system-i386 -hda code.img -hdb data.img
10 
11 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
12   var img-storage: image
13   var img/esi: (addr image) <- address img-storage
14   load-image img, data-disk
15   render-image screen, img, 0/x, 0/y, 0x300/width, 0x300/height
16 }
17 
18 fn load-image self: (addr image), data-disk: (addr disk) {
19   var s-storage: (stream byte 0x200000)  # 512 * 0x1000 sectors
20   var s/ebx: (addr stream byte) <- address s-storage
21   load-sectors data-disk, 0/lba, 0x1000/sectors, s
22   initialize-image self, s
23 }