1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-17 02:30:54 +00:00

Just do a multiply and divide. Easy.

This commit is contained in:
Thomas Harte 2023-01-21 14:19:52 -05:00
parent c9643c4145
commit d1f929e6f7

View File

@ -844,10 +844,9 @@ void Base<personality>::write_palette(uint8_t value) {
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;
const uint8_t r = ((Storage<personality>::new_colour_ >> 4) & 7) * 255 / 7;
const uint8_t g = (value & 7) * 255 / 7;
const uint8_t b = (Storage<personality>::new_colour_ & 7) * 255 / 7;
Storage<personality>::palette_[Storage<personality>::palette_entry_ & 0xf] = palette_pack(r, g, b);
++Storage<personality>::palette_entry_;