1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Add named getters, resolving composition bug.

This commit is contained in:
Thomas Harte 2023-02-25 10:32:47 -06:00
parent 9debed25e8
commit dd65074bbf
3 changed files with 19 additions and 6 deletions

View File

@ -96,7 +96,7 @@ void Base<personality>::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<personality>::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<personality>::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<personality>::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;
}

View File

@ -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];

View File

@ -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.