From b385e6edad94c4117d82614a5b014f11ae811d84 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 6 Dec 2023 22:03:24 -0500 Subject: [PATCH] Revise guess as to address wrapping. --- Machines/PCCompatible/CGA.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Machines/PCCompatible/CGA.hpp b/Machines/PCCompatible/CGA.hpp index 547cb24cd..897924656 100644 --- a/Machines/PCCompatible/CGA.hpp +++ b/Machines/PCCompatible/CGA.hpp @@ -263,7 +263,9 @@ class CGA { // character code + attributes except that these are two bytes worth of graphics. // // Meanwhile, row address is used to invent a 15th address line. - const auto base_address = ((state.refresh_address << 1) + (state.row_address << 13)) & 0x3fff; + const auto base_address = + ((state.refresh_address & 0xfff) << 1) + + ((state.row_address & 1) << 13); const uint8_t bitmap[] = { ram[base_address], ram[base_address + 1], @@ -299,8 +301,8 @@ class CGA { } void serialise_text(const Motorola::CRTC::BusState &state) { - const uint8_t attributes = ram[((state.refresh_address << 1) + 1) & 0xfff]; - const uint8_t glyph = ram[((state.refresh_address << 1) + 0) & 0xfff]; + const uint8_t attributes = ram[((state.refresh_address << 1) + 1) & 0x3fff]; + const uint8_t glyph = ram[((state.refresh_address << 1) + 0) & 0x3fff]; const uint8_t row = font[(glyph * 8) + state.row_address]; uint8_t colours[2] = {