Previous 199869 Revisions Next

r17592 Sunday 2nd September, 2012 at 12:33:21 UTC by Ville Linde
cobra.c: Added DMA sound streaming.
[src/mame/drivers]cobra.c

trunk/src/mame/drivers/cobra.c
r17591r17592
207207
208208        0x400f4:        xxx----- -------- -------- --------            Texture select (0-3)
209209
210                  xxx----- -------- -------- --------            ?
211
212210        0x40114:        -------- ----x--- -------- --------             Scissor enable
213211
214212        0x40138:        Set to 0x88800000 (0xe0) by mode_viewclip()
r17591r17592
324322#include "video/polynew.h"
325323#include "video/rgbgen.h"
326324#include "sound/rf5c400.h"
325#include "sound/dmadac.h"
327326
328327#define GFXFIFO_IN_VERBOSE         0
329328#define GFXFIFO_OUT_VERBOSE         0
r17591r17592
337336
338337#define ENABLE_BILINEAR            1
339338
339#define DMA_SOUND_BUFFER_SIZE      16000
340340
341
341342/* Cobra Renderer class */
342343
343344struct cobra_polydata
r17591r17592
708709
709710   bool m_has_psac;
710711
712   INT16 *m_sound_dma_buffer_l;
713   INT16 *m_sound_dma_buffer_r;
714   UINT32 m_sound_dma_ptr;
715
716   dmadac_sound_device *m_dmadac[2];
717
711718   DECLARE_DRIVER_INIT(racjamdx);
712719   DECLARE_DRIVER_INIT(bujutsu);
713720   DECLARE_DRIVER_INIT(cobra);
r17591r17592
16161623// Interrupts:
16171624
16181625// Serial Transmit      JVS
1619// DMA0:                Sound-related (TMS57002?)
1626// DMA0:                DMA-driven DAC
16201627// DMA2:                SCSI?
16211628// DMA3:                JVS
16221629// External IRQ0        M2SFIFO
r17591r17592
19131920
19141921}
19151922
1916static UINT32 sub_unknown_dma_r(device_t *device, int width)
1923static void sub_sound_dma_w(device_t *device, int width, UINT32 data)
19171924{
1918   //printf("DMA read from unknown: size %d\n", width);
1919   return 0;
1920}
1925   //printf("DMA write to unknown: size %d, data %08X\n", width, data);
19211926
1922static void sub_unknown_dma_w(device_t *device, int width, UINT32 data)
1923{
1924   //printf("DMA write to unknown: size %d, data %08X\n", width, data);
1927   /*
1928   static FILE *out;
1929   if (out == NULL)
1930      out = fopen("sound.bin", "wb");
1931
1932   fputc((data >> 24) & 0xff, out);
1933   fputc((data >> 16) & 0xff, out);
1934   fputc((data >> 8) & 0xff, out);
1935   fputc((data >> 0) & 0xff, out);
1936   */
1937
1938   cobra_state *cobra = device->machine().driver_data<cobra_state>();
1939
1940   INT16 ldata = (INT16)(data >> 16);
1941   INT16 rdata = (INT16)(data);
1942
1943   cobra->m_sound_dma_buffer_l[cobra->m_sound_dma_ptr] = ldata;
1944   cobra->m_sound_dma_buffer_r[cobra->m_sound_dma_ptr] = rdata;
1945   cobra->m_sound_dma_ptr++;
1946
1947   if (cobra->m_sound_dma_ptr >= DMA_SOUND_BUFFER_SIZE)
1948   {
1949      cobra->m_sound_dma_ptr = 0;
1950     
1951      dmadac_transfer(&cobra->m_dmadac[0], 1, 0, 1, DMA_SOUND_BUFFER_SIZE, cobra->m_sound_dma_buffer_l);
1952      dmadac_transfer(&cobra->m_dmadac[1], 1, 0, 1, DMA_SOUND_BUFFER_SIZE, cobra->m_sound_dma_buffer_r);
1953   }
19251954}
19261955
19271956static void sub_jvs_w(device_t *device, UINT8 data)
r17591r17592
31833212   ide_features[67*2+1] = 0x01;
31843213
31853214   cobra->m_renderer->gfx_reset(machine);
3215
3216   cobra->m_sound_dma_ptr = 0;
3217
3218   cobra->m_dmadac[0] = machine.device<dmadac_sound_device>("dac1");
3219   cobra->m_dmadac[1] = machine.device<dmadac_sound_device>("dac2");
3220   dmadac_enable(&cobra->m_dmadac[0], 1, 1);
3221   dmadac_enable(&cobra->m_dmadac[1], 1, 1);
3222   dmadac_set_frequency(&cobra->m_dmadac[0], 1, 44100);
3223   dmadac_set_frequency(&cobra->m_dmadac[1], 1, 44100);
31863224}
31873225
31883226static const ide_config ide_intf =
r17591r17592
32323270   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
32333271   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
32343272
3273   MCFG_SOUND_ADD("dac1", DMADAC, 0)
3274   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
3275
3276   MCFG_SOUND_ADD("dac2", DMADAC, 0)
3277   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
3278
32353279   MCFG_M48T58_ADD("m48t58")
32363280
32373281   MCFG_K001604_ADD("k001604", cobra_k001604_intf)      // on the LAN board in Racing Jam DX
r17591r17592
32843328
32853329   ppc_set_dcstore_callback(m_gfxcpu, gfx_cpu_dc_store);
32863330
3287
3288   ppc4xx_set_dma_read_handler(m_subcpu, 0, sub_unknown_dma_r);
3289   ppc4xx_set_dma_write_handler(m_subcpu, 0, sub_unknown_dma_w);
3331   ppc4xx_set_dma_write_handler(m_subcpu, 0, sub_sound_dma_w, 44100);
32903332   ppc4xx_spu_set_tx_handler(m_subcpu, sub_jvs_w);
32913333
32923334
r17591r17592
32953337
32963338   m_comram_page = 0;
32973339
3340   m_sound_dma_buffer_l = auto_alloc_array(machine(), INT16, DMA_SOUND_BUFFER_SIZE);
3341   m_sound_dma_buffer_r = auto_alloc_array(machine(), INT16, DMA_SOUND_BUFFER_SIZE);
32983342
32993343   // setup fake pagetable until we figure out what really maps there...
33003344   //m_gfx_pagetable[0x80 / 8] = U64(0x800001001e0001a8);
r17591r17592
34903534   ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00)
34913535   ROM_LOAD( "m48t58-70pc1.17l", 0x000000, 0x002000, NO_DUMP )
34923536
3537   ROM_REGION(0x1000000, "rfsnd", ROMREGION_ERASE00)
3538
34933539   DISK_REGION( "drive_0" )
34943540   DISK_IMAGE_READONLY( "645c04", 0, SHA1(c0aabe69f6eb4e4cf748d606ae50674297af6a04) )
34953541ROM_END
r17591r17592
35073553   ROM_REGION(0x2000, "m48t58", ROMREGION_ERASE00)
35083554   ROM_LOAD( "m48t58-70pc1.17l", 0x000000, 0x002000, NO_DUMP )
35093555
3556   ROM_REGION(0x1000000, "rfsnd", ROMREGION_ERASE00)
3557
35103558   DISK_REGION( "drive_0" )
35113559   DISK_IMAGE_READONLY( "676a04", 0, SHA1(8e89d3e5099e871b99fccba13adaa3cf8a6b71f0) )
35123560ROM_END

Previous 199869 Revisions Next


© 1997-2024 The MAME Team