[Scummvm-cvs-logs] scummvm master -> d14e75cdc7507c041f4fcb5a588107ddc3fb7c53

lordhoto lordhoto at gmail.com
Sun Dec 11 06:26:02 CET 2011


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:
d14e75cdc7 CINE: Make findNote behave like in the original.


Commit: d14e75cdc7507c041f4fcb5a588107ddc3fb7c53
    https://github.com/scummvm/scummvm/commit/d14e75cdc7507c041f4fcb5a588107ddc3fb7c53
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-12-10T21:24:33-08:00

Commit Message:
CINE: Make findNote behave like in the original.

This also reverts 42fd6975447b99f4a66ec411a62def2b3b49c5d6, which was wrong,
since I misread the assembly. Ooops.

Changed paths:
    engines/cine/sound.cpp



diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 35c379b..0328466 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -249,16 +249,30 @@ private:
 
 
 void PCSoundDriver::findNote(int freq, int *note, int *oct) const {
-	*note = _noteTableCount - 1;
-	// It might seem odd that we start with 1 here, but the original has the
-	// same behavior.
-	for (int i = 1; i < _noteTableCount; ++i) {
-		if (_noteTable[i] <= freq) {
+	if (freq > 0x777)
+		*oct = 0;
+	else if (freq > 0x3BB)
+		*oct = 1;
+	else if (freq > 0x1DD)
+		*oct = 2;
+	else if (freq > 0x0EE)
+		*oct = 3;
+	else if (freq > 0x077)
+		*oct = 4;
+	else if (freq > 0x03B)
+		*oct = 5;
+	else if (freq > 0x01D)
+		*oct = 6;
+	else
+		*oct = 7;
+
+	*note = 11;
+	for (int i = 0; i < 12; ++i) {
+		if (_noteTable[*oct * 12 + i] <= freq) {
 			*note = i;
 			break;
 		}
 	}
-	*oct = *note / 12;
 }
 
 void PCSoundDriver::resetChannel(int channel) {
@@ -475,12 +489,11 @@ void AdLibSoundDriverINS::setChannelFrequency(int channel, int frequency) {
 	if (ins->mode == 0 || ins->channel == 6) {
 		int freq, note, oct;
 		findNote(frequency, &note, &oct);
-		if (channel == 6) {
-			note %= 12;
-		}
+		if (channel == 6)
+			oct = 0;
 		freq = _freqTable[note % 12];
 		OPLWriteReg(_opl, 0xA0 | channel, freq);
-		freq = ((note / 12) << 2) | ((freq & 0x300) >> 8);
+		freq = (oct << 2) | ((freq & 0x300) >> 8);
 		if (ins->mode == 0) {
 			freq |= 0x20;
 		}
@@ -543,14 +556,16 @@ void AdLibSoundDriverADL::setChannelFrequency(int channel, int frequency) {
 	findNote(frequency, &note, &oct);
 	if (ins->amDepth) {
 		note = ins->amDepth;
+		oct = note / 12;
 	}
 	if (note < 0) {
 		note = 0;
+		oct = 0;
 	}
 
 	freq = _freqTable[note % 12];
 	OPLWriteReg(_opl, 0xA0 | channel, freq);
-	freq = ((note / 12) << 2) | ((freq & 0x300) >> 8);
+	freq = (oct << 2) | ((freq & 0x300) >> 8);
 	if (ins->mode == 0) {
 		freq |= 0x20;
 	}






More information about the Scummvm-git-logs mailing list