Exemplo n.º 1
0
void CVRC6Sawtooth::RefreshChannel()
{
	unsigned int Period = CalculatePeriod();

	unsigned char HiFreq = (Period & 0xFF);
	unsigned char LoFreq = (Period >> 8);

	unsigned int TremVol = GetTremolo();
	int Volume = (m_iSeqVolume * (m_iVolume >> VOL_COLUMN_SHIFT)) / 15 - TremVol;

	Volume = (Volume << 1) | ((m_iDutyPeriod & 1) << 5);

	if (Volume < 0)
		Volume = 0;
	if (Volume > 63)
		Volume = 63;

	if (m_iSeqVolume > 0 && m_iVolume > 0 && Volume == 0)
		Volume = 2;

	if (!m_bGate)
		Volume = 0;

	if (!m_bGate || !Volume) {
		WriteExternalRegister(0xB002, 0x00);
		return;
	}

	WriteExternalRegister(0xB000, Volume);
	WriteExternalRegister(0xB001, HiFreq);
	WriteExternalRegister(0xB002, 0x80 | LoFreq);
}
Exemplo n.º 2
0
void CVRC6Sawtooth::RefreshChannel()
{
	if (!m_bEnabled)
		return;

	unsigned int Period = CalculatePeriod(false);

	unsigned char HiFreq = (Period & 0xFF);
	unsigned char LoFreq = (Period >> 8);

	unsigned int TremVol = GetTremolo();
	unsigned int Volume = (m_iSeqVolume * (m_iVolume >> VOL_SHIFT)) / 15 - TremVol;

	Volume = (Volume << 1) | ((m_iDutyPeriod & 1) << 5);

	if (Volume > 63)
		Volume = 63;

	if (m_iSeqVolume > 0 && m_iVolume > 0 && Volume == 0)
		Volume = 1;

	m_pAPU->ExternalWrite(0xB000, Volume);
	m_pAPU->ExternalWrite(0xB001, HiFreq);
	m_pAPU->ExternalWrite(0xB002, 0x80 | LoFreq);
}