[Scummvm-cvs-logs] CVS: scummvm/backends/midi adlib.cpp,1.55,1.56

Max Horn fingolfin at users.sourceforge.net
Sat Mar 13 10:53:03 CET 2004


Update of /cvsroot/scummvm/scummvm/backends/midi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11963/backends/midi

Modified Files:
	adlib.cpp 
Log Message:
Patch #902111: Change remaining random function calls to use RandomSource

Index: adlib.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/adlib.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- adlib.cpp	24 Feb 2004 22:39:36 -0000	1.55
+++ adlib.cpp	13 Mar 2004 18:44:09 -0000	1.56
@@ -573,6 +573,8 @@
 	bool _isOpen;
 	bool _game_SmallHeader;
 
+	static Common::RandomSource _rnd;
+
 	FM_OPL *_opl;
 	byte *_adlib_reg_cache;
 	SoundMixer *_mixer;
@@ -624,7 +626,6 @@
 	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 @@
 	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 @@
 		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 @@
 	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 @@
 	curnote_table[chan] = code;
 	adlib_playnote(chan, (int16) channel_table_2[chan] + code);
 }
+
+Common::RandomSource MidiDriver_ADLIB::_rnd;





More information about the Scummvm-git-logs mailing list