diff options
Diffstat (limited to 'src/mame/drivers/dmndrby.cpp')
-rw-r--r-- | src/mame/drivers/dmndrby.cpp | 84 |
1 files changed, 43 insertions, 41 deletions
diff --git a/src/mame/drivers/dmndrby.cpp b/src/mame/drivers/dmndrby.cpp index 6b40b0fc807..0055bfe608d 100644 --- a/src/mame/drivers/dmndrby.cpp +++ b/src/mame/drivers/dmndrby.cpp @@ -65,8 +65,8 @@ DD10 DD14 DD18 H5 DD21 class dmndrby_state : public driver_device { public: - dmndrby_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + dmndrby_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_scroll_ram(*this, "scroll_ram"), m_sprite_ram(*this, "sprite_ram"), m_dderby_vidchars(*this, "vidchars"), @@ -75,10 +75,14 @@ public: m_audiocpu(*this, "audiocpu"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch") { } + m_soundlatch(*this, "soundlatch") + { } void dderby(machine_config &config); +protected: + virtual void video_start() override; + private: required_shared_ptr<uint8_t> m_scroll_ram; required_shared_ptr<uint8_t> m_sprite_ram; @@ -88,20 +92,22 @@ private: tilemap_t *m_racetrack_tilemap; uint8_t m_io_port[8]; int m_bg; + + required_device<cpu_device> m_maincpu; + required_device<cpu_device> m_audiocpu; + required_device<gfxdecode_device> m_gfxdecode; + required_device<palette_device> m_palette; + required_device<generic_latch_8_device> m_soundlatch; + DECLARE_WRITE8_MEMBER(dderby_sound_w); DECLARE_READ8_MEMBER(input_r); DECLARE_WRITE8_MEMBER(output_w); TILE_GET_INFO_MEMBER(get_dmndrby_tile_info); - virtual void video_start() override; - DECLARE_PALETTE_INIT(dmndrby); + void dmndrby_palette(palette_device &palette) const; uint32_t screen_update_dderby(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(dderby_irq); INTERRUPT_GEN_MEMBER(dderby_timer_irq); - required_device<cpu_device> m_maincpu; - required_device<cpu_device> m_audiocpu; - required_device<gfxdecode_device> m_gfxdecode; - required_device<palette_device> m_palette; - required_device<generic_latch_8_device> m_soundlatch; + void dderby_sound_map(address_map &map); void memmap(address_map &map); }; @@ -469,51 +475,49 @@ wouldnt like to say its the most effective way though... } // copied from elsewhere. surely incorrect -PALETTE_INIT_MEMBER(dmndrby_state, dmndrby) +void dmndrby_state::dmndrby_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, 470, 0, 3, &resistances_rg[0], gweights, 470, 0, 2, &resistances_b[0], bweights, 470, 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 = memregion("proms2")->base(); - /* normal tiles use colors 0-15 */ - for (i = 0x000; i < 0x300; i++) + // normal tiles use colors 0-15 + for (int i = 0x000; i < 0x300; i++) { uint8_t ctabentry = color_prom[i]; palette.set_pen_indirect(i, ctabentry); @@ -551,12 +555,10 @@ MACHINE_CONFIG_START(dmndrby_state::dderby) MCFG_SCREEN_SIZE(256, 256) MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 16, 256-16-1) MCFG_SCREEN_UPDATE_DRIVER(dmndrby_state, screen_update_dderby) - MCFG_SCREEN_PALETTE("palette") + MCFG_SCREEN_PALETTE(m_palette) - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_dmndrby) - MCFG_PALETTE_ADD("palette", 0x300) - MCFG_PALETTE_INDIRECT_ENTRIES(0x20) - MCFG_PALETTE_INIT_OWNER(dmndrby_state, dmndrby) + GFXDECODE(config, m_gfxdecode, m_palette, gfx_dmndrby); + PALETTE(config, m_palette, FUNC(dmndrby_state::dmndrby_palette), 0x300, 0x20); SPEAKER(config, "mono").front_center(); |