diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-08-29 20:34:53 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-08-29 20:34:53 -0700 |
commit | b1dcfb03d00f93999da0225600fe5f9d708e439c (patch) | |
tree | f4f3978f93918d4551dd7e13b2f97f57f8b83db9 | |
parent | 354c72a6377d04574efe1c5cfb4b29d91c939b15 (diff) | |
download | mu-b1dcfb03d00f93999da0225600fe5f9d708e439c.tar.gz |
load Font in a non-contiguous area of memory
-rw-r--r-- | 103grapheme.subx | 4 | ||||
-rw-r--r-- | boot.subx | 8 | ||||
-rw-r--r-- | font.subx | 3 | ||||
-rwxr-xr-x | translate | 21 | ||||
-rwxr-xr-x | translate_emulated | 21 |
5 files changed, 44 insertions, 13 deletions
diff --git a/103grapheme.subx b/103grapheme.subx index eaeacfab..abcfe57c 100644 --- a/103grapheme.subx +++ b/103grapheme.subx @@ -83,7 +83,7 @@ draw-grapheme-on-screen-buffer: # buffer: (addr byte), g: grapheme, x: int, y: 0f 8d/jump-if->= $draw-grapheme-on-screen-buffer:end/disp32 # var letter-bitmap/esi = font[g] 69/multiply %esi 0x21/imm32/glyph-size 6/r32/esi - 81 0/subop/add %esi Font/imm32 + 81 0/subop/add %esi 0x0010000c/imm32/Font # see boot.subx # dispatch based on letter-bitmap->size b8/copy-to-eax 0/imm32 8a/byte-> *esi 0/r32/AL @@ -116,7 +116,7 @@ wide-grapheme?: # g: grapheme -> _/eax: boolean 0f 8d/jump-if->= $wide-grapheme?:end/disp32 # var letter-bitmap/eax = font[g] 69/multiply %eax 0x21/imm32/glyph-size 0/r32/eax - 05/add-to-eax Font/imm32 + 05/add-to-eax 0x0010000c/imm32/Font # see boot.subx # dispatch based on letter-bitmap->size 8a/byte-> *eax 0/r32/AL 25/and-eax-with 0xff/imm32 diff --git a/boot.subx b/boot.subx index 1cd78bfd..ed1631bc 100644 --- a/boot.subx +++ b/boot.subx @@ -16,6 +16,7 @@ # Memory map of a Mu computer: # code: [0x00007c00, 0x0007de00) +# system font: [0x00100000, 0x00f00000) # stack: (0x02000000, 0x01000000] # heap: [0x02000000, 0x80000000) # see 120allocate.subx; Qemu initializes with 128MB RAM by default; simulating 2GB RAM is known to work @@ -275,6 +276,13 @@ initialize_32bit_mode: bc/copy-to-esp 0x02000000/imm32 + ## install the font somewhere non-contiguous (keep sync'd with memory map up top) + c7 0/subop/copy *0x00100000 0/imm32/read + c7 0/subop/copy *0x00100004 0/imm32/write + c7 0/subop/copy *0x00100008 0x00e00000/imm32/size + (load-sectors Primary-bus-primary-drive 0x2328 0x120 0x00100000) # source 0x2328 = sector 9000 on disk, destination 0x00100000 + # Font is now loaded starting at 0x0010000c. + ## load interrupt handlers # We can't refer to the label directly because SubX doesn't do the right # thing for lidt, so rather than make errors worse in most places we instead diff --git a/font.subx b/font.subx index f7275352..dd822c71 100644 --- a/font.subx +++ b/font.subx @@ -11,9 +11,6 @@ # * If it's 16, the glyph is 16 pixels wide, and each row consists of two # bytes. -== data - -Font: # 0x00-0x1f: unprintable ASCII 08/size # nul character hard-coded to 8 bits wide 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 # nul character hard-coded to blank diff --git a/translate b/translate index e0e3ba02..e9fec574 100755 --- a/translate +++ b/translate @@ -6,7 +6,9 @@ set -e # Map of the Mu code disk export DISK=20160 # 20*16*63 512-byte sectors = almost 10MB dd if=/dev/zero of=code.img count=$DISK -# code: sectors 0-10079 +# code: sectors 0-8999 +# font: sectors 9000-10079 (1080 sectors = space enough for 16k glyphs (1080 * 512 / 33 bytes per glyph)) +export FONT=9000 # keep this sync'd with boot.subx # debug: sector 10080 onwards export DEBUG=10080 @@ -14,7 +16,7 @@ export DEBUG=10080 cat $* [0-9]*.mu |linux/mu > a.subx -cat boot.subx font.subx mu-init.subx [0-9]*.subx a.subx |linux/braces > a.braces +cat boot.subx mu-init.subx [0-9]*.subx a.subx |linux/braces > a.braces cat a.braces |linux/calls > a.calls @@ -47,9 +49,9 @@ then exit 1 fi -if [ `stat --printf="%s" a.bin` -ge $(($DEBUG*512)) ] +if [ `stat --printf="%s" a.bin` -ge $(($FONT*512)) ] then - echo "a.bin will overwrite debug info on disk" + echo "a.bin will overwrite font in disk" exit 1 fi @@ -68,3 +70,14 @@ then fi dd if=labels of=code.img seek=$DEBUG conv=notrunc # keep this sync'd with abort.subx + +## Some space for font data at another well-defined location +cat font.subx |sed 's,#.*,,' |sed 's,/[^ ]*,,' |linux/hex > a.font + +if [ `stat --printf="%s" a.bin` -ge $(( ($DEBUG - $FONT) * 512 )) ] +then + echo "font will overwrite debug info in disk" + exit 1 +fi + +dd if=a.font of=code.img seek=$FONT conv=notrunc diff --git a/translate_emulated b/translate_emulated index 6d3b6681..3ff4b24c 100755 --- a/translate_emulated +++ b/translate_emulated @@ -10,7 +10,9 @@ set -v # Map of the Mu code disk export DISK=20160 # 20*16*63 512-byte sectors = almost 10MB dd if=/dev/zero of=code.img count=$DISK -# code: sectors 0-10079 +# code: sectors 0-8999 +# font: sectors 9000-10079 (1080 sectors = space enough for 16k glyphs (1080 * 512 / 33 bytes per glyph)) +export FONT=9000 # debug: sector 10080 onwards export DEBUG=10080 @@ -18,7 +20,7 @@ export DEBUG=10080 cat $* [0-9]*.mu |linux/bootstrap/bootstrap run linux/mu > a.subx -cat boot.subx font.subx mu-init.subx [0-9]*.subx a.subx |linux/bootstrap/bootstrap run linux/braces > a.braces +cat boot.subx mu-init.subx [0-9]*.subx a.subx |linux/bootstrap/bootstrap run linux/braces > a.braces cat a.braces |linux/bootstrap/bootstrap run linux/calls > a.calls @@ -51,9 +53,9 @@ then exit 1 fi -if [ `stat --printf="%s" a.bin` -ge $(($DEBUG*512)) ] +if [ `stat --printf="%s" a.bin` -ge $(($FONT*512)) ] then - echo "a.bin will overwrite debug info on disk" + echo "a.bin will overwrite font in disk" exit 1 fi @@ -72,3 +74,14 @@ then fi dd if=labels of=code.img seek=$DEBUG conv=notrunc # keep this sync'd with abort.subx + +## Some space for font data at another well-defined location +cat font.subx |sed 's,#.*,,' |sed 's,/[^ ]*,,' |linux/hex > a.font + +if [ `stat --printf="%s" a.bin` -ge $(( ($DEBUG - $FONT) * 512 )) ] +then + echo "font will overwrite debug info in disk" + exit 1 +fi + +dd if=a.font of=code.img seek=$FONT conv=notrunc |