From 9d99cc611569456f4dc75d0594c6d756d4f92392 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 12 Apr 2023 22:35:01 -0400 Subject: [PATCH] Fix external slot placement. --- Components/9918/Implementation/Fetch.hpp | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Components/9918/Implementation/Fetch.hpp b/Components/9918/Implementation/Fetch.hpp index a4bed98f7..d26df8e27 100644 --- a/Components/9918/Implementation/Fetch.hpp +++ b/Components/9918/Implementation/Fetch.hpp @@ -71,7 +71,7 @@ template void Base::dispatch(Seq #define index(n) \ if(use_end && end == n) return; \ [[fallthrough]]; \ - case n: fetcher.template fetch<(n + 171 - 16) % 171>(); + case n: fetcher.template fetch<(n + 171 - 16) % 171>(n); // `template fetch` call includes an in-place internal -> sync-aligned conversion for now, during transition. switch(start) { @@ -389,9 +389,9 @@ template struct RefreshSequencer { RefreshSequencer(Base *base) : base(base) {} - template void fetch() { + template void fetch(int c) { if(cycle < 26 || (cycle & 1) || cycle >= 154) { - base->do_external_slot(to_internal(cycle)); + base->do_external_slot(to_internal(c)); } } @@ -402,19 +402,19 @@ template struct TextSequencer { template TextSequencer(Args&&... args) : fetcher(std::forward(args)...) {} - template void fetch() { + template void fetch(int c) { // The first 30 and the final 4 slots are external. if constexpr (cycle < 30 || cycle >= 150) { - fetcher.base->do_external_slot(to_internal(cycle)); + fetcher.base->do_external_slot(to_internal(c)); return; } else { // For the 120 slots in between follow a three-step pattern of: constexpr int offset = cycle - 30; constexpr auto column = AddressT(offset / 3); switch(offset % 3) { - case 0: fetcher.fetch_name(column); break; // (1) fetch tile name. - case 1: fetcher.base->do_external_slot(to_internal(cycle)); break; // (2) external slot. - case 2: fetcher.fetch_pattern(column); break; // (3) fetch tile pattern. + case 0: fetcher.fetch_name(column); break; // (1) fetch tile name. + case 1: fetcher.base->do_external_slot(to_internal(c)); break; // (2) external slot. + case 2: fetcher.fetch_pattern(column); break; // (3) fetch tile pattern. } } } @@ -429,9 +429,9 @@ struct CharacterSequencer { character_fetcher(std::forward(args)...), sprite_fetcher(std::forward(args)...) {} - template void fetch() { + template void fetch(int c) { if(cycle < 5) { - character_fetcher.base->do_external_slot(to_internal(cycle)); + character_fetcher.base->do_external_slot(to_internal(c)); } if(cycle == 5) { @@ -442,7 +442,7 @@ struct CharacterSequencer { } if(cycle > 14 && cycle < 19) { - character_fetcher.base->do_external_slot(to_internal(cycle)); + character_fetcher.base->do_external_slot(to_internal(c)); } // Fetch 8 new sprite Y coordinates, to begin selecting sprites for next line. @@ -460,13 +460,13 @@ struct CharacterSequencer { case 0: character_fetcher.fetch_name(block); break; case 1: if(!(block & 3)) { - character_fetcher.base->do_external_slot(to_internal(cycle)); + character_fetcher.base->do_external_slot(to_internal(c)); } else { constexpr int sprite = 8 + ((block >> 2) * 3) + ((block & 3) - 1); sprite_fetcher.fetch_y(sprite); } break; - case 3: + case 2: character_fetcher.fetch_pattern(block); character_fetcher.fetch_colour(block); break; @@ -475,7 +475,7 @@ struct CharacterSequencer { } if(cycle >= 155 && cycle < 157) { - character_fetcher.base->do_external_slot(to_internal(cycle)); + character_fetcher.base->do_external_slot(to_internal(c)); } if(cycle == 157) { @@ -521,9 +521,9 @@ struct SMSSequencer { // Cf. https://www.smspower.org/forums/16485-GenesisMode4VRAMTiming with this implementation pegging // window 0 to HSYNC low. - template void fetch() { + template void fetch(int c) { if(cycle < 3) { - fetcher.base->do_external_slot(to_internal(cycle)); + fetcher.base->do_external_slot(to_internal(c)); } if(cycle == 3) { @@ -534,7 +534,7 @@ struct SMSSequencer { } if(cycle == 15 || cycle == 16) { - fetcher.base->do_external_slot(to_internal(cycle)); + fetcher.base->do_external_slot(to_internal(c)); } if(cycle == 17) { @@ -555,7 +555,7 @@ struct SMSSequencer { case 0: fetcher.fetch_tile_name(block); break; case 1: if(!(block & 3)) { - fetcher.base->do_external_slot(to_internal(cycle)); + fetcher.base->do_external_slot(to_internal(c)); } else { constexpr int sprite = (8 + ((block >> 2) * 3) + ((block & 3) - 1)) << 1; fetcher.posit_sprite(sprite); @@ -567,7 +567,7 @@ struct SMSSequencer { } if(cycle >= 153 && cycle < 157) { - fetcher.base->do_external_slot(to_internal(cycle)); + fetcher.base->do_external_slot(to_internal(c)); } if(cycle == 157) { @@ -578,7 +578,7 @@ struct SMSSequencer { } if(cycle >= 169) { - fetcher.base->do_external_slot(to_internal(cycle)); + fetcher.base->do_external_slot(to_internal(c)); } }