psx spu dma hookup is done in machine config, so the trampolines can go.

plus a bit of a tidy up.
This commit is contained in:
smf- 2011-06-04 05:52:49 +00:00
parent 1d1983b52c
commit fe7cf51480
5 changed files with 52 additions and 86 deletions

View File

@ -1042,8 +1042,6 @@ void spu_device::device_reset()
dirty_flags = -1;
changed_xa_vol = 0;
installed_dma_hooks = false;
xa_cnt=0;
xa_freq=0;
xa_channels=2;
@ -3090,20 +3088,20 @@ void spu_device::flush_cdda(const unsigned int sector)
// MAME I/O stuff. This can get cleaner when machine/psx.c does.
static void spu_dma_read( spu_device *spu, UINT32 n_address, INT32 n_size )
void spu_device::dma_read( UINT32 n_address, INT32 n_size )
{
UINT8 *psxram = (UINT8 *)memory_get_shared(spu->machine(), "share1");
UINT8 *psxram = (UINT8 *)memory_get_shared(machine(), "share1");
spu->start_dma(psxram + n_address, false, n_size*4);
start_dma(psxram + n_address, false, n_size*4);
}
static void spu_dma_write( spu_device *spu, UINT32 n_address, INT32 n_size )
void spu_device::dma_write( UINT32 n_address, INT32 n_size )
{
UINT8 *psxram = (UINT8 *)memory_get_shared(spu->machine(), "share1");
UINT8 *psxram = (UINT8 *)memory_get_shared(machine(), "share1");
// printf("SPU DMA write from %x, size %x\n", n_address, n_size);
spu->start_dma(psxram + n_address, true, n_size*4);
start_dma(psxram + n_address, true, n_size*4);
}
READ16_HANDLER( spu_r )
@ -3115,13 +3113,6 @@ READ16_HANDLER( spu_r )
return 0;
}
if (!spu->installed_dma_hooks)
{
psx_dma_install_read_handler( space->machine(), 4, psx_dma_read_delegate( FUNC( spu_dma_read ), spu ) );
psx_dma_install_write_handler( space->machine(), 4, psx_dma_write_delegate( FUNC( spu_dma_write ), spu ) );
spu->installed_dma_hooks = true;
}
return spu->read_word(offset*2);
}
@ -3134,13 +3125,5 @@ WRITE16_HANDLER( spu_w )
return;
}
if (!spu->installed_dma_hooks)
{
psx_dma_install_read_handler( space->machine(), 4, psx_dma_read_delegate( FUNC( spu_dma_read ), spu ) );
psx_dma_install_write_handler( space->machine(), 4, psx_dma_write_delegate( FUNC( spu_dma_write ), spu ) );
spu->installed_dma_hooks = true;
}
spu->write_word(offset*2, data);
}

View File

@ -11,10 +11,8 @@
#define MCFG_SPU_ADD(_tag, _clock, _irqf) \
MCFG_DEVICE_ADD(_tag, SPU, _clock) \
MCFG_IRQ_FUNC(_irqf)
#define MCFG_SPU_REPLACE(_tag, _clock, _irqf) \
MCFG_DEVICE_REPLACE(_tag, SPU, _clock) \
MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 4, psx_dma_read_delegate( FUNC( spu_device::dma_read ), (spu_device *) device ) ) \
MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 4, psx_dma_write_delegate( FUNC( spu_device::dma_write ), (spu_device *) device ) ) \
MCFG_IRQ_FUNC(_irqf)
#define MCFG_IRQ_FUNC(_irqf) \
@ -222,6 +220,9 @@ public:
// inline configuration helpers
static void static_set_irqf(device_t &device, void (*irqf)(device_t *device, UINT32 state));
void dma_read( UINT32 n_address, INT32 n_size );
void dma_write( UINT32 n_address, INT32 n_size );
void reinit_sound();
void kill_sound();
@ -238,7 +239,6 @@ public:
void write_byte(const unsigned int addr, const unsigned char byte);
void write_word(const unsigned int addr, const unsigned short word);
bool installed_dma_hooks;
sound_stream *m_stream;
};

View File

@ -99,16 +99,6 @@ INLINE void ATTR_PRINTF(3,4) verboselog( running_machine& machine, int n_level,
}
}
PALETTE_INIT( psx )
{
UINT32 n_colour;
for( n_colour = 0; n_colour < 0x10000; n_colour++ )
{
palette_set_color_rgb( machine, n_colour, pal5bit(n_colour >> 0), pal5bit(n_colour >> 5), pal5bit(n_colour >> 10) );
}
}
#if defined( MAME_DEBUG )
void psxgpu_device::DebugMeshInit( void )

View File

@ -24,29 +24,19 @@ public:
};
/*----------- defined in machine/psx.c -----------*/
PALETTE_INIT( psx );
VIDEO_START( psx_type1 );
VIDEO_START( psx_type2 );
SCREEN_UPDATE( psx );
INTERRUPT_GEN( psx_vblank );
extern void psx_gpu_reset( running_machine &machine );
READ32_HANDLER( psx_gpu_r );
WRITE32_HANDLER( psx_gpu_w );
extern void psx_lightgun_set( running_machine &, int, int );
extern void psx_driver_init( running_machine &machine );
WRITE32_HANDLER( psx_com_delay_w );
READ32_HANDLER( psx_com_delay_r );
extern void psx_irq_set( running_machine &, UINT32 );
extern void psx_dma_install_read_handler( running_machine &, int, psx_dma_read_delegate );
extern void psx_dma_install_write_handler( running_machine &, int, psx_dma_read_delegate );
WRITE32_HANDLER( psx_counter_w );
READ32_HANDLER( psx_counter_r );
extern void psx_sio_install_handler( running_machine &, int, psx_sio_handler );
extern void psx_sio_input( running_machine &, int, int, int );
extern void psx_driver_init( running_machine &machine );
PALETTE_INIT( psx );
SCREEN_UPDATE( psx );
READ32_HANDLER( psx_gpu_r );
WRITE32_HANDLER( psx_gpu_w );
INTERRUPT_GEN( psx_vblank );
extern void psx_lightgun_set( running_machine &, int, int );
#define PSX_H ( 1 )
#endif

View File

@ -24,6 +24,15 @@ INLINE void ATTR_PRINTF(3,4) verboselog( psx_state *p_psx, int n_level, const ch
}
}
void psx_driver_init( running_machine &machine )
{
psx_state *p_psx = machine.driver_data<psx_state>();
p_psx->b_need_sianniv_vblank_hack = !strcmp(machine.system().name, "sianniv");
p_psx->m_p_n_psxram = (UINT32 *)memory_get_shared(machine, "share1", p_psx->m_n_psxramsize);
}
WRITE32_HANDLER( psx_com_delay_w )
{
psx_state *p_psx = space->machine().driver_data<psx_state>();
@ -40,21 +49,6 @@ READ32_HANDLER( psx_com_delay_r )
return p_psx->n_com_delay;
}
INTERRUPT_GEN( psx_vblank )
{
psxgpu_device *gpu = downcast<psxgpu_device *>( device->machine().device("gpu") );
psx_state *p_psx = device->machine().driver_data<psx_state>();
if(p_psx->b_need_sianniv_vblank_hack)
{
UINT32 pc = cpu_get_pc(device);
if((pc >= 0x80010018 && pc <= 0x80010028) || pc == 0x8002a4f0)
return;
}
gpu->vblank();
}
/* IRQ */
void psx_irq_set( running_machine &machine, UINT32 data )
@ -62,17 +56,7 @@ void psx_irq_set( running_machine &machine, UINT32 data )
psxcpu_device::irq_set( *machine.device("maincpu"), "maincpu", data );
}
/* DMA */
void psx_dma_install_read_handler( running_machine &machine, int n_channel, psx_dma_read_delegate p_fn_dma_read )
{
downcast<psxdma_device *>( machine.device("maincpu")->subdevice("dma") )->install_read_handler( n_channel, p_fn_dma_read );
}
void psx_dma_install_write_handler( running_machine &machine, int n_channel, psx_dma_read_delegate p_fn_dma_write )
{
downcast<psxdma_device *>( machine.device("maincpu")->subdevice("dma") )->install_write_handler( n_channel, p_fn_dma_write );
}
/* SIO */
void psx_sio_install_handler( running_machine &machine, int n_port, psx_sio_handler p_f_sio_handler )
{
@ -84,13 +68,16 @@ void psx_sio_input( running_machine &machine, int n_port, int n_mask, int n_data
psxcpu_device::sio_input( *machine.device("maincpu"), "maincpu", n_port, n_mask, n_data );
}
void psx_driver_init( running_machine &machine )
/* GPU */
PALETTE_INIT( psx )
{
psx_state *p_psx = machine.driver_data<psx_state>();
UINT32 n_colour;
p_psx->b_need_sianniv_vblank_hack = !strcmp(machine.system().name, "sianniv");
p_psx->m_p_n_psxram = (UINT32 *)memory_get_shared(machine, "share1", p_psx->m_n_psxramsize);
for( n_colour = 0; n_colour < 0x10000; n_colour++ )
{
palette_set_color_rgb( machine, n_colour, pal5bit(n_colour >> 0), pal5bit(n_colour >> 5), pal5bit(n_colour >> 10) );
}
}
SCREEN_UPDATE( psx )
@ -117,3 +104,19 @@ void psx_lightgun_set( running_machine &machine, int n_x, int n_y )
psxgpu_device *gpu = downcast<psxgpu_device *>( machine.device("gpu") );
gpu->lightgun_set( n_x, n_y );
}
INTERRUPT_GEN( psx_vblank )
{
psxgpu_device *gpu = downcast<psxgpu_device *>( device->machine().device("gpu") );
psx_state *p_psx = device->machine().driver_data<psx_state>();
if(p_psx->b_need_sianniv_vblank_hack)
{
UINT32 pc = cpu_get_pc(device);
if((pc >= 0x80010018 && pc <= 0x80010028) || pc == 0x8002a4f0)
return;
}
gpu->vblank();
}