Merge pull request #4314 from hp9k/nereid_device_palette_interface

nereid: use device_palette_interface (nw)
This commit is contained in:
ajrhacker 2018-11-18 22:47:24 -05:00 committed by GitHub
commit e567e10237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 20 deletions

View File

@ -11,6 +11,7 @@ DEFINE_DEVICE_TYPE(NEREID, nereid_device, "nereid", "HP Nereid ASIC")
nereid_device::nereid_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : nereid_device::nereid_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock), device_t(mconfig, type, tag, owner, clock),
device_palette_interface(mconfig, *this),
m_red(0), m_red(0),
m_green(0), m_green(0),
m_blue(0), m_blue(0),
@ -30,8 +31,6 @@ void nereid_device::device_start()
save_item(NAME(m_green)); save_item(NAME(m_green));
save_item(NAME(m_blue)); save_item(NAME(m_blue));
save_item(NAME(m_index)); save_item(NAME(m_index));
save_item(NAME(m_video_palette));
save_item(NAME(m_overlay_palette));
save_item(NAME(m_plane_mask)); save_item(NAME(m_plane_mask));
save_item(NAME(m_overlay_ctl)); save_item(NAME(m_overlay_ctl));
save_item(NAME(m_overlay_index)); save_item(NAME(m_overlay_index));
@ -40,9 +39,8 @@ void nereid_device::device_start()
void nereid_device::device_reset() void nereid_device::device_reset()
{ {
std::fill(m_video_palette.begin(), m_video_palette.end(), 0); for(int i = 0; i < palette_entries(); i++)
std::fill(m_overlay_palette.begin(), m_overlay_palette.end(), 0); set_pen_color(i, rgb_t(0, 0, 0));
m_index = 0; m_index = 0;
m_plane_mask = 0; m_plane_mask = 0;
m_overlay_ctl = 0; m_overlay_ctl = 0;
@ -136,20 +134,22 @@ WRITE16_MEMBER(nereid_device::ctrl_w)
const int index = (m_overlay_index >> 1) & 0x3; const int index = (m_overlay_index >> 1) & 0x3;
LOG("NEREID: set overlay color index %u: rgb_t(%u,%u,%u)\n", LOG("NEREID: set overlay color index %u: rgb_t(%u,%u,%u)\n",
index, m_red, m_green, m_blue); index, m_red, m_green, m_blue);
m_overlay_palette[index] = rgb_t(m_red, m_green, m_blue); set_pen_color(index | 0x100, rgb_t(m_red, m_green, m_blue));
} else { } else {
LOG("NEREID: set video color index %u: rgb_t(%u,%u,%u)\n", LOG("NEREID: set video color index %u: rgb_t(%u,%u,%u)\n",
m_index, m_red, m_green, m_blue); m_index, m_red, m_green, m_blue);
m_video_palette[m_index] = rgb_t(m_red, m_green, m_blue); set_pen_color(m_index, rgb_t(m_red, m_green, m_blue));
} }
break; break;
case NEREID_READ_STROBE: case NEREID_READ_STROBE:
m_red = m_video_palette[m_index].r(); {
m_green = m_video_palette[m_index].g(); rgb_t tmp = pen_color(m_index);
m_blue = m_video_palette[m_index].b(); m_red = tmp.r();
m_green = tmp.g();
m_blue = tmp.b();
break; break;
}
case NEREID_PLANE_MASK: case NEREID_PLANE_MASK:
m_plane_mask = data; m_plane_mask = data;
LOG("W NEREID_PLANE_MASK = %02x\n", m_plane_mask); LOG("W NEREID_PLANE_MASK = %02x\n", m_plane_mask);
@ -180,8 +180,9 @@ rgb_t nereid_device::map_color(uint8_t input, uint8_t ovl)
{ {
ovl &= m_overlay_ctl; ovl &= m_overlay_ctl;
if (ovl == 0) if (ovl == 0) {
return m_video_palette[input & m_plane_mask]; return pen_color(input & m_plane_mask);
else } else {
return m_overlay_palette[ovl & m_plane_mask]; return pen_color((ovl & m_plane_mask) | 0x100);
}
} }

View File

@ -5,7 +5,7 @@
#pragma once #pragma once
class nereid_device : public device_t class nereid_device : public device_t, public device_palette_interface
{ {
public: public:
nereid_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); nereid_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@ -19,6 +19,7 @@ protected:
nereid_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); nereid_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
virtual void device_start() override; virtual void device_start() override;
virtual void device_reset() override; virtual void device_reset() override;
virtual u32 palette_entries() const override { return 0x200; }
private: private:
static constexpr int NEREID_BUSY=1; static constexpr int NEREID_BUSY=1;
@ -38,10 +39,6 @@ private:
static constexpr int NEREID_WRITE_STROBE=0x78; static constexpr int NEREID_WRITE_STROBE=0x78;
static constexpr int NEREID_READ_STROBE=0x7c; static constexpr int NEREID_READ_STROBE=0x7c;
std::array<rgb_t, 256> m_video_palette;
std::array<rgb_t, 256> m_overlay_palette;
/* registers */ /* registers */
uint8_t m_red; uint8_t m_red;
uint8_t m_green; uint8_t m_green;