1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-12 15:31:09 +00:00

Corrects off-by-one error in line fetching coroutines.

This commit is contained in:
Thomas Harte 2018-10-16 21:36:31 -04:00
parent 58ca74c68a
commit 1fc88c4eff
2 changed files with 18 additions and 15 deletions

View File

@ -721,21 +721,24 @@ void Base::draw_tms_character(int start, int end) {
// Draw all sprites into the sprite buffer.
const int shift_advance = sprites_magnified_ ? 1 : 2;
const int shifter_target = sprites_16x16_ ? 32 : 16;
for(int index = line_buffer.active_sprite_slot - 1; index >= 0; --index) {
LineBuffer::ActiveSprite &sprite = line_buffer.active_sprites[index];
const int shifter_target = sprites_16x16_ ? 32 : 16;
if(sprite.shift_position < shifter_target) {
const int pixel_start = std::max(start, sprite.x);
for(int c = pixel_start; c < end && sprite.shift_position < shifter_target; ++c) {
const int shift = (sprite.shift_position >> 1) ^ 7;
int sprite_colour = (sprite.image[shift >> 3] >> (shift & 7)) & 1;
// A colision is detected regardless of sprite colour ...
sprite_collision |= sprite_buffer[c] & sprite_colour;
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];
pixel_origin_[c] =
(pixel_origin_[c] & sprite_colour_selection_masks[sprite_colour^1]) | (palette[sprite.image[2]&15] & sprite_colour_selection_masks[sprite_colour]);
(pixel_origin_[c] & sprite_colour_selection_masks[sprite_colour^1]) |
(palette[sprite.image[2]&15] & sprite_colour_selection_masks[sprite_colour]);
sprite.shift_position += shift_advance;
}

View File

@ -359,7 +359,7 @@ class Base {
*/
#define slot(n) \
if(use_end && end+1 == n) return;\
if(use_end && end == n) return;\
case n
#define external_slot(n) \
@ -534,21 +534,21 @@ class Base {
line_buffer.patterns[column][0] = ram_[(pattern_base + static_cast<size_t>(line_buffer.names[column].offset << 3)) & 0x3fff]; \
}
#define background_fetch_block(location, column) \
#define background_fetch_block(location, column, sprite) \
slot(location): fetch_tile_name(column) \
external_slot(location+1); \
slot(location+2): \
slot(location+3): fetch_tile(column) \
slot(location+4): fetch_tile_name(column+1) \
sprite_y_read(location+5, column+8); \
sprite_y_read(location+5, sprite); \
slot(location+6): \
slot(location+7): fetch_tile(column+1) \
slot(location+8): fetch_tile_name(column+2) \
sprite_y_read(location+9, column+9); \
sprite_y_read(location+9, sprite+1); \
slot(location+10): \
slot(location+11): fetch_tile(column+2) \
slot(location+12): fetch_tile_name(column+3) \
sprite_y_read(location+13, column+10); \
sprite_y_read(location+13, sprite+2); \
slot(location+14): \
slot(location+15): fetch_tile(column+3)
@ -605,14 +605,14 @@ class Base {
sprite_y_read(41, 6);
sprite_y_read(42, 7);
background_fetch_block(43, 0);
background_fetch_block(59, 4);
background_fetch_block(75, 8);
background_fetch_block(91, 12);
background_fetch_block(107, 16);
background_fetch_block(123, 20);
background_fetch_block(139, 24);
background_fetch_block(155, 28);
background_fetch_block(43, 0, 8);
background_fetch_block(59, 4, 11);
background_fetch_block(75, 8, 14);
background_fetch_block(91, 12, 17);
background_fetch_block(107, 16, 20);
background_fetch_block(123, 20, 23);
background_fetch_block(139, 24, 26);
background_fetch_block(155, 28, 29);
return;
}