MCPcopy Create free account
hub / github.com/TASEmulators/fceux / FCEU_SoundCPUHook

Function FCEU_SoundCPUHook

src/sound.cpp:546–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546void FCEU_SoundCPUHook(int cycles)
547{
548 fhcnt-=cycles*48;
549 if(fhcnt<=0)
550 {
551 FrameSoundUpdate();
552 fhcnt+=fhinc;
553 }
554
555 DMCDMA();
556 DMCacc-=cycles;
557
558 while(DMCacc<=0)
559 {
560 if(DMCHaveSample)
561 {
562 uint8 bah=RawDALatch;
563 int t=((DMCShift&1)<<2)-2;
564
565 /* Unbelievably ugly hack */
566 if(FSettings.SndRate)
567 {
568 const uint32 fudge = std::min<uint32>(-DMCacc, soundtsoffs + timestamp);
569 soundtsoffs -= fudge;
570 DoPCM();
571 soundtsoffs += fudge;
572 }
573 RawDALatch+=t;
574 if(RawDALatch&0x80)
575 RawDALatch=bah;
576 }
577
578 DMCacc+=DMCPeriod;
579 DMCBitCount=(DMCBitCount+1)&7;
580 DMCShift>>=1;
581 tester();
582 }
583}
584
585void RDoPCM(void)
586{

Callers 1

X6502_RunFunction · 0.85

Calls 3

FrameSoundUpdateFunction · 0.85
DMCDMAFunction · 0.85
testerFunction · 0.85

Tested by

no test coverage detected