2012-04-29 01:09:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Sound
|
|
|
|
|
{
|
|
|
|
|
public partial class YM2612
|
|
|
|
|
{
|
|
|
|
|
public sealed class Operator
|
|
|
|
|
{
|
|
|
|
|
// External Settings
|
|
|
|
|
public int TL_TotalLevel;
|
2012-04-29 17:41:39 +00:00
|
|
|
|
public int SL_SustainLevel;
|
2012-04-29 01:09:06 +00:00
|
|
|
|
public int AR_AttackRate;
|
2012-04-29 17:41:39 +00:00
|
|
|
|
public int DR_DecayRate;
|
|
|
|
|
public int SR_SustainRate;
|
2012-04-29 01:09:06 +00:00
|
|
|
|
public int RR_ReleaseRate;
|
2012-04-29 17:41:39 +00:00
|
|
|
|
public int KS_KeyScale;
|
2012-04-29 01:09:06 +00:00
|
|
|
|
public int SSG_EG;
|
|
|
|
|
|
|
|
|
|
public int DT1_Detune;
|
|
|
|
|
public int MUL_Multiple;
|
|
|
|
|
|
|
|
|
|
public bool AM_AmplitudeModulation;
|
|
|
|
|
|
2012-04-29 18:33:21 +00:00
|
|
|
|
public int FrequencyNumber;
|
|
|
|
|
public int Block;
|
|
|
|
|
|
2012-04-29 01:09:06 +00:00
|
|
|
|
// Internal State
|
2012-04-29 17:41:39 +00:00
|
|
|
|
public int PhaseCounter;
|
|
|
|
|
|
|
|
|
|
// I/O
|
|
|
|
|
public void Write_MUL_DT1(byte value)
|
|
|
|
|
{
|
|
|
|
|
MUL_Multiple = value & 15;
|
|
|
|
|
DT1_Detune = (value >> 4) & 7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write_TL(byte value)
|
|
|
|
|
{
|
|
|
|
|
TL_TotalLevel = value & 127;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write_AR_KS(byte value)
|
|
|
|
|
{
|
|
|
|
|
AR_AttackRate = value & 31;
|
|
|
|
|
KS_KeyScale = value >> 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write_DR_AM(byte value)
|
|
|
|
|
{
|
|
|
|
|
DR_DecayRate = value & 31;
|
|
|
|
|
AM_AmplitudeModulation = (value & 128) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write_SR(byte value)
|
|
|
|
|
{
|
|
|
|
|
SR_SustainRate = value & 31;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write_RR_SL(byte value)
|
|
|
|
|
{
|
|
|
|
|
RR_ReleaseRate = value & 15;
|
|
|
|
|
SL_SustainLevel = value >> 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write_SSGEG(byte value)
|
|
|
|
|
{
|
|
|
|
|
SSG_EG = value & 15;
|
|
|
|
|
}
|
2012-04-29 18:33:21 +00:00
|
|
|
|
|
|
|
|
|
public void UpdateFrequency(int frequencyNumber, int block)
|
|
|
|
|
{
|
|
|
|
|
FrequencyNumber = frequencyNumber;
|
|
|
|
|
Block = block;
|
|
|
|
|
}
|
2012-04-29 01:09:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//TODO "the shape of the waves of the envelope changes in a exponential when attacking it, and it changes in the straight line at other rates."
|
|
|
|
|
|
|
|
|
|
// pg 8, read it
|
|
|
|
|
// pg 11, detailed overview of how operator works.
|
|
|
|
|
// pg 12, detailed description of phase generator.
|
|
|
|
|
|
|
|
|
|
//TL Total Level 7 bits
|
|
|
|
|
//SL Sustain Level 4 bits
|
|
|
|
|
//AR Attack Rate 5 bits
|
|
|
|
|
//DR Decay Rate 5 bits
|
|
|
|
|
//SR Sustain Rate 5 bits
|
|
|
|
|
//RR Release Rate 4 bits
|
|
|
|
|
//SSG-EG SSG-EG Mode 4 bits
|
|
|
|
|
}
|