tms9928a/v9938: Now using own address space for attached video memory, appears in memory selection list in debugger. Also cleaned up v9938. [Michael Zapf]

This commit is contained in:
Michael Zapf 2012-07-06 20:31:09 +00:00
parent 54a6159a82
commit 323140f125
4 changed files with 1124 additions and 1119 deletions

View File

@ -34,6 +34,13 @@ const device_type TMS9929 = &device_creator<tms9929_device>;
const device_type TMS9929A = &device_creator<tms9929a_device>;
const device_type TMS9129 = &device_creator<tms9129_device>;
/*
The TMS9928 has an own address space.
*/
static ADDRESS_MAP_START(memmap, AS_DATA, 8, tms9928a_device)
ADDRESS_MAP_GLOBAL_MASK(0x3fff)
AM_RANGE(0x0000, 0x3fff) AM_RAM
ADDRESS_MAP_END
/*
New palette (R. Nabet).
@ -94,18 +101,24 @@ PALETTE_INIT( tms9928a )
tms9928a_device::tms9928a_device( const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_50hz, bool is_reva )
: device_t( mconfig, type, name, tag, owner, clock )
: device_t( mconfig, type, name, tag, owner, clock ),
device_memory_interface(mconfig, *this),
m_space_config("vram", ENDIANNESS_BIG, 8, 14)
{
m_50hz = is_50hz;
m_reva = is_reva;
static_set_addrmap(*this, AS_DATA, ADDRESS_MAP_NAME(memmap));
}
tms9928a_device::tms9928a_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
: device_t( mconfig, TMS9928A, "tms9928a", tag, owner, clock )
: device_t( mconfig, TMS9928A, "TMS9928A", tag, owner, clock ),
device_memory_interface(mconfig, *this),
m_space_config("vram", ENDIANNESS_BIG, 8, 14)
{
m_50hz = false;
m_reva = true;
static_set_addrmap(*this, AS_DATA, ADDRESS_MAP_NAME(memmap));
}
@ -113,7 +126,7 @@ READ8_MEMBER( tms9928a_device::vram_read )
{
UINT8 data = m_ReadAhead;
m_ReadAhead = m_vMem[ m_Addr ];
m_ReadAhead = m_vram_space->read_byte(m_Addr);
m_Addr = (m_Addr + 1) & (m_vram_size - 1);
m_latch = 0;
@ -123,7 +136,7 @@ READ8_MEMBER( tms9928a_device::vram_read )
WRITE8_MEMBER( tms9928a_device::vram_write )
{
m_vMem[ m_Addr ] = data;
m_vram_space->write_byte(m_Addr, data);
m_Addr = (m_Addr + 1) & (m_vram_size - 1);
m_ReadAhead = data;
m_latch = 0;
@ -313,9 +326,9 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ )
{
UINT8 charcode = m_vMem[ addr ];
UINT8 pattern = m_vMem[ m_pattern + ( charcode << 3 ) + ( y & 7 ) ];
UINT8 colour = m_vMem[ m_colour + ( charcode >> 3 ) ];
UINT8 charcode = m_vram_space->read_byte( addr );
UINT8 pattern = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( y & 7 ) );
UINT8 colour = m_vram_space->read_byte( m_colour + ( charcode >> 3 ) );
UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
@ -338,8 +351,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( int x = TMS9928A_HORZ_DISPLAY_START + 6; x < TMS9928A_HORZ_DISPLAY_START + 246; x+= 6, addr++ )
{
UINT16 charcode = m_vMem[ addr ];
UINT8 pattern = m_vMem[ m_pattern + ( charcode << 3 ) + ( y & 7 ) ];
UINT16 charcode = m_vram_space->read_byte( addr );
UINT8 pattern = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( y & 7 ) );
for ( int i = 0; i < 6; pattern <<= 1, i++ )
p[x+i] = ( pattern & 0x80 ) ? fg : bg;
@ -358,9 +371,9 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ )
{
UINT16 charcode = m_vMem[ addr ] + ( ( y >> 6 ) << 8 );
UINT8 pattern = m_vMem[ m_pattern + ( ( charcode & m_patternmask ) << 3 ) + ( y & 7 ) ];
UINT8 colour = m_vMem[ m_colour + ( ( charcode & m_colourmask ) << 3 ) + ( y & 7 ) ];
UINT16 charcode = m_vram_space->read_byte( addr ) + ( ( y >> 6 ) << 8 );
UINT8 pattern = m_vram_space->read_byte( m_pattern + ( ( charcode & m_patternmask ) << 3 ) + ( y & 7 ) );
UINT8 colour = m_vram_space->read_byte( m_colour + ( ( charcode & m_colourmask ) << 3 ) + ( y & 7 ) );
UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
@ -383,8 +396,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( int x = TMS9928A_HORZ_DISPLAY_START + 6; x < TMS9928A_HORZ_DISPLAY_START + 246; x+= 6, addr++ )
{
UINT16 charcode = ( m_vMem[ addr ] + ( ( y >> 6 ) << 8 ) ) & m_patternmask;
UINT8 pattern = m_vMem[ m_pattern + ( charcode << 3 ) + ( y & 7 ) ];
UINT16 charcode = ( m_vram_space->read_byte( addr ) + ( ( y >> 6 ) << 8 ) ) & m_patternmask;
UINT8 pattern = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( y & 7 ) );
for ( int i = 0; i < 6; pattern <<= 1, i++ )
p[x+i] = ( pattern & 0x80 ) ? fg : bg;
@ -403,8 +416,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ )
{
UINT8 charcode = m_vMem[ addr ];
UINT8 colour = m_vMem[ m_pattern + ( charcode << 3 ) + ( ( y >> 2 ) & 7 ) ];
UINT8 charcode = m_vram_space->read_byte( addr );
UINT8 colour = m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( ( y >> 2 ) & 7 ) );
UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
@ -443,8 +456,8 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ )
{
UINT8 charcode = m_vMem[ addr ];
UINT8 colour = m_vMem[ m_pattern + ( ( ( charcode + ( ( y >> 2 ) & 7 ) + ( ( y >> 6 ) << 8 ) ) & m_patternmask ) << 3 ) ];
UINT8 charcode = m_vram_space->read_byte( addr );
UINT8 colour = m_vram_space->read_byte( m_pattern + ( ( ( charcode + ( ( y >> 2 ) & 7 ) + ( ( y >> 6 ) << 8 ) ) & m_patternmask ) << 3 ) );
UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
@ -472,7 +485,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
for ( UINT16 sprattr = 0; sprattr < 128; sprattr += 4 )
{
int spr_y = m_vMem[ m_spriteattribute + sprattr + 0 ];
int spr_y = m_vram_space->read_byte( m_spriteattribute + sprattr + 0 );
m_FifthSprite = sprattr / 4;
@ -489,9 +502,9 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
/* is sprite enabled on this line? */
if ( spr_y <= y && y < spr_y + sprite_height )
{
int spr_x = m_vMem[ m_spriteattribute + sprattr + 1 ];
UINT8 sprcode = m_vMem[ m_spriteattribute + sprattr + 2 ];
UINT8 sprcol = m_vMem[ m_spriteattribute + sprattr + 3 ];
int spr_x = m_vram_space->read_byte( m_spriteattribute + sprattr + 1 );
UINT8 sprcode = m_vram_space->read_byte( m_spriteattribute + sprattr + 2 );
UINT8 sprcol = m_vram_space->read_byte( m_spriteattribute + sprattr + 3 );
UINT16 pataddr = m_spritepattern + ( ( sprite_size == 16 ) ? sprcode & ~0x03 : sprcode ) * 8;
num_sprites++;
@ -508,7 +521,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
else
pataddr += ( ( y - spr_y ) & 0x0F );
UINT8 pattern = m_vMem[ pataddr ];
UINT8 pattern = m_vram_space->read_byte( pataddr );
if ( sprcol & 0x80 )
spr_x -= 32;
@ -547,7 +560,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par
}
}
pattern = m_vMem[ pataddr + 16 ];
pattern = m_vram_space->read_byte( pataddr + 16 );
spr_x += sprite_mag ? 16 : 8;
}
}
@ -597,8 +610,6 @@ void tms9928a_device::device_config_complete()
void tms9928a_device::device_start()
{
assert_always(((m_vram_size == 0x1000) || (m_vram_size == 0x2000) || (m_vram_size == 0x4000)), "4, 8 or 16 kB vram please");
m_screen = machine().device<screen_device>( m_screen_tag );
assert( m_screen != NULL );
@ -607,8 +618,8 @@ void tms9928a_device::device_start()
m_irq_changed.resolve( m_out_int_line, *this );
/* Video RAM */
m_vMem = auto_alloc_array_clear(machine(), UINT8, m_vram_size);
// Video RAM is allocated as an own address space
m_vram_space = space(AS_DATA);
/* back bitmap */
m_tmpbmp.allocate(TMS9928A_TOTAL_HORZ, TMS9928A_TOTAL_VERT_PAL);
@ -629,7 +640,7 @@ void tms9928a_device::device_start()
save_item(NAME(m_latch));
save_item(NAME(m_Addr));
save_item(NAME(m_INT));
save_pointer(NAME(m_vMem), m_vram_size);
// save_pointer(NAME(m_vMem), m_vram_size);
save_item(NAME(m_colour));
save_item(NAME(m_colourmask));
save_item(NAME(m_pattern));

View File

@ -82,6 +82,7 @@ struct _tms9928a_interface
const char *m_screen_tag;
int m_vram_size; /* 4K, 8K, or 16K. This should be replaced by fetching data from an address space? */
devcb_write_line m_out_int_line; /* Callback is called whenever the state of the INT output changes */
const char *m_regionname; // Alternatively, get the name of the region (if vram size is 0)
};
@ -89,6 +90,7 @@ PALETTE_INIT( tms9928a );
class tms9928a_device : public device_t,
public device_memory_interface,
public tms9928a_interface
{
public:
@ -113,7 +115,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// device_memory_interface overrides
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_0) ? &m_space_config : NULL; }
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_DATA) const { return (spacenum == AS_DATA) ? &m_space_config : NULL; }
private:
void change_register(UINT8 reg, UINT8 val);
@ -145,8 +147,8 @@ private:
/* memory */
const address_space_config m_space_config;
address_space* m_vram_space;
UINT8 *m_vMem;
bitmap_ind16 m_tmpbmp;
emu_timer *m_line_timer;
UINT8 m_mode;
@ -161,7 +163,7 @@ class tms9918_device : public tms9928a_device
{
public:
tms9918_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9918, "tms9918", tag, owner, clock, false, false ) { }
: tms9928a_device( mconfig, TMS9918, "TMS9918", tag, owner, clock, false, false ) { }
};
@ -169,7 +171,7 @@ class tms9918a_device : public tms9928a_device
{
public:
tms9918a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9918A, "tms9918a", tag, owner, clock, false, true ) { }
: tms9928a_device( mconfig, TMS9918A, "TMS9918a", tag, owner, clock, false, true ) { }
};
@ -177,7 +179,7 @@ class tms9118_device : public tms9928a_device
{
public:
tms9118_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9118, "tms9118", tag, owner, clock, false, true ) { }
: tms9928a_device( mconfig, TMS9118, "TMS9118", tag, owner, clock, false, true ) { }
};
@ -185,7 +187,7 @@ class tms9128_device : public tms9928a_device
{
public:
tms9128_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9128, "tms9128", tag, owner, clock, false, true ) { }
: tms9928a_device( mconfig, TMS9128, "TMS9128", tag, owner, clock, false, true ) { }
};
@ -193,7 +195,7 @@ class tms9929_device : public tms9928a_device
{
public:
tms9929_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9929, "tms9929", tag, owner, clock, true, false ) { }
: tms9928a_device( mconfig, TMS9929, "TMS9929", tag, owner, clock, true, false ) { }
};
@ -201,7 +203,7 @@ class tms9929a_device : public tms9928a_device
{
public:
tms9929a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9929A, "tms9929a", tag, owner, clock, true, true ) { }
: tms9928a_device( mconfig, TMS9929A, "TMS9929A", tag, owner, clock, true, true ) { }
};
@ -209,7 +211,7 @@ class tms9129_device : public tms9928a_device
{
public:
tms9129_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: tms9928a_device( mconfig, TMS9129, "tms9129", tag, owner, clock, true, true ) { }
: tms9928a_device( mconfig, TMS9129, "TMS9129", tag, owner, clock, true, true ) { }
};

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,7 @@ typedef delegate<void (v99x8_device &, int)> v99x8_interrupt_delegate;
// ======================> v99x8_device
class v99x8_device : public device_t
class v99x8_device : public device_t, public device_memory_interface
{
friend PALETTE_INIT( v9958 );
@ -97,19 +97,25 @@ public:
static void static_set_interrupt_callback(device_t &device, v99x8_interrupt_delegate callback, const char *device_name);
protected:
const address_space_config m_space_config;
address_space* m_vram_space;
int m_model;
// device overrides
virtual void device_start();
virtual void device_reset();
// device_memory_interface overrides
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_DATA) const { return (spacenum == AS_DATA) ? &m_space_config : NULL; }
private:
// internal helpers
void reset_palette ();
void vram_write (int offset, int data);
int vram_read (int offset);
void check_int ();
void register_write (int reg, int data);
void reset_palette();
void vram_write(int offset, int data);
int vram_read(int offset);
void check_int();
void register_write(int reg, int data);
template<typename _PixelType, int _Width> void default_border(const pen_t *pens, _PixelType *ln);
template<typename _PixelType, int _Width> void graphic7_border(const pen_t *pens, _PixelType *ln);
@ -128,15 +134,15 @@ private:
template<typename _PixelType, int _Width> void graphic5_draw_sprite(const pen_t *pens, _PixelType *ln, UINT8 *col);
template<typename _PixelType, int _Width> void graphic7_draw_sprite(const pen_t *pens, _PixelType *ln, UINT8 *col);
void sprite_mode1 (int line, UINT8 *col);
void sprite_mode2 (int line, UINT8 *col);
void set_mode ();
void refresh_16 (int line);
void refresh_line (int line);
void sprite_mode1(int line, UINT8 *col);
void sprite_mode2(int line, UINT8 *col);
void set_mode();
void refresh_16(int line);
void refresh_line(int line);
void interrupt_start_vblank ();
void interrupt_start_vblank();
UINT8 *VDPVRMP(UINT8 M, int MX, int X, int Y);
int VDPVRMP(UINT8 M, int MX, int X, int Y);
UINT8 VDPpoint5(int MXS, int SX, int SY);
UINT8 VDPpoint6(int MXS, int SX, int SY);
@ -145,7 +151,7 @@ private:
UINT8 VDPpoint(UINT8 SM, int MXS, int SX, int SY);
void VDPpsetlowlevel(UINT8 *P, UINT8 CL, UINT8 M, UINT8 OP);
void VDPpsetlowlevel(int addr, UINT8 CL, UINT8 M, UINT8 OP);
void VDPpset5(int MXD, int DX, int DY, UINT8 CL, UINT8 OP);
void VDPpset6(int MXD, int DX, int DY, UINT8 CL, UINT8 OP);
@ -154,24 +160,26 @@ private:
void VDPpset(UINT8 SM, int MXD, int DX, int DY, UINT8 CL, UINT8 OP);
int GetVdpTimingValue(const int *);
int get_vdp_timing_value(const int *);
void SrchEngine();
void LineEngine();
void LmmvEngine();
void LmmmEngine();
void LmcmEngine();
void LmmcEngine();
void HmmvEngine();
void HmmmEngine();
void YmmmEngine();
void HmmcEngine();
void srch_engine();
void line_engine();
void lmmv_engine();
void lmmm_engine();
void lmcm_engine();
void lmmc_engine();
void hmmv_engine();
void hmmm_engine();
void ymmm_engine();
void hmmc_engine();
void cpu_to_vdp (UINT8 V);
UINT8 vdp_to_cpu ();
void ReportVdpCommand(UINT8 Op);
UINT8 command_unit_w (UINT8 Op);
void update_command ();
inline bool v9938_second_field();
void cpu_to_vdp(UINT8 V);
UINT8 vdp_to_cpu();
void report_vdp_command(UINT8 Op);
UINT8 command_unit_w(UINT8 Op);
void update_command();
// general
int m_offset_x, m_offset_y, m_visible_y, m_mode;
@ -179,10 +187,11 @@ private:
int m_pal_write_first, m_cmd_write_first;
UINT8 m_pal_write, m_cmd_write;
UINT8 m_pal_reg[32], m_stat_reg[10], m_cont_reg[48], m_read_ahead;
// memory
UINT16 m_address_latch;
UINT8 *m_vram_exp;
int m_vram_size;
// interrupt
UINT8 m_int_state;
v99x8_interrupt_delegate m_int_callback;
@ -222,8 +231,6 @@ private:
int m_vdp_ops_count;
void (v99x8_device::*m_vdp_engine)();
UINT8 m_vram[0x20000];
struct v99x8_mode
{
UINT8 m;