static INT32 DrvFrame() { if (DrvReset) { DrvDoReset(); } { memset (DrvInputs, 0xff, 2 * sizeof(INT16)); for (INT32 i = 0; i < 16; i++) { DrvInputs[0] ^= (DrvJoy1[i] & 1) << i; DrvInputs[1] ^= (DrvJoy2[i] & 1) << i; } } INT32 nInterleave = 256; INT32 nCyclesTotal[1] = { 12000000 / 60 }; INT32 nCyclesDone[1] = { 0 }; SekOpen(0); for (INT32 i = 0; i < nInterleave; i++) { nCyclesDone[0] += SekRun(nCyclesTotal[0] / nInterleave); if (control_data & 0x800) { if (i == 0) SekSetIRQLine(4, CPU_IRQSTATUS_AUTO); if (i == 240) SekSetIRQLine(3, CPU_IRQSTATUS_AUTO); } } if (pBurnSoundOut) { YMZ280BRender(pBurnSoundOut, nBurnSoundLen); } SekClose(); if (pBurnDraw) { DrvDraw(); } return 0; }
static INT32 DrvFrame() { INT32 nCyclesVBlank; INT32 nInterleave = 8; if (DrvReset) { // Reset machine DrvDoReset(); } // Compile digital inputs DrvInput[0] = 0; // Player 1 DrvInput[1] = 0; // Player 2 for (INT32 i = 0; i < 16; i++) { DrvInput[0] |= (DrvJoy1[i] & 1) << i; DrvInput[1] |= (DrvJoy2[i] & 1) << i; } CaveClearOpposites(&DrvInput[0]); CaveClearOpposites(&DrvInput[1]); DrvInput[0] ^= 0xffff; DrvInput[1] ^= 0xffff; SekNewFrame(); nCyclesTotal[0] = (INT32)((INT64)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE)); nCyclesDone[0] = 0; nCyclesVBlank = nCyclesTotal[0] - (INT32)((nCyclesTotal[0] * CAVE_VBLANK_LINES) / 271.5); bVBlank = false; INT32 nSoundBufferPos = 0; SekOpen(0); for (INT32 i = 1; i <= nInterleave; i++) { INT32 nNext; // Render sound segment if ((i & 1) == 0) { if (pBurnSoundOut) { INT32 nSegmentEnd = nBurnSoundLen * i / nInterleave; INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); YMZ280BRender(pSoundBuf, nSegmentEnd - nSoundBufferPos); nSoundBufferPos = nSegmentEnd; } } // Run 68000 nCurrentCPU = 0; nNext = i * nCyclesTotal[nCurrentCPU] / nInterleave; // See if we need to trigger the VBlank interrupt if (!bVBlank && nNext > nCyclesVBlank) { if (nCyclesDone[nCurrentCPU] < nCyclesVBlank) { nCyclesSegment = nCyclesVBlank - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } } if (pBurnDraw != NULL) { DrvDraw(); // Draw screen if needed } bVBlank = true; nVideoIRQ = 0; UpdateIRQStatus(); } nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } nCurrentCPU = -1; } { // Make sure the buffer is entirely filled. if (pBurnSoundOut) { INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); if (nSegmentLength) { YMZ280BRender(pSoundBuf, nSegmentLength); } } } SekClose(); return 0; }