summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/wallc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/wallc.cpp')
-rw-r--r--src/mame/drivers/wallc.cpp123
1 files changed, 60 insertions, 63 deletions
diff --git a/src/mame/drivers/wallc.cpp b/src/mame/drivers/wallc.cpp
index 5dbfa2c663f..50ae92b81cb 100644
--- a/src/mame/drivers/wallc.cpp
+++ b/src/mame/drivers/wallc.cpp
@@ -61,11 +61,12 @@ Thanks to HIGHWAYMAN for providing info on how to get to these epoxies
class wallc_state : public driver_device
{
public:
- wallc_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
+ wallc_state(const machine_config &mconfig, device_type type, const char *tag) :
+ driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
- m_videoram(*this, "videoram") { }
+ m_videoram(*this, "videoram")
+ { }
void sidampkr(machine_config &config);
void unkitpkr(machine_config &config);
@@ -104,8 +105,8 @@ private:
TILE_GET_INFO_MEMBER(get_bg_tile_info_sidampkr);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- DECLARE_PALETTE_INIT(wallc);
- DECLARE_PALETTE_INIT(unkitpkr);
+ void wallc_palette(palette_device &palette) const;
+ void unkitpkr_palette(palette_device &palette) const;
DECLARE_VIDEO_START(unkitpkr);
DECLARE_VIDEO_START(sidampkr);
};
@@ -114,102 +115,100 @@ private:
/***************************************************************************
- Convert the color PROMs into a more useable format.
+ Convert the color PROMs into a more usable format.
Wall Crash has one 32 bytes palette PROM, connected to the RGB output this
way:
- bit 6 -- 330 ohm resistor --+-- 330 ohm pulldown resistor -- RED
- bit 5 -- 220 ohm resistor --/
+ bit 6 -- 330 Ohm resistor --+-- 330 Ohm pulldown resistor -- RED
+ bit 5 -- 220 Ohm resistor --/
bit 4 -- NC
- bit 3 -- 330 ohm resistor --+-- 330 ohm pulldown resistor -- GREEN
- bit 2 -- 220 ohm resistor --/
+ bit 3 -- 330 Ohm resistor --+-- 330 Ohm pulldown resistor -- GREEN
+ bit 2 -- 220 Ohm resistor --/
- bit 1 -- 330 ohm resistor --+--+-- 330 ohm pulldown resistor -- BLUE
- bit 0 -- 220 ohm resistor --/ |
+ bit 1 -- 330 Ohm resistor --+--+-- 330 Ohm pulldown resistor -- BLUE
+ bit 0 -- 220 Ohm resistor --/ |
|
bit 7 -+- diode(~655 Ohm)------/
- \------220 ohm pullup (+5V) resistor
+ \------220 Ohm pullup (+5V) resistor
***************************************************************************/
-PALETTE_INIT_MEMBER(wallc_state, wallc)
+void wallc_state::wallc_palette(palette_device &palette) const
{
- const uint8_t *color_prom = memregion("proms")->base();
- int i;
+ uint8_t const *const color_prom = memregion("proms")->base();
- static const int resistances_rg[2] = { 330, 220 };
- static const int resistances_b[3] = { 655, 330, 220 };
- double weights_r[2], weights_g[2], weights_b[3];
+ static constexpr int resistances_rg[2] = { 330, 220 };
+ static constexpr int resistances_b[3] = { 655, 330, 220 };
+ double weights_r[2], weights_g[2], weights_b[3];
compute_resistor_weights(0, 255, -1.0,
2, resistances_rg, weights_r, 330, 0,
2, resistances_rg, weights_g, 330, 0,
3, resistances_b, weights_b, 330, 655+220);
- for (i = 0;i < palette.entries();i++)
+ for (int i = 0; i < palette.entries(); i++)
{
- int bit0,bit1,bit7,r,g,b;
+ int bit0, bit1, bit7;
- /* red component */
- bit0 = (color_prom[i] >> 5) & 0x01;
- bit1 = (color_prom[i] >> 6) & 0x01;
- r = combine_2_weights(weights_r, bit1, bit0);
+ // red component
+ bit0 = BIT(color_prom[i], 5);
+ bit1 = BIT(color_prom[i], 6);
+ int const r = combine_2_weights(weights_r, bit1, bit0);
- /* green component */
- bit0 = (color_prom[i] >> 2) & 0x01;
- bit1 = (color_prom[i] >> 3) & 0x01;
- g = combine_2_weights(weights_g, bit1, bit0);
+ // green component
+ bit0 = BIT(color_prom[i], 2);
+ bit1 = BIT(color_prom[i], 3);
+ int const g = combine_2_weights(weights_g, bit1, bit0);
- /* blue component */
- bit0 = (color_prom[i] >> 0) & 0x01;
- bit1 = (color_prom[i] >> 1) & 0x01;
- bit7 = (color_prom[i] >> 7) & 0x01;
- b = combine_3_weights(weights_b, bit7, bit1, bit0);
+ // blue component
+ bit0 = BIT(color_prom[i], 0);
+ bit1 = BIT(color_prom[i], 1);
+ bit7 = BIT(color_prom[i], 7);
+ int const b = combine_3_weights(weights_b, bit7, bit1, bit0);
- palette.set_pen_color(i,rgb_t(r,g,b));
+ palette.set_pen_color(i, rgb_t(r, g, b));
}
}
-PALETTE_INIT_MEMBER(wallc_state, unkitpkr)
+void wallc_state::unkitpkr_palette(palette_device &palette) const
{
-// this pcb has 470 ohms resistors instead of the expected 330 ohms.
- const uint8_t *color_prom = memregion("proms")->base();
- int i;
+ // this pcb has 470 Ohm resistors instead of the expected 330 Ohms.
+ uint8_t const *const color_prom = memregion("proms")->base();
- static const int resistances_rg[2] = { 470, 220 };
- static const int resistances_b[3] = { 655, 470, 220 };
- double weights_r[2], weights_g[2], weights_b[3];
+ static constexpr int resistances_rg[2] = { 470, 220 };
+ static constexpr int resistances_b[3] = { 655, 470, 220 };
+ double weights_r[2], weights_g[2], weights_b[3];
compute_resistor_weights(0, 255, -1.0,
2, resistances_rg, weights_r, 470, 0,
2, resistances_rg, weights_g, 470, 0,
3, resistances_b, weights_b, 470, 655+220);
- for (i = 0;i < palette.entries();i++)
+ for (int i = 0; i < palette.entries(); i++)
{
- int bit0,bit1,bit7,r,g,b;
+ int bit0, bit1, bit7;
- /* red component */
- bit0 = (color_prom[i] >> 5) & 0x01;
- bit1 = (color_prom[i] >> 6) & 0x01;
- r = combine_2_weights(weights_r, bit1, bit0);
+ // red component
+ bit0 = BIT(color_prom[i], 5);
+ bit1 = BIT(color_prom[i], 6);
+ int const r = combine_2_weights(weights_r, bit1, bit0);
- /* green component */
- bit0 = (color_prom[i] >> 2) & 0x01;
- bit1 = (color_prom[i] >> 3) & 0x01;
- g = combine_2_weights(weights_g, bit1, bit0);
+ // green component
+ bit0 = BIT(color_prom[i], 2);
+ bit1 = BIT(color_prom[i], 3);
+ int const g = combine_2_weights(weights_g, bit1, bit0);
- /* blue component */
- bit0 = (color_prom[i] >> 0) & 0x01;
- bit1 = (color_prom[i] >> 1) & 0x01;
- bit7 = (color_prom[i] >> 7) & 0x01;
- b = combine_3_weights(weights_b, bit7, bit1, bit0);
+ // blue component
+ bit0 = BIT(color_prom[i], 0);
+ bit1 = BIT(color_prom[i], 1);
+ bit7 = BIT(color_prom[i], 7);
+ int const b = combine_3_weights(weights_b, bit7, bit1, bit0);
- palette.set_pen_color(i,rgb_t(r,g,b));
+ palette.set_pen_color(i, rgb_t(r, g, b));
}
}
@@ -530,9 +529,8 @@ MACHINE_CONFIG_START(wallc_state::wallc)
MCFG_SCREEN_UPDATE_DRIVER(wallc_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
- MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_wallc)
- MCFG_PALETTE_ADD("palette", 32)
- MCFG_PALETTE_INIT_OWNER(wallc_state, wallc)
+ GFXDECODE(config, m_gfxdecode, "palette", gfx_wallc);
+ PALETTE(config, "palette", FUNC(wallc_state::wallc_palette), 32);
/* sound hardware */
SPEAKER(config, "mono").front_center();
@@ -552,8 +550,7 @@ MACHINE_CONFIG_START(wallc_state::unkitpkr)
MCFG_DEVICE_PROGRAM_MAP(unkitpkr_map)
MCFG_VIDEO_START_OVERRIDE(wallc_state, unkitpkr)
- MCFG_PALETTE_MODIFY("palette")
- MCFG_PALETTE_INIT_OWNER(wallc_state, unkitpkr)
+ subdevice<palette_device>("palette")->set_init(FUNC(wallc_state::unkitpkr_palette));
/* sound hardware */
subdevice<ay8912_device>("aysnd")->port_a_read_callback().set_ioport("DSW2");