From bbb25639e881e99191a9bd87d1443d94a06fdfb8 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 1 Jun 2018 18:01:37 -0400 Subject: [PATCH] mos8563: Use device_palette_interface instead of creating palette subdevice (nw) --- src/devices/video/mc6845.cpp | 56 ++++++++++++++---------------------- src/devices/video/mc6845.h | 15 +++++----- src/mame/drivers/c128.cpp | 4 +-- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/src/devices/video/mc6845.cpp b/src/devices/video/mc6845.cpp index ecafad88902..ffcca065d5b 100644 --- a/src/devices/video/mc6845.cpp +++ b/src/devices/video/mc6845.cpp @@ -1352,6 +1352,24 @@ void mos8563_device::device_start() data ^= 0xff; } + // VICE palette + set_pen_color(0, rgb_t::black()); + set_pen_color(1, rgb_t(0x55, 0x55, 0x55)); + set_pen_color(2, rgb_t(0x00, 0x00, 0xaa)); + set_pen_color(3, rgb_t(0x55, 0x55, 0xff)); + set_pen_color(4, rgb_t(0x00, 0xaa, 0x00)); + set_pen_color(5, rgb_t(0x55, 0xff, 0x55)); + set_pen_color(6, rgb_t(0x00, 0xaa, 0xaa)); + set_pen_color(7, rgb_t(0x55, 0xff, 0xff)); + set_pen_color(8, rgb_t(0xaa, 0x00, 0x00)); + set_pen_color(9, rgb_t(0xff, 0x55, 0x55)); + set_pen_color(10, rgb_t(0xaa, 0x00, 0xaa)); + set_pen_color(11, rgb_t(0xff, 0x55, 0xff)); + set_pen_color(12, rgb_t(0xaa, 0x55, 0x00)); + set_pen_color(13, rgb_t(0xff, 0xff, 0x55)); + set_pen_color(14, rgb_t(0xaa, 0xaa, 0xaa)); + set_pen_color(15, rgb_t::white()); + save_item(NAME(m_char_buffer)); save_item(NAME(m_attr_buffer)); save_item(NAME(m_attribute_addr)); @@ -1506,8 +1524,8 @@ ams40489_device::ams40489_device(const machine_config &mconfig, const char *tag, mos8563_device::mos8563_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : mc6845_device(mconfig, type, tag, owner, clock), device_memory_interface(mconfig, *this), - m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(mos8563_device::mos8563_videoram_map), this)), - m_palette(*this, "palette") + device_palette_interface(mconfig, *this), + m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(mos8563_device::mos8563_videoram_map), this)) { set_clock_scale(1.0/8); } @@ -1525,34 +1543,6 @@ mos8568_device::mos8568_device(const machine_config &mconfig, const char *tag, d } -MACHINE_CONFIG_START(mos8563_device::device_add_mconfig) - MCFG_PALETTE_ADD("palette", 16) - MCFG_PALETTE_INIT_OWNER(mos8563_device, mos8563) -MACHINE_CONFIG_END - - -// VICE palette -PALETTE_INIT_MEMBER(mos8563_device, mos8563) -{ - palette.set_pen_color(0, rgb_t::black()); - palette.set_pen_color(1, rgb_t(0x55, 0x55, 0x55)); - palette.set_pen_color(2, rgb_t(0x00, 0x00, 0xaa)); - palette.set_pen_color(3, rgb_t(0x55, 0x55, 0xff)); - palette.set_pen_color(4, rgb_t(0x00, 0xaa, 0x00)); - palette.set_pen_color(5, rgb_t(0x55, 0xff, 0x55)); - palette.set_pen_color(6, rgb_t(0x00, 0xaa, 0xaa)); - palette.set_pen_color(7, rgb_t(0x55, 0xff, 0xff)); - palette.set_pen_color(8, rgb_t(0xaa, 0x00, 0x00)); - palette.set_pen_color(9, rgb_t(0xff, 0x55, 0x55)); - palette.set_pen_color(10, rgb_t(0xaa, 0x00, 0xaa)); - palette.set_pen_color(11, rgb_t(0xff, 0x55, 0xff)); - palette.set_pen_color(12, rgb_t(0xaa, 0x55, 0x00)); - palette.set_pen_color(13, rgb_t(0xff, 0xff, 0x55)); - palette.set_pen_color(14, rgb_t(0xaa, 0xaa, 0xaa)); - palette.set_pen_color(15, rgb_t::white()); -} - - void mos8563_device::update_cursor_state() { mc6845_device::update_cursor_state(); @@ -1588,8 +1578,6 @@ uint8_t mos8563_device::draw_scanline(int y, bitmap_rgb32 &bitmap, const rectang MC6845_UPDATE_ROW( mos8563_device::vdc_update_row ) { - const pen_t *pen = m_palette->pens(); - ra += (m_vert_scroll & 0x0f); ra &= 0x0f; @@ -1627,7 +1615,7 @@ MC6845_UPDATE_ROW( mos8563_device::vdc_update_row ) if (x < 0) x = 0; int color = BIT(code, 7) ? fg : bg; - bitmap.pix32(vbp + y, hbp + x) = pen[de ? color : 0]; + bitmap.pix32(vbp + y, hbp + x) = pen(de ? color : 0); } } else @@ -1663,7 +1651,7 @@ MC6845_UPDATE_ROW( mos8563_device::vdc_update_row ) if (x < 0) x = 0; int color = BIT(data, 7) ? fg : bg; - bitmap.pix32(vbp + y, hbp + x) = pen[de ? color : 0]; + bitmap.pix32(vbp + y, hbp + x) = pen(de ? color : 0); if ((bit < 8) || !HSS_SEMI) data <<= 1; } diff --git a/src/devices/video/mc6845.h b/src/devices/video/mc6845.h index fbcb9ad4f13..966b81d3cb3 100644 --- a/src/devices/video/mc6845.h +++ b/src/devices/video/mc6845.h @@ -429,13 +429,12 @@ protected: }; class mos8563_device : public mc6845_device, - public device_memory_interface + public device_memory_interface, + public device_palette_interface { public: mos8563_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual space_config_vector memory_space_config() const override; - DECLARE_WRITE8_MEMBER( address_w ); DECLARE_READ8_MEMBER( status_r ); DECLARE_READ8_MEMBER( register_r ); @@ -450,13 +449,17 @@ protected: mos8563_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); // device-level overrides - virtual void device_add_mconfig(machine_config &config) override; virtual void device_start() override; virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + // device_memory_interface overrides + virtual space_config_vector memory_space_config() const override; + + // device_palette_interface overrides + virtual uint32_t palette_entries() const override { return 16; } + const address_space_config m_videoram_space_config; - required_device m_palette; uint8_t m_char_buffer[80]; uint8_t m_attr_buffer[80]; @@ -490,8 +493,6 @@ protected: emu_timer *m_block_copy_timer; - DECLARE_PALETTE_INIT(mos8563); - void mos8563_videoram_map(address_map &map); }; diff --git a/src/mame/drivers/c128.cpp b/src/mame/drivers/c128.cpp index 4d2b446ea1d..7d8b5007f7d 100644 --- a/src/mame/drivers/c128.cpp +++ b/src/mame/drivers/c128.cpp @@ -1730,7 +1730,7 @@ MACHINE_CONFIG_START(c128_state::ntsc) MCFG_SCREEN_VISIBLE_AREA(0, VIC6567_VISIBLECOLUMNS - 1, 0, VIC6567_VISIBLELINES - 1) MCFG_SCREEN_UPDATE_DEVICE(MOS8564_TAG, mos8564_device, screen_update) - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, MOS8563_TAG":palette", gfx_c128) + MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, MOS8563_TAG, gfx_c128) // sound hardware SPEAKER(config, "speaker").front_center(); @@ -1904,7 +1904,7 @@ MACHINE_CONFIG_START(c128_state::pal) MCFG_SCREEN_VISIBLE_AREA(0, VIC6569_VISIBLECOLUMNS - 1, 0, VIC6569_VISIBLELINES - 1) MCFG_SCREEN_UPDATE_DEVICE(MOS8566_TAG, mos8566_device, screen_update) - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, MOS8563_TAG":palette", gfx_c128) + MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, MOS8563_TAG, gfx_c128) // sound hardware SPEAKER(config, "speaker").front_center();