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

Better judge when to rotate addresses.

This commit is contained in:
Thomas Harte 2023-03-08 18:27:59 -05:00
parent cc7b209e1a
commit 020d9604c6

View File

@ -280,9 +280,9 @@ template <Personality personality> struct Base: public Storage<personality> {
return AddressT((address >> 1) | (address << 16)) & memory_mask(personality); return AddressT((address >> 1) | (address << 16)) & memory_mask(personality);
} }
AddressT command_address(Vector location) const { AddressT command_address(Vector location, bool expansion) const {
if constexpr (is_yamaha_vdp(personality)) { if constexpr (is_yamaha_vdp(personality)) {
switch(this->screen_mode_) { switch(this->underlying_mode_) {
default: default:
case ScreenMode::YamahaGraphics4: // 256 pixels @ 4bpp case ScreenMode::YamahaGraphics4: // 256 pixels @ 4bpp
return AddressT( return AddressT(
@ -296,17 +296,23 @@ template <Personality personality> struct Base: public Storage<personality> {
(location.v[1] << 7) (location.v[1] << 7)
); );
case ScreenMode::YamahaGraphics6: // 512 pixels @ 4bpp case ScreenMode::YamahaGraphics6: { // 512 pixels @ 4bpp
return rotate(AddressT( const auto linear_address =
AddressT(
(location.v[0] >> 1) + (location.v[0] >> 1) +
(location.v[1] << 8) (location.v[1] << 8)
)); );
return expansion ? linear_address : rotate(linear_address);
}
case ScreenMode::YamahaGraphics7: // 256 pixels @ 8bpp case ScreenMode::YamahaGraphics7: { // 256 pixels @ 8bpp
return rotate(AddressT( const auto linear_address =
AddressT(
(location.v[0] >> 0) + (location.v[0] >> 0) +
(location.v[1] << 8) (location.v[1] << 8)
)); );
return expansion ? linear_address : rotate(linear_address);
}
} }
} else { } else {
return 0; return 0;
@ -385,14 +391,14 @@ template <Personality personality> struct Base: public Storage<personality> {
break; break;
case CommandStep::ReadSourcePixel: case CommandStep::ReadSourcePixel:
context.latched_colour.set(extract_colour(source[command_address(context.source)], context.source)); context.latched_colour.set(extract_colour(source[command_address(context.source, context.arguments & 0x10)], context.source));
Storage<personality>::minimum_command_column_ = access_column + 32; Storage<personality>::minimum_command_column_ = access_column + 32;
Storage<personality>::next_command_step_ = CommandStep::ReadDestinationPixel; Storage<personality>::next_command_step_ = CommandStep::ReadDestinationPixel;
break; break;
case CommandStep::ReadDestinationPixel: case CommandStep::ReadDestinationPixel:
Storage<personality>::command_latch_ = source[command_address(context.destination)]; Storage<personality>::command_latch_ = source[command_address(context.destination, context.arguments & 0x20)];
Storage<personality>::minimum_command_column_ = access_column + 24; Storage<personality>::minimum_command_column_ = access_column + 24;
Storage<personality>::next_command_step_ = CommandStep::WritePixel; Storage<personality>::next_command_step_ = CommandStep::WritePixel;
@ -400,7 +406,7 @@ template <Personality personality> struct Base: public Storage<personality> {
case CommandStep::WritePixel: { case CommandStep::WritePixel: {
const auto [mask, unmasked_colour] = command_colour_mask(context.destination); const auto [mask, unmasked_colour] = command_colour_mask(context.destination);
const auto address = command_address(context.destination); const auto address = command_address(context.destination, context.arguments & 0x20);
const uint8_t colour = unmasked_colour & mask; const uint8_t colour = unmasked_colour & mask;
context.latched_colour.reset(); context.latched_colour.reset();
@ -435,14 +441,14 @@ template <Personality personality> struct Base: public Storage<personality> {
} break; } break;
case CommandStep::ReadSourceByte: case CommandStep::ReadSourceByte:
context.latched_colour.set(source[command_address(context.source)]); context.latched_colour.set(source[command_address(context.source, context.arguments & 0x10)]);
Storage<personality>::minimum_command_column_ = access_column + 24; Storage<personality>::minimum_command_column_ = access_column + 24;
Storage<personality>::next_command_step_ = CommandStep::WriteByte; Storage<personality>::next_command_step_ = CommandStep::WriteByte;
break; break;
case CommandStep::WriteByte: case CommandStep::WriteByte:
destination[command_address(context.destination)] = context.latched_colour.has_value() ? context.latched_colour.colour : context.colour.colour; destination[command_address(context.destination, context.arguments & 0x20)] = context.latched_colour.has_value() ? context.latched_colour.colour : context.colour.colour;
context.latched_colour.reset(); context.latched_colour.reset();
Storage<personality>::command_->advance(pixels_per_byte(this->underlying_mode_)); Storage<personality>::command_->advance(pixels_per_byte(this->underlying_mode_));