Previous 15994 Revisions Next

r9225 Sunday 26th September, 2010 at 13:13:17 UTC by Angelo Salese
Give an option of how to handle the DMA timing... with or without the MAME timers (without is a lot faster..) [David Haywood]
[src/emu/cpu/sh2]sh2.c sh2comn.c sh2comn.h sh2drc.c

src/emu/cpu/sh2/sh2comn.h
r9224r9225
1414
1515#define USE_SH2DRC
1616
17// do we use a timer for the DMA, or have it in CPU_EXECUTE
18//#define USE_TIMER_FOR_DMA
19
1720#ifdef USE_SH2DRC
1821#include "cpu/drcfe.h"
1922#include "cpu/drcuml.h"
r9224r9225
184187void sh2_recalc_irq(sh2_state *sh2);
185188void sh2_set_irq_line(sh2_state *sh2, int irqline, int state);
186189void sh2_exception(sh2_state *sh2, const char *message, int irqline);
190void sh2_do_dma(sh2_state *sh2, int dma);
187191
188192#endif /* __SH2COMN_H__ */
src/emu/cpu/sh2/sh2drc.c
r9224r9225
884884   drcuml_state *drcuml = sh2->drcuml;
885885   int execute_result;
886886
887   // run any active DMAs now
888#ifndef USE_TIMER_FOR_DMA
889   for ( int i = 0; i < sh2->icount ; i++)
890   {
891      for( int dma=0;dma<1;dma++)
892      {
893         if (sh2->dma_timer_active[dma])
894            sh2_do_dma(sh2, dma);
895      }
896   }
897#endif
898
887899   /* reset the cache if dirty */
888900   if (sh2->cache_dirty)
889901      code_flush_cache(sh2);
src/emu/cpu/sh2/sh2comn.c
r9224r9225
134134}
135135
136136
137
138137/*
139138  We have to do DMA on a timer (or at least, in chunks) due to the way some systems use it.
140139  The 32x is a difficult case, they set the SOURCE of the DMA to a FIFO buffer, which at most
r9224r9225
142141  because the game is expecting the 68k of the system to feed data into the FIFO at the same
143142  time as the SH2 is transfering it out via DMA
144143
145  It might be possible to avoid the timer (which causes a performance hit) by calling this
146  from the CPU_EXECUTE loop instead when there is active DMA
144  There are two ways we can do this
145
146  a) with a high frequency timer (more accurate, but a large performance hit)
147
148  or
149 
150  b) in the CPU_EXECUTE loop
151
152
153  we're currently doing b)
154
147155*/
148156
149static void sh2_do_dma(sh2_state *sh2, int dma)
157
158void sh2_do_dma(sh2_state *sh2, int dma)
150159{
151160   UINT32 dmadata;
152161
r9224r9225
154163
155164   if (sh2->active_dma_count[dma] > 0)
156165   {
157      // schedule next DMA callback
166#ifdef USE_TIMER_FOR_DMA
167       //schedule next DMA callback
158168      timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma);
169#endif
159170
160171      // process current DMA
161172      switch(sh2->active_dma_size[dma])
r9224r9225
393404            sh2->active_dma_count[dma] &= ~3;
394405            break;
395406         }
396
407#ifdef USE_TIMER_FOR_DMA
397408         // start DMA timer
398409         timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma);
410#endif
399411
400
401412      }
402413   }
403414   else
src/emu/cpu/sh2/sh2.c
r9224r9225
22192219      return;
22202220   }
22212221
2222   // run any active DMAs now
2223#ifndef USE_TIMER_FOR_DMA
2224   for ( int i = 0; i < sh2->icount ; i++)
2225   {
2226      for( int dma=0;dma<1;dma++)
2227      {
2228         if (sh2->dma_timer_active[dma])
2229            sh2_do_dma(sh2, dma);
2230      }
2231   }
2232#endif
2233
22222234   do
22232235   {
22242236      UINT32 opcode;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team