Renamed some variables and parameters to match their real use.

svn-id: r40083
This commit is contained in:
Johannes Schickel 2009-04-22 20:18:12 +00:00
parent 17a92f6a70
commit 0638a8a27a

View File

@ -601,12 +601,12 @@ private:
void adlib_note_on_ex(int chan, byte note, int mod);
int adlib_read_param(int chan, byte data);
void adlib_setup_channel(int chan, AdlibInstrument * instr, byte vol_1, byte vol_2);
byte adlib_read(byte port) {
return _adlib_reg_cache[port];
byte adlib_read(byte reg) {
return _adlib_reg_cache[reg];
}
void adlib_set_param(int channel, byte param, int value);
void adlib_key_onoff(int channel);
void adlib_write(byte port, byte value);
void adlib_write(byte reg, byte value);
void adlib_playnote(int channel, int note);
AdlibVoice *allocate_voice(byte pri);
@ -1028,15 +1028,15 @@ MidiChannel *MidiDriver_ADLIB::allocateChannel() {
// All the code brought over from IMuseAdlib
void MidiDriver_ADLIB::adlib_write(byte port, byte value) {
if (_adlib_reg_cache[port] == value)
void MidiDriver_ADLIB::adlib_write(byte reg, byte value) {
if (_adlib_reg_cache[reg] == value)
return;
#ifdef DEBUG_ADLIB
debug(6, "%10d: adlib_write[%x] = %x", tick, port, value);
debug(6, "%10d: adlib_write[%x] = %x", tick, reg, value);
#endif
_adlib_reg_cache[port] = value;
_adlib_reg_cache[reg] = value;
OPLWriteReg(_opl, port, value);
OPLWriteReg(_opl, reg, value);
}
void MidiDriver_ADLIB::generateSamples(int16 *data, int len) {
@ -1134,8 +1134,8 @@ void MidiDriver_ADLIB::mc_inc_stuff(AdlibVoice *voice, Struct10 *s10, Struct11 *
}
void MidiDriver_ADLIB::adlib_key_off(int chan){
byte port = chan + 0xB0;
adlib_write(port, adlib_read(port) & ~0x20);
byte reg = chan + 0xB0;
adlib_write(reg, adlib_read(reg) & ~0x20);
}
byte MidiDriver_ADLIB::struct10_ontimer(Struct10 *s10, Struct11 *s11) {
@ -1183,18 +1183,18 @@ byte MidiDriver_ADLIB::struct10_ontimer(Struct10 *s10, Struct11 *s11) {
void MidiDriver_ADLIB::adlib_set_param(int channel, byte param, int value) {
const AdlibSetParams *as;
byte port;
byte reg;
assert(channel >= 0 && channel < 9);
if (param <= 12) {
port = channel_mappings_2[channel];
reg = channel_mappings_2[channel];
} else if (param <= 25) {
param -= 13;
port = channel_mappings[channel];
reg = channel_mappings[channel];
} else if (param <= 27) {
param -= 13;
port = channel;
reg = channel;
} else if (param == 28 || param == 29) {
if (param == 28)
value -= 15;
@ -1211,18 +1211,18 @@ void MidiDriver_ADLIB::adlib_set_param(int channel, byte param, int value) {
as = &adlib_setparam_table[param];
if (as->d)
value = as->d - value;
port += as->a;
adlib_write(port, (adlib_read(port) & ~as->c) | (((byte)value) << as->b));
reg += as->a;
adlib_write(reg, (adlib_read(reg) & ~as->c) | (((byte)value) << as->b));
}
void MidiDriver_ADLIB::adlib_key_onoff(int channel) {
byte val;
byte port = channel + 0xB0;
byte reg = channel + 0xB0;
assert(channel >= 0 && channel < 9);
val = adlib_read(port);
adlib_write(port, val & ~0x20);
adlib_write(port, val | 0x20);
val = adlib_read(reg);
adlib_write(reg, val & ~0x20);
adlib_write(reg, val | 0x20);
}
void MidiDriver_ADLIB::struct10_setup(Struct10 *s10) {
@ -1435,23 +1435,23 @@ void MidiDriver_ADLIB::mc_key_on(AdlibVoice *voice, AdlibInstrument *instr, byte
}
void MidiDriver_ADLIB::adlib_setup_channel(int chan, AdlibInstrument *instr, byte vol_1, byte vol_2) {
byte port;
byte channel;
assert(chan >= 0 && chan < 9);
port = channel_mappings[chan];
adlib_write(port + 0x20, instr->mod_characteristic);
adlib_write(port + 0x40, (instr->mod_scalingOutputLevel | 0x3F) - vol_1 );
adlib_write(port + 0x60, 0xff & (~instr->mod_attackDecay));
adlib_write(port + 0x80, 0xff & (~instr->mod_sustainRelease));
adlib_write(port + 0xE0, instr->mod_waveformSelect);
channel = channel_mappings[chan];
adlib_write(channel + 0x20, instr->mod_characteristic);
adlib_write(channel + 0x40, (instr->mod_scalingOutputLevel | 0x3F) - vol_1 );
adlib_write(channel + 0x60, 0xff & (~instr->mod_attackDecay));
adlib_write(channel + 0x80, 0xff & (~instr->mod_sustainRelease));
adlib_write(channel + 0xE0, instr->mod_waveformSelect);
port = channel_mappings_2[chan];
adlib_write(port + 0x20, instr->car_characteristic);
adlib_write(port + 0x40, (instr->car_scalingOutputLevel | 0x3F) - vol_2 );
adlib_write(port + 0x60, 0xff & (~instr->car_attackDecay));
adlib_write(port + 0x80, 0xff & (~instr->car_sustainRelease));
adlib_write(port + 0xE0, instr->car_waveformSelect);
channel = channel_mappings_2[chan];
adlib_write(channel + 0x20, instr->car_characteristic);
adlib_write(channel + 0x40, (instr->car_scalingOutputLevel | 0x3F) - vol_2 );
adlib_write(channel + 0x60, 0xff & (~instr->car_attackDecay));
adlib_write(channel + 0x80, 0xff & (~instr->car_sustainRelease));
adlib_write(channel + 0xE0, instr->car_waveformSelect);
adlib_write((byte)chan + 0xC0, instr->feedback);
}
@ -1532,18 +1532,18 @@ void MidiDriver_ADLIB::struct10_init(Struct10 *s10, InstrumentExtra *ie) {
int MidiDriver_ADLIB::adlib_read_param(int chan, byte param) {
const AdlibSetParams *as;
byte val;
byte port;
byte channel;
assert(chan >= 0 && chan < 9);
if (param <= 12) {
port = channel_mappings_2[chan];
channel = channel_mappings_2[chan];
} else if (param <= 25) {
param -= 13;
port = channel_mappings[chan];
channel = channel_mappings[chan];
} else if (param <= 27) {
param -= 13;
port = chan;
channel = chan;
} else if (param == 28) {
return 0xF;
} else if (param == 29) {
@ -1553,7 +1553,7 @@ int MidiDriver_ADLIB::adlib_read_param(int chan, byte param) {
}
as = &adlib_setparam_table[param];
val = adlib_read(port + as->a);
val = adlib_read(channel + as->a);
val &= as->c;
val >>= as->b;
if (as->d)