From dce04e72196f3224e488d563fc10d25a0b29a081 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 12 Feb 2023 22:54:08 -0500 Subject: [PATCH] Add a generator for character modes. --- Components/9918/Implementation/Storage.hpp | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Components/9918/Implementation/Storage.hpp b/Components/9918/Implementation/Storage.hpp index 7e0c11149..f5e0c32ee 100644 --- a/Components/9918/Implementation/Storage.hpp +++ b/Components/9918/Implementation/Storage.hpp @@ -60,12 +60,16 @@ template struct Storage struct Storage struct Storage event(int grauw_index) { - // TODO. - (void)grauw_index; + // Grab sprite events. + switch(grauw_index) { + default: break; + case 1242: case 1306: case 6: case 70: return Event::Type::SpriteLocation; + case 1274: case 1342: case 38: case 102: return Event::Type::SpritePattern; + case 1268: case 1334: case 32: case 96: return Event::Type::External; + } + + if(grauw_index >= 166 && grauw_index < 180) { + return StandardGenerators::external_every_eight(grauw_index - 166); + } + + if(grauw_index >= 182 && grauw_index < 1236) { + const int offset = grauw_index - 182; + const int block = offset / 32; + const int sub_block = offset & 31; + switch(sub_block) { + case 0: if(block > 0) return Event::Type::Name; + case 6: if((sub_block & 3) != 3) return Event::Type::External;; + case 12: if(block > 0) return Event::Type::Pattern; + case 18: if(block > 0) return Event::Type::Colour; + } + } + return std::nullopt; } };