summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/mappy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/mappy.cpp')
-rw-r--r--src/mame/video/mappy.cpp182
1 files changed, 88 insertions, 94 deletions
diff --git a/src/mame/video/mappy.cpp b/src/mame/video/mappy.cpp
index fafc84915ad..81828b961a7 100644
--- a/src/mame/video/mappy.cpp
+++ b/src/mame/video/mappy.cpp
@@ -32,116 +32,112 @@
***************************************************************************/
-PALETTE_INIT_MEMBER(mappy_state,superpac)
+void mappy_state::superpac_palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
- static const int resistances[3] = { 1000, 470, 220 };
- double rweights[3], gweights[3], bweights[2];
- int i;
+ static constexpr int resistances[3] = { 1000, 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[0], rweights, 0, 0,
3, &resistances[0], gweights, 0, 0,
2, &resistances[1], bweights, 0, 0);
- /* create a lookup table for the palette */
- for (i = 0; i < 32; i++)
+ // create a lookup table for the palette
+ for (int i = 0; i < 32; 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 += 32;
- /* characters map to the upper 16 palette entries */
- for (i = 0; i < 64*4; i++)
+ // characters map to the upper 16 palette entries
+ for (int i = 0; i < 64*4; i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, (ctabentry ^ 15) + 0x10);
}
- /* sprites map to the lower 16 palette entries */
- for (i = 64*4; i < 128*4; i++)
+ // sprites map to the lower 16 palette entries
+ for (int i = 64*4; i < 128*4; i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, ctabentry);
}
}
-PALETTE_INIT_MEMBER(mappy_state,mappy)
+void mappy_state::mappy_palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
- static const int resistances[3] = { 1000, 470, 220 };
- double rweights[3], gweights[3], bweights[2];
- int i;
+ static constexpr int resistances[3] = { 1000, 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[0], rweights, 0, 0,
3, &resistances[0], gweights, 0, 0,
2, &resistances[1], bweights, 0, 0);
- /* create a lookup table for the palette */
- for (i = 0; i < 32; i++)
+ // create a lookup table for the palette
+ for (int i = 0; i < 32; 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 += 32;
- /* characters map to the upper 16 palette entries */
- for (i = 0*4; i < 64*4; i++)
+ // characters map to the upper 16 palette entries
+ for (int i = 0*4; i < 64*4; i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, ctabentry + 0x10);
}
- /* sprites map to the lower 16 palette entries */
- for (i = 64*4; i < palette.entries(); i++)
+ // sprites map to the lower 16 palette entries
+ for (int i = 64*4; i < palette.entries(); i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, ctabentry);
}
}
@@ -158,63 +154,61 @@ PALETTE_INIT_MEMBER(mappy_state,mappy)
***************************************************************************/
-PALETTE_INIT_MEMBER(mappy_state,phozon)
+void mappy_state::phozon_palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
- static const int resistances[4] = { 2200, 1000, 470, 220 };
- double rweights[4], gweights[4], bweights[4];
- int i;
+ static constexpr int resistances[4] = { 2200, 1000, 470, 220 };
- /* compute the color output resistor weights */
+ // compute the color output resistor weights
+ double rweights[4], gweights[4], bweights[4];
compute_resistor_weights(0, 255, -1.0,
4, &resistances[0], rweights, 0, 0,
4, &resistances[0], gweights, 0, 0,
4, &resistances[0], bweights, 0, 0);
- /* create a lookup table for the palette */
- for (i = 0; i < 32; i++)
+ // create a lookup table for the palette
+ for (int i = 0; i < 32; i++)
{
int bit0, bit1, bit2, bit3;
- int r, g, b;
-
- /* red component */
- bit0 = (color_prom[i] >> 0) & 0x01;
- bit1 = (color_prom[i] >> 1) & 0x01;
- bit2 = (color_prom[i] >> 2) & 0x01;
- bit3 = (color_prom[i] >> 3) & 0x01;
- r = combine_4_weights(rweights, 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(gweights, 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(bweights, bit0, bit1, bit2, bit3);
+
+ // red component
+ bit0 = BIT(color_prom[i], 0);
+ bit1 = BIT(color_prom[i], 1);
+ bit2 = BIT(color_prom[i], 2);
+ bit3 = BIT(color_prom[i], 3);
+ int const r = combine_4_weights(rweights, 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(gweights, 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(bweights, 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 map to the lower 16 palette entries */
- for (i = 0; i < 64*4; i++)
+ // characters map to the lower 16 palette entries
+ for (int i = 0; i < 64*4; i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, ctabentry);
}
- /* sprites map to the upper 16 palette entries */
- for (i = 64*4; i < 128*4; i++)
+ // sprites map to the upper 16 palette entries
+ for (int i = 64*4; i < 128*4; i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, ctabentry + 0x10);
}
}