summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2018-06-17 00:36:17 -0400
committer AJR <ajrhacker@users.noreply.github.com>2018-06-17 00:37:23 -0400
commitd4ee9c304e9097c51afaacf38cd45a38e1c637ba (patch)
tree9d988dc785d07f820af348f6816d1f9666ce53c2
parente4e7a4780ca8da832d35b83b91382465b46c8eec (diff)
tms9928a: Expose internal palette through device_palette_interface
-rw-r--r--src/devices/video/tms9928a.cpp42
-rw-r--r--src/devices/video/tms9928a.h5
2 files changed, 25 insertions, 22 deletions
diff --git a/src/devices/video/tms9928a.cpp b/src/devices/video/tms9928a.cpp
index 8af4ba861f0..dbfcdabe2b4 100644
--- a/src/devices/video/tms9928a.cpp
+++ b/src/devices/video/tms9928a.cpp
@@ -58,6 +58,7 @@ void tms9928a_device::memmap(address_map &map)
tms9928a_device::tms9928a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool is_50hz, bool is_reva, bool is_99)
: device_t(mconfig, type, tag, owner, clock)
, device_memory_interface(mconfig, *this)
+ , device_palette_interface(mconfig, *this)
, device_video_interface(mconfig, *this)
, m_vram_size(0)
, m_out_int_line_cb(*this)
@@ -196,7 +197,7 @@ void tms9928a_device::update_backdrop()
{
// update backdrop colour to transparent if EXTVID bit is set
if ((m_Regs[7] & 15) == 0)
- m_palette[0] = rgb_t(m_Regs[0] & 1 ? 0 : 255,0,0,0);
+ set_pen_color(0, rgb_t(m_Regs[0] & 1 ? 0 : 255,0,0,0));
}
@@ -346,7 +347,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
{
/* Draw backdrop colour */
for ( int i = 0; i < TOTAL_HORZ; i++ )
- p[i] = m_palette[BackColour];
+ p[i] = pen(BackColour);
/* vblank is set at the last cycle of the first inactive line */
if ( y == 193 )
@@ -361,7 +362,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
/* Left border */
for ( int i = 0; i < HORZ_DISPLAY_START; i++ )
- p[i] = m_palette[BackColour];
+ p[i] = pen(BackColour);
/* Active display */
@@ -377,8 +378,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
uint8_t charcode = m_vram_space->read_byte( addr );
uint8_t pattern = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( y & 7 ) );
uint8_t colour = m_vram_space->read_byte( m_colour + ( charcode >> 3 ) );
- rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
- rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
+ rgb_t fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
+ rgb_t bg = pen((colour & 15) ? (colour & 15) : BackColour);
for ( int i = 0; i < 8; pattern <<= 1, i++ )
p[x+i] = ( pattern & 0x80 ) ? fg : bg;
@@ -390,8 +391,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
//if (vpos==100 ) popmessage("TMS9928A MODE 1");
{
uint16_t addr = m_nametbl + ( ( y >> 3 ) * 40 );
- rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour];
- rgb_t bg = m_palette[BackColour];
+ rgb_t fg = pen((m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour);
+ rgb_t bg = pen(BackColour);
/* Extra 6 pixels left border */
for ( int x = HORZ_DISPLAY_START; x < HORZ_DISPLAY_START + 6; x++ )
@@ -422,8 +423,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
uint16_t charcode = m_vram_space->read_byte( addr ) + ( ( y >> 6 ) << 8 );
uint8_t pattern = m_vram_space->read_byte( m_pattern + ( ( charcode & m_patternmask ) << 3 ) + ( y & 7 ) );
uint8_t colour = m_vram_space->read_byte( m_colour + ( ( charcode & m_colourmask ) << 3 ) + ( y & 7 ) );
- rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
- rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
+ rgb_t fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
+ rgb_t bg = pen((colour & 15) ? (colour & 15) : BackColour);
for ( int i = 0; i < 8; pattern <<= 1, i++ )
p[x+i] = ( pattern & 0x80 ) ? fg : bg;
@@ -435,8 +436,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
//if (vpos==100) popmessage("TMS9928A MODE1+2");
{
uint16_t addr = m_nametbl + ( ( y >> 3 ) * 40 );
- rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour];
- rgb_t bg = m_palette[BackColour];
+ rgb_t fg = pen((m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour);
+ rgb_t bg = pen(BackColour);
/* Extra 6 pixels left border */
for ( int x = HORZ_DISPLAY_START; x < HORZ_DISPLAY_START + 6; x++ )
@@ -466,8 +467,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
{
uint8_t charcode = m_vram_space->read_byte( addr );
uint8_t colour = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( ( y >> 2 ) & 7 ) );
- rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
- rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
+ rgb_t fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
+ rgb_t bg = pen((colour & 15) ? (colour & 15) : BackColour);
p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg;
p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg;
@@ -478,8 +479,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
case 5: case 7: /* MODE bogus */
//if (vpos==100 ) popmessage("TMS9928A MODE bogus");
{
- rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour];
- rgb_t bg = m_palette[BackColour];
+ rgb_t fg = pen((m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour);
+ rgb_t bg = pen(BackColour);
/* Extra 6 pixels left border */
for ( int x = HORZ_DISPLAY_START; x < HORZ_DISPLAY_START + 6; x++ )
@@ -506,8 +507,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
{
uint8_t charcode = m_vram_space->read_byte( addr );
uint8_t colour = m_vram_space->read_byte( m_pattern + ( ( ( charcode + ( ( y >> 2 ) & 7 ) + ( ( y >> 6 ) << 8 ) ) & m_patternmask ) << 3 ) );
- rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
- rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
+ rgb_t fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
+ rgb_t bg = pen((colour & 15) ? (colour & 15) : BackColour);
p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg;
p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg;
@@ -600,7 +601,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
if ( ! ( spr_drawn[ colission_index ] & 0x02 ) )
{
spr_drawn[ colission_index ] |= 0x02;
- p[ HORZ_DISPLAY_START + colission_index - 32 ] = m_palette[sprcol];
+ p[ HORZ_DISPLAY_START + colission_index - 32 ] = pen(sprcol);
}
}
}
@@ -625,7 +626,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
/* Right border */
for ( int i = HORZ_DISPLAY_START + 256; i < TOTAL_HORZ; i++ )
- p[i] = m_palette[BackColour];
+ p[i] = pen(BackColour);
}
/* Schedule next callback */
@@ -692,7 +693,7 @@ void tms9928a_device::set_palette()
/* copy default palette into working palette */
for (int i = 0; i < PALETTE_SIZE; i++)
{
- m_palette[i] = tms9928a_palette[i];
+ set_pen_color(i, tms9928a_palette[i]);
}
}
@@ -738,7 +739,6 @@ void tms9928a_device::device_start()
save_item(NAME(m_spriteattribute));
save_item(NAME(m_spritepattern));
save_item(NAME(m_mode));
- save_item(NAME(m_palette));
}
diff --git a/src/devices/video/tms9928a.h b/src/devices/video/tms9928a.h
index f6e934664a3..d5dcfca7347 100644
--- a/src/devices/video/tms9928a.h
+++ b/src/devices/video/tms9928a.h
@@ -71,6 +71,7 @@ DECLARE_DEVICE_TYPE(TMS9129, tms9129_device)
class tms9928a_device : public device_t,
public device_memory_interface,
+ public device_palette_interface,
public device_video_interface
{
public:
@@ -123,6 +124,9 @@ protected:
// 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; }
+
private:
void change_register(uint8_t reg, uint8_t val);
void check_interrupt();
@@ -157,7 +161,6 @@ private:
const bool m_50hz;
const bool m_reva;
const bool m_99;
- rgb_t m_palette[16];
/* memory */
const address_space_config m_space_config;