mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 20:01:25 +00:00
Removed old subsystems design files. Removed graphics.cpp
svn-id: r49474
This commit is contained in:
parent
56b9e6c9b7
commit
e23ae648bc
@ -1,350 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "backends/platform/sdl/audio.h"
|
||||
#include "sound/mixer_intern.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
//#define SAMPLES_PER_SEC 11025
|
||||
#define SAMPLES_PER_SEC 22050
|
||||
//#define SAMPLES_PER_SEC 44100
|
||||
|
||||
SdlSubSys_Audio::SdlSubSys_Audio()
|
||||
:
|
||||
_inited(false),
|
||||
_cdrom(0),
|
||||
#if MIXER_DOUBLE_BUFFERING
|
||||
_soundMutex(0), _soundCond(0), _soundThread(0),
|
||||
_soundThreadIsRunning(false), _soundThreadShouldQuit(false),
|
||||
#endif
|
||||
_mixer(0) {
|
||||
|
||||
}
|
||||
|
||||
SdlSubSys_Audio::~SdlSubSys_Audio() {
|
||||
if (_inited) {
|
||||
audioDone();
|
||||
}
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::audioInit() {
|
||||
if (_inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create and hook up the mixer, if none exists yet (we check for this to
|
||||
// allow subclasses to provide their own).
|
||||
if (_mixer == 0) {
|
||||
setupMixer();
|
||||
}
|
||||
|
||||
_inited = true;
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::audioDone() {
|
||||
if (_cdrom) {
|
||||
SDL_CDStop(_cdrom);
|
||||
SDL_CDClose(_cdrom);
|
||||
}
|
||||
|
||||
closeMixer();
|
||||
|
||||
_inited = false;
|
||||
}
|
||||
|
||||
bool SdlSubSys_Audio::hasFeature(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::setFeatureState(Feature f, bool enable) {
|
||||
|
||||
}
|
||||
|
||||
bool SdlSubSys_Audio::getFeatureState(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if MIXER_DOUBLE_BUFFERING
|
||||
|
||||
void SdlSubSys_Audio::mixerProducerThread() {
|
||||
byte nextSoundBuffer;
|
||||
|
||||
SDL_LockMutex(_soundMutex);
|
||||
while (true) {
|
||||
// Wait till we are allowed to produce data
|
||||
SDL_CondWait(_soundCond, _soundMutex);
|
||||
|
||||
if (_soundThreadShouldQuit)
|
||||
break;
|
||||
|
||||
// Generate samples and put them into the next buffer
|
||||
nextSoundBuffer = _activeSoundBuf ^ 1;
|
||||
_mixer->mixCallback(_soundBuffers[nextSoundBuffer], _soundBufSize);
|
||||
|
||||
// Swap buffers
|
||||
_activeSoundBuf = nextSoundBuffer;
|
||||
}
|
||||
SDL_UnlockMutex(_soundMutex);
|
||||
}
|
||||
|
||||
int SDLCALL SdlSubSys_Audio::mixerProducerThreadEntry(void *arg) {
|
||||
OSystem_SDL *this_ = (OSystem_SDL *)arg;
|
||||
assert(this_);
|
||||
this_->mixerProducerThread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SdlSubSys_Audio::initThreadedMixer(Audio::MixerImpl *mixer, uint bufSize) {
|
||||
_soundThreadIsRunning = false;
|
||||
_soundThreadShouldQuit = false;
|
||||
|
||||
// Create mutex and condition variable
|
||||
_soundMutex = SDL_CreateMutex();
|
||||
_soundCond = SDL_CreateCond();
|
||||
|
||||
// Create two sound buffers
|
||||
_activeSoundBuf = 0;
|
||||
_soundBufSize = bufSize;
|
||||
_soundBuffers[0] = (byte *)calloc(1, bufSize);
|
||||
_soundBuffers[1] = (byte *)calloc(1, bufSize);
|
||||
|
||||
_soundThreadIsRunning = true;
|
||||
|
||||
// Finally start the thread
|
||||
_soundThread = SDL_CreateThread(mixerProducerThreadEntry, this);
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::deinitThreadedMixer() {
|
||||
// Kill thread?? _soundThread
|
||||
|
||||
if (_soundThreadIsRunning) {
|
||||
// Signal the producer thread to end, and wait for it to actually finish.
|
||||
_soundThreadShouldQuit = true;
|
||||
SDL_CondBroadcast(_soundCond);
|
||||
SDL_WaitThread(_soundThread, NULL);
|
||||
|
||||
// Kill the mutex & cond variables.
|
||||
// Attention: AT this point, the mixer callback must not be running
|
||||
// anymore, else we will crash!
|
||||
SDL_DestroyMutex(_soundMutex);
|
||||
SDL_DestroyCond(_soundCond);
|
||||
|
||||
_soundThreadIsRunning = false;
|
||||
|
||||
free(_soundBuffers[0]);
|
||||
free(_soundBuffers[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SdlSubSys_Audio::mixCallback(void *arg, byte *samples, int len) {
|
||||
OSystem_SDL *this_ = (OSystem_SDL *)arg;
|
||||
assert(this_);
|
||||
assert(this_->_mixer);
|
||||
|
||||
assert((int)this_->_soundBufSize == len);
|
||||
|
||||
// Lock mutex, to ensure our data is not overwritten by the producer thread
|
||||
SDL_LockMutex(this_->_soundMutex);
|
||||
|
||||
// Copy data from the current sound buffer
|
||||
memcpy(samples, this_->_soundBuffers[this_->_activeSoundBuf], len);
|
||||
|
||||
// Unlock mutex and wake up the produced thread
|
||||
SDL_UnlockMutex(this_->_soundMutex);
|
||||
SDL_CondSignal(this_->_soundCond);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void SdlSubSys_Audio::mixCallback(void *sys, byte *samples, int len) {
|
||||
SdlSubSys_Audio *this_ = (SdlSubSys_Audio *)sys;
|
||||
assert(this_);
|
||||
assert(this_->_mixer);
|
||||
|
||||
this_->_mixer->mixCallback(samples, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SdlSubSys_Audio::setupMixer() {
|
||||
SDL_AudioSpec desired;
|
||||
|
||||
// Determine the desired output sampling frequency.
|
||||
uint32 samplesPerSec = 0;
|
||||
if (ConfMan.hasKey("output_rate"))
|
||||
samplesPerSec = ConfMan.getInt("output_rate");
|
||||
if (samplesPerSec <= 0)
|
||||
samplesPerSec = SAMPLES_PER_SEC;
|
||||
|
||||
// Determine the sample buffer size. We want it to store enough data for
|
||||
// at least 1/16th of a second (though at most 8192 samples). Note
|
||||
// that it must be a power of two. So e.g. at 22050 Hz, we request a
|
||||
// sample buffer size of 2048.
|
||||
uint32 samples = 8192;
|
||||
while (samples * 16 > samplesPerSec * 2)
|
||||
samples >>= 1;
|
||||
|
||||
memset(&desired, 0, sizeof(desired));
|
||||
desired.freq = samplesPerSec;
|
||||
desired.format = AUDIO_S16SYS;
|
||||
desired.channels = 2;
|
||||
desired.samples = (uint16)samples;
|
||||
desired.callback = mixCallback;
|
||||
desired.userdata = this;
|
||||
|
||||
assert(!_mixer);
|
||||
if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
|
||||
warning("Could not open audio device: %s", SDL_GetError());
|
||||
_mixer = new Audio::MixerImpl(this, samplesPerSec);
|
||||
assert(_mixer);
|
||||
_mixer->setReady(false);
|
||||
} else {
|
||||
// Note: This should be the obtained output rate, but it seems that at
|
||||
// least on some platforms SDL will lie and claim it did get the rate
|
||||
// even if it didn't. Probably only happens for "weird" rates, though.
|
||||
samplesPerSec = _obtainedRate.freq;
|
||||
debug(1, "Output sample rate: %d Hz", samplesPerSec);
|
||||
|
||||
// Create the mixer instance and start the sound processing
|
||||
_mixer = new Audio::MixerImpl(this, samplesPerSec);
|
||||
assert(_mixer);
|
||||
_mixer->setReady(true);
|
||||
|
||||
#if MIXER_DOUBLE_BUFFERING
|
||||
initThreadedMixer(_mixer, _obtainedRate.samples * 4);
|
||||
#endif
|
||||
|
||||
// start the sound system
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::closeMixer() {
|
||||
if (_mixer)
|
||||
_mixer->setReady(false);
|
||||
|
||||
SDL_CloseAudio();
|
||||
|
||||
delete _mixer;
|
||||
_mixer = 0;
|
||||
|
||||
#if MIXER_DOUBLE_BUFFERING
|
||||
deinitThreadedMixer();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Audio::Mixer *SdlSubSys_Audio::getMixer() {
|
||||
assert(_mixer);
|
||||
return _mixer;
|
||||
}
|
||||
|
||||
bool SdlSubSys_Audio::openCD(int drive) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1)
|
||||
_cdrom = NULL;
|
||||
else {
|
||||
_cdrom = SDL_CDOpen(drive);
|
||||
// Did it open? Check if _cdrom is NULL
|
||||
if (!_cdrom) {
|
||||
warning("Couldn't open drive: %s", SDL_GetError());
|
||||
} else {
|
||||
_cdNumLoops = 0;
|
||||
_cdStopTime = 0;
|
||||
_cdEndTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (_cdrom != NULL);
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::stopCD() { /* Stop CD Audio in 1/10th of a second */
|
||||
_cdStopTime = SDL_GetTicks() + 100;
|
||||
_cdNumLoops = 0;
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::playCD(int track, int num_loops, int start_frame, int duration) {
|
||||
if (!num_loops && !start_frame)
|
||||
return;
|
||||
|
||||
if (!_cdrom)
|
||||
return;
|
||||
|
||||
if (duration > 0)
|
||||
duration += 5;
|
||||
|
||||
_cdTrack = track;
|
||||
_cdNumLoops = num_loops;
|
||||
_cdStartFrame = start_frame;
|
||||
|
||||
SDL_CDStatus(_cdrom);
|
||||
if (start_frame == 0 && duration == 0)
|
||||
SDL_CDPlayTracks(_cdrom, track, 0, 1, 0);
|
||||
else
|
||||
SDL_CDPlayTracks(_cdrom, track, start_frame, 0, duration);
|
||||
_cdDuration = duration;
|
||||
_cdStopTime = 0;
|
||||
_cdEndTime = SDL_GetTicks() + _cdrom->track[track].length * 1000 / CD_FPS;
|
||||
}
|
||||
|
||||
bool SdlSubSys_Audio::pollCD() {
|
||||
if (!_cdrom)
|
||||
return false;
|
||||
|
||||
return (_cdNumLoops != 0 && (SDL_GetTicks() < _cdEndTime || SDL_CDStatus(_cdrom) == CD_PLAYING));
|
||||
}
|
||||
|
||||
void SdlSubSys_Audio::updateCD() {
|
||||
if (!_cdrom)
|
||||
return;
|
||||
|
||||
if (_cdStopTime != 0 && SDL_GetTicks() >= _cdStopTime) {
|
||||
SDL_CDStop(_cdrom);
|
||||
_cdNumLoops = 0;
|
||||
_cdStopTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cdNumLoops == 0 || SDL_GetTicks() < _cdEndTime)
|
||||
return;
|
||||
|
||||
if (_cdNumLoops != 1 && SDL_CDStatus(_cdrom) != CD_STOPPED) {
|
||||
// Wait another second for it to be done
|
||||
_cdEndTime += 1000;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cdNumLoops > 0)
|
||||
_cdNumLoops--;
|
||||
|
||||
if (_cdNumLoops != 0) {
|
||||
if (_cdStartFrame == 0 && _cdDuration == 0)
|
||||
SDL_CDPlayTracks(_cdrom, _cdTrack, 0, 1, 0);
|
||||
else
|
||||
SDL_CDPlayTracks(_cdrom, _cdTrack, _cdStartFrame, 0, _cdDuration);
|
||||
_cdEndTime = SDL_GetTicks() + _cdrom->track[_cdTrack].length * 1000 / CD_FPS;
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BACKENDS_SDL_SUBSYS_AUDIO_H
|
||||
#define BACKENDS_SDL_SUBSYS_AUDIO_H
|
||||
|
||||
#include "backends/base-subsys-audio.h"
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
#include <esdl\SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
#if defined(MACOSX)
|
||||
// On Mac OS X, we need to double buffer the audio buffer, else anything
|
||||
// which produces sampled data with high latency (like the MT-32 emulator)
|
||||
// will sound terribly.
|
||||
// This could be enabled for more / most ports in the future, but needs some
|
||||
// testing.
|
||||
#define MIXER_DOUBLE_BUFFERING 1
|
||||
#endif
|
||||
|
||||
namespace Audio {
|
||||
class MixerImpl;
|
||||
}
|
||||
|
||||
class SdlSubSys_Audio : public BaseSubSys_Audio {
|
||||
public:
|
||||
SdlSubSys_Audio();
|
||||
~SdlSubSys_Audio();
|
||||
|
||||
virtual void audioInit();
|
||||
virtual void audioDone();
|
||||
|
||||
bool hasFeature(Feature f);
|
||||
void setFeatureState(Feature f, bool enable);
|
||||
bool getFeatureState(Feature f);
|
||||
|
||||
// Set function that generates samples
|
||||
virtual void setupMixer();
|
||||
static void mixCallback(void *s, byte *samples, int len);
|
||||
|
||||
virtual void closeMixer();
|
||||
|
||||
virtual Audio::Mixer *getMixer();
|
||||
|
||||
virtual bool openCD(int drive);
|
||||
|
||||
// Poll CD status
|
||||
// Returns true if cd audio is playing
|
||||
bool pollCD();
|
||||
|
||||
// Play CD audio track
|
||||
void playCD(int track, int num_loops, int start_frame, int duration);
|
||||
|
||||
// Stop CD audio track
|
||||
void stopCD();
|
||||
|
||||
// Update CD audio status
|
||||
void updateCD();
|
||||
|
||||
protected:
|
||||
bool _inited;
|
||||
|
||||
SDL_AudioSpec _obtainedRate;
|
||||
|
||||
// CD Audio
|
||||
SDL_CD *_cdrom;
|
||||
int _cdTrack, _cdNumLoops, _cdStartFrame, _cdDuration;
|
||||
uint32 _cdEndTime, _cdStopTime;
|
||||
|
||||
#ifdef MIXER_DOUBLE_BUFFERING
|
||||
SDL_mutex *_soundMutex;
|
||||
SDL_cond *_soundCond;
|
||||
SDL_Thread *_soundThread;
|
||||
bool _soundThreadIsRunning;
|
||||
bool _soundThreadShouldQuit;
|
||||
|
||||
byte _activeSoundBuf;
|
||||
uint _soundBufSize;
|
||||
byte *_soundBuffers[2];
|
||||
|
||||
void mixerProducerThread();
|
||||
static int SDLCALL mixerProducerThreadEntry(void *arg);
|
||||
void initThreadedMixer(Audio::MixerImpl *mixer, uint bufSize);
|
||||
void deinitThreadedMixer();
|
||||
#endif
|
||||
|
||||
Audio::MixerImpl *_mixer;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -1,241 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
// winnt.h defines ARRAYSIZE, but we want our own one... - this is needed before including util.h
|
||||
#undef ARRAYSIZE
|
||||
#endif
|
||||
|
||||
#include "backends/platform/sdl/file.h"
|
||||
#include "common/archive.h"
|
||||
|
||||
#ifdef UNIX
|
||||
#include "backends/saves/posix/posix-saves.h"
|
||||
#else
|
||||
#include "backends/saves/default/default-saves.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include header files needed for the getFilesystemFactory() method.
|
||||
*/
|
||||
#if defined(__amigaos4__)
|
||||
#include "backends/fs/amigaos4/amigaos4-fs-factory.h"
|
||||
#elif defined(UNIX)
|
||||
#include "backends/fs/posix/posix-fs-factory.h"
|
||||
#elif defined(WIN32)
|
||||
#include "backends/fs/windows/windows-fs-factory.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(UNIX)
|
||||
#ifdef MACOSX
|
||||
#define DEFAULT_CONFIG_FILE "Library/Preferences/ScummVM Preferences"
|
||||
#elif defined(SAMSUNGTV)
|
||||
#define DEFAULT_CONFIG_FILE "/dtv/usb/sda1/.scummvmrc"
|
||||
#else
|
||||
#define DEFAULT_CONFIG_FILE ".scummvmrc"
|
||||
#endif
|
||||
#else
|
||||
#define DEFAULT_CONFIG_FILE "scummvm.ini"
|
||||
#endif
|
||||
|
||||
SdlSubSys_File::SdlSubSys_File()
|
||||
:
|
||||
_inited(false),
|
||||
_fsFactory(0),
|
||||
_savefile(0) {
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
_fsFactory = new AmigaOSFilesystemFactory();
|
||||
#elif defined(UNIX)
|
||||
_fsFactory = new POSIXFilesystemFactory();
|
||||
#elif defined(WIN32)
|
||||
_fsFactory = new WindowsFilesystemFactory();
|
||||
#elif defined(__SYMBIAN32__)
|
||||
// Do nothing since its handled by the Symbian SDL inheritance
|
||||
#else
|
||||
#error Unknown and unsupported FS backend
|
||||
#endif
|
||||
}
|
||||
|
||||
SdlSubSys_File::~SdlSubSys_File() {
|
||||
if (_inited) {
|
||||
fileDone();
|
||||
}
|
||||
}
|
||||
|
||||
void SdlSubSys_File::fileInit() {
|
||||
if (_inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the savefile manager, if none exists yet (we check for this to
|
||||
// allow subclasses to provide their own).
|
||||
if (_savefile == 0) {
|
||||
#ifdef UNIX
|
||||
_savefile = new POSIXSaveFileManager();
|
||||
#else
|
||||
_savefile = new DefaultSaveFileManager();
|
||||
#endif
|
||||
}
|
||||
|
||||
_inited = true;
|
||||
}
|
||||
|
||||
void SdlSubSys_File::fileDone() {
|
||||
// Event Manager requires save manager for storing
|
||||
// recorded events
|
||||
delete getEventManager();
|
||||
delete _savefile;
|
||||
|
||||
_inited = false;
|
||||
}
|
||||
|
||||
bool SdlSubSys_File::hasFeature(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SdlSubSys_File::setFeatureState(Feature f, bool enable) {
|
||||
|
||||
}
|
||||
|
||||
bool SdlSubSys_File::getFeatureState(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Common::SaveFileManager *SdlSubSys_File::getSavefileManager() {
|
||||
assert(_savefile);
|
||||
return _savefile;
|
||||
}
|
||||
|
||||
FilesystemFactory *SdlSubSys_File::getFilesystemFactory() {
|
||||
assert(_fsFactory);
|
||||
return _fsFactory;
|
||||
}
|
||||
|
||||
void SdlSubSys_File::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
||||
|
||||
#ifdef DATA_PATH
|
||||
// Add the global DATA_PATH to the directory search list
|
||||
// FIXME: We use depth = 4 for now, to match the old code. May want to change that
|
||||
Common::FSNode dataNode(DATA_PATH);
|
||||
if (dataNode.exists() && dataNode.isDirectory()) {
|
||||
s.add(DATA_PATH, new Common::FSDirectory(dataNode, 4), priority);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MACOSX
|
||||
// Get URL of the Resource directory of the .app bundle
|
||||
CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
|
||||
if (fileUrl) {
|
||||
// Try to convert the URL to an absolute path
|
||||
UInt8 buf[MAXPATHLEN];
|
||||
if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) {
|
||||
// Success: Add it to the search path
|
||||
Common::String bundlePath((const char *)buf);
|
||||
s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath), priority);
|
||||
}
|
||||
CFRelease(fileUrl);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static Common::String getDefaultConfigFileName() {
|
||||
char configFile[MAXPATHLEN];
|
||||
#if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
|
||||
OSVERSIONINFO win32OsVersion;
|
||||
ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
|
||||
win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&win32OsVersion);
|
||||
// Check for non-9X version of Windows.
|
||||
if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
|
||||
// Use the Application Data directory of the user profile.
|
||||
if (win32OsVersion.dwMajorVersion >= 5) {
|
||||
if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)))
|
||||
error("Unable to access application data directory");
|
||||
} else {
|
||||
if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)))
|
||||
error("Unable to access user profile directory");
|
||||
|
||||
strcat(configFile, "\\Application Data");
|
||||
CreateDirectory(configFile, NULL);
|
||||
}
|
||||
|
||||
strcat(configFile, "\\ScummVM");
|
||||
CreateDirectory(configFile, NULL);
|
||||
strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
|
||||
|
||||
FILE *tmp = NULL;
|
||||
if ((tmp = fopen(configFile, "r")) == NULL) {
|
||||
// Check windows directory
|
||||
char oldConfigFile[MAXPATHLEN];
|
||||
GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
|
||||
strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE);
|
||||
if ((tmp = fopen(oldConfigFile, "r"))) {
|
||||
strcpy(configFile, oldConfigFile);
|
||||
|
||||
fclose(tmp);
|
||||
}
|
||||
} else {
|
||||
fclose(tmp);
|
||||
}
|
||||
} else {
|
||||
// Check windows directory
|
||||
GetWindowsDirectory(configFile, MAXPATHLEN);
|
||||
strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
|
||||
}
|
||||
#elif defined(UNIX)
|
||||
// On UNIX type systems, by default we store the config file inside
|
||||
// to the HOME directory of the user.
|
||||
//
|
||||
// GP2X is Linux based but Home dir can be read only so do not use
|
||||
// it and put the config in the executable dir.
|
||||
//
|
||||
// On the iPhone, the home dir of the user when you launch the app
|
||||
// from the Springboard, is /. Which we don't want.
|
||||
const char *home = getenv("HOME");
|
||||
if (home != NULL && strlen(home) < MAXPATHLEN)
|
||||
snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE);
|
||||
else
|
||||
strcpy(configFile, DEFAULT_CONFIG_FILE);
|
||||
#else
|
||||
strcpy(configFile, DEFAULT_CONFIG_FILE);
|
||||
#endif
|
||||
|
||||
return configFile;
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *SdlSubSys_File::createConfigReadStream() {
|
||||
Common::FSNode file(getDefaultConfigFileName());
|
||||
return file.createReadStream();
|
||||
}
|
||||
|
||||
Common::WriteStream *SdlSubSys_File::createConfigWriteStream() {
|
||||
Common::FSNode file(getDefaultConfigFileName());
|
||||
return file.createWriteStream();
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BACKENDS_SDL_SUBSYS_FILE_H
|
||||
#define BACKENDS_SDL_SUBSYS_FILE_H
|
||||
|
||||
#include "backends/base-subsys-file.h"
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
#include <esdl\SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
class SdlSubSys_File : public BaseSubSys_File {
|
||||
public:
|
||||
SdlSubSys_File();
|
||||
~SdlSubSys_File();
|
||||
|
||||
virtual void fileInit();
|
||||
virtual void fileDone();
|
||||
|
||||
bool hasFeature(Feature f);
|
||||
void setFeatureState(Feature f, bool enable);
|
||||
bool getFeatureState(Feature f);
|
||||
|
||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
||||
virtual Common::WriteStream *createConfigWriteStream();
|
||||
|
||||
virtual Common::SaveFileManager *getSavefileManager();
|
||||
virtual FilesystemFactory *getFilesystemFactory();
|
||||
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
|
||||
|
||||
protected:
|
||||
bool _inited;
|
||||
|
||||
FilesystemFactory *_fsFactory;
|
||||
Common::SaveFileManager *_savefile;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,6 @@ MODULE := backends/platform/sdl
|
||||
|
||||
MODULE_OBJS := \
|
||||
events.o \
|
||||
graphics.o \
|
||||
hardwarekeys.o \
|
||||
main.o \
|
||||
sdl.o
|
||||
|
@ -1,83 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "backends/platform/sdl/mutex.h"
|
||||
|
||||
SdlSubSys_Mutex::SdlSubSys_Mutex()
|
||||
:
|
||||
_inited(false),
|
||||
_graphicsMutex(0) {
|
||||
|
||||
}
|
||||
|
||||
SdlSubSys_Mutex::~SdlSubSys_Mutex() {
|
||||
if (_inited) {
|
||||
mutexDone();
|
||||
}
|
||||
}
|
||||
|
||||
void SdlSubSys_Mutex::mutexInit() {
|
||||
if (_inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
_graphicsMutex = createMutex();
|
||||
|
||||
_inited = true;
|
||||
}
|
||||
|
||||
void SdlSubSys_Mutex::mutexDone() {
|
||||
deleteMutex(_graphicsMutex);
|
||||
|
||||
_inited = false;
|
||||
}
|
||||
|
||||
bool SdlSubSys_Mutex::hasFeature(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SdlSubSys_Mutex::setFeatureState(Feature f, bool enable) {
|
||||
|
||||
}
|
||||
|
||||
bool SdlSubSys_Mutex::getFeatureState(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OSystem::MutexRef SdlSubSys_Mutex::createMutex() {
|
||||
return (MutexRef) SDL_CreateMutex();
|
||||
}
|
||||
|
||||
void SdlSubSys_Mutex::lockMutex(MutexRef mutex) {
|
||||
SDL_mutexP((SDL_mutex *) mutex);
|
||||
}
|
||||
|
||||
void SdlSubSys_Mutex::unlockMutex(MutexRef mutex) {
|
||||
SDL_mutexV((SDL_mutex *) mutex);
|
||||
}
|
||||
|
||||
void SdlSubSys_Mutex::deleteMutex(MutexRef mutex) {
|
||||
SDL_DestroyMutex((SDL_mutex *) mutex);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BACKENDS_SDL_SUBSYS_MUTEX_H
|
||||
#define BACKENDS_SDL_SUBSYS_MUTEX_H
|
||||
|
||||
#include "backends/base-subsys-mutex.h"
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
#include <esdl\SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
class SdlSubSys_Mutex : public BaseSubSys_Mutex {
|
||||
public:
|
||||
SdlSubSys_Mutex();
|
||||
~SdlSubSys_Mutex();
|
||||
|
||||
virtual void mutexInit();
|
||||
virtual void mutexDone();
|
||||
|
||||
bool hasFeature(Feature f);
|
||||
void setFeatureState(Feature f, bool enable);
|
||||
bool getFeatureState(Feature f);
|
||||
|
||||
// Mutex handling
|
||||
MutexRef createMutex();
|
||||
void lockMutex(MutexRef mutex);
|
||||
void unlockMutex(MutexRef mutex);
|
||||
void deleteMutex(MutexRef mutex);
|
||||
|
||||
protected:
|
||||
bool _inited;
|
||||
|
||||
/**
|
||||
* Mutex which prevents multiple threads from interfering with each other
|
||||
* when accessing the screen.
|
||||
*/
|
||||
MutexRef _graphicsMutex;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -1,120 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "backends/platform/sdl/timer.h"
|
||||
#include "backends/timer/default/default-timer.h"
|
||||
#include "common/EventRecorder.h"
|
||||
#include <time.h> // for getTimeAndDate()
|
||||
|
||||
static Uint32 timer_handler(Uint32 interval, void *param) {
|
||||
((DefaultTimerManager *)param)->handler();
|
||||
return interval;
|
||||
}
|
||||
|
||||
SdlSubSys_Timer::SdlSubSys_Timer()
|
||||
:
|
||||
_inited(false),
|
||||
_timerID(),
|
||||
_timer(0) {
|
||||
|
||||
}
|
||||
|
||||
SdlSubSys_Timer::~SdlSubSys_Timer() {
|
||||
if (_inited) {
|
||||
timerDone();
|
||||
}
|
||||
}
|
||||
|
||||
void SdlSubSys_Timer::timerInit() {
|
||||
if (_inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_TIMER) == -1) {
|
||||
error("Could not initialize SDL Timer: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
// Create and hook up the timer manager, if none exists yet (we check for
|
||||
// this to allow subclasses to provide their own).
|
||||
if (_timer == 0) {
|
||||
// Note: We could implement a custom SDLTimerManager by using
|
||||
// SDL_AddTimer. That might yield better timer resolution, but it would
|
||||
// also change the semantics of a timer: Right now, ScummVM timers
|
||||
// *never* run in parallel, due to the way they are implemented. If we
|
||||
// switched to SDL_AddTimer, each timer might run in a separate thread.
|
||||
// However, not all our code is prepared for that, so we can't just
|
||||
// switch. Still, it's a potential future change to keep in mind.
|
||||
_timer = new DefaultTimerManager();
|
||||
_timerID = SDL_AddTimer(10, &timer_handler, _timer);
|
||||
}
|
||||
|
||||
_inited = true;
|
||||
}
|
||||
|
||||
void SdlSubSys_Timer::timerDone() {
|
||||
delete _timer;
|
||||
SDL_RemoveTimer(_timerID);
|
||||
SDL_QuitSubSystem(SDL_INIT_TIMER);
|
||||
|
||||
_inited = false;
|
||||
}
|
||||
|
||||
bool SdlSubSys_Timer::hasFeature(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SdlSubSys_Timer::setFeatureState(Feature f, bool enable) {
|
||||
|
||||
}
|
||||
|
||||
bool SdlSubSys_Timer::getFeatureState(Feature f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 SdlSubSys_Timer::getMillis() {
|
||||
uint32 millis = SDL_GetTicks();
|
||||
g_eventRec.processMillis(millis);
|
||||
return millis;
|
||||
}
|
||||
|
||||
void SdlSubSys_Timer::delayMillis(uint msecs) {
|
||||
SDL_Delay(msecs);
|
||||
}
|
||||
|
||||
void SdlSubSys_Timer::getTimeAndDate(TimeDate &td) const {
|
||||
time_t curTime = time(0);
|
||||
struct tm t = *localtime(&curTime);
|
||||
td.tm_sec = t.tm_sec;
|
||||
td.tm_min = t.tm_min;
|
||||
td.tm_hour = t.tm_hour;
|
||||
td.tm_mday = t.tm_mday;
|
||||
td.tm_mon = t.tm_mon;
|
||||
td.tm_year = t.tm_year;
|
||||
}
|
||||
|
||||
Common::TimerManager *SdlSubSys_Timer::getTimerManager() {
|
||||
assert(_timer);
|
||||
return _timer;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BACKENDS_SDL_SUBSYS_TIMER_H
|
||||
#define BACKENDS_SDL_SUBSYS_TIMER_H
|
||||
|
||||
#include "backends/base-subsys-timer.h"
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
#include <esdl\SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
class SdlSubSys_Timer : public BaseSubSys_Timer {
|
||||
public:
|
||||
SdlSubSys_Timer();
|
||||
~SdlSubSys_Timer();
|
||||
|
||||
virtual void timerInit();
|
||||
virtual void timerDone();
|
||||
|
||||
bool hasFeature(Feature f);
|
||||
void setFeatureState(Feature f, bool enable);
|
||||
bool getFeatureState(Feature f);
|
||||
|
||||
// Get the number of milliseconds since the program was started.
|
||||
uint32 getMillis();
|
||||
|
||||
// Delay for a specified amount of milliseconds
|
||||
void delayMillis(uint msecs);
|
||||
|
||||
virtual void getTimeAndDate(TimeDate &t) const;
|
||||
virtual Common::TimerManager *getTimerManager();
|
||||
|
||||
protected:
|
||||
bool _inited;
|
||||
|
||||
SDL_TimerID _timerID;
|
||||
Common::TimerManager *_timer;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user