aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Hoenicke2003-06-01 16:42:29 +0000
committerJochen Hoenicke2003-06-01 16:42:29 +0000
commitff5705b32c70406db97e64142472ae806f4b8413 (patch)
tree9b51d0b0311b4d1023964eadf3d2854ec8c27b39
parent3733667aa56ed50d1efea0734181e5c5b40a80b3 (diff)
downloadscummvm-rg350-ff5705b32c70406db97e64142472ae806f4b8413.tar.gz
scummvm-rg350-ff5705b32c70406db97e64142472ae806f4b8413.tar.bz2
scummvm-rg350-ff5705b32c70406db97e64142472ae806f4b8413.zip
Added VAR_MUSIC_TIMER support to playerV2. Now Zak intro is synchronized.
svn-id: r8245
-rw-r--r--scumm/player_v2.cpp18
-rw-r--r--scumm/player_v2.h8
-rw-r--r--scumm/scummvm.cpp6
3 files changed, 21 insertions, 11 deletions
diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp
index 8943bb1b88..37b5842b6a 100644
--- a/scumm/player_v2.cpp
+++ b/scumm/player_v2.cpp
@@ -21,6 +21,7 @@
#include "stdafx.h"
#include "common/engine.h"
#include "player_v2.h"
+#include "scumm.h"
#define FREQ_HZ 236 // Don't change!
@@ -326,13 +327,13 @@ static const uint16 pcjr_freq_table[12] = {
////////////////////////////////////////
-Player_V2::Player_V2() {
+Player_V2::Player_V2(Scumm *scumm) : _scumm(scumm) {
int i;
// This simulates the pc speaker sound, which is driven
// by the 8253 (square wave generator) and a low-band filter.
- _system = g_system;
+ _system = scumm->_system;
_sample_rate = _system->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
_mutex = _system->create_mutex();
@@ -355,14 +356,13 @@ Player_V2::Player_V2() {
set_pcjr(true);
set_master_volume(255);
- _mixer = g_mixer;
- _mixer->setupPremix(this, premix_proc);
+ scumm->_mixer->setupPremix(this, premix_proc);
}
Player_V2::~Player_V2() {
mutex_up();
// Detach the premix callback handler
- _mixer->setupPremix (0, 0);
+ _scumm->_mixer->setupPremix (0, 0);
mutex_down();
_system->delete_mutex (_mutex);
}
@@ -548,6 +548,10 @@ void Player_V2::clear_channel(int i) {
channel->d.freqmod_modulo = 0;
}
+int Player_V2::getMusicTimer() {
+ return channels[0].d.music_timer;
+}
+
void Player_V2::execute_cmd(ChannelInfo *channel) {
uint16 value;
int16 offset;
@@ -810,8 +814,8 @@ void Player_V2::do_mix (int16 *data, int len) {
void Player_V2::lowPassFilter(int16 *sample, int len) {
for (int i = 0; i < len; i++) {
- _level = ((int)_level * _decay
- + (int)sample[i] * (0x10000-_decay)) >> 16;
+ _level = (_level * _decay
+ + (unsigned int)sample[i] * (0x10000-_decay)) >> 16;
sample[i] = _level;
}
}
diff --git a/scumm/player_v2.h b/scumm/player_v2.h
index 19558ba743..2ffcc3dc33 100644
--- a/scumm/player_v2.h
+++ b/scumm/player_v2.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "sound/mixer.h"
+class Scumm;
struct channel_data {
uint16 time_left; // 00
@@ -46,7 +47,8 @@ struct channel_data {
uint16 freqmod_incr; // 32
uint16 freqmod_multiplier; // 34
uint16 freqmod_modulo; // 36
- uint16 unknown[5]; // 38 - 46
+ uint16 unknown[4]; // 38 - 44
+ uint16 music_timer; // 46
uint16 music_script_nr; // 48
} GCC_PACK;
@@ -59,7 +61,7 @@ union ChannelInfo {
class Player_V2 {
public:
- Player_V2();
+ Player_V2(Scumm *scumm);
~Player_V2();
void set_pcjr(bool pcjr);
@@ -69,9 +71,11 @@ public:
void stopSound(int nr);
void stopAllSounds();
int getSoundStatus(int nr);
+ int getMusicTimer();
private:
SoundMixer *_mixer;
+ Scumm *_scumm;
bool _pcjr;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 2e4e2f47ae..c171c16a08 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -602,10 +602,10 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_imuseDigital = new IMuseDigital(this);
_imuse = NULL;
_playerV2 = NULL;
- } else if (_features & GF_OLD_BUNDLE && !(_features & GF_AMIGA)) {
+ } else if ((_features & GF_OLD_BUNDLE) && !(_features & GF_AMIGA)) {
_playerV2 = NULL;
if (!(_features & GF_AMIGA))
- _playerV2 = new Player_V2();
+ _playerV2 = new Player_V2(this);
_imuse = NULL;
_imuseDigital = NULL;
} else {
@@ -923,6 +923,8 @@ int Scumm::scummLoop(int delta) {
if (_features & GF_AUDIOTRACKS) {
// Covered automatically by the Sound class
+ } else if (_playerV2) {
+ VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer();
} else if (_features & GF_SMALL_HEADER) {
// TODO: The music delay (given in milliseconds) might have to be tuned a little
// to get it correct for all games. Without the ability to watch/listen to the