diff options
Diffstat (limited to 'src/mame/video/tp84.cpp')
-rw-r--r-- | src/mame/video/tp84.cpp | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/src/mame/video/tp84.cpp b/src/mame/video/tp84.cpp index d6534f36e43..14a64748c89 100644 --- a/src/mame/video/tp84.cpp +++ b/src/mame/video/tp84.cpp @@ -43,60 +43,56 @@ 220 ohm 100 ohm */ -PALETTE_INIT_MEMBER(tp84_state, tp84) +void tp84_state::tp84_palette(palette_device &palette) const { const uint8_t *color_prom = memregion("proms")->base(); - static const int resistances[4] = { 1000, 470, 220, 100 }; - double weights[4]; - int i; + static constexpr int resistances[4] = { 1000, 470, 220, 100 }; - /* compute the color output resistor weights */ + // compute the color output resistor weights + double weights[4]; compute_resistor_weights(0, 255, -1.0, 4, resistances, weights, 470, 0, 0, nullptr, nullptr, 0, 0, 0, nullptr, nullptr, 0, 0); - /* create a lookup table for the palette */ - for (i = 0; i < 0x100; i++) + // create a lookup table for the palette + for (int i = 0; i < 0x100; i++) { int bit0, bit1, bit2, bit3; - int r, g, b; - - /* red component */ - bit0 = (color_prom[i + 0x000] >> 0) & 0x01; - bit1 = (color_prom[i + 0x000] >> 1) & 0x01; - bit2 = (color_prom[i + 0x000] >> 2) & 0x01; - bit3 = (color_prom[i + 0x000] >> 3) & 0x01; - r = combine_4_weights(weights, bit0, bit1, bit2, bit3); - - /* green component */ - bit0 = (color_prom[i + 0x100] >> 0) & 0x01; - bit1 = (color_prom[i + 0x100] >> 1) & 0x01; - bit2 = (color_prom[i + 0x100] >> 2) & 0x01; - bit3 = (color_prom[i + 0x100] >> 3) & 0x01; - g = combine_4_weights(weights, bit0, bit1, bit2, bit3); - - /* blue component */ - bit0 = (color_prom[i + 0x200] >> 0) & 0x01; - bit1 = (color_prom[i + 0x200] >> 1) & 0x01; - bit2 = (color_prom[i + 0x200] >> 2) & 0x01; - bit3 = (color_prom[i + 0x200] >> 3) & 0x01; - b = combine_4_weights(weights, bit0, bit1, bit2, bit3); + + // red component + bit0 = BIT(color_prom[i | 0x000], 0); + bit1 = BIT(color_prom[i | 0x000], 1); + bit2 = BIT(color_prom[i | 0x000], 2); + bit3 = BIT(color_prom[i | 0x000], 3); + int const r = combine_4_weights(weights, bit0, bit1, bit2, bit3); + + // green component + bit0 = BIT(color_prom[i | 0x100], 0); + bit1 = BIT(color_prom[i | 0x100], 1); + bit2 = BIT(color_prom[i | 0x100], 2); + bit3 = BIT(color_prom[i | 0x100], 3); + int const g = combine_4_weights(weights, bit0, bit1, bit2, bit3); + + // blue component + bit0 = BIT(color_prom[i | 0x200], 0); + bit1 = BIT(color_prom[i | 0x200], 1); + bit2 = BIT(color_prom[i | 0x200], 2); + bit3 = BIT(color_prom[i | 0x200], 3); + int const b = combine_4_weights(weights, bit0, bit1, bit2, bit3); palette.set_indirect_color(i, rgb_t(r, g, b)); } - /* color_prom now points to the beginning of the lookup table */ + // color_prom now points to the beginning of the lookup table color_prom += 0x300; - /* characters use colors 0x80-0xff, sprites use colors 0-0x7f */ - for (i = 0; i < 0x200; i++) + // characters use colors 0x80-0xff, sprites use colors 0-0x7f + for (int i = 0; i < 0x200; i++) { - int j; - - for (j = 0; j < 8; j++) + for (int j = 0; j < 8; j++) { - uint8_t ctabentry = ((~i & 0x100) >> 1) | (j << 4) | (color_prom[i] & 0x0f); + uint8_t const ctabentry = ((~i & 0x100) >> 1) | (j << 4) | (color_prom[i] & 0x0f); palette.set_pen_indirect(((i & 0x100) << 3) | (j << 8) | (i & 0xff), ctabentry); } } |