aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/dc
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-30 05:28:09 +0000
committerAlejandro Marzini2010-07-30 05:28:09 +0000
commitfb4086cadb8ce3e473dae40558d713e7a31b3858 (patch)
tree95c19d544da914c43a43f0538a1977f43e17cb39 /backends/platform/dc
parent7b070bbef8275ff25dfc2cbc3106acfdc8de74a5 (diff)
parenta17e3c444917ca90dfd537c2102a6150e7ffe977 (diff)
downloadscummvm-rg350-fb4086cadb8ce3e473dae40558d713e7a31b3858.tar.gz
scummvm-rg350-fb4086cadb8ce3e473dae40558d713e7a31b3858.tar.bz2
scummvm-rg350-fb4086cadb8ce3e473dae40558d713e7a31b3858.zip
Merged from trunk, from Rev 50841 to HEAD
svn-id: r51495
Diffstat (limited to 'backends/platform/dc')
-rw-r--r--backends/platform/dc/Makefile2
-rw-r--r--backends/platform/dc/dc.h3
-rw-r--r--backends/platform/dc/dcmain.cpp11
-rw-r--r--backends/platform/dc/module.mk9
-rw-r--r--backends/platform/dc/selector.cpp98
5 files changed, 87 insertions, 36 deletions
diff --git a/backends/platform/dc/Makefile b/backends/platform/dc/Makefile
index 2dcf9b7a7c..4494e8da78 100644
--- a/backends/platform/dc/Makefile
+++ b/backends/platform/dc/Makefile
@@ -69,6 +69,8 @@ OBJS := dcmain.o time.o display.o audio.o input.o selector.o icon.o \
MODULE_DIRS += ./
+BACKEND := dc
+
include $(srcdir)/Makefile.common
scummvm.bin : scummvm.elf
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index e87a0a8c90..057ab283cf 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -233,6 +233,9 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys
Common::SaveFileManager *createSavefileManager();
+
+ Common::SeekableReadStream *createConfigReadStream();
+ Common::WriteStream *createConfigWriteStream();
};
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index 5a9286093f..5fde919650 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -31,6 +31,7 @@
#include "icon.h"
#include "DCLauncherDialog.h"
#include <common/config-manager.h>
+#include <common/stream.h>
#include "backends/plugins/dc/dc-provider.h"
#include "sound/mixer_intern.h"
@@ -206,6 +207,16 @@ void OSystem_Dreamcast::getTimeAndDate(TimeDate &td) const {
td.tm_year = t.tm_year;
}
+Common::SeekableReadStream *OSystem_Dreamcast::createConfigReadStream() {
+ Common::FSNode file("/scummvm.ini");
+ Common::SeekableReadStream *s = file.createReadStream();
+ return s? s : new Common::MemoryReadStream((const byte *)"", 0);
+}
+
+Common::WriteStream *OSystem_Dreamcast::createConfigWriteStream() {
+ return 0;
+}
+
void DCHardware::dc_init_hardware()
{
#ifndef NOSERIAL
diff --git a/backends/platform/dc/module.mk b/backends/platform/dc/module.mk
index eecb91909c..c52ca1a474 100644
--- a/backends/platform/dc/module.mk
+++ b/backends/platform/dc/module.mk
@@ -3,8 +3,7 @@ MODULE := backends/platform/dc
MODULE_OBJS := dcmain.o time.o display.o audio.o input.o selector.o icon.o \
label.o vmsave.o softkbd.o dcloader.o cache.o dc-fs.o
-MODULE_DIRS += \
- backends/platform/dc/
-
-# We don't use the rules.mk here on purpose
-OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS)
+# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
+MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
+OBJS := $(MODULE_OBJS) $(OBJS)
+MODULE_DIRS += $(sort $(dir $(MODULE_OBJS)))
diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp
index 0d8e0a0188..0d9b931d2c 100644
--- a/backends/platform/dc/selector.cpp
+++ b/backends/platform/dc/selector.cpp
@@ -30,6 +30,7 @@
#include <base/plugins.h>
#include <common/fs.h>
#include <common/events.h>
+#include <common/config-manager.h>
#include "dc.h"
#include "icon.h"
#include "label.h"
@@ -200,12 +201,43 @@ static bool uniqueGame(const char *base, const char *dir,
return true;
}
-static int findGames(Game *games, int max)
+static int findGames(Game *games, int max, bool use_ini)
{
Dir *dirs = new Dir[MAX_DIR];
- int curr_game = 0, curr_dir = 0, num_dirs = 1;
- dirs[0].node = Common::FSNode("");
- while (curr_game < max && curr_dir < num_dirs) {
+ int curr_game = 0, curr_dir = 0, num_dirs = 0;
+
+ if (use_ini) {
+ ConfMan.loadDefaultConfigFile();
+ Common::ConfigManager::DomainMap &game_domains = ConfMan.getGameDomains();
+ for(Common::ConfigManager::DomainMap::const_iterator i =
+ game_domains.begin(); curr_game < max && i != game_domains.end(); i++) {
+ Common::String path = (*i)._value["path"];
+ if (path.size() && path.lastChar() != '/')
+ path += "/";
+ int j;
+ for (j=0; j<num_dirs; j++)
+ if (path.equals(dirs[j].node.getPath()))
+ break;
+ if (j >= num_dirs) {
+ if (num_dirs >= MAX_DIR)
+ continue;
+ dirs[j = num_dirs++].node = Common::FSNode(path);
+ }
+ if (curr_game < max) {
+ strcpy(games[curr_game].filename_base, (*i)._key.c_str());
+ strncpy(games[curr_game].dir, dirs[j].node.getPath().c_str(), 256);
+ games[curr_game].dir[255] = '\0';
+ games[curr_game].language = Common::UNK_LANG;
+ games[curr_game].platform = Common::kPlatformUnknown;
+ strcpy(games[curr_game].text, (*i)._value["description"].c_str());
+ curr_game++;
+ }
+ }
+ } else {
+ dirs[num_dirs++].node = Common::FSNode("");
+ }
+
+ while ((curr_game < max || use_ini) && curr_dir < num_dirs) {
strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252);
dirs[curr_dir].name[251] = '\0';
dirs[curr_dir].deficon[0] = '\0';
@@ -214,44 +246,46 @@ static int findGames(Game *games, int max)
for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end();
++entry) {
if (entry->isDirectory()) {
- if (num_dirs < MAX_DIR && strcasecmp(entry->getDisplayName().c_str(),
- "install")) {
+ if (!use_ini && num_dirs < MAX_DIR &&
+ strcasecmp(entry->getDisplayName().c_str(), "install")) {
dirs[num_dirs].node = *entry;
num_dirs++;
}
} else
if (isIcon(*entry))
strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str());
- else
+ else if(!use_ini)
files.push_back(*entry);
}
- GameList candidates = EngineMan.detectGames(files);
-
- for (GameList::const_iterator ge = candidates.begin();
- ge != candidates.end(); ++ge)
- if (curr_game < max) {
- strcpy(games[curr_game].filename_base, ge->gameid().c_str());
- strcpy(games[curr_game].dir, dirs[curr_dir-1].name);
- games[curr_game].language = ge->language();
- games[curr_game].platform = ge->platform();
- if (uniqueGame(games[curr_game].filename_base,
- games[curr_game].dir,
- games[curr_game].language,
- games[curr_game].platform, games, curr_game)) {
-
- strcpy(games[curr_game].text, ge->description().c_str());
+ if (!use_ini) {
+ GameList candidates = EngineMan.detectGames(files);
+
+ for (GameList::const_iterator ge = candidates.begin();
+ ge != candidates.end(); ++ge)
+ if (curr_game < max) {
+ strcpy(games[curr_game].filename_base, ge->gameid().c_str());
+ strcpy(games[curr_game].dir, dirs[curr_dir-1].name);
+ games[curr_game].language = ge->language();
+ games[curr_game].platform = ge->platform();
+ if (uniqueGame(games[curr_game].filename_base,
+ games[curr_game].dir,
+ games[curr_game].language,
+ games[curr_game].platform, games, curr_game)) {
+
+ strcpy(games[curr_game].text, ge->description().c_str());
#if 0
- printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n",
- games[curr_game].text,
- (int)games[curr_game].language,
- (int)games[curr_game].platform,
- games[curr_game].dir, games[curr_game].filename_base,
- dirs[curr_dir-1].name);
+ printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n",
+ games[curr_game].text,
+ (int)games[curr_game].language,
+ (int)games[curr_game].platform,
+ games[curr_game].dir, games[curr_game].filename_base,
+ dirs[curr_dir-1].name);
#endif
- curr_game++;
+ curr_game++;
+ }
}
- }
+ }
}
for (int i=0; i<curr_game; i++)
@@ -426,7 +460,9 @@ bool selectGame(char *&ret, char *&dir_ret, Common::Language &lang_ret, Common::
void *mark = ta_txmark();
for (;;) {
- num_games = findGames(games, MAX_GAMES);
+ num_games = findGames(games, MAX_GAMES, true);
+ if (!num_games)
+ num_games = findGames(games, MAX_GAMES, false);
for (int i=0; i<num_games; i++) {
games[i].icon.create_texture();