aboutsummaryrefslogtreecommitdiff
path: root/engines/queen
diff options
context:
space:
mode:
authorGregory Montoir2007-03-08 22:15:20 +0000
committerGregory Montoir2007-03-08 22:15:20 +0000
commita3c2c1f413049fd9d0e92f89b37b37755b6b5105 (patch)
tree2699e8e18350ccdb49ea2f005316f7f97900b9fc /engines/queen
parent801771db87bdb1298652d19291b6a658f3fdd6b6 (diff)
downloadscummvm-rg350-a3c2c1f413049fd9d0e92f89b37b37755b6b5105.tar.gz
scummvm-rg350-a3c2c1f413049fd9d0e92f89b37b37755b6b5105.tar.bz2
scummvm-rg350-a3c2c1f413049fd9d0e92f89b37b37755b6b5105.zip
Since the amiga version handle music very differently than the PC version, the existing Music and MusicPlayer classes have been merged to a single MidiMusic class, simplifying code a bit.
svn-id: r26033
Diffstat (limited to 'engines/queen')
-rw-r--r--engines/queen/journal.cpp2
-rw-r--r--engines/queen/logic.cpp2
-rw-r--r--engines/queen/music.cpp74
-rw-r--r--engines/queen/music.h30
-rw-r--r--engines/queen/queen.cpp2
-rw-r--r--engines/queen/sound.cpp4
-rw-r--r--engines/queen/sound.h6
7 files changed, 46 insertions, 74 deletions
diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp
index 3107f8ea6b..82a2a5e0b8 100644
--- a/engines/queen/journal.cpp
+++ b/engines/queen/journal.cpp
@@ -451,7 +451,7 @@ void Journal::drawConfigPanel() {
_vm->checkOptionSettings();
drawSlideBar(_vm->talkSpeed(), QueenEngine::MAX_TEXT_SPEED, BOB_TALK_SPEED, 164, FRAME_BLUE_PIN);
- drawSlideBar(_vm->sound()->volume(), QueenEngine::MAX_MUSIC_VOLUME, BOB_MUSIC_VOLUME, 177, FRAME_GREEN_PIN);
+ drawSlideBar(_vm->sound()->getVolume(), QueenEngine::MAX_MUSIC_VOLUME, BOB_MUSIC_VOLUME, 177, FRAME_GREEN_PIN);
drawCheckBox(_vm->sound()->sfxOn(), BOB_SFX_TOGGLE, 221, 155, FRAME_CHECK_BOX);
drawCheckBox(_vm->sound()->speechOn(), BOB_SPEECH_TOGGLE, 158, 155, FRAME_CHECK_BOX);
diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp
index 934b03bb9d..071f1778ba 100644
--- a/engines/queen/logic.cpp
+++ b/engines/queen/logic.cpp
@@ -655,7 +655,7 @@ void Logic::setupJoeInRoom(bool autoPosition, uint16 scale) {
if (_currentRoom == 108) {
_vm->graphics()->putCameraOnBob(-1);
- _vm->bankMan()->load("joe_e.act", 7);
+ _vm->bankMan()->load("JOE_E.ACT", 7);
_vm->bankMan()->unpack(2, 31, 7);
_vm->display()->horizontalScroll(320);
diff --git a/engines/queen/music.cpp b/engines/queen/music.cpp
index ccd7f9c86f..d00694dc4a 100644
--- a/engines/queen/music.cpp
+++ b/engines/queen/music.cpp
@@ -30,7 +30,8 @@
namespace Queen {
-MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _masterVolume(192), _queuePos(0), _musicData(data), _musicDataSize(size), _passThrough(false), _buf(0) {
+MidiMusic::MidiMusic(MidiDriver *driver, QueenEngine *vm)
+ : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _masterVolume(192), _queuePos(0), _passThrough(false), _buf(0) {
memset(_channel, 0, sizeof(_channel));
queueClear();
_lastSong = _currentSong = 0;
@@ -38,18 +39,21 @@ MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(
_parser->setMidiDriver(this);
_parser->setTimerRate(_driver->getBaseTempo());
+ const char *filename = vm->resource()->isDemo() ? "AQ8.RL" : "AQ.RL";
+ _musicData = vm->resource()->loadFile(filename, 0, &_musicDataSize);
_numSongs = READ_LE_UINT16(_musicData);
this->open();
}
-MusicPlayer::~MusicPlayer() {
+MidiMusic::~MidiMusic() {
_parser->unloadMusic();
delete _parser;
this->close();
delete[] _buf;
+ delete[] _musicData;
}
-void MusicPlayer::setVolume(int volume) {
+void MidiMusic::setVolume(int volume) {
if (volume < 0)
volume = 0;
else if (volume > 255)
@@ -66,7 +70,13 @@ void MusicPlayer::setVolume(int volume) {
}
}
-bool MusicPlayer::queueSong(uint16 songNum) {
+void MidiMusic::playSong(uint16 songNum) {
+ queueClear();
+ queueSong(songNum);
+ playMusic();
+}
+
+bool MidiMusic::queueSong(uint16 songNum) {
if (songNum >= _numSongs && songNum < 1000) {
// this happens at the end of the car chase, where we try to play song 176,
// see Sound::_tune[], entry 39
@@ -90,14 +100,14 @@ bool MusicPlayer::queueSong(uint16 songNum) {
return true;
}
-void MusicPlayer::queueClear() {
+void MidiMusic::queueClear() {
_lastSong = _songQueue[0];
_queuePos = 0;
_looping = _randomLoop = false;
memset(_songQueue, 0, sizeof(_songQueue));
}
-int MusicPlayer::open() {
+int MidiMusic::open() {
// Don't ever call open without first setting the output driver!
if (!_driver)
return 255;
@@ -109,14 +119,14 @@ int MusicPlayer::open() {
return 0;
}
-void MusicPlayer::close() {
+void MidiMusic::close() {
_driver->setTimerCallback(NULL, NULL);
if (_driver)
_driver->close();
_driver = 0;
}
-void MusicPlayer::send(uint32 b) {
+void MidiMusic::send(uint32 b) {
if (_passThrough) {
_driver->send(b);
return;
@@ -154,7 +164,7 @@ void MusicPlayer::send(uint32 b) {
_channel[channel]->send(b);
}
-void MusicPlayer::metaEvent(byte type, byte *data, uint16 length) {
+void MidiMusic::metaEvent(byte type, byte *data, uint16 length) {
//Only thing we care about is End of Track.
if (type != 0x2F)
return;
@@ -165,13 +175,13 @@ void MusicPlayer::metaEvent(byte type, byte *data, uint16 length) {
stopMusic();
}
-void MusicPlayer::onTimer(void *refCon) {
- MusicPlayer *music = (MusicPlayer *)refCon;
+void MidiMusic::onTimer(void *refCon) {
+ MidiMusic *music = (MidiMusic *)refCon;
if (music->_isPlaying)
music->_parser->onTimer();
}
-void MusicPlayer::queueTuneList(int16 tuneList) {
+void MidiMusic::queueTuneList(int16 tuneList) {
queueClear();
//Jungle is the only part of the game that uses multiple tunelists.
@@ -212,9 +222,9 @@ void MusicPlayer::queueTuneList(int16 tuneList) {
_queuePos = randomQueuePos();
}
-void MusicPlayer::playMusic() {
+void MidiMusic::playMusic() {
if (!_songQueue[0]) {
- debug(5, "MusicPlayer::playMusic - Music queue is empty");
+ debug(5, "MidiMusic::playMusic - Music queue is empty");
return;
}
@@ -276,7 +286,7 @@ void MusicPlayer::playMusic() {
queueUpdatePos();
}
-void MusicPlayer::queueUpdatePos() {
+void MidiMusic::queueUpdatePos() {
if (_randomLoop) {
_queuePos = randomQueuePos();
} else {
@@ -287,7 +297,7 @@ void MusicPlayer::queueUpdatePos() {
}
}
-uint8 MusicPlayer::randomQueuePos() {
+uint8 MidiMusic::randomQueuePos() {
int queueSize = 0;
for (int i = 0; i < MUSIC_QUEUE_SIZE; i++)
if (_songQueue[i])
@@ -299,46 +309,26 @@ uint8 MusicPlayer::randomQueuePos() {
return (uint8) _rnd.getRandomNumber(queueSize - 1) & 0xFF;
}
-void MusicPlayer::stopMusic() {
+void MidiMusic::stopMusic() {
_isPlaying = false;
_parser->unloadMusic();
}
-uint32 MusicPlayer::songOffset(uint16 songNum) const {
+uint32 MidiMusic::songOffset(uint16 songNum) const {
uint16 offsLo = READ_LE_UINT16(_musicData + (songNum * 4) + 2);
uint16 offsHi = READ_LE_UINT16(_musicData + (songNum * 4) + 4);
return (offsHi << 4) | offsLo;
}
-uint32 MusicPlayer::songLength(uint16 songNum) const {
+uint32 MidiMusic::songLength(uint16 songNum) const {
if (songNum < _numSongs)
return (songOffset(songNum + 1) - songOffset(songNum));
return (_musicDataSize - songOffset(songNum));
}
-Music::Music(MidiDriver *driver, QueenEngine *vm) : _vToggle(false) {
- if (vm->resource()->isDemo()) {
- _musicData = vm->resource()->loadFile("AQ8.RL", 0, &_musicDataSize);
- } else {
- _musicData = vm->resource()->loadFile("AQ.RL", 0, &_musicDataSize);
- }
- _player = new MusicPlayer(driver, _musicData, _musicDataSize);
-}
-
-Music::~Music() {
- delete _player;
- delete[] _musicData;
-}
-
-void Music::playSong(uint16 songNum) {
- _player->queueClear();
- _player->queueSong(songNum);
- _player->playMusic();
-}
-
-void Music::toggleVChange() {
- setVolume(_vToggle ? (volume() * 2) : (volume() / 2));
- _vToggle ^= true;
+void MidiMusic::toggleVChange() {
+ setVolume(_vToggle ? (getVolume() * 2) : (getVolume() / 2));
+ _vToggle = !_vToggle;
}
} // End of namespace Queen
diff --git a/engines/queen/music.h b/engines/queen/music.h
index 1112b1fe6c..0d0a845306 100644
--- a/engines/queen/music.h
+++ b/engines/queen/music.h
@@ -32,14 +32,16 @@ namespace Queen {
class QueenEngine;
-class MusicPlayer : public MidiDriver {
+class MidiMusic : public MidiDriver {
public:
- MusicPlayer(MidiDriver *driver, byte *data, uint32 size);
- ~MusicPlayer();
+ MidiMusic(MidiDriver *driver, QueenEngine *vm);
+ ~MidiMusic();
void setVolume(int volume);
int getVolume() { return _masterVolume; }
void hasNativeMT32(bool b) { _nativeMT32 = b; }
+ void playSong(uint16 songNum);
+ void stopSong() { stopMusic(); }
void playMusic();
void stopMusic();
void setLoop(bool loop) { _looping = loop; }
@@ -47,6 +49,7 @@ public:
bool queueSong(uint16 songNum);
void queueClear();
void setPassThrough(bool b) { _passThrough = b; }
+ void toggleVChange();
//MidiDriver interface implementation
int open();
@@ -93,31 +96,10 @@ protected:
int16 _songQueue[MUSIC_QUEUE_SIZE];
uint16 _numSongs;
- byte *_musicData;
uint16 *_buf;
uint32 _musicDataSize;
-};
-
-class Music {
-public:
- Music(MidiDriver *_driver, QueenEngine *vm);
- ~Music();
- void hasNativeMT32(bool b) { _player->hasNativeMT32(b); }
- void playSong(uint16 songNum);
- void queueTuneList(int16 tuneList) { _player->queueTuneList(tuneList); }
- void playMusic() { _player->playMusic(); }
- void stopSong() { _player->stopMusic(); }
- void setPassThrough(bool b) { _player->setPassThrough(b); }
-
- void toggleVChange();
- void setVolume(int vol) { _player->setVolume(vol); }
- int volume() { return _player->getVolume(); }
-
-protected:
bool _vToggle;
byte *_musicData;
- uint32 _musicDataSize;
- MusicPlayer *_player;
};
} // End of namespace Queen
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index 750afe4a10..bb777b927d 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -160,7 +160,7 @@ void QueenEngine::readOptionSettings() {
}
void QueenEngine::writeOptionSettings() {
- ConfMan.setInt("music_volume", _sound->volume());
+ ConfMan.setInt("music_volume", _sound->getVolume());
ConfMan.setBool("music_mute", !_sound->musicOn());
ConfMan.setBool("sfx_mute", !_sound->sfxOn());
ConfMan.setInt("talkspeed", ((_talkSpeed - MIN_TEXT_SPEED) * 255 + (MAX_TEXT_SPEED - MIN_TEXT_SPEED) / 2) / (MAX_TEXT_SPEED - MIN_TEXT_SPEED));
diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp
index fe321cf007..e6d9e23e80 100644
--- a/engines/queen/sound.cpp
+++ b/engines/queen/sound.cpp
@@ -148,7 +148,7 @@ PCSound::PCSound(Audio::Mixer *mixer, QueenEngine *vm)
if (native_mt32)
driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
- _music = new Music(driver, vm);
+ _music = new MidiMusic(driver, vm);
_music->hasNativeMT32(native_mt32);
}
@@ -224,7 +224,7 @@ void PCSound::setVolume(int vol) {
}
int PCSound::volume() {
- return _music->volume();
+ return _music->getVolume();
}
void PCSound::waitFinished(bool isSpeech) {
diff --git a/engines/queen/sound.h b/engines/queen/sound.h
index 43c7b11bdf..f004edc599 100644
--- a/engines/queen/sound.h
+++ b/engines/queen/sound.h
@@ -50,7 +50,7 @@ struct tuneData {
int16 delay;
};
-class Music;
+class MidiMusic;
class QueenEngine;
class Sound {
@@ -77,7 +77,7 @@ public:
virtual void updateMusic() {}
virtual void setVolume(int vol) { _masterVolume = vol; }
- virtual int volume() { return _masterVolume; }
+ virtual int getVolume() { return _masterVolume; }
void playLastSong() { playSong(_lastOverride); }
@@ -157,7 +157,7 @@ protected:
Audio::SoundHandle _sfxHandle;
Audio::SoundHandle _speechHandle;
- Music *_music;
+ MidiMusic *_music;
};
class AmigaSound : public Sound {