1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Detect mode 2 collisions, albeit without proper reporting.

This commit is contained in:
Thomas Harte 2023-02-25 10:42:44 -06:00
parent dd65074bbf
commit b948761f30
2 changed files with 25 additions and 7 deletions

View File

@ -111,8 +111,12 @@ void Base<personality>::draw_sprites(LineBuffer &buffer, int start, int end, int
LineBuffer::ActiveSprite &sprite = buffer.active_sprites[index];
for(int c = 0; c < 32; c+= 2) {
const int shift = (c >> 1) ^ 7;
Storage<personality>::sprite_cache_[index][c] = Storage<personality>::sprite_cache_[index][c + 1] =
sprite.image[2] & 0xf & sprite_colour_selection_masks[1 & (sprite.image[shift >> 3] >> (shift & 7))];
const int bit = 1 & (sprite.image[shift >> 3] >> (shift & 7));
Storage<personality>::sprite_cache_[index][c] =
Storage<personality>::sprite_cache_[index][c + 1] =
(sprite.image[2] & 0xf & sprite_colour_selection_masks[bit]) |
uint8_t((bit << StatusSpriteCollisionShift) & sprite.collision_bit());
}
}
} else {
@ -120,8 +124,11 @@ void Base<personality>::draw_sprites(LineBuffer &buffer, int start, int end, int
LineBuffer::ActiveSprite &sprite = buffer.active_sprites[index];
for(int c = 0; c < 16; c++) {
const int shift = c ^ 7;
const int bit = 1 & (sprite.image[shift >> 3] >> (shift & 7));
Storage<personality>::sprite_cache_[index][c] =
sprite.image[2] & 0xf & sprite_colour_selection_masks[1 & (sprite.image[shift >> 3] >> (shift & 7))];
(sprite.image[2] & 0xf & sprite_colour_selection_masks[bit]) |
uint8_t((bit << StatusSpriteCollisionShift) & sprite.collision_bit());
}
}
}
@ -163,12 +170,21 @@ void Base<personality>::draw_sprites(LineBuffer &buffer, int start, int end, int
for(int x = x1; x < x2; x++) {
const uint8_t colour = Storage<personality>::sprite_cache_[index][x];
// Plot colour, if visible.
if(colour) {
pixel_origin_[sprite.x + x] = palette()[colour];
pixel_origin_[sprite.x + x] = palette()[colour & 0xf];
}
// Accumulate collisions.
sprite_collision |= sprite_buffer[sprite.x + x];
sprite_buffer[sprite.x + x] |= colour;
// TODO: capture (x, y) if a collision has been spotted.
}
// TODO: collisions.
// Update collision bit.
status_ |= sprite_collision & StatusSpriteCollision;
}
return;

View File

@ -93,8 +93,10 @@ struct LineBuffer {
bool opaque() const {
return !(image[2] & 0x40);
}
bool noncollideable() const {
return image[2] & 0x20;
/// @returns @c 0x20 if this sprite should generate collisions; @c 0x00 otherwise.
int collision_bit() const {
return ((image[2] & 0x20) | ((image[2] & 0x40) >> 1)) ^ 0x20;
}
// Yamaha and TMS helpers.