[Scummvm-git-logs] scummvm master -> 29923889d9deb6213e73fbd2e9aa8a78ff0b910e

bluegr noreply at scummvm.org
Sat Nov 26 21:06:25 UTC 2022


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

Summary:
99485ac757 AUDIO: Backport commit r3523 from DOSBox to the CMS emulator
29923889d9 AUDIO: Backport commit r4010 from DOSBox to the CMS emulator


Commit: 99485ac757cf0ab407db6f4b513e30b884ca3673
    https://github.com/scummvm/scummvm/commit/99485ac757cf0ab407db6f4b513e30b884ca3673
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-26T23:06:21+02:00

Commit Message:
AUDIO: Backport commit r3523 from DOSBox to the CMS emulator

CMS/Gameblaster: add sbtype=gb, fix base addresses other than 220h, fix lack of sound when starting from autoexec, add autodetection (Thanks robertmo and Cloudschatze)

Changed paths:
    audio/softsynth/cms.cpp
    audio/softsynth/cms.h


diff --git a/audio/softsynth/cms.cpp b/audio/softsynth/cms.cpp
index 1c390153270..ef5e383eaca 100644
--- a/audio/softsynth/cms.cpp
+++ b/audio/softsynth/cms.cpp
@@ -82,35 +82,21 @@ static const int amplitude_lookup[16] = {
 };
 
 void CMSEmulator::portWrite(int port, int val) {
-	switch (port) {
-	case 0x220:
-		portWriteIntern(0, 1, val);
+	switch (port-_basePort) {
+	case 0:
+		portWriteIntern(0, 0, val);
 		break;
 
-	case 0x221:
-		_saa1099[0].selected_reg = val & 0x1f;
-		if (_saa1099[0].selected_reg == 0x18 || _saa1099[0].selected_reg == 0x19) {
-			/* clock the envelope channels */
-			if (_saa1099[0].env_clock[0])
-				envelope(0, 0);
-			if (_saa1099[0].env_clock[1])
-				envelope(0, 1);
-		}
+	case 1:
+		portWriteIntern(0, 1, val);
 		break;
 
-	case 0x222:
-		portWriteIntern(1, 1, val);
+	case 2:
+		portWriteIntern(1, 0, val);
 		break;
 
-	case 0x223:
-		_saa1099[1].selected_reg = val & 0x1f;
-		if (_saa1099[1].selected_reg == 0x18 || _saa1099[1].selected_reg == 0x19) {
-			/* clock the envelope channels */
-			if (_saa1099[1].env_clock[0])
-				envelope(1, 0);
-			if (_saa1099[1].env_clock[1])
-				envelope(1, 1);
-		}
+	case 3:
+		portWriteIntern(1, 1, val);
 		break;
 
 	default:
@@ -252,6 +238,18 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
 
 void CMSEmulator::portWriteIntern(int chip, int offset, int data) {
 	SAA1099 *saa = &_saa1099[chip];
+	if(offset == 1) {
+		// address port
+		saa->selected_reg = data & 0x1f;
+		if (saa->selected_reg == 0x18 || saa->selected_reg == 0x19) {
+			/* clock the envelope channels */
+			if (saa->env_clock[0])
+				envelope(chip,0);
+			if (saa->env_clock[1])
+				envelope(chip,1);
+		}
+		return;
+	}
 	int reg = saa->selected_reg;
 	int ch;
 
diff --git a/audio/softsynth/cms.h b/audio/softsynth/cms.h
index 950c272b6c2..52743bab8f9 100644
--- a/audio/softsynth/cms.h
+++ b/audio/softsynth/cms.h
@@ -66,11 +66,12 @@ struct SAA1099 {
 
 class CMSEmulator {
 public:
-	CMSEmulator(uint32 sampleRate) {
+	CMSEmulator(uint32 sampleRate, uint32 basePort = 0x220) {
 		// In PCs the chips run at 7.15909 MHz instead of 8 MHz.
 		// Adjust sampling rate upwards to bring pitch down.
 		_sampleRate = (sampleRate * 352) / 315;
 		memset(_saa1099, 0, sizeof(SAA1099)*2);
+		_basePort = basePort;
 	}
 
 	~CMSEmulator() { }
@@ -81,6 +82,7 @@ public:
 
 private:
 	uint32 _sampleRate;
+	uint32 _basePort;
 
 	SAA1099 _saa1099[2];
 


Commit: 29923889d9deb6213e73fbd2e9aa8a78ff0b910e
    https://github.com/scummvm/scummvm/commit/29923889d9deb6213e73fbd2e9aa8a78ff0b910e
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-26T23:06:21+02:00

Commit Message:
AUDIO: Backport commit r4010 from DOSBox to the CMS emulator

Correct oscillator frequency used in the gameblaster. Thanks OPLx, Great Hierophant and NewRisingSun. Reported on VOGONS: 38350.

Changed paths:
    audio/softsynth/cms.cpp
    audio/softsynth/cms.h


diff --git a/audio/softsynth/cms.cpp b/audio/softsynth/cms.cpp
index ef5e383eaca..cf13456cba0 100644
--- a/audio/softsynth/cms.cpp
+++ b/audio/softsynth/cms.cpp
@@ -30,6 +30,8 @@
 
 #define LEFT	0x00
 #define RIGHT	0x01
+/*#define MASTER_CLOCK 14318180/2 */
+#define MASTER_CLOCK 7159090
 
 static const byte envelope[8][64] = {
 	/* zero amplitude */
@@ -164,9 +166,9 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
 
 	for (ch = 0; ch < 2; ch++) {
 		switch (saa->noise_params[ch]) {
-		case 0: saa->noise[ch].freq = 31250.0 * 2; break;
-		case 1: saa->noise[ch].freq = 15625.0 * 2; break;
-		case 2: saa->noise[ch].freq =  7812.5 * 2; break;
+		case 0: saa->noise[ch].freq = MASTER_CLOCK/256  * 2; break;
+		case 1: saa->noise[ch].freq = MASTER_CLOCK/512  * 2; break;
+		case 2: saa->noise[ch].freq = MASTER_CLOCK/1024 * 2; break;
 		case 3: saa->noise[ch].freq = saa->channels[ch * 3].freq; break;
 		default: break;
 		}
@@ -179,14 +181,14 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
 		/* for each channel */
 		for (ch = 0; ch < 6; ch++) {
 			if (saa->channels[ch].freq == 0.0)
-				saa->channels[ch].freq = (double)((2 * 15625) << saa->channels[ch].octave) /
-				(511.0 - (double)saa->channels[ch].frequency);
+				saa->channels[ch].freq = (double)((2 * MASTER_CLOCK/512) << saa->channels[ch].octave) /
+					(511.0 - (double)saa->channels[ch].frequency);
 
 			/* check the actual position in the square wave */
 			saa->channels[ch].counter -= saa->channels[ch].freq;
 			while (saa->channels[ch].counter < 0) {
 				/* calculate new frequency now after the half wave is updated */
-				saa->channels[ch].freq = (double)((2 * 15625) << saa->channels[ch].octave) /
+				saa->channels[ch].freq = (double)((2 * MASTER_CLOCK/512) << saa->channels[ch].octave) /
 					(511.0 - (double)saa->channels[ch].frequency);
 
 				saa->channels[ch].counter += _sampleRate;
diff --git a/audio/softsynth/cms.h b/audio/softsynth/cms.h
index 52743bab8f9..4a956d303d7 100644
--- a/audio/softsynth/cms.h
+++ b/audio/softsynth/cms.h
@@ -67,9 +67,7 @@ struct SAA1099 {
 class CMSEmulator {
 public:
 	CMSEmulator(uint32 sampleRate, uint32 basePort = 0x220) {
-		// In PCs the chips run at 7.15909 MHz instead of 8 MHz.
-		// Adjust sampling rate upwards to bring pitch down.
-		_sampleRate = (sampleRate * 352) / 315;
+		_sampleRate = sampleRate;
 		memset(_saa1099, 0, sizeof(SAA1099)*2);
 		_basePort = basePort;
 	}




More information about the Scummvm-git-logs mailing list