Previous 15994 Revisions Next

r11778 Thursday 2nd June, 2011 at 14:28:27 UTC by smf
removed dma trampoline from the cpu.
added MCFG_PSXGPU_ADD for adding the gpu device and hooking up the dma to the cpu.
[src/emu/cpu/psx]psx.c psx.h
[src/emu/video]psx.c psx.h
[src/mame/drivers]konamigq.c konamigv.c ksys573.c namcos10.c namcos11.c namcos12.c taitogn.c twinkle.c zn.c
[src/mame/includes]psx.h
[src/mame/machine]psx.c
[src/mess/drivers]psx.c

src/mame/machine/psx.c
r11777r11778
6666
6767void psx_dma_install_read_handler( running_machine &machine, int n_channel, psx_dma_read_delegate p_fn_dma_read )
6868{
69   psxcpu_device::install_dma_read_handler( *machine.device("maincpu"), "maincpu", n_channel, p_fn_dma_read );
69   downcast<psxdma_device *>( machine.device("maincpu")->subdevice("dma") )->install_read_handler( n_channel, p_fn_dma_read );
7070}
7171
7272void psx_dma_install_write_handler( running_machine &machine, int n_channel, psx_dma_read_delegate p_fn_dma_write )
7373{
74   psxcpu_device::install_dma_write_handler( *machine.device("maincpu"), "maincpu", n_channel, p_fn_dma_write );
74   downcast<psxdma_device *>( machine.device("maincpu")->subdevice("dma") )->install_write_handler( n_channel, p_fn_dma_write );
7575}
7676
7777void psx_sio_install_handler( running_machine &machine, int n_port, psx_sio_handler p_f_sio_handler )
r11777r11778
8484   psxcpu_device::sio_input( *machine.device("maincpu"), "maincpu", n_port, n_mask, n_data );
8585}
8686
87static void gpu_read( psx_state *p_psx, UINT32 n_address, INT32 n_size )
88{
89   psxgpu_device *gpu = downcast<psxgpu_device *>( p_psx->machine().device("gpu") );
90   UINT32 *p_n_psxram = p_psx->m_p_n_psxram;
91
92   gpu->dma_read( &p_n_psxram[ n_address / 4 ], n_size );
93}
94
95static void gpu_write( psx_state *p_psx, UINT32 n_address, INT32 n_size )
96{
97   psxgpu_device *gpu = downcast<psxgpu_device *>( p_psx->machine().device("gpu") );
98   UINT32 *p_n_psxram = p_psx->m_p_n_psxram;
99
100   gpu->dma_write( &p_n_psxram[ n_address / 4 ], n_size );
101}
102
10387void psx_driver_init( running_machine &machine )
10488{
10589   psx_state *p_psx = machine.driver_data<psx_state>();
r11777r11778
10791   p_psx->b_need_sianniv_vblank_hack = !strcmp(machine.system().name, "sianniv");
10892
10993   p_psx->m_p_n_psxram = (UINT32 *)memory_get_shared(machine, "share1", p_psx->m_n_psxramsize);
110
111   psx_dma_install_read_handler( machine, 2, psx_dma_read_delegate( FUNC( gpu_read ), p_psx ) );
112   psx_dma_install_write_handler( machine, 2, psx_dma_write_delegate( FUNC( gpu_write ), p_psx ) );
11394}
11495
11596SCREEN_UPDATE( psx )
src/mame/includes/psx.h
r11777r11778
3232SCREEN_UPDATE( psx );
3333INTERRUPT_GEN( psx_vblank );
3434extern void psx_gpu_reset( running_machine &machine );
35extern void psx_gpu_read( running_machine &, UINT32 *p_ram, INT32 n_size );
36extern void psx_gpu_write( running_machine &, UINT32 *p_ram, INT32 n_size );
3735READ32_HANDLER( psx_gpu_r );
3836WRITE32_HANDLER( psx_gpu_w );
3937extern void psx_lightgun_set( running_machine &, int, int );
src/mame/drivers/zn.c
r11777r11778
502502   MCFG_PALETTE_LENGTH( 65536 )
503503
504504   MCFG_PALETTE_INIT( psx )
505   MCFG_DEVICE_ADD( "gpu", CXD8561Q, 0 )
505   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0 )
506506
507507   /* sound hardware */
508508   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
r11777r11778
538538   MCFG_PALETTE_LENGTH( 65536 )
539539
540540   MCFG_PALETTE_INIT( psx )
541   MCFG_DEVICE_ADD( "gpu", CXD8654Q, 0 )
541   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8654Q, 0 )
542542
543543   /* sound hardware */
544544   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/mame/drivers/namcos10.c
r11777r11778
491491   MCFG_PALETTE_LENGTH( 65536 )
492492
493493   MCFG_PALETTE_INIT( psx )
494   MCFG_DEVICE_ADD( "gpu", CXD8561CQ, 0 )
494   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561CQ, 0 )
495495
496496   /* sound hardware */
497497   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/mame/drivers/namcos12.c
r11777r11778
16701670   MCFG_PALETTE_LENGTH( 65536 )
16711671
16721672   MCFG_PALETTE_INIT( psx )
1673   MCFG_DEVICE_ADD( "gpu", CXD8654Q, 0 )
1673   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8654Q, 0 )
16741674
16751675   /* sound hardware */
16761676   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/mame/drivers/konamigq.c
r11777r11778
391391   MCFG_PALETTE_LENGTH( 65536 )
392392
393393   MCFG_PALETTE_INIT( psx )
394   MCFG_DEVICE_ADD( "gpu", CXD8538Q, 0 )
394   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8538Q, 0 )
395395
396396   /* sound hardware */
397397   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/mame/drivers/twinkle.c
r11777r11778
906906   MCFG_PALETTE_LENGTH( 65536 )
907907
908908   MCFG_PALETTE_INIT( psx )
909   MCFG_DEVICE_ADD( "gpu", CXD8561Q, 0 )
909   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0 )
910910
911911   /* sound hardware */
912912   MCFG_SPEAKER_STANDARD_STEREO("speakerleft", "speakerright")
src/mame/drivers/namcos11.c
r11777r11778
10061006   MCFG_PALETTE_LENGTH( 65536 )
10071007
10081008   MCFG_PALETTE_INIT( psx )
1009   MCFG_DEVICE_ADD( "gpu", CXD8538Q, 0 )
1009   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8538Q, 0 )
10101010
10111011   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
10121012   MCFG_SOUND_ADD("c352", C352, 16384000)
src/mame/drivers/konamigv.c
r11777r11778
350350   MCFG_PALETTE_LENGTH( 65536 )
351351
352352   MCFG_PALETTE_INIT( psx )
353   MCFG_DEVICE_ADD( "gpu", CXD8514Q, 0 )
353   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8514Q, 0 )
354354
355355   /* sound hardware */
356356   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/mame/drivers/ksys573.c
r11777r11778
29882988   MCFG_PALETTE_LENGTH( 65536 )
29892989
29902990   MCFG_PALETTE_INIT( psx )
2991   MCFG_DEVICE_ADD( "gpu", CXD8561Q, 0 )
2991   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0 )
29922992
29932993   /* sound hardware */
29942994   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/mame/drivers/taitogn.c
r11777r11778
975975   MCFG_PALETTE_LENGTH( 65536 )
976976
977977   MCFG_PALETTE_INIT( psx )
978   MCFG_DEVICE_ADD( "gpu", CXD8654Q, 0 )
978   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8654Q, 0 )
979979
980980   /* sound hardware */
981981   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
src/emu/cpu/psx/psx.c
r11777r11778
31563156{
31573157}
31583158
3159static psxcpu_device *getcpu( device_t &device, const char *cputag )
3159psxcpu_device *psxcpu_device::getcpu( device_t &device, const char *cputag )
31603160{
31613161   if( strcmp( cputag, DEVICE_SELF ) == 0 )
31623162   {
r11777r11778
31723172   irq->set( bitmask );
31733173}
31743174
3175void psxcpu_device::install_dma_read_handler( device_t &device, const char *cputag, int channel, psx_dma_read_delegate handler )
3176{
3177   psxdma_device *dma = downcast<psxdma_device *>( getcpu( device, cputag )->subdevice("dma") );
3178   dma->install_read_handler( channel, handler );
3179}
3180
3181void psxcpu_device::install_dma_write_handler( device_t &device, const char *cputag, int channel, psx_dma_write_delegate handler )
3182{
3183   psxdma_device *dma = downcast<psxdma_device *>( getcpu( device, cputag )->subdevice("dma") );
3184   dma->install_write_handler( channel, handler );
3185}
3186
31873175void psxcpu_device::install_sio_handler( device_t &device, const char *cputag, int n_port, psx_sio_handler p_f_sio_handler )
31883176{
31893177   psxsio_device *sio = downcast<psxsio_device *>( getcpu( device, cputag )->subdevice("sio") );
src/emu/cpu/psx/psx.h
r11777r11778
105105//**************************************************************************
106106
107107#define MCFG_PSX_DMA_CHANNEL_READ( cputag, channel, handler ) \
108   psxcpu_device::install_dma_read_handler( *owner, cputag, channel, handler ); \
108   downcast<psxdma_device *>( psxcpu_device::getcpu( *owner, cputag )->subdevice("dma") )->install_read_handler( channel, handler );
109109
110110#define MCFG_PSX_DMA_CHANNEL_WRITE( cputag, channel, handler ) \
111   psxcpu_device::install_dma_write_handler( *owner, cputag, channel, handler ); \
111   downcast<psxdma_device *>( psxcpu_device::getcpu( *owner, cputag )->subdevice("dma") )->install_write_handler( channel, handler );
112112
113113
114114
r11777r11778
130130   WRITE32_MEMBER( berr_w );
131131   READ32_MEMBER( berr_r );
132132
133   static void install_dma_read_handler( device_t &device, const char *cputag, int channel, psx_dma_read_delegate handler );
134   static void install_dma_write_handler( device_t &device, const char *cputag, int channel, psx_dma_write_delegate handler );
133   static psxcpu_device *getcpu( device_t &device, const char *cputag );
135134   static void install_sio_handler( device_t &device, const char *cputag, int n_port, psx_sio_handler p_f_sio_handler );
136135   static void sio_input( device_t &device, const char *cputag, int n_port, int n_mask, int n_data );
137136   static void irq_set( device_t &device, const char *cputag, UINT32 bitmask );
src/emu/video/psx.c
r11777r11778
29242924   }
29252925}
29262926
2927void psxgpu_device::dma_write( UINT32 *p_ram, INT32 n_size )
2927void psxgpu_device::dma_write( UINT32 n_address, INT32 n_size )
29282928{
2929   psx_state *p_psx = machine().driver_data<psx_state>();
2930   UINT32 *p_n_psxram = p_psx->m_p_n_psxram;
2931
2932   gpu_write( &p_n_psxram[ n_address / 4 ], n_size );
2933}
2934
2935void psxgpu_device::gpu_write( UINT32 *p_ram, INT32 n_size )
2936{
29292937   while( n_size > 0 )
29302938   {
29312939      UINT32 data = *( p_ram );
r11777r11778
34183426   switch( offset )
34193427   {
34203428   case 0x00:
3421      dma_write( &data, 1 );
3429      gpu_write( &data, 1 );
34223430      break;
34233431   case 0x01:
34243432      switch( data >> 24 )
r11777r11778
35563564}
35573565
35583566
3559void psxgpu_device::dma_read( UINT32 *p_ram, INT32 n_size )
3567void psxgpu_device::dma_read( UINT32 n_address, INT32 n_size )
35603568{
3569   psx_state *p_psx = machine().driver_data<psx_state>();
3570   UINT32 *p_n_psxram = p_psx->m_p_n_psxram;
3571
3572   gpu_read( &p_n_psxram[ n_address / 4 ], n_size );
3573}
3574
3575void psxgpu_device::gpu_read( UINT32 *p_ram, INT32 n_size )
3576{
35613577   while( n_size > 0 )
35623578   {
35633579      if( ( n_gpustatus & ( 1L << 0x1b ) ) != 0 )
r11777r11778
36113627   switch( offset )
36123628   {
36133629   case 0x00:
3614      dma_read( &data, 1 );
3630      gpu_read( &data, 1 );
36153631      break;
36163632   case 0x01:
36173633      data = n_gpustatus;
src/emu/video/psx.h
r11777r11778
1212 
1313#include "emu.h"
1414 
15#define MCFG_PSXGPU_ADD( cputag, tag, type, clock ) \
16   MCFG_DEVICE_ADD( tag, type, clock ) \
17   MCFG_PSX_DMA_CHANNEL_READ( cputag, 2, psx_dma_write_delegate( FUNC( psxgpu_device::dma_read ), (psxgpu_device *) device ) ) \
18   MCFG_PSX_DMA_CHANNEL_WRITE( cputag, 2, psx_dma_read_delegate( FUNC( psxgpu_device::dma_write ), (psxgpu_device *) device ) )
19 
1520extern const device_type CXD8514Q;
1621extern const device_type CXD8538Q;
1722extern const device_type CXD8561Q;
r11777r11778
168173   void update_screen(bitmap_t *bitmap, const rectangle *cliprect);
169174   WRITE32_MEMBER( write );
170175   READ32_MEMBER( read );
171   void dma_read( UINT32 *p_ram, INT32 n_size );
172   void dma_write( UINT32 *p_ram, INT32 n_size );
176   void dma_read( UINT32 n_address, INT32 n_size );
177   void dma_write( UINT32 n_address, INT32 n_size );
173178   void lightgun_set( int, int );
174179   void vblank( void );
175180 
r11777r11778
195200   void MoveImage( void );
196201   void psx_gpu_init( int n_gputype );
197202   void gpu_reset();
203   void gpu_read( UINT32 *p_ram, INT32 n_size );
204   void gpu_write( UINT32 *p_ram, INT32 n_size );
198205 
199206#if defined( MAME_DEBUG )
200207   void DebugMeshInit( void );
src/mess/drivers/psx.c
r11777r11778
781781   MCFG_PALETTE_LENGTH( 65536 )
782782
783783   MCFG_PALETTE_INIT( psx )
784   MCFG_DEVICE_ADD( "gpu", CXD8561Q, 0 )
784   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0 )
785785
786786   /* sound hardware */
787787   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
r11777r11778
818818   MCFG_PALETTE_LENGTH( 65536 )
819819
820820   MCFG_PALETTE_INIT( psx )
821   MCFG_DEVICE_ADD( "gpu", CXD8561Q, 0 )
821   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0 )
822822
823823   /* sound hardware */
824824   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team