tms9928a: Expose internal palette through device_palette_interface

This commit is contained in:
AJR 2018-06-17 00:36:17 -04:00
parent e4e7a4780c
commit d4ee9c304e
2 changed files with 25 additions and 22 deletions

View File

@ -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) 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_t(mconfig, type, tag, owner, clock)
, device_memory_interface(mconfig, *this) , device_memory_interface(mconfig, *this)
, device_palette_interface(mconfig, *this)
, device_video_interface(mconfig, *this) , device_video_interface(mconfig, *this)
, m_vram_size(0) , m_vram_size(0)
, m_out_int_line_cb(*this) , 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 // update backdrop colour to transparent if EXTVID bit is set
if ((m_Regs[7] & 15) == 0) 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 */ /* Draw backdrop colour */
for ( int i = 0; i < TOTAL_HORZ; i++ ) 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 */ /* vblank is set at the last cycle of the first inactive line */
if ( y == 193 ) if ( y == 193 )
@ -361,7 +362,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
/* Left border */ /* Left border */
for ( int i = 0; i < HORZ_DISPLAY_START; i++ ) for ( int i = 0; i < HORZ_DISPLAY_START; i++ )
p[i] = m_palette[BackColour]; p[i] = pen(BackColour);
/* Active display */ /* 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 charcode = m_vram_space->read_byte( addr );
uint8_t pattern = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( y & 7 ) ); 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 ) ); uint8_t colour = m_vram_space->read_byte( m_colour + ( charcode >> 3 ) );
rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour]; rgb_t fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour]; rgb_t bg = pen((colour & 15) ? (colour & 15) : BackColour);
for ( int i = 0; i < 8; pattern <<= 1, i++ ) for ( int i = 0; i < 8; pattern <<= 1, i++ )
p[x+i] = ( pattern & 0x80 ) ? fg : bg; 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"); //if (vpos==100 ) popmessage("TMS9928A MODE 1");
{ {
uint16_t addr = m_nametbl + ( ( y >> 3 ) * 40 ); uint16_t addr = m_nametbl + ( ( y >> 3 ) * 40 );
rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour]; rgb_t fg = pen((m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour);
rgb_t bg = m_palette[BackColour]; rgb_t bg = pen(BackColour);
/* Extra 6 pixels left border */ /* Extra 6 pixels left border */
for ( int x = HORZ_DISPLAY_START; x < HORZ_DISPLAY_START + 6; x++ ) 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 ); 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 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 ) ); 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 fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour]; rgb_t bg = pen((colour & 15) ? (colour & 15) : BackColour);
for ( int i = 0; i < 8; pattern <<= 1, i++ ) for ( int i = 0; i < 8; pattern <<= 1, i++ )
p[x+i] = ( pattern & 0x80 ) ? fg : bg; 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"); //if (vpos==100) popmessage("TMS9928A MODE1+2");
{ {
uint16_t addr = m_nametbl + ( ( y >> 3 ) * 40 ); uint16_t addr = m_nametbl + ( ( y >> 3 ) * 40 );
rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour]; rgb_t fg = pen((m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour);
rgb_t bg = m_palette[BackColour]; rgb_t bg = pen(BackColour);
/* Extra 6 pixels left border */ /* Extra 6 pixels left border */
for ( int x = HORZ_DISPLAY_START; x < HORZ_DISPLAY_START + 6; x++ ) 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 charcode = m_vram_space->read_byte( addr );
uint8_t colour = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( ( y >> 2 ) & 7 ) ); 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 fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : 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+0] = p[x+1] = p[x+2] = p[x+3] = fg;
p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg; 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 */ case 5: case 7: /* MODE bogus */
//if (vpos==100 ) popmessage("TMS9928A 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 fg = pen((m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour);
rgb_t bg = m_palette[BackColour]; rgb_t bg = pen(BackColour);
/* Extra 6 pixels left border */ /* Extra 6 pixels left border */
for ( int x = HORZ_DISPLAY_START; x < HORZ_DISPLAY_START + 6; x++ ) 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 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 ) ); 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 fg = pen((colour >> 4) ? (colour >> 4) : BackColour);
rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : 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+0] = p[x+1] = p[x+2] = p[x+3] = fg;
p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg; 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 ) ) if ( ! ( spr_drawn[ colission_index ] & 0x02 ) )
{ {
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 */ /* Right border */
for ( int i = HORZ_DISPLAY_START + 256; i < TOTAL_HORZ; i++ ) for ( int i = HORZ_DISPLAY_START + 256; i < TOTAL_HORZ; i++ )
p[i] = m_palette[BackColour]; p[i] = pen(BackColour);
} }
/* Schedule next callback */ /* Schedule next callback */
@ -692,7 +693,7 @@ void tms9928a_device::set_palette()
/* copy default palette into working palette */ /* copy default palette into working palette */
for (int i = 0; i < PALETTE_SIZE; i++) 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_spriteattribute));
save_item(NAME(m_spritepattern)); save_item(NAME(m_spritepattern));
save_item(NAME(m_mode)); save_item(NAME(m_mode));
save_item(NAME(m_palette));
} }

View File

@ -71,6 +71,7 @@ DECLARE_DEVICE_TYPE(TMS9129, tms9129_device)
class tms9928a_device : public device_t, class tms9928a_device : public device_t,
public device_memory_interface, public device_memory_interface,
public device_palette_interface,
public device_video_interface public device_video_interface
{ {
public: public:
@ -123,6 +124,9 @@ protected:
// device_memory_interface overrides // device_memory_interface overrides
virtual space_config_vector memory_space_config() const override; virtual space_config_vector memory_space_config() const override;
// device_palette_interface overrides
virtual uint32_t palette_entries() const override { return 16; }
private: private:
void change_register(uint8_t reg, uint8_t val); void change_register(uint8_t reg, uint8_t val);
void check_interrupt(); void check_interrupt();
@ -157,7 +161,6 @@ private:
const bool m_50hz; const bool m_50hz;
const bool m_reva; const bool m_reva;
const bool m_99; const bool m_99;
rgb_t m_palette[16];
/* memory */ /* memory */
const address_space_config m_space_config; const address_space_config m_space_config;