[Scummvm-git-logs] scummvm master -> 5d419c2b58841b2bc56c40caebab5e38622dee88

criezy criezy at scummvm.org
Mon Sep 11 22:46:56 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5d419c2b58 AUDIO: Rename two functions in ModuleModXmS3m


Commit: 5d419c2b58841b2bc56c40caebab5e38622dee88
    https://github.com/scummvm/scummvm/commit/5d419c2b58841b2bc56c40caebab5e38622dee88
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-09-11T21:38:58+01:00

Commit Message:
AUDIO: Rename two functions in ModuleModXmS3m

This is an attempt to fix a compilation error on some platforms.
The error message seems to indicate that log2 might be a define
on thos platforms.

Note that the log2 implementation in ModuleModXmS3m is not the binary
logarithm, and we cannot use Common::intLog2.

Changed paths:
    audio/mods/mod_xm_s3m.cpp
    audio/mods/module_mod_xm_s3m.cpp
    audio/mods/module_mod_xm_s3m.h


diff --git a/audio/mods/mod_xm_s3m.cpp b/audio/mods/mod_xm_s3m.cpp
index fdacbbb..615e587 100644
--- a/audio/mods/mod_xm_s3m.cpp
+++ b/audio/mods/mod_xm_s3m.cpp
@@ -665,7 +665,7 @@ void ModXmS3mStream::trigger(Channel &channel) {
 			if (_module.linearPeriods) {
 				channel.portaPeriod = 7744 - period;
 			} else {
-				channel.portaPeriod = 29021 * ModuleModXmS3m::exp2((period << FP_SHIFT) / -768) >> FP_SHIFT;
+				channel.portaPeriod = 29021 * ModuleModXmS3m::moduleExp2((period << FP_SHIFT) / -768) >> FP_SHIFT;
 			}
 			if (!porta) {
 				channel.period = channel.portaPeriod;
@@ -720,12 +720,12 @@ void ModXmS3mStream::calculateFreq(Channel &channel) {
 		if (per < 28 || per > 7680) {
 			per = 7680;
 		}
-		channel.freq = ((_module.c2Rate >> 4) * ModuleModXmS3m::exp2(((4608 - per) << FP_SHIFT) / 768)) >> (FP_SHIFT - 4);
+		channel.freq = ((_module.c2Rate >> 4) * ModuleModXmS3m::moduleExp2(((4608 - per) << FP_SHIFT) / 768)) >> (FP_SHIFT - 4);
 	} else {
 		if (per > 29021) {
 			per = 29021;
 		}
-		per = (per << FP_SHIFT) / ModuleModXmS3m::exp2((channel.arpeggioAdd << FP_SHIFT) / 12);
+		per = (per << FP_SHIFT) / ModuleModXmS3m::moduleExp2((channel.arpeggioAdd << FP_SHIFT) / 12);
 		if (per < 28) {
 			per = 29021;
 		}
diff --git a/audio/mods/module_mod_xm_s3m.cpp b/audio/mods/module_mod_xm_s3m.cpp
index 6283dbe..3ea68e5 100644
--- a/audio/mods/module_mod_xm_s3m.cpp
+++ b/audio/mods/module_mod_xm_s3m.cpp
@@ -94,7 +94,7 @@ const int ModuleModXmS3m::exp2table[] = {
 		65536
 };
 
-int ModuleModXmS3m::exp2(int x) {
+int ModuleModXmS3m::moduleExp2(int x) {
 	int c, m, y;
 	int x0 = (x & FP_MASK) >> (FP_SHIFT - 7);
 	c = exp2table[x0];
@@ -103,10 +103,10 @@ int ModuleModXmS3m::exp2(int x) {
 	return (y << FP_SHIFT) >> (FP_SHIFT - (x >> FP_SHIFT));
 }
 
-int ModuleModXmS3m::log2(int x) {
+int ModuleModXmS3m::moduleLog2(int x) {
 	int y = 16 << FP_SHIFT;
 	for (int step = y; step > 0; step >>= 1) {
-		if (exp2(y - step) >= x) {
+		if (moduleExp2(y - step) >= x) {
 			y -= step;
 		}
 	}
@@ -337,7 +337,7 @@ bool ModuleModXmS3m::loadMod(Common::SeekableReadStream &st) {
 			uint period = (first & 0xF) << 8;
 			period = (period | second) * 4;
 			if (period >= 112 && period <= 6848) {
-				int key = -12 * log2((period << FP_SHIFT) / 29021);
+				int key = -12 * moduleLog2((period << FP_SHIFT) / 29021);
 				key = (key + (key & (FP_ONE >> 1))) >> FP_SHIFT;
 				patterns[i].notes[idx].key = key;
 			}
@@ -688,7 +688,7 @@ bool ModuleModXmS3m::loadS3m(Common::SeekableReadStream &st) {
 			sample.loopLength = loopLength;
 
 			bool sixteenBit = samParam & 0x4;
-			int tune = (log2(st.readUint32LE()) - log2(c2Rate)) * 12;
+			int tune = (moduleLog2(st.readUint32LE()) - moduleLog2(c2Rate)) * 12;
 			sample.relNote = tune >> FP_SHIFT;
 			sample.finetune = (tune & FP_MASK) >> (FP_SHIFT - 7);
 			st.skip(12); // skip unused bytes
diff --git a/audio/mods/module_mod_xm_s3m.h b/audio/mods/module_mod_xm_s3m.h
index d92ac66..b4c984a 100644
--- a/audio/mods/module_mod_xm_s3m.h
+++ b/audio/mods/module_mod_xm_s3m.h
@@ -155,8 +155,8 @@ public:
 	bool load(Common::SeekableReadStream &stream);
 
 	// math functions
-	static int log2(int x);
-	static int exp2(int x);
+	static int moduleLog2(int x);
+	static int moduleExp2(int x);
 
 private:
 	bool loadMod(Common::SeekableReadStream &stream);





More information about the Scummvm-git-logs mailing list