public void YM3812UpdateOne(short[] buffer, int length)
{
int i;
int data;
short[] buf = buffer;
int amsCnt = this.amsCnt;
int vibCnt = this.vibCnt;
byte rythm = (byte)(rythm & 0x20);
OPL_CH CH, R_CH;
if (this != cur_chip)
{
cur_chip = this;
/* channel pointers */
S_CH = P_CH;
E_CH = S_CH[9];
/* rythm slot */
SLOT7_1 = S_CH[7].SLOT[SLOT1];
SLOT7_2 = S_CH[7].SLOT[SLOT2];
SLOT8_1 = S_CH[8].SLOT[SLOT1];
SLOT8_2 = S_CH[8].SLOT[SLOT2];
/* LFO state */
amsIncr = this.amsIncr;
vibIncr = this.vibIncr;
ams_table = this.ams_table;
vib_table = this.vib_table;
}
R_CH = rythm != 0 ? S_CH[6] : E_CH;
for (i = 0; i < length; i++)
{
/* channel A channel B channel C */
/* LFO */
ams = ams_table((amsCnt += amsIncr) >> AMS_SHIFT);
vib = vib_table((vibCnt += vibIncr) >> VIB_SHIFT);
outd[0] = 0;
/* FM part */
for (CH = S_CH; CH < R_CH; CH++)
OPL_CALC_CH(CH);
/* Rythn part */
if (rythm)
OPL_CALC_RH(OPL, S_CH);
/* limit check */
data = CLIP(outd[0], OPL_MINOUT, OPL_MAXOUT);
/* store to sound buffer */
buf[i] = data >> OPL_OUTSB;
}
amsCnt = amsCnt;
vibCnt = vibCnt;
}