From a5765abbada1b67b3c79161195eddd40a8655816 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 21 Jan 2023 22:47:16 -0500 Subject: [PATCH] Route into the Yamaha fetcher. Albeit that it doesn't yet fetch. --- Components/9918/Implementation/9918.cpp | 46 ++++++++++++++++----- Components/9918/Implementation/9918Base.hpp | 7 ++-- Components/9918/Implementation/Fetch.hpp | 8 +--- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 70abeaf69..28ff48d5a 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -200,25 +200,51 @@ void TMS9918::run_for(const HalfCycles cycles) { // ------------------------ // Perform memory accesses. // ------------------------ -#define fetch(function, clock) \ +#define fetch(function_true, function_false, clock) { \ const int first_window = from_internal(this->fetch_pointer_.column);\ const int final_window = from_internal(end_column); \ if(first_window == final_window) break; \ if(final_window != clock_rate()) { \ - function(first_window, final_window); \ + function_true(first_window, final_window); \ } else { \ - function(first_window, final_window); \ - } + function_false(first_window, final_window); \ + } \ +} + +#define fetch_simple(function, clock) fetch(function, function, clock) switch(line_buffer.line_mode) { - case LineMode::Text: { fetch(this->template fetch_tms_text, Clock::TMSMemoryWindow); } break; - case LineMode::Character: { fetch(this->template fetch_tms_character, Clock::TMSMemoryWindow); } break; - case LineMode::SMS: { fetch(this->template fetch_sms, Clock::TMSMemoryWindow); } break; - case LineMode::Refresh: { fetch(this->template fetch_tms_refresh, Clock::TMSMemoryWindow); } break; + case LineMode::Text: fetch_simple(this->template fetch_tms_text, Clock::TMSMemoryWindow); break; + case LineMode::Character: fetch_simple(this->template fetch_tms_character, Clock::TMSMemoryWindow); break; + case LineMode::SMS: fetch_simple(this->template fetch_sms, Clock::TMSMemoryWindow); break; + case LineMode::Refresh: fetch_simple(this->template fetch_tms_refresh, Clock::TMSMemoryWindow); break; + + case LineMode::Yamaha: +#define true_func this->template fetch_yamaha +#define false_func this->template fetch_yamaha + fetch( + true_func, + false_func, + Clock::Internal); +#undef true_func +#undef false_func + break; +#define true_func this->template fetch_yamaha +#define false_func this->template fetch_yamaha + case LineMode::YamahaNoSprites: + fetch( + true_func, + false_func, + Clock::Internal); +#undef true_func +#undef false_func + break; } +#undef fetch_simple #undef fetch + // TODO: the above is too macro-heavy. Simplify. // ------------------------------- @@ -290,8 +316,8 @@ void TMS9918::run_for(const HalfCycles cycles) { case ScreenMode::YamahaGraphics5: case ScreenMode::YamahaGraphics6: case ScreenMode::YamahaGraphics7: - // TODO: actual line modes. - next_line_buffer.line_mode = LineMode::Refresh; + // TODO: sprites? + next_line_buffer.line_mode = LineMode::YamahaNoSprites; break; default: // This covers both MultiColour and Graphics modes. diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 7b6b4c500..9b1343081 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -57,7 +57,9 @@ enum class LineMode { Text, Character, Refresh, - SMS + SMS, + Yamaha, + YamahaNoSprites, }; enum class MemoryAccess { @@ -459,8 +461,7 @@ template struct Base: public Storage { template void fetch_tms_character(int start, int end); template void fetch_yamaha_refresh(int start, int end); - template void fetch_yamaha_no_sprites(int start, int end); - template void fetch_yamaha_sprites(int start, int end); + template void fetch_yamaha(int start, int end); template void fetch_sms(int start, int end); diff --git a/Components/9918/Implementation/Fetch.hpp b/Components/9918/Implementation/Fetch.hpp index cf987a67c..537fc492b 100644 --- a/Components/9918/Implementation/Fetch.hpp +++ b/Components/9918/Implementation/Fetch.hpp @@ -479,13 +479,7 @@ template void Base::fetch_yamaha_refresh(int start, i } template -template void Base::fetch_yamaha_no_sprites(int start, int end) { - (void)start; - (void)end; -} - -template -template void Base::fetch_yamaha_sprites(int start, int end) { +template void Base::fetch_yamaha(int start, int end) { (void)start; (void)end; }