Previous 15994 Revisions Next

r11802 Saturday 4th June, 2011 at 05:53:17 UTC by smf
psx spu dma hookup is done in machine config, so the trampolines can go.
plus a bit of a tidy up.
[src/emu/sound]spu.c spu.h
[src/emu/video]psx.c
[src/mame/includes]psx.h
[src/mame/machine]psx.c

src/mame/machine/psx.c
r11801r11802
2424   }
2525}
2626
27void psx_driver_init( running_machine &machine )
28{
29   psx_state *p_psx = machine.driver_data<psx_state>();
30
31   p_psx->b_need_sianniv_vblank_hack = !strcmp(machine.system().name, "sianniv");
32
33   p_psx->m_p_n_psxram = (UINT32 *)memory_get_shared(machine, "share1", p_psx->m_n_psxramsize);
34}
35
2736WRITE32_HANDLER( psx_com_delay_w )
2837{
2938   psx_state *p_psx = space->machine().driver_data<psx_state>();
r11801r11802
4049   return p_psx->n_com_delay;
4150}
4251
43INTERRUPT_GEN( psx_vblank )
44{
45   psxgpu_device *gpu = downcast<psxgpu_device *>( device->machine().device("gpu") );
46   psx_state *p_psx = device->machine().driver_data<psx_state>();
47   
48   if(p_psx->b_need_sianniv_vblank_hack)
49   {
50      UINT32 pc = cpu_get_pc(device);
51      if((pc >= 0x80010018 && pc <= 0x80010028) || pc == 0x8002a4f0)
52         return;
53   }
54
55   gpu->vblank();
56}
57
5852/* IRQ */
5953
6054void psx_irq_set( running_machine &machine, UINT32 data )
r11801r11802
6256   psxcpu_device::irq_set( *machine.device("maincpu"), "maincpu", data );
6357}
6458
65/* DMA */
59/* SIO */
6660
67void psx_dma_install_read_handler( running_machine &machine, int n_channel, psx_dma_read_delegate p_fn_dma_read )
68{
69   downcast<psxdma_device *>( machine.device("maincpu")->subdevice("dma") )->install_read_handler( n_channel, p_fn_dma_read );
70}
71
72void psx_dma_install_write_handler( running_machine &machine, int n_channel, psx_dma_read_delegate p_fn_dma_write )
73{
74   downcast<psxdma_device *>( machine.device("maincpu")->subdevice("dma") )->install_write_handler( n_channel, p_fn_dma_write );
75}
76
7761void psx_sio_install_handler( running_machine &machine, int n_port, psx_sio_handler p_f_sio_handler )
7862{
7963   psxcpu_device::install_sio_handler( *machine.device("maincpu"), "maincpu", n_port, p_f_sio_handler );
r11801r11802
8468   psxcpu_device::sio_input( *machine.device("maincpu"), "maincpu", n_port, n_mask, n_data );
8569}
8670
87void psx_driver_init( running_machine &machine )
71/* GPU */
72
73PALETTE_INIT( psx )
8874{
89   psx_state *p_psx = machine.driver_data<psx_state>();
75   UINT32 n_colour;
9076
91   p_psx->b_need_sianniv_vblank_hack = !strcmp(machine.system().name, "sianniv");
92
93   p_psx->m_p_n_psxram = (UINT32 *)memory_get_shared(machine, "share1", p_psx->m_n_psxramsize);
77   for( n_colour = 0; n_colour < 0x10000; n_colour++ )
78   {
79      palette_set_color_rgb( machine, n_colour, pal5bit(n_colour >> 0), pal5bit(n_colour >> 5), pal5bit(n_colour >> 10) );
80   }
9481}
9582
9683SCREEN_UPDATE( psx )
r11801r11802
117104   psxgpu_device *gpu = downcast<psxgpu_device *>( machine.device("gpu") );
118105   gpu->lightgun_set( n_x, n_y );
119106}
107
108INTERRUPT_GEN( psx_vblank )
109{
110   psxgpu_device *gpu = downcast<psxgpu_device *>( device->machine().device("gpu") );
111   psx_state *p_psx = device->machine().driver_data<psx_state>();
112   
113   if(p_psx->b_need_sianniv_vblank_hack)
114   {
115      UINT32 pc = cpu_get_pc(device);
116      if((pc >= 0x80010018 && pc <= 0x80010028) || pc == 0x8002a4f0)
117         return;
118   }
119
120   gpu->vblank();
121}
122
src/mame/includes/psx.h
r11801r11802
2424};
2525
2626
27/*----------- defined in machine/psx.c -----------*/
27extern void psx_driver_init( running_machine &machine );
28WRITE32_HANDLER( psx_com_delay_w );
29READ32_HANDLER( psx_com_delay_r );
30extern void psx_irq_set( running_machine &, UINT32 );
31extern void psx_sio_install_handler( running_machine &, int, psx_sio_handler );
32extern void psx_sio_input( running_machine &, int, int, int );
2833
2934PALETTE_INIT( psx );
30VIDEO_START( psx_type1 );
31VIDEO_START( psx_type2 );
3235SCREEN_UPDATE( psx );
33INTERRUPT_GEN( psx_vblank );
34extern void psx_gpu_reset( running_machine &machine );
3536READ32_HANDLER( psx_gpu_r );
3637WRITE32_HANDLER( psx_gpu_w );
38INTERRUPT_GEN( psx_vblank );
3739extern void psx_lightgun_set( running_machine &, int, int );
3840
39WRITE32_HANDLER( psx_com_delay_w );
40READ32_HANDLER( psx_com_delay_r );
41extern void psx_irq_set( running_machine &, UINT32 );
42extern void psx_dma_install_read_handler( running_machine &, int, psx_dma_read_delegate );
43extern void psx_dma_install_write_handler( running_machine &, int, psx_dma_read_delegate );
44WRITE32_HANDLER( psx_counter_w );
45READ32_HANDLER( psx_counter_r );
46extern void psx_sio_install_handler( running_machine &, int, psx_sio_handler );
47extern void psx_sio_input( running_machine &, int, int, int );
48
49extern void psx_driver_init( running_machine &machine );
50
5141#define PSX_H ( 1 )
5242#endif
src/emu/video/psx.c
r11801r11802
9999   }
100100}
101101
102PALETTE_INIT( psx )
103{
104   UINT32 n_colour;
105
106   for( n_colour = 0; n_colour < 0x10000; n_colour++ )
107   {
108      palette_set_color_rgb( machine, n_colour, pal5bit(n_colour >> 0), pal5bit(n_colour >> 5), pal5bit(n_colour >> 10) );
109   }
110}
111
112102#if defined( MAME_DEBUG )
113103
114104void psxgpu_device::DebugMeshInit( void )
src/emu/sound/spu.c
r11801r11802
10421042   dirty_flags = -1;
10431043   changed_xa_vol = 0;
10441044
1045   installed_dma_hooks = false;
1046
10471045   xa_cnt=0;
10481046   xa_freq=0;
10491047   xa_channels=2;
r11801r11802
30903088
30913089// MAME I/O stuff.  This can get cleaner when machine/psx.c does.
30923090
3093static void spu_dma_read( spu_device *spu, UINT32 n_address, INT32 n_size )
3091void spu_device::dma_read( UINT32 n_address, INT32 n_size )
30943092{
3095   UINT8 *psxram = (UINT8 *)memory_get_shared(spu->machine(), "share1");
3093   UINT8 *psxram = (UINT8 *)memory_get_shared(machine(), "share1");
30963094
3097   spu->start_dma(psxram + n_address, false, n_size*4);
3095   start_dma(psxram + n_address, false, n_size*4);
30983096}
30993097
3100static void spu_dma_write( spu_device *spu, UINT32 n_address, INT32 n_size )
3098void spu_device::dma_write( UINT32 n_address, INT32 n_size )
31013099{
3102   UINT8 *psxram = (UINT8 *)memory_get_shared(spu->machine(), "share1");
3100   UINT8 *psxram = (UINT8 *)memory_get_shared(machine(), "share1");
31033101
31043102//  printf("SPU DMA write from %x, size %x\n", n_address, n_size);
31053103
3106   spu->start_dma(psxram + n_address, true, n_size*4);
3104   start_dma(psxram + n_address, true, n_size*4);
31073105}
31083106
31093107READ16_HANDLER( spu_r )
r11801r11802
31153113      return 0;
31163114   }
31173115
3118   if (!spu->installed_dma_hooks)
3119   {
3120      psx_dma_install_read_handler( space->machine(), 4, psx_dma_read_delegate( FUNC( spu_dma_read ), spu ) );
3121      psx_dma_install_write_handler( space->machine(), 4, psx_dma_write_delegate( FUNC( spu_dma_write ), spu ) );
3122      spu->installed_dma_hooks = true;
3123   }
3124
31253116   return spu->read_word(offset*2);
31263117}
31273118
r11801r11802
31343125      return;
31353126   }
31363127
3137   if (!spu->installed_dma_hooks)
3138   {
3139      psx_dma_install_read_handler( space->machine(), 4, psx_dma_read_delegate( FUNC( spu_dma_read ), spu ) );
3140      psx_dma_install_write_handler( space->machine(), 4, psx_dma_write_delegate( FUNC( spu_dma_write ), spu ) );
3141      spu->installed_dma_hooks = true;
3142   }
3143
31443128   spu->write_word(offset*2, data);
31453129}
3146
src/emu/sound/spu.h
r11801r11802
1111
1212#define MCFG_SPU_ADD(_tag, _clock, _irqf) \
1313   MCFG_DEVICE_ADD(_tag, SPU, _clock) \
14   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 4, psx_dma_read_delegate( FUNC( spu_device::dma_read ), (spu_device *) device ) ) \
15   MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 4, psx_dma_write_delegate( FUNC( spu_device::dma_write ), (spu_device *) device ) ) \
1416   MCFG_IRQ_FUNC(_irqf)
1517
16#define MCFG_SPU_REPLACE(_tag, _clock, _irqf) \
17   MCFG_DEVICE_REPLACE(_tag, SPU, _clock) \
18   MCFG_IRQ_FUNC(_irqf)
19
2018#define MCFG_IRQ_FUNC(_irqf) \
2119   spu_device::static_set_irqf(*device, _irqf); \
2220
r11801r11802
222220   // inline configuration helpers
223221   static void static_set_irqf(device_t &device, void (*irqf)(device_t *device, UINT32 state));
224222
223   void dma_read( UINT32 n_address, INT32 n_size );
224   void dma_write( UINT32 n_address, INT32 n_size );
225
225226   void reinit_sound();
226227   void kill_sound();
227228
r11801r11802
238239   void write_byte(const unsigned int addr, const unsigned char byte);
239240   void write_word(const unsigned int addr, const unsigned short word);
240241
241   bool installed_dma_hooks;
242242   sound_stream *m_stream;
243243};
244244

Previous 15994 Revisions Next


© 1998-2018 The MESS Team