diff --git a/Components/9918/Implementation/Draw.hpp b/Components/9918/Implementation/Draw.hpp index 3f0fe6e0c..c44f41240 100644 --- a/Components/9918/Implementation/Draw.hpp +++ b/Components/9918/Implementation/Draw.hpp @@ -96,7 +96,7 @@ void Base::draw_sprites(LineBuffer &buffer, int start, int end, int // Determine the lowest visible sprite; exit early if that leaves no sprites visible. for(; min_sprite < buffer.active_sprite_slot; min_sprite++) { LineBuffer::ActiveSprite &sprite = buffer.active_sprites[min_sprite]; - if(!(sprite.image[2]&0x40)) { + if(sprite.opaque()) { break; } } @@ -129,7 +129,7 @@ void Base::draw_sprites(LineBuffer &buffer, int start, int end, int // Go backwards compositing any sprites that are set as OR masks onto their parents. for(int index = buffer.active_sprite_slot - 1; index >= min_sprite + 1; --index) { LineBuffer::ActiveSprite &sprite = buffer.active_sprites[index]; - if(!(sprite.image[2] & 0x40)) { + if(sprite.opaque()) { continue; } @@ -148,7 +148,7 @@ void Base::draw_sprites(LineBuffer &buffer, int start, int end, int } // If a previous opaque sprite has been found, stop. - if(previous.image[2] & 0x40) { + if(previous.opaque()) { break; } } @@ -191,11 +191,11 @@ void Base::draw_sprites(LineBuffer &buffer, int start, int end, int sprite_buffer[c] |= sprite_colour; // ... but a sprite with the transparent colour won't actually be visible. - sprite_colour &= colour_masks[sprite.image[2]&15]; + sprite_colour &= colour_masks[sprite.image[2] & 0xf]; pixel_origin_[c] = (pixel_origin_[c] & sprite_colour_selection_masks[sprite_colour^1]) | - (palette()[sprite.image[2]&15] & sprite_colour_selection_masks[sprite_colour]); + (palette()[sprite.image[2] & 0xf] & sprite_colour_selection_masks[sprite_colour]); sprite.shift_position += shift_advance; } diff --git a/Components/9918/Implementation/Fetch.hpp b/Components/9918/Implementation/Fetch.hpp index 67d31a4dd..6141158c7 100644 --- a/Components/9918/Implementation/Fetch.hpp +++ b/Components/9918/Implementation/Fetch.hpp @@ -281,7 +281,7 @@ class SpriteFetcher { } break; } sprite.image[2] = colour; - sprite.x -= (colour & 0x80) >> 2; + sprite.x -= sprite.early_clock(); const AddressT graphic_location = base->sprite_generator_table_address_ & bits<11>(AddressT((name << 3) | sprite.row)); sprite.image[0] = base->ram_[graphic_location]; diff --git a/Components/9918/Implementation/LineBuffer.hpp b/Components/9918/Implementation/LineBuffer.hpp index f2d4ad0eb..3a32b70ec 100644 --- a/Components/9918/Implementation/LineBuffer.hpp +++ b/Components/9918/Implementation/LineBuffer.hpp @@ -88,6 +88,19 @@ struct LineBuffer { // 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. + + // Yamaha helpers. + bool opaque() const { + return !(image[2] & 0x40); + } + bool noncollideable() const { + return image[2] & 0x20; + } + + // Yamaha and TMS helpers. + int early_clock() const { + return (image[2] & 0x80) >> 2; + } } active_sprites[8]; int active_sprite_slot = 0; // A pointer to the slot into which a new active sprite will be deposited, if required.