1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-26 15:32:04 +00:00

Catch and map Yamaha palette entries.

It's one less thing in the uncaptured log.
This commit is contained in:
Thomas Harte 2023-01-21 14:12:46 -05:00
parent a726c9d97a
commit e289e6e757
2 changed files with 31 additions and 5 deletions

View File

@ -554,8 +554,9 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
reg &= 0x7;
}
// This is a write to a register; handle all generic
// TMS registers here (with potential extra bits).
//
// Generic TMS functionality.
//
switch(reg) {
case 0:
mode2_enable_ = value & 0x02;
@ -602,6 +603,9 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
default: break;
}
//
// Sega extensions.
//
if constexpr (is_sega_vdp(personality)) {
switch(reg) {
default: break;
@ -641,6 +645,9 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
}
}
//
// Yamaha extensions.
//
if constexpr (is_yamaha_vdp(personality)) {
switch(reg) {
default: break;
@ -705,7 +712,7 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
break;
case 16:
LOG("TODO: Yamaha palette index selection; " << PADHEX(2) << +value);
Storage<personality>::palette_entry_ = value;
// b0b3: palette entry for writing on port 2; autoincrements upon every write.
break;
@ -828,8 +835,23 @@ void Base<personality>::write_register(uint8_t value) {
template <Personality personality>
void Base<personality>::write_palette(uint8_t value) {
LOG("Palette write TODO");
(void)value;
if constexpr (is_yamaha_vdp(personality)) {
if(!write_phase_) {
Storage<personality>::new_colour_ = value;
write_phase_ = true;
return;
}
write_phase_ = false;
// TODO: the below scales the palette into the range 0252 rather than 0255; correct.
const uint8_t r = ((Storage<personality>::new_colour_ >> 4) & 7) * 36;
const uint8_t g = (value & 7) * 36;
const uint8_t b = (Storage<personality>::new_colour_ & 7) * 36;
Storage<personality>::palette_[Storage<personality>::palette_entry_ & 0xf] = palette_pack(r, g, b);
++Storage<personality>::palette_entry_;
}
}
template <Personality personality>

View File

@ -131,6 +131,10 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
int indirect_register_ = 0;
bool increment_indirect_register_ = false;
uint32_t palette_[16]{};
uint8_t new_colour_ = 0;
uint8_t palette_entry_ = 0;
};
// Master System-specific storage.