mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Corrects sprite information collection to cover all four.
This commit is contained in:
parent
38b11893e8
commit
ad3df36c20
@ -141,17 +141,20 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
||||
// Then ten access windows are filled with collection of sprite 3 and 4 details.
|
||||
if(access_pointer_ >= 4 && access_pointer_ < 14) {
|
||||
// TODO: this repeats the code below.
|
||||
while(access_pointer_ < access_slot) {
|
||||
const int target = 2 + (access_pointer_ - 4) / 6;
|
||||
int end = std::min(14, access_slot);
|
||||
while(access_pointer_ < end) {
|
||||
const int offset = access_pointer_ - 2;
|
||||
const int target = 2 + (offset / 6);
|
||||
const int sprite = active_sprites_[target] & 31;
|
||||
const int subcycle = access_pointer_ % 6;
|
||||
const int subcycle = offset % 6;
|
||||
// printf("%d: %d %d\n", access_pointer_, target, subcycle);
|
||||
switch(subcycle) {
|
||||
case 2: sprites_[target].y = ram_[sprite_attribute_table_address_ + (sprite << 2)]; break;
|
||||
case 3: sprites_[target].x = ram_[sprite_attribute_table_address_ + (sprite << 2) + 1]; break;
|
||||
case 4: sprites_[target].pattern_number = ram_[sprite_attribute_table_address_ + (sprite << 2) + 2]; break;
|
||||
case 5: sprites_[target].colour = ram_[sprite_attribute_table_address_ + (sprite << 2) + 3]; break;
|
||||
case 0:
|
||||
case 1: {
|
||||
case 0: sprites_[target].y = ram_[sprite_attribute_table_address_ + (sprite << 2)]; break;
|
||||
case 1: sprites_[target].x = ram_[sprite_attribute_table_address_ + (sprite << 2) + 1]; break;
|
||||
case 2: sprites_[target].pattern_number = ram_[sprite_attribute_table_address_ + (sprite << 2) + 2]; break;
|
||||
case 3: sprites_[target].colour = ram_[sprite_attribute_table_address_ + (sprite << 2) + 3]; break;
|
||||
case 4:
|
||||
case 5: {
|
||||
const int sprite_offset = sprites_[target].pattern_number & ~(sprites_16x16_ ? 3 : 0);
|
||||
const int sprite_row = (row_ - sprites_[target].y) & 15;
|
||||
const int sprite_address =
|
||||
@ -208,7 +211,7 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
||||
break;
|
||||
const int sprite = slot - (slot >> 2) + 8;
|
||||
sprite_locations_[sprite] = ram_[sprite_attribute_table_address_ + (sprite << 2)];
|
||||
} break; // TODO: sprites / CPU access.
|
||||
} break;
|
||||
case 0:
|
||||
if(screen_mode_ != 1) {
|
||||
colour_buffer_[character_column] = ram_[colour_base + (pattern_name_ >> 3)];
|
||||
@ -236,8 +239,8 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
||||
if(sprite_locations_[c] == 208) break;
|
||||
|
||||
// Skip sprite if invisible anyway.
|
||||
int ranged_location = ((static_cast<int>(sprite_locations_[c]) + sprite_height) & 255) - sprite_height;
|
||||
if(ranged_location > row_ || ranged_location + sprite_height < row_) continue;
|
||||
int offset = (row_ - sprite_locations_[c])&255;
|
||||
if(offset < 0 || offset >= sprite_height) continue;
|
||||
|
||||
last_visible = c;
|
||||
if(slot < 4) {
|
||||
@ -264,10 +267,12 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
||||
|
||||
// Fourteen access windows: collect initial sprite information.
|
||||
if(access_pointer_ >= 156 && access_pointer_ < 170) {
|
||||
while(access_pointer_ < access_slot) {
|
||||
int end = std::min(170, access_slot);
|
||||
while(access_pointer_ < end) {
|
||||
const int target = (access_pointer_ - 156) / 6;
|
||||
const int sprite = active_sprites_[target] & 31;
|
||||
const int subcycle = access_pointer_ % 6;
|
||||
// printf("%d: %d %d\n", access_pointer_, target, subcycle);
|
||||
switch(subcycle) {
|
||||
case 0: sprites_[target].y = ram_[sprite_attribute_table_address_ + (sprite << 2)]; break;
|
||||
case 1: sprites_[target].x = ram_[sprite_attribute_table_address_ + (sprite << 2) + 1]; break;
|
||||
@ -286,7 +291,8 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
||||
}
|
||||
}
|
||||
|
||||
// There's another unused access window here.
|
||||
// There's a single unused access window here.
|
||||
access_pointer_ = std::min(171, access_slot);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -368,7 +374,8 @@ void TMS9918::run_for(const HalfCycles cycles) {
|
||||
if(output_column_ == first_right_border_column_) {
|
||||
// Just chuck the sprites on. Quick hack!
|
||||
for(size_t c = 0; c < 4; ++c) {
|
||||
if(active_sprites_[c^3] == 255) continue;
|
||||
if(active_sprites_[c^3] == 0xff) continue;
|
||||
if(!(sprites_[c^3].colour&15)) continue;
|
||||
for(int p = 0; p < (sprites_16x16_ ? 16 : 8); ++p) {
|
||||
int x = sprites_[c^3].x + p;
|
||||
if(sprites_[c^3].colour & 0x80) x -= 32;
|
||||
|
Loading…
x
Reference in New Issue
Block a user