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

Method MB_Update

source/Mockingboard.cpp:475–568  ·  view source on GitHub ↗

Called by: . MB_SyncEventCallback() -> MockingboardCardManager::UpdateSoundBuffer() on a TIMER1 (not TIMER2) underflow - when IsAnyTimer1Active() == true (for any MB) . MockingboardCardManager::Update() - when IsAnyTimer1Active() == false (for all MB's)

Source from the content-addressed store, hash-verified

473// . MB_SyncEventCallback() -> MockingboardCardManager::UpdateSoundBuffer() on a TIMER1 (not TIMER2) underflow - when IsAnyTimer1Active() == true (for any MB)
474// . MockingboardCardManager::Update() - when IsAnyTimer1Active() == false (for all MB's)
475UINT MockingboardCard::MB_Update(void)
476{
477 if (g_bFullSpeed)
478 {
479 // Keep AY reg writes relative to the current 'frame'
480 // - Required for Ultima3:
481 // . Tune ends
482 // . g_bFullSpeed:=true (disk-spinning) for ~50 frames
483 // . U3 sets AY_ENABLE:=0xFF (as a side-effect, this sets g_bFullSpeed:=false)
484 // o Without this, the write to AY_ENABLE gets ignored (since AY8910's /m_lastCumulativeCycle/ was last set 50 frame ago)
485 AY8910UpdateSetCycles();
486
487 // TODO:
488 // If any AY regs have changed then push them out to the AY chip
489
490 return 0;
491 }
492
493 //
494
495 if (!m_regAccessedFlag)
496 {
497 if (!m_inActiveCycleCount)
498 {
499 m_inActiveCycleCount = g_nCumulativeCycles;
500 }
501 else if (g_nCumulativeCycles - m_inActiveCycleCount > (unsigned __int64)g_fCurrentCLK6502 / 10)
502 {
503 // After 0.1 sec of Apple time, assume MB is not active
504 m_isActive = false;
505 }
506 }
507 else
508 {
509 m_inActiveCycleCount = 0;
510 m_regAccessedFlag = false;
511 m_isActive = true;
512 }
513
514 //
515
516 // For small timer periods, wait for a period of 500cy before updating DirectSound ring-buffer.
517 // NB. A timer period of less than 24cy will yield nNumSamplesPerPeriod=0.
518 const double kMinimumUpdateInterval = 500.0; // Arbitary (500 cycles = 21 samples)
519 const double kMaximumUpdateInterval = (double)(0xFFFF + 2); // Max 6522 timer interval (2756 samples)
520
521 if (m_lastMBUpdateCycle == 0)
522 m_lastMBUpdateCycle = m_lastCumulativeCycle; // Initial call to MB_Update() after reset/power-cycle
523
524 _ASSERT(m_lastCumulativeCycle >= m_lastMBUpdateCycle);
525 double updateInterval = (double)(m_lastCumulativeCycle - m_lastMBUpdateCycle);
526 if (updateInterval < kMinimumUpdateInterval)
527 return 0;
528 if (updateInterval > kMaximumUpdateInterval)
529 updateInterval = kMaximumUpdateInterval;
530
531 m_lastMBUpdateCycle = m_lastCumulativeCycle;
532

Callers 1

GenerateAllSoundDataMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected