Skip to content

Instantly share code, notes, and snippets.

@neuromancer
Last active April 7, 2022 16:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neuromancer/193b6cfc5cdc0a0977d3b81edc5a8796 to your computer and use it in GitHub Desktop.
Save neuromancer/193b6cfc5cdc0a0977d3b81edc5a8796 to your computer and use it in GitHub Desktop.
A patch to combine the best of Loom PC CD (“talkie” release) and FM-Towns (background music)
diff --git a/backends/audiocd/default/default-audiocd.cpp b/backends/audiocd/default/default-audiocd.cpp
index 003060c..3108983 100644
--- a/backends/audiocd/default/default-audiocd.cpp
+++ b/backends/audiocd/default/default-audiocd.cpp
@@ -24,6 +24,8 @@
#include "audio/audiostream.h"
#include "common/config-manager.h"
#include "common/system.h"
+#include "common/textconsole.h"
+
DefaultAudioCDManager::DefaultAudioCDManager() {
_cd.playing = false;
@@ -56,7 +58,8 @@ void DefaultAudioCDManager::close() {
bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate,
Audio::Mixer::SoundType soundType) {
- stop();
+
+ //stop();
if (numLoops != 0 || startFrame != 0) {
_cd.track = track;
@@ -87,6 +90,8 @@ bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int du
_emulating = true;
_mixer->playStream(soundType, &_handle,
Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance);
+ if (_cd.volume < 255)
+ _cd.volume = 255;
return true;
}
}
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 9c5271e..398d3ab 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -545,6 +545,16 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
if (_game.id == GID_CMI)
mainmenuKeyEnabled = true;
+ if (_game.id == GID_LOOM && lastKeyHit.keycode >= Common::KEYCODE_1 && lastKeyHit.keycode <= Common::KEYCODE_9 && lastKeyHit.hasFlags(0)) {
+ int track = lastKeyHit.keycode - Common::KEYCODE_1 + 2;
+ _sound->setVolumeCDTrack(64);
+ _sound->playCDTrack(track, 1, 0, 0);
+ }
+ if (_game.id == GID_LOOM && lastKeyHit.keycode == Common::KEYCODE_0 && lastKeyHit.hasFlags(0)) {
+ _sound->stopCD();
+ }
+
+
if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(0))) {
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0);
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index c90b13c..98fc8cc 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -1059,6 +1059,10 @@ void Sound::stopCDTimer() {
_vm->getTimerManager()->removeTimerProc(&cd_timer_handler);
}
+void Sound::setVolumeCDTrack(byte volume) {
+ g_system->getAudioCDManager()->setVolume(volume);
+}
+
void Sound::playCDTrack(int track, int numLoops, int startFrame, int duration) {
// Reset the music timer variable at the start of a new track
_vm->VAR(_vm->VAR_MUSIC_TIMER) = 0;
diff --git a/engines/scumm/sound.h b/engines/scumm/sound.h
index 740420e..15e2e0b 100644
--- a/engines/scumm/sound.h
+++ b/engines/scumm/sound.h
@@ -125,6 +125,8 @@ public:
void stopCDTimer();
void playCDTrack(int track, int numLoops, int startFrame, int duration);
+ void setVolumeCDTrack(byte volume);
+
void playCDTrackInternal(int track, int numLoops, int startFrame, int duration);
void stopCD();
int pollCD() const;
@leshokunin
Copy link

As people mentioned on Reddit:

  • "FM-Towns is the best version since all cutscenes/dialogues are there. It just has some worse backgrounds here and there, not a big thing."
  • "To get the best version we need the opposite, adding voices to the FMTowns version."

What do you think of that?

@neuromancer
Copy link
Author

I agree that the FMTowns versions is better in the sense of cutscenes/dialogues. But, I believe it is nearly impossible to add the voices into the FMTowns version: it requires to look for every piece of dialog and assign the right sound to it, manually. Moreover, the dialog lines in the two versions are different, so they cannot be synced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment