From 231de8440ee41e86239bee15fb8125d151b2701c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 22 Nov 2023 14:11:22 -0500 Subject: [PATCH] Add text display. --- Machines/PCCompatible/PCCompatible.cpp | 31 +++++++++++++++++++------- Machines/Utility/ROMCatalogue.cpp | 3 +++ Machines/Utility/ROMCatalogue.hpp | 1 + 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index 568cb9ec7..1d76bcdb2 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -39,8 +39,9 @@ class MDA { public: MDA() : crtc_(Motorola::CRTC::Personality::HD6845S, outputter_) {} - void set_source(const uint8_t *source) { - outputter_.source = source; + void set_source(const uint8_t *ram, std::vector font) { + outputter_.ram = ram; + outputter_.font = font; } void run_for(Cycles cycles) { @@ -131,10 +132,21 @@ class MDA { } if(pixels) { - // TODO: use refresh address to fetch from RAM; use that plus row address to index font. + // TODO: use flags. + const uint8_t glyph = ram[(state.refresh_address << 1) + 0]; +// const uint8_t flags = ram[(state.refresh_address << 1) + 1]; - pixel_pointer[0] = pixel_pointer[2] = pixel_pointer[4] = pixel_pointer[6] = 0; - pixel_pointer[1] = pixel_pointer[3] = pixel_pointer[5] = pixel_pointer[7] = pixel_pointer[8] = 1; + const uint8_t row = font[(glyph * 14) + state.row_address]; + + pixel_pointer[0] = row & 0x80; + pixel_pointer[1] = row & 0x40; + pixel_pointer[2] = row & 0x20; + pixel_pointer[3] = row & 0x10; + pixel_pointer[4] = row & 0x08; + pixel_pointer[5] = row & 0x04; + pixel_pointer[6] = row & 0x02; + pixel_pointer[7] = row & 0x01; + pixel_pointer[8] = 0; // TODO. pixel_pointer += 9; } } @@ -163,7 +175,8 @@ class MDA { uint8_t *pixel_pointer = nullptr; static constexpr size_t DefaultAllocationSize = 720; - const uint8_t *source = nullptr; + const uint8_t *ram = nullptr; + std::vector font; } outputter_; Motorola::CRTC::CRTC6845 crtc_; @@ -766,8 +779,9 @@ class ConcreteMachine: // Fetch the BIOS. [8088 only, for now] const auto bios = ROM::Name::PCCompatibleGLaBIOS; + const auto font = ROM::Name::PCCompatibleMDAFont; - ROM::Request request = ROM::Request(bios); + ROM::Request request = ROM::Request(bios) && ROM::Request(font); auto roms = rom_fetcher(request); if(!request.validate(roms)) { throw ROMMachine::Error::MissingROMs; @@ -777,7 +791,8 @@ class ConcreteMachine: context.memory.install(0x10'0000 - bios_contents.size(), bios_contents.data(), bios_contents.size()); // Give the MDA something to read from. - mda_.set_source(context.memory.at(0xb'0000)); + const auto &font_contents = roms.find(font)->second; + mda_.set_source(context.memory.at(0xb'0000), font_contents); } ~ConcreteMachine() { diff --git a/Machines/Utility/ROMCatalogue.cpp b/Machines/Utility/ROMCatalogue.cpp index 28488454e..14bc0a118 100644 --- a/Machines/Utility/ROMCatalogue.cpp +++ b/Machines/Utility/ROMCatalogue.cpp @@ -573,6 +573,9 @@ Description::Description(Name name) { case Name::PCCompatiblePhoenix80286BIOS: *this = Description(name, "PCCompatible", "Phoenix 80286 BIOS 3.05", "Phoenix 80286 ROM BIOS Version 3.05.bin", 32 * 1024, 0x8d0d318au); break; + case Name::PCCompatibleMDAFont: + *this = Description(name, "PCCompatible", "IBM's MDA font", "EUMDA9.F14", 14 * 256, 0x7754882au); + break; // TODO: CRCs below are incomplete, at best. case Name::MSXGenericBIOS: *this = Description(name, "MSX", "a generix MSX BIOS", "msx.rom", 32*1024, 0x94ee12f3u); break; diff --git a/Machines/Utility/ROMCatalogue.hpp b/Machines/Utility/ROMCatalogue.hpp index da256fa4e..37c53adf8 100644 --- a/Machines/Utility/ROMCatalogue.hpp +++ b/Machines/Utility/ROMCatalogue.hpp @@ -135,6 +135,7 @@ enum Name { // PCCompatible. PCCompatibleGLaBIOS, PCCompatiblePhoenix80286BIOS, + PCCompatibleMDAFont, // Sinclair QL. SinclairQLJS,