about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-30 00:32:15 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-30 00:34:40 -0700
commitc970190021a0aeb2b73558a9095f63a774f439ba (patch)
tree1a6b0179bdf5b01ee58d524731ebca9a387965b5 /apps
parent877fbf640a91e24febe54426777e9edeb516a985 (diff)
downloadmu-c970190021a0aeb2b73558a9095f63a774f439ba.tar.gz
first rendering of non-latin script
Open question: why does column 0 get cropped? The spacing also seems
excessive. Are we taking up 3 grid points?
Diffstat (limited to 'apps')
-rw-r--r--apps/ex14.mu27
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/ex14.mu b/apps/ex14.mu
new file mode 100644
index 00000000..600aded5
--- /dev/null
+++ b/apps/ex14.mu
@@ -0,0 +1,27 @@
+# Unicode demo
+#
+# Mu can't read Unicode from keyboard yet, so we'll read from disk and print
+# to screen.
+#
+# Steps for trying it out:
+#   1. Translate this example into a disk image code.img.
+#       ./translate apps/ex14.mu
+#   2. Build a second disk image data.img containing some Unicode text.
+#       dd if=/dev/zero of=data.img count=20160
+#       echo 'நட' |dd of=data.img conv=notrunc
+#   3. Run:
+#       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)
+  var text/esi: (addr stream byte) <- address text-storage
+  load-sectors data-disk, 0/lba, 1/num-sectors, text
+  var dummy/eax: int <- draw-stream-rightward screen, text, 1/x 0x80/xmax 0/y, 0xa/fg, 0/bg
+}
='#n174'>174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255