synced with scummvm

This commit is contained in:
Pawel Kolodziejski 2011-05-01 17:49:40 +02:00
parent 8e46fdc4c3
commit 6be453780f
192 changed files with 2249 additions and 703 deletions

18
.gitignore vendored
View file

@ -6,6 +6,23 @@
lib*.a
.deps
/config.log
/residual
/residual-static
/config.h
/config.mk
/.gdb_history
/dumps
/Credits.rtf
/*.mshark
/*.dSYM
/MT32_CONTROL.ROM
/MT32_PCM.ROM
/Residual.app
/*.ipk
/.project
/.cproject
/.settings
/dists/codeblocks/*.cbp
/dists/codeblocks/*.depend
/dists/codeblocks/*.layout
@ -18,6 +35,7 @@ lib*.a
/dists/msvc*/*.dat
/dists/msvc*/*.dll
/plugins
/devtools/create_project/create_project
#ignore thumbnails created by windows

View file

@ -25,6 +25,7 @@ MODULES += \
gui \
backends \
engines \
video \
graphics \
audio \
common \

View file

@ -24,14 +24,14 @@
*/
#include "common/debug.h"
#include "common/endian.h"
#include "common/file.h"
#include "common/mutex.h"
#include "common/textconsole.h"
#include "common/queue.h"
#include "common/util.h"
#include "audio/audiostream.h"
#include "audio/decoders/flac.h"
#include "audio/mixer.h"
#include "audio/decoders/mp3.h"
#include "audio/decoders/raw.h"
#include "audio/decoders/vorbis.h"

View file

@ -26,16 +26,14 @@
#ifndef SOUND_AUDIOSTREAM_H
#define SOUND_AUDIOSTREAM_H
#include "common/util.h"
#include "common/scummsys.h"
#include "common/str.h"
#include "common/types.h"
#include "audio/timestamp.h"
namespace Audio {
class SeekableAudioStream;
/**
* Generic audio input stream. Subclasses of this are used to feed arbitrary
* sampled audio data into ScummVM's audio mixer.

View file

@ -32,6 +32,7 @@
#include "common/debug.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/audiostream.h"

View file

@ -54,7 +54,6 @@ namespace Common {
namespace Audio {
class AudioStream;
class SeekableAudioStream;
/**

View file

@ -29,6 +29,7 @@
#include "common/debug.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/audiostream.h"

View file

@ -55,7 +55,6 @@ namespace Common {
namespace Audio {
class AudioStream;
class SeekableAudioStream;
/**

View file

@ -25,9 +25,10 @@
#include "common/endian.h"
#include "common/memstream.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/audiostream.h"
#include "audio/mixer.h"
#include "audio/decoders/raw.h"
namespace Audio {

View file

@ -32,12 +32,12 @@
#include "common/list.h"
namespace Common { class SeekableReadStream; }
namespace Common {
class SeekableReadStream;
}
namespace Audio {
class AudioStream;
class SeekableAudioStream;
/**

View file

@ -32,15 +32,15 @@
#ifdef USE_VORBIS
#include "common/debug.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/audiostream.h"
#ifdef USE_TREMOR
#if defined(__GP32__) // custom libtremor locations
#include <ivorbisfile.h>
#ifdef USE_TREMOLO
#include <tremolo/ivorbisfile.h>
#else
#include <tremor/ivorbisfile.h>
#endif

View file

@ -54,7 +54,6 @@ namespace Common {
namespace Audio {
class AudioStream;
class SeekableAudioStream;
/**

View file

@ -28,6 +28,7 @@
#include "audio/softsynth/opl/mame.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
#include "common/translation.h"
namespace OPL {

View file

@ -23,14 +23,14 @@
*
*/
#include "engines/engine.h"
#include "common/config-manager.h"
#include "common/error.h"
#include "common/str.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/mididrv.h"
#include "audio/musicplugin.h"
#include "common/translation.h"
const byte MidiDriver::_mt32ToGm[128] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F

View file

@ -27,15 +27,10 @@
#define SOUND_MIDIDRV_H
#include "common/scummsys.h"
#include "common/str.h"
#include "common/timer.h"
class MidiChannel;
class MusicDevice;
namespace Audio {
class Mixer;
}
namespace Common { class String; }
/**
* Music types that music drivers can implement and engines can rely on.

View file

@ -25,6 +25,7 @@
#include "audio/midiparser.h"
#include "audio/mididrv.h"
#include "common/textconsole.h"
#include "common/util.h"
//////////////////////////////////////////////////

View file

@ -31,7 +31,6 @@
#include "common/scummsys.h"
#include "common/endian.h"
class MidiParser;
class MidiDriver_BASE;

View file

@ -25,6 +25,7 @@
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "audio/mixer_intern.h"
#include "audio/rate.h"
@ -162,16 +163,11 @@ private:
MixerImpl::MixerImpl(OSystem *system, uint sampleRate)
: _syst(system), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0) {
: _syst(system), _mutex(), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0), _soundTypeSettings() {
assert(sampleRate > 0);
int i;
for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
_volumeForSoundType[i] = kMaxMixerVolume;
for (i = 0; i != NUM_CHANNELS; i++)
for (int i = 0; i != NUM_CHANNELS; i++)
_channels[i] = 0;
}
@ -322,6 +318,21 @@ void MixerImpl::stopHandle(SoundHandle handle) {
_channels[index] = 0;
}
void MixerImpl::muteSoundType(SoundType type, bool mute) {
assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
_soundTypeSettings[type].mute = mute;
for (int i = 0; i != NUM_CHANNELS; ++i) {
if (_channels[i] && _channels[i]->getType() == type)
_channels[i]->notifyGlobalVolChange();
}
}
bool MixerImpl::isSoundTypeMuted(SoundType type) const {
assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
return _soundTypeSettings[type].mute;
}
void MixerImpl::setChannelVolume(SoundHandle handle, byte volume) {
Common::StackLock lock(_mutex);
@ -417,7 +428,7 @@ bool MixerImpl::hasActiveChannelOfType(SoundType type) {
}
void MixerImpl::setVolumeForSoundType(SoundType type, int volume) {
assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType));
assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
// Check range
if (volume > kMaxMixerVolume)
@ -429,7 +440,7 @@ void MixerImpl::setVolumeForSoundType(SoundType type, int volume) {
// scaling? See also Player_V2::setMasterVolume
Common::StackLock lock(_mutex);
_volumeForSoundType[type] = volume;
_soundTypeSettings[type].volume = volume;
for (int i = 0; i != NUM_CHANNELS; ++i) {
if (_channels[i] && _channels[i]->getType() == type)
@ -438,9 +449,9 @@ void MixerImpl::setVolumeForSoundType(SoundType type, int volume) {
}
int MixerImpl::getVolumeForSoundType(SoundType type) const {
assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType));
assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
return _volumeForSoundType[type];
return _soundTypeSettings[type].volume;
}
@ -486,6 +497,7 @@ void Channel::updateChannelVolumes() {
// volume is in the range 0 - kMaxMixerVolume.
// Hence, the vol_l/vol_r values will be in that range, too
if (!_mixer->isSoundTypeMuted(_type)) {
int vol = _mixer->getVolumeForSoundType(_type) * _volume;
if (_balance == 0) {
@ -498,6 +510,9 @@ void Channel::updateChannelVolumes() {
_volL = ((127 - _balance) * vol) / (Mixer::kMaxChannelVolume * 127);
_volR = vol / Mixer::kMaxChannelVolume;
}
} else {
_volL = _volR = 0;
}
}
void Channel::pause(bool paused) {

View file

@ -27,20 +27,13 @@
#define SOUND_MIXER_H
#include "common/types.h"
#include "common/mutex.h"
#include "common/noncopyable.h"
#include "audio/timestamp.h"
class OSystem;
namespace Audio {
class AudioStream;
class Channel;
class Mixer;
class MixerImpl;
class Timestamp;
/**
* A SoundHandle instances corresponds to a specific sound
@ -197,6 +190,20 @@ public:
virtual bool isSoundHandleActive(SoundHandle handle) = 0;
/**
* Set the mute state for a given sound type.
*
* @param type the sound type
* @param mute Whether to mute (= true) or not (= false).
*/
virtual void muteSoundType(SoundType type, bool mute) = 0;
/**
* Query the mute state for a given sound type.
*
* @param type the sound type
*/
virtual bool isSoundTypeMuted(SoundType type) const = 0;
/**
* Set the channel volume for the given handle.

View file

@ -64,7 +64,14 @@ private:
bool _mixerReady;
uint32 _handleSeed;
int _volumeForSoundType[4];
struct SoundTypeSettings {
SoundTypeSettings() : mute(false), volume(kMaxMixerVolume) {}
bool mute;
int volume;
};
SoundTypeSettings _soundTypeSettings[4];
Channel *_channels[NUM_CHANNELS];
@ -97,6 +104,9 @@ public:
virtual bool isSoundHandleActive(SoundHandle handle);
virtual void muteSoundType(SoundType type, bool mute);
virtual bool isSoundTypeMuted(SoundType type) const;
virtual void setChannelVolume(SoundHandle handle, byte volume);
virtual void setChannelBalance(SoundHandle handle, int8 balance);

View file

@ -34,8 +34,6 @@
//
////////////////////////////////////////
class MidiDriver_MPU401;
class MidiChannel_MPU401 : public MidiChannel {
private:

View file

@ -29,6 +29,10 @@
#include "audio/mididrv.h"
#include "common/list.h"
namespace Common {
class Error;
}
class MusicPluginObject;
/**

View file

@ -22,6 +22,7 @@
* $Id$
*/
#include "common/error.h"
#include "audio/null.h"
Common::Error NullMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {

View file

@ -35,6 +35,7 @@
#include "audio/rate.h"
#include "audio/mixer.h"
#include "common/frac.h"
#include "common/textconsole.h"
#include "common/util.h"
namespace Audio {

View file

@ -27,13 +27,11 @@
#define SOUND_RATE_H
#include "common/scummsys.h"
#include "engines/engine.h"
class AudioStream;
namespace Audio {
class AudioStream;
typedef int16 st_sample_t;
typedef uint16 st_volume_t;
typedef uint32 st_size_t;

View file

@ -48,6 +48,7 @@
#include "audio/rate.h"
#include "audio/mixer.h"
#include "common/util.h"
#include "common/textconsole.h"
//#define DEBUG_RATECONV
@ -129,13 +130,11 @@ SimpleRateConverter<stereo, reverseStereo>::SimpleRateConverter(st_rate_t inrate
sr.inLen = 0;
}
extern "C" {
#ifndef IPHONE
#define ARM_SimpleRate_M _ARM_SimpleRate_M
#define ARM_SimpleRate_S _ARM_SimpleRate_S
#define ARM_SimpleRate_R _ARM_SimpleRate_R
#endif
}
extern "C" st_sample_t *ARM_SimpleRate_M(
AudioStream &input,

View file

@ -24,6 +24,11 @@
#include "audio/softsynth/emumidi.h"
#include "common/debug.h"
#include "common/error.h"
#include "common/scummsys.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/types.h"
#include "common/util.h"
#include "audio/fmopl.h"
#include "audio/musicplugin.h"

View file

@ -27,6 +27,9 @@
#ifdef USE_FLUIDSYNTH
#include "common/config-manager.h"
#include "common/error.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "audio/musicplugin.h"
#include "audio/mpu401.h"
#include "audio/softsynth/emumidi.h"

View file

@ -34,15 +34,19 @@
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/error.h"
#include "common/events.h"
#include "common/file.h"
#include "common/system.h"
#include "common/util.h"
#include "common/archive.h"
#include "common/textconsole.h"
#include "common/translation.h"
#include "graphics/fontman.h"
#include "graphics/surface.h"
#include "graphics/pixelformat.h"
#include "graphics/font.h"
class MidiChannel_MT32 : public MidiChannel_MPU401 {
void effectLevel(byte value) { }

View file

@ -100,7 +100,7 @@ void RhythmPart::setBend(unsigned int midiBend) {
}
void Part::setBend(unsigned int midiBend) {
// FIXME:KG: Slightly unbalanced increments, but I wanted min -1.0, centre 0.0 and max 1.0
// FIXME:KG: Slightly unbalanced increments, but I wanted min -1.0, center 0.0 and max 1.0
if (midiBend <= 0x2000) {
bend = ((signed int)midiBend - 0x2000) / (float)0x2000;
} else {
@ -413,7 +413,7 @@ void RhythmPart::setPan(unsigned int midiPan)
}
void Part::setPan(unsigned int midiPan) {
// FIXME:KG: Tweaked this a bit so that we have a left 100%, centre and right 100%
// FIXME:KG: Tweaked this a bit so that we have a left 100%, center and right 100%
// (But this makes the range somewhat skewed)
// Check against the real thing
// NOTE: Panning is inverted compared to GM.

View file

@ -24,7 +24,6 @@
namespace MT32Emu {
class PartialManager;
class Synth;
class Part {

View file

@ -25,8 +25,6 @@
#include "mt32emu.h"
#include "common/str.h"
#if defined(MACOSX) || defined(SOLARIS) || defined(__MINGW32__)
// Older versions of Mac OS X didn't supply a powf function, so using it
// will cause a binary incompatibility when trying to run a binary built

View file

@ -29,7 +29,6 @@ class revmodel;
namespace MT32Emu {
class File;
class TableInitialiser;
class Partial;
class PartialManager;
class Part;

View file

@ -36,6 +36,7 @@
#include "common/system.h"
#include "common/scummsys.h"
#include "common/util.h"
#include <math.h>
#include <string.h>

View file

@ -33,6 +33,9 @@
#include "mame.h"
#include "common/textconsole.h"
#include "common/util.h"
#if defined (_WIN32_WCE) || defined (__SYMBIAN32__) || defined(__GP32__) || defined(GP2X) || defined (__MAEMO__) || defined(__DS__) || defined (__MINT__) || defined(__N64__)
#include "common/config-manager.h"
#endif

View file

@ -30,7 +30,6 @@
#define SOUND_SOFTSYNTH_OPL_MAME_H
#include "common/scummsys.h"
#include "common/util.h"
#include "common/random.h"
#include "audio/fmopl.h"

View file

@ -26,7 +26,6 @@
#define SOUND_SOFTSYNTH_PCSPK_H
#include "audio/audiostream.h"
#include "audio/mixer.h"
#include "common/mutex.h"
namespace Audio {

View file

@ -32,7 +32,6 @@
#include "sid.h"
#include "audio/null.h"
#include <math.h>
namespace Resid {

View file

@ -27,7 +27,11 @@
#include "audio/softsynth/ym2612.h"
#include "common/util.h"
#include "audio/musicplugin.h"
#include "common/error.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/translation.h"
#include "common/types.h"
////////////////////////////////////////
//

View file

@ -31,6 +31,7 @@
#include "backends/platform/sdl/sdl.h"
#include "backends/graphics/graphics.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
// FIXME move joystick defines out and replace with confile file options
// we should really allow users to map any key to a joystick button

View file

@ -31,6 +31,7 @@
#endif
#include "backends/graphics/graphics.h"
#include "graphics/pixelformat.h"
#include "graphics/scaler.h"
#include "common/events.h"
#include "common/system.h"

View file

@ -31,6 +31,7 @@
#ifdef ENABLE_KEYMAPPER
#include "backends/keymapper/types.h"
#include "common/textconsole.h"
namespace Common {

View file

@ -26,6 +26,7 @@
#ifdef ENABLE_KEYMAPPER
#include "common/system.h"
#include "gui/gui-manager.h"
#include "gui/widgets/popup.h"
#include "gui/widgets/scrollbar.h"

View file

@ -33,8 +33,10 @@
#include "gui/dialog.h"
namespace GUI {
class PopupWidget;
class ButtonWidget;
class PopUpWidget;
class ScrollBarWidget;
class StaticTextWidget;
}
namespace Common {

View file

@ -30,6 +30,8 @@
#if defined(USE_ALSA)
#include "common/config-manager.h"
#include "common/error.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/musicplugin.h"
#include "audio/mpu401.h"

View file

@ -29,6 +29,8 @@
#if defined(__amigaos4__)
#include "common/textconsole.h"
#include "common/error.h"
#include "common/endian.h"
#include "common/util.h"
#include "audio/musicplugin.h"
@ -135,8 +137,8 @@ void MidiDriver_CAMD::sysEx(const byte *msg, uint16 length) {
char *MidiDriver_CAMD::getDevice() {
char *retname = NULL;
APTR key;
if (key = _ICamd->LockCAMD(CD_Linkages)) {
APTR key = _ICamd->LockCAMD(CD_Linkages);
if (key != NULL) {
struct MidiCluster *cluster = _ICamd->NextCluster(NULL);
while (cluster && !retname) {

View file

@ -41,6 +41,8 @@
#include "common/config-manager.h"
#include "common/error.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/musicplugin.h"
#include "audio/mpu401.h"

View file

@ -30,6 +30,8 @@
#ifdef MACOSX
#include "common/config-manager.h"
#include "common/error.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/musicplugin.h"
#include "audio/mpu401.h"

View file

@ -35,6 +35,8 @@
#if defined(USE_SEQ_MIDI)
#include "common/error.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "audio/musicplugin.h"
#include "audio/mpu401.h"

View file

@ -41,13 +41,13 @@
#if defined(USE_TIMIDITY)
#include "common/util.h"
#include "common/endian.h"
#include "common/error.h"
#include "common/str.h"
#include "common/textconsole.h"
#include "audio/musicplugin.h"
#include "audio/mpu401.h"
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

View file

@ -38,6 +38,8 @@
#include "audio/mpu401.h"
#include "common/config-manager.h"
#include "common/translation.h"
#include "common/textconsole.h"
#include "common/error.h"
#include <mmsystem.h>

View file

@ -23,7 +23,7 @@
*
*/
#if defined(MACOSX) || defined(GP2X)
#if defined(MACOSX) || defined(GP2X) || defined(CAANOO) || defined(GP2XWIZ)
#include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h"

View file

@ -26,8 +26,10 @@
#if defined(SDL_BACKEND)
#include "backends/mixer/sdl/sdl-mixer.h"
#include "common/debug.h"
#include "common/system.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
#ifdef GP2X
#define SAMPLES_PER_SEC 11025

View file

@ -26,12 +26,14 @@
#include "backends/modular-backend.h"
#include "backends/fs/fs-factory.h"
#include "backends/events/default/default-events.h"
#include "backends/audiocd/default/default-audiocd.h"
#include "backends/mutex/mutex.h"
#include "backends/audiocd/audiocd.h"
#include "backends/graphics/graphics.h"
#include "backends/mutex/mutex.h"
#include "audio/mixer.h"
#include "common/events.h"
#include "gui/message.h"
#include "graphics/pixelformat.h"
ModularBackend::ModularBackend()
:

View file

@ -43,11 +43,6 @@ MODULE_OBJS := \
vkeybd/virtual-keyboard-gui.o \
vkeybd/virtual-keyboard-parser.o
ifeq ($(BACKEND),dc)
MODULE_OBJS += \
plugins/dc/dc-provider.o
endif
ifeq ($(BACKEND),ds)
MODULE_OBJS += \
fs/ds/ds-fs-factory.o \

View file

@ -32,6 +32,7 @@
#include "backends/platform/sdl/sdl.h"
#include "common/config-manager.h"
#include "common/EventRecorder.h"
#include "common/textconsole.h"
#include "backends/saves/default/default-saves.h"
#include "backends/audiocd/sdl/sdl-audiocd.h"
@ -333,7 +334,11 @@ void OSystem_SDL::setupIcon() {
unsigned int rgba[256];
unsigned int *icon;
sscanf(residual_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes);
if (sscanf(residual_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) {
warning("Wrong format of residual_icon[0] (%s)", scummvm_icon[0]);
return;
}
if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) {
warning("Could not load the built-in icon (%d %d %d %d)", w, h, ncols, nbytes);
return;
@ -348,13 +353,17 @@ void OSystem_SDL::setupIcon() {
unsigned char code;
char color[32];
unsigned int col;
sscanf(residual_icon[1 + i], "%c c %s", &code, color);
if (sscanf(residual_icon[1 + i], "%c c %s", &code, color) != 2) {
warning("Wrong format of residual_icon[%d] (%s)", 1 + i, residual_icon[1 + i]);
}
if (!strcmp(color, "None"))
col = 0x00000000;
else if (!strcmp(color, "black"))
col = 0xFF000000;
else if (color[0] == '#') {
sscanf(color + 1, "%06x", &col);
if (sscanf(color + 1, "%06x", &col) != 1) {
warning("Wrong format of color (%s)", color + 1);
}
col |= 0xFF000000;
} else {
warning("Could not load the built-in icon (%d %s - %s) ", code, color, residual_icon[1 + i]);

View file

@ -27,6 +27,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "common/scummsys.h"
#include "common/error.h"
#include "common/textconsole.h"
#ifdef WIN32

View file

@ -27,6 +27,7 @@
#define BACKENDS_PLUGINS_DYNAMICPLUGIN_H
#include "base/plugins.h"
#include "common/textconsole.h"
class DynamicPlugin : public Plugin {

View file

@ -60,7 +60,7 @@ void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) {
Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) {
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
if (getError().getCode() != Common::kNoError)
return Common::StringArray();
// recreate FSNode since checkPath may have changed/created the directory
@ -84,7 +84,7 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String
// Ensure that the savepath is valid. If not, generate an appropriate error.
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
if (getError().getCode() != Common::kNoError)
return 0;
// recreate FSNode since checkPath may have changed/created the directory
@ -104,7 +104,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String
// Ensure that the savepath is valid. If not, generate an appropriate error.
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
if (getError().getCode() != Common::kNoError)
return 0;
// recreate FSNode since checkPath may have changed/created the directory
@ -121,7 +121,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
if (getError().getCode() != Common::kNoError)
return false;
// recreate FSNode since checkPath may have changed/created the directory

View file

@ -31,6 +31,7 @@
#include "common/config-manager.h"
#include "common/savefile.h"
#include "common/textconsole.h"
#include <stdio.h>
#include <string.h>

View file

@ -25,9 +25,7 @@
#include "common/util.h"
#include "common/savefile.h"
#include <stdio.h>
#include <string.h>
#include "common/str.h"
namespace Common {

View file

@ -28,8 +28,6 @@
#include "common/timer.h"
#include "common/mutex.h"
class OSystem;
struct TimerSlot;
class DefaultTimerManager : public Common::TimerManager {

View file

@ -30,6 +30,8 @@
#include "backends/timer/sdl/sdl-timer.h"
#include "common/textconsole.h"
static Uint32 timer_handler(Uint32 interval, void *param) {
((DefaultTimerManager *)param)->handler();
return interval;

View file

@ -27,6 +27,8 @@
#ifdef ENABLE_VKEYBD
#include "common/textconsole.h"
#include "backends/vkeybd/image-map.h"
#include "backends/vkeybd/polygon.h"

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<keyboard initial_mode="lowercase" v_align="bottom" h_align="centre">
<keyboard initial_mode="lowercase" v_align="bottom" h_align="center">
<!-- coords key = "start x, start y, end x, end y" -->
<!-- Lowercase -->
<mode name="lowercase" resolutions="320x240,640x480">

View file

@ -203,7 +203,7 @@ void VirtualKeyboardGUI::moveToDefaultPosition()
case VirtualKeyboard::kAlignLeft:
x = 0;
break;
case VirtualKeyboard::kAlignCentre:
case VirtualKeyboard::kAlignCenter:
x = (_screenW - kbdW) / 2;
break;
case VirtualKeyboard::kAlignRight:

View file

@ -84,7 +84,7 @@ bool VirtualKeyboardParser::parserCallback_keyboard(ParserNode *node) {
if (h.equalsIgnoreCase("left"))
_keyboard->_hAlignment = VirtualKeyboard::kAlignLeft;
else if (h.equalsIgnoreCase("centre") || h.equalsIgnoreCase("center"))
_keyboard->_hAlignment = VirtualKeyboard::kAlignCentre;
_keyboard->_hAlignment = VirtualKeyboard::kAlignCenter;
else if (h.equalsIgnoreCase("right"))
_keyboard->_hAlignment = VirtualKeyboard::kAlignRight;
}

View file

@ -51,7 +51,7 @@ keyboard layouts for different screen resolutions.
** Example keyboard pack description file **
********************************************
<keyboard modes="normal,caps" initial_mode="normal" v_align="bottom" h_align="centre">
<keyboard modes="normal,caps" initial_mode="normal" v_align="bottom" h_align="center">
<mode name="normal" resolutions="640x400,320x200">
<layout resolution="640x400" bitmap="normal_640x400.bmp" transparent_color="255,0,255">
<map>

View file

@ -33,6 +33,7 @@
#include "backends/vkeybd/virtual-keyboard-parser.h"
#include "backends/vkeybd/keycode-descriptions.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
#include "common/unzip.h"
#define KEY_START_CHAR ('[')
@ -71,7 +72,7 @@ void VirtualKeyboard::reset() {
deleteEvents();
_modes.clear();
_initialMode = _currentMode = 0;
_hAlignment = kAlignCentre;
_hAlignment = kAlignCenter;
_vAlignment = kAlignBottom;
_keyQueue.clear();
_loaded = false;

View file

@ -134,7 +134,7 @@ protected:
enum HorizontalAlignment {
kAlignLeft,
kAlignCentre,
kAlignCenter,
kAlignRight
};

View file

@ -30,6 +30,7 @@
#include "common/config-manager.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/fs.h"
#include "gui/ThemeEngine.h"
@ -59,9 +60,12 @@ static const char HELP_STRING[] =
" -h, --help Display a brief help text and exit\n"
" -z, --list-games Display list of supported games and exit\n"
" -t, --list-targets Display list of configured targets and exit\n"
" --list-saves=TARGET Display a list of savegames for the game (TARGET) specified\n"
"\n"
" -c, --config=CONFIG Use alternate configuration file\n"
" -p, --path=PATH Path to where the game is installed\n"
" -f, --fullscreen Force full-screen mode\n"
" -F, --no-fullscreen Force windowed mode\n"
" --gui-theme=THEME Select GUI theme\n"
" --themepath=PATH Path to where GUI themes are stored\n"
" --list-themes Display list of all usable GUI themes\n"
@ -147,6 +151,7 @@ void registerDefaults() {
ConfMan.registerDefault("dimuse_tempo", 10);
// Miscellaneous
ConfMan.registerDefault("joystick_num", -1);
ConfMan.registerDefault("confirm_exit", false);
ConfMan.registerDefault("disable_sdl_parachute", false);
@ -193,7 +198,7 @@ void registerDefaults() {
#define DO_OPTION_INT(shortCmd, longCmd) \
DO_OPTION(shortCmd, longCmd) \
char *endptr = 0; \
int intValue; intValue = (int)strtol(option, &endptr, 0); \
strtol(option, &endptr, 0); \
if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);
// Use this for boolean options; this distinguishes between "-x" and "-X",
@ -285,6 +290,13 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
END_OPTION
#endif
DO_LONG_OPTION("list-saves")
// FIXME: Need to document this.
// TODO: Make the argument optional. If no argument is given, list all savegames
// for all configured targets.
return "list-saves";
END_OPTION
DO_OPTION('c', "config")
END_OPTION
@ -300,6 +312,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_OPTION_INT("output-rate")
END_OPTION
DO_OPTION_BOOL('f', "fullscreen")
END_OPTION
DO_LONG_OPTION("opl-driver")
END_OPTION
@ -511,6 +526,67 @@ static void listTargets() {
printf("%s\n", i->c_str());
}
/** List all saves states for the given target. */
static Common::Error listSaves(const char *target) {
Common::Error result = Common::kNoError;
// FIXME HACK
g_system->initBackend();
// Grab the "target" domain, if any
const Common::ConfigManager::Domain *domain = ConfMan.getDomain(target);
// Set up the game domain as newly active domain, so
// target specific savepath will be checked
Common::String oldDomain = ConfMan.getActiveDomainName();
ConfMan.setActiveDomain(target);
// Grab the gameid from the domain resp. use the target as gameid
Common::String gameid;
if (domain)
gameid = domain->getVal("gameid");
if (gameid.empty())
gameid = target;
gameid.toLowercase(); // Normalize it to lower case
// Find the plugin that will handle the specified gameid
const EnginePlugin *plugin = 0;
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
if (!plugin) {
return Common::Error(Common::kEnginePluginNotFound,
Common::String::format("target '%s', gameid '%s", target, gameid.c_str()));
}
if (!(*plugin)->hasFeature(MetaEngine::kSupportsListSaves)) {
// TODO: Include more info about the target (desc, engine name, ...) ???
return Common::Error(Common::kEnginePluginNotSupportSaves,
Common::String::format("target '%s', gameid '%s", target, gameid.c_str()));
} else {
// Query the plugin for a list of savegames
SaveStateList saveList = (*plugin)->listSaves(target);
if (saveList.size() > 0) {
// TODO: Include more info about the target (desc, engine name, ...) ???
printf("Save states for target '%s' (gameid '%s'):\n", target, gameid.c_str());
printf(" Slot Description \n"
" ---- ------------------------------------------------------\n");
for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
printf(" %-4s %s\n", x->save_slot().c_str(), x->description().c_str());
// TODO: Could also iterate over the full hashmap, printing all key-value pairs
}
} else {
printf("There are no save states for target '%s' (gameid '%s'):\n", target, gameid.c_str());
}
}
// Revert to the old active domain
ConfMan.setActiveDomain(oldDomain);
return result;
}
/** Lists all usable themes */
static void listThemes() {
typedef Common::List<GUI::ThemeEngine::ThemeDescriptor> ThList;
@ -560,7 +636,7 @@ static void runDetectorTest() {
bool gameidDiffers = false;
GameList::iterator x;
for (x = candidates.begin(); x != candidates.end(); ++x) {
gameidDiffers |= (strcasecmp(gameid.c_str(), x->gameid().c_str()) != 0);
gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid().c_str()) != 0);
}
if (candidates.empty()) {
@ -734,6 +810,8 @@ Common::Error processSettings(Common::String &command, Common::StringMap &settin
} else if (command == "list-games") {
listGames();
return Common::kNoError;
} else if (command == "list-saves") {
return listSaves(settings["list-saves"].c_str());
} else if (command == "list-themes") {
listThemes();
return Common::kNoError;

View file

@ -23,12 +23,15 @@
*
*/
#ifndef BASE_OPTIONS_H
#define BASE_OPTIONS_H
#ifndef COMMON_COMMAND_LINE_H
#define COMMON_COMMAND_LINE_H
#include "common/str.h"
#include "common/error.h"
#include "common/config-manager.h"
#include "common/hash-str.h"
namespace Common {
class Error;
class String;
}
namespace Base {

View file

@ -43,14 +43,13 @@
#include "common/debug-channels.h" /* for debug manager */
#include "common/events.h"
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/tokenizer.h"
#include "common/translation.h"
#include "gui/gui-manager.h"
#include "gui/message.h"
#include "gui/error.h"
#include "audio/mididrv.h"
@ -111,13 +110,12 @@ static const EnginePlugin *detectPlugin() {
if (plugin == 0) {
printf("failed\n");
warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
return 0;
} else {
printf("%s\n", plugin->getName());
}
// FIXME: Do we really need this one?
printf(" Starting '%s'\n", game.description().c_str());
}
return plugin;
}
@ -131,24 +129,20 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const
// Verify that the game path refers to an actual directory
if (!(dir.exists() && dir.isDirectory()))
err = Common::kInvalidPathError;
err = Common::kPathNotDirectory;
// Create the game engine
if (err == Common::kNoError)
if (err.getCode() == Common::kNoError)
err = (*plugin)->createInstance(&system, &engine);
// Check for errors
if (!engine || err != Common::kNoError) {
// TODO: An errorDialog for this and engine related errors is displayed already in the scummvm_main function
// Is a separate dialog here still required?
//GUI::displayErrorDialog("ScummVM could not find any game in the specified directory!");
const char *errMsg = _(Common::errorToString(err));
if (!engine || err.getCode() != Common::kNoError) {
// Print a warning; note that scummvm_main will also
// display an error dialog, so we don't have to do this here.
warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
plugin->getName(),
errMsg,
err.getDesc().c_str(),
ConfMan.getActiveDomainName().c_str(),
dir.getPath().c_str()
);
@ -344,8 +338,11 @@ extern "C" int residual_main(int argc, const char * const argv[]) {
Common::Error res;
// TODO: deal with settings that require plugins to be loaded
if ((res = Base::processSettings(command, settings)) != Common::kArgumentNotProcessed)
return res;
res = Base::processSettings(command, settings);
if (res.getCode() != Common::kArgumentNotProcessed) {
warning("%s", res.getDesc().c_str());
return res.getCode();
}
// Init the backend. Must take place after all config data (including
// the command line params) was read.
@ -400,14 +397,14 @@ extern "C" int residual_main(int argc, const char * const argv[]) {
#endif
// Did an error occur ?
if (result != Common::kNoError) {
if (result.getCode() != Common::kNoError) {
// Shows an informative error dialog if starting the selected game failed.
GUI::displayErrorDialog(result, _("Error running game:"));
}
// Quit unless an error occurred, or Return to launcher was requested
#ifndef FORCE_RTL
if (result == 0 && !g_system->getEventManager()->shouldRTL())
if (result.getCode() == Common::kNoError && !g_system->getEventManager()->shouldRTL())
break;
#endif
// Reset RTL flag in case we want to load another engine

View file

@ -27,16 +27,10 @@
#define BASE_PLUGINS_H
#include "common/array.h"
#include "common/error.h"
#include "common/singleton.h"
#include "common/util.h"
#include "common/fs.h"
#include "common/str.h"
//#include "backends/plugins/elf/version.h"
namespace Common {
class FSList;
class FSNode;
}
/**
* @page pagePlugins An overview of the ScummVM plugin system

View file

@ -28,6 +28,7 @@
#include "common/config-manager.h"
#include "common/random.h"
#include "common/savefile.h"
#include "common/textconsole.h"
DECLARE_SINGLETON(Common::EventRecorder);

View file

@ -25,8 +25,8 @@
#include "common/archive.h"
#include "common/fs.h"
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
namespace Common {

View file

@ -27,7 +27,6 @@
#define COMMON_ARCHIVE_H
#include "common/str.h"
#include "common/hash-str.h"
#include "common/list.h"
#include "common/ptr.h"
#include "common/singleton.h"

View file

@ -27,6 +27,7 @@
#define COMMON_BUFFEREDSTREAM_H
#include "common/stream.h"
#include "common/types.h"
namespace Common {

View file

@ -27,7 +27,7 @@
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/util.h"
#include "common/textconsole.h"
#define MAXLINELEN 256
@ -101,11 +101,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
// of the 'comment' variable with that entity. The semicolon and
// C++-style comments are used for Living Books games in Mohawk.
comment += line;
#ifdef _WIN32
comment += "\r\n";
#else
comment += "\n";
#endif
} else if (line[0] == '(') {
// HACK: The following is a hack added by Kirben to support the
// "map.ini" used in the HE SCUMM game "SPY Fox in Hold the Mustard".

View file

@ -26,13 +26,15 @@
#ifndef COMMON_CONFIG_FILE_H
#define COMMON_CONFIG_FILE_H
#include "common/config-manager.h"
#include "common/hash-str.h"
#include "common/list.h"
#include "common/str.h"
#include "common/stream.h"
namespace Common {
class SeekableReadStream;
class WriteStream;
/**
* This class allows reading/writing INI style config files.
* It is used by the ConfigManager for storage, but can also

View file

@ -24,10 +24,11 @@
*/
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
DECLARE_SINGLETON(Common::ConfigManager);
@ -179,11 +180,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
// of a new domain, or a key-value-pair, we associate the value
// of the 'comment' variable with that entity.
comment += line;
#ifdef _WIN32
comment += "\r\n";
#else
comment += "\n";
#endif
} else if (line[0] == '[') {
// It's a new domain which begins here.
// Determine where the previously accumulated domain goes, if we accumulated anything.

View file

@ -24,8 +24,8 @@
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
#include <stdarg.h> // For va_list etc.

View file

@ -48,7 +48,7 @@
*/
// Sanity check
#if !defined(SYSTEM_LITTLE_ENDIAN) && !defined(SYSTEM_BIG_ENDIAN)
#if !defined(SCUMM_LITTLE_ENDIAN) && !defined(SCUMM_BIG_ENDIAN)
# error No endianness defined
#endif
@ -152,7 +152,7 @@
// Functions for reading/writing native Integers,
// this transparently handles the need for alignment
#if !defined(SYSTEM_NEED_ALIGNMENT)
#if !defined(SCUMM_NEED_ALIGNMENT)
FORCEINLINE uint16 READ_UINT16(const void *ptr) {
return *(const uint16 *)(ptr);
@ -197,7 +197,7 @@
// use software fallback by loading each byte explicitely
#else
# if defined(SYSTEM_LITTLE_ENDIAN)
# if defined(SCUMM_LITTLE_ENDIAN)
inline uint16 READ_UINT16(const void *ptr) {
const uint8 *b = (const uint8 *)ptr;
@ -220,7 +220,7 @@
b[3] = (uint8)(value >> 24);
}
# elif defined(SYSTEM_BIG_ENDIAN)
# elif defined(SCUMM_BIG_ENDIAN)
inline uint16 READ_UINT16(const void *ptr) {
const uint8 *b = (const uint8 *)ptr;
@ -249,7 +249,7 @@
// Map Funtions for reading/writing BE/LE integers depending on native endianess
#if defined(SYSTEM_LITTLE_ENDIAN)
#if defined(SCUMM_LITTLE_ENDIAN)
#define READ_LE_UINT16(a) READ_UINT16(a)
#define READ_LE_UINT32(a) READ_UINT32(a)
@ -276,7 +276,7 @@
#define CONSTANT_BE_16(a) SWAP_CONSTANT_16(a)
// if the unaligned load and the byteswap take alot instructions its better to directly read and invert
# if defined(SYSTEM_NEED_ALIGNMENT) && !defined(__mips__)
# if defined(SCUMM_NEED_ALIGNMENT) && !defined(__mips__)
inline uint16 READ_BE_UINT16(const void *ptr) {
const uint8 *b = (const uint8 *)ptr;
@ -313,9 +313,9 @@
WRITE_UINT32(ptr, SWAP_BYTES_32(value));
}
# endif // if defined(SYSTEM_NEED_ALIGNMENT)
# endif // if defined(SCUMM_NEED_ALIGNMENT)
#elif defined(SYSTEM_BIG_ENDIAN)
#elif defined(SCUMM_BIG_ENDIAN)
#define READ_BE_UINT16(a) READ_UINT16(a)
#define READ_BE_UINT32(a) READ_UINT32(a)
@ -342,7 +342,7 @@
#define CONSTANT_BE_16(a) ((uint16)(a))
// if the unaligned load and the byteswap take alot instructions its better to directly read and invert
# if defined(SYSTEM_NEED_ALIGNMENT) && !defined(__mips__)
# if defined(SCUMM_NEED_ALIGNMENT) && !defined(__mips__)
inline uint16 READ_LE_UINT16(const void *ptr) {
const uint8 *b = (const uint8 *)ptr;
@ -379,9 +379,9 @@
WRITE_UINT32(ptr, SWAP_BYTES_32(value));
}
# endif // if defined(SYSTEM_NEED_ALIGNMENT)
# endif // if defined(SCUMM_NEED_ALIGNMENT)
#endif // if defined(SYSTEM_LITTLE_ENDIAN)
#endif // if defined(SCUMM_LITTLE_ENDIAN)
inline uint32 READ_LE_UINT24(const void *ptr) {
const uint8 *b = (const uint8 *)ptr;
@ -393,7 +393,7 @@ inline uint32 READ_BE_UINT24(const void *ptr) {
return (b[0] << 16) | (b[1] << 8) | (b[2]);
}
#if defined(SYSTEM_BIG_ENDIAN)
#if defined(SCUMM_BIG_ENDIAN)
inline float get_float(const char *data) {
const unsigned char *udata = reinterpret_cast<const unsigned char *>(data);

View file

@ -24,51 +24,68 @@
*/
#include "common/error.h"
#include "common/util.h"
#include "common/translation.h"
namespace Common {
/**
* Error Table: Maps error codes to their default descriptions
* Maps an error code to equivalent string description.
*
* @param errorCode error code to be converted
* @return a pointer to string description of the error
*/
static String errorToString(ErrorCode errorCode) {
switch (errorCode) {
case kNoError:
return _s("No error");
case kNoGameDataFoundError:
return _s("Game data not found");
case kUnsupportedGameidError:
return _s("Game id not supported");
case kUnsupportedColorMode:
return _s("Unsupported color mode");
struct ErrorMessage {
Error error;
const char *errMsg;
};
case kReadPermissionDenied:
return _s("Read permission denied");
case kWritePermissionDenied:
return _s("Write permission denied");
static const ErrorMessage _errMsgTable[] = {
{ kInvalidPathError, _s("Invalid Path") },
{ kNoGameDataFoundError, _s("Game Data not found") },
{ kUnsupportedGameidError, _s("Game Id not supported") },
{ kUnsupportedColorMode, _s("Unsupported Color Mode") },
case kPathDoesNotExist:
return _s("Path does not exist");
case kPathNotDirectory:
return _s("Path not a directory");
case kPathNotFile:
return _s("Path not a file");
{ kReadPermissionDenied, _s("Read permission denied") },
{ kWritePermissionDenied, _s("Write permission denied") },
case kCreatingFileFailed:
return _s("Cannot create file");
case kReadingFailed:
return _s("Reading data failed");
case kWritingFailed:
return _s("Writing data failed");
// The following three overlap a bit with kInvalidPathError and each other. Which to keep?
{ kPathDoesNotExist, _s("Path not exists") },
{ kPathNotDirectory, _s("Path not a directory") },
{ kPathNotFile, _s("Path not a file") },
case kEnginePluginNotFound:
return _s("Could not find suitable engine plugin");
case kEnginePluginNotSupportSaves:
return _s("Engine plugin does not support save states");
{ kCreatingFileFailed, _s("Cannot create file") },
{ kReadingFailed, _s("Reading failed") },
{ kWritingFailed, _s("Writing data failed") },
case kArgumentNotProcessed:
return _s("Command line argument not processed");
{ kUnknownError, _s("Unknown Error") }
};
const char *errorToString(Error error) {
for (int i = 0; i < ARRAYSIZE(_errMsgTable); i++) {
if (error == _errMsgTable[i].error) {
return _errMsgTable[i].errMsg;
case kUnknownError:
default:
return _s("Unknown error");
}
}
return _("Unknown Error");
Error::Error(ErrorCode code)
: _code(code), _desc(errorToString(code)) {
}
Error::Error(ErrorCode code, const String &desc)
: _code(code), _desc(errorToString(code) + " (" + desc + ")") {
}
} // End of namespace Common

View file

@ -26,6 +26,8 @@
#ifndef COMMON_ERROR_H
#define COMMON_ERROR_H
#include "common/str.h"
namespace Common {
/**
@ -37,15 +39,13 @@ namespace Common {
/**
* Error codes which may be reported by plugins under various circumstances.
*
* @todo Clarify the names; add more codes, resp. verify all existing ones are acutally useful.
* Also, try to avoid overlap.
* @todo Maybe introduce a naming convention? E.g. k-NOUN/ACTION-CONDITION-Error, so
* kPathInvalidError would be correct, but these would not be: kInvalidPath,
* kPathInvalid, kPathIsInvalid, kInvalidPathError
* @note Error names should follow the pattern k-NOUN/ACTION-CONDITION-Error.
* So kPathInvalidError would be correct, but these would not be:
* kInvalidPath, kPathInvalid, kPathIsInvalid, kInvalidPathError.
* @todo Adjust all error codes to comply with these conventions.
*/
enum Error {
enum ErrorCode {
kNoError = 0, ///< No error occurred
kInvalidPathError, ///< Engine initialization: Invalid game path was passed
kNoGameDataFoundError, ///< Engine initialization: No game data was found in the specified location
kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine
kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode
@ -54,7 +54,6 @@ enum Error {
kReadPermissionDenied, ///< Unable to read data due to missing read permission
kWritePermissionDenied, ///< Unable to write data due to missing write permission
// The following three overlap a bit with kInvalidPathError and each other. Which to keep?
kPathDoesNotExist, ///< The specified path does not exist
kPathNotDirectory, ///< The specified path does not point to a directory
kPathNotFile, ///< The specified path does not point to a file
@ -64,21 +63,48 @@ enum Error {
kWritingFailed, ///< Failure to write data -- disk full?
// The following are used by --list-saves
kPluginNotFound, ///< Failed to find plugin to handle tager
kPluginNotSupportSaves, ///< Failed if plugin does not support saves
kNoSavesError, ///< There are no saves to show
kEnginePluginNotFound, ///< Failed to find plugin to handle target
kEnginePluginNotSupportSaves, ///< Failed if plugin does not support listing save states
kArgumentNotProcessed, ///< Used in command line parsing
kUnknownError ///< Catch-all error, used if no other error code matches
};
/**
* Maps an error code to equivalent string description.
*
* @param error error code to be converted
* @return a pointer to string description of the error
* An Error instance pairs an error code with string description providing more
* details about the error. For every error code, a default description is
* provided, but it is possible to optionally augment that description with
* extra information when creating a new Error instance.
*/
const char *errorToString(Error error);
class Error {
protected:
ErrorCode _code;
String _desc;
public:
/**
* Construct a new Error with the specified error code and the default
* error message.
*/
Error(ErrorCode code = kUnknownError);
/**
* Construct a new Error with the specified error code and an augmented
* error message. Specifically, the provided extra text is suitably
* appended to the default message.
*/
Error(ErrorCode code, const String &extra);
/**
* Get the description of this error.
*/
const String &getDesc() const { return _desc; }
/**
* Get the error code of this error.
*/
ErrorCode getCode() const { return _code; }
};
} // End of namespace Common

View file

@ -27,8 +27,7 @@
#include "common/debug.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
namespace Common {

View file

@ -27,6 +27,7 @@
#define COMMON_FILE_H
#include "common/scummsys.h"
#include "common/fs.h"
#include "common/noncopyable.h"
#include "common/str.h"
#include "common/stream.h"
@ -34,7 +35,6 @@
namespace Common {
class Archive;
class FSNode;
/**
* TODO: vital to document this core class properly!!! For both users and implementors

View file

@ -22,8 +22,8 @@
* $Id$
*/
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "backends/fs/abstract-fs.h"
#include "backends/fs/fs-factory.h"

View file

@ -27,6 +27,8 @@
#include "common/array.h"
#include "common/archive.h"
#include "common/hash-str.h"
#include "common/hashmap.h"
#include "common/ptr.h"
#include "common/str.h"

View file

@ -47,8 +47,6 @@
#include "common/func.h"
#include "common/str.h"
#include "common/util.h"
#ifdef DEBUG_HASH_COLLISIONS
#include "common/debug.h"

View file

@ -31,7 +31,7 @@
#include "common/macresman.h"
#include "common/md5.h"
#include "common/substream.h"
#include "common/memstream.h"
#include "common/textconsole.h"
#ifdef MACOSX
#include "common/config-manager.h"
@ -623,6 +623,11 @@ void MacResManager::convertCrsrCursor(SeekableReadStream *data, byte **cursor, i
// Pixel data for cursor
int iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]);
byte *iconData = new byte[iconDataSize];
if (!iconData) {
error("Cannot allocate iconData in macresman.cpp");
}
data->read(iconData, iconDataSize);
// Color table

View file

@ -33,15 +33,14 @@
*/
#include "common/array.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/str.h"
#ifndef COMMON_MACRESMAN_H
#define COMMON_MACRESMAN_H
namespace Common {
class FSNode;
typedef Array<uint16> MacResIDArray;
typedef Array<uint32> MacResTagArray;

View file

@ -28,10 +28,10 @@
* this program is licensed under the GPL.
*/
#include "common/file.h"
#include "common/fs.h"
#include "common/md5.h"
#include "common/endian.h"
#include "common/str.h"
#include "common/stream.h"
namespace Common {

View file

@ -26,11 +26,11 @@
#define COMMON_MD5_H
#include "common/scummsys.h"
#include "common/str.h"
namespace Common {
class ReadStream;
class String;
/**
* Compute the MD5 checksum of the content of the given ReadStream.

View file

@ -27,6 +27,7 @@
#define COMMON_MEMSTREAM_H
#include "common/stream.h"
#include "common/types.h"
namespace Common {

View file

@ -120,13 +120,13 @@
// which can't use our "configure" tool and hence don't use config.h.
//
// Some #defines that occur here frequently:
// SYSTEM_LITTLE_ENDIAN
// SCUMM_LITTLE_ENDIAN
// - Define this on a little endian target
// SYSTEM_BIG_ENDIAN
// SCUMM_BIG_ENDIAN
// - Define this on a big endian target
// SYSTEM_NEED_ALIGNMENT
// SCUMM_NEED_ALIGNMENT
// - Define this if your system has problems reading e.g. an int32 from an odd address
// SYSTEM_DONT_DEFINE_TYPES
// SCUMMVM_DONT_DEFINE_TYPES
// - Define this if you need to provide your own typedefs, e.g. because your
// system headers conflict with our typenames, or because you have odd
// type requirements.
@ -137,7 +137,7 @@
// We define all types in config.h, so we don't want to typedef those types
// here again!
#ifdef HAVE_CONFIG_H
#define SYSTEM_DONT_DEFINE_TYPES
#define SCUMMVM_DONT_DEFINE_TYPES
#endif
@ -152,22 +152,25 @@
// If neither is possible, tough luck. Try to contact the team, maybe we can
// come up with a solution, though I wouldn't hold my breath on it :-/.
//
#define SYSTEM_USE_PRAGMA_PACK
#define SCUMMVM_USE_PRAGMA_PACK
#if defined(__SYMBIAN32__)
#define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#define SMALL_SCREEN_DEVICE
// Enable Symbians own datatypes
// This is done for two reasons
// a) uint is already defined by Symbians libc component
// b) Symbian is using its "own" datatyping, and the Residual port
// b) Symbian is using its "own" datatyping, and the Scummvm port
// should follow this to ensure the best compability possible.
#define SYSTEM_DONT_DEFINE_TYPES
#define SCUMMVM_DONT_DEFINE_TYPES
typedef unsigned char byte;
typedef unsigned char uint8;
@ -181,11 +184,11 @@
#elif defined(_WIN32_WCE)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define scumm_stricmp stricmp
#define scumm_strnicmp _strnicmp
#define snprintf _snprintf
#define SYSTEM_LITTLE_ENDIAN
#define SCUMM_LITTLE_ENDIAN
#ifndef __GNUC__
#define FORCEINLINE __forceinline
@ -199,11 +202,11 @@
#elif defined(_MSC_VER)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define scumm_stricmp stricmp
#define scumm_strnicmp _strnicmp
#define snprintf _snprintf
#define SYSTEM_LITTLE_ENDIAN
#define SCUMM_LITTLE_ENDIAN
#define FORCEINLINE __forceinline
#define NORETURN_PRE __declspec(noreturn)
@ -212,15 +215,18 @@
#elif defined(__MINGW32__)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define scumm_stricmp stricmp
#define scumm_strnicmp strnicmp
#define SYSTEM_LITTLE_ENDIAN
#define SCUMM_LITTLE_ENDIAN
#define PLUGIN_EXPORT __declspec(dllexport)
#elif defined(UNIX)
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#ifndef CONFIG_H
/* need this for the SDL_BYTEORDER define */
#include <SDL_byteorder.h>
@ -235,7 +241,7 @@
#endif
// You need to set this manually if necessary
// #define SYSTEM_NEED_ALIGNMENT
// #define SCUMM_NEED_ALIGNMENT
// Very BAD hack following, used to avoid triggering an assert in uClibc dingux library
// "toupper" when pressing keyboard function keys.
@ -246,19 +252,22 @@
#elif defined(__DC__)
#define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#elif defined(__GP32__)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define scumm_stricmp stricmp
#define scumm_strnicmp strnicmp
#define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
// Override typenames. uint is already defined by system header files.
#define SYSTEM_DONT_DEFINE_TYPES
#define SCUMMVM_DONT_DEFINE_TYPES
typedef unsigned char byte;
typedef unsigned char uint8;
@ -272,16 +281,23 @@
#elif defined(__PLAYSTATION2__)
#define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#elif defined(__N64__)
#define SYSTEM_BIG_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_BIG_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#define STRINGBUFLEN 256
#define SYSTEM_DONT_DEFINE_TYPES
#define SCUMMVM_DONT_DEFINE_TYPES
typedef unsigned char byte;
typedef unsigned char uint8;
@ -301,31 +317,43 @@
#include <malloc.h>
#include "backends/platform/psp/memory.h"
#define SYSTEM_LITTLE_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
/* to make an efficient, inlined memcpy implementation */
#define memcpy(dst, src, size) psp_memcpy(dst, src, size)
#elif defined(__amigaos4__)
#define SYSTEM_BIG_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_BIG_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#elif defined (__DS__)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define scumm_stricmp stricmp
#define scumm_strnicmp strnicmp
#define SYSTEM_NEED_ALIGNMENT
#define SYSTEM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#define SCUMM_LITTLE_ENDIAN
#define SYSTEM_DONT_DEFINE_TYPES
#define SCUMMVM_DONT_DEFINE_TYPES
#define STRINGBUFLEN 256
// #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__)
#elif defined(__WII__)
#define SYSTEM_BIG_ENDIAN
#define SYSTEM_NEED_ALIGNMENT
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_BIG_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#else
#error No system type defined
@ -387,9 +415,9 @@
//
// Typedef our system types unless SYSTEM_DONT_DEFINE_TYPES is set.
// Typedef our system types unless SCUMMVM_DONT_DEFINE_TYPES is set.
//
#ifndef SYSTEM_DONT_DEFINE_TYPES
#ifndef SCUMMVM_DONT_DEFINE_TYPES
typedef unsigned char byte;
typedef unsigned char uint8;
typedef signed char int8;

View file

@ -563,7 +563,7 @@ int String::compareToIgnoreCase(const String &x) const {
int String::compareToIgnoreCase(const char *x) const {
assert(x != 0);
return strcasecmp(c_str(), x);
return scumm_stricmp(c_str(), x);
}
#pragma mark -

View file

@ -26,9 +26,7 @@
#include "common/stream.h"
#include "common/memstream.h"
#include "common/substream.h"
#include "common/bufferedstream.h"
#include "common/str.h"
#include "common/util.h"
namespace Common {
@ -205,7 +203,6 @@ uint32 SubReadStream::read(void *dataPtr, uint32 dataSize) {
}
dataSize = _parentStream->read(dataPtr, dataSize);
_eos |= _parentStream->eos();
_pos += dataSize;
return dataSize;

View file

@ -26,12 +26,12 @@
#ifndef COMMON_STREAM_H
#define COMMON_STREAM_H
#include "common/types.h"
#include "common/endian.h"
#include "common/scummsys.h"
#include "common/str.h"
namespace Common {
class String;
class SeekableReadStream;
/**

View file

@ -27,6 +27,7 @@
#define COMMON_SUBSTREAM_H
#include "common/stream.h"
#include "common/types.h"
namespace Common {
@ -59,7 +60,7 @@ public:
delete _parentStream;
}
virtual bool eos() const { return _eos; }
virtual bool eos() const { return _eos | _parentStream->eos(); }
virtual bool err() const { return _parentStream->err(); }
virtual void clearErr() { _eos = false; _parentStream->clearErr(); }
virtual uint32 read(void *dataPtr, uint32 dataSize);

Some files were not shown because too many files have changed in this diff Show more