From d3f86f910e7291833c430b6f9741f555fa2f156e Mon Sep 17 00:00:00 2001 From: arbee Date: Mon, 11 Dec 2023 08:25:20 -0500 Subject: nubus/nubus_vikbw.cpp: Additional modernizations, add save state support. [R. Belmont] --- src/devices/bus/nubus/nubus_vikbw.cpp | 74 ++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/src/devices/bus/nubus/nubus_vikbw.cpp b/src/devices/bus/nubus/nubus_vikbw.cpp index 2f648e552ff..88f3ef5a5d4 100644 --- a/src/devices/bus/nubus/nubus_vikbw.cpp +++ b/src/devices/bus/nubus/nubus_vikbw.cpp @@ -20,6 +20,7 @@ ***************************************************************************/ #include "emu.h" +#include "emupal.h" #include "nubus_vikbw.h" #include "screen.h" @@ -32,10 +33,10 @@ class nubus_vikbw_device : public device_t, { public: // construction/destruction - nubus_vikbw_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nubus_vikbw_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); protected: - nubus_vikbw_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + nubus_vikbw_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); // device-level overrides virtual void device_start() override; @@ -46,15 +47,15 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override; private: - uint32_t viking_ack_r(); - void viking_ack_w(uint32_t data); - uint32_t viking_enable_r(); - void viking_disable_w(uint32_t data); + u32 viking_ack_r(); + void viking_ack_w(u32 data); + u32 viking_enable_r(); + void viking_disable_w(u32 data); - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - std::vector m_vram; - uint32_t m_vbl_disable, m_palette[2]; + std::unique_ptr m_vram; + u32 m_vbl_disable; }; ROM_START( vikbw ) @@ -67,6 +68,9 @@ void nubus_vikbw_device::device_add_mconfig(machine_config &config) screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_screen_update(FUNC(nubus_vikbw_device::screen_update)); screen.set_raw(72000000, 1324, 0, 1024, 803, 0, 768); + screen.set_palette("palette"); + + PALETTE(config, "palette", palette_device::MONOCHROME_INVERTED); } const tiny_rom_entry *nubus_vikbw_device::device_rom_region() const @@ -74,12 +78,12 @@ const tiny_rom_entry *nubus_vikbw_device::device_rom_region() const return ROM_NAME( vikbw ); } -nubus_vikbw_device::nubus_vikbw_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +nubus_vikbw_device::nubus_vikbw_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : nubus_vikbw_device(mconfig, NUBUS_VIKBW, tag, owner, clock) { } -nubus_vikbw_device::nubus_vikbw_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : +nubus_vikbw_device::nubus_vikbw_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, type, tag, owner, clock), device_nubus_card_interface(mconfig, *this), m_vbl_disable(0) @@ -88,74 +92,74 @@ nubus_vikbw_device::nubus_vikbw_device(const machine_config &mconfig, device_typ void nubus_vikbw_device::device_start() { - uint32_t slotspace; + u32 slotspace; install_declaration_rom("vikingrom", true); slotspace = get_slotspace(); - m_vram.resize(VRAM_SIZE / sizeof(uint32_t)); - install_bank(slotspace+0x40000, slotspace+0x40000+VRAM_SIZE-1, &m_vram[0]); + m_vram = std::make_unique(VRAM_SIZE / sizeof(u32)); + install_bank(slotspace + 0x40000, slotspace + 0x40000 + VRAM_SIZE - 1, &m_vram[0]); install_bank(slotspace+0x940000, slotspace+0x940000+VRAM_SIZE-1, &m_vram[0]); nubus().install_device(slotspace, slotspace+3, read32smo_delegate(*this, FUNC(nubus_vikbw_device::viking_enable_r)), write32smo_delegate(*this, FUNC(nubus_vikbw_device::viking_disable_w))); nubus().install_device(slotspace+0x80000, slotspace+0x80000+3, read32smo_delegate(*this, FUNC(nubus_vikbw_device::viking_ack_r)), write32smo_delegate(*this, FUNC(nubus_vikbw_device::viking_ack_w))); + + save_item(NAME(m_vbl_disable)); + save_pointer(NAME(m_vram), VRAM_SIZE / sizeof(u32)); } void nubus_vikbw_device::device_reset() { m_vbl_disable = 1; - std::fill(m_vram.begin(), m_vram.end(), 0); - - m_palette[0] = rgb_t(255, 255, 255); - m_palette[1] = rgb_t(0, 0, 0); + std::fill_n(&m_vram[0], VRAM_SIZE / sizeof(u32), 0); } -uint32_t nubus_vikbw_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +u32 nubus_vikbw_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { if (!m_vbl_disable) { raise_slot_irq(); } - auto const vram8 = util::big_endian_cast(&m_vram[0]); + auto const vram8 = util::big_endian_cast(&m_vram[0]); for (int y = 0; y < 768; y++) { - uint32_t *scanline = &bitmap.pix(y); + u16 *scanline = &bitmap.pix(y); for (int x = 0; x < 1024/8; x++) { - uint8_t const pixels = vram8[(y * 128) + x]; - - *scanline++ = m_palette[BIT(pixels, 7)]; - *scanline++ = m_palette[BIT(pixels, 6)]; - *scanline++ = m_palette[BIT(pixels, 5)]; - *scanline++ = m_palette[BIT(pixels, 4)]; - *scanline++ = m_palette[BIT(pixels, 3)]; - *scanline++ = m_palette[BIT(pixels, 2)]; - *scanline++ = m_palette[BIT(pixels, 1)]; - *scanline++ = m_palette[BIT(pixels, 0)]; + u8 const pixels = vram8[(y * 128) + x]; + + *scanline++ = BIT(pixels, 7); + *scanline++ = BIT(pixels, 6); + *scanline++ = BIT(pixels, 5); + *scanline++ = BIT(pixels, 4); + *scanline++ = BIT(pixels, 3); + *scanline++ = BIT(pixels, 2); + *scanline++ = BIT(pixels, 1); + *scanline++ = BIT(pixels, 0); } } return 0; } -void nubus_vikbw_device::viking_ack_w(uint32_t data) +void nubus_vikbw_device::viking_ack_w(u32 data) { lower_slot_irq(); } -uint32_t nubus_vikbw_device::viking_ack_r() +u32 nubus_vikbw_device::viking_ack_r() { return 0; } -void nubus_vikbw_device::viking_disable_w(uint32_t data) +void nubus_vikbw_device::viking_disable_w(u32 data) { m_vbl_disable = 1; } -uint32_t nubus_vikbw_device::viking_enable_r() +u32 nubus_vikbw_device::viking_enable_r() { m_vbl_disable = 0; return 0; -- cgit v1.2.3