From f5814b4c758b8b563e2a2db33117d34abf20969b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 12 Feb 2023 22:45:11 -0500 Subject: [PATCH] Add text-mode events list. --- Components/9918/Implementation/Storage.hpp | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Components/9918/Implementation/Storage.hpp b/Components/9918/Implementation/Storage.hpp index 546187313..7e0c11149 100644 --- a/Components/9918/Implementation/Storage.hpp +++ b/Components/9918/Implementation/Storage.hpp @@ -53,11 +53,23 @@ template struct Storage struct Storage struct Storage>(); static constexpr auto sprites_events = events>(); + + struct TextGenerator { + static constexpr std::optional event(int grauw_index) { + // Capture various one-in-eight zones. + if(grauw_index < 72) { + return StandardGenerators::external_every_eight(grauw_index - 2); + } + if(grauw_index >= 166 && grauw_index < 228) { + return StandardGenerators::external_every_eight(grauw_index - 166); + } + if(grauw_index >= 1206 && grauw_index < 1332) { + return StandardGenerators::external_every_eight(grauw_index - 1206); + } + if(grauw_index == 1336) { + return Event::Type::External; + } + if(grauw_index >= 1346) { + return StandardGenerators::external_every_eight(grauw_index - 1346); + } + + // Elsewhere... + if(grauw_index >= 246) { + const int offset = grauw_index - 246; + const int block = offset / 48; + const int sub_block = offset % 48; + switch(sub_block) { + default: break; + case 0: return Event::Type::Name; + case 18: return (block & 1) ? Event::Type::External : Event::Type::Colour; + case 24: return Event::Type::Pattern; + } + } + + return std::nullopt; + } + }; + static constexpr auto text_events = events(); + + struct CharacterGenerator { + static constexpr std::optional event(int grauw_index) { + // TODO. + (void)grauw_index; + return std::nullopt; + } + }; + static constexpr auto character_events = events(); }; // Master System-specific storage.