void __fastcall QsndZWrite(unsigned short a, unsigned char d) { QUARK_LOG_VAR(a); QUARK_LOG_VAR(d); QUARK_LOG_VAR(QscCmd[0]); QUARK_LOG_VAR(QscCmd[1]); if (a == 0xd000) { QscCmd[0] = d; return; } if (a == 0xd001) { QscCmd[1] = d; return; } if (a == 0xd002) { QscWrite(d, (QscCmd[0] << 8) | QscCmd[1]); // bprintf(PRINT_NORMAL, "QSound command %02X %04X sent.\n", d, (QscCmd[0] << 8) | QscCmd[1]); return; } if (a == 0xd003) { int nNewBank = d & 0x0f; if (nQsndZBank != nNewBank) { nQsndZBank = nNewBank; QsndZBankMap(); } } }
void QsndEndFrame() { BurnTimerEndFrame(nCpsZ80Cycles); if (pBurnSoundOut) QscUpdate(nBurnSoundLen); nQsndCyclesExtra = ZetTotalCycles() - nCpsZ80Cycles; QUARK_LOG_VAR(nBurnSoundLen); QUARK_LOG_VAR(ZetTotalCycles()); QUARK_LOG_VAR(nCpsZ80Cycles); QUARK_LOG_VAR(nQsndCyclesExtra); ZetClose(); }
void QsndNewFrame() { ZetNewFrame(); QUARK_LOG_VAR(nQsndCyclesExtra); ZetOpen(0); ZetIdle(nQsndCyclesExtra); QscNewFrame(); }
void QsndSyncZ80() { int nCycles = (long long)SekTotalCycles() * nCpsZ80Cycles / nCpsCycles; QUARK_LOG_VAR(nCycles); QUARK_LOG_VAR(nCpsZ80Cycles); QUARK_LOG_VAR(nCpsCycles); QUARK_LOG_VAR(SekTotalCycles()); QUARK_LOG_VAR(nSekCyclesTotal); QUARK_LOG_VAR(nSekCyclesToDo); QUARK_LOG_VAR(ZetTotalCycles()); if (nCycles <= ZetTotalCycles()) { return; } BurnTimerUpdate(nCycles); }
int BurnTimerUpdate(int nCycles) { int nIRQStatus = 0; nTicksTotal = MAKE_TIMER_TICKS(nCycles, nCPUClockspeed); QUARK_LOG_VAR(nTicksTotal); QUARK_LOG_VAR(nCycles); QUARK_LOG_VAR(nCPUClockspeed); QUARK_LOG_VAR(nTimerCount[0]); QUARK_LOG_VAR(nTimerCount[1]); QUARK_LOG_VAR(nTimerStart[0]); QUARK_LOG_VAR(nTimerStart[1]); // bprintf(PRINT_NORMAL, _T(" -- Ticks: %08X, cycles %i\n"), nTicksTotal, nCycles); while (nTicksDone < nTicksTotal) { int nTimer, nCyclesSegment, nTicksSegment; // Determine which timer fires first if (nTimerCount[0] <= nTimerCount[1]) { nTicksSegment = nTimerCount[0]; } else { nTicksSegment = nTimerCount[1]; } if (nTicksSegment > nTicksTotal) { nTicksSegment = nTicksTotal; } nCyclesSegment = MAKE_CPU_CYLES(nTicksSegment + nTicksExtra, nCPUClockspeed); // bprintf(PRINT_NORMAL, _T(" - Timer: %08X, %08X, %08X, cycles %i, %i\n"), nTicksDone, nTicksSegment, nTicksTotal, nCyclesSegment, pCPUTotalCycles()); QUARK_LOG_VAR(nTicksExtra); QUARK_LOG_VAR(nTicksSegment); QUARK_LOG_VAR(nCyclesSegment); QUARK_LOG_VAR(pCPUTotalCycles()); QUARK_LOG_VAR(nCyclesSegment - pCPUTotalCycles()); pCPURun(nCyclesSegment - pCPUTotalCycles()); nTicksDone = MAKE_TIMER_TICKS(pCPUTotalCycles() + 1, nCPUClockspeed) - 1; // bprintf(PRINT_NORMAL, _T(" - ticks done -> %08X cycles -> %i\n"), nTicksDone, pCPUTotalCycles()); QUARK_LOG_VAR(nTicksDone); nTimer = 0; if (nTicksDone >= nTimerCount[0]) { if (nTimerStart[0] == MAX_TIMER_VALUE) { nTimerCount[0] = MAX_TIMER_VALUE; } else { nTimerCount[0] += nTimerStart[0]; } // bprintf(PRINT_NORMAL, _T(" - timer 0 fired\n")); nTimer |= 1; } if (nTicksDone >= nTimerCount[1]) { if (nTimerStart[1] == MAX_TIMER_VALUE) { nTimerCount[1] = MAX_TIMER_VALUE; } else { nTimerCount[1] += nTimerStart[1]; } // bprintf(PRINT_NORMAL, _T(" - timer 1 fired\n")); nTimer |= 2; } if (nTimer & 1) { nIRQStatus |= pTimerOverCallback(0, 0); } if (nTimer & 2) { nIRQStatus |= pTimerOverCallback(0, 1); } } return nIRQStatus; }