1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-26 10:29:31 +00:00

Realign fetching.

This commit is contained in:
Thomas Harte 2023-04-23 21:16:04 -04:00
parent 96896f838c
commit e5b0e666cc
2 changed files with 3 additions and 14 deletions

View File

@ -71,8 +71,7 @@ template<bool use_end, typename SequencerT> void Base<personality>::dispatch(Seq
#define index(n) \
if(use_end && end == n) return; \
[[fallthrough]]; \
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.
case n: fetcher.template fetch<n>(n);
switch(start) {
default: assert(false);

View File

@ -216,20 +216,10 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
}
private:
// This emulator treats position 0 as being immediately after the standard pixel area.
// i.e. offset 1282 on Grauw's http://map.grauw.nl/articles/vdp-vram-timing/vdp-timing.png
static constexpr int ZeroAsGrauwIndex = 1282;
constexpr static int grauw_to_internal(int offset) {
return (offset + 1368 - ZeroAsGrauwIndex) % 1368;
}
constexpr static int internal_to_grauw(int offset) {
return (offset + ZeroAsGrauwIndex) % 1368;
}
template <typename GeneratorT> static constexpr size_t events_size() {
size_t size = 0;
for(int c = 0; c < 1368; c++) {
const auto event_type = GeneratorT::event(internal_to_grauw(c));
const auto event_type = GeneratorT::event(c);
size += event_type.has_value();
}
return size + 1;
@ -240,7 +230,7 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
std::array<Event, size> result{};
size_t index = 0;
for(int c = 0; c < 1368; c++) {
const auto event = GeneratorT::event(internal_to_grauw(c));
const auto event = GeneratorT::event(c);
if(!event) {
continue;
}