static int DrvFrame() { if (DrvReset) { DrvDoReset(); } m6502Open(0); m6502Run(4000000 / 60); m6502SetIRQ(M6502_IRQ); m6502Close(); if (pBurnSoundOut) { int nSample; int nSegmentLength = nBurnSoundLen; short* pSoundBuf = pBurnSoundOut; if (nSegmentLength) { AY8910Update(0, &pAY8910Buffer[0], nSegmentLength); for (int n = 0; n < nSegmentLength; n++) { nSample = pAY8910Buffer[0][n]; nSample += pAY8910Buffer[1][n]; nSample += pAY8910Buffer[2][n]; nSample /= 4; if (nSample < -32768) { nSample = -32768; } else { if (nSample > 32767) { nSample = 32767; } } pSoundBuf[(n << 1) + 0] = nSample; pSoundBuf[(n << 1) + 1] = nSample; } } } if (pBurnDraw) { DrvDraw(); } return 0; }
static void AY8910Render(INT32 nSegmentLength) { #if defined FBA_DEBUG if (!DebugSnd_YM2610Initted) bprintf(PRINT_ERROR, _T("BurnYM2610 AY8910Render called without init\n")); #endif if (nAY8910Position >= nSegmentLength) { return; } nSegmentLength -= nAY8910Position; pYM2610Buffer[2] = pBuffer + 2 * 4096 + 4 + nAY8910Position; pYM2610Buffer[3] = pBuffer + 3 * 4096 + 4 + nAY8910Position; pYM2610Buffer[4] = pBuffer + 4 * 4096 + 4 + nAY8910Position; AY8910Update(0, &pYM2610Buffer[2], nSegmentLength); nAY8910Position += nSegmentLength; }
void AY8910Render(INT16** buffer, INT16* dest, INT32 length, INT32 bAddSignal) { #if defined FBA_DEBUG #ifdef __GNUC__ if (!DebugSnd_AY8910Initted) bprintf(PRINT_ERROR, _T("AY8910Render called without init\n")); if (num >= 7) bprintf(PRINT_ERROR, _T("AY8910Render called with invalid number of chips %i (max is 6)\n"), num); #endif #endif INT32 i; INT16 *buf0 = buffer[0]; INT16 *buf1 = buffer[1]; INT16 *buf2 = buffer[2]; INT16 *buf3, *buf4, *buf5, *buf6, *buf7, *buf8, *buf9, *buf10, *buf11, *buf12, *buf13, *buf14, *buf15, *buf16, *buf17; INT32 n; for (i = 0; i < num; i++) { AY8910Update(i, buffer + (i * 3), length); } if (num >= 2) { buf3 = buffer[3]; buf4 = buffer[4]; buf5 = buffer[5]; } if (num >= 3) { buf6 = buffer[6]; buf7 = buffer[7]; buf8 = buffer[8]; } if (num >= 4) { buf9 = buffer[9]; buf10 = buffer[10]; buf11 = buffer[11]; } if (num >= 5) { buf12 = buffer[12]; buf13 = buffer[13]; buf14 = buffer[14]; } if (num >= 6) { buf15 = buffer[15]; buf16 = buffer[16]; buf17 = buffer[17]; } for (n = 0; n < length; n++) { INT32 nLeftSample = 0, nRightSample = 0; AY8910_ADD_SOUND(BURN_SND_AY8910_ROUTE_1, buf0) AY8910_ADD_SOUND(BURN_SND_AY8910_ROUTE_2, buf1) AY8910_ADD_SOUND(BURN_SND_AY8910_ROUTE_3, buf2) if (num >= 2) { AY8910_ADD_SOUND(3 + BURN_SND_AY8910_ROUTE_1, buf3) AY8910_ADD_SOUND(3 + BURN_SND_AY8910_ROUTE_2, buf4) AY8910_ADD_SOUND(3 + BURN_SND_AY8910_ROUTE_3, buf5) } if (num >= 3) { AY8910_ADD_SOUND(6 + BURN_SND_AY8910_ROUTE_1, buf6) AY8910_ADD_SOUND(6 + BURN_SND_AY8910_ROUTE_2, buf7) AY8910_ADD_SOUND(6 + BURN_SND_AY8910_ROUTE_3, buf8) } if (num >= 4) { AY8910_ADD_SOUND(9 + BURN_SND_AY8910_ROUTE_1, buf9) AY8910_ADD_SOUND(9 + BURN_SND_AY8910_ROUTE_2, buf10) AY8910_ADD_SOUND(9 + BURN_SND_AY8910_ROUTE_3, buf11) } if (num >= 5) { AY8910_ADD_SOUND(12 + BURN_SND_AY8910_ROUTE_1, buf12) AY8910_ADD_SOUND(12 + BURN_SND_AY8910_ROUTE_2, buf13) AY8910_ADD_SOUND(12 + BURN_SND_AY8910_ROUTE_3, buf14) } if (num >= 6) { AY8910_ADD_SOUND(15 + BURN_SND_AY8910_ROUTE_1, buf15) AY8910_ADD_SOUND(15 + BURN_SND_AY8910_ROUTE_2, buf16) AY8910_ADD_SOUND(15 + BURN_SND_AY8910_ROUTE_3, buf17) } nLeftSample = BURN_SND_CLIP(nLeftSample); nRightSample = BURN_SND_CLIP(nRightSample); if (bAddSignal) { dest[(n << 1) + 0] += nLeftSample; dest[(n << 1) + 1] += nRightSample; } else { dest[(n << 1) + 0] = nLeftSample; dest[(n << 1) + 1] = nRightSample; } } }