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

Method Update

source/SSI263.cpp:426–738  ·  view source on GitHub ↗

Called by: . PeriodicUpdate()

Source from the content-addressed store, hash-verified

424// Called by:
425// . PeriodicUpdate()
426void SSI263::Update(void)
427{
428 if (!IsPhonemeActive())
429 return;
430
431 if (!SSI263SingleVoice.lpDSBvoice || !SSI263SingleVoice.bActive)
432 {
433 if (!DSInit())
434 return;
435 }
436
437 UpdateAccurateLength();
438
439 if (g_bFullSpeed) // NB. if true, then it's irrespective of IsPhonemeActive() - see MockingboardCard::IsActiveToPreventFullSpeed()
440 {
441 if (m_phonemeLengthRemaining)
442 {
443 // Willy Byte does SSI263 detection with drive motor on
444 m_phonemeLengthRemaining = 0;
445#if LOG_SSI263 || LOG_SSI263B || LOG_SC01
446 if (m_dbgFirst) LogOutput("1st phoneme short-circuited by fullspeed\n");
447#endif
448
449 if (m_phonemeAccurateLengthRemaining)
450 m_phonemeCompleteByFullSpeed = true; // Let UpdateAccurateLength() call UpdateIRQ()
451 else
452 UpdateIRQ();
453 }
454
455 m_updateWasFullSpeed = true;
456 return;
457 }
458
459 //
460
461 const bool nowNormalSpeed = m_updateWasFullSpeed; // Just transitioned from full-speed to normal speed
462 m_updateWasFullSpeed = false;
463
464 // NB. next call to this function: nowNormalSpeed = false
465 if (nowNormalSpeed)
466 m_byteOffset = (uint32_t)-1; // ...which resets m_numSamplesError below
467
468 //-------------
469
470 DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
471 HRESULT hr = SSI263SingleVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
472 if (FAILED(hr))
473 {
474 LogOutput("SSI263::Update() early return: GetCurrentPosition() failed\n");
475 return;
476 }
477
478 bool prefillBufferOnInit = false;
479
480 if (m_byteOffset == (uint32_t)-1)
481 {
482 // First time in this func (or transitioned from full-speed to normal speed, or a ring-buffer reset)
483#ifdef DBG_SSI263_UPDATE

Callers

nothing calls this directly

Calls 6

DSInitFunction · 0.85
LogOutputFunction · 0.85
SoundCore_GetErrorIncFunction · 0.85
DSGetLockFunction · 0.85
GetCurrentPositionMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected