Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

FDS wave lag (0CC preview playback)

nyanpasu64 edited this page Jul 19, 2018 · 7 revisions

Export speed test (1GB NTFS physical ramdisk):

Eirin Dev (allch): 5.5s Eirin Dev (pulse1): 3.2s

pulse1 and "all but pulse1" are both 16,975,916 bytes

FDS bug

Not FDS:

  • Allusion World (VRC7) is identical, if you remove VRC7.
  • Eirin is identical, if you remove n163+vrc6+5B.
  • Lord of the Rings MMC5 Covers is identical.

FDS:

  • ddc little princess is shorter, if you remove FDS.
  • 0CC runs at a consistent 28.9Hz, if switching FDS instruments once per frame.
  • NSF runs at a consistent 30Hz.

  • pInterface->FillWaveRAM causes slowdown.

void CSoundGen::UpdateAPU() manages the number of frames to delay.

  • It assumes each channel takes 150-250 cycles.
  • And it skips the delay if it's approaching vblank.
CSoundGen::OnIdle
... calls ...
void CChannelHandler::HandleNoteData(stChanNote *pNoteData, int EffColumns)
bool CChannelHandler::HandleInstrument(bool Trigger, bool NewInstrument)
void CSeqInstHandlerFDS::LoadInstrument(std::shared_ptr<CInstrument> pInst) etc...
void CSeqInstHandlerFDS::UpdateTables(const CInstrumentFDS *pInst)
void CChannelHandlerFDS::FillWaveRAM(const char *pBuffer)
void CChannelHandler::AddCycles(int count)
void CSoundGen::AddCycles(int Count)

BUG: FillWaveRAM is called from outside CSoundGen::UpdateAPU()!

m_iConsumedCycles == 313370

void CSoundGen::UpdateAPU() {
	m_iConsumedCycles = 0;		****
	for i:
		m_pChannels[i]->RefreshChannel();
		m_pChannels[i]->FinishTick();

		unsigned int Chip;

		int Delay = (Chip == LastChip) ? 150 : 250;
		if (m_iConsumedCycles + Delay < m_iUpdateCycles)
			AddCycles(Delay);

		m_pAPU->Process();
	m_iConsumedCycles = 313370
void CSoundGen::AddCycles(int Count)
	m_iConsumedCycles += Count;	****
	m_pAPU->AddTime(Count);
	std::cerr << m_iConsumedCycles << "\n";
prints 313370