summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/koikoi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/koikoi.cpp')
-rw-r--r--src/mame/drivers/koikoi.cpp63
1 files changed, 30 insertions, 33 deletions
diff --git a/src/mame/drivers/koikoi.cpp b/src/mame/drivers/koikoi.cpp
index 23bf222b0a0..51eb86d950f 100644
--- a/src/mame/drivers/koikoi.cpp
+++ b/src/mame/drivers/koikoi.cpp
@@ -48,16 +48,17 @@ to prevent disabling inputs.
#define KOIKOI_CRYSTAL 15468000
-static const int input_tab[]= { 0x22, 0x64, 0x44, 0x68, 0x30, 0x50, 0x70, 0x48, 0x28, 0x21, 0x41, 0x82, 0x81, 0x42 };
+static constexpr int input_tab[] = { 0x22, 0x64, 0x44, 0x68, 0x30, 0x50, 0x70, 0x48, 0x28, 0x21, 0x41, 0x82, 0x81, 0x42 };
class koikoi_state : public driver_device
{
public:
- koikoi_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
+ koikoi_state(const machine_config &mconfig, device_type type, const char *tag) :
+ driver_device(mconfig, type, tag),
m_videoram(*this, "videoram"),
m_maincpu(*this, "maincpu"),
- m_gfxdecode(*this, "gfxdecode") { }
+ m_gfxdecode(*this, "gfxdecode")
+ { }
void koikoi(machine_config &config);
@@ -82,7 +83,7 @@ private:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
- DECLARE_PALETTE_INIT(koikoi);
+ void koikoi_palette(palette_device &palette) const;
uint32_t screen_update_koikoi(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
@@ -106,45 +107,43 @@ TILE_GET_INFO_MEMBER(koikoi_state::get_tile_info)
SET_TILE_INFO_MEMBER(0, code, color, flip);
}
-PALETTE_INIT_MEMBER(koikoi_state, koikoi)
+void koikoi_state::koikoi_palette(palette_device &palette) const
{
- const uint8_t *color_prom = memregion("proms")->base();
- int i;
+ uint8_t const *color_prom = memregion("proms")->base();
- /* create a lookup table for the palette */
- for (i = 0; i < 0x10; i++)
+ // create a lookup table for the palette
+ for (int i = 0; i < 0x10; 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 = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ // red component
+ bit0 = BIT(color_prom[i], 0);
+ bit1 = BIT(color_prom[i], 1);
+ bit2 = BIT(color_prom[i], 2);
+ int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
- /* green component */
- bit0 = (color_prom[i] >> 3) & 0x01;
- bit1 = (color_prom[i] >> 4) & 0x01;
- bit2 = (color_prom[i] >> 5) & 0x01;
- g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ // green component
+ bit0 = BIT(color_prom[i], 3);
+ bit1 = BIT(color_prom[i], 4);
+ bit2 = BIT(color_prom[i], 5);
+ int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
- /* blue component */
+ // blue component
bit0 = 0;
- bit1 = (color_prom[i] >> 6) & 0x01;
- bit2 = (color_prom[i] >> 7) & 0x01;
- b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ bit1 = BIT(color_prom[i], 6);
+ bit2 = BIT(color_prom[i], 7);
+ int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
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;
- /* characters/sprites */
- for (i = 0; i < 0x100; i++)
+ // characters/sprites
+ for (int i = 0; i < 0x100; i++)
{
- uint8_t ctabentry = color_prom[i] & 0x0f;
+ uint8_t const ctabentry = color_prom[i] & 0x0f;
palette.set_pen_indirect(i, ctabentry);
}
}
@@ -373,10 +372,8 @@ MACHINE_CONFIG_START(koikoi_state::koikoi)
MCFG_SCREEN_PALETTE("palette")
MCFG_SCREEN_VBLANK_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI))
- MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_koikoi)
- MCFG_PALETTE_ADD("palette", 8*32)
- MCFG_PALETTE_INDIRECT_ENTRIES(16)
- MCFG_PALETTE_INIT_OWNER(koikoi_state, koikoi)
+ GFXDECODE(config, m_gfxdecode, "palette", gfx_koikoi);
+ PALETTE(config, "palette", FUNC(koikoi_state::koikoi_palette), 8 * 32, 16);
/* sound hardware */
SPEAKER(config, "mono").front_center();