AGOS: Reduced header dependency

This commit is contained in:
Eugene Sandulenko 2011-08-05 11:16:03 +01:00
parent 43c7b10566
commit 6e795a89b0
33 changed files with 80 additions and 90 deletions

View file

@ -24,13 +24,13 @@
#include "common/file.h"
#include "common/fs.h"
#include "common/textconsole.h"
#include "common/system.h"
#include "engines/util.h"
#include "agos/debugger.h"
#include "agos/intern.h"
#include "agos/agos.h"
#include "agos/midi.h"
#include "backends/audiocd/audiocd.h"
@ -541,16 +541,18 @@ Common::Error AGOSEngine::init() {
initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP);
_midi = new MidiPlayer();
if ((getGameType() == GType_SIMON2 && getPlatform() == Common::kPlatformWindows) ||
(getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformWindows) ||
((getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformAcorn) ||
(getPlatform() == Common::kPlatformPC)) {
int ret = _midi.open(getGameType());
int ret = _midi->open(getGameType());
if (ret)
warning("MIDI Player init failed: \"%s\"", MidiDriver::getErrorName(ret));
_midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume"));
_midi->setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume"));
_midiEnabled = true;
}
@ -597,14 +599,14 @@ Common::Error AGOSEngine::init() {
if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1) {
_musicPaused = true;
if (_midiEnabled) {
_midi.pause(_musicPaused);
_midi->pause(_musicPaused);
}
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, 0);
}
if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) {
if (getGameId() == GID_SIMON1DOS)
_midi._enable_sfx = !_midi._enable_sfx;
_midi->_enable_sfx = !_midi->_enable_sfx;
else {
_effectsPaused = !_effectsPaused;
_sound->effectsPause(_effectsPaused);
@ -708,7 +710,7 @@ void AGOSEngine_Simon2::setupGame() {
_itemMemSize = 20000;
_tableMemSize = 100000;
// Check whether to use MT-32 MIDI tracks in Simon the Sorcerer 2
if (getGameType() == GType_SIMON2 && _midi.hasNativeMT32())
if (getGameType() == GType_SIMON2 && _midi->hasNativeMT32())
_musicIndexBase = (1128 + 612) / 4;
else
_musicIndexBase = 1128 / 4;
@ -911,6 +913,8 @@ AGOSEngine::~AGOSEngine() {
_window6BackScn->free();
delete _window6BackScn;
free(_midi);
free(_firstTimeStruct);
free(_pendingDeleteTimeEvent);
@ -938,12 +942,12 @@ void AGOSEngine::pauseEngineIntern(bool pauseIt) {
_keyPressed.reset();
_pause = true;
_midi.pause(true);
_midi->pause(true);
_mixer->pauseAll(true);
} else {
_pause = false;
_midi.pause(_musicPaused);
_midi->pause(_musicPaused);
_mixer->pauseAll(false);
}
}
@ -1027,7 +1031,7 @@ void AGOSEngine::syncSoundSettings() {
int soundVolumeSFX = ConfMan.getInt("sfx_volume");
if (_midiEnabled)
_midi.setVolume((mute ? 0 : soundVolumeMusic), (mute ? 0 : soundVolumeSFX));
_midi->setVolume((mute ? 0 : soundVolumeMusic), (mute ? 0 : soundVolumeSFX));
}
} // End of namespace AGOS

View file

@ -33,7 +33,6 @@
#include "common/stack.h"
#include "common/util.h"
#include "agos/midi.h"
#include "agos/sound.h"
#include "agos/vga.h"
@ -50,6 +49,16 @@
* - Simon the Sorcerer 2
* - Simon the Sorcerer Puzzle Pack
*/
namespace Common {
class File;
class SeekableReadStream;
}
namespace Graphics {
class Surface;
}
namespace AGOS {
uint fileReadItemID(Common::SeekableReadStream *in);
@ -60,6 +69,8 @@ uint fileReadItemID(Common::SeekableReadStream *in);
class MoviePlayer;
#endif
class MidiPlayer;
struct Child;
struct SubObject;
@ -548,7 +559,7 @@ protected:
byte _lettersToPrintBuf[80];
MidiPlayer _midi;
MidiPlayer *_midi;
bool _midiEnabled;
int _vgaTickCounter;

View file

@ -20,8 +20,6 @@
*
*/
#include "common/system.h"
#include "common/textconsole.h"

View file

@ -20,8 +20,7 @@
*
*/
#include "common/endian.h"
#include "common/system.h"
#include "agos/agos.h"

View file

@ -20,8 +20,6 @@
*
*/
#include "agos/agos.h"
#include "agos/intern.h"

View file

@ -20,10 +20,8 @@
*
*/
#include "common/endian.h"
#include "common/events.h"
#include "common/system.h"
#include "graphics/cursorman.h"

View file

@ -22,7 +22,6 @@
// AGOS debug functions
#include "common/file.h"
#include "common/textconsole.h"

View file

@ -20,12 +20,11 @@
*
*/
#include "common/config-manager.h"
#include "agos/debugger.h"
#include "agos/agos.h"
#include "agos/midi.h"
namespace AGOS {
@ -79,7 +78,7 @@ bool Debugger::Cmd_PlayMusic(int argc, const char **argv) {
// TODO
} else if (_vm->getGameType() == GType_SIMON2) {
_vm->loadMusic(music);
_vm->_midi.startTrack(0);
_vm->_midi->startTrack(0);
} else {
_vm->playMusic(music, 0);
}

View file

@ -20,8 +20,7 @@
*
*/
#include "common/endian.h"
#include "common/system.h"
#include "graphics/surface.h"

View file

@ -20,8 +20,6 @@
*
*/
#include "agos/agos.h"
#include "agos/animation.h"
#include "agos/debugger.h"

View file

@ -20,8 +20,7 @@
*
*/
#include "common/endian.h"
#include "common/system.h"
#include "common/textconsole.h"

View file

@ -20,8 +20,6 @@
*
*/
#include "common/file.h"
#include "common/system.h"
#include "common/textconsole.h"

View file

@ -20,13 +20,12 @@
*
*/
#include "common/config-manager.h"
#include "common/file.h"
#include "agos/intern.h"
#include "agos/agos.h"
#include "agos/midi.h"
#include "agos/vga.h"
namespace AGOS {
@ -582,14 +581,14 @@ bool AGOSEngine::processSpecialKeys() {
break;
case '+':
if (_midiEnabled) {
_midi.setVolume(_midi.getMusicVolume() + 16, _midi.getSFXVolume() + 16);
_midi->setVolume(_midi->getMusicVolume() + 16, _midi->getSFXVolume() + 16);
}
ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16);
syncSoundSettings();
break;
case '-':
if (_midiEnabled) {
_midi.setVolume(_midi.getMusicVolume() - 16, _midi.getSFXVolume() - 16);
_midi->setVolume(_midi->getMusicVolume() - 16, _midi->getSFXVolume() - 16);
}
ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16);
syncSoundSettings();
@ -597,13 +596,13 @@ bool AGOSEngine::processSpecialKeys() {
case 'm':
_musicPaused = !_musicPaused;
if (_midiEnabled) {
_midi.pause(_musicPaused);
_midi->pause(_musicPaused);
}
syncSoundSettings();
break;
case 's':
if (getGameId() == GID_SIMON1DOS) {
_midi._enable_sfx = !_midi._enable_sfx;
_midi->_enable_sfx = !_midi->_enable_sfx;
} else {
_effectsPaused = !_effectsPaused;
_sound->effectsPause(_effectsPaused);

View file

@ -20,8 +20,6 @@
*
*/
#include "agos/agos.h"
#include "agos/intern.h"

View file

@ -20,8 +20,6 @@
*
*/
#include "common/file.h"
#include "common/textconsole.h"

View file

@ -20,8 +20,6 @@
*
*/
#include "common/file.h"
#include "common/system.h"
#include "common/textconsole.h"

View file

@ -20,14 +20,12 @@
*
*/
#include "common/config-manager.h"
#include "common/file.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "agos/agos.h"
#include "agos/midi.h"
namespace AGOS {

View file

@ -25,7 +25,6 @@
#ifdef ENABLE_AGOS2
#include "common/savefile.h"
#include "common/system.h"
#include "graphics/surface.h"

View file

@ -26,6 +26,8 @@
#include "agos/agos.h"
#include "agos/intern.h"
#include "common/endian.h"
namespace AGOS {
enum {

View file

@ -27,12 +27,12 @@
#include "agos/intern.h"
#include "agos/agos.h"
#include "agos/midi.h"
#include "agos/vga.h"
#include "backends/audiocd/audiocd.h"
#include "audio/audiostream.h"
#include "audio/mididrv.h"
#include "audio/mods/protracker.h"
namespace AGOS {
@ -125,10 +125,10 @@ void AGOSEngine::loadMusic(uint16 music) {
_gameFile->read(buf, 4);
if (!memcmp(buf, "FORM", 4)) {
_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
_midi.loadXMIDI(_gameFile);
_midi->loadXMIDI(_gameFile);
} else {
_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
_midi.loadMultipleSMF(_gameFile);
_midi->loadMultipleSMF(_gameFile);
}
_lastMusicPlayed = music;
@ -242,20 +242,20 @@ void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) {
if (music == 35)
return;
_midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
_midi->setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
_gameFile->read(buf, 4);
if (!memcmp(buf, "GMF\x1", 4)) {
_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
_midi.loadSMF(_gameFile, music);
_midi->loadSMF(_gameFile, music);
} else {
_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
_midi.loadMultipleSMF(_gameFile);
_midi->loadMultipleSMF(_gameFile);
}
_midi.startTrack(0);
_midi.startTrack(track);
_midi->startTrack(0);
_midi->startTrack(track);
} else if (getPlatform() == Common::kPlatformAcorn) {
// TODO: Add support for Desktop Tracker format in Acorn disk version
} else {
@ -266,15 +266,15 @@ void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) {
if (f.isOpen() == false)
error("playMusic: Can't load music from '%s'", filename);
_midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
_midi->setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
if (getFeatures() & GF_DEMO)
_midi.loadS1D(&f);
_midi->loadS1D(&f);
else
_midi.loadSMF(&f, music);
_midi->loadSMF(&f, music);
_midi.startTrack(0);
_midi.startTrack(track);
_midi->startTrack(0);
_midi->startTrack(track);
}
}
@ -286,7 +286,7 @@ void AGOSEngine::playMusic(uint16 music, uint16 track) {
} else if (getPlatform() == Common::kPlatformAtariST) {
// TODO: Add support for music formats used
} else {
_midi.setLoop(true); // Must do this BEFORE loading music.
_midi->setLoop(true); // Must do this BEFORE loading music.
char filename[15];
Common::File f;
@ -295,21 +295,21 @@ void AGOSEngine::playMusic(uint16 music, uint16 track) {
if (f.isOpen() == false)
error("playMusic: Can't load music from '%s'", filename);
_midi.loadS1D(&f);
_midi.startTrack(0);
_midi.startTrack(track);
_midi->loadS1D(&f);
_midi->startTrack(0);
_midi->startTrack(track);
}
}
void AGOSEngine::stopMusic() {
if (_midiEnabled) {
_midi.stop();
_midi->stop();
}
_mixer->stopHandle(_modHandle);
}
void AGOSEngine::playSting(uint16 soundId) {
if (!_midi._enable_sfx)
if (!_midi->_enable_sfx)
return;
char filename[15];
@ -328,8 +328,8 @@ void AGOSEngine::playSting(uint16 soundId) {
error("playSting: Can't read sting %d offset", soundId);
mus_file.seek(mus_offset, SEEK_SET);
_midi.loadSMF(&mus_file, soundId, true);
_midi.startTrack(0);
_midi->loadSMF(&mus_file, soundId, true);
_midi->startTrack(0);
}
static const byte elvira1_soundTable[100] = {

View file

@ -22,7 +22,6 @@
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/translation.h"

View file

@ -22,8 +22,7 @@
// Item script opcodes for Simon1/Simon2
#include "common/endian.h"
#include "common/system.h"
#include "common/textconsole.h"

View file

@ -24,8 +24,6 @@
#ifdef ENABLE_AGOS2
#include "common/system.h"
#include "agos/agos.h"
namespace AGOS {

View file

@ -23,6 +23,7 @@
#include "agos/agos.h"
#include "agos/vga.h"
#include "common/endian.h"
#include "common/textconsole.h"
namespace AGOS {

View file

@ -20,7 +20,6 @@
*
*/
#include "common/system.h"
#include "graphics/palette.h"

View file

@ -23,6 +23,7 @@
#include "agos/agos.h"
#include "agos/midi.h"
#include "common/textconsole.h"
@ -342,11 +343,11 @@ void AGOSEngine_Simon2::os2_playTune() {
// effectively preloaded so there's no latency when
// starting playback).
_midi.setLoop(loop != 0);
_midi->setLoop(loop != 0);
if (_lastMusicPlayed != music)
_nextMusicToPlay = music;
else
_midi.startTrack(track);
_midi->startTrack(track);
}
void AGOSEngine_Simon2::os2_screenTextPObj() {

View file

@ -22,8 +22,6 @@
#include "common/system.h"
#include "agos/agos.h"
namespace AGOS {

View file

@ -28,6 +28,10 @@
#include "agos/intern.h"
#include "common/str.h"
namespace Common {
class File;
}
namespace AGOS {
class BaseSound;

View file

@ -22,7 +22,6 @@
// Verb and hitarea handling
#include "common/system.h"
#include "graphics/surface.h"

View file

@ -27,6 +27,7 @@
#include "agos/intern.h"
#include "agos/vga.h"
#include "common/endian.h"
#include "common/system.h"
#include "common/textconsole.h"

View file

@ -26,6 +26,7 @@
#include "agos/agos.h"
#include "agos/intern.h"
#include "common/endian.h"
#include "common/system.h"
#include "graphics/surface.h"

View file

@ -20,10 +20,9 @@
*
*/
#include "agos/agos.h"
#include "agos/intern.h"
#include "agos/midi.h"
#include "graphics/surface.h"
@ -146,8 +145,8 @@ void AGOSEngine::vc69_playSeq() {
// specifying a non-valid track number (999 or -1)
// as a means of stopping what music is currently
// playing.
_midi.setLoop(loop != 0);
_midi.startTrack(track);
_midi->setLoop(loop != 0);
_midi->startTrack(track);
}
void AGOSEngine::vc70_joinSeq() {
@ -161,9 +160,9 @@ void AGOSEngine::vc70_joinSeq() {
// track and, if not, whether to switch to
// a different track upon completion.
if (track != 0xFFFF && track != 999)
_midi.queueTrack(track, loop != 0);
_midi->queueTrack(track, loop != 0);
else
_midi.setLoop(loop != 0);
_midi->setLoop(loop != 0);
}
void AGOSEngine::vc71_ifSeqWaiting() {
@ -171,7 +170,7 @@ void AGOSEngine::vc71_ifSeqWaiting() {
// This command skips the next instruction
// unless (1) there is a track playing, AND
// (2) there is a track queued to play after it.
if (!_midi.isPlaying(true))
if (!_midi->isPlaying(true))
vcSkipNextInstruction();
}
@ -195,8 +194,8 @@ void AGOSEngine::vc72_segue() {
if (track == -1 || track == 999) {
stopMusic();
} else {
_midi.setLoop(loop != 0);
_midi.startTrack(track);
_midi->setLoop(loop != 0);
_midi->startTrack(track);
}
}

View file

@ -21,7 +21,6 @@
*/
#include "common/system.h"
#include "common/textconsole.h"