sw =1+memoryWaitSeq32[sm & 15] + ((((sm>=0x05) && (sm<=0x07)) && !blank) ? 2 : 0); dw =1+memoryWaitSeq32[dm & 15] + ((((dw>=0x05) && (dw<=0x07)) && !blank) ? 2 : 0); totalTicks = (sw+dw)*(sc-1) + 2 + 1 + memoryWait32[sm & 15] + 1 + memoryWaitSeq32[dm & 15];
sw =1+memoryWaitSeq32[sm & 15]; dw =1+memoryWaitSeq32[dm & 15]; totalTicks = (sw+dw)*(sc-1) + 6 + memoryWait32[sm & 15] + memoryWaitSeq32[dm & 15];
void doDMA(u32 &s, u32 &d, u32 si, u32 di, u32 c, int transfer32){  int sm = s >> 24;  int dm = d >> 24;  int sw = 0;  int dw = 0;  bool blank = false;  int sc = c;  cpuDmaCount = c;  if (sm>15)      sm=15;  if (dm>15)      dm=15;    if ((sm>=0x05) && (sm<=0x07) || (dm>=0x05) && (dm <=0x07))      blank = (((DISPSTAT | ((DISPSTAT>>1)&1))==1) ?  true : false);  if(transfer32) {    s &= 0xFFFFFFFC;    if(s < 0x02000000 && (reg[15].I >> 24)) {      while(c != 0) {        CPUWriteMemory(d, 0);        d += di;        c--;      }    } else {      while(c != 0) {        cpuDmaLast = CPUReadMemory(s);        CPUWriteMemory(d, cpuDmaLast);        d += di;        s += si;        c--;      }    }  } else {    s &= 0xFFFFFFFE;    si = (int)si >> 1;    di = (int)di >> 1;    if(s < 0x02000000 && (reg[15].I >> 24)) {      while(c != 0) {        CPUWriteHalfWord(d, 0);        d += di;        c--;      }    } else {      while(c != 0) {        cpuDmaLast = CPUReadHalfWord(s);        CPUWriteHalfWord(d, cpuDmaLast);        cpuDmaLast |= (cpuDmaLast<<16);        d += di;        s += si;        c--;      }    }  }  cpuDmaCount = 0;    int totalTicks = 0;  if(transfer32) {      sw =1+memoryWaitSeq32[sm & 15] +      ((((sm>=0x05) && (sm<=0x07)) && !blank) ? 2 : 0);      dw =1+memoryWaitSeq32[dm & 15] +      ((((dw>=0x05) && (dw<=0x07)) && !blank) ? 2 : 0);      totalTicks = (sw+dw)*(sc-1) + 2 +          1 + memoryWait32[sm & 15] + 1 + memoryWaitSeq32[dm & 15];  }  else  {     sw = 1+memoryWaitSeq[sm & 15] +      ((((sm>=0x05) && (sm<=0x07)) && !blank) ? 1 : 0);     dw = 1+memoryWaitSeq[dm & 15] +      ((((dw>=0x05) && (dw<=0x07)) && !blank) ? 1 : 0);      totalTicks = (sw+dw)*(sc-1) + 2 +          1 + memoryWait[sm & 15] + 1 + memoryWaitSeq[dm & 15];  }  cpuDmaTicksToUpdate += totalTicks;}