aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-06-25 23:25:52 +0000
committerMax Horn2003-06-25 23:25:52 +0000
commit870ce2879e934a4bb559c2a9fb3ff14e9fb6be99 (patch)
tree40047757bcbe2b5c382ac24b31bfdca878c7cc4e /scumm
parent3351f4257b56118a87901f491e74af4fd952c0b7 (diff)
downloadscummvm-rg350-870ce2879e934a4bb559c2a9fb3ff14e9fb6be99.tar.gz
scummvm-rg350-870ce2879e934a4bb559c2a9fb3ff14e9fb6be99.tar.bz2
scummvm-rg350-870ce2879e934a4bb559c2a9fb3ff14e9fb6be99.zip
added some const qualifiers; moved _bundle & _current_cd_sound from class Scumm to class Sound; some other tweaks
svn-id: r8648
Diffstat (limited to 'scumm')
-rw-r--r--scumm/actor.cpp2
-rw-r--r--scumm/object.cpp16
-rw-r--r--scumm/resource.cpp4
-rw-r--r--scumm/script.cpp12
-rw-r--r--scumm/scumm.h54
-rw-r--r--scumm/scummvm.cpp45
-rw-r--r--scumm/sound.cpp48
-rw-r--r--scumm/sound.h9
8 files changed, 94 insertions, 96 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 5f50d21c50..ccf8ba29f1 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -116,7 +116,7 @@ void Actor::setActorWalkSpeed(uint newSpeedX, uint newSpeedY) {
}
}
-int Scumm::getAngleFromPos(int x, int y) {
+int Scumm::getAngleFromPos(int x, int y) const {
if (_gameId == GID_DIG || _gameId == GID_CMI) {
double temp = atan2((double)x, (double)-y);
return normalizeAngle((int)(temp * 180 / 3.1415926535));
diff --git a/scumm/object.cpp b/scumm/object.cpp
index f8f4c8fa39..4ae64274b0 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -50,8 +50,7 @@ struct BompHeader { /* Bomp header */
#endif
-bool Scumm::getClass(int obj, int cls)
-{
+bool Scumm::getClass(int obj, int cls) const {
checkRange(_numGlobalObjects - 1, 0, obj, "Object %d out of range in getClass");
cls &= 0x7F;
checkRange(32, 1, cls, "Class %d out of range in getClass");
@@ -78,8 +77,7 @@ bool Scumm::getClass(int obj, int cls)
return (_classData[obj] & (1 << (cls - 1))) != 0;
}
-void Scumm::putClass(int obj, int cls, bool set)
-{
+void Scumm::putClass(int obj, int cls, bool set) {
checkRange(_numGlobalObjects - 1, 0, obj, "Object %d out of range in putClass");
cls &= 0x7F;
checkRange(32, 1, cls, "Class %d out of range in putClass");
@@ -119,7 +117,7 @@ void Scumm::putClass(int obj, int cls, bool set)
}
}
-int Scumm::getOwner(int obj) {
+int Scumm::getOwner(int obj) const {
checkRange(_numGlobalObjects - 1, 0, obj, "Object %d out of range in getOwner");
return _objectOwnerTable[obj];
}
@@ -160,12 +158,12 @@ void Scumm::putState(int obj, int state) {
_objectStateTable[obj] = state;
}
-int Scumm::getObjectRoom(int obj) {
+int Scumm::getObjectRoom(int obj) const {
checkRange(_numGlobalObjects - 1, 0, obj, "Object %d out of range in getObjectRoom");
return _objectRoomTable[obj];
}
-int Scumm::getObjectIndex(int object) {
+int Scumm::getObjectIndex(int object) const {
int i;
if (object < 1)
@@ -178,7 +176,7 @@ int Scumm::getObjectIndex(int object) {
return -1;
}
-int Scumm::whereIsObject(int object) {
+int Scumm::whereIsObject(int object) const {
int i;
if (object >= _numGlobalObjects)
@@ -941,7 +939,7 @@ const byte *Scumm::getObjOrActorName(int obj) {
return findResourceData(MKID('OBNA'), objptr);
}
-uint32 Scumm::getOBCDOffs(int object) {
+uint32 Scumm::getOBCDOffs(int object) const {
int i;
if (_objectOwnerTable[object] != OF_OWNER_ROOM)
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 71e8e07678..7c2cbb3319 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -222,8 +222,8 @@ void Scumm::askForDisk(const char *filename, int disknum) {
if (_version == 8) {
char result;
- _bundle->closeVoiceFile();
- _bundle->closeMusicFile();
+ _sound->_bundle->closeVoiceFile();
+ _sound->_bundle->closeMusicFile();
#ifdef MACOSX
sprintf(buf, "Cannot find file: '%s'\nPlease insert disc %d.\nHit OK to retry, Cancel to exit", filename, disknum);
diff --git a/scumm/script.cpp b/scumm/script.cpp
index 57eb81e49f..a61f07fcba 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -969,27 +969,27 @@ void Scumm::decreaseScriptDelay(int amount) {
}
}
-bool Scumm::isScriptInUse(int script) {
+bool Scumm::isScriptInUse(int script) const {
int i;
- ScriptSlot *ss = vm.slot;
+ const ScriptSlot *ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++)
if (ss->number == script)
return true;
return false;
}
-bool Scumm::isScriptRunning(int script) {
+bool Scumm::isScriptRunning(int script) const {
int i;
- ScriptSlot *ss = vm.slot;
+ const ScriptSlot *ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++)
if (ss->number == script && (ss->where == WIO_GLOBAL || ss->where == WIO_LOCAL) && ss->status != ssDead)
return true;
return false;
}
-bool Scumm::isRoomScriptRunning(int script) {
+bool Scumm::isRoomScriptRunning(int script) const {
int i;
- ScriptSlot *ss = vm.slot;
+ const ScriptSlot *ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++)
if (ss->number == script && ss->where == WIO_ROOM && ss->status != ssDead)
return true;
diff --git a/scumm/scumm.h b/scumm/scumm.h
index ec9f28ec5d..b24b43cb20 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -32,22 +32,21 @@
#include "gfx.h"
#include "boxes.h"
+class Actor;
+class BaseCostumeRenderer;
class CharsetRenderer;
-class GameDetector;
-class NewGui;
-class Dialog;
class ConsoleDialog;
-class Scumm;
+class Dialog;
+class GameDetector;
class IMuse;
class IMuseDigital;
+class NewGui;
class Player_V2;
-class Actor;
-class Sound;
-class Bundle;
+class Scumm;
class ScummDebugger;
class Serializer;
+class Sound;
struct FindObjectInRoom;
-class BaseCostumeRenderer;
typedef ScummVM::Map<ScummVM::String, int> ObjectIDMap;
@@ -296,18 +295,17 @@ public:
IMuse *_imuse;
IMuseDigital *_imuseDigital;
Player_V2 *_playerV2;
+ Sound *_sound;
+
+ VerbSlot *_verbs;
+ ObjectData *_objs;
+ ScummDebugger *_debugger;
byte _version;
uint32 _features; // Should only be accessed for reading (TODO enforce it compiler-wise with making it private and creating an accessor)
void setFeatures (uint32 newFeatures); // Changes the features set. This allows some gamewide stuff to be precalculated/prepared (ie CostumeRenderer)
- VerbSlot *_verbs;
- ObjectData *_objs;
- ScummDebugger *_debugger;
- Bundle *_bundle;
- Sound *_sound;
-
struct {
byte mode[rtNumTypes];
uint16 num[rtNumTypes];
@@ -319,6 +317,7 @@ public:
uint32 *roomoffs[rtNumTypes];
} res;
+protected:
struct {
uint32 cutScenePtr[5];
byte cutSceneScript[5];
@@ -330,6 +329,7 @@ public:
int32 localvar[NUM_SCRIPT_SLOT][26];
} vm;
+public:
// Constructor / Destructor
Scumm(GameDetector *detector, OSystem *syst);
virtual ~Scumm();
@@ -361,7 +361,7 @@ public:
void clearClickedStatus();
// Misc utility functions
- void checkRange(int max, int min, int no, const char *str);
+ void checkRange(int max, int min, int no, const char *str) const;
const char *getExeName() const { return _exe_name; }
const char *getGameDataPath() const;
@@ -544,7 +544,7 @@ protected:
public:
void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr);
void stopScript(int script);
- bool isScriptRunning(int script); // FIXME - should be protected, used by Sound::startTalkSound
+ bool isScriptRunning(int script) const; // FIXME - should be protected, used by Sound::startTalkSound
protected:
void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars);
@@ -559,8 +559,8 @@ protected:
void freezeScripts(int scr);
void unfreezeScripts();
- bool isScriptInUse(int script);
- bool isRoomScriptRunning(int script);
+ bool isScriptInUse(int script) const;
+ bool isRoomScriptRunning(int script) const;
void killAllScriptsExceptCurrent();
void killScriptsAndResources();
@@ -669,7 +669,6 @@ protected:
void resourceStats();
void expireResources(uint32 size);
void freeResources();
- void destroy();
public:
/* Should be in Object class */
@@ -693,25 +692,25 @@ protected:
void addObjectToInventory(uint obj, uint room);
void fixObjectFlags();
public:
- bool getClass(int obj, int cls); // Used in actor.cpp, hence public
+ bool getClass(int obj, int cls) const; // Used in actor.cpp, hence public
protected:
void putClass(int obj, int cls, bool set);
int getState(int obj);
void putState(int obj, int state);
void setObjectState(int obj, int state, int x, int y);
- int getOwner(int obj);
+ int getOwner(int obj) const;
void putOwner(int obj, int owner);
void setOwnerOf(int obj, int owner);
void clearOwnerOf(int obj);
- int getObjectRoom(int obj);
+ int getObjectRoom(int obj) const;
int getObjX(int obj);
int getObjY(int obj);
void getObjectXYPos(int object, int &x, int &y) { int dir; getObjectXYPos(object, x, y, dir); }
void getObjectXYPos(int object, int &x, int &y, int &dir);
int getObjOldDir(int obj);
int getObjNewDir(int obj);
- int getObjectIndex(int object);
- int whereIsObject(int object);
+ int getObjectIndex(int object) const;
+ int whereIsObject(int object) const;
int findObject(int x, int y);
void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room);
public:
@@ -724,8 +723,8 @@ protected:
void clearDrawObjectQueue();
void processDrawQue();
- uint32 getOBCDOffs(int object);
- byte *getOBCDFromObject(int obj);
+ uint32 getOBCDOffs(int object) const;
+ byte *getOBCDFromObject(int obj);
int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f);
@@ -765,7 +764,7 @@ public:
uint32 *_classData;
- int getAngleFromPos(int x, int y);
+ int getAngleFromPos(int x, int y) const;
protected:
void walkActors();
@@ -1004,7 +1003,6 @@ protected:
int _saveSound;
public:
bool _silentDigitalImuse, _noDigitalSamples;
- int current_cd_sound; // Used in class Sound
public:
uint16 _extraBoxFlags[65];
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 012861e17f..83abcdc49e 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -23,7 +23,6 @@
#include "stdafx.h"
#include "scumm.h"
#include "actor.h"
-#include "bundle.h"
#include "charset.h"
#include "debugger.h"
#include "dialogs.h"
@@ -229,7 +228,6 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_verbs = NULL;
_objs = NULL;
_debugger = NULL;
- _bundle = NULL;
_sound = NULL;
memset(&res, 0, sizeof(res));
memset(&vm, 0, sizeof(vm));
@@ -395,7 +393,6 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_silentDigitalImuse = 0;
_noDigitalSamples = 0;
_saveSound = 1;
- current_cd_sound = 0;
memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags));
memset(_scaleSlots, 0, sizeof(_scaleSlots));
_charset = NULL;
@@ -583,7 +580,6 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
gdi._numStrips = _screenWidth / 8;
_newgui = g_gui;
- _bundle = new Bundle();
_sound = new Sound(this);
_sound->_sound_volume_master = detector->_master_volume;
@@ -721,7 +717,6 @@ Scumm::~Scumm () {
delete _optionsDialog;
delete _saveLoadDialog;
- delete _bundle;
delete _sound;
delete _imuse;
delete _imuseDigital;
@@ -733,7 +728,23 @@ Scumm::~Scumm () {
free(_shadowPalette);
- destroy();
+ freeResources();
+
+ free(_objectStateTable);
+ free(_objectRoomTable);
+ free(_objectOwnerTable);
+ free(_inventory);
+ free(_verbs);
+ free(_objs);
+ free(_scummVars);
+ free(_bitVars);
+ free(_newNames);
+ free(_classData);
+ free(_exe_name);
+ free(_game_name);
+
+ free(_roomStrips);
+ free(_languageIndex);
delete g_debugger;
}
@@ -959,7 +970,7 @@ void Scumm::initScummVars() {
VAR(VAR_TALK_ACTOR) = 0;
}
-void Scumm::checkRange(int max, int min, int no, const char *str) {
+void Scumm::checkRange(int max, int min, int no, const char *str) const {
if (no < min || no > max) {
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack
@@ -2139,26 +2150,6 @@ void Scumm::startManiac() {
warning("stub startManiac()");
}
-void Scumm::destroy() {
- freeResources();
-
- free(_objectStateTable);
- free(_objectRoomTable);
- free(_objectOwnerTable);
- free(_inventory);
- free(_verbs);
- free(_objs);
- free(_scummVars);
- free(_bitVars);
- free(_newNames);
- free(_classData);
- free(_exe_name);
- free(_game_name);
-
- free(_roomStrips);
- free(_languageIndex);
-}
-
//
// Convert an old style direction to a new style one (angle),
//
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 303b97f43c..fb140b5cd9 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -93,6 +93,9 @@ Sound::Sound(Scumm *parent) {
_musicDisk = 0;
_talkChannel = -1;
_current_cache = 0;
+ _current_cd_sound = 0;
+
+ _bundle = new Bundle();
}
Sound::~Sound() {
@@ -100,6 +103,7 @@ Sound::~Sound() {
_sfxFile->close();
delete _sfxFile;
}
+ delete _bundle;
}
void Sound::addSoundToQueue(int sound) {
@@ -195,7 +199,7 @@ void Sound::playSound(int soundID) {
playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
(ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
- _scumm->current_cd_sound = soundID;
+ _current_cd_sound = soundID;
return;
}
// Support for SFX in Monkey Island 1, Mac version
@@ -368,12 +372,12 @@ void Sound::playSound(int soundID) {
if (size == 30) {
int track = *(ptr + 0x16);
- if (track == _scumm->current_cd_sound)
+ if (track == _current_cd_sound)
if (pollCD() == 1)
return;
playCDTrack(track, 1, 0, 0);
- _scumm->current_cd_sound = track;
+ _current_cd_sound = track;
return;
}
@@ -590,7 +594,7 @@ bool Sound::isMouthSyncOff(uint pos) {
int Sound::isSoundRunning(int sound) {
int i;
- if (sound == _scumm->current_cd_sound)
+ if (sound == _current_cd_sound)
return pollCD();
if (_scumm->_features & GF_HUMONGOUS) {
@@ -634,7 +638,7 @@ int Sound::isSoundRunning(int sound) {
bool Sound::isSoundActive(int sound) {
int i;
- if (sound == _scumm->current_cd_sound)
+ if (sound == _current_cd_sound)
return pollCD() != 0;
i = _soundQue2Pos;
@@ -681,8 +685,8 @@ bool Sound::isSoundInQueue(int sound) {
void Sound::stopSound(int a) {
int i;
- if (a != 0 && a == _scumm->current_cd_sound) {
- _scumm->current_cd_sound = 0;
+ if (a != 0 && a == _current_cd_sound) {
+ _current_cd_sound = 0;
stopCD();
}
@@ -700,8 +704,8 @@ void Sound::stopSound(int a) {
}
void Sound::stopAllSounds() {
- if (_scumm->current_cd_sound != 0) {
- _scumm->current_cd_sound = 0;
+ if (_current_cd_sound != 0) {
+ _current_cd_sound = 0;
stopCD();
}
@@ -1007,10 +1011,10 @@ void Sound::playBundleMusic(const char *song) {
char bunfile[20];
sprintf(bunfile, "musdisk%d.bun", _scumm->VAR(_scumm->VAR_CURRENTDISK));
if (_musicDisk != _scumm->VAR(_scumm->VAR_CURRENTDISK))
- _scumm->_bundle->closeMusicFile();
+ _bundle->closeMusicFile();
- if (_scumm->_bundle->openMusicFile(bunfile, _scumm->getGameDataPath()) == false) {
- if (_scumm->_bundle->openMusicFile("music.bun", _scumm->getGameDataPath()) == false) {
+ if (_bundle->openMusicFile(bunfile, _scumm->getGameDataPath()) == false) {
+ if (_bundle->openMusicFile("music.bun", _scumm->getGameDataPath()) == false) {
_outputMixerSize = 0;
return;
}
@@ -1019,7 +1023,7 @@ void Sound::playBundleMusic(const char *song) {
_musicDisk = (byte)_scumm->VAR(_scumm->VAR_CURRENTDISK);
_outputMixerSize = 88140; // ((22050 * 2 * 2)
} else {
- if (_scumm->_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false)
+ if (_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false)
return;
}
_musicBundleBufFinal = (byte *)malloc(_outputMixerSize);
@@ -1032,7 +1036,7 @@ void Sound::playBundleMusic(const char *song) {
_musicBundleToBeRemoved = false;
_musicBundleToBeChanged = false;
_bundleMusicTrack = -1;
- _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(song);
+ _numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song);
_nameBundleMusic = song;
_scumm->_timer->installProcedure(&music_handler, 1000000);
return;
@@ -1081,7 +1085,7 @@ void Sound::bundleMusicHandler(Scumm *scumm) {
if (_musicBundleToBeChanged == true) {
_nameBundleMusic = _newNameBundleMusic;
- _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(_nameBundleMusic);
+ _numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(_nameBundleMusic);
_currentSampleBundleMusic = 0;
_offsetSampleBundleMusic = 0;
_offsetBufBundleMusic = 0;
@@ -1092,7 +1096,7 @@ void Sound::bundleMusicHandler(Scumm *scumm) {
ptr = _musicBundleBufOutput;
for (k = 0, l = _currentSampleBundleMusic; l < num; k++) {
- length = _scumm->_bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic)));
+ length = _bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic)));
_offsetSampleBundleMusic += length;
if (l == 0) {
@@ -1196,15 +1200,15 @@ int Sound::playBundleSound(char *sound) {
char voxfile[20];
sprintf(voxfile, "voxdisk%d.bun", _scumm->VAR(_scumm->VAR_CURRENTDISK));
if (_voiceDisk != _scumm->VAR(_scumm->VAR_CURRENTDISK))
- _scumm->_bundle->closeVoiceFile();
+ _bundle->closeVoiceFile();
- result = _scumm->_bundle->openVoiceFile(voxfile, _scumm->getGameDataPath());
+ result = _bundle->openVoiceFile(voxfile, _scumm->getGameDataPath());
if (result == false)
- result = _scumm->_bundle->openVoiceFile("voice.bun", _scumm->getGameDataPath());
+ result = _bundle->openVoiceFile("voice.bun", _scumm->getGameDataPath());
_voiceDisk = (byte)_scumm->VAR(_scumm->VAR_CURRENTDISK);
} else if (_scumm->_gameId == GID_DIG)
- result = _scumm->_bundle->openVoiceFile("digvoice.bun", _scumm->getGameDataPath());
+ result = _bundle->openVoiceFile("digvoice.bun", _scumm->getGameDataPath());
else
error("Don't know which bundle file to load");
@@ -1220,9 +1224,9 @@ int Sound::playBundleSound(char *sound) {
strcpy(name, sound);
if (_scumm->_maxRooms != 6) // CMI demo does not have .IMX for voice but does for music...
strcat(name, ".IMX");
- output_size = _scumm->_bundle->decompressVoiceSampleByName(name, &ptr);
+ output_size = _bundle->decompressVoiceSampleByName(name, &ptr);
} else {
- output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, &ptr);
+ output_size = _bundle->decompressVoiceSampleByName(sound, &ptr);
}
orig_ptr = ptr;
diff --git a/scumm/sound.h b/scumm/sound.h
index 842912f4e4..4617b807fc 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -23,6 +23,7 @@
#include "scummsys.h"
+class Bundle;
class DigitalTrackInfo;
class File;
class Scumm;
@@ -75,10 +76,14 @@ protected:
int num_sound_effects; // SO3 MP3 compressed audio
bool _vorbis_mode; // true if using SOG, false if using SO3
- #define CACHE_TRACKS 10
+ enum {
+ CACHE_TRACKS = 10
+ };
/* used for mp3 CD music */
+ int _current_cd_sound;
+
int _cached_tracks[CACHE_TRACKS];
int _dig_cd_index;
int _dig_cd_track;
@@ -100,6 +105,8 @@ public:
int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
byte _sfxMode;
+ Bundle *_bundle; // FIXME: should be protected but is used by Scumm::askForDisk
+
public:
Sound(Scumm *parent);
~Sound();