OSYSTEM: Pushed out some port specific code from common/system.cpp to the respective ports

svn-id: r34812
This commit is contained in:
Max Horn 2008-10-16 17:18:15 +00:00
parent 0cd4939110
commit 36311eefb4
9 changed files with 62 additions and 38 deletions

View file

@ -171,10 +171,22 @@ Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
return _saveMgr;
}
Audio::Mixer * OSystem_PalmBase::getMixer() {
Audio::Mixer *OSystem_PalmBase::getMixer() {
return _mixerMgr;
}
Common::TimerManager * OSystem_PalmBase::getTimerManager() {
Common::TimerManager *OSystem_PalmBase::getTimerManager() {
return _timerMgr;
}
#define PALMOS_CONFIG_FILE "/PALM/Programs/ScummVM/scummvm.ini"
Common::SeekableReadStream *OSystem_PalmBase::openConfigFileForReading() {
Common::FSNode file(PALMOS_CONFIG_FILE);
return file.openForReading();
}
Common::WriteStream *OSystem_PalmBase::openConfigFileForWriting() {
Common::FSNode file(PALMOS_CONFIG_FILE);
return file.openForWriting();
}

View file

@ -257,6 +257,9 @@ public:
Common::SaveFileManager *getSavefileManager();
Common::TimerManager *getTimerManager();
virtual Common::SeekableReadStream *openConfigFileForReading();
virtual Common::WriteStream *openConfigFileForWriting();
};
#endif

View file

@ -1312,8 +1312,14 @@ OSystem *OSystem_IPHONE_create() {
return new OSystem_IPHONE();
}
const char* OSystem_IPHONE::getConfigPath() {
return SCUMMVM_PREFS_PATH;
Common::SeekableReadStream *OSystem_IPHONE::openConfigFileForReading() {
Common::FSNode file(SCUMMVM_PREFS_PATH);
return file.openForReading();
}
Common::WriteStream *OSystem_IPHONE::openConfigFileForWriting() {
Common::FSNode file(SCUMMVM_PREFS_PATH);
return file.openForWriting();
}
void iphone_main(int argc, char *argv[]) {

View file

@ -177,7 +177,8 @@ public:
void startSoundsystem();
void stopSoundsystem();
static const char* getConfigPath();
virtual Common::SeekableReadStream *openConfigFileForReading();
virtual Common::WriteStream *openConfigFileForWriting();
protected:
inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h);

View file

@ -770,6 +770,7 @@ void OSystem_PS2::quit(void) {
}
void OSystem_PS2::makeConfigPath(char *dest) {
// FIXME: Maybe merge this method into openConfigFileForReading/openConfigFileForWriting ?
FILE *handle;
strcpy(dest, "cdfs:/ScummVM.ini");
handle = ps2_fopen(dest, "r");
@ -783,6 +784,20 @@ void OSystem_PS2::makeConfigPath(char *dest) {
strcpy(dest, "mc0:ScummVM/scummvm.ini");
}
Common::SeekableReadStream *OSystem_PS2::openConfigFileForReading() {
char configFile[MAXPATHLEN];
makeConfigPath(configFile);
Common::FSNode file(configFile);
return file.openForReading();
}
Common::WriteStream *OSystem_PS2::openConfigFileForWriting() {
char configFile[MAXPATHLEN];
makeConfigPath(configFile);
Common::FSNode file(configFile);
return file.openForWriting();
}
bool OSystem_PS2::runningFromHost(void) {
return (_bootDevice == HOST);
}

View file

@ -107,6 +107,9 @@ public:
virtual void quit();
virtual Common::SeekableReadStream *openConfigFileForReading();
virtual Common::WriteStream *openConfigFileForWriting();
virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);

View file

@ -677,3 +677,14 @@ void OSystem_PSP::setWindowCaption(const char *caption) {
void OSystem_PSP::displayMessageOnOSD(const char *msg) {
}
#define PSP_CONFIG_FILE "ms0:/scummvm.ini"
Common::SeekableReadStream *OSystem_PSP::openConfigFileForReading() {
Common::FSNode file(PSP_CONFIG_FILE);
return file.openForReading();
}
Common::WriteStream *OSystem_PSP::openConfigFileForWriting() {
Common::FSNode file(PSP_CONFIG_FILE);
return file.openForWriting();
}

View file

@ -145,5 +145,7 @@ public:
virtual void displayMessageOnOSD(const char *msg);
virtual Common::SeekableReadStream *openConfigFileForReading();
virtual Common::WriteStream *openConfigFileForWriting();
};

View file

@ -122,48 +122,19 @@ void OSystem::clearScreen() {
/*
FIXME: The config file loading code below needs to be cleaned up.
Port specific variants should be pushed into the respective ports.
Ideally, the default OSystem::openConfigFileForReading/Writing methods
should be removed completely.
FIXME: Maybe we should push the default config file loading/saving code below
out to all the backends?
*/
#ifdef __PLAYSTATION2__
#include "backends/platform/ps2/systemps2.h"
#endif
#ifdef IPHONE
#include "backends/platform/iphone/osys_iphone.h"
#endif
#if defined(UNIX)
#define DEFAULT_CONFIG_FILE ".scummvmrc"
#else
#define DEFAULT_CONFIG_FILE "scummvm.ini"
#endif
static Common::String getDefaultConfigFileName() {
char configFile[MAXPATHLEN];
#if defined(PALMOS_MODE)
strcpy(configFile,"/PALM/Programs/ScummVM/" DEFAULT_CONFIG_FILE);
#elif defined(IPHONE)
strcpy(configFile, OSystem_IPHONE::getConfigPath());
#elif defined(__PLAYSTATION2__)
((OSystem_PS2*)g_system)->makeConfigPath(configFile);
#elif defined(__PSP__)
strcpy(configFile, "ms0:/" DEFAULT_CONFIG_FILE);
#else
strcpy(configFile, DEFAULT_CONFIG_FILE);
#endif
return configFile;
}
Common::SeekableReadStream *OSystem::openConfigFileForReading() {
Common::FSNode file(getDefaultConfigFileName());
Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.openForReading();
}
@ -171,7 +142,7 @@ Common::WriteStream *OSystem::openConfigFileForWriting() {
#ifdef __DC__
return 0;
#else
Common::FSNode file(getDefaultConfigFileName());
Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.openForWriting();
#endif
}