From 1b537be8d43c7b7a41f6eee31fb1db5175405175 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 13 Mar 2004 18:44:10 +0000 Subject: Patch #902111: Change remaining random function calls to use RandomSource svn-id: r13262 --- backends/midi/adlib.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'backends') diff --git a/backends/midi/adlib.cpp b/backends/midi/adlib.cpp index 7fb0de39b1..6b6ebb3528 100644 --- a/backends/midi/adlib.cpp +++ b/backends/midi/adlib.cpp @@ -573,6 +573,8 @@ private: bool _isOpen; bool _game_SmallHeader; + static Common::RandomSource _rnd; + FM_OPL *_opl; byte *_adlib_reg_cache; SoundMixer *_mixer; @@ -624,7 +626,6 @@ private: void struct10_init(Struct10 * s10, InstrumentExtra * ie); static byte struct10_ontimer(Struct10 * s10, Struct11 * s11); static void struct10_setup(Struct10 * s10); - static int random_nr(int a); void mc_key_on(AdlibVoice *voice, AdlibInstrument *instr, byte note, byte velocity); static void premix_proc(void *param, int16 *buf, uint len); @@ -1230,7 +1231,7 @@ void MidiDriver_ADLIB::struct10_setup(Struct10 *s10) { t = s10->table_a[f]; e = num_steps_table[lookup_table[t & 0x7F][b]]; if (t & 0x80) { - e = random_nr(e); + e = _rnd.getRandomNumber(e); } if (e == 0) e++; @@ -1243,7 +1244,7 @@ void MidiDriver_ADLIB::struct10_setup(Struct10 *s10) { t = s10->table_b[f]; d = lookup_volume(c, (t & 0x7F) - 31); if (t & 0x80) { - d = random_nr(d); + d = _rnd.getRandomNumber(d); } if (d + g > c) { h = c - g; @@ -1305,17 +1306,6 @@ void MidiDriver_ADLIB::adlib_playnote(int channel, int note) { adlib_write(channel + 0xB0, oct | 0x20); } -int MidiDriver_ADLIB::random_nr(int a) { - static byte _rand_seed = 1; - if (_rand_seed & 1) { - _rand_seed >>= 1; - _rand_seed ^= 0xB8; - } else { - _rand_seed >>= 1; - } - return _rand_seed * a >> 8; -} - void MidiDriver_ADLIB::part_key_off(AdlibPart *part, byte note) { AdlibVoice *voice; @@ -1564,3 +1554,5 @@ void MidiDriver_ADLIB::adlib_note_on(int chan, byte note, int mod) { curnote_table[chan] = code; adlib_playnote(chan, (int16) channel_table_2[chan] + code); } + +Common::RandomSource MidiDriver_ADLIB::_rnd; -- cgit v1.2.3