1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-19 23:29:05 +00:00

Elucidate a magic constant, add an extra constexpr.

This commit is contained in:
Thomas Harte 2023-01-07 09:10:41 -05:00
parent 4875148617
commit de45536b5c
2 changed files with 32 additions and 31 deletions

View File

@ -756,13 +756,12 @@ bool TMS9918<personality>::get_interrupt_line() const {
}
// TODO: [potentially] remove Master System timing assumptions in latch and get_latched below.
template <Personality personality>
uint8_t TMS9918<personality>::get_latched_horizontal_counter() const {
template <Personality personality>uint8_t TMS9918<personality>::get_latched_horizontal_counter() const {
// Translate from internal numbering, which puts pixel output
// in the final 256 pixels of 342, to the public numbering,
// which makes the 256 pixels the first 256 spots, but starts
// which counts the 256 pixels as items 0255, starts
// counting at -48, and returns only the top 8 bits of the number.
int public_counter = this->latched_column_ - 86;
int public_counter = this->latched_column_ - (342 - 256);
if(public_counter < -46) public_counter += 342;
return uint8_t(public_counter >> 1);
}

View File

@ -349,6 +349,7 @@ template <Personality personality> struct Base {
default: return;
case MemoryAccess::Write:
if constexpr (is_sega_vdp(personality)) {
if(master_system_.cram_is_selected) {
// Adjust the palette. In a Master System blue has a slightly different
// scale; cf. https://www.retrorgb.com/sega-master-system-non-linear-blue-channel-findings.html
@ -377,9 +378,10 @@ template <Personality personality> struct Base {
dot.location.column %= 342;
dot.value = master_system_.colour_ram[ram_pointer_ & 0x1f];
} else {
ram_[ram_pointer_ & 16383] = read_ahead_buffer_;
break;
}
}
ram_[ram_pointer_ & 16383] = read_ahead_buffer_;
break;
case MemoryAccess::Read:
read_ahead_buffer_ = ram_[ram_pointer_ & 16383];