diff options
Diffstat (limited to 'src/mame/drivers/supercrd.cpp')
-rw-r--r-- | src/mame/drivers/supercrd.cpp | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/src/mame/drivers/supercrd.cpp b/src/mame/drivers/supercrd.cpp index 98d14f2d0c5..ff3e1dd79d2 100644 --- a/src/mame/drivers/supercrd.cpp +++ b/src/mame/drivers/supercrd.cpp @@ -177,27 +177,31 @@ class supercrd_state : public driver_device { public: - supercrd_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + supercrd_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_videoram(*this, "videoram"), m_colorram(*this, "colorram"), m_maincpu(*this, "maincpu"), - m_gfxdecode(*this, "gfxdecode") { } + m_gfxdecode(*this, "gfxdecode") + { } void supercrd(machine_config &config); +protected: + virtual void video_start() override; + private: required_shared_ptr<uint8_t> m_videoram; required_shared_ptr<uint8_t> m_colorram; tilemap_t *m_bg_tilemap; + required_device<cpu_device> m_maincpu; + required_device<gfxdecode_device> m_gfxdecode; + DECLARE_WRITE8_MEMBER(supercrd_videoram_w); DECLARE_WRITE8_MEMBER(supercrd_colorram_w); TILE_GET_INFO_MEMBER(get_bg_tile_info); - DECLARE_PALETTE_INIT(supercrd); - DECLARE_VIDEO_START(supercrd); + void supercrd_palette(palette_device &palette) const; uint32_t screen_update_supercrd(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - required_device<cpu_device> m_maincpu; - required_device<gfxdecode_device> m_gfxdecode; void supercrd_map(address_map &map); }; @@ -206,40 +210,40 @@ private: * Video Hardware * *************************/ -PALETTE_INIT_MEMBER(supercrd_state, supercrd) +void supercrd_state::supercrd_palette(palette_device &palette) const { - const uint8_t *color_prom = memregion("proms")->base(); - int i; - static const int resistances_rb[3] = { 1000, 470, 220 }; - static const int resistances_g [2] = { 470, 220 }; - double weights_r[3], weights_b[3], weights_g[2]; + uint8_t const *const color_prom = memregion("proms")->base(); + static constexpr int resistances_rb[3] = { 1000, 470, 220 }; + static constexpr int resistances_g [2] = { 470, 220 }; + double weights_r[3], weights_b[3], weights_g[2]; compute_resistor_weights(0, 255, -1.0, 3, resistances_rb, weights_r, 100, 0, 3, resistances_rb, weights_b, 100, 0, 2, resistances_g, weights_g, 100, 0); - - for (i = 0; i < palette.entries(); i++) + for (int i = 0; i < palette.entries(); i++) { - int bit0, bit1, bit2, 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(weights_r, bit0, bit1, bit2); - /* blue component */ - bit0 = (color_prom[i] >> 3) & 0x01; - bit1 = (color_prom[i] >> 4) & 0x01; - bit2 = (color_prom[i] >> 5) & 0x01; - b = combine_3_weights(weights_b, bit0, bit1, bit2); - /* green component */ - bit0 = (color_prom[i] >> 6) & 0x01; - bit1 = (color_prom[i] >> 7) & 0x01; - g = combine_2_weights(weights_g, bit0, bit1); - - palette.set_pen_color(i,rgb_t(r,g,b)); + int 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(weights_r, bit0, bit1, bit2); + + // blue component */ + bit0 = BIT(color_prom[i], 3); + bit1 = BIT(color_prom[i], 4); + bit2 = BIT(color_prom[i], 5); + int const b = combine_3_weights(weights_b, bit0, bit1, bit2); + + // green component */ + bit0 = BIT(color_prom[i], 6); + bit1 = BIT(color_prom[i], 7); + int const g = combine_2_weights(weights_g, bit0, bit1); + + palette.set_pen_color(i, rgb_t(r, g, b)); } } @@ -273,7 +277,7 @@ TILE_GET_INFO_MEMBER(supercrd_state::get_bg_tile_info) } -VIDEO_START_MEMBER(supercrd_state, supercrd) +void supercrd_state::video_start() { m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(supercrd_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 4, 8, 96, 29); } @@ -438,11 +442,8 @@ MACHINE_CONFIG_START(supercrd_state::supercrd) MCFG_SCREEN_UPDATE_DRIVER(supercrd_state, screen_update_supercrd) MCFG_SCREEN_PALETTE("palette") - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_supercrd) - - MCFG_PALETTE_ADD("palette", 0x200) - MCFG_PALETTE_INIT_OWNER(supercrd_state, supercrd) - MCFG_VIDEO_START_OVERRIDE(supercrd_state, supercrd) + GFXDECODE(config, m_gfxdecode, "palette", gfx_supercrd); + PALETTE(config, "palette", FUNC(supercrd_state::supercrd_palette), 0x200); // mc6845_device &crtc(MC6845(config, "crtc", MASTER_CLOCK/8)); // crtc.set_screen("screen"); |