From e6f83e9e747f17d2e0d88f97349587624f84c8fe Mon Sep 17 00:00:00 2001 From: Bryan McPhail Date: Wed, 28 Jun 2017 12:02:14 -0400 Subject: [PATCH] Fix colours in Crude Buster (verified against real hardware) --- src/mame/drivers/cbuster.cpp | 4 ++-- src/mame/includes/cbuster.h | 7 ++++++ src/mame/video/cbuster.cpp | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/mame/drivers/cbuster.cpp b/src/mame/drivers/cbuster.cpp index afc555c4e31..74d16d4a231 100644 --- a/src/mame/drivers/cbuster.cpp +++ b/src/mame/drivers/cbuster.cpp @@ -137,8 +137,8 @@ static ADDRESS_MAP_START( twocrude_map, AS_PROGRAM, 16, cbuster_state ) AM_RANGE(0x0b4000, 0x0b4001) AM_WRITENOP AM_RANGE(0x0b5000, 0x0b500f) AM_DEVWRITE("tilegen1", deco16ic_device, pf_control_w) AM_RANGE(0x0b6000, 0x0b600f) AM_DEVWRITE("tilegen2", deco16ic_device, pf_control_w) - AM_RANGE(0x0b8000, 0x0b8fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") - AM_RANGE(0x0b9000, 0x0b9fff) AM_RAM_DEVWRITE("palette", palette_device, write_ext) AM_SHARE("palette_ext") + AM_RANGE(0x0b8000, 0x0b8fff) AM_RAM_WRITE(cbuster_palette_w) AM_SHARE("palette") + AM_RANGE(0x0b9000, 0x0b9fff) AM_RAM_WRITE(cbuster_palette_ext_w) AM_SHARE("palette_ext") AM_RANGE(0x0bc000, 0x0bc00f) AM_READWRITE(twocrude_control_r, twocrude_control_w) ADDRESS_MAP_END diff --git a/src/mame/includes/cbuster.h b/src/mame/includes/cbuster.h index e404f579121..8930820e097 100644 --- a/src/mame/includes/cbuster.h +++ b/src/mame/includes/cbuster.h @@ -21,6 +21,8 @@ public: m_pf3_rowscroll(*this, "pf3_rowscroll"), m_pf4_rowscroll(*this, "pf4_rowscroll"), m_spriteram16(*this, "spriteram16"), + m_paletteram(*this, "palette"), + m_paletteram_ext(*this, "palette_ext"), m_sprgen(*this, "spritegen"), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), @@ -37,6 +39,8 @@ public: required_shared_ptr m_pf3_rowscroll; required_shared_ptr m_pf4_rowscroll; required_shared_ptr m_spriteram16; + required_shared_ptr m_paletteram; + required_shared_ptr m_paletteram_ext; optional_device m_sprgen; uint16_t m_spriteram16_buffer[0x400]; @@ -61,4 +65,7 @@ public: virtual void video_start() override; uint32_t screen_update_twocrude(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); DECO16IC_BANK_CB_MEMBER(bank_callback); + DECLARE_WRITE16_MEMBER(cbuster_palette_w); + DECLARE_WRITE16_MEMBER(cbuster_palette_ext_w); + void update_palette(int offset); }; diff --git a/src/mame/video/cbuster.cpp b/src/mame/video/cbuster.cpp index cd72fbad4a5..11d725c7bb7 100644 --- a/src/mame/video/cbuster.cpp +++ b/src/mame/video/cbuster.cpp @@ -22,6 +22,47 @@ void cbuster_state::video_start() m_sprgen->alloc_sprite_bitmap(); } +/* + Crude Buster palette is a little strange compared to other Data East games + of this period. Although the digital palette is 8 bits per channel, the + analog 'white' level is set at 0x8e. In hardware this is done at the + final resistors before the JAMMA connector. It also suggests that if the + game were to use any values above 0x8e (it doesn't) then the final output + voltage would be out of spec. + + I suspect this setup is actually software compensating for a hardware + design problem. +*/ + +void cbuster_state::update_palette(int offset) +{ + int r = m_paletteram[offset]&0xff; + int g = m_paletteram[offset]>>8; + int b = m_paletteram_ext[offset]&0xff; + + if (r>0x8e) r=0x8e; + if (g>0x8e) g=0x8e; + if (b>0x8e) b=0x8e; + + r = (r * 255) / 0x8e; + g = (g * 255) / 0x8e; + b = (b * 255) / 0x8e; + + m_palette->set_pen_color(offset,rgb_t(r,g,b)); +} + +WRITE16_MEMBER(cbuster_state::cbuster_palette_w) +{ + COMBINE_DATA(&m_paletteram[offset]); + update_palette(offset); +} + +WRITE16_MEMBER(cbuster_state::cbuster_palette_ext_w) +{ + COMBINE_DATA(&m_paletteram_ext[offset]); + update_palette(offset); +} + uint32_t cbuster_state::screen_update_twocrude(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { address_space &space = machine().dummy_space();