diff options
Diffstat (limited to 'src/mame/video/rallyx.cpp')
-rw-r--r-- | src/mame/video/rallyx.cpp | 165 |
1 files changed, 80 insertions, 85 deletions
diff --git a/src/mame/video/rallyx.cpp b/src/mame/video/rallyx.cpp index b41a5e74a4a..8df8741902d 100644 --- a/src/mame/video/rallyx.cpp +++ b/src/mame/video/rallyx.cpp @@ -58,149 +58,144 @@ needs more color combination to render its graphics. ***************************************************************************/ -PALETTE_INIT_MEMBER(rallyx_state,rallyx) +void rallyx_state::rallyx_palette(palette_device &palette) const { const uint8_t *color_prom = memregion("proms")->base(); - static const int resistances_rg[3] = { 1000, 470, 220 }; - static const int resistances_b [2] = { 470, 220 }; - double rweights[3], gweights[3], bweights[2]; - int i; + static constexpr int resistances_rg[3] = { 1000, 470, 220 }; + static constexpr int resistances_b [2] = { 470, 220 }; - /* compute the color output resistor weights */ + // compute the color output resistor weights + double rweights[3], gweights[3], bweights[2]; compute_resistor_weights(0, 255, -1.0, 3, &resistances_rg[0], rweights, 0, 0, 3, &resistances_rg[0], gweights, 0, 0, 2, &resistances_b[0], bweights, 1000, 0); - /* create a lookup table for the palette */ - for (i = 0; i < 0x20; i++) + // create a lookup table for the palette + for (int i = 0; i < 0x20; i++) { int bit0, bit1, bit2; - int r, g, b; - /* red component */ - bit0 = (color_prom[i] >> 0) & 0x01; - bit1 = (color_prom[i] >> 1) & 0x01; - bit2 = (color_prom[i] >> 2) & 0x01; - r = combine_3_weights(rweights, bit0, bit1, bit2); + // red component + bit0 = BIT(color_prom[i], 0); + bit1 = BIT(color_prom[i], 1); + bit2 = BIT(color_prom[i], 2); + int const r = combine_3_weights(rweights, bit0, bit1, bit2); - /* green component */ - bit0 = (color_prom[i] >> 3) & 0x01; - bit1 = (color_prom[i] >> 4) & 0x01; - bit2 = (color_prom[i] >> 5) & 0x01; - g = combine_3_weights(gweights, bit0, bit1, bit2); + // green component + bit0 = BIT(color_prom[i], 3); + bit1 = BIT(color_prom[i], 4); + bit2 = BIT(color_prom[i], 5); + int const g = combine_3_weights(gweights, bit0, bit1, bit2); - /* blue component */ - bit0 = (color_prom[i] >> 6) & 0x01; - bit1 = (color_prom[i] >> 7) & 0x01; - b = combine_2_weights(bweights, bit0, bit1); + // blue component + bit0 = BIT(color_prom[i], 6); + bit1 = BIT(color_prom[i], 7); + int const b = combine_2_weights(bweights, bit0, bit1); 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 += 0x20; - /* character/sprites lookup table */ - for (i = 0x000; i < 0x100; i++) + // character/sprites lookup table + for (int i = 0x000; i < 0x100; i++) { - uint8_t ctabentry = color_prom[i] & 0x0f; + uint8_t const ctabentry = color_prom[i] & 0x0f; palette.set_pen_indirect(i, ctabentry); } - /* bullets use colors 0x10-0x13 */ - for (i = 0x100; i < 0x104; i++) + // bullets use colors 0x10-0x13 + for (int i = 0x100; i < 0x104; i++) palette.set_pen_indirect(i, (i - 0x100) | 0x10); } -PALETTE_INIT_MEMBER(rallyx_state,jungler) +void rallyx_state::jungler_palette(palette_device &palette) const { const uint8_t *color_prom = memregion("proms")->base(); - static const int resistances_rg[3] = { 1000, 470, 220 }; - static const int resistances_b [2] = { 470, 220 }; - static const int resistances_star[3] = { 150, 100 }; - double rweights[3], gweights[3], bweights[2]; - double rweights_star[2], gweights_star[2], bweights_star[2]; - int i; + static constexpr int resistances_rg[3] = { 1000, 470, 220 }; + static constexpr int resistances_b [2] = { 470, 220 }; + static constexpr int resistances_star[3] = { 150, 100 }; - /* compute the color output resistor weights */ - double scale = compute_resistor_weights(0, 255, -1.0, - 2, resistances_star, rweights_star, 0, 0, - 2, resistances_star, gweights_star, 0, 0, - 2, resistances_star, bweights_star, 0, 0); + // compute the color output resistor weights + double rweights_star[2], gweights_star[2], bweights_star[2]; + double const scale = compute_resistor_weights(0, 255, -1.0, + 2, resistances_star, rweights_star, 0, 0, + 2, resistances_star, gweights_star, 0, 0, + 2, resistances_star, bweights_star, 0, 0); - compute_resistor_weights(0, 255, scale, - 3, resistances_rg, rweights, 1000, 0, - 3, resistances_rg, gweights, 1000, 0, - 2, resistances_b, bweights, 1000, 0); + double rweights[3], gweights[3], bweights[2]; + compute_resistor_weights(0, 255, scale, + 3, resistances_rg, rweights, 1000, 0, + 3, resistances_rg, gweights, 1000, 0, + 2, resistances_b, bweights, 1000, 0); - /* create a lookup table for the palette */ - for (i = 0; i < 0x20; i++) + // create a lookup table for the palette + for (int i = 0; i < 0x20; i++) { int bit0, bit1, bit2; - int r, g, b; - /* red component */ - bit0 = (color_prom[i] >> 0) & 0x01; - bit1 = (color_prom[i] >> 1) & 0x01; - bit2 = (color_prom[i] >> 2) & 0x01; - r = combine_3_weights(rweights, bit0, bit1, bit2); + // red component + bit0 = BIT(color_prom[i], 0); + bit1 = BIT(color_prom[i], 1); + bit2 = BIT(color_prom[i], 2); + int const r = combine_3_weights(rweights, bit0, bit1, bit2); - /* green component */ - bit0 = (color_prom[i] >> 3) & 0x01; - bit1 = (color_prom[i] >> 4) & 0x01; - bit2 = (color_prom[i] >> 5) & 0x01; - g = combine_3_weights(gweights, bit0, bit1, bit2); + // green component + bit0 = BIT(color_prom[i], 3); + bit1 = BIT(color_prom[i], 4); + bit2 = BIT(color_prom[i], 5); + int const g = combine_3_weights(gweights, bit0, bit1, bit2); - /* blue component */ - bit0 = (color_prom[i] >> 6) & 0x01; - bit1 = (color_prom[i] >> 7) & 0x01; - b = combine_2_weights(bweights, bit0, bit1); + // blue component + bit0 = BIT(color_prom[i], 6); + bit1 = BIT(color_prom[i], 7); + int const b = combine_2_weights(bweights, bit0, bit1); palette.set_indirect_color(i, rgb_t(r, g, b)); } - /* star pens */ - for (i = 0x20; i < 0x60; i++) + // star pens + for (int i = 0x20; i < 0x60; i++) { int bit0, bit1; - int r, g, b; - /* red component */ - bit0 = ((i - 0x20) >> 0) & 0x01; - bit1 = ((i - 0x20) >> 1) & 0x01; - r = combine_2_weights(rweights_star, bit0, bit1); + // red component + bit0 = BIT((i - 0x20), 0); + bit1 = BIT((i - 0x20), 1); + int const r = combine_2_weights(rweights_star, bit0, bit1); - /* green component */ - bit0 = ((i - 0x20) >> 2) & 0x01; - bit1 = ((i - 0x20) >> 3) & 0x01; - g = combine_2_weights(gweights_star, bit0, bit1); + // green component + bit0 = BIT(i - 0x20, 2); + bit1 = BIT(i - 0x20, 3); + int const g = combine_2_weights(gweights_star, bit0, bit1); - /* blue component */ - bit0 = ((i - 0x20) >> 4) & 0x01; - bit1 = ((i - 0x20) >> 5) & 0x01; - b = combine_2_weights(bweights_star, bit0, bit1); + // blue component + bit0 = BIT(i - 0x20, 4); + bit1 = BIT(i - 0x20, 5); + int const b = combine_2_weights(bweights_star, bit0, bit1); 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 += 0x20; - /* character/sprites lookup table */ - for (i = 0x000; i < 0x100; i++) + // character/sprites lookup table + for (int i = 0x000; i < 0x100; i++) { - uint8_t ctabentry = color_prom[i] & 0x0f; + uint8_t const ctabentry = color_prom[i] & 0x0f; palette.set_pen_indirect(i, ctabentry); } - /* bullets use colors 0x10-0x13 */ - for (i = 0x100; i < 0x104; i++) + // bullets use colors 0x10-0x13 + for (int i = 0x100; i < 0x104; i++) palette.set_pen_indirect(i, (i - 0x100) | 0x10); - /* stars */ - for (i = 0x104; i < 0x144; i++) + // stars + for (int i = 0x104; i < 0x144; i++) palette.set_pen_indirect(i, (i - 0x104) + 0x20); } |