diff --git a/Components/9918/Implementation/Fetch.hpp b/Components/9918/Implementation/Fetch.hpp index d476c98df..5f746b2d7 100644 --- a/Components/9918/Implementation/Fetch.hpp +++ b/Components/9918/Implementation/Fetch.hpp @@ -151,11 +151,17 @@ struct CharacterFetcher { } } - void fetch_sprite_location(int sprite) { + template void fetch_sprite_location(int sprite, [[maybe_unused]] int name_slot = 0) { tile_buffer.active_sprites[sprite].x = base->ram_[ base->sprite_attribute_table_address_ & bits<7>(AddressT((tile_buffer.active_sprites[sprite].index << 2) | 1)) ]; + + if constexpr (fetch_name) { + base->name_[name_slot] = base->ram_[ + base->sprite_attribute_table_address_ & bits<7>(AddressT((tile_buffer.active_sprites[sprite].index << 2) | 2)) + ] & (base->sprites_16x16_ ? ~3 : ~0); + } } void fetch_sprite_pattern(int sprite) { @@ -614,30 +620,47 @@ template void Base::fetch_yamaha(LineBuffer &line_ case Type::SpriteY: switch(mode) { - case ScreenMode::Graphics: - case ScreenMode::MultiColour: - case ScreenMode::ColouredText: - character_fetcher.posit_sprite(Storage::next_event_->id); + case ScreenMode::Blank: + case ScreenMode::Text: + case ScreenMode::YamahaText80: + // Ensure the compiler can discard character_fetcher in these modes. break; - default: break; + default: + character_fetcher.posit_sprite(Storage::next_event_->id); + break; } break; case Type::SpriteLocation: switch(mode) { + case ScreenMode::Blank: + case ScreenMode::Text: + case ScreenMode::YamahaText80: + // Ensure the compiler can discard character_fetcher in these modes. + break; + case ScreenMode::Graphics: case ScreenMode::MultiColour: case ScreenMode::ColouredText: character_fetcher.fetch_sprite_location(Storage::next_event_->id); break; - default: break; + default: + character_fetcher.template fetch_sprite_location(Storage::next_event_->id, 0); + character_fetcher.template fetch_sprite_location(Storage::next_event_->id + 1, 1); + break; } break; case Type::SpritePattern: switch(mode) { + case ScreenMode::Blank: + case ScreenMode::Text: + case ScreenMode::YamahaText80: + // Ensure the compiler can discard character_fetcher in these modes. + break; + case ScreenMode::Graphics: case ScreenMode::MultiColour: case ScreenMode::ColouredText: diff --git a/Components/9918/Implementation/LineBuffer.hpp b/Components/9918/Implementation/LineBuffer.hpp index a16b66e72..f2d4ad0eb 100644 --- a/Components/9918/Implementation/LineBuffer.hpp +++ b/Components/9918/Implementation/LineBuffer.hpp @@ -82,6 +82,11 @@ struct LineBuffer { int x = 0; // The sprite's x position on screen. uint8_t image[4]; // Up to four bytes of image information. + // + // In practice: + // + // Master System mode: the four bytes of this 8x8 sprite; + // TMS and Yamaha: [0] = the left half of this sprite; [1] = the right side (if 16x16 sprites enabled); [2] = colour, early-clock bit, etc. int shift_position = 0; // An offset representing how much of the image information has already been drawn. } active_sprites[8]; diff --git a/Components/9918/Implementation/Storage.hpp b/Components/9918/Implementation/Storage.hpp index bb27678ba..d82aabe04 100644 --- a/Components/9918/Implementation/Storage.hpp +++ b/Components/9918/Implementation/Storage.hpp @@ -279,7 +279,7 @@ template struct Storage(); - template struct BitmapEventsGenerator { + template struct BitmapGenerator { static constexpr std::optional event(int grauw_index) { if(!include_sprites) { // Various standard zones of one-every-eight external slots. @@ -297,10 +297,14 @@ template struct Storage struct Storage>(); - static constexpr auto sprites_events = events>(); + static constexpr auto no_sprites_events = events>(); + static constexpr auto sprites_events = events>(); struct TextGenerator { static constexpr std::optional event(int grauw_index) {