mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-26 15:32:04 +00:00
Sprite mode 2: select sprites, fetch locations and names.
This commit is contained in:
parent
7aa8728b39
commit
5eae11434a
@ -151,11 +151,17 @@ struct CharacterFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
void fetch_sprite_location(int sprite) {
|
||||
template <bool fetch_name = false> 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<ScreenMode mode> void Base<personality>::fetch_yamaha(LineBuffer &line_
|
||||
|
||||
case Type::SpriteY:
|
||||
switch(mode) {
|
||||
case ScreenMode::Graphics:
|
||||
case ScreenMode::MultiColour:
|
||||
case ScreenMode::ColouredText:
|
||||
character_fetcher.posit_sprite(Storage<personality>::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<personality>::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<personality>::next_event_->id);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
default:
|
||||
character_fetcher.template fetch_sprite_location<true>(Storage<personality>::next_event_->id, 0);
|
||||
character_fetcher.template fetch_sprite_location<true>(Storage<personality>::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:
|
||||
|
@ -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];
|
||||
|
||||
|
@ -279,7 +279,7 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
|
||||
};
|
||||
static constexpr auto refresh_events = events<RefreshGenerator>();
|
||||
|
||||
template <bool include_sprites> struct BitmapEventsGenerator {
|
||||
template <bool include_sprites> struct BitmapGenerator {
|
||||
static constexpr std::optional<Event> event(int grauw_index) {
|
||||
if(!include_sprites) {
|
||||
// Various standard zones of one-every-eight external slots.
|
||||
@ -297,10 +297,14 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
|
||||
// There's also a corresponding number of extra external slots to spell out.
|
||||
switch(grauw_index) {
|
||||
default: break;
|
||||
case 1238: case 1302: case 2: case 66:
|
||||
return Event::Type::SpriteLocation;
|
||||
case 1270: case 1338: case 34: case 98:
|
||||
return Event::Type::SpritePattern;
|
||||
case 1238: return Event(Event::Type::SpriteLocation, 0);
|
||||
case 1302: return Event(Event::Type::SpriteLocation, 2);
|
||||
case 2: return Event(Event::Type::SpriteLocation, 4);
|
||||
case 66: return Event(Event::Type::SpriteLocation, 6);
|
||||
case 1270: return Event(Event::Type::SpritePattern, 0);
|
||||
case 1338: return Event(Event::Type::SpritePattern, 2);
|
||||
case 34: return Event(Event::Type::SpritePattern, 4);
|
||||
case 98: return Event(Event::Type::SpritePattern, 6);
|
||||
case 1264: case 1330: case 28: case 92:
|
||||
return Event::Type::External;
|
||||
}
|
||||
@ -352,8 +356,8 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
|
||||
return std::nullopt;
|
||||
}
|
||||
};
|
||||
static constexpr auto no_sprites_events = events<BitmapEventsGenerator<false>>();
|
||||
static constexpr auto sprites_events = events<BitmapEventsGenerator<true>>();
|
||||
static constexpr auto no_sprites_events = events<BitmapGenerator<false>>();
|
||||
static constexpr auto sprites_events = events<BitmapGenerator<true>>();
|
||||
|
||||
struct TextGenerator {
|
||||
static constexpr std::optional<Event> event(int grauw_index) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user