aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/fs/posix-drives/posix-drives-fs-factory.cpp50
-rw-r--r--backends/fs/posix-drives/posix-drives-fs-factory.h54
-rw-r--r--backends/fs/posix-drives/posix-drives-fs.cpp136
-rw-r--r--backends/fs/posix-drives/posix-drives-fs.h56
-rw-r--r--backends/module.mk2
-rw-r--r--backends/platform/3ds/3ds.mk29
-rw-r--r--backends/platform/3ds/README.md16
-rw-r--r--backends/platform/3ds/main.cpp2
-rw-r--r--backends/platform/3ds/osystem.cpp25
-rw-r--r--backends/platform/3ds/osystem.h1
10 files changed, 342 insertions, 29 deletions
diff --git a/backends/fs/posix-drives/posix-drives-fs-factory.cpp b/backends/fs/posix-drives/posix-drives-fs-factory.cpp
new file mode 100644
index 0000000000..709b57c698
--- /dev/null
+++ b/backends/fs/posix-drives/posix-drives-fs-factory.cpp
@@ -0,0 +1,50 @@
+/* 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.
+ *
+ */
+
+#if defined(POSIX)
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "backends/fs/posix-drives/posix-drives-fs-factory.h"
+#include "backends/fs/posix-drives/posix-drives-fs.h"
+
+#include <unistd.h>
+
+void DrivesPOSIXFilesystemFactory::addDrive(const Common::String &name) {
+ _drives.push_back(Common::normalizePath(name, '/'));
+}
+
+AbstractFSNode *DrivesPOSIXFilesystemFactory::makeRootFileNode() const {
+ return new DrivePOSIXFilesystemNode(_drives);
+}
+
+AbstractFSNode *DrivesPOSIXFilesystemFactory::makeCurrentDirectoryFileNode() const {
+ char buf[MAXPATHLEN];
+ return getcwd(buf, MAXPATHLEN) ? new DrivePOSIXFilesystemNode(buf, _drives) : nullptr;
+}
+
+AbstractFSNode *DrivesPOSIXFilesystemFactory::makeFileNodePath(const Common::String &path) const {
+ assert(!path.empty());
+ return new DrivePOSIXFilesystemNode(path, _drives);
+}
+
+#endif
diff --git a/backends/fs/posix-drives/posix-drives-fs-factory.h b/backends/fs/posix-drives/posix-drives-fs-factory.h
new file mode 100644
index 0000000000..08b8b6973d
--- /dev/null
+++ b/backends/fs/posix-drives/posix-drives-fs-factory.h
@@ -0,0 +1,54 @@
+/* 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.
+ *
+ */
+
+#ifndef POSIX_DRIVES_FILESYSTEM_FACTORY_H
+#define POSIX_DRIVES_FILESYSTEM_FACTORY_H
+
+#include "backends/fs/fs-factory.h"
+
+/**
+ * A FilesystemFactory implementation for filesystems with a special
+ * top-level directory with hard-coded entries but that otherwise
+ * implement the POSIX APIs.
+ *
+ * For used with paths like these:
+ * - 'sdcard:/games/scummvm.ini'
+ * - 'hdd1:/usr/bin'
+ */
+class DrivesPOSIXFilesystemFactory : public FilesystemFactory {
+public:
+ /**
+ * Add a drive to the top-level directory
+ */
+ void addDrive(const Common::String &name);
+
+protected:
+ // FilesystemFactory API
+ AbstractFSNode *makeRootFileNode() const override;
+ AbstractFSNode *makeCurrentDirectoryFileNode() const override;
+ AbstractFSNode *makeFileNodePath(const Common::String &path) const override;
+
+private:
+ Common::Array<Common::String> _drives;
+};
+
+#endif
diff --git a/backends/fs/posix-drives/posix-drives-fs.cpp b/backends/fs/posix-drives/posix-drives-fs.cpp
new file mode 100644
index 0000000000..683ab190ae
--- /dev/null
+++ b/backends/fs/posix-drives/posix-drives-fs.cpp
@@ -0,0 +1,136 @@
+/* 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.
+ *
+ */
+
+#if defined(POSIX)
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "backends/fs/posix-drives/posix-drives-fs.h"
+#include "common/algorithm.h"
+
+#include <dirent.h>
+
+DrivePOSIXFilesystemNode::DrivePOSIXFilesystemNode(const Common::String &path, const DrivesArray &drives) :
+ POSIXFilesystemNode(path),
+ _isPseudoRoot(false),
+ _drives(drives) {
+
+ if (isDrive(path)) {
+ _isDirectory = true;
+ _isValid = true;
+
+ // FIXME: Add a setting for deciding whether drive paths need to end with a slash
+ if (!_path.hasSuffix("/")) {
+ _path += "/";
+ }
+ return;
+ }
+}
+
+DrivePOSIXFilesystemNode::DrivePOSIXFilesystemNode(const DrivesArray &drives) :
+ _isPseudoRoot(true),
+ _drives(drives) {
+ _isDirectory = true;
+ _isValid = false;
+}
+
+AbstractFSNode *DrivePOSIXFilesystemNode::getChild(const Common::String &n) const {
+ if (!_isPseudoRoot) {
+ return POSIXFilesystemNode::getChild(n);
+ }
+
+ // Make sure the string contains no slashes
+ assert(!n.contains('/'));
+
+ Common::String newPath(_path);
+ if (_path.lastChar() != '/')
+ newPath += '/';
+ newPath += n;
+
+ return makeNode(newPath);
+}
+
+bool DrivePOSIXFilesystemNode::getChildren(AbstractFSList &list, AbstractFSNode::ListMode mode, bool hidden) const {
+ assert(_isDirectory);
+
+ if (_isPseudoRoot) {
+ for (uint i = 0; i < _drives.size(); i++) {
+ list.push_back(makeNode(_drives[i]));
+ }
+
+ return true;
+ } else {
+ DIR *dirp = opendir(_path.c_str());
+ struct dirent *dp;
+
+ if (!dirp)
+ return false;
+
+ while ((dp = readdir(dirp)) != nullptr) {
+ // Skip 'invisible' files if necessary
+ if (dp->d_name[0] == '.' && !hidden) {
+ continue;
+ }
+
+ // Skip '.' and '..' to avoid cycles
+ if ((dp->d_name[0] == '.' && dp->d_name[1] == 0) || (dp->d_name[0] == '.' && dp->d_name[1] == '.')) {
+ continue;
+ }
+
+ AbstractFSNode *child = getChild(dp->d_name);
+
+ // Honor the chosen mode
+ if ((mode == Common::FSNode::kListFilesOnly && child->isDirectory()) ||
+ (mode == Common::FSNode::kListDirectoriesOnly && !child->isDirectory())) {
+ delete child;
+ continue;
+ }
+
+ list.push_back(child);
+ }
+
+ closedir(dirp);
+
+ return true;
+ }
+}
+
+AbstractFSNode *DrivePOSIXFilesystemNode::getParent() const {
+ if (_isPseudoRoot) {
+ return nullptr;
+ }
+
+ if (isDrive(_path)) {
+ DrivePOSIXFilesystemNode *root = new DrivePOSIXFilesystemNode(_drives);
+ return root;
+ }
+
+ return POSIXFilesystemNode::getParent();
+}
+
+bool DrivePOSIXFilesystemNode::isDrive(const Common::String &path) const {
+ Common::String normalizedPath = Common::normalizePath(path, '/');
+ DrivesArray::const_iterator drive = Common::find(_drives.begin(), _drives.end(), normalizedPath);
+ return drive != _drives.end();
+}
+
+#endif //#if defined(POSIX)
diff --git a/backends/fs/posix-drives/posix-drives-fs.h b/backends/fs/posix-drives/posix-drives-fs.h
new file mode 100644
index 0000000000..43c89423fa
--- /dev/null
+++ b/backends/fs/posix-drives/posix-drives-fs.h
@@ -0,0 +1,56 @@
+/* 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.
+ *
+ */
+
+#ifndef POSIX_DRIVES_FILESYSTEM_H
+#define POSIX_DRIVES_FILESYSTEM_H
+
+#include "backends/fs/posix/posix-fs.h"
+
+/**
+ * POSIX file system node where the top-level directory is a hardcoded
+ * list of drives.
+ */
+class DrivePOSIXFilesystemNode : public POSIXFilesystemNode {
+protected:
+ AbstractFSNode *makeNode(const Common::String &path) const override {
+ return new DrivePOSIXFilesystemNode(path, _drives);
+ }
+
+public:
+ typedef Common::Array<Common::String> DrivesArray;
+
+ DrivePOSIXFilesystemNode(const Common::String &path, const DrivesArray &drives);
+ DrivePOSIXFilesystemNode(const DrivesArray &drives);
+
+ // POSIXFilesystemNode API
+ AbstractFSNode *getChild(const Common::String &n) const override;
+ bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const override;
+ AbstractFSNode *getParent() const override;
+
+private:
+ bool _isPseudoRoot;
+ const DrivesArray &_drives;
+
+ bool isDrive(const Common::String &path) const;
+};
+
+#endif
diff --git a/backends/module.mk b/backends/module.mk
index 771b3f80a0..2201e65354 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -161,6 +161,8 @@ ifdef POSIX
MODULE_OBJS += \
fs/posix/posix-fs.o \
fs/posix/posix-fs-factory.o \
+ fs/posix-drives/posix-drives-fs.o \
+ fs/posix-drives/posix-drives-fs-factory.o \
fs/chroot/chroot-fs-factory.o \
fs/chroot/chroot-fs.o \
plugins/posix/posix-provider.o \
diff --git a/backends/platform/3ds/3ds.mk b/backends/platform/3ds/3ds.mk
index 7cb162ff88..dcb7b5e3ab 100644
--- a/backends/platform/3ds/3ds.mk
+++ b/backends/platform/3ds/3ds.mk
@@ -21,21 +21,40 @@ clean: clean_3ds
clean_3ds:
$(RM) $(TARGET).3dsx
$(RM) $(TARGET).cia
+ $(RM) -rf romfs
+
+romfs: $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD)
+ @rm -rf romfs
+ @mkdir -p romfs
+ @cp $(DIST_FILES_THEMES) romfs/
+ifdef DIST_FILES_ENGINEDATA
+ @cp $(DIST_FILES_ENGINEDATA) romfs/
+endif
+ifdef DIST_FILES_NETWORKING
+ @cp $(DIST_FILES_NETWORKING) romfs/
+endif
+ifdef DIST_FILES_VKEYBD
+ @cp $(DIST_FILES_VKEYBD) romfs/
+endif
$(TARGET).smdh: $(APP_ICON)
@smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
@echo built ... $(notdir $@)
-$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh
- @3dsxtool $< $@ --smdh=$(TARGET).smdh
+$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh romfs
+ @3dsxtool $< $@ --smdh=$(TARGET).smdh --romfs=romfs
@echo built ... $(notdir $@)
$(TARGET).bnr: $(APP_BANNER_IMAGE) $(APP_BANNER_AUDIO)
@bannertool makebanner -o $@ -i $(APP_BANNER_IMAGE) -a $(APP_BANNER_AUDIO)
@echo built ... $(notdir $@)
-
-$(TARGET).cia: $(EXECUTABLE) $(APP_RSF) $(TARGET).smdh $(TARGET).bnr
- @makerom -f cia -target t -exefslogo -o $@ -elf $(EXECUTABLE) -rsf $(APP_RSF) -banner $(TARGET).bnr -icon $(TARGET).smdh
+
+$(TARGET).romfs: romfs
+ @3dstool -cvtf romfs $(TARGET).romfs --romfs-dir romfs
+ @echo built ... $(notdir $@)
+
+$(TARGET).cia: $(EXECUTABLE) $(APP_RSF) $(TARGET).smdh $(TARGET).bnr $(TARGET).romfs
+ @makerom -f cia -target t -exefslogo -o $@ -elf $(EXECUTABLE) -rsf $(APP_RSF) -banner $(TARGET).bnr -icon $(TARGET).smdh -romfs $(TARGET).romfs
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
diff --git a/backends/platform/3ds/README.md b/backends/platform/3ds/README.md
index b45a2a69d1..95ce0f4a8f 100644
--- a/backends/platform/3ds/README.md
+++ b/backends/platform/3ds/README.md
@@ -49,19 +49,7 @@ Not having this file will cause many problems with games that need audio, someti
even crashing, so this is NOT considered optional.
Using any CIA installation software (search elsewhere for that), you need to install
-the `scummvm.cia` file. Then, just like what is done with the 3DSX installation, you
-need to extract all ScummVM 3DS files (`scummvm.cia` excluded) to the root of your SD
-card so that all files reside in the `/3ds/scummvm/` directory.
-
-1.3) Additional files
----------------------
-In order to use the Virtual Keyboard, you need to get the:
-`backends/vkeybd/packs/vkeybd_small.zip` file from ScummVM's repository, and
-place it on your SD card, in the `/3ds/scummvm/kb` folder.
-
-In case you want a translated GUI, you need to get the:
-`scummvm/gui/themes/translations.dat` file from ScummVM's repository, and place
-it on your SD card, in the `/3ds/scummvm/themes` folder.
+the `scummvm.cia` file.
2.0) Controls
-------------
@@ -229,7 +217,7 @@ Additionally compile to specific formats to be used on the 3DS:
Assuming everything was successful, you'll be able to find the binary
files in the root of your scummvm folder.
-Note: for the CIA format, you will need the 'makerom' and 'bannertool' tools which are
+Note: for the CIA format, you will need the '3dstool', 'makerom' and 'bannertool' tools which are
not supplied with devkitPro.
4.3) Warning for build sizes
diff --git a/backends/platform/3ds/main.cpp b/backends/platform/3ds/main.cpp
index dc89faaef6..ce549b67c4 100644
--- a/backends/platform/3ds/main.cpp
+++ b/backends/platform/3ds/main.cpp
@@ -27,6 +27,7 @@ int main(int argc, char *argv[]) {
// Initialize basic libctru stuff
gfxInitDefault();
cfguInit();
+ romfsInit();
osSetSpeedupEnable(true);
// consoleInit(GFX_TOP, NULL);
@@ -50,6 +51,7 @@ int main(int argc, char *argv[]) {
gspLcdExit();
}
+ romfsExit();
cfguExit();
gfxExit();
return res;
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index c42e208b40..0e5cb7bfbb 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -36,8 +36,8 @@
#include "common/str.h"
#include "config.h"
-#include "backends/fs/posix/posix-fs-factory.h"
-#include "backends/fs/posix/posix-fs.h"
+#include "backends/fs/posix-drives/posix-drives-fs-factory.h"
+#include "backends/fs/posix-drives/posix-drives-fs.h"
#include <unistd.h>
#include <time.h>
@@ -77,8 +77,13 @@ OSystem_3DS::OSystem_3DS():
sleeping(false)
{
chdir("sdmc:/");
- _fsFactory = new POSIXFilesystemFactory();
- Posix::assureDirectoryExists("/3ds/scummvm/saves/");
+
+ DrivesPOSIXFilesystemFactory *fsFactory = new DrivesPOSIXFilesystemFactory();
+ fsFactory->addDrive("sdmc:");
+ fsFactory->addDrive("romfs:");
+ _fsFactory = fsFactory;
+
+ Posix::assureDirectoryExists("sdmc:/3ds/scummvm/saves/");
}
OSystem_3DS::~OSystem_3DS() {
@@ -101,15 +106,11 @@ void OSystem_3DS::initBackend() {
ConfMan.registerDefault("aspect_ratio", true);
if (!ConfMan.hasKey("vkeybd_pack_name"))
ConfMan.set("vkeybd_pack_name", "vkeybd_small");
- if (!ConfMan.hasKey("vkeybdpath"))
- ConfMan.set("vkeybdpath", "/3ds/scummvm/kb");
- if (!ConfMan.hasKey("themepath"))
- ConfMan.set("themepath", "/3ds/scummvm");
if (!ConfMan.hasKey("gui_theme"))
ConfMan.set("gui_theme", "builtin");
_timerManager = new DefaultTimerManager();
- _savefileManager = new DefaultSaveFileManager("/3ds/scummvm/saves/");
+ _savefileManager = new DefaultSaveFileManager("sdmc:/3ds/scummvm/saves/");
initGraphics();
initAudio();
@@ -125,7 +126,11 @@ void OSystem_3DS::updateConfig() {
}
Common::String OSystem_3DS::getDefaultConfigFileName() {
- return "/3ds/scummvm/scummvm.ini";
+ return "sdmc:/3ds/scummvm/scummvm.ini";
+}
+
+void OSystem_3DS::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
+ s.add("RomFS", new Common::FSDirectory("romfs:/"), priority);
}
uint32 OSystem_3DS::getMillis(bool skipRecord) {
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index 6901295640..28d21c3eda 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -88,6 +88,7 @@ public:
virtual void quit();
virtual Common::String getDefaultConfigFileName();
+ void addSysArchivesToSearchSet(Common::SearchSet &s, int priority) override;
// Graphics
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const;