about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/ex14.mu9
-rw-r--r--apps/ex15.mu36
2 files changed, 38 insertions, 7 deletions
diff --git a/apps/ex14.mu b/apps/ex14.mu
index 4a2d5dd7..b940e4f6 100644
--- a/apps/ex14.mu
+++ b/apps/ex14.mu
@@ -1,7 +1,7 @@
 # Unicode demo
 #
-# Mu can't read Unicode from keyboard yet, so we'll read from disk and print
-# to screen.
+# Mu can't read Unicode from keyboard yet, so we'll read utf-8 from disk and
+# print to screen.
 #
 # Steps for trying it out:
 #   1. Translate this example into a disk image code.img.
@@ -13,11 +13,6 @@
 #       qemu-system-i386 -hda code.img -hdb data.img
 #
 # Expected output: 'நட' in green near the top-left corner of screen
-#
-# Limitations:
-#   - Utf-8 is the one true encoding.
-#   - No keyboard support yet.
-#   - Just single-code-point graphemes so far. No combiner characters, etc.
 
 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
   var text-storage: (stream byte 0x200)
diff --git a/apps/ex15.mu b/apps/ex15.mu
new file mode 100644
index 00000000..2d1c6bcf
--- /dev/null
+++ b/apps/ex15.mu
@@ -0,0 +1,36 @@
+# Demo of combining-character support in Mu, which can be summarized as, "the
+# old typewriter-based approach of backing up one character and adding the
+# accent or _matra_ in."
+#   https://en.wikipedia.org/wiki/Combining_character
+#
+# Mu uses this approach for both accents in Latin languages and vowel
+# diacritics in Abugida scripts.
+#   https://en.wikipedia.org/wiki/Diacritic
+#   https://en.wikipedia.org/wiki/Abugida
+#
+# Steps for trying it out:
+#   1. Translate this example into a disk image code.img.
+#       ./translate apps/ex15.mu
+#   2. Run:
+#       qemu-system-i386 -hda code.img -hdb data.img
+#
+# Expected output: 'à' in green in a few places near the top-left corner of
+# screen, showing off what this approach can and cannot do.
+
+fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
+  # at the top of screen, the accent is almost cropped
+  var dummy/eax: int <-    draw-code-point-on-real-screen   0x61/a,                       0/x 0/y, 3/fg 0/bg
+  var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent,  0/x 0/y, 3/fg 0/bg
+
+  # below a grapheme with a descender, the accent uglily overlaps
+  #   https://en.wikipedia.org/wiki/Descender
+  var dummy/eax: int <-    draw-code-point-on-real-screen   0x67/g,                       4/x 3/y, 3/fg 0/bg
+  var dummy/eax: int <-    draw-code-point-on-real-screen   0x61/a,                       4/x 4/y, 3/fg 0/bg
+  var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent,  4/x 4/y, 3/fg 0/bg
+
+  # beside a grapheme with a descender, it becomes more obvious that monowidth fonts can't make baselines line up
+  #   https://en.wikipedia.org/wiki/Baseline_(typography)
+  var dummy/eax: int <-    draw-code-point-on-real-screen   0x67/g,                       8/x 3/y, 3/fg 0/bg
+  var dummy/eax: int <-    draw-code-point-on-real-screen   0x61/a,                       9/x 3/y, 3/fg 0/bg
+  var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent,  9/x 3/y, 3/fg 0/bg
+}