summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/psx
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/psx')
-rw-r--r--src/devices/cpu/psx/dma.cpp386
-rw-r--r--src/devices/cpu/psx/dma.h12
-rw-r--r--src/devices/cpu/psx/gte.cpp6
-rw-r--r--src/devices/cpu/psx/gte.h2
-rw-r--r--src/devices/cpu/psx/irq.cpp68
-rw-r--r--src/devices/cpu/psx/irq.h32
-rw-r--r--src/devices/cpu/psx/mdec.cpp47
-rw-r--r--src/devices/cpu/psx/mdec.h8
-rw-r--r--src/devices/cpu/psx/psx.cpp133
-rw-r--r--src/devices/cpu/psx/psx.h63
-rw-r--r--src/devices/cpu/psx/psxdasm.cpp140
-rw-r--r--src/devices/cpu/psx/rcnt.cpp102
-rw-r--r--src/devices/cpu/psx/rcnt.h13
-rw-r--r--src/devices/cpu/psx/sio.cpp100
-rw-r--r--src/devices/cpu/psx/sio.h13
15 files changed, 562 insertions, 563 deletions
diff --git a/src/devices/cpu/psx/dma.cpp b/src/devices/cpu/psx/dma.cpp
index 5ec8e29fdbd..d0c3836ea43 100644
--- a/src/devices/cpu/psx/dma.cpp
+++ b/src/devices/cpu/psx/dma.cpp
@@ -10,22 +10,19 @@
#include "emu.h"
#include "dma.h"
-#define VERBOSE_LEVEL ( 0 )
+#define LOG_READ (1U << 1)
+#define LOG_WRITE (1U << 2)
+#define LOG_DMA (1U << 3)
+#define LOG_IRQ (1U << 4)
-static inline void ATTR_PRINTF(3,4) verboselog( device_t& device, int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- device.logerror( "%s: %s", device.machine().describe_context(), buf );
- }
-}
+//#define VERBOSE (LOG_READ | LOG_WRITE | LOG_DMA | LOG_IRQ)
+//#define LOG_OUTPUT_FUNC osd_printf_info
+#include "logmacro.h"
-DEFINE_DEVICE_TYPE(PSX_DMA, psxdma_device, "psxdma", "Sony PSX DMA")
+#define LOGREAD(...) LOGMASKED(LOG_READ, __VA_ARGS__)
+#define LOGWRITE(...) LOGMASKED(LOG_WRITE, __VA_ARGS__)
+#define LOGDMA(...) LOGMASKED(LOG_DMA, __VA_ARGS__)
+#define LOGIRQ(...) LOGMASKED(LOG_IRQ, __VA_ARGS__)
psxdma_device::psxdma_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, PSX_DMA, tag, owner, clock), m_ram(), m_ramsize(0), m_dpcp(0), m_dicr(0),
@@ -35,77 +32,61 @@ psxdma_device::psxdma_device(const machine_config &mconfig, const char *tag, dev
void psxdma_device::device_reset()
{
- int n;
-
m_dpcp = 0;
m_dicr = 0;
- for( n = 0; n < 7; n++ )
- {
- dma_stop_timer( n );
- }
-}
-
-void psxdma_device::device_post_load()
-{
- int n;
-
- for( n = 0; n < 7; n++ )
+ for (int n = 0; n < 7; n++)
{
- dma_timer_adjust( n );
+ dma_stop_timer(n);
+ m_channel[n].n_channelcontrol = 0;
}
}
void psxdma_device::device_start()
{
- m_irq_handler.resolve_safe();
-
- for( int index = 0; index < 7; index++ )
+ for (int index = 0; index < 7; index++)
{
- psx_dma_channel *dma = &m_channel[ index ];
+ psx_dma_channel *dma = &m_channel[index];
- dma->timer = timer_alloc(index);
+ dma->timer = timer_alloc(FUNC(psxdma_device::dma_finished), this);
+ dma->b_running = 0;
- save_item( NAME( dma->n_base ), index );
- save_item( NAME( dma->n_blockcontrol ), index );
- save_item( NAME( dma->n_channelcontrol ), index );
- save_item( NAME( dma->n_ticks ), index );
- save_item( NAME( dma->b_running ), index );
+ save_item(NAME(dma->n_base), index);
+ save_item(NAME(dma->n_blockcontrol), index);
+ save_item(NAME(dma->n_channelcontrol), index);
+ save_item(NAME(dma->n_ticks), index);
+ save_item(NAME(dma->b_running), index);
}
- save_item( NAME(m_dpcp) );
- save_item( NAME(m_dicr) );
+ save_item(NAME(m_dpcp));
+ save_item(NAME(m_dicr));
}
-void psxdma_device::dma_start_timer( int index, uint32_t n_ticks )
+void psxdma_device::dma_start_timer(int index, uint32_t n_ticks)
{
- psx_dma_channel *dma = &m_channel[ index ];
+ psx_dma_channel *dma = &m_channel[index];
- dma->timer->adjust( attotime::from_hz(33868800) * n_ticks, index);
+ dma->timer->adjust(attotime::from_hz(33868800) * n_ticks, index);
dma->n_ticks = n_ticks;
dma->b_running = 1;
}
-void psxdma_device::dma_stop_timer( int index )
+void psxdma_device::dma_stop_timer(int index)
{
- psx_dma_channel *dma = &m_channel[ index ];
+ psx_dma_channel *dma = &m_channel[index];
- dma->timer->adjust( attotime::never);
+ dma->timer->adjust(attotime::never);
dma->b_running = 0;
}
-void psxdma_device::dma_timer_adjust( int index )
+void psxdma_device::dma_timer_adjust(int index)
{
- psx_dma_channel *dma = &m_channel[ index ];
+ psx_dma_channel *dma = &m_channel[index];
- if( dma->b_running )
- {
- dma_start_timer( index, dma->n_ticks );
- }
+ if (dma->b_running)
+ dma_start_timer(index, dma->n_ticks);
else
- {
- dma_stop_timer( index );
- }
+ dma_stop_timer(index);
}
void psxdma_device::dma_interrupt_update()
@@ -113,61 +94,85 @@ void psxdma_device::dma_interrupt_update()
int n_int;
int n_mask;
- n_int = ( m_dicr >> 24 ) & 0x7f;
- n_mask = ( m_dicr >> 16 ) & 0xff;
+ n_int = (m_dicr >> 24) & 0x7f;
+ n_mask = (m_dicr >> 16) & 0xff;
- if( ( n_mask & 0x80 ) != 0 && ( n_int & n_mask ) != 0 )
+ if ((n_mask & 0x80) != 0 && (n_int & n_mask) != 0)
{
- verboselog( *this, 2, "dma_interrupt_update( %02x, %02x ) interrupt triggered\n", n_int, n_mask );
+ LOGIRQ("dma_interrupt_update( %02x, %02x ) interrupt triggered\n", machine().describe_context(), n_int, n_mask);
m_dicr |= 0x80000000;
m_irq_handler(1);
}
- else if( n_int != 0 )
+ else if (n_int != 0)
{
- verboselog( *this, 2, "dma_interrupt_update( %02x, %02x ) interrupt not enabled\n", n_int, n_mask );
+ LOGIRQ("dma_interrupt_update( %02x, %02x ) interrupt not enabled\n", machine().describe_context(), n_int, n_mask);
}
- m_dicr &= 0x00ffffff | ( m_dicr << 8 );
+ m_dicr &= 0x00ffffff | (m_dicr << 8);
}
-void psxdma_device::dma_finished( int index )
+TIMER_CALLBACK_MEMBER(psxdma_device::dma_finished)
{
- psx_dma_channel *dma = &m_channel[ index ];
+ int const index = param;
+ psx_dma_channel *dma = &m_channel[index];
- if( dma->n_channelcontrol == 0x01000401 && index == 2 )
+ if (dma->n_channelcontrol == 0x01000201)
+ {
+ int32_t n_size;
+ uint32_t n_address;
+ uint32_t n_adrmask;
+
+ n_adrmask = m_ramsize - 1;
+ n_address = (dma->n_base & n_adrmask);
+ n_size = dma->n_blockcontrol;
+ if ((dma->n_channelcontrol & 0x200) != 0)
+ {
+ uint32_t n_ba;
+ n_ba = dma->n_blockcontrol >> 16;
+ if (n_ba == 0)
+ {
+ n_ba = 0x10000;
+ }
+ n_size = (n_size & 0xffff) * n_ba;
+ }
+
+ LOGDMA("%s dma %d write block %08x %08x\n", machine().describe_context(), index, n_address, n_size);
+ dma->fn_write(m_ram, n_address, n_size);
+ }
+ else if (dma->n_channelcontrol == 0x01000401 && index == 2)
{
uint32_t n_size;
uint32_t n_total;
- uint32_t n_address = ( dma->n_base & 0xffffff );
+ uint32_t n_address = (dma->n_base & 0xffffff);
uint32_t n_adrmask = m_ramsize - 1;
uint32_t n_nextaddress;
- if( n_address != 0xffffff )
+ if (n_address != 0xffffff)
{
n_total = 0;
- for( ;; )
+ for (;; )
{
- if( n_address == 0xffffff )
+ if (n_address == 0xffffff)
{
dma->n_base = n_address;
//HACK: fixes pse bios 2.x & other texture uploading issues, breaks kdeadeye test mode, gtrfrk7m & gtrkfrk8m loading
//dma_start_timer( index, 19000 );
- dma_start_timer( index, 500 );
+ dma_start_timer(index, 500);
return;
}
- if( n_total > 65535 )
+ if (n_total > 65535)
{
dma->n_base = n_address;
//FIXME:
// 16000 below is based on try and error.
// Mametesters.org: sfex20103red
//dma_start_timer( index, 16 );
- dma_start_timer( index, 16000 );
+ dma_start_timer(index, 16000);
return;
}
n_address &= n_adrmask;
- n_nextaddress = m_ram[ n_address / 4 ];
+ n_nextaddress = m_ram[n_address / 4];
n_size = n_nextaddress >> 24;
- dma->fn_write( m_ram, n_address + 4, n_size );
+ dma->fn_write(m_ram, n_address + 4, n_size);
//FIXME:
// The following conditions will cause an endless loop.
// If stopping the transfer is correct I cannot judge
@@ -176,62 +181,61 @@ void psxdma_device::dma_finished( int index )
// Mametesters.org: psyforce0105u5red, raystorm0111u1red
if ((n_nextaddress & 0xffffff) != 0xffffff)
{
- if (n_address == m_ram[ (n_nextaddress & n_adrmask) / 4] ||
- n_address == (n_nextaddress & n_adrmask) )
+ if (n_address == m_ram[(n_nextaddress & n_adrmask) / 4] ||
+ n_address == (n_nextaddress & n_adrmask))
{
break;
}
}
- n_address = ( n_nextaddress & 0xffffff );
+ n_address = (n_nextaddress & 0xffffff);
- n_total += ( n_size + 1 );
+ n_total += (n_size + 1);
}
}
}
- dma->n_channelcontrol &= ~( ( 1L << 0x18 ) | ( 1L << 0x1c ) );
+ dma->n_channelcontrol &= ~((1L << 0x18) | (1L << 0x1c));
- m_dicr |= 1 << ( 24 + index );
+ m_dicr |= 1 << (24 + index);
dma_interrupt_update();
- dma_stop_timer( index );
-}
-
-void psxdma_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- dma_finished(id);
+ dma_stop_timer(index);
}
-void psxdma_device::install_read_handler( int index, read_delegate p_fn_dma_read )
+void psxdma_device::install_read_handler(int index, read_delegate p_fn_dma_read)
{
- m_channel[ index ].fn_read = p_fn_dma_read;
+ m_channel[index].fn_read = p_fn_dma_read;
}
-void psxdma_device::install_write_handler( int index, write_delegate p_fn_dma_write )
+void psxdma_device::install_write_handler(int index, write_delegate p_fn_dma_write)
{
- m_channel[ index ].fn_write = p_fn_dma_write;
+ m_channel[index].fn_write = p_fn_dma_write;
}
-WRITE32_MEMBER( psxdma_device::write )
+void psxdma_device::write(offs_t offset, uint32_t data, uint32_t mem_mask)
{
int index = offset / 4;
- psx_dma_channel *dma = &m_channel[ index ];
+ psx_dma_channel *dma = &m_channel[index];
- if( index < 7 )
+ if (index < 7)
{
- switch( offset % 4 )
+ switch (offset % 4)
{
case 0:
- verboselog( *this, 2, "dmabase( %d ) = %08x\n", index, data );
+ LOGWRITE("%s dmabase( %d ) = %08x\n", machine().describe_context(), index, data);
dma->n_base = data;
break;
+
case 1:
- verboselog( *this, 2, "dmablockcontrol( %d ) = %08x\n", index, data );
+ LOGWRITE("%s dmablockcontrol( %d ) = %08x\n", machine().describe_context(), index, data);
dma->n_blockcontrol = data;
break;
+
case 2:
- verboselog( *this, 2, "dmachannelcontrol( %d ) = %08x\n", index, data );
+ case 3:
+ LOGWRITE("%s dmachannelcontrol( %d ) = %08x\n", machine().describe_context(), index, data);
dma->n_channelcontrol = data;
- if( ( dma->n_channelcontrol & ( 1L << 0x18 ) ) != 0 && ( m_dpcp & ( 1 << ( 3 + ( index * 4 ) ) ) ) != 0 )
+
+ if ((dma->n_channelcontrol & (1L << 0x18)) != 0 && (m_dpcp & (1 << (3 + (index * 4)))) != 0)
{
int32_t n_size;
uint32_t n_address;
@@ -240,185 +244,177 @@ WRITE32_MEMBER( psxdma_device::write )
n_adrmask = m_ramsize - 1;
- n_address = ( dma->n_base & n_adrmask );
+ n_address = (dma->n_base & n_adrmask);
n_size = dma->n_blockcontrol;
- if( ( dma->n_channelcontrol & 0x200 ) != 0 )
+ if ((dma->n_channelcontrol & 0x200) != 0)
{
uint32_t n_ba;
n_ba = dma->n_blockcontrol >> 16;
- if( n_ba == 0 )
- {
+ if (n_ba == 0)
n_ba = 0x10000;
- }
- n_size = ( n_size & 0xffff ) * n_ba;
+ n_size = (n_size & 0xffff) * n_ba;
}
- if( dma->n_channelcontrol == 0x01000000 &&
- !dma->fn_read.isnull() )
+ if (dma->n_channelcontrol == 0x01000000 &&
+ !dma->fn_read.isnull())
{
- verboselog( *this, 1, "dma %d read block %08x %08x\n", index, n_address, n_size );
- dma->fn_read( m_ram, n_address, n_size );
- dma_finished( index );
+ LOGDMA("%s dma %d read block %08x %08x\n", machine().describe_context(), index, n_address, n_size);
+ dma->fn_read(m_ram, n_address, n_size);
+ dma_finished(index);
}
else if ((dma->n_channelcontrol & 0xffbffeff) == 0x11000000 && // CD DMA
- !dma->fn_read.isnull() )
+ !dma->fn_read.isnull())
{
- verboselog( *this, 1, "dma %d read block %08x %08x\n", index, n_address, n_size );
+ LOGDMA("%s dma %d read block %08x %08x\n", machine().describe_context(), index, n_address, n_size);
// pSX's CD DMA size calc formula
- int oursize = (dma->n_blockcontrol>>16);
+ int oursize = (dma->n_blockcontrol >> 16);
oursize = (oursize > 1) ? oursize : 1;
- oursize *= (dma->n_blockcontrol&0xffff);
+ oursize *= (dma->n_blockcontrol & 0xffff);
- dma->fn_read( m_ram, n_address, oursize );
- dma_finished( index );
+ dma->fn_read(m_ram, n_address, oursize);
+ dma_finished(index);
}
- else if( dma->n_channelcontrol == 0x01000200 &&
- !dma->fn_read.isnull() )
+ else if (dma->n_channelcontrol == 0x01000200 &&
+ !dma->fn_read.isnull())
{
- verboselog( *this, 1, "dma %d read block %08x %08x\n", index, n_address, n_size );
- dma->fn_read( m_ram, n_address, n_size );
- if( index == 1 )
- {
- dma_start_timer( index, 26000 );
- }
+ LOGDMA("%s dma %d read block %08x %08x\n", machine().describe_context(), index, n_address, n_size);
+ dma->fn_read(m_ram, n_address, n_size);
+ if (index == 1)
+ dma_start_timer(index, 26000);
else
- {
- dma_finished( index );
- }
+ dma_finished(index);
}
- else if( dma->n_channelcontrol == 0x01000201 &&
- !dma->fn_write.isnull() )
+ else if (dma->n_channelcontrol == 0x01000201 &&
+ !dma->fn_write.isnull())
{
- verboselog( *this, 1, "dma %d write block %08x %08x\n", index, n_address, n_size );
- dma->fn_write( m_ram, n_address, n_size );
- dma_finished( index );
+ if (index == 4)
+ dma_start_timer(index, 24000);
+ else
+ dma_finished(index);
}
- else if( dma->n_channelcontrol == 0x11050100 &&
- !dma->fn_write.isnull() )
+ else if (dma->n_channelcontrol == 0x11050100 &&
+ !dma->fn_write.isnull())
{
/* todo: check this is a write not a read... */
- verboselog( *this, 1, "dma %d write block %08x %08x\n", index, n_address, n_size );
- dma->fn_write( m_ram, n_address, n_size );
- dma_finished( index );
+ LOGDMA("%s dma %d write block %08x %08x\n", machine().describe_context(), index, n_address, n_size);
+ dma->fn_write(m_ram, n_address, n_size);
+ dma_finished(index);
}
- else if( dma->n_channelcontrol == 0x11150100 &&
- !dma->fn_write.isnull() )
+ else if (dma->n_channelcontrol == 0x11150100 &&
+ !dma->fn_write.isnull())
{
/* todo: check this is a write not a read... */
- verboselog( *this, 1, "dma %d write block %08x %08x\n", index, n_address, n_size );
- dma->fn_write( m_ram, n_address, n_size );
- dma_finished( index );
+ LOGDMA("%s dma %d write block %08x %08x\n", machine().describe_context(), index, n_address, n_size);
+ dma->fn_write(m_ram, n_address, n_size);
+ dma_finished(index);
}
- else if( dma->n_channelcontrol == 0x01000401 &&
+ else if (dma->n_channelcontrol == 0x01000401 &&
index == 2 &&
- !dma->fn_write.isnull() )
+ !dma->fn_write.isnull())
{
- verboselog( *this, 1, "dma %d write linked list %08x\n",
- index, dma->n_base );
+ LOGDMA("%s dma %d write linked list %08x\n", machine().describe_context(), index, dma->n_base);
- dma_finished( index );
+ dma_finished(index);
}
- else if( dma->n_channelcontrol == 0x11000002 &&
- index == 6 )
+ else if (dma->n_channelcontrol == 0x11000002 &&
+ index == 6)
{
- verboselog( *this, 1, "dma 6 reverse clear %08x %08x\n",
- dma->n_base, dma->n_blockcontrol );
- if( n_size > 0 )
+ LOGDMA("%s dma 6 reverse clear %08x %08x\n", machine().describe_context(), dma->n_base, dma->n_blockcontrol);
+ if (n_size > 0)
{
n_size--;
- while( n_size > 0 )
+ while (n_size > 0)
{
- n_nextaddress = ( n_address - 4 ) & 0xffffff;
- m_ram[ n_address / 4 ] = n_nextaddress;
+ n_nextaddress = (n_address - 4) & 0xffffff;
+ m_ram[n_address / 4] = n_nextaddress;
n_address = n_nextaddress;
n_size--;
}
- m_ram[ n_address / 4 ] = 0xffffff;
+ m_ram[n_address / 4] = 0xffffff;
}
- dma_start_timer( index, 2150 );
+ dma_start_timer(index, 2150);
}
else
- {
- verboselog( *this, 1, "dma %d unknown mode %08x\n", index, dma->n_channelcontrol );
- }
- }
- else if( dma->n_channelcontrol != 0 )
- {
- verboselog( *this, 1, "psx_dma_w( %04x, %08x, %08x ) channel not enabled\n", offset, dma->n_channelcontrol, mem_mask );
+ LOGDMA("%s dma %d unknown mode %08x\n", machine().describe_context(), index, dma->n_channelcontrol);
}
- break;
- default:
- verboselog( *this, 1, "psx_dma_w( %04x, %08x, %08x ) Unknown dma channel register\n", offset, data, mem_mask );
+ else if (dma->n_channelcontrol != 0)
+ LOGDMA("%s psx_dma_w( %04x, %08x, %08x ) channel not enabled\n", machine().describe_context(), offset, dma->n_channelcontrol, mem_mask);
break;
}
}
else
{
- switch( offset % 4 )
+ switch (offset % 4)
{
case 0x0:
- verboselog( *this, 1, "psx_dma_w( %04x, %08x, %08x ) dpcp\n", offset, data, mem_mask );
- m_dpcp = ( m_dpcp & ~mem_mask ) | data;
+ LOGWRITE("%s dpcr_w(0x%08x)\n", machine().describe_context(), data);
+ m_dpcp = data;
break;
case 0x1:
+ {
+ uint32_t dicr = (m_dicr & 0x80000000) |
+ (m_dicr & ~data & 0x7f000000) |
+ (data & 0xff803f);
- m_dicr = ( m_dicr & ( 0x80000000 | ~mem_mask ) ) |
- ( m_dicr & ~data & 0x7f000000 & mem_mask ) |
- ( data & 0x00ffffff & mem_mask );
+ LOGWRITE("%s dicr_w(0x%08x) 0x%08x -> 0x%08x\n", machine().describe_context(), data, m_dicr, dicr);
+ m_dicr = dicr;
+ }
- if( ( m_dicr & 0x80000000 ) != 0 && ( m_dicr & 0x7f000000 ) == 0 )
+ if ((m_dicr & 0x80000000) != 0 && (m_dicr & 0x7f000000) == 0)
{
- verboselog( *this, 2, "dma interrupt cleared\n" );
+ LOGIRQ("%s dma interrupt cleared\n", machine().describe_context());
m_dicr &= ~0x80000000;
+ m_irq_handler(0);
}
-
- verboselog( *this, 1, "psx_dma_w( %04x, %08x, %08x ) dicr -> %08x\n", offset, data, mem_mask, m_dicr );
- break;
- default:
- verboselog( *this, 0, "psx_dma_w( %04x, %08x, %08x ) Unknown dma control register\n", offset, data, mem_mask );
break;
}
}
}
-READ32_MEMBER( psxdma_device::read )
+uint32_t psxdma_device::read(offs_t offset, uint32_t mem_mask)
{
int index = offset / 4;
- psx_dma_channel *dma = &m_channel[ index ];
+ psx_dma_channel *dma = &m_channel[index];
- if( index < 7 )
+ if (index < 7)
{
- switch( offset % 4 )
+ switch (offset % 4)
{
case 0:
- verboselog( *this, 1, "psx_dma_r dmabase[ %d ] ( %08x )\n", index, dma->n_base );
+ if (!machine().side_effects_disabled())
+ LOGREAD("%s psx_dma_r dmabase[ %d ] ( %08x )\n", machine().describe_context(), index, dma->n_base);
return dma->n_base;
+
case 1:
- verboselog( *this, 1, "psx_dma_r dmablockcontrol[ %d ] ( %08x )\n", index, dma->n_blockcontrol );
+ if (!machine().side_effects_disabled())
+ LOGREAD("%s psx_dma_r dmablockcontrol[ %d ] ( %08x )\n", machine().describe_context(), index, dma->n_blockcontrol);
return dma->n_blockcontrol;
+
case 2:
- verboselog( *this, 1, "psx_dma_r dmachannelcontrol[ %d ] ( %08x )\n", index, dma->n_channelcontrol );
+ case 3:
+ if (!machine().side_effects_disabled())
+ LOGREAD("%s psx_dma_r dmachannelcontrol[ %d ] ( %08x )\n", machine().describe_context(), index, dma->n_channelcontrol);
return dma->n_channelcontrol;
- default:
- verboselog( *this, 0, "psx_dma_r( %08x, %08x ) Unknown dma channel register\n", offset, mem_mask );
- break;
}
}
else
{
- switch( offset % 4 )
+ switch (offset % 4)
{
case 0x0:
- verboselog( *this, 1, "psx_dma_r dpcp ( %08x )\n", m_dpcp );
+ if (!machine().side_effects_disabled())
+ LOGREAD("%s dpcr_r() 0x%08x\n", machine().describe_context(), m_dpcp);
return m_dpcp;
+
case 0x1:
- verboselog( *this, 1, "psx_dma_r dicr ( %08x )\n", m_dicr );
+ if (!machine().side_effects_disabled())
+ LOGREAD("%s dicr_r() 0x%08x\n", machine().describe_context(), m_dicr);
return m_dicr;
- default:
- verboselog( *this, 0, "psx_dma_r( %08x, %08x ) Unknown dma control register\n", offset, mem_mask );
- break;
}
}
+
return 0;
}
+
+DEFINE_DEVICE_TYPE(PSX_DMA, psxdma_device, "psxdma", "Sony PSX DMA")
diff --git a/src/devices/cpu/psx/dma.h b/src/devices/cpu/psx/dma.h
index 3e368c23ad3..0e0c93f8a4f 100644
--- a/src/devices/cpu/psx/dma.h
+++ b/src/devices/cpu/psx/dma.h
@@ -29,17 +29,15 @@ public:
void install_read_handler( int n_channel, read_delegate p_fn_dma_read );
void install_write_handler( int n_channel, write_delegate p_fn_dma_write );
- DECLARE_WRITE32_MEMBER( write );
- DECLARE_READ32_MEMBER( read );
+ void write(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t read(offs_t offset, uint32_t mem_mask = ~0);
uint32_t *m_ram;
size_t m_ramsize;
protected:
- virtual void device_start() override;
- virtual void device_reset() override;
- virtual void device_post_load() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
private:
struct psx_dma_channel
@@ -58,7 +56,7 @@ private:
void dma_stop_timer( int n_channel );
void dma_timer_adjust( int n_channel );
void dma_interrupt_update();
- void dma_finished( int n_channel );
+ TIMER_CALLBACK_MEMBER( dma_finished );
psx_dma_channel m_channel[7];
uint32_t m_dpcp;
diff --git a/src/devices/cpu/psx/gte.cpp b/src/devices/cpu/psx/gte.cpp
index d48b206e84f..562a3a995d7 100644
--- a/src/devices/cpu/psx/gte.cpp
+++ b/src/devices/cpu/psx/gte.cpp
@@ -11,6 +11,8 @@
#include "gte.h"
#if 0
+#include <cstdarg>
+
void ATTR_PRINTF(2,3) GTELOG( uint32_t pc, const char *a, ...)
{
va_list va;
@@ -215,7 +217,7 @@ void gte::setcp2dr( uint32_t pc, int reg, uint32_t value )
break;
case 30:
- LZCR = (value & 0x80000000) == 0 ? count_leading_zeros(value) : count_leading_ones(value);
+ LZCR = (value & 0x80000000) == 0 ? count_leading_zeros_32(value) : count_leading_ones_32(value);
break;
case 31:
@@ -314,7 +316,7 @@ static inline uint32_t gte_divide( uint16_t numerator, uint16_t denominator )
0x00
};
- int shift = count_leading_zeros( denominator ) - 16;
+ int shift = count_leading_zeros_32( denominator ) - 16;
int r1 = ( denominator << shift ) & 0x7fff;
int r2 = table[ ( ( r1 + 0x40 ) >> 7 ) ] + 0x101;
diff --git a/src/devices/cpu/psx/gte.h b/src/devices/cpu/psx/gte.h
index 33755043704..01f16cde383 100644
--- a/src/devices/cpu/psx/gte.h
+++ b/src/devices/cpu/psx/gte.h
@@ -56,7 +56,7 @@ protected:
int44 operator+( int64_t add )
{
- int64_t value = ( ( m_value + add ) << 20 ) >> 20;
+ int64_t value = util::sext( m_value + add, 44 );
return int44( value,
m_positive_overflow || ( value < 0 && m_value >= 0 && add >= 0 ),
diff --git a/src/devices/cpu/psx/irq.cpp b/src/devices/cpu/psx/irq.cpp
index 94aafc73b2f..41706fcf9db 100644
--- a/src/devices/cpu/psx/irq.cpp
+++ b/src/devices/cpu/psx/irq.cpp
@@ -11,23 +11,11 @@
#include "psx.h"
#include "irq.h"
-#define VERBOSE_LEVEL ( 0 )
+#define VERBOSE ( 0 )
+#include "logmacro.h"
#define PSX_IRQ_MASK ( 0x7fd )
-static inline void ATTR_PRINTF(3,4) verboselog( device_t& device, int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- device.logerror( "%s: %s", device.machine().describe_context(), buf );
- }
-}
-
DEFINE_DEVICE_TYPE(PSX_IRQ, psxirq_device, "psxirq", "Sony PSX IRQ")
psxirq_device::psxirq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
@@ -51,15 +39,13 @@ void psxirq_device::device_post_load()
void psxirq_device::device_start()
{
- m_irq_handler.resolve_safe();
-
- save_item( NAME( n_irqdata ) );
- save_item( NAME( n_irqmask ) );
+ save_item(NAME(n_irqdata));
+ save_item(NAME(n_irqmask));
}
void psxirq_device::set( uint32_t bitmask )
{
- verboselog( *this, 2, "psx_irq_set %08x\n", bitmask );
+ LOG( "%s: psx_irq_set %08x\n", machine().describe_context(), bitmask );
n_irqdata |= bitmask;
psx_irq_update();
}
@@ -68,58 +54,58 @@ void psxirq_device::psx_irq_update( void )
{
if( ( n_irqdata & n_irqmask ) != 0 )
{
- verboselog( *this, 2, "psx irq assert\n" );
+ LOG( "%s: psx irq assert\n", machine().describe_context() );
m_irq_handler( ASSERT_LINE );
}
else
{
- verboselog( *this, 2, "psx irq clear\n" );
+ LOG( "%s: psx irq clear\n", machine().describe_context() );
m_irq_handler( CLEAR_LINE );
}
}
-WRITE32_MEMBER( psxirq_device::write )
+void psxirq_device::write(offs_t offset, uint32_t data, uint32_t mem_mask)
{
switch( offset )
{
case 0x00:
- verboselog( *this, 2, "psx irq data ( %08x, %08x ) %08x -> %08x\n", data, mem_mask, n_irqdata, ( n_irqdata & ~mem_mask ) | ( n_irqdata & n_irqmask & data ) );
+ LOG( "%s: psx irq data ( %08x, %08x ) %08x -> %08x\n", machine().describe_context(), data, mem_mask, n_irqdata, ( n_irqdata & ~mem_mask ) | ( n_irqdata & n_irqmask & data ) );
n_irqdata = ( n_irqdata & ~mem_mask ) | ( n_irqdata & n_irqmask & data );
psx_irq_update();
break;
case 0x01:
- verboselog( *this, 2, "psx irq mask ( %08x, %08x ) %08x -> %08x\n", data, mem_mask, n_irqmask, ( n_irqmask & ~mem_mask ) | data );
+ LOG( "%s: psx irq mask ( %08x, %08x ) %08x -> %08x\n", machine().describe_context(), data, mem_mask, n_irqmask, ( n_irqmask & ~mem_mask ) | data );
n_irqmask = ( n_irqmask & ~mem_mask ) | data;
if( ( n_irqmask &~ PSX_IRQ_MASK ) != 0 )
{
- verboselog( *this, 0, "psx_irq_w( %08x, %08x, %08x ) unknown irq\n", offset, data, mem_mask );
+ logerror( "%s: psx_irq_w( %08x, %08x, %08x ) unknown irq\n", machine().describe_context(), offset, data, mem_mask );
}
psx_irq_update();
break;
default:
- verboselog( *this, 0, "psx_irq_w( %08x, %08x, %08x ) unknown register\n", offset, data, mem_mask );
+ logerror( "%s: psx_irq_w( %08x, %08x, %08x ) unknown register\n", machine().describe_context(), offset, data, mem_mask );
break;
}
}
-READ32_MEMBER( psxirq_device::read )
+uint32_t psxirq_device::read(offs_t offset)
{
switch( offset )
{
case 0x00:
- verboselog( *this, 1, "psx_irq_r irq data %08x\n", n_irqdata );
+ LOG( "%s: psx_irq_r irq data %08x\n", machine().describe_context(), n_irqdata );
return n_irqdata;
case 0x01:
- verboselog( *this, 1, "psx_irq_r irq mask %08x\n", n_irqmask );
+ LOG( "%s: psx_irq_r irq mask %08x\n", machine().describe_context(), n_irqmask );
return n_irqmask;
default:
- verboselog( *this, 0, "psx_irq_r unknown register %d\n", offset );
+ logerror( "%s: psx_irq_r unknown register %d\n", machine().describe_context(), offset );
break;
}
return 0;
}
-WRITE_LINE_MEMBER( psxirq_device::intin0 )
+void psxirq_device::intin0(int state)
{
if( state )
{
@@ -127,7 +113,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin0 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin1 )
+void psxirq_device::intin1(int state)
{
if( state )
{
@@ -135,7 +121,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin1 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin2 )
+void psxirq_device::intin2(int state)
{
if( state )
{
@@ -143,7 +129,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin2 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin3 )
+void psxirq_device::intin3(int state)
{
if( state )
{
@@ -151,7 +137,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin3 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin4 )
+void psxirq_device::intin4(int state)
{
if( state )
{
@@ -159,7 +145,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin4 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin5 )
+void psxirq_device::intin5(int state)
{
if( state )
{
@@ -167,7 +153,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin5 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin6 )
+void psxirq_device::intin6(int state)
{
if( state )
{
@@ -175,7 +161,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin6 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin7 )
+void psxirq_device::intin7(int state)
{
if( state )
{
@@ -183,7 +169,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin7 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin8 )
+void psxirq_device::intin8(int state)
{
if( state )
{
@@ -191,7 +177,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin8 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin9 )
+void psxirq_device::intin9(int state)
{
if( state )
{
@@ -199,7 +185,7 @@ WRITE_LINE_MEMBER( psxirq_device::intin9 )
}
}
-WRITE_LINE_MEMBER( psxirq_device::intin10 )
+void psxirq_device::intin10(int state)
{
if( state )
{
diff --git a/src/devices/cpu/psx/irq.h b/src/devices/cpu/psx/irq.h
index 11d637921f7..d59f3953222 100644
--- a/src/devices/cpu/psx/irq.h
+++ b/src/devices/cpu/psx/irq.h
@@ -23,24 +23,24 @@ public:
// configuration helpers
auto irq() { return m_irq_handler.bind(); }
- DECLARE_READ32_MEMBER( read );
- DECLARE_WRITE32_MEMBER( write );
-
- DECLARE_WRITE_LINE_MEMBER( intin0 );
- DECLARE_WRITE_LINE_MEMBER( intin1 );
- DECLARE_WRITE_LINE_MEMBER( intin2 );
- DECLARE_WRITE_LINE_MEMBER( intin3 );
- DECLARE_WRITE_LINE_MEMBER( intin4 );
- DECLARE_WRITE_LINE_MEMBER( intin5 );
- DECLARE_WRITE_LINE_MEMBER( intin6 );
- DECLARE_WRITE_LINE_MEMBER( intin7 );
- DECLARE_WRITE_LINE_MEMBER( intin8 );
- DECLARE_WRITE_LINE_MEMBER( intin9 );
- DECLARE_WRITE_LINE_MEMBER( intin10 );
+ uint32_t read(offs_t offset);
+ void write(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+
+ void intin0(int state);
+ void intin1(int state);
+ void intin2(int state);
+ void intin3(int state);
+ void intin4(int state);
+ void intin5(int state);
+ void intin6(int state);
+ void intin7(int state);
+ void intin8(int state);
+ void intin9(int state);
+ void intin10(int state);
protected:
- virtual void device_start() override;
- virtual void device_reset() override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
virtual void device_post_load() override;
private:
diff --git a/src/devices/cpu/psx/mdec.cpp b/src/devices/cpu/psx/mdec.cpp
index 6a177255da9..4ef7d827ba2 100644
--- a/src/devices/cpu/psx/mdec.cpp
+++ b/src/devices/cpu/psx/mdec.cpp
@@ -13,20 +13,11 @@
#include "mdec.h"
#include "dma.h"
-#define VERBOSE_LEVEL ( 0 )
+#define LOG_DMA (1U << 1)
+#define LOG_COMMAND (1U << 2)
-static inline void ATTR_PRINTF(3,4) verboselog( device_t& device, int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- device.logerror( "%s: %s", device.machine().describe_context(), buf );
- }
-}
+#define VERBOSE ( 0 )
+#include "logmacro.h"
DEFINE_DEVICE_TYPE(PSX_MDEC, psxmdec_device, "psxmdec", "Sony PSX MDEC")
@@ -82,12 +73,10 @@ void psxmdec_device::device_start()
save_item( NAME( p_n_cos ) );
}
-#ifdef UNUSED_FUNCTION
-static inline void psxwriteword( uint32_t *p_n_psxram, uint32_t n_address, uint16_t n_data )
+[[maybe_unused]] static inline void psxwriteword( uint32_t *p_n_psxram, uint32_t n_address, uint16_t n_data )
{
*( (uint16_t *)( (uint8_t *)p_n_psxram + WORD_XOR_LE( n_address ) ) ) = n_data;
}
-#endif
static inline uint16_t psxreadword( uint32_t *p_n_psxram, uint32_t n_address )
{
@@ -168,7 +157,7 @@ static inline uint16_t mdec_unpack_run( uint16_t n_packed )
static inline int32_t mdec_unpack_val( uint16_t n_packed )
{
- return ( ( (int32_t)n_packed ) << 22 ) >> 22;
+ return util::sext<int32_t>( n_packed, 10 );
}
uint32_t psxmdec_device::mdec_unpack( uint32_t *p_n_psxram, uint32_t n_address )
@@ -424,18 +413,18 @@ void psxmdec_device::dma_write( uint32_t *p_n_psxram, uint32_t n_address, int32_
{
int n_index;
- verboselog( *this, 2, "mdec0_write( %08x, %08x )\n", n_address, n_size );
+ LOGMASKED( LOG_DMA, "mdec0_write( %08x, %08x )\n", n_address, n_size );
switch( n_0_command >> 28 )
{
case 0x3:
- verboselog( *this, 1, "mdec decode %08x %08x %08x\n", n_0_command, n_address, n_size );
+ LOGMASKED( LOG_COMMAND, "mdec decode %08x %08x %08x\n", n_0_command, n_address, n_size );
n_0_address = n_address;
n_0_size = n_size * 4;
n_1_status |= ( 1L << 29 );
break;
case 0x4:
- verboselog( *this, 1, "mdec quantize table %08x %08x %08x\n", n_0_command, n_address, n_size );
+ LOGMASKED( LOG_COMMAND, "mdec quantize table %08x %08x %08x\n", n_0_command, n_address, n_size );
n_index = 0;
while( n_size > 0 )
{
@@ -459,7 +448,7 @@ void psxmdec_device::dma_write( uint32_t *p_n_psxram, uint32_t n_address, int32_
}
break;
case 0x6:
- verboselog( *this, 1, "mdec cosine table %08x %08x %08x\n", n_0_command, n_address, n_size );
+ LOGMASKED( LOG_COMMAND, "mdec cosine table %08x %08x %08x\n", n_0_command, n_address, n_size );
n_index = 0;
while( n_size > 0 )
{
@@ -472,7 +461,7 @@ void psxmdec_device::dma_write( uint32_t *p_n_psxram, uint32_t n_address, int32_
mdec_cos_precalc();
break;
default:
- verboselog( *this, 0, "mdec unknown command %08x %08x %08x\n", n_0_command, n_address, n_size );
+ logerror( "mdec unknown command %08x %08x %08x\n", n_0_command, n_address, n_size );
break;
}
}
@@ -482,7 +471,7 @@ void psxmdec_device::dma_read( uint32_t *p_n_psxram, uint32_t n_address, int32_t
uint32_t n_this;
uint32_t n_nextaddress;
- verboselog( *this, 2, "mdec1_read( %08x, %08x )\n", n_address, n_size );
+ LOGMASKED( LOG_DMA, "mdec1_read( %08x, %08x )\n", n_address, n_size );
if( ( n_0_command & ( 1L << 29 ) ) != 0 && n_0_size != 0 )
{
while( n_size > 0 )
@@ -542,30 +531,30 @@ void psxmdec_device::dma_read( uint32_t *p_n_psxram, uint32_t n_address, int32_t
n_1_status &= ~( 1L << 29 );
}
-WRITE32_MEMBER( psxmdec_device::write )
+void psxmdec_device::write(offs_t offset, uint32_t data)
{
switch( offset )
{
case 0:
- verboselog( *this, 2, "mdec 0 command %08x\n", data );
+ LOG( "%s: mdec 0 command %08x\n", machine().describe_context(), data );
n_0_command = data;
break;
case 1:
- verboselog( *this, 2, "mdec 1 command %08x\n", data );
+ LOG( "%s: mdec 1 command %08x\n", machine().describe_context(), data );
n_1_command = data;
break;
}
}
-READ32_MEMBER( psxmdec_device::read )
+uint32_t psxmdec_device::read(offs_t offset)
{
switch( offset )
{
case 0:
- verboselog( *this, 2, "mdec 0 status %08x\n", 0 );
+ LOG( "%s: mdec 0 status %08x\n", machine().describe_context(), 0 );
return 0;
case 1:
- verboselog( *this, 2, "mdec 1 status %08x\n", n_1_status );
+ LOG( "%s: mdec 1 status %08x\n", machine().describe_context(), n_1_status );
return n_1_status;
}
return 0;
diff --git a/src/devices/cpu/psx/mdec.h b/src/devices/cpu/psx/mdec.h
index 941ba2f2f58..a380413d876 100644
--- a/src/devices/cpu/psx/mdec.h
+++ b/src/devices/cpu/psx/mdec.h
@@ -20,15 +20,15 @@ class psxmdec_device : public device_t
public:
psxmdec_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- DECLARE_WRITE32_MEMBER( write );
- DECLARE_READ32_MEMBER( read );
+ void write(offs_t offset, uint32_t data);
+ uint32_t read(offs_t offset);
void dma_write( uint32_t *ram, uint32_t n_address, int32_t n_size );
void dma_read( uint32_t *ram, uint32_t n_address, int32_t n_size );
protected:
- virtual void device_start() override;
- virtual void device_reset() override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
virtual void device_post_load() override;
private:
diff --git a/src/devices/cpu/psx/psx.cpp b/src/devices/cpu/psx/psx.cpp
index 171ff14a5bb..b658b9046d7 100644
--- a/src/devices/cpu/psx/psx.cpp
+++ b/src/devices/cpu/psx/psx.cpp
@@ -70,7 +70,6 @@
#include "mdec.h"
#include "rcnt.h"
#include "sound/spu.h"
-#include "debugger.h"
#include "psxdefs.h"
@@ -205,25 +204,25 @@ static const uint32_t mtc0_writemask[]=
0x00000000 /* PRID */
};
-READ32_MEMBER( psxcpu_device::berr_r )
+uint32_t psxcpu_device::berr_r()
{
if( !machine().side_effects_disabled() )
m_berr = 1;
return 0;
}
-WRITE32_MEMBER( psxcpu_device::berr_w )
+void psxcpu_device::berr_w(uint32_t data)
{
if( !machine().side_effects_disabled() )
m_berr = 1;
}
-READ32_MEMBER( psxcpu_device::exp_base_r )
+uint32_t psxcpu_device::exp_base_r()
{
return m_exp_base;
}
-WRITE32_MEMBER( psxcpu_device::exp_base_w )
+void psxcpu_device::exp_base_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
COMBINE_DATA( &m_exp_base ); // TODO: check byte writes
@@ -235,24 +234,24 @@ uint32_t psxcpu_device::exp_base()
return m_exp_base;
}
-READ32_MEMBER( psxcpu_device::exp_config_r )
+uint32_t psxcpu_device::exp_config_r()
{
return m_exp_config;
}
-WRITE32_MEMBER( psxcpu_device::exp_config_w )
+void psxcpu_device::exp_config_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
COMBINE_DATA( &m_exp_config ); // TODO: check byte writes
m_exp_config &= 0xaf1fffff;
}
-READ32_MEMBER( psxcpu_device::ram_config_r )
+uint32_t psxcpu_device::ram_config_r()
{
return m_ram_config;
}
-WRITE32_MEMBER( psxcpu_device::ram_config_w )
+void psxcpu_device::ram_config_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
uint32_t old = m_ram_config;
@@ -264,12 +263,12 @@ WRITE32_MEMBER( psxcpu_device::ram_config_w )
}
}
-READ32_MEMBER( psxcpu_device::rom_config_r )
+uint32_t psxcpu_device::rom_config_r()
{
return m_rom_config;
}
-WRITE32_MEMBER( psxcpu_device::rom_config_w )
+void psxcpu_device::rom_config_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
uint32_t old = m_rom_config;
@@ -281,24 +280,24 @@ WRITE32_MEMBER( psxcpu_device::rom_config_w )
}
}
-READ32_MEMBER( psxcpu_device::com_delay_r )
+uint32_t psxcpu_device::com_delay_r(offs_t offset, uint32_t mem_mask)
{
//verboselog( p_psx, 1, "psx_com_delay_r( %08x )\n", mem_mask );
return m_com_delay;
}
-WRITE32_MEMBER( psxcpu_device::com_delay_w )
+void psxcpu_device::com_delay_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
COMBINE_DATA( &m_com_delay ); // TODO: check byte writes
//verboselog( p_psx, 1, "psx_com_delay_w( %08x %08x )\n", data, mem_mask );
}
-READ32_MEMBER( psxcpu_device::biu_r )
+uint32_t psxcpu_device::biu_r()
{
return m_biu;
}
-WRITE32_MEMBER( psxcpu_device::biu_w )
+void psxcpu_device::biu_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
uint32_t old = m_biu;
@@ -386,7 +385,7 @@ uint8_t psxcpu_device::readbyte( uint32_t address )
{
if( m_bus_attached )
{
- return m_program->read_byte( address );
+ return m_data.read_byte( address );
}
return cache_readword( address ) >> ( ( address & 3 ) * 8 );
@@ -396,7 +395,7 @@ uint16_t psxcpu_device::readhalf( uint32_t address )
{
if( m_bus_attached )
{
- return m_program->read_word( address );
+ return m_data.read_word( address );
}
return cache_readword( address ) >> ( ( address & 2 ) * 8 );
@@ -406,7 +405,7 @@ uint32_t psxcpu_device::readword( uint32_t address )
{
if( m_bus_attached )
{
- return m_program->read_dword( address );
+ return m_data.read_dword( address );
}
return cache_readword( address );
@@ -416,7 +415,7 @@ uint32_t psxcpu_device::readword_masked( uint32_t address, uint32_t mask )
{
if( m_bus_attached )
{
- return m_program->read_dword( address, mask );
+ return m_data.read_dword( address, mask );
}
return cache_readword( address );
@@ -426,7 +425,7 @@ void psxcpu_device::writeword( uint32_t address, uint32_t data )
{
if( m_bus_attached )
{
- m_program->write_dword( address, data );
+ m_data.write_dword( address, data );
}
else
{
@@ -438,7 +437,7 @@ void psxcpu_device::writeword_masked( uint32_t address, uint32_t data, uint32_t
{
if( m_bus_attached )
{
- m_program->write_dword( address, data, mask );
+ m_data.write_dword( address, data, mask );
}
else
{
@@ -1186,16 +1185,16 @@ void psxcpu_device::multiplier_update()
case MULTIPLIER_OPERATION_MULT:
{
int64_t result = mul_32x32( (int32_t)m_multiplier_operand1, (int32_t)m_multiplier_operand2 );
- m_lo = extract_64lo( result );
- m_hi = extract_64hi( result );
+ m_lo = result;
+ m_hi = result >> 32;
}
break;
case MULTIPLIER_OPERATION_MULTU:
{
uint64_t result = mulu_32x32( m_multiplier_operand1, m_multiplier_operand2 );
- m_lo = extract_64lo( result );
- m_hi = extract_64hi( result );
+ m_lo = result;
+ m_hi = result >> 32;
}
break;
@@ -1338,11 +1337,11 @@ void psxcpu_device::update_scratchpad()
{
if( ( m_biu & BIU_RAM ) == 0 )
{
- m_program->install_readwrite_handler( 0x1f800000, 0x1f8003ff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
+ m_program->install_readwrite_handler( 0x1f800000, 0x1f8003ff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
}
else if( ( m_biu & BIU_DS ) == 0 )
{
- m_program->install_read_handler( 0x1f800000, 0x1f8003ff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ) );
+ m_program->install_read_handler( 0x1f800000, 0x1f8003ff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)) );
m_program->nop_write( 0x1f800000, 0x1f8003ff );
}
else
@@ -1397,9 +1396,9 @@ void psxcpu_device::update_ram_config()
}
}
- m_program->install_readwrite_handler( 0x00000000 + window_size, 0x1effffff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
- m_program->install_readwrite_handler( 0x80000000 + window_size, 0x9effffff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
- m_program->install_readwrite_handler( 0xa0000000 + window_size, 0xbeffffff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
+ m_program->install_readwrite_handler( 0x00000000 + window_size, 0x1effffff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
+ m_program->install_readwrite_handler( 0x80000000 + window_size, 0x9effffff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
+ m_program->install_readwrite_handler( 0xa0000000 + window_size, 0xbeffffff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
}
void psxcpu_device::update_rom_config()
@@ -1434,9 +1433,9 @@ void psxcpu_device::update_rom_config()
if( window_size < max_window_size && !m_disable_rom_berr)
{
- m_program->install_readwrite_handler( 0x1fc00000 + window_size, 0x1fffffff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
- m_program->install_readwrite_handler( 0x9fc00000 + window_size, 0x9fffffff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
- m_program->install_readwrite_handler( 0xbfc00000 + window_size, 0xbfffffff, read32_delegate( FUNC( psxcpu_device::berr_r ), this ), write32_delegate( FUNC( psxcpu_device::berr_w ), this ) );
+ m_program->install_readwrite_handler( 0x1fc00000 + window_size, 0x1fffffff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
+ m_program->install_readwrite_handler( 0x9fc00000 + window_size, 0x9fffffff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
+ m_program->install_readwrite_handler( 0xbfc00000 + window_size, 0xbfffffff, read32smo_delegate(*this, FUNC(psxcpu_device::berr_r)), write32smo_delegate(*this, FUNC(psxcpu_device::berr_w)) );
}
}
@@ -1462,7 +1461,7 @@ void psxcpu_device::update_cop0(int reg)
//if (ip & CAUSE_IP5) debugger_interrupt_hook(PSXCPU_IRQ3);
//if (ip & CAUSE_IP6) debugger_interrupt_hook(PSXCPU_IRQ4);
//if (ip & CAUSE_IP7) debugger_interrupt_hook(PSXCPU_IRQ5);
- m_op = m_cache->read_dword(m_pc);
+ m_op = m_instruction.read_dword(m_pc);
execute_unstoppable_instructions(1);
exception(EXC_INT);
}
@@ -1490,11 +1489,11 @@ void psxcpu_device::fetch_next_op()
{
uint32_t safepc = m_delayv & ~m_bad_word_address_mask;
- m_op = m_cache->read_dword( safepc );
+ m_op = m_instruction.read_dword( safepc );
}
else
{
- m_op = m_cache->read_dword( m_pc + 4 );
+ m_op = m_instruction.read_dword( m_pc + 4 );
}
}
@@ -1786,15 +1785,16 @@ void psxcpu_device::psxcpu_internal_map(address_map &map)
//-------------------------------------------------
psxcpu_device::psxcpu_device( const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock ) :
- cpu_device( mconfig, type, tag, owner, clock ),
- m_program_config( "program", ENDIANNESS_LITTLE, 32, 32, 0, address_map_constructor(FUNC(psxcpu_device::psxcpu_internal_map), this)),
- m_gpu_read_handler( *this ),
- m_gpu_write_handler( *this ),
- m_spu_read_handler( *this ),
- m_spu_write_handler( *this ),
- m_cd_read_handler( *this ),
- m_cd_write_handler( *this ),
- m_ram( *this, "ram" )
+ cpu_device(mconfig, type, tag, owner, clock),
+ m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0, address_map_constructor(FUNC(psxcpu_device::psxcpu_internal_map), this)),
+ m_gpu_read_handler(*this, 0),
+ m_gpu_write_handler(*this),
+ m_spu_read_handler(*this, 0),
+ m_spu_write_handler(*this),
+ m_cd_read_handler(*this, 0),
+ m_cd_write_handler(*this),
+ m_ram(*this, "ram"),
+ m_rom(*this, "rom")
{
m_disable_rom_berr = false;
}
@@ -1836,8 +1836,9 @@ cxd8606cq_device::cxd8606cq_device( const machine_config &mconfig, const char *t
void psxcpu_device::device_start()
{
// get our address spaces
- m_program = &space( AS_PROGRAM );
- m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>();
+ m_program = &space(AS_PROGRAM);
+ m_program->cache(m_instruction);
+ m_program->specific(m_data);
save_item( NAME( m_op ) );
save_item( NAME( m_pc ) );
@@ -1982,17 +1983,11 @@ void psxcpu_device::device_start()
state_add( PSXCPU_CP2CR30, "zsf4", m_gte.m_cp2cr[ 30 ].d );
state_add( PSXCPU_CP2CR31, "flag", m_gte.m_cp2cr[ 31 ].d );
+ // initialize the registers once
+ std::fill(std::begin(m_r), std::end(m_r), 0);
+
// set our instruction counter
set_icountptr(m_icount);
-
- m_gpu_read_handler.resolve_safe( 0 );
- m_gpu_write_handler.resolve_safe();
- m_spu_read_handler.resolve_safe( 0 );
- m_spu_write_handler.resolve_safe();
- m_cd_read_handler.resolve_safe( 0 );
- m_cd_write_handler.resolve_safe();
-
- m_rom = memregion( "rom" );
}
@@ -2349,7 +2344,7 @@ void psxcpu_device::execute_run()
}
else
{
- m_op = m_cache->read_dword(m_pc);
+ m_op = m_instruction.read_dword(m_pc);
if( m_berr )
{
@@ -3400,34 +3395,34 @@ void psxcpu_device::setcp3cr( int reg, uint32_t value )
{
}
-READ32_MEMBER( psxcpu_device::gpu_r )
+uint32_t psxcpu_device::gpu_r(offs_t offset, uint32_t mem_mask)
{
- return m_gpu_read_handler( space, offset, mem_mask );
+ return m_gpu_read_handler( offset, mem_mask );
}
-WRITE32_MEMBER( psxcpu_device::gpu_w )
+void psxcpu_device::gpu_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
- m_gpu_write_handler( space, offset, data, mem_mask );
+ m_gpu_write_handler( offset, data, mem_mask );
}
-READ16_MEMBER( psxcpu_device::spu_r )
+uint16_t psxcpu_device::spu_r(offs_t offset, uint16_t mem_mask)
{
- return m_spu_read_handler( space, offset, mem_mask );
+ return m_spu_read_handler( offset, mem_mask );
}
-WRITE16_MEMBER( psxcpu_device::spu_w )
+void psxcpu_device::spu_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
- m_spu_write_handler( space, offset, data, mem_mask );
+ m_spu_write_handler( offset, data, mem_mask );
}
-READ8_MEMBER( psxcpu_device::cd_r )
+uint8_t psxcpu_device::cd_r(offs_t offset, uint8_t mem_mask)
{
- return m_cd_read_handler( space, offset, mem_mask );
+ return m_cd_read_handler( offset, mem_mask );
}
-WRITE8_MEMBER( psxcpu_device::cd_w )
+void psxcpu_device::cd_w(offs_t offset, uint8_t data, uint8_t mem_mask)
{
- m_cd_write_handler( space, offset, data, mem_mask );
+ m_cd_write_handler( offset, data, mem_mask );
}
void psxcpu_device::set_disable_rom_berr(bool mode)
diff --git a/src/devices/cpu/psx/psx.h b/src/devices/cpu/psx/psx.h
index ff21787eeab..16950f929da 100644
--- a/src/devices/cpu/psx/psx.h
+++ b/src/devices/cpu/psx/psx.h
@@ -128,42 +128,41 @@ public:
auto cd_write() { return m_cd_write_handler.bind(); }
// public interfaces
- DECLARE_WRITE32_MEMBER( berr_w );
- DECLARE_READ32_MEMBER( berr_r );
+ void berr_w(uint32_t data);
+ uint32_t berr_r();
uint32_t exp_base();
- DECLARE_WRITE32_MEMBER( exp_base_w );
- DECLARE_READ32_MEMBER( exp_base_r );
+ void exp_base_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t exp_base_r();
- DECLARE_WRITE32_MEMBER( exp_config_w );
- DECLARE_READ32_MEMBER( exp_config_r );
+ void exp_config_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t exp_config_r();
- DECLARE_WRITE32_MEMBER( ram_config_w );
- DECLARE_READ32_MEMBER( ram_config_r );
+ void ram_config_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t ram_config_r();
- DECLARE_WRITE32_MEMBER( rom_config_w );
- DECLARE_READ32_MEMBER( rom_config_r );
+ void rom_config_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t rom_config_r();
- DECLARE_WRITE32_MEMBER( biu_w );
- DECLARE_READ32_MEMBER( biu_r );
+ void biu_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t biu_r();
- DECLARE_WRITE32_MEMBER( gpu_w );
- DECLARE_READ32_MEMBER( gpu_r );
+ void gpu_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t gpu_r(offs_t offset, uint32_t mem_mask = ~0);
- DECLARE_WRITE16_MEMBER( spu_w );
- DECLARE_READ16_MEMBER( spu_r );
+ void spu_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
+ uint16_t spu_r(offs_t offset, uint16_t mem_mask = ~0);
- DECLARE_WRITE8_MEMBER( cd_w );
- DECLARE_READ8_MEMBER( cd_r );
+ void cd_w(offs_t offset, uint8_t data, uint8_t mem_mask = ~0);
+ uint8_t cd_r(offs_t offset, uint8_t mem_mask = ~0);
- DECLARE_WRITE32_MEMBER( com_delay_w );
- DECLARE_READ32_MEMBER( com_delay_r );
+ void com_delay_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t com_delay_r(offs_t offset, uint32_t mem_mask = ~0);
- static psxcpu_device *getcpu( device_t &device, const char *cputag ) { return downcast<psxcpu_device *>( device.subdevice( cputag ) ); }
void set_disable_rom_berr(bool mode);
- void psxcpu_internal_map(address_map &map);
+ void psxcpu_internal_map(address_map &map) ATTR_COLD;
protected:
static constexpr unsigned ICACHE_ENTRIES = 0x400;
static constexpr unsigned DCACHE_ENTRIES = 0x100;
@@ -171,17 +170,16 @@ protected:
psxcpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
- virtual void device_start() override;
- virtual void device_reset() override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
virtual void device_post_load() override;
- virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
// device_execute_interface overrides
- virtual uint32_t execute_min_cycles() const override { return 1; }
- virtual uint32_t execute_max_cycles() const override { return 40; }
- virtual uint32_t execute_input_lines() const override { return 6; }
- virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const override { return ( clocks + 3 ) / 4; }
- virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const override { return cycles * 4; }
+ virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
+ virtual uint32_t execute_max_cycles() const noexcept override { return 40; }
+ virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const noexcept override { return ( clocks + 3 ) / 4; }
+ virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const noexcept override { return cycles * 4; }
virtual void execute_run() override;
virtual void execute_set_input(int inputnum, int state) override;
@@ -208,7 +206,8 @@ protected:
// address spaces
const address_space_config m_program_config;
address_space *m_program;
- memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;
+ memory_access<32, 2, 0, ENDIANNESS_LITTLE>::cache m_instruction;
+ memory_access<32, 2, 0, ENDIANNESS_LITTLE>::specific m_data;
// other internal states
int m_icount;
@@ -309,7 +308,7 @@ protected:
devcb_read8 m_cd_read_handler;
devcb_write8 m_cd_write_handler;
required_device<ram_device> m_ram;
- memory_region *m_rom;
+ required_memory_region m_rom;
bool m_disable_rom_berr;
private:
diff --git a/src/devices/cpu/psx/psxdasm.cpp b/src/devices/cpu/psx/psxdasm.cpp
index 51a62f6dc1d..706b5523535 100644
--- a/src/devices/cpu/psx/psxdasm.cpp
+++ b/src/devices/cpu/psx/psxdasm.cpp
@@ -15,13 +15,17 @@
std::string psxcpu_disassembler::make_signed_hex_str_16( uint32_t value )
{
- if( value & 0x8000 )
+ if( int16_t( value & 0xffff ) >= -9 && int16_t( value & 0xffff ) <= 9 )
{
- return util::string_format("-$%x", -value & 0xffff );
+ return util::string_format("%d", int16_t( value & 0xffff ) );
+ }
+ else if( value & 0x8000 )
+ {
+ return util::string_format("-0x%x", -value & 0xffff );
}
else
{
- return util::string_format("$%x", value & 0xffff );
+ return util::string_format("0x%x", value & 0xffff );
}
}
@@ -159,15 +163,15 @@ std::string psxcpu_disassembler::upper_address( uint32_t op, offs_t pos, const d
if( INS_OP( nextop ) == OP_ORI && INS_RT( op ) == INS_RS( nextop ) )
{
- return util::string_format("$%04x ; 0x%08x", INS_IMMEDIATE( op ), ( INS_IMMEDIATE( op ) << 16 ) | INS_IMMEDIATE( nextop ) );
+ return util::string_format("0x%04x ; 0x%08x", INS_IMMEDIATE( op ), ( INS_IMMEDIATE( op ) << 16 ) | INS_IMMEDIATE( nextop ) );
}
else if( INS_OP( nextop ) == OP_ADDIU && INS_RT( op ) == INS_RS( nextop ) )
{
- return util::string_format("$%04x ; 0x%08x", INS_IMMEDIATE( op ), ( INS_IMMEDIATE( op ) << 16 ) + (int16_t) INS_IMMEDIATE( nextop ) );
+ return util::string_format("0x%04x ; 0x%08x", INS_IMMEDIATE( op ), ( INS_IMMEDIATE( op ) << 16 ) + (int16_t) INS_IMMEDIATE( nextop ) );
}
else
{
- return util::string_format("$%04x", INS_IMMEDIATE( op ) );
+ return util::string_format("0x%04x", INS_IMMEDIATE( op ) );
}
}
@@ -198,19 +202,19 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
case FUNCT_SLL:
if( op == 0 )
{
- /* the standard nop is "sll zero,zero,$0000" */
+ /* the standard nop is "sll zero,zero,0x0000" */
util::stream_format( stream, "nop" );
}
else
{
- util::stream_format( stream, "sll %s,%s,$%02x", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], INS_SHAMT( op ) );
+ util::stream_format( stream, "sll %s,%s,0x%02x", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], INS_SHAMT( op ) );
}
break;
case FUNCT_SRL:
- util::stream_format( stream, "srl %s,%s,$%02x", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], INS_SHAMT( op ) );
+ util::stream_format( stream, "srl %s,%s,0x%02x", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], INS_SHAMT( op ) );
break;
case FUNCT_SRA:
- util::stream_format( stream, "sra %s,%s,$%02x", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], INS_SHAMT( op ) );
+ util::stream_format( stream, "sra %s,%s,0x%02x", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], INS_SHAMT( op ) );
break;
case FUNCT_SLLV:
util::stream_format( stream, "sllv %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ] );
@@ -225,7 +229,7 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
util::stream_format( stream, "jr %s", s_cpugenreg[ INS_RS( op ) ] );
if( INS_RS( op ) == 31 )
{
- flags = STEP_OUT;
+ flags = STEP_OUT | step_over_extra( 1 );
}
break;
case FUNCT_JALR:
@@ -233,11 +237,11 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
flags = STEP_OVER | step_over_extra( 1 );
break;
case FUNCT_SYSCALL:
- util::stream_format( stream, "syscall $%05x", INS_CODE( op ) );
+ util::stream_format( stream, "syscall 0x%05x", INS_CODE( op ) );
flags = STEP_OVER;
break;
case FUNCT_BREAK:
- util::stream_format( stream, "break $%05x", INS_CODE( op ) );
+ util::stream_format( stream, "break 0x%05x", INS_CODE( op ) );
flags = STEP_OVER;
break;
case FUNCT_MFHI:
@@ -268,13 +272,22 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
util::stream_format( stream, "add %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
break;
case FUNCT_ADDU:
- util::stream_format( stream, "addu %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
+ if( INS_RT( op ) == 0 )
+ util::stream_format( stream, "move %s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ] );
+ else
+ util::stream_format( stream, "addu %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
break;
case FUNCT_SUB:
- util::stream_format( stream, "sub %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
+ if( INS_RS( op ) == 0 )
+ util::stream_format( stream, "neg %s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ] );
+ else
+ util::stream_format( stream, "sub %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
break;
case FUNCT_SUBU:
- util::stream_format( stream, "subu %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
+ if( INS_RS( op ) == 0 )
+ util::stream_format( stream, "negu %s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ] );
+ else
+ util::stream_format( stream, "subu %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
break;
case FUNCT_AND:
util::stream_format( stream, "and %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
@@ -286,7 +299,10 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
util::stream_format( stream, "xor %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
break;
case FUNCT_NOR:
- util::stream_format( stream, "nor %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
+ if( INS_RS( op ) == 0 || INS_RT( op ) == 0 )
+ util::stream_format( stream, "not %s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) != 0 ? INS_RS( op ) : INS_RT( op ) ] );
+ else
+ util::stream_format( stream, "nor %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
break;
case FUNCT_SLT:
util::stream_format( stream, "slt %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
@@ -302,51 +318,78 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
case RT_BLTZ:
if( INS_RT( op ) == RT_BLTZAL )
{
- util::stream_format( stream, "bltzal %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
- flags = STEP_OVER | step_over_extra( 1 );
+ util::stream_format( stream, "bltzal %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ if( INS_RS( op ) != 0 )
+ flags = STEP_OVER | STEP_COND | step_over_extra( 1 );
}
else
{
- util::stream_format( stream, "bltz %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ util::stream_format( stream, "bltz %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ if( INS_RS( op ) != 0 )
+ flags = STEP_COND | step_over_extra( 1 );
}
break;
case RT_BGEZ:
if( INS_RT( op ) == RT_BGEZAL )
{
- util::stream_format( stream, "bgezal %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ util::stream_format( stream, "bgezal %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
flags = STEP_OVER | step_over_extra( 1 );
+ if( INS_RS( op ) != 0 )
+ flags |= STEP_COND;
}
else
{
- util::stream_format( stream, "bgez %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ util::stream_format( stream, "bgez %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ if( INS_RS( op ) != 0 )
+ flags = STEP_COND | step_over_extra( 1 );
}
break;
}
break;
case OP_J:
- util::stream_format( stream, "j $%08x", jump_address( pc, op ) );
+ util::stream_format( stream, "j 0x%08x", jump_address( pc, op ) );
break;
case OP_JAL:
- util::stream_format( stream, "jal $%08x", jump_address( pc, op ) );
+ util::stream_format( stream, "jal 0x%08x", jump_address( pc, op ) );
flags = STEP_OVER | step_over_extra( 1 );
break;
case OP_BEQ:
- util::stream_format( stream, "beq %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
+ if( INS_RS( op ) == 0 && INS_RT( op ) == 0 )
+ {
+ util::stream_format( stream, "b 0x%08x", relative_address( pc, op ) );
+ }
+ else
+ {
+ if( INS_RT( op ) == 0 )
+ util::stream_format( stream, "beqz %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ else
+ util::stream_format( stream, "beq %s,%s,0x%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
+ flags = STEP_COND | step_over_extra( 1 );
+ }
break;
case OP_BNE:
- util::stream_format( stream, "bne %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
+ if( INS_RT( op ) == 0 )
+ util::stream_format( stream, "bnez %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ else
+ util::stream_format( stream, "bne %s,%s,0x%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
+ flags = STEP_COND | step_over_extra( 1 );
break;
case OP_BLEZ:
- util::stream_format( stream, "blez %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
+ util::stream_format( stream, "blez %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ flags = STEP_COND | step_over_extra( 1 );
break;
case OP_BGTZ:
- util::stream_format( stream, "bgtz %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
+ util::stream_format( stream, "bgtz %s,0x%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
+ flags = STEP_COND | step_over_extra( 1 );
break;
case OP_ADDI:
util::stream_format( stream, "addi %s,%s,%s", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
break;
case OP_ADDIU:
- util::stream_format( stream, "addiu %s,%s,%s", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
+ if( INS_RS( op ) == 0 )
+ util::stream_format( stream, "li %s,%s", s_cpugenreg[ INS_RT( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
+ else
+ util::stream_format( stream, "addiu %s,%s,%s", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
break;
case OP_SLTI:
util::stream_format( stream, "slti %s,%s,%s", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
@@ -355,13 +398,16 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
util::stream_format( stream, "sltiu %s,%s,%s", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
break;
case OP_ANDI:
- util::stream_format( stream, "andi %s,%s,$%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
+ util::stream_format( stream, "andi %s,%s,0x%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
break;
case OP_ORI:
- util::stream_format( stream, "ori %s,%s,$%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
+ if( INS_RS( op ) == 0 )
+ util::stream_format( stream, "li %s,0x%04x", s_cpugenreg[ INS_RT( op ) ], INS_IMMEDIATE( op ) );
+ else
+ util::stream_format( stream, "ori %s,%s,0x%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
break;
case OP_XORI:
- util::stream_format( stream, "xori %s,%s,$%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
+ util::stream_format( stream, "xori %s,%s,0x%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
break;
case OP_LUI:
util::stream_format( stream, "lui %s,%s", s_cpugenreg[ INS_RT( op ) ], upper_address( op, pos, opcodes ) );
@@ -386,12 +432,13 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
switch( INS_BC( op ) )
{
case BC_BCF:
- util::stream_format( stream, "bc0f $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc0f 0x%08x", relative_address( pc, op ) );
break;
case BC_BCT:
- util::stream_format( stream, "bc0t $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc0t 0x%08x", relative_address( pc, op ) );
break;
}
+ flags = STEP_COND | step_over_extra( 1 );
break;
default:
switch( INS_CO( op ) )
@@ -415,7 +462,7 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
util::stream_format( stream, "rfe" );
break;
default:
- util::stream_format(stream, "cop0 $%07x", INS_COFUN(op));
+ util::stream_format(stream, "cop0 0x%07x", INS_COFUN(op));
break;
}
break;
@@ -443,18 +490,19 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
switch( INS_BC( op ) )
{
case BC_BCF:
- util::stream_format( stream, "bc1f $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc1f 0x%08x", relative_address( pc, op ) );
break;
case BC_BCT:
- util::stream_format( stream, "bc1t $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc1t 0x%08x", relative_address( pc, op ) );
break;
}
+ flags = STEP_COND | step_over_extra( 1 );
break;
default:
switch( INS_CO( op ) )
{
case 1:
- util::stream_format( stream, "cop1 $%07x", INS_COFUN( op ) );
+ util::stream_format( stream, "cop1 0x%07x", INS_COFUN( op ) );
break;
}
break;
@@ -480,12 +528,13 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
switch( INS_BC( op ) )
{
case BC_BCF:
- util::stream_format( stream, "bc2f $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc2f 0x%08x", relative_address( pc, op ) );
break;
case BC_BCT:
- util::stream_format( stream, "bc2t $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc2t 0x%08x", relative_address( pc, op ) );
break;
}
+ flags = STEP_COND | step_over_extra( 1 );
break;
default:
switch( INS_CO( op ) )
@@ -563,7 +612,7 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
util::stream_format( stream, "ncct%s%s", s_gtesf[ GTE_SF( op ) ], s_gtelm[ GTE_LM( op ) ] );
break;
default:
- util::stream_format(stream, "cop2 $%07x", INS_COFUN(op));
+ util::stream_format(stream, "cop2 0x%07x", INS_COFUN(op));
break;
}
}
@@ -590,18 +639,19 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
switch( INS_BC( op ) )
{
case BC_BCF:
- util::stream_format( stream, "bc3f $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc3f 0x%08x", relative_address( pc, op ) );
break;
case BC_BCT:
- util::stream_format( stream, "bc3t $%08x", relative_address( pc, op ) );
+ util::stream_format( stream, "bc3t 0x%08x", relative_address( pc, op ) );
break;
}
+ flags = STEP_COND | step_over_extra( 1 );
break;
default:
switch( INS_CO( op ) )
{
case 1:
- util::stream_format( stream, "cop3 $%07x", INS_COFUN( op ) );
+ util::stream_format( stream, "cop3 0x%07x", INS_COFUN( op ) );
break;
}
break;
@@ -672,7 +722,7 @@ offs_t psxcpu_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
// fall back if we have not emitted anything
if (current_pos == stream.tellp())
{
- util::stream_format(stream, "dw $%08x", op);
+ util::stream_format(stream, "dw 0x%08x", op);
}
return ( pos - pc ) | flags | SUPPORTED;
diff --git a/src/devices/cpu/psx/rcnt.cpp b/src/devices/cpu/psx/rcnt.cpp
index e0ac985fa0a..0a9b03f89d3 100644
--- a/src/devices/cpu/psx/rcnt.cpp
+++ b/src/devices/cpu/psx/rcnt.cpp
@@ -10,20 +10,8 @@
#include "emu.h"
#include "rcnt.h"
-#define VERBOSE_LEVEL ( 0 )
-
-static inline void ATTR_PRINTF(3,4) verboselog( device_t& device, int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- device.logerror( "%s: %s", device.machine().describe_context(), buf );
- }
-}
+#define VERBOSE ( 0 )
+#include "logmacro.h"
DEFINE_DEVICE_TYPE(PSX_RCNT, psxrcnt_device, "psxrcnt", "Sony PSX RCNT")
@@ -41,41 +29,33 @@ void psxrcnt_device::device_reset()
void psxrcnt_device::device_post_load()
{
- int n;
- for( n = 0; n < 3; n++ )
- {
- root_timer_adjust( n );
- }
+ for (int n = 0; n < 3; n++)
+ root_timer_adjust(n);
}
void psxrcnt_device::device_start()
{
- int n;
+ save_item(STRUCT_MEMBER(root_counter, n_count));
+ save_item(STRUCT_MEMBER(root_counter, n_mode));
+ save_item(STRUCT_MEMBER(root_counter, n_target));
+ save_item(STRUCT_MEMBER(root_counter, n_start));
- m_irq0_handler.resolve_safe();
- m_irq1_handler.resolve_safe();
- m_irq2_handler.resolve_safe();
-
- for( n = 0; n < 3; n++ )
+ for (int n = 0; n < 3; n++)
{
- root_counter[ n ].timer = timer_alloc(n);
- save_item(NAME(root_counter[ n ].n_count), n);
- save_item(NAME(root_counter[ n ].n_mode), n);
- save_item(NAME(root_counter[ n ].n_target), n);
- save_item(NAME(root_counter[ n ].n_start), n);
- root_counter[ n ].n_count = 0;
- root_counter[ n ].n_mode = 0;
- root_counter[ n ].n_target = 0;
- root_counter[ n ].n_start = 0;
+ root_counter[n].timer = timer_alloc(FUNC(psxrcnt_device::timer_update ), this);
+ root_counter[n].n_count = 0;
+ root_counter[n].n_mode = 0;
+ root_counter[n].n_target = 0;
+ root_counter[n].n_start = 0;
}
}
-WRITE32_MEMBER( psxrcnt_device::write )
+void psxrcnt_device::write(offs_t offset, uint32_t data, uint32_t mem_mask)
{
- int n_counter = offset / 4;
- psx_root *root = &root_counter[ n_counter ];
+ int const n_counter = offset / 4;
+ psx_root *const root = &root_counter[ n_counter ];
- verboselog( *this, 1, "psx_counter_w ( %08x, %08x, %08x )\n", offset, data, mem_mask );
+ LOG( "%s: psx_counter_w ( %08x, %08x, %08x )\n", machine().describe_context(), offset, data, mem_mask );
switch( offset % 4 )
{
@@ -93,7 +73,9 @@ WRITE32_MEMBER( psxrcnt_device::write )
root->n_count = 0;
}
- root->n_mode = data;
+ // Reached FFFF and reached target value are read-only flags that are only cleared when read
+ data &= ~( PSX_RC_REACHEDFFFF | PSX_RC_REACHEDTARGET );
+ root->n_mode = data | ( root->n_mode & ( PSX_RC_REACHEDFFFF | PSX_RC_REACHEDTARGET ) );
#if 0
if( ( data & 0xfca6 ) != 0 ||
@@ -108,17 +90,17 @@ WRITE32_MEMBER( psxrcnt_device::write )
root->n_target = data;
break;
default:
- verboselog( *this, 0, "psx_counter_w( %08x, %08x, %08x ) unknown register\n", offset, mem_mask, data );
+ logerror( "%s: psx_counter_w( %08x, %08x, %08x ) unknown register\n", machine().describe_context(), offset, mem_mask, data );
return;
}
root_timer_adjust( n_counter );
}
-READ32_MEMBER( psxrcnt_device::read )
+uint32_t psxrcnt_device::read(offs_t offset, uint32_t mem_mask)
{
- int n_counter = offset / 4;
- psx_root *root = &root_counter[ n_counter ];
+ int const n_counter = offset / 4;
+ psx_root *const root = &root_counter[ n_counter ];
uint32_t data;
switch( offset % 4 )
@@ -128,15 +110,19 @@ READ32_MEMBER( psxrcnt_device::read )
break;
case 1:
data = root->n_mode;
+ if (!machine().side_effects_disabled())
+ root->n_mode &= ~( PSX_RC_REACHEDFFFF | PSX_RC_REACHEDTARGET );
break;
case 2:
data = root->n_target;
break;
default:
- verboselog( *this, 0, "psx_counter_r( %08x, %08x ) unknown register\n", offset, mem_mask );
+ if (!machine().side_effects_disabled())
+ logerror( "%s: psx_counter_r( %08x, %08x ) unknown register\n", machine().describe_context(), offset, mem_mask );
return 0;
}
- verboselog( *this, 1, "psx_counter_r ( %08x, %08x ) %08x\n", offset, mem_mask, data );
+ if (!machine().side_effects_disabled())
+ LOG( "%s: psx_counter_r ( %08x, %08x ) %08x\n", machine().describe_context(), offset, mem_mask, data );
return data;
}
@@ -148,7 +134,7 @@ uint64_t psxrcnt_device::gettotalcycles( void )
int psxrcnt_device::root_divider( int n_counter )
{
- psx_root *root = &root_counter[ n_counter ];
+ psx_root *const root = &root_counter[ n_counter ];
if( n_counter == 0 && ( root->n_mode & PSX_RC_CLC ) != 0 )
{
@@ -168,7 +154,7 @@ int psxrcnt_device::root_divider( int n_counter )
uint16_t psxrcnt_device::root_current( int n_counter )
{
- psx_root *root = &root_counter[ n_counter ];
+ psx_root *const root = &root_counter[ n_counter ];
if( ( root->n_mode & PSX_RC_STOP ) != 0 )
{
@@ -185,6 +171,7 @@ uint16_t psxrcnt_device::root_current( int n_counter )
/* TODO: use timer for wrap on 0x10000. */
root->n_count = n_current;
root->n_start = gettotalcycles();
+ root->n_mode |= PSX_RC_REACHEDFFFF;
}
return n_current;
}
@@ -192,7 +179,7 @@ uint16_t psxrcnt_device::root_current( int n_counter )
int psxrcnt_device::root_target( int n_counter )
{
- psx_root *root = &root_counter[ n_counter ];
+ psx_root *const root = &root_counter[ n_counter ];
if( ( root->n_mode & PSX_RC_COUNTTARGET ) != 0 ||
( root->n_mode & PSX_RC_IRQTARGET ) != 0 )
@@ -204,7 +191,7 @@ int psxrcnt_device::root_target( int n_counter )
void psxrcnt_device::root_timer_adjust( int n_counter )
{
- psx_root *root = &root_counter[ n_counter ];
+ psx_root *const root = &root_counter[ n_counter ];
if( ( root->n_mode & PSX_RC_STOP ) != 0 )
{
@@ -218,6 +205,15 @@ void psxrcnt_device::root_timer_adjust( int n_counter )
if( n_duration < 1 )
{
n_duration += 0x10000;
+
+ if ( ( root->n_mode & PSX_RC_COUNTTARGET ) != 0 )
+ {
+ root->n_mode |= PSX_RC_REACHEDTARGET;
+ }
+ else
+ {
+ root->n_mode |= PSX_RC_REACHEDFFFF;
+ }
}
n_duration *= root_divider( n_counter );
@@ -227,12 +223,12 @@ void psxrcnt_device::root_timer_adjust( int n_counter )
}
}
-void psxrcnt_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER( psxrcnt_device::timer_update )
{
- int n_counter = id;
- psx_root *root = &root_counter[ n_counter ];
+ int const n_counter = param;
+ psx_root *const root = &root_counter[ n_counter ];
- verboselog( *this, 2, "root_finished( %d ) %04x\n", n_counter, root_current( n_counter ) );
+ LOG( "root_finished( %d ) %04x\n", n_counter, root_current( n_counter ) );
//if( ( root->n_mode & PSX_RC_COUNTTARGET ) != 0 )
{
/* TODO: wrap should be handled differently as PSX_RC_COUNTTARGET & PSX_RC_IRQTARGET don't have to be the same. */
diff --git a/src/devices/cpu/psx/rcnt.h b/src/devices/cpu/psx/rcnt.h
index b6e4e46dab9..25df13a2d7e 100644
--- a/src/devices/cpu/psx/rcnt.h
+++ b/src/devices/cpu/psx/rcnt.h
@@ -23,6 +23,8 @@ DECLARE_DEVICE_TYPE(PSX_RCNT, psxrcnt_device)
#define PSX_RC_REPEAT ( 0x40 )
#define PSX_RC_CLC ( 0x100 )
#define PSX_RC_DIV ( 0x200 )
+#define PSX_RC_REACHEDTARGET ( 0x800 )
+#define PSX_RC_REACHEDFFFF ( 0x1000 )
class psxrcnt_device : public device_t
{
@@ -34,14 +36,15 @@ public:
auto irq1() { return m_irq1_handler.bind(); }
auto irq2() { return m_irq2_handler.bind(); }
- DECLARE_WRITE32_MEMBER( write );
- DECLARE_READ32_MEMBER( read );
+ void write(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t read(offs_t offset, uint32_t mem_mask = ~0);
protected:
- virtual void device_start() override;
- virtual void device_reset() override;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
virtual void device_post_load() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+ TIMER_CALLBACK_MEMBER( timer_update );
private:
struct psx_root
diff --git a/src/devices/cpu/psx/sio.cpp b/src/devices/cpu/psx/sio.cpp
index 5ff3e671109..07f7bd93bb6 100644
--- a/src/devices/cpu/psx/sio.cpp
+++ b/src/devices/cpu/psx/sio.cpp
@@ -10,20 +10,10 @@
#include "emu.h"
#include "sio.h"
-#define VERBOSE_LEVEL ( 0 )
+#define LOG_TIMER (1U << 1)
-static inline void ATTR_PRINTF(3,4) verboselog( device_t& device, int n_level, const char *s_fmt, ... )
-{
- if( VERBOSE_LEVEL >= n_level )
- {
- va_list v;
- char buf[ 32768 ];
- va_start( v, s_fmt );
- vsprintf( buf, s_fmt, v );
- va_end( v );
- device.logerror( "%s: %s", device.machine().describe_context(), buf );
- }
-}
+#define VERBOSE ( 0 )
+#include "logmacro.h"
DEFINE_DEVICE_TYPE(PSX_SIO0, psxsio0_device, "psxsio0", "Sony PSX SIO-0")
DEFINE_DEVICE_TYPE(PSX_SIO1, psxsio1_device, "psxsio1", "Sony PSX SIO-1")
@@ -57,13 +47,7 @@ void psxsio_device::device_post_load()
void psxsio_device::device_start()
{
- m_irq_handler.resolve_safe();
- m_sck_handler.resolve_safe();
- m_txd_handler.resolve_safe();
- m_dtr_handler.resolve_safe();
- m_rts_handler.resolve_safe();
-
- m_timer = timer_alloc( 0 );
+ m_timer = timer_alloc(FUNC( psxsio_device::sio_tick ), this);
m_mode = 0;
m_control = 0;
m_baud = 0;
@@ -74,22 +58,22 @@ void psxsio_device::device_start()
m_rx_bits = 0;
m_tx_bits = 0;
- save_item( NAME( m_status ) );
- save_item( NAME( m_mode ) );
- save_item( NAME( m_control ) );
- save_item( NAME( m_baud ) );
- save_item( NAME( m_rxd ) );
- save_item( NAME( m_rx_data ) );
- save_item( NAME( m_tx_data ) );
- save_item( NAME( m_rx_shift ) );
- save_item( NAME( m_tx_shift ) );
- save_item( NAME( m_rx_bits ) );
- save_item( NAME( m_tx_bits ) );
+ save_item(NAME(m_status));
+ save_item(NAME(m_mode));
+ save_item(NAME(m_control));
+ save_item(NAME(m_baud));
+ save_item(NAME(m_rxd));
+ save_item(NAME(m_rx_data));
+ save_item(NAME(m_tx_data));
+ save_item(NAME(m_rx_shift));
+ save_item(NAME(m_tx_shift));
+ save_item(NAME(m_rx_bits));
+ save_item(NAME(m_tx_bits));
}
void psxsio_device::sio_interrupt()
{
- verboselog( *this, 1, "sio_interrupt( %s )\n", tag() );
+ LOG("sio_interrupt\n");
m_status |= SIO_STATUS_IRQ;
m_irq_handler(1);
}
@@ -121,26 +105,26 @@ void psxsio_device::sio_timer_adjust()
if( m_baud != 0 && n_prescaler != 0 )
{
n_time = attotime::from_hz(33868800) * (n_prescaler * m_baud);
- verboselog( *this, 2, "sio_timer_adjust( %s ) = %s ( %d x %d )\n", tag(), n_time.as_string(), n_prescaler, m_baud );
+ LOGMASKED( LOG_TIMER, "sio_timer_adjust = %s ( %d x %d )\n", n_time.as_string(), n_prescaler, m_baud );
}
else
{
n_time = attotime::never;
- verboselog( *this, 0, "sio_timer_adjust( %s ) invalid baud rate ( %d x %d )\n", tag(), n_prescaler, m_baud );
+ logerror( "sio_timer_adjust invalid baud rate ( %d x %d )\n", n_prescaler, m_baud );
}
}
else
{
n_time = attotime::never;
- verboselog( *this, 2, "sio_timer_adjust( %s ) finished\n", tag() );
+ LOG( "sio_timer_adjust finished\n" );
}
m_timer->adjust( n_time );
}
-void psxsio_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
+TIMER_CALLBACK_MEMBER( psxsio_device::sio_tick )
{
- verboselog( *this, 2, "sio tick\n" );
+ LOGMASKED( LOG_TIMER, "sio tick\n" );
if( m_tx_bits == 0 &&
( m_control & SIO_CONTROL_TX_ENA ) != 0 &&
@@ -209,34 +193,34 @@ void psxsio_device::device_timer(emu_timer &timer, device_timer_id tid, int para
sio_timer_adjust();
}
-WRITE32_MEMBER( psxsio_device::write )
+void psxsio_device::write(offs_t offset, uint32_t data, uint32_t mem_mask)
{
switch( offset % 4 )
{
case 0:
- verboselog( *this, 1, "psx_sio_w %s data %02x (%08x)\n", tag(), data, mem_mask );
+ LOG( "%s: psx_sio_w data %02x (%08x)\n", machine().describe_context(), data, mem_mask );
m_tx_data = data;
m_status &= ~( SIO_STATUS_TX_RDY );
m_status &= ~( SIO_STATUS_TX_EMPTY );
sio_timer_adjust();
break;
case 1:
- verboselog( *this, 0, "psx_sio_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
+ logerror( "%s: psx_sio_w( %08x, %08x, %08x )\n", machine().describe_context(), offset, data, mem_mask );
break;
case 2:
if( ACCESSING_BITS_0_15 )
{
m_mode = data & 0xffff;
- verboselog( *this, 1, "psx_sio_w %s mode %04x\n", tag(), data & 0xffff );
+ LOG( "%s: psx_sio_w mode %04x\n", machine().describe_context(), data & 0xffff );
}
if( ACCESSING_BITS_16_31 )
{
- verboselog( *this, 1, "psx_sio_w %s control %04x\n", tag(), data >> 16 );
+ LOG( "%s: psx_sio_w control %04x\n", machine().describe_context(), data >> 16 );
m_control = data >> 16;
if( ( m_control & SIO_CONTROL_RESET ) != 0 )
{
- verboselog( *this, 1, "psx_sio_w reset\n" );
+ LOG( "%s: psx_sio_w reset\n", machine().describe_context() );
m_status |= SIO_STATUS_TX_EMPTY | SIO_STATUS_TX_RDY;
m_status &= ~( SIO_STATUS_RX_RDY | SIO_STATUS_OVERRUN | SIO_STATUS_IRQ );
m_irq_handler(0);
@@ -253,7 +237,7 @@ WRITE32_MEMBER( psxsio_device::write )
}
if( ( m_control & SIO_CONTROL_IACK ) != 0 )
{
- verboselog( *this, 1, "psx_sio_w iack\n" );
+ LOG( "%s: psx_sio_w iack\n", machine().describe_context() );
m_status &= ~( SIO_STATUS_IRQ );
m_control &= ~( SIO_CONTROL_IACK );
m_irq_handler(0);
@@ -271,21 +255,21 @@ WRITE32_MEMBER( psxsio_device::write )
case 3:
if( ACCESSING_BITS_0_15 )
{
- verboselog( *this, 0, "psx_sio_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
+ logerror( "%s: psx_sio_w( %08x, %08x, %08x )\n", machine().describe_context(), offset, data, mem_mask );
}
if( ACCESSING_BITS_16_31 )
{
m_baud = data >> 16;
- verboselog( *this, 1, "psx_sio_w %s baud %04x\n", tag(), data >> 16 );
+ LOG( "%s: psx_sio_w baud %04x\n", machine().describe_context(), data >> 16 );
}
break;
default:
- verboselog( *this, 0, "psx_sio_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
+ logerror( "%s: psx_sio_w( %08x, %08x, %08x )\n", machine().describe_context(), offset, data, mem_mask );
break;
}
}
-READ32_MEMBER( psxsio_device::read )
+uint32_t psxsio_device::read(offs_t offset, uint32_t mem_mask)
{
uint32_t data;
@@ -295,55 +279,55 @@ READ32_MEMBER( psxsio_device::read )
data = m_rx_data;
m_status &= ~( SIO_STATUS_RX_RDY );
m_rx_data = 0xff;
- verboselog( *this, 1, "psx_sio_r %s data %02x (%08x)\n", tag(), data, mem_mask );
+ LOG( "%s: psx_sio_r data %02x (%08x)\n", machine().describe_context(), data, mem_mask );
break;
case 1:
data = m_status;
if( ACCESSING_BITS_0_15 )
{
- verboselog( *this, 1, "psx_sio_r %s status %04x\n", tag(), data & 0xffff );
+ LOG( "%s: psx_sio_r status %04x\n", machine().describe_context(), data & 0xffff );
}
if( ACCESSING_BITS_16_31 )
{
- verboselog( *this, 0, "psx_sio_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
+ logerror( "%s: psx_sio_r( %08x, %08x ) %08x\n", machine().describe_context(), offset, mem_mask, data );
}
break;
case 2:
data = ( m_control << 16 ) | m_mode;
if( ACCESSING_BITS_0_15 )
{
- verboselog( *this, 1, "psx_sio_r %s mode %04x\n", tag(), data & 0xffff );
+ LOG( "%s: psx_sio_r mode %04x\n", machine().describe_context(), data & 0xffff );
}
if( ACCESSING_BITS_16_31 )
{
- verboselog( *this, 1, "psx_sio_r %s control %04x\n", tag(), data >> 16 );
+ LOG( "%s: psx_sio_r control %04x\n", machine().describe_context(), data >> 16 );
}
break;
case 3:
data = m_baud << 16;
if( ACCESSING_BITS_0_15 )
{
- verboselog( *this, 0, "psx_sio_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
+ logerror( "%s: psx_sio_r( %08x, %08x ) %08x\n", machine().describe_context(), offset, mem_mask, data );
}
if( ACCESSING_BITS_16_31 )
{
- verboselog( *this, 1, "psx_sio_r %s baud %04x\n", tag(), data >> 16 );
+ LOG( "%s: psx_sio_r baud %04x\n", machine().describe_context(), data >> 16 );
}
break;
default:
data = 0;
- verboselog( *this, 0, "psx_sio_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
+ logerror( "%s: psx_sio_r( %08x, %08x ) %08x\n", machine().describe_context(), offset, mem_mask, data );
break;
}
return data;
}
-WRITE_LINE_MEMBER(psxsio_device::write_rxd)
+void psxsio_device::write_rxd(int state)
{
m_rxd = state;
}
-WRITE_LINE_MEMBER(psxsio_device::write_dsr)
+void psxsio_device::write_dsr(int state)
{
if (state)
{
diff --git a/src/devices/cpu/psx/sio.h b/src/devices/cpu/psx/sio.h
index 7e02b57330f..6bc07ab1df8 100644
--- a/src/devices/cpu/psx/sio.h
+++ b/src/devices/cpu/psx/sio.h
@@ -43,20 +43,21 @@ public:
auto dtr_handler() { return m_dtr_handler.bind(); }
auto rts_handler() { return m_rts_handler.bind(); }
- DECLARE_WRITE32_MEMBER( write );
- DECLARE_READ32_MEMBER( read );
+ void write(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
+ uint32_t read(offs_t offset, uint32_t mem_mask = ~0);
- DECLARE_WRITE_LINE_MEMBER(write_rxd);
- DECLARE_WRITE_LINE_MEMBER(write_dsr);
+ void write_rxd(int state);
+ void write_dsr(int state);
protected:
psxsio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
- virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_start() override ATTR_COLD;
virtual void device_post_load() override;
+ TIMER_CALLBACK_MEMBER( sio_tick );
+
private:
void sio_interrupt();
void sio_timer_adjust();