[Scummvm-cvs-logs] scummvm master -> 3635efd92cdc48661abd23780520626a12be09d4

lordhoto lordhoto at gmail.com
Wed Aug 10 00:05:39 CEST 2011


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

Summary:
37a34e6da2 SCUMM: Do not pack structs in CMS code.
74560278b2 SCUMM: Change CMS sfx methods to use its own register set.
b95bbb2ace CMS: Do proper clipping of the sound data on generation.
3635efd92c CMS: Simplify code a tiny bit.


Commit: 37a34e6da26fff8c5b0298874b9e3e26dcb34b29
    https://github.com/scummvm/scummvm/commit/37a34e6da26fff8c5b0298874b9e3e26dcb34b29
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-08-09T15:00:06-07:00

Commit Message:
SCUMM: Do not pack structs in CMS code.

Changed paths:
    engines/scumm/player_v2cms.h



diff --git a/engines/scumm/player_v2cms.h b/engines/scumm/player_v2cms.h
index cbad46f..29444b1 100644
--- a/engines/scumm/player_v2cms.h
+++ b/engines/scumm/player_v2cms.h
@@ -50,7 +50,6 @@ public:
 	virtual bool isStereo() const { return true; }
 
 private:
-#include "common/pack-start.h"	// START STRUCT PACKING
 	struct Voice {
 		byte attack;
 		byte decay;
@@ -60,7 +59,7 @@ private:
 		int16 vibrato;
 		int16 vibrato2;
 		int16 noise;
-	} PACKED_STRUCT;
+	};
 
 	struct Voice2 {
 		byte *amplitudeOutput;
@@ -105,14 +104,13 @@ private:
 		Voice2 *nextVoice;
 
 		byte chanNumber;
-	} PACKED_STRUCT;
+	};
 
 	struct MusicChip {
 		byte ampl[4];
 		byte freq[4];
 		byte octave[2];
-	} PACKED_STRUCT;
-#include "common/pack-end.h"	// END STRUCT PACKING
+	};
 
 	Voice _cmsVoicesBase[16];
 	Voice2 _cmsVoices[8];


Commit: 74560278b2d7d14f459bafc7d5eed63bc6a363b0
    https://github.com/scummvm/scummvm/commit/74560278b2d7d14f459bafc7d5eed63bc6a363b0
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-08-09T15:00:12-07:00

Commit Message:
SCUMM: Change CMS sfx methods to use its own register set.

This is now like in the original and helps comparing register writes against
DOSBox's behavior.

Changed paths:
    engines/scumm/player_v2cms.cpp
    engines/scumm/player_v2cms.h



diff --git a/engines/scumm/player_v2cms.cpp b/engines/scumm/player_v2cms.cpp
index d16f9d2..d4b2177 100644
--- a/engines/scumm/player_v2cms.cpp
+++ b/engines/scumm/player_v2cms.cpp
@@ -36,6 +36,10 @@ Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer)
 	  _outputTableReady(0), _midiChannel(), _midiChannelUse() {
 	setMusicVolume(255);
 
+	memset(_sfxFreq, 0xFF, sizeof(_sfxFreq));
+	memset(_sfxAmpl, 0x00, sizeof(_sfxAmpl));
+	memset(_sfxOctave, 0x66, sizeof(_sfxOctave));
+
 	_cmsVoices[0].amplitudeOutput = &_cmsChips[0].ampl[0];
 	_cmsVoices[0].freqOutput = &_cmsChips[0].freq[0];
 	_cmsVoices[0].octaveOutput = &_cmsChips[0].octave[0];
@@ -596,7 +600,6 @@ void Player_V2CMS::play() {
 	_octaveMask = 0xF0;
 	channel_data *chan = &_channels[0].d;
 
-	MusicChip &cms = _cmsChips[0];
 	byte noiseGen = 3;
 
 	for (int i = 1; i <= 4; ++i) {
@@ -608,8 +611,8 @@ void Player_V2CMS::play() {
 					noiseGen = freq & 0xFF;
 				} else {
 					noiseGen = 3;
-					cms.freq[0] = cms.freq[3];
-					cms.octave[0] = (cms.octave[0] & 0xF0) | ((cms.octave[1] & 0xF0) >> 4);
+					_sfxFreq[0] = _sfxFreq[3];
+					_sfxOctave[0] = (_sfxOctave[0] & 0xF0) | ((_sfxOctave[1] & 0xF0) >> 4);
 				}
 			} else {
 				if (freq == 0) {
@@ -635,15 +638,15 @@ void Player_V2CMS::play() {
 				oct |= cmsOct;
 
 				oct &= _octaveMask;
-				oct |= (~_octaveMask) & cms.octave[(i & 3) >> 1];
-				cms.octave[(i & 3) >> 1] = oct;
+				oct |= (~_octaveMask) & _sfxOctave[(i & 3) >> 1];
+				_sfxOctave[(i & 3) >> 1] = oct;
 
 				freq >>= -(cmsOct - 9);
-				cms.freq[i & 3] = (-(freq - 511)) & 0xFF;
+				_sfxFreq[i & 3] = (-(freq - 511)) & 0xFF;
 			}
-			cms.ampl[i & 3] = _volumeTable[chan->volume >> 12];
+			_sfxAmpl[i & 3] = _volumeTable[chan->volume >> 12];
 		} else {
-			cms.ampl[i & 3] = 0;
+			_sfxAmpl[i & 3] = 0;
 		}
 
 		chan = &_channels[i].d;
@@ -654,25 +657,25 @@ void Player_V2CMS::play() {
 	// the right channels amplitude is set
 	// with the low value the left channels amplitude
 	_cmsEmu->portWrite(0x221, 0);
-	_cmsEmu->portWrite(0x220, cms.ampl[0]);
+	_cmsEmu->portWrite(0x220, _sfxAmpl[0]);
 	_cmsEmu->portWrite(0x221, 1);
-	_cmsEmu->portWrite(0x220, cms.ampl[1]);
+	_cmsEmu->portWrite(0x220, _sfxAmpl[1]);
 	_cmsEmu->portWrite(0x221, 2);
-	_cmsEmu->portWrite(0x220, cms.ampl[2]);
+	_cmsEmu->portWrite(0x220, _sfxAmpl[2]);
 	_cmsEmu->portWrite(0x221, 3);
-	_cmsEmu->portWrite(0x220, cms.ampl[3]);
+	_cmsEmu->portWrite(0x220, _sfxAmpl[3]);
 	_cmsEmu->portWrite(0x221, 8);
-	_cmsEmu->portWrite(0x220, cms.freq[0]);
+	_cmsEmu->portWrite(0x220, _sfxFreq[0]);
 	_cmsEmu->portWrite(0x221, 9);
-	_cmsEmu->portWrite(0x220, cms.freq[1]);
+	_cmsEmu->portWrite(0x220, _sfxFreq[1]);
 	_cmsEmu->portWrite(0x221, 10);
-	_cmsEmu->portWrite(0x220, cms.freq[2]);
+	_cmsEmu->portWrite(0x220, _sfxFreq[2]);
 	_cmsEmu->portWrite(0x221, 11);
-	_cmsEmu->portWrite(0x220, cms.freq[3]);
+	_cmsEmu->portWrite(0x220, _sfxFreq[3]);
 	_cmsEmu->portWrite(0x221, 0x10);
-	_cmsEmu->portWrite(0x220, cms.octave[0]);
+	_cmsEmu->portWrite(0x220, _sfxOctave[0]);
 	_cmsEmu->portWrite(0x221, 0x11);
-	_cmsEmu->portWrite(0x220, cms.octave[1]);
+	_cmsEmu->portWrite(0x220, _sfxOctave[1]);
 	_cmsEmu->portWrite(0x221, 0x14);
 	_cmsEmu->portWrite(0x220, 0x3E);
 	_cmsEmu->portWrite(0x221, 0x15);
diff --git a/engines/scumm/player_v2cms.h b/engines/scumm/player_v2cms.h
index 29444b1..905c7c1 100644
--- a/engines/scumm/player_v2cms.h
+++ b/engines/scumm/player_v2cms.h
@@ -128,6 +128,8 @@ private:
 
 	int _loadedMidiSong;
 
+	byte _sfxFreq[4], _sfxAmpl[4], _sfxOctave[2];
+
 	byte _lastMidiCommand;
 	uint _outputTableReady;
 	byte _voiceTimer;


Commit: b95bbb2ace6a240da8b6ee54ceb66c6ab2484ab7
    https://github.com/scummvm/scummvm/commit/b95bbb2ace6a240da8b6ee54ceb66c6ab2484ab7
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-08-09T15:00:12-07:00

Commit Message:
CMS: Do proper clipping of the sound data on generation.

This fixes some overflows/underflows which resulted in crackling.

Changed paths:
    audio/softsynth/cms.cpp



diff --git a/audio/softsynth/cms.cpp b/audio/softsynth/cms.cpp
index 67eacd1..889f19a 100644
--- a/audio/softsynth/cms.cpp
+++ b/audio/softsynth/cms.cpp
@@ -244,8 +244,8 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
 			}
 		}
 		/* write sound data to the buffer */
-		buffer[j*2] += output_l / 6;
-		buffer[j*2+1] += output_r / 6;
+		buffer[j*2+0] = CLIP<int>(buffer[j*2+0] + output_l / 6, -32768, 32767);
+		buffer[j*2+1] = CLIP<int>(buffer[j*2+1] + output_r / 6, -32768, 32767);
 	}
 }
 


Commit: 3635efd92cdc48661abd23780520626a12be09d4
    https://github.com/scummvm/scummvm/commit/3635efd92cdc48661abd23780520626a12be09d4
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-08-09T15:00:12-07:00

Commit Message:
CMS: Simplify code a tiny bit.

Changed paths:
    audio/softsynth/cms.cpp



diff --git a/audio/softsynth/cms.cpp b/audio/softsynth/cms.cpp
index 889f19a..a675da3 100644
--- a/audio/softsynth/cms.cpp
+++ b/audio/softsynth/cms.cpp
@@ -163,19 +163,15 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
 	struct SAA1099 *saa = &_saa1099[chip];
 	int j, ch;
 
+	if (chip == 0) {
+		memset(buffer, 0, sizeof(int16)*length*2);
+	}
+
 	/* if the channels are disabled we're done */
 	if (!saa->all_ch_enable) {
-		/* init output data */
-		if (chip == 0) {
-			memset(buffer, 0, sizeof(int16)*length*2);
-		}
 		return;
 	}
 
-	if (chip == 0) {
-		memset(buffer, 0, sizeof(int16)*length*2);
-	}
-
 	for (ch = 0; ch < 2; ch++) {
 		switch (saa->noise_params[ch]) {
 		case 0: saa->noise[ch].freq = 31250.0 * 2; break;






More information about the Scummvm-git-logs mailing list