summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/sprcros2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/sprcros2.cpp')
-rw-r--r--src/mame/drivers/sprcros2.cpp98
1 files changed, 45 insertions, 53 deletions
diff --git a/src/mame/drivers/sprcros2.cpp b/src/mame/drivers/sprcros2.cpp
index f4b1c2f6fce..1f10dc36802 100644
--- a/src/mame/drivers/sprcros2.cpp
+++ b/src/mame/drivers/sprcros2.cpp
@@ -79,6 +79,13 @@ public:
void sprcros2(machine_config &config);
+protected:
+ // driver_device overrides
+ virtual void machine_start() override;
+ virtual void machine_reset() override;
+
+ virtual void video_start() override;
+
private:
// devices
required_device<cpu_device> m_master_cpu;
@@ -91,10 +98,15 @@ private:
required_shared_ptr<uint8_t> m_bgattr;
required_shared_ptr<uint8_t> m_sprram;
+ bool m_master_nmi_enable;
+ bool m_master_irq_enable;
+ bool m_slave_nmi_enable;
+ bool m_screen_enable;
+ uint8_t m_bg_scrollx, m_bg_scrolly;
// screen updates
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- DECLARE_PALETTE_INIT(sprcros2);
+ void sprcros2_palette(palette_device &palette) const;
DECLARE_WRITE8_MEMBER(master_output_w);
DECLARE_WRITE8_MEMBER(slave_output_w);
DECLARE_WRITE8_MEMBER(bg_scrollx_w);
@@ -103,22 +115,11 @@ private:
INTERRUPT_GEN_MEMBER(slave_vblank_irq);
TIMER_DEVICE_CALLBACK_MEMBER(master_scanline);
- bool m_master_nmi_enable;
- bool m_master_irq_enable;
- bool m_slave_nmi_enable;
- bool m_screen_enable;
- uint8_t m_bg_scrollx, m_bg_scrolly;
void master_io(address_map &map);
void master_map(address_map &map);
void slave_io(address_map &map);
void slave_map(address_map &map);
- // driver_device overrides
- virtual void machine_start() override;
- virtual void machine_reset() override;
-
- virtual void video_start() override;
-
void legacy_bg_draw(bitmap_ind16 &bitmap,const rectangle &cliprect);
void legacy_fg_draw(bitmap_ind16 &bitmap,const rectangle &cliprect);
void legacy_obj_draw(bitmap_ind16 &bitmap,const rectangle &cliprect);
@@ -382,50 +383,48 @@ void sprcros2_state::machine_reset()
}
-PALETTE_INIT_MEMBER(sprcros2_state, sprcros2)
+void sprcros2_state::sprcros2_palette(palette_device &palette) const
{
const uint8_t *color_prom = memregion("proms")->base();
- int i;
- /* 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 = 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;
-
- /* blue component */
- bit0 = (color_prom[i] >> 6) & 0x01;
- bit1 = (color_prom[i] >> 7) & 0x01;
- b = 0x47 * bit0 + 0xb8 * bit1;
- palette.set_pen_color(i,rgb_t(r,g,b));
+ // 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 = 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
+ bit0 = BIT(color_prom[i], 6);
+ bit1 = BIT(color_prom[i], 7);
+ int const b = 0x47 * bit0 + 0xb8 * bit1;
+
+ palette.set_pen_color(i, rgb_t(r, g, b));
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;
- /* bg */
- for (i = 0; i < 0x100; i++)
+ // bg
+ for (int i = 0; i < 0x100; i++)
{
- uint8_t ctabentry = (color_prom[i] & 0x0f) | ((color_prom[i + 0x100] & 0x0f) << 4);
+ uint8_t const ctabentry = (color_prom[i] & 0x0f) | ((color_prom[i + 0x100] & 0x0f) << 4);
palette.set_pen_indirect(i, ctabentry);
}
- /* sprites & fg */
- for (i = 0x100; i < 0x300; i++)
+ // sprites & fg
+ for (int i = 0x100; i < 0x300; i++)
{
uint8_t ctabentry = color_prom[i + 0x100];
palette.set_pen_indirect(i, ctabentry);
@@ -475,22 +474,15 @@ MACHINE_CONFIG_START(sprcros2_state::sprcros2)
MCFG_SCREEN_RAW_PARAMS(MAIN_CLOCK/2, 343, 8, 256-8, 262, 16, 240) // TODO: Wrong screen parameters
MCFG_SCREEN_PALETTE("palette")
- MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_sprcros2)
+ GFXDECODE(config, m_gfxdecode, "palette", gfx_sprcros2);
- MCFG_PALETTE_ADD("palette", 768)
- MCFG_PALETTE_INDIRECT_ENTRIES(32)
- MCFG_PALETTE_INIT_OWNER(sprcros2_state, sprcros2)
+ PALETTE(config, "palette", FUNC(sprcros2_state::sprcros2_palette), 768, 32);
/* sound hardware */
SPEAKER(config, "mono").front_center();
- MCFG_DEVICE_ADD("sn1", SN76489, 10000000/4)
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
-
- MCFG_DEVICE_ADD("sn2", SN76489, 10000000/4)
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
-
- MCFG_DEVICE_ADD("sn3", SN76489, 10000000/4)
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
+ SN76489(config, "sn1", 10000000/4).add_route(ALL_OUTPUTS, "mono", 0.50);
+ SN76489(config, "sn2", 10000000/4).add_route(ALL_OUTPUTS, "mono", 0.50);
+ SN76489(config, "sn3", 10000000/4).add_route(ALL_OUTPUTS, "mono", 0.50);
MACHINE_CONFIG_END