summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/shaolins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/shaolins.cpp')
-rw-r--r--src/mame/video/shaolins.cpp69
1 files changed, 32 insertions, 37 deletions
diff --git a/src/mame/video/shaolins.cpp b/src/mame/video/shaolins.cpp
index aeeaef0c0b2..d78d5169dc3 100644
--- a/src/mame/video/shaolins.cpp
+++ b/src/mame/video/shaolins.cpp
@@ -28,61 +28,56 @@
bit 0 -- 2.2kohm resistor -- RED/GREEN/BLUE
***************************************************************************/
-PALETTE_INIT_MEMBER(shaolins_state, shaolins)
+void shaolins_state::shaolins_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, rweights, 470, 0,
4, resistances, gweights, 470, 0,
4, resistances, bweights, 470, 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(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 | 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(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 use colors 0x10-0x1f of each 0x20 color bank,
- while sprites use colors 0-0x0f */
- for (i = 0; i < 0x200; i++)
+ // characters use colors 0x10-0x1f of each 0x20 color bank, while sprites use colors 0-0x0f
+ 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 = (j << 5) | ((~i & 0x100) >> 4) | (color_prom[i] & 0x0f);
+ uint8_t const ctabentry = (j << 5) | ((~i & 0x100) >> 4) | (color_prom[i] & 0x0f);
palette.set_pen_indirect(((i & 0x100) << 3) | (j << 8) | (i & 0xff), ctabentry);
}
}