[Scummvm-git-logs] scummvm master -> 8b2b97321680695746f52838dab630e4b06e0abf

bluegr noreply at scummvm.org
Tue Jun 24 10:52:44 UTC 2025


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

Summary:
8b2b973216 AGI: add PCjr sound chip variant to game settings


Commit: 8b2b97321680695746f52838dab630e4b06e0abf
    https://github.com/scummvm/scummvm/commit/8b2b97321680695746f52838dab630e4b06e0abf
Author: Sinus (sinus-github at sinpi.net)
Date: 2025-06-24T13:52:40+03:00

Commit Message:
AGI: add PCjr sound chip variant to game settings

The standard SN76489 sound chip found in PCjr machines uses a 15-bit
shift register for its periodic noise generator. When the noise channel
"borrows" a tone channel's frequency, it sounds awfully out of key.
Some SEGA consoles, however, use a version of the chip with a 16-bit
shift register, generating periodic noise with a resonant frequency
in key with the borrowed one, thus allowing for using the periodic noise
as a bass instrument. On a 15-bit shifting chip, using noise for music
can only be achieved by premultiplying all the borrowed frequencies by
15/16ths, a workaround not entirely convenient.

With PCjr noise set to 16 bits, the chip emulation is set to generate properly
resonant noise.

This option has been added to the settings of fan-made games

Changed paths:
    engines/agi/detection.h
    engines/agi/detection_tables.h
    engines/agi/metaengine.cpp
    engines/agi/sound_pcjr.cpp
    engines/agi/sound_pcjr.h


diff --git a/engines/agi/detection.h b/engines/agi/detection.h
index d1d7f7a53ba..d9c26bdbd36 100644
--- a/engines/agi/detection.h
+++ b/engines/agi/detection.h
@@ -45,6 +45,7 @@ struct AGIGameDescription {
 #define GAMEOPTION_APPLE2GS_ADD_SPEED_MENU     GUIO_GAMEOPTIONS6
 #define GAMEOPTION_COPY_PROTECTION             GUIO_GAMEOPTIONS7
 #define GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE GUIO_GAMEOPTIONS8
+#define GAMEOPTION_PCJR_SN76496_16BIT          GUIO_GAMEOPTIONS9
 
 } // End of namespace Agi
 
diff --git a/engines/agi/detection_tables.h b/engines/agi/detection_tables.h
index f84a1e2cb2f..8adbaac62e6 100644
--- a/engines/agi/detection_tables.h
+++ b/engines/agi/detection_tables.h
@@ -30,8 +30,8 @@ namespace Agi {
 #define GAMEOPTIONS_APPLE2GS                  GUIO6(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_MOUSE,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW, GAMEOPTION_APPLE2GS_ADD_SPEED_MENU)
 #define GAMEOPTIONS_APPLE2GS_CP               GUIO7(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_MOUSE,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW, GAMEOPTION_APPLE2GS_ADD_SPEED_MENU, GAMEOPTION_COPY_PROTECTION)
 #define GAMEOPTIONS_VGA                       GUIO6(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_MOUSE,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW,GUIO_RENDERVGA)
-#define GAMEOPTIONS_FANMADE_MOUSE             GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW)
-#define GAMEOPTIONS_FANMADE_MOUSE_VGA         GUIO5(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW,GUIO_RENDERVGA)
+#define GAMEOPTIONS_FANMADE_MOUSE             GUIO5(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW,GAMEOPTION_PCJR_SN76496_16BIT)
+#define GAMEOPTIONS_FANMADE_MOUSE_VGA         GUIO6(GAMEOPTION_ORIGINAL_SAVELOAD,GAMEOPTION_ENABLE_PREDICTIVE_FOR_MOUSE,GAMEOPTION_USE_HERCULES_FONT,GAMEOPTION_COMMAND_PROMPT_WINDOW,GAMEOPTION_PCJR_SN76496_16BIT,GUIO_RENDERVGA)
 
 #define GAME_LVFPN(id,extra,fname,md5,size,lang,ver,features,gid,platform,interp,guioptions) { \
 		{ \
diff --git a/engines/agi/metaengine.cpp b/engines/agi/metaengine.cpp
index 00f4cc9d5f9..e0651f9522a 100644
--- a/engines/agi/metaengine.cpp
+++ b/engines/agi/metaengine.cpp
@@ -201,6 +201,18 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 		}
 	},
 
+	{
+		GAMEOPTION_PCJR_SN76496_16BIT,
+		{
+			_s("Use PCjr's sound chip in 16-bit shift mode"),
+			_s("In PCjr sound mode, emulate a non-standard SN76496 sound chip, similar to chips found in SEGA Master System consoles. Allows certain music effects, especially in fanmade games, but original Sierra music designed strictly for PCjr may sound wrong."),
+			"pcjr_16bitnoise",
+			false,
+			0,
+			0
+		}
+	},
+
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
diff --git a/engines/agi/sound_pcjr.cpp b/engines/agi/sound_pcjr.cpp
index 5f1bbbf6636..85d77abf54c 100644
--- a/engines/agi/sound_pcjr.cpp
+++ b/engines/agi/sound_pcjr.cpp
@@ -57,6 +57,7 @@
 #include "agi/agi.h"
 #include "agi/sound.h"
 #include "agi/sound_pcjr.h"
+#include "common/config-manager.h"
 
 namespace Agi {
 
@@ -101,7 +102,6 @@ const int8 dissolveDataV3[] = {
 	-100
 };
 
-
 SoundGenPCJr::SoundGenPCJr(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
 	_chanAllocated = 10240; // preallocate something which will most likely fit
 	_chanData = (int16 *)malloc(_chanAllocated << 1);
@@ -120,6 +120,11 @@ SoundGenPCJr::SoundGenPCJr(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMi
 	else
 		_dissolveMethod = 0;
 
+	if (ConfMan.getBool("pcjr_16bitnoise"))
+		_periodicNoiseMask = 0x10000; // non-standard, SEGA-like 16-bit periodic noise mask
+	else
+		_periodicNoiseMask = 0x08000; // default 15-bit periodic noise mask
+
 	memset(_channel, 0, sizeof(_channel));
 	memset(_tchannel, 0, sizeof(_tchannel));
 
@@ -387,7 +392,7 @@ void SoundGenPCJr::writeData(uint8 val) {
 // noise feedback for periodic noise mode
 // it is correct maybe (it was in the Megadrive sound manual)
 //#define FB_PNOISE 0x10000 // 16bit rorate
-#define FB_PNOISE 0x08000
+//#define FB_PNOISE 0x08000
 
 // noise generator start preset (for periodic noise)
 #define NG_PRESET 0x0f35
@@ -518,7 +523,7 @@ int SoundGenPCJr::fillNoise(ToneChan *t, int16 *buf, int len) {
 		t->count = t->scale;
 		t->freqCountPrev = t->freqCount;
 
-		t->feedback = (t->genType == kGenWhite) ? FB_WNOISE : FB_PNOISE;
+		t->feedback = (t->genType == kGenWhite) ? FB_WNOISE : _periodicNoiseMask;
 		// reset noise shifter
 		t->noiseState = NG_PRESET;
 		t->sign = t->noiseState & 1;
diff --git a/engines/agi/sound_pcjr.h b/engines/agi/sound_pcjr.h
index b5bc203d4c5..2164f155288 100644
--- a/engines/agi/sound_pcjr.h
+++ b/engines/agi/sound_pcjr.h
@@ -116,6 +116,7 @@ private:
 	int _chanAllocated;
 
 	int _dissolveMethod;
+	int32 _periodicNoiseMask;
 
 	uint8 *_v1data;
 	uint32 _v1size;




More information about the Scummvm-git-logs mailing list