From 217b27b040d0b4505195861d5a6dd5fb67baee12 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Wed, 24 Jan 2018 20:05:47 -0600 Subject: [PATCH] Handle inversed text --- src/apple2.text.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/apple2.text.c b/src/apple2.text.c index ee285d5..554ee75 100644 --- a/src/apple2.text.c +++ b/src/apple2.text.c @@ -10,12 +10,14 @@ * implemented as part of both fonts. */ +#include + #include "apple2.text.h" void apple2_text_draw(apple2 *mach, size_t addr) { - int err; + int err, bit7, bit6; vm_8bit ch; vm_area dest; vm_bitfont *font; @@ -38,12 +40,45 @@ apple2_text_draw(apple2 *mach, size_t addr) // What are we working with? ch = mos6502_get(mach->cpu, addr); + // Bit 7 and bit 6 mean different things in ALTCHAR + // and...non-ALTCHAR. + bit7 = ch & 0x80; + bit6 = ch & 0x40; + + // The ASCII code we will use is only that which is composed of the + // first 6 bits. + ch = ch & 0x7f; + // We treat special characters as spaces for display purposes. if (ch < 0x20) { vm_bitfont_render(font, mach->screen, &dest, ' '); return; } + // If bit 7 is high, then we want to show inverse video. This is + // mostly true regardless of character set. + if (bit7) { + font = mach->invfont; + } + + if (mach->display_mode & DISPLAY_ALTCHAR) { + // The character here should be MouseText, so we'll need to use + // the _non_ inverted font for that. + if (ch >= 0x40 && ch <= 0x5F) { + font = mach->sysfont; + } + + if (bit6) { + ch = tolower(ch); + } + } else { + // FIXME: we should turn on flashing text here, but that's not + // yet implemented + if (bit6) { + // do something with flashing text + } + } + // Blank out the space on the screen, then show the character vm_bitfont_render(font, mach->screen, &dest, ' '); vm_bitfont_render(font, mach->screen, &dest, ch);