MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / SpkrUpdate

Function SpkrUpdate

source/Speaker.cpp:418–457  ·  view source on GitHub ↗

Called by ContinueExecution()

Source from the content-addressed store, hash-verified

416
417// Called by ContinueExecution()
418void SpkrUpdate(uint32_t totalcycles)
419{
420#ifdef LOG_PERF_TIMINGS
421 extern UINT64 g_timeSpeaker;
422 PerfMarker perfMarker(g_timeSpeaker);
423#endif
424
425 if (!g_bSpkrToggleFlag)
426 {
427 if (!g_nSpkrQuietCycleCount)
428 {
429 g_nSpkrQuietCycleCount = g_nCumulativeCycles;
430 }
431 else if (g_nCumulativeCycles - g_nSpkrQuietCycleCount > (unsigned __int64)g_fCurrentCLK6502 / 5)
432 {
433 // After 0.2 sec of Apple time, deactivate spkr voice
434 // . This allows emulator to auto-switch to full-speed g_nAppMode for fast disk access
435 Spkr_SetActive(false);
436 }
437 }
438 else
439 {
440 g_nSpkrQuietCycleCount = 0;
441 g_bSpkrToggleFlag = false;
442 }
443
444 //
445
446 UpdateSpkr();
447 ULONG nSamplesUsed;
448
449 if (g_bFullSpeed)
450 nSamplesUsed = Spkr_SubmitWaveBuffer_FullSpeed(g_pSpeakerBuffer, g_nBufferIdx);
451 else
452 nSamplesUsed = Spkr_SubmitWaveBuffer(g_pSpeakerBuffer, g_nBufferIdx);
453
454 _ASSERT(nSamplesUsed <= g_nBufferIdx);
455 memmove(g_pSpeakerBuffer, &g_pSpeakerBuffer[nSamplesUsed], (g_nBufferIdx - nSamplesUsed) * sizeof(short) * g_nSPKR_NumChannels);
456 g_nBufferIdx -= nSamplesUsed;
457}
458
459// Called from SoundCore_TimerFunc() for FADE_OUT
460void SpkrUpdate_Timer()

Callers 1

ContinueExecutionFunction · 0.85

Calls 4

Spkr_SetActiveFunction · 0.85
UpdateSpkrFunction · 0.85
Spkr_SubmitWaveBufferFunction · 0.85

Tested by

no test coverage detected