about summary refs log tree commit diff stats
path: root/img.mu
diff options
context:
space:
mode:
Diffstat (limited to 'img.mu')
-rw-r--r--img.mu48
1 files changed, 24 insertions, 24 deletions
diff --git a/img.mu b/img.mu
index 3d8d1113..f9f2d6e9 100644
--- a/img.mu
+++ b/img.mu
@@ -109,7 +109,7 @@ fn render-image screen: (addr screen), _img: (addr image), xmin: int, ymin: int,
     break-if-!=
     var img2-storage: image
     var img2/edi: (addr image) <- address img2-storage
-    dither-pgm-with-monochrome img, img2
+    dither-pgm-unordered-monochrome img, img2
     render-pbm-image screen, img2, xmin, ymin, width, height
     return
   }
@@ -360,7 +360,7 @@ fn nearest-grey level-255: byte -> _/eax: int {
   return result
 }
 
-fn dither-pgm-with-monochrome _src: (addr image), _dest: (addr image) {
+fn dither-pgm-unordered-monochrome _src: (addr image), _dest: (addr image) {
   var src/esi: (addr image) <- copy _src
   var dest/edi: (addr image) <- copy _dest
   # copy 'width'
@@ -391,10 +391,10 @@ fn dither-pgm-with-monochrome _src: (addr image), _dest: (addr image) {
   var src-data-ah/eax: (addr handle array byte) <- get src, data
   var _src-data/eax: (addr array byte) <- lookup *src-data-ah
   var src-data/esi: (addr array byte) <- copy _src-data
-  _unordered-monochrome-dither src-data, src-width, src-height, buffer, dest-data
+  _dither-pgm-unordered-monochrome src-data, src-width, src-height, buffer, dest-data
 }
 
-fn _unordered-monochrome-dither src: (addr array byte), width: int, height: int, buf: (addr array int), dest: (addr array byte) {
+fn _dither-pgm-unordered-monochrome src: (addr array byte), width: int, height: int, buf: (addr array int), dest: (addr array byte) {
   var y/edx: int <- copy 0
   {
     compare y, height
@@ -405,9 +405,9 @@ fn _unordered-monochrome-dither src: (addr array byte), width: int, height: int,
       compare x, width
       break-if->=
 #?       psd "x", x, 3/fg, x, y
-      var error/ebx: int <- _read-buffer buf, x, y, width
-      $_unordered-monochrome-dither:update-error: {
-        var curr/eax: byte <- _read-byte-buffer src, x, y, width
+      var error/ebx: int <- _read-pgm-buffer buf, x, y, width
+      $_dither-pgm-unordered-monochrome:update-error: {
+        var curr/eax: byte <- _read-pgm-byte-buffer src, x, y, width
         var curr-int/eax: int <- copy curr
         curr-int <- shift-left 0x10  # we have 32 bits; we'll use 16 bits for the fraction and leave 8 for unanticipated overflow
         error <- add curr-int
@@ -416,14 +416,14 @@ fn _unordered-monochrome-dither src: (addr array byte), width: int, height: int,
         {
           break-if->=
 #?           psd "p", 0, 0x14/fg, x, y
-          _write-byte-buffer dest, x, y, width, 0/black
-          break $_unordered-monochrome-dither:update-error
+          _write-pgm-byte-buffer dest, x, y, width, 0/black
+          break $_dither-pgm-unordered-monochrome:update-error
         }
 #?         psd "p", 1, 0xf/fg, x, y
-        _write-byte-buffer dest, x, y, width, 1/white
+        _write-pgm-byte-buffer dest, x, y, width, 1/white
         error <- subtract 0xff0000
       }
-      _diffuse-monochrome-dithering-errors buf, x, y, width, height, error
+      _diffuse-dithering-error-floyd-steinberg buf, x, y, width, height, error
       x <- increment
       loop
     }
@@ -440,7 +440,7 @@ fn _unordered-monochrome-dither src: (addr array byte), width: int, height: int,
 #
 # Error is currently a fixed-point number with 16-bit fraction. But
 # interestingly this function doesn't care about that.
-fn _diffuse-monochrome-dithering-errors buf: (addr array int), x: int, y: int, width: int, height: int, error: int {
+fn _diffuse-dithering-error-floyd-steinberg buf: (addr array int), x: int, y: int, width: int, height: int, error: int {
   {
     compare error, 0
     break-if-!=
@@ -466,7 +466,7 @@ fn _diffuse-monochrome-dithering-errors buf: (addr array int), x: int, y: int, w
     tmp <- multiply delta
     var xright/edx: int <- copy x
     xright <- increment
-    _accumulate-error buf, xright, y, width, tmp
+    _accumulate-pgm-error buf, xright, y, width, tmp
   }
   var y/ebx: int <- copy y
   {
@@ -484,30 +484,30 @@ fn _diffuse-monochrome-dithering-errors buf: (addr array int), x: int, y: int, w
     tmp <- multiply delta
     var xleft/edx: int <- copy x
     xleft <- decrement
-    _accumulate-error buf, xleft, ybelow, width, tmp
+    _accumulate-pgm-error buf, xleft, ybelow, width, tmp
   }
   {
     var tmp/eax: int <- copy 5
     tmp <- multiply delta
-    _accumulate-error buf, x, ybelow, width, tmp
+    _accumulate-pgm-error buf, x, ybelow, width, tmp
   }
   {
     compare x, width-1
     break-if->=
     var xright/edx: int <- copy x
     xright <- increment
-    _accumulate-error buf, xright, ybelow, width, delta
+    _accumulate-pgm-error buf, xright, ybelow, width, delta
   }
 #?   show-errors buf, width, height, x, y
 }
 
-fn _accumulate-error buf: (addr array int), x: int, y: int, width: int, error: int {
-  var curr/ebx: int <- _read-buffer buf, x, y, width
+fn _accumulate-pgm-error buf: (addr array int), x: int, y: int, width: int, error: int {
+  var curr/ebx: int <- _read-pgm-buffer buf, x, y, width
   curr <- add error
-  _write-buffer buf, x, y, width, curr
+  _write-pgm-buffer buf, x, y, width, curr
 }
 
-fn _read-buffer _buf: (addr array int), x: int, y: int, width: int -> _/ebx: int {
+fn _read-pgm-buffer _buf: (addr array int), x: int, y: int, width: int -> _/ebx: int {
   var buf/esi: (addr array int) <- copy _buf
   var idx/ecx: int <- copy y
   idx <- multiply width
@@ -517,7 +517,7 @@ fn _read-buffer _buf: (addr array int), x: int, y: int, width: int -> _/ebx: int
   return *result-a
 }
 
-fn _write-buffer _buf: (addr array int), x: int, y: int, width: int, val: int {
+fn _write-pgm-buffer _buf: (addr array int), x: int, y: int, width: int, val: int {
   var buf/esi: (addr array int) <- copy _buf
   var idx/ecx: int <- copy y
   idx <- multiply width
@@ -529,7 +529,7 @@ fn _write-buffer _buf: (addr array int), x: int, y: int, width: int, val: int {
   copy-to *dest-a, src
 }
 
-fn _read-byte-buffer _buf: (addr array byte), x: int, y: int, width: int -> _/eax: byte {
+fn _read-pgm-byte-buffer _buf: (addr array byte), x: int, y: int, width: int -> _/eax: byte {
   var buf/esi: (addr array byte) <- copy _buf
   var idx/ecx: int <- copy y
   idx <- multiply width
@@ -539,7 +539,7 @@ fn _read-byte-buffer _buf: (addr array byte), x: int, y: int, width: int -> _/ea
   return result
 }
 
-fn _write-byte-buffer _buf: (addr array byte), x: int, y: int, width: int, val: byte {
+fn _write-pgm-byte-buffer _buf: (addr array byte), x: int, y: int, width: int, val: byte {
   var buf/esi: (addr array byte) <- copy _buf
   var idx/ecx: int <- copy y
   idx <- multiply width
@@ -568,7 +568,7 @@ fn show-errors buf: (addr array int), width: int, height: int, x: int, y: int {
     {
       compare x, width
       break-if->=
-      var error/ebx: int <- _read-buffer buf, x, y, width
+      var error/ebx: int <- _read-pgm-buffer buf, x, y, width
       psd "e", error, 5/fg, x, y
       x <- increment
       loop