From 4a2dcff028e8cd3774e616e5b6e95aabf2e43eff Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 21 Mar 2024 21:53:50 -0400 Subject: [PATCH] Endeavour to map colours properly. --- Machines/Acorn/Archimedes/Video.hpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Machines/Acorn/Archimedes/Video.hpp b/Machines/Acorn/Archimedes/Video.hpp index 1611d2697..a09f36c82 100644 --- a/Machines/Acorn/Archimedes/Video.hpp +++ b/Machines/Acorn/Archimedes/Video.hpp @@ -12,6 +12,7 @@ #include "../../../Outputs/CRT/CRT.hpp" #include +#include namespace Archimedes { @@ -31,8 +32,13 @@ struct Video { return (value >> 14) & 0x3ff; }; const auto colour = [](uint32_t value) -> uint16_t { - // TODO: convert to internal format. - return static_cast(value & 0x1fff); + uint8_t packed[2]; + packed[0] = value & 0xf; + packed[1] = (value & 0xf0) | ((value & 0xf00) >> 8); + + uint16_t result; + memcpy(&result, packed, 2); + return result; }; switch(target) { @@ -122,6 +128,7 @@ struct Video { if(vertical_state_.position == vertical_timing_.period) { vertical_state_.position = 0; + address_ = frame_start_; } } @@ -202,11 +209,14 @@ private: Phase phase_ = Phase::Sync; uint32_t time_in_phase_ = 0; - // Addresses. - uint32_t buffer_start_; - uint32_t buffer_end_; - uint32_t frame_start_; - uint32_t cursor_start_; + // Programmer-set addresses. + uint32_t buffer_start_ = 0; + uint32_t buffer_end_ = 0; + uint32_t frame_start_ = 0; + uint32_t cursor_start_ = 0; + + // Ephemeral address state. + uint32_t address_ = 0; // Horizontal and vertical timing. struct Timing {