Previous 199869 Revisions Next

r32938 Saturday 25th October, 2014 at 06:31:27 UTC by Osso
ppc: converted remaining callbacks to delegates (nw)
[src/emu/cpu/powerpc]ppc.h ppccom.c
[src/mame/drivers]cobra.c firebeat.c hornet.c

trunk/src/emu/cpu/powerpc/ppc.h
r241449r241450
159159#define PPCDRC_COMPATIBLE_OPTIONS   (PPCDRC_STRICT_VERIFY | PPCDRC_FLUSH_PC | PPCDRC_ACCURATE_SINGLES)
160160#define PPCDRC_FASTEST_OPTIONS      (0)
161161
162
163
164/***************************************************************************
165    STRUCTURES AND TYPEDEFS
166***************************************************************************/
167
168typedef void (*ppc4xx_spu_tx_handler)(device_t *device, UINT8 data);
169
170
171typedef void (*ppc_dcstore_handler)(device_t *device, UINT32 address);
172typedef UINT32 (*ppc4xx_dma_read_handler)(device_t *device, int width);
173typedef void (*ppc4xx_dma_write_handler)(device_t *device, int width, UINT32 data);
174
175
176/***************************************************************************
177    PUBLIC FUNCTIONS
178***************************************************************************/
179
162 
163 
164/***************************************************************************
165    PUBLIC FUNCTIONS
166***************************************************************************/
167 
180168#define MCFG_PPC_BUS_FREQUENCY(_frequency) \
181169   ppc_device::set_bus_frequency(*device, _frequency);
182170
r241449r241450
225213public:
226214   // construction/destruction
227215   ppc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, int address_bits, int data_bits, powerpc_flavor flavor, UINT32 cap, UINT32 tb_divisor, address_map_constructor internal_map);
216 
217   static void set_bus_frequency(device_t &device, UINT32 bus_frequency) { downcast<ppc_device &>(device).c_bus_frequency = bus_frequency; }
218 
219   void ppc_set_dcstore_callback(write32_delegate callback);
220   
221   void ppcdrc_set_options(UINT32 options);
222   void ppcdrc_add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base);
223   void ppcdrc_add_hotspot(offs_t pc, UINT32 opcode, UINT32 cycles);
228224
229   static void set_bus_frequency(device_t &device, UINT32 bus_frequency) { downcast<ppc_device &>(device).c_bus_frequency = bus_frequency; }
230
231   void ppc_set_dcstore_callback(ppc_dcstore_handler handler);
232
233   void ppcdrc_set_options(UINT32 options);
234   void ppcdrc_add_fastram(offs_t start, offs_t end, UINT8 readonly, void *base);
235   void ppcdrc_add_hotspot(offs_t pc, UINT32 opcode, UINT32 cycles);
236
237225   TIMER_CALLBACK_MEMBER(decrementer_int_callback);
238226   TIMER_CALLBACK_MEMBER(ppc4xx_buffered_dma_callback);
239227   TIMER_CALLBACK_MEMBER(ppc4xx_fit_callback);
r241449r241450
491479      UINT8           regs[9];
492480      UINT8           txbuf;
493481      UINT8           rxbuf;
494      emu_timer *     timer;
495      UINT8           rxbuffer[256];
496      UINT32          rxin, rxout;
497      ppc4xx_spu_tx_handler tx_handler;
498   };
499
500   ppc4xx_spu_state m_spu;
482      emu_timer *     timer;
483      UINT8           rxbuffer[256];
484      UINT32          rxin, rxout;
485      write8_delegate tx_cb;
486   };
487 
488   ppc4xx_spu_state m_spu;
501489   emu_timer *     m_fit_timer;
502490   emu_timer *     m_pit_timer;
503491   emu_timer *     m_wdog_timer;
r241449r241450
515503   UINT64          m_dec_zero_cycles;
516504   emu_timer *     m_decrementer_int_timer;
517505
518   read32_delegate  m_dcr_read_func;
519   write32_delegate m_dcr_write_func;
520
521   ppc_dcstore_handler m_dcstore_handler;
522
523   ppc4xx_dma_read_handler m_ext_dma_read_handler[4];
524   ppc4xx_dma_write_handler m_ext_dma_write_handler[4];
525
526   /* PowerPC function pointers for memory accesses/exceptions */
527   jmp_buf m_exception_jmpbuf;
506   read32_delegate  m_dcr_read_func;
507   write32_delegate m_dcr_write_func;
508 
509   write32_delegate m_dcstore_cb;
510 
511   read32_delegate m_ext_dma_read_cb[4];
512   write32_delegate m_ext_dma_write_cb[4];
513 
514   /* PowerPC function pointers for memory accesses/exceptions */
515   jmp_buf m_exception_jmpbuf;
528516   UINT8 (*m_ppcread8)(address_space &space, offs_t address);
529517   UINT16 (*m_ppcread16)(address_space &space, offs_t address);
530518   UINT32 (*m_ppcread32)(address_space &space, offs_t address);
r241449r241450
763751
764752class ppc4xx_device : public ppc_device
765753{
766public:
767   ppc4xx_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, powerpc_flavor flavor, UINT32 cap, UINT32 tb_divisor);
768
769   void ppc4xx_spu_set_tx_handler(ppc4xx_spu_tx_handler handler);
770   void ppc4xx_spu_receive_byte(UINT8 byteval);
771
772   void ppc4xx_set_dma_read_handler(int channel, ppc4xx_dma_read_handler handler, int rate);
773   void ppc4xx_set_dma_write_handler(int channel, ppc4xx_dma_write_handler handler, int rate);
774   void ppc4xx_set_dcr_read_handler(read32_delegate dcr_read_func);
775   void ppc4xx_set_dcr_write_handler(write32_delegate dcr_write_func);
776
754public:
755   ppc4xx_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, powerpc_flavor flavor, UINT32 cap, UINT32 tb_divisor);
756 
757   void ppc4xx_spu_set_tx_handler(write8_delegate callback);
758   void ppc4xx_spu_receive_byte(UINT8 byteval);
759 
760   void ppc4xx_set_dma_read_handler(int channel, read32_delegate callback, int rate);
761   void ppc4xx_set_dma_write_handler(int channel, write32_delegate callback, int rate);
762   void ppc4xx_set_dcr_read_handler(read32_delegate dcr_read_func);
763   void ppc4xx_set_dcr_write_handler(write32_delegate dcr_write_func);
764 
777765   DECLARE_READ8_MEMBER( ppc4xx_spu_r );
778766   DECLARE_WRITE8_MEMBER( ppc4xx_spu_w );
779767
trunk/src/emu/cpu/powerpc/ppccom.c
r241449r241450
214214   , m_core(NULL)
215215   , m_bus_freq_multiplier(1)
216216   , m_vtlb(NULL)
217   , m_flavor(flavor)
218   , m_cap(cap)
219   , m_tb_divisor(tb_divisor)
220   , m_dcstore_handler(NULL)
221   , m_cache(CACHE_SIZE + sizeof(internal_ppc_state))
222   , m_drcuml(NULL)
223   , m_drcfe(NULL)
217   , m_flavor(flavor)
218   , m_cap(cap)
219   , m_tb_divisor(tb_divisor)
220   , m_cache(CACHE_SIZE + sizeof(internal_ppc_state))
221   , m_drcuml(NULL)
222   , m_drcfe(NULL)
224223   , m_drcoptions(0)
225{
226   m_program_config.m_logaddr_width = 32;
227   m_program_config.m_page_shift = POWERPC_MIN_PAGE_SHIFT;
228   memset(m_ext_dma_read_handler, 0, sizeof(m_ext_dma_read_handler));
229   memset(m_ext_dma_write_handler, 0, sizeof(m_ext_dma_write_handler));
230}
231
232//ppc403_device::ppc403_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
224{
225   m_program_config.m_logaddr_width = 32;
226   m_program_config.m_page_shift = POWERPC_MIN_PAGE_SHIFT;
227}
228 
229//ppc403_device::ppc403_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
233230//  : ppc_device(mconfig, PPC403, "PPC403", tag, owner, clock, "ppc403", 32?, 64?)
234231//{
235232//}
r241449r241450
12411238    ppccom_dcstore_callback - call the dcstore
12421239    callback if installed
12431240-------------------------------------------------*/
1241 
1242void ppc_device::ppccom_dcstore_callback()
1243{
1244   if (!m_dcstore_cb.isnull())
1245   {
1246      m_dcstore_cb(*m_program, m_core->param0, 0, 0xffffffff);
1247   }
1248}
1249 
12441250
1245void ppc_device::ppccom_dcstore_callback()
1246{
1247   if (m_dcstore_handler != NULL)
1248   {
1249      m_dcstore_handler(this, m_core->param0);
1250   }
1251}
1252
1253
12541251/***************************************************************************
12551252    TLB HANDLING
12561253***************************************************************************/
r241449r241450
20612058
20622059/*-------------------------------------------------
20632060    ppc_set_dcstore_callback - installs a callback
2064    for detecting datacache stores with dcbst
2065-------------------------------------------------*/
2066
2067void ppc_device::ppc_set_dcstore_callback(ppc_dcstore_handler handler)
2068{
2069   m_dcstore_handler = handler;
2070}
2071
2072
2061    for detecting datacache stores with dcbst
2062-------------------------------------------------*/
2063 
2064void ppc_device::ppc_set_dcstore_callback(write32_delegate callback)
2065{
2066   m_dcstore_cb = callback;
2067}
2068 
2069 
20732070void ppc_device::execute_set_input(int inputnum, int state)
20742071{
20752072   switch (inputnum)
r241449r241450
22882285      {
22892286         /* byte transfer */
22902287         case 1:
2291         do
2292         {
2293            UINT8 data = 0;
2294            if (m_ext_dma_read_handler[dmachan] != NULL)
2295               data = (*m_ext_dma_read_handler[dmachan])(this, 1);
2296            m_program->write_byte(dmaregs[DCR4XX_DMADA0], data);
2297            dmaregs[DCR4XX_DMADA0] += destinc;
2298         } while (!ppc4xx_dma_decrement_count(dmachan));
2288         do
2289         {
2290            UINT8 data = 0;
2291            if (!m_ext_dma_read_cb[dmachan].isnull())
2292               data = (m_ext_dma_read_cb[dmachan])(*m_program, 1, 0xffffffff);
2293            m_program->write_byte(dmaregs[DCR4XX_DMADA0], data);
2294            dmaregs[DCR4XX_DMADA0] += destinc;
2295         } while (!ppc4xx_dma_decrement_count(dmachan));
22992296         break;
23002297
23012298         /* word transfer */
23022299         case 2:
2303         do
2304         {
2305            UINT16 data = 0;
2306            if (m_ext_dma_read_handler[dmachan] != NULL)
2307               data = (*m_ext_dma_read_handler[dmachan])(this, 2);
2308            m_program->write_word(dmaregs[DCR4XX_DMADA0], data);
2309            dmaregs[DCR4XX_DMADA0] += destinc;
2310         } while (!ppc4xx_dma_decrement_count(dmachan));
2300         do
2301         {
2302            UINT16 data = 0;
2303            if (!m_ext_dma_read_cb[dmachan].isnull())
2304               data = (m_ext_dma_read_cb[dmachan])(*m_program, 2, 0xffffffff);
2305            m_program->write_word(dmaregs[DCR4XX_DMADA0], data);
2306            dmaregs[DCR4XX_DMADA0] += destinc;
2307         } while (!ppc4xx_dma_decrement_count(dmachan));
23112308         break;
23122309
23132310         /* dword transfer */
23142311         case 4:
2315         do
2316         {
2317            UINT32 data = 0;
2318            if (m_ext_dma_read_handler[dmachan] != NULL)
2319               data = (*m_ext_dma_read_handler[dmachan])(this, 4);
2320            m_program->write_dword(dmaregs[DCR4XX_DMADA0], data);
2321            dmaregs[DCR4XX_DMADA0] += destinc;
2322         } while (!ppc4xx_dma_decrement_count(dmachan));
2312         do
2313         {
2314            UINT32 data = 0;
2315            if (!m_ext_dma_read_cb[dmachan].isnull())
2316               data = (m_ext_dma_read_cb[dmachan])(*m_program, 4, 0xffffffff);
2317            m_program->write_dword(dmaregs[DCR4XX_DMADA0], data);
2318            dmaregs[DCR4XX_DMADA0] += destinc;
2319         } while (!ppc4xx_dma_decrement_count(dmachan));
23232320         break;
23242321      }
23252322   }
r241449r241450
23322329      {
23332330         /* byte transfer */
23342331         case 1:
2335         do
2336         {
2337            UINT8 data = m_program->read_byte(dmaregs[DCR4XX_DMADA0]);
2338            if (m_ext_dma_write_handler[dmachan] != NULL)
2339               (*m_ext_dma_write_handler[dmachan])(this, 1, data);
2340            dmaregs[DCR4XX_DMADA0] += destinc;
2341         } while (!ppc4xx_dma_decrement_count(dmachan));
2342         break;
2332         do
2333         {
2334            UINT8 data = m_program->read_byte(dmaregs[DCR4XX_DMADA0]);
2335            if (!m_ext_dma_write_cb[dmachan].isnull())
2336               (m_ext_dma_write_cb[dmachan])(*m_program, 1, data, 0xffffffff);
2337            dmaregs[DCR4XX_DMADA0] += destinc;
2338         } while (!ppc4xx_dma_decrement_count(dmachan));
2339         break;
23432340
23442341         /* word transfer */
23452342         case 2:
2346         do
2347         {
2348            UINT16 data = m_program->read_word(dmaregs[DCR4XX_DMADA0]);
2349            if (m_ext_dma_write_handler[dmachan] != NULL)
2350               (*m_ext_dma_write_handler[dmachan])(this, 2, data);
2351            dmaregs[DCR4XX_DMADA0] += destinc;
2352         } while (!ppc4xx_dma_decrement_count(dmachan));
2353         break;
2343         do
2344         {
2345            UINT16 data = m_program->read_word(dmaregs[DCR4XX_DMADA0]);
2346            if (!m_ext_dma_write_cb[dmachan].isnull())
2347               (m_ext_dma_write_cb[dmachan])(*m_program, 2, data, 0xffffffff);
2348            dmaregs[DCR4XX_DMADA0] += destinc;
2349         } while (!ppc4xx_dma_decrement_count(dmachan));
2350         break;
23542351
23552352         /* dword transfer */
23562353         case 4:
2357         do
2358         {
2359            UINT32 data = m_program->read_dword(dmaregs[DCR4XX_DMADA0]);
2360            if (m_ext_dma_write_handler[dmachan] != NULL)
2361               (*m_ext_dma_write_handler[dmachan])(this, 4, data);
2362            dmaregs[DCR4XX_DMADA0] += destinc;
2363         } while (!ppc4xx_dma_decrement_count(dmachan));
2364         break;
2354         do
2355         {
2356            UINT32 data = m_program->read_dword(dmaregs[DCR4XX_DMADA0]);
2357            if (!m_ext_dma_write_cb[dmachan].isnull())
2358               (m_ext_dma_write_cb[dmachan])(*m_program, 4, data, 0xffffffff);
2359            dmaregs[DCR4XX_DMADA0] += destinc;
2360         } while (!ppc4xx_dma_decrement_count(dmachan));
2361         break;
23652362      }
23662363   }
23672364}
r241449r241450
26772674      int operation = (m_spu.regs[SPU4XX_TX_COMMAND] >> 5) & 3;
26782675
26792676      /* if we have data to transmit, do it now */
2680      if (!(m_spu.regs[SPU4XX_LINE_STATUS] & 0x04))
2681      {
2682         /* if we have a transmit handler, send it that way */
2683         if (m_spu.tx_handler != NULL)
2684            (*m_spu.tx_handler)(this, m_spu.txbuf);
2685
2686         /* indicate that we have moved it to the shift register */
2687         m_spu.regs[SPU4XX_LINE_STATUS] |= 0x04;
2677      if (!(m_spu.regs[SPU4XX_LINE_STATUS] & 0x04))
2678      {
2679         /* if we have a transmit handler, send it that way */
2680         if (!m_spu.tx_cb.isnull())
2681            (m_spu.tx_cb)(*m_program, 0, m_spu.txbuf, 0xff);
2682 
2683         /* indicate that we have moved it to the shift register */
2684         m_spu.regs[SPU4XX_LINE_STATUS] |= 0x04;
26882685         m_spu.regs[SPU4XX_LINE_STATUS] &= ~0x02;
26892686      }
26902687
r241449r241450
28232820
28242821/*-------------------------------------------------
28252822    ppc4xx_spu_set_tx_handler - PowerPC 4XX-
2826    specific TX handler configuration
2827-------------------------------------------------*/
2828
2829void ppc4xx_device::ppc4xx_spu_set_tx_handler(ppc4xx_spu_tx_handler handler)
2830{
2831   m_spu.tx_handler = handler;
2832}
2833
2834
2823    specific TX handler configuration
2824-------------------------------------------------*/
2825 
2826void ppc4xx_device::ppc4xx_spu_set_tx_handler(write8_delegate callback)
2827{
2828   m_spu.tx_cb = callback;
2829}
2830 
2831 
28352832/*-------------------------------------------------
28362833    ppc4xx_spu_receive_byte - PowerPC 4XX-
28372834    specific serial byte receive
r241449r241450
28442841
28452842/*-------------------------------------------------
28462843    ppc4xx_set_dma_read_handler - PowerPC 4XX-
2847    specific external DMA read handler configuration
2848-------------------------------------------------*/
2849
2850void ppc4xx_device::ppc4xx_set_dma_read_handler(int channel, ppc4xx_dma_read_handler handler, int rate)
2851{
2852   m_ext_dma_read_handler[channel] = handler;
2853   m_buffered_dma_rate[channel] = rate;
2854}
2855
2844    specific external DMA read handler configuration
2845-------------------------------------------------*/
2846 
2847void ppc4xx_device::ppc4xx_set_dma_read_handler(int channel, read32_delegate callback, int rate)
2848{
2849   m_ext_dma_read_cb[channel] = callback;
2850   m_buffered_dma_rate[channel] = rate;
2851}
2852 
28562853/*-------------------------------------------------
28572854    ppc4xx_set_dma_write_handler - PowerPC 4XX-
2858    specific external DMA write handler configuration
2859-------------------------------------------------*/
2860
2861void ppc4xx_device::ppc4xx_set_dma_write_handler(int channel, ppc4xx_dma_write_handler handler, int rate)
2862{
2863   m_ext_dma_write_handler[channel] = handler;
2864   m_buffered_dma_rate[channel] = rate;
2865}
2866
2855    specific external DMA write handler configuration
2856-------------------------------------------------*/
2857 
2858void ppc4xx_device::ppc4xx_set_dma_write_handler(int channel, write32_delegate callback, int rate)
2859{
2860   m_ext_dma_write_cb[channel] = callback;
2861   m_buffered_dma_rate[channel] = rate;
2862}
2863 
28672864/*-------------------------------------------------
28682865    ppc4xx_set_dcr_read_handler
28692866-------------------------------------------------*/
trunk/src/mame/drivers/cobra.c
r241449r241450
630630   DECLARE_READ64_MEMBER(main_comram_r);
631631   DECLARE_WRITE64_MEMBER(main_comram_w);
632632   DECLARE_READ64_MEMBER(main_fifo_r);
633   DECLARE_WRITE64_MEMBER(main_fifo_w);
634   DECLARE_READ64_MEMBER(main_mpc106_r);
635   DECLARE_WRITE64_MEMBER(main_mpc106_w);
636
637   DECLARE_READ32_MEMBER(sub_comram_r);
638   DECLARE_WRITE32_MEMBER(sub_comram_w);
639   DECLARE_READ32_MEMBER(sub_sound_r);
633   DECLARE_WRITE64_MEMBER(main_fifo_w);
634   DECLARE_READ64_MEMBER(main_mpc106_r);
635   DECLARE_WRITE64_MEMBER(main_mpc106_w);
636   DECLARE_WRITE32_MEMBER(main_cpu_dc_store);
637   
638   DECLARE_READ32_MEMBER(sub_comram_r);
639   DECLARE_WRITE32_MEMBER(sub_comram_w);
640   DECLARE_READ32_MEMBER(sub_sound_r);
640641   DECLARE_WRITE32_MEMBER(sub_sound_w);
641642   DECLARE_READ32_MEMBER(sub_unk7e_r);
642643   DECLARE_WRITE32_MEMBER(sub_debug_w);
r241449r241450
650651   DECLARE_WRITE16_MEMBER(sub_ata0_w);
651652   DECLARE_READ16_MEMBER(sub_ata1_r);
652653   DECLARE_WRITE16_MEMBER(sub_ata1_w);
653   DECLARE_READ32_MEMBER(sub_psac2_r);
654   DECLARE_WRITE32_MEMBER(sub_psac2_w);
655   DECLARE_WRITE32_MEMBER(sub_psac_palette_w);
656
657   DECLARE_WRITE64_MEMBER(gfx_fifo0_w);
658   DECLARE_WRITE64_MEMBER(gfx_fifo1_w);
654   DECLARE_READ32_MEMBER(sub_psac2_r);
655   DECLARE_WRITE32_MEMBER(sub_psac2_w);
656   DECLARE_WRITE32_MEMBER(sub_psac_palette_w);
657   DECLARE_WRITE32_MEMBER(sub_sound_dma_w);
658 
659   DECLARE_WRITE64_MEMBER(gfx_fifo0_w);
660   DECLARE_WRITE64_MEMBER(gfx_fifo1_w);
659661   DECLARE_WRITE64_MEMBER(gfx_fifo2_w);
660662   DECLARE_WRITE64_MEMBER(gfx_debug_state_w);
661663   DECLARE_READ64_MEMBER(gfx_unk1_r);
662   DECLARE_WRITE64_MEMBER(gfx_unk1_w);
663   DECLARE_READ64_MEMBER(gfx_fifo_r);
664   DECLARE_WRITE64_MEMBER(gfx_buf_w);
665
666   DECLARE_WRITE_LINE_MEMBER(ide_interrupt);
667
664   DECLARE_WRITE64_MEMBER(gfx_unk1_w);
665   DECLARE_READ64_MEMBER(gfx_fifo_r);
666   DECLARE_WRITE64_MEMBER(gfx_buf_w);
667   DECLARE_WRITE32_MEMBER(gfx_cpu_dc_store);
668   
669   DECLARE_WRITE8_MEMBER(sub_jvs_w);
670 
671   DECLARE_WRITE_LINE_MEMBER(ide_interrupt);
672 
668673   cobra_renderer *m_renderer;
669674
670675   cobra_fifo *m_gfxfifo_in;
r241449r241450
15961601   UINT32 m2 = (UINT32)(mem_mask);
15971602
15981603   m_comram[page][(offset << 1) + 0] = (w1 & ~m1) | (d1 & m1);
1599   m_comram[page][(offset << 1) + 1] = (w2 & ~m2) | (d2 & m2);
1600}
1601
1602static void main_cpu_dc_store(device_t *device, UINT32 address)
1603{
1604   cobra_state *cobra = device->machine().driver_data<cobra_state>();
1605
1606   if ((address & 0xf0000000) == 0xc0000000)
1607   {
1608      // force sync when writing to GFX board main ram
1609      cobra->m_maincpu->spin_until_time(attotime::from_usec(80));
1610   }
1611}
1612
1604   m_comram[page][(offset << 1) + 1] = (w2 & ~m2) | (d2 & m2);
1605}
1606 
1607WRITE32_MEMBER(cobra_state::main_cpu_dc_store)
1608{
1609   if ((offset & 0xf0000000) == 0xc0000000)
1610   {
1611      // force sync when writing to GFX board main ram
1612      m_maincpu->spin_until_time(attotime::from_usec(80));
1613   }
1614}
1615 
16131616static ADDRESS_MAP_START( cobra_main_map, AS_PROGRAM, 64, cobra_state )
16141617   AM_RANGE(0x00000000, 0x003fffff) AM_RAM
16151618   AM_RANGE(0x07c00000, 0x07ffffff) AM_RAM
r241449r241450
18851888}
18861889
18871890WRITE32_MEMBER(cobra_state::sub_psac2_w)
1888{
1889}
1890
1891static void sub_sound_dma_w(device_t *device, int width, UINT32 data)
1892{
1893   //printf("DMA write to unknown: size %d, data %08X\n", width, data);
1894
1895   /*
1896   static FILE *out;
1891{
1892}
1893 
1894WRITE32_MEMBER(cobra_state::sub_sound_dma_w)
1895{
1896   //printf("DMA write to unknown: size %d, data %08X\n", address, data);
1897 
1898   /*
1899   static FILE *out;
18971900   if (out == NULL)
18981901       out = fopen("sound.bin", "wb");
18991902
19001903   fputc((data >> 24) & 0xff, out);
19011904   fputc((data >> 16) & 0xff, out);
19021905   fputc((data >> 8) & 0xff, out);
1903   fputc((data >> 0) & 0xff, out);
1904   */
1905
1906   cobra_state *cobra = device->machine().driver_data<cobra_state>();
1907
1908   INT16 ldata = (INT16)(data >> 16);
1909   INT16 rdata = (INT16)(data);
1910
1911   cobra->m_sound_dma_buffer_l[cobra->m_sound_dma_ptr] = ldata;
1912   cobra->m_sound_dma_buffer_r[cobra->m_sound_dma_ptr] = rdata;
1913   cobra->m_sound_dma_ptr++;
1914
1915   if (cobra->m_sound_dma_ptr >= DMA_SOUND_BUFFER_SIZE)
1916   {
1917      cobra->m_sound_dma_ptr = 0;
1918
1919      dmadac_transfer(&cobra->m_dmadac[0], 1, 0, 1, DMA_SOUND_BUFFER_SIZE, cobra->m_sound_dma_buffer_l);
1920      dmadac_transfer(&cobra->m_dmadac[1], 1, 0, 1, DMA_SOUND_BUFFER_SIZE, cobra->m_sound_dma_buffer_r);
1921   }
1922}
1923
1924static void sub_jvs_w(device_t *device, UINT8 data)
1925{
1926   cobra_state *cobra = device->machine().driver_data<cobra_state>();
1927   cobra_jvs_host *jvs = downcast<cobra_jvs_host *>(device->machine().device("cobra_jvs_host"));
1928
1929#if LOG_JVS
1930   printf("sub_jvs_w: %02X\n", data);
1906   fputc((data >> 0) & 0xff, out);
1907   */
1908 
1909   INT16 ldata = (INT16)(data >> 16);
1910   INT16 rdata = (INT16)(data);
1911 
1912   m_sound_dma_buffer_l[m_sound_dma_ptr] = ldata;
1913   m_sound_dma_buffer_r[m_sound_dma_ptr] = rdata;
1914   m_sound_dma_ptr++;
1915 
1916   if (m_sound_dma_ptr >= DMA_SOUND_BUFFER_SIZE)
1917   {
1918      m_sound_dma_ptr = 0;
1919 
1920      dmadac_transfer(&m_dmadac[0], 1, 0, 1, DMA_SOUND_BUFFER_SIZE, m_sound_dma_buffer_l);
1921      dmadac_transfer(&m_dmadac[1], 1, 0, 1, DMA_SOUND_BUFFER_SIZE, m_sound_dma_buffer_r);
1922   }
1923}
1924 
1925WRITE8_MEMBER(cobra_state::sub_jvs_w)
1926{
1927   cobra_jvs_host *jvs = machine().device<cobra_jvs_host>("cobra_jvs_host");
1928 
1929#if LOG_JVS
1930   printf("sub_jvs_w: %02X\n", data);
19311931#endif
19321932
19331933   const UINT8 *rec_data;
r241449r241450
19451945      }
19461946      printf("\n");
19471947#endif
1948 
1949      for (int i=0; i < rec_size; i++)
1950      {
1951         m_subcpu->ppc4xx_spu_receive_byte(rec_data[i]);
1952      }
1953   }
1954}
19481955
1949      for (int i=0; i < rec_size; i++)
1950      {
1951         cobra->m_subcpu->ppc4xx_spu_receive_byte(rec_data[i]);
1952      }
1953   }
1954}
1955
19561956static ADDRESS_MAP_START( cobra_sub_map, AS_PROGRAM, 32, cobra_state )
19571957   AM_RANGE(0x00000000, 0x003fffff) AM_MIRROR(0x80000000) AM_RAM                                           // Main RAM
19581958   AM_RANGE(0x70000000, 0x7003ffff) AM_MIRROR(0x80000000) AM_READWRITE(sub_comram_r, sub_comram_w)         // Double buffered shared RAM between Main and Sub
r241449r241450
29882988      // prc_read always expects a value...
29892989
29902990      m_gfxfifo_out->push(&space.device(), 0);
2991   }
2992}
2993
2994static void gfx_cpu_dc_store(device_t *device, UINT32 address)
2995{
2996   cobra_state *cobra = device->machine().driver_data<cobra_state>();
2997
2998   UINT32 addr = address >> 24;
2999   if (addr == 0x10 || addr == 0x18 || addr == 0x1e)
3000   {
3001      UINT64 i = (UINT64)(cobra->m_gfx_fifo_cache_addr) << 32;
3002      cobra_fifo *fifo_in = cobra->m_gfxfifo_in;
3003
3004      UINT32 a = (address / 8) & 0xff;
3005
3006      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+0] >> 32) | i);
3007      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+0] >>  0) | i);
3008      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+1] >> 32) | i);
3009      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+1] >>  0) | i);
3010      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+2] >> 32) | i);
3011      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+2] >>  0) | i);
3012      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+3] >> 32) | i);
3013      fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[a+3] >>  0) | i);
3014
3015      cobra->m_renderer->gfx_fifo_exec();
3016   }
3017   else
3018   {
3019      logerror("gfx: data cache store at %08X\n", address);
3020   }
3021}
3022
2991   }
2992}
2993 
2994WRITE32_MEMBER(cobra_state::gfx_cpu_dc_store)
2995{
2996   UINT32 addr = offset >> 24;
2997   if (addr == 0x10 || addr == 0x18 || addr == 0x1e)
2998   {
2999      UINT64 i = (UINT64)(m_gfx_fifo_cache_addr) << 32;
3000      cobra_fifo *fifo_in = m_gfxfifo_in;
3001 
3002      UINT32 a = (offset / 8) & 0xff;
3003 
3004      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+0] >> 32) | i);
3005      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+0] >>  0) | i);
3006      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+1] >> 32) | i);
3007      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+1] >>  0) | i);
3008      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+2] >> 32) | i);
3009      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+2] >>  0) | i);
3010      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+3] >> 32) | i);
3011      fifo_in->push(&space.device(), (UINT32)(m_gfx_fifo_mem[a+3] >>  0) | i);
3012 
3013      m_renderer->gfx_fifo_exec();
3014   }
3015   else
3016   {
3017      logerror("gfx: data cache store at %08X\n", offset);
3018   }
3019}
3020 
30233021WRITE64_MEMBER(cobra_state::gfx_debug_state_w)
30243022{
30253023   if (ACCESSING_BITS_40_47)
r241449r241450
32603258                        2048,
32613259                        "S2MFIFO",
32623260                        S2MFIFO_VERBOSE != 0,
3263                        cobra_fifo::event_delegate(FUNC(cobra_state::s2mfifo_event_callback), this))
3264                        );
3265
3266   m_maincpu->ppc_set_dcstore_callback(main_cpu_dc_store);
3267
3268   m_gfxcpu->ppc_set_dcstore_callback(gfx_cpu_dc_store);
3269
3270   m_subcpu->ppc4xx_set_dma_write_handler(0, sub_sound_dma_w, 44100);
3271   m_subcpu->ppc4xx_spu_set_tx_handler(sub_jvs_w);
3272
3273
3274   m_comram[0] = auto_alloc_array(machine(), UINT32, 0x40000/4);
3261                        cobra_fifo::event_delegate(FUNC(cobra_state::s2mfifo_event_callback), this))
3262                        );
3263 
3264   m_maincpu->ppc_set_dcstore_callback(write32_delegate(FUNC(cobra_state::main_cpu_dc_store),this));
3265 
3266   m_gfxcpu->ppc_set_dcstore_callback(write32_delegate(FUNC(cobra_state::gfx_cpu_dc_store), this));
3267 
3268   m_subcpu->ppc4xx_set_dma_write_handler(0, write32_delegate(FUNC(cobra_state::sub_sound_dma_w), this), 44100);
3269   m_subcpu->ppc4xx_spu_set_tx_handler(write8_delegate(FUNC(cobra_state::sub_jvs_w), this));
3270 
3271 
3272   m_comram[0] = auto_alloc_array(machine(), UINT32, 0x40000/4);
32753273   m_comram[1] = auto_alloc_array(machine(), UINT32, 0x40000/4);
32763274
32773275   m_comram_page = 0;
trunk/src/mame/drivers/firebeat.c
r241449r241450
256256   void gcu_exec_display_list(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 address);
257257   UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip);
258258   UINT32 GCU_r(int chip, UINT32 offset, UINT32 mem_mask);
259   void GCU_w(int chip, UINT32 offset, UINT32 data, UINT32 mem_mask);
260   void set_ibutton(UINT8 *data);
261   int ibutton_w(UINT8 data);
262   void init_lights(write32_delegate out1, write32_delegate out2, write32_delegate out3);
263   void init_firebeat();
264   void init_keyboard();
259   void GCU_w(int chip, UINT32 offset, UINT32 data, UINT32 mem_mask);
260   void set_ibutton(UINT8 *data);
261   int ibutton_w(UINT8 data);
262   DECLARE_WRITE8_MEMBER(security_w);
263   void init_lights(write32_delegate out1, write32_delegate out2, write32_delegate out3);
264   void init_firebeat();
265   void init_keyboard();
265266   DECLARE_WRITE_LINE_MEMBER(sound_irq_callback);
266267   DECLARE_WRITE_LINE_MEMBER(midi_uart_ch0_irq_callback);
267268   DECLARE_WRITE_LINE_MEMBER(midi_uart_ch1_irq_callback);
r241449r241450
19461947      }
19471948   }
19481949
1949   return r;
1950}
1950   return r;
1951}
1952 
1953WRITE8_MEMBER(firebeat_state::security_w)
1954{
1955   int r = ibutton_w(data);
1956   if (r >= 0)
1957      m_maincpu->ppc4xx_spu_receive_byte(r);
1958}
1959 
1960/*****************************************************************************/
19511961
1952static void security_w(device_t *device, UINT8 data)
1953{
1954   firebeat_state *state = device->machine().driver_data<firebeat_state>();
1955   int r = state->ibutton_w(data);
1956   if (r >= 0)
1957      state->m_maincpu->ppc4xx_spu_receive_byte(r);
1958}
1959
1960/*****************************************************************************/
1961
19621962void firebeat_state::init_lights(write32_delegate out1, write32_delegate out2, write32_delegate out3)
19631963{
19641964   if(out1.isnull()) out1 = write32_delegate(FUNC(firebeat_state::lamp_output_w),this);
r241449r241450
19791979
19801980   m_extend_board_irq_enable = 0x3f;
19811981   m_extend_board_irq_active = 0x00;
1982
1983   m_cur_cab_data = cab_data;
1984
1985   m_maincpu->ppc4xx_spu_set_tx_handler(security_w);
1986
1987   set_ibutton(rom);
1988
1982 
1983   m_cur_cab_data = cab_data;
1984 
1985   m_maincpu->ppc4xx_spu_set_tx_handler(write8_delegate(FUNC(firebeat_state::security_w), this));
1986 
1987   set_ibutton(rom);
1988 
19891989   init_lights(write32_delegate(), write32_delegate(), write32_delegate());
19901990}
19911991
trunk/src/mame/drivers/hornet.c
r241449r241450
402402   DECLARE_WRITE32_MEMBER(dsp_dataram1_w);
403403   DECLARE_WRITE_LINE_MEMBER(voodoo_vblank_0);
404404   DECLARE_WRITE_LINE_MEMBER(voodoo_vblank_1);
405   DECLARE_WRITE16_MEMBER(soundtimer_en_w);
406   DECLARE_WRITE16_MEMBER(soundtimer_count_w);
407   ADC12138_IPT_CONVERT_CB(adc12138_input_callback);
408
409   DECLARE_DRIVER_INIT(hornet);
410   DECLARE_DRIVER_INIT(hornet_2board);
405   DECLARE_WRITE16_MEMBER(soundtimer_en_w);
406   DECLARE_WRITE16_MEMBER(soundtimer_count_w);
407   ADC12138_IPT_CONVERT_CB(adc12138_input_callback);
408   DECLARE_WRITE8_MEMBER(jamma_jvs_w);
409 
410   DECLARE_DRIVER_INIT(hornet);
411   DECLARE_DRIVER_INIT(hornet_2board);
411412   virtual void machine_start();
412413   virtual void machine_reset();
413414   DECLARE_MACHINE_RESET(hornet_2board);
r241449r241450
11351136   MCFG_EEPROM_SERIAL_93C46_ADD("lan_eeprom")
11361137MACHINE_CONFIG_END
11371138
1138
1139/*****************************************************************************/
1140
1141static void jamma_jvs_w(device_t *device, UINT8 data)
1139 
1140/*****************************************************************************/
1141 
1142WRITE8_MEMBER(hornet_state::jamma_jvs_w)
1143{
1144   if (m_jvs_sdata_ptr == 0 && data != 0xe0)
1145      return;
1146   m_jvs_sdata[m_jvs_sdata_ptr] = data;
1147   m_jvs_sdata_ptr++;
1148 
1149   if (m_jvs_sdata_ptr >= 3 && m_jvs_sdata_ptr >= 3 + m_jvs_sdata[2])
1150      jamma_jvs_cmd_exec();
1151}
1152 
1153int hornet_state::jvs_encode_data(UINT8 *in, int length)
11421154{
1143   hornet_state *state = device->machine().driver_data<hornet_state>();
1144   if (state->m_jvs_sdata_ptr == 0 && data != 0xe0)
1145      return;
1146   state->m_jvs_sdata[state->m_jvs_sdata_ptr] = data;
1147   state->m_jvs_sdata_ptr++;
1148
1149   if (state->m_jvs_sdata_ptr >= 3 && state->m_jvs_sdata_ptr >= 3 + state->m_jvs_sdata[2])
1150      state->jamma_jvs_cmd_exec();
1151}
1152
1153int hornet_state::jvs_encode_data(UINT8 *in, int length)
1154{
11551155   int inptr = 0;
11561156   int sum = 0;
11571157
r241449r241450
12801280
12811281DRIVER_INIT_MEMBER(hornet_state,hornet)
12821282{
1283   m_konppc->set_cgboard_texture_bank(0, "bank5", memregion("user5")->base());
1284   m_led_reg0 = m_led_reg1 = 0x7f;
1285
1286   m_maincpu->ppc4xx_spu_set_tx_handler(jamma_jvs_w);
1287}
1288
1289DRIVER_INIT_MEMBER(hornet_state,hornet_2board)
1283   m_konppc->set_cgboard_texture_bank(0, "bank5", memregion("user5")->base());
1284   m_led_reg0 = m_led_reg1 = 0x7f;
1285 
1286   m_maincpu->ppc4xx_spu_set_tx_handler(write8_delegate(FUNC(hornet_state::jamma_jvs_w), this));
1287}
1288 
1289DRIVER_INIT_MEMBER(hornet_state,hornet_2board)
12901290{
12911291   m_konppc->set_cgboard_texture_bank(0, "bank5", memregion("user5")->base());
1292   m_konppc->set_cgboard_texture_bank(1, "bank6", memregion("user5")->base());
1293   m_led_reg0 = m_led_reg1 = 0x7f;
1292   m_konppc->set_cgboard_texture_bank(1, "bank6", memregion("user5")->base());
1293   m_led_reg0 = m_led_reg1 = 0x7f;
1294 
1295   m_maincpu->ppc4xx_spu_set_tx_handler(write8_delegate(FUNC(hornet_state::jamma_jvs_w), this));
1296}
1297 
1298/*****************************************************************************/
12941299
1295   m_maincpu->ppc4xx_spu_set_tx_handler(jamma_jvs_w);
1296}
1297
1298/*****************************************************************************/
1299
13001300ROM_START(sscope)
13011301   ROM_REGION32_BE(0x400000, "user1", 0)   /* PowerPC program */
13021302   ROM_LOAD16_WORD_SWAP("830d01.27p", 0x200000, 0x200000, CRC(de9b3dfa) SHA1(660652a5f745cb04687481c3626d8a43cd169193) )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team