summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2011-06-04 05:52:49 +0000
committer smf- <smf-@users.noreply.github.com>2011-06-04 05:52:49 +0000
commitfe7cf514805dbfc37c9e4db101c4766de6c0aa41 (patch)
tree54f6f31eace127f8733a4001d1c48b637deacac6 /src
parent1d1983b52c8c85039d0f066940378763f8cb13d9 (diff)
psx spu dma hookup is done in machine config, so the trampolines can go.
plus a bit of a tidy up.
Diffstat (limited to 'src')
-rw-r--r--src/emu/sound/spu.c29
-rw-r--r--src/emu/sound/spu.h10
-rw-r--r--src/emu/video/psx.c10
-rw-r--r--src/mame/includes/psx.h24
-rw-r--r--src/mame/machine/psx.c65
5 files changed, 52 insertions, 86 deletions
diff --git a/src/emu/sound/spu.c b/src/emu/sound/spu.c
index b8715f45565..df26313c100 100644
--- a/src/emu/sound/spu.c
+++ b/src/emu/sound/spu.c
@@ -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);
}
-
diff --git a/src/emu/sound/spu.h b/src/emu/sound/spu.h
index a0aec5943d4..5f9c8a1797c 100644
--- a/src/emu/sound/spu.h
+++ b/src/emu/sound/spu.h
@@ -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;
};
diff --git a/src/emu/video/psx.c b/src/emu/video/psx.c
index 125495c144d..16252219227 100644
--- a/src/emu/video/psx.c
+++ b/src/emu/video/psx.c
@@ -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 )
diff --git a/src/mame/includes/psx.h b/src/mame/includes/psx.h
index 7b1df1d569b..17a1c7debdc 100644
--- a/src/mame/includes/psx.h
+++ b/src/mame/includes/psx.h
@@ -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
diff --git a/src/mame/machine/psx.c b/src/mame/machine/psx.c
index 965033068b8..aa861fe22ba 100644
--- a/src/mame/machine/psx.c
+++ b/src/mame/machine/psx.c
@@ -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 )
-{
- psx_state *p_psx = machine.driver_data<psx_state>();
+/* GPU */
- p_psx->b_need_sianniv_vblank_hack = !strcmp(machine.system().name, "sianniv");
+PALETTE_INIT( psx )
+{
+ UINT32 n_colour;
- 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();
+}
+