Beginnings of music support for Cruise, based on the cine engine sound code (note that the music played isn't yet correct, though)
svn-id: r41506
This commit is contained in:
parent
95f02dd86f
commit
2f3e5f11cb
7 changed files with 867 additions and 219 deletions
|
@ -52,8 +52,8 @@ CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc
|
|||
_currentVolumeFile = new Common::File();
|
||||
#endif
|
||||
|
||||
Common::addDebugChannel(kCruiseDebugScript, "Script",
|
||||
"Script debug level");
|
||||
Common::addDebugChannel(kCruiseDebugScript, "scripts", "Scripts debug level");
|
||||
Common::addDebugChannel(kCruiseDebugSound, "sound", "Sound debug level");
|
||||
|
||||
// Setup mixer
|
||||
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType,
|
||||
|
@ -63,15 +63,13 @@ CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc
|
|||
|
||||
_vm = this;
|
||||
_debugger = new Debugger();
|
||||
_music = new MusicPlayer();
|
||||
_sound = new SoundPlayer();
|
||||
_sound = new PCSound(_mixer, this);
|
||||
|
||||
syst->getEventManager()->registerRandomSource(_rnd, "cruise");
|
||||
}
|
||||
|
||||
CruiseEngine::~CruiseEngine() {
|
||||
delete _debugger;
|
||||
delete _music;
|
||||
delete _sound;
|
||||
|
||||
freeSystem();
|
||||
|
|
|
@ -57,8 +57,7 @@ private:
|
|||
bool _preLoad;
|
||||
Debugger *_debugger;
|
||||
MidiDriver *_driver;
|
||||
MusicPlayer *_music;
|
||||
SoundPlayer *_sound;
|
||||
PCSound *_sound;
|
||||
bool _mt32, _adlib;
|
||||
int _musicVolume;
|
||||
Common::StringList _langStrings;
|
||||
|
@ -90,8 +89,7 @@ public:
|
|||
uint32 getFeatures() const;
|
||||
Common::Language getLanguage() const;
|
||||
Common::Platform getPlatform() const;
|
||||
MusicPlayer &music() { return *_music; }
|
||||
SoundPlayer &sound() { return *_sound; }
|
||||
PCSound &sound() { return *_sound; }
|
||||
bool mt32() const { return _mt32; }
|
||||
bool adlib() const { return _adlib; }
|
||||
virtual GUI::Debugger *getDebugger() { return _debugger; }
|
||||
|
@ -128,7 +126,8 @@ enum {
|
|||
};
|
||||
|
||||
enum {
|
||||
kCruiseDebugScript = 1 << 0
|
||||
kCruiseDebugScript = 1 << 0,
|
||||
kCruiseDebugSound = 1 << 1
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -1354,22 +1354,22 @@ int16 Op_LoadSong(void) {
|
|||
|
||||
strcpy(buffer, ptr);
|
||||
strToUpper(buffer);
|
||||
_vm->music().loadSong(buffer);
|
||||
_vm->sound().loadMusic(buffer);
|
||||
|
||||
changeCursor(CURSOR_NORMAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16 Op_PlaySong(void) {
|
||||
if (_vm->music().songLoaded() && !_vm->music().songPlayed())
|
||||
_vm->music().startSong();
|
||||
if (_vm->sound().songLoaded() && !_vm->sound().songPlayed())
|
||||
_vm->sound().playMusic();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16 Op_StopSong(void) {
|
||||
if (_vm->music().isPlaying())
|
||||
_vm->music().stop();
|
||||
if (_vm->sound().isPlaying())
|
||||
_vm->sound().stopMusic();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1383,12 +1383,12 @@ int16 Op_RestoreSong(void) {
|
|||
int16 Op_SongSize(void) {
|
||||
int size, oldSize;
|
||||
|
||||
if (_vm->music().songLoaded()) {
|
||||
byte *pSize = _vm->music().songData() + 470;
|
||||
oldSize = *pSize;
|
||||
if (_vm->sound().songLoaded()) {
|
||||
oldSize = _vm->sound().numOrders();
|
||||
|
||||
size = popVar();
|
||||
if ((size >= 1) && (size < 128))
|
||||
*pSize = size;
|
||||
_vm->sound().setNumOrders(size);
|
||||
} else
|
||||
oldSize = 0;
|
||||
|
||||
|
@ -1399,35 +1399,34 @@ int16 Op_SetPattern(void) {
|
|||
int value = popVar();
|
||||
int offset = popVar();
|
||||
|
||||
if (_vm->music().songLoaded()) {
|
||||
byte *pData = _vm->music().songData();
|
||||
*(pData + 472 + offset) = (byte)value;
|
||||
if (_vm->sound().songLoaded()) {
|
||||
_vm->sound().setPattern(offset, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16 Op_FadeSong(void) {
|
||||
_vm->music().fadeSong();
|
||||
_vm->sound().fadeSong();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16 Op_FreeSong(void) {
|
||||
_vm->music().stop();
|
||||
_vm->music().removeSong();
|
||||
_vm->sound().stopMusic();
|
||||
_vm->sound().removeMusic();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16 Op_SongLoop(void) {
|
||||
bool oldLooping = _vm->music().looping();
|
||||
_vm->music().setLoop(popVar() != 0);
|
||||
bool oldLooping = _vm->sound().musicLooping();
|
||||
_vm->sound().musicLoop(popVar() != 0);
|
||||
|
||||
return oldLooping;
|
||||
}
|
||||
|
||||
int16 Op_SongPlayed(void) {
|
||||
return _vm->music().songPlayed();
|
||||
return _vm->sound().songPlayed();
|
||||
}
|
||||
|
||||
void setVar49Value(int value) {
|
||||
|
@ -1632,7 +1631,7 @@ int16 Op_GetNodeY(void) {
|
|||
}
|
||||
|
||||
int16 Op_SetVolume(void) {
|
||||
int oldVolume = _vm->music().getVolume() >> 2;
|
||||
int oldVolume = _vm->sound().getVolume() >> 2;
|
||||
int newVolume = popVar();
|
||||
|
||||
// TODO: The game seems to expect the volume will only range from 0 - 63, so for now
|
||||
|
@ -1641,7 +1640,7 @@ int16 Op_SetVolume(void) {
|
|||
if (newVolume > 63) newVolume = 63;
|
||||
if (newVolume >= 0) {
|
||||
int volume = 63 - newVolume;
|
||||
_vm->music().setVolume(volume << 2);
|
||||
_vm->sound().setVolume(volume << 2);
|
||||
}
|
||||
|
||||
return oldVolume >> 2;
|
||||
|
|
|
@ -207,7 +207,7 @@ int playerMenu(int menuX, int menuY) {
|
|||
|
||||
if (playerMenuEnabled && displayOn) {
|
||||
if (remdo) {
|
||||
_vm->music().removeSong();
|
||||
_vm->sound().stopMusic();
|
||||
freeStuff2();
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -610,7 +610,7 @@ static void syncCT(Common::Serializer &s) {
|
|||
|
||||
static void DoSync(Common::Serializer &s) {
|
||||
syncBasicInfo(s);
|
||||
_vm->music().doSync(s);
|
||||
_vm->sound().doSync(s);
|
||||
|
||||
syncPalette(s, newPal);
|
||||
syncPalette(s, workpal);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,58 +33,45 @@
|
|||
|
||||
namespace Cruise {
|
||||
|
||||
class MusicPlayer {
|
||||
class CruiseEngine;
|
||||
class PCSoundDriver;
|
||||
class PCSoundFxPlayer;
|
||||
|
||||
class PCSound {
|
||||
private:
|
||||
byte _channelVolume[16];
|
||||
int _fadeVolume;
|
||||
char _musicName[33];
|
||||
|
||||
bool _isPlaying;
|
||||
bool _songPlayed;
|
||||
bool _looping;
|
||||
byte _masterVolume;
|
||||
|
||||
byte *_songPointer;
|
||||
// TODO: lib_SongSize
|
||||
int _songSize;
|
||||
|
||||
void patchMidi(uint32 adr, const byte *data, int size);
|
||||
byte *loadInstrument(const char *name, int i);
|
||||
Audio::Mixer *_mixer;
|
||||
CruiseEngine *_vm;
|
||||
protected:
|
||||
PCSoundDriver *_soundDriver;
|
||||
PCSoundFxPlayer *_player;
|
||||
public:
|
||||
MusicPlayer();
|
||||
~MusicPlayer();
|
||||
PCSound(Audio::Mixer *mixer, CruiseEngine *vm);
|
||||
virtual ~PCSound();
|
||||
|
||||
void setVolume(int volume);
|
||||
int getVolume() const { return _masterVolume; }
|
||||
virtual void loadMusic(const char *name);
|
||||
virtual void playMusic();
|
||||
virtual void stopMusic();
|
||||
virtual void removeMusic();
|
||||
virtual void fadeOutMusic();
|
||||
|
||||
void stop();
|
||||
void pause();
|
||||
void resume();
|
||||
virtual void playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat);
|
||||
virtual void startSound(int channelNum, const byte *ptr, int size, int speed, int volume, bool loop);
|
||||
virtual void stopSound(int channel);
|
||||
|
||||
// Common public access methods
|
||||
void doSync(Common::Serializer &s);
|
||||
void loadSong(const char *name);
|
||||
void startSong();
|
||||
void stopSong();
|
||||
void removeSong();
|
||||
void stopChannel(int channel);
|
||||
bool isPlaying() const;
|
||||
bool songLoaded() const;
|
||||
bool songPlayed() const;
|
||||
void fadeSong();
|
||||
|
||||
bool songLoaded() const { return _songPointer != NULL; }
|
||||
bool songPlayed() const { return _songPlayed; }
|
||||
bool isPlaying() const { return _isPlaying; }
|
||||
bool looping() const { return _looping; }
|
||||
byte *songData() { return _songPointer; }
|
||||
void setPlaying(bool playing) { _isPlaying = playing; }
|
||||
void setLoop(bool loop) { _looping = loop; }
|
||||
};
|
||||
|
||||
class SoundPlayer {
|
||||
public:
|
||||
SoundPlayer() {}
|
||||
|
||||
void startSound(int channelNum, const byte *ptr, int size, int speed, int volume, bool loop) {}
|
||||
void startNote(int channelNum, int speed, int volume) {}
|
||||
void stopChannel(int channelNum) {}
|
||||
uint8 numOrders() const;
|
||||
void setNumOrders(uint8 v);
|
||||
void setPattern(int offset, uint8 value);
|
||||
bool musicLooping() const;
|
||||
void musicLoop(bool v);
|
||||
void startNote(int channel, int volume, int speed);
|
||||
void setVolume(int volume);
|
||||
uint8 getVolume();
|
||||
};
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue