[Scummvm-git-logs] scummvm master -> 52fbe6620aea9f2f6ca77172bbbd9511d5394807
bluegr
noreply at scummvm.org
Sat Nov 23 17:24:05 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
52fbe6620a BACKENDS: MORPHOS: enhanced init and add features
Commit: 52fbe6620aea9f2f6ca77172bbbd9511d5394807
https://github.com/scummvm/scummvm/commit/52fbe6620aea9f2f6ca77172bbbd9511d5394807
Author: BeWorld (36823759+BeWorld2018 at users.noreply.github.com)
Date: 2024-11-23T19:24:02+02:00
Commit Message:
BACKENDS: MORPHOS: enhanced init and add features
- Add initBackend (same as AmigaOS)
- Add getSystemLanguage() to detect system language (use SDL_GetPreferredLocales)
Changed paths:
backends/fs/morphos/morphos-fs.cpp
backends/platform/sdl/morphos/morphos-main.cpp
backends/platform/sdl/morphos/morphos.cpp
backends/platform/sdl/morphos/morphos.h
backends/platform/sdl/sdl.cpp
diff --git a/backends/fs/morphos/morphos-fs.cpp b/backends/fs/morphos/morphos-fs.cpp
index 6c94bb704e6..94f80f73069 100644
--- a/backends/fs/morphos/morphos-fs.cpp
+++ b/backends/fs/morphos/morphos-fs.cpp
@@ -358,7 +358,19 @@ Common::SeekableWriteStream *MorphOSFilesystemNode::createWriteStream(bool atomi
}
bool MorphOSFilesystemNode::createDirectory() {
- warning("MorphOSFilesystemNode::createDirectory(): Not supported");
+ Common::String createPath = _sPath;
+ if (createPath.lastChar() == '/') {
+ createPath.deleteLastChar();
+ }
+
+ BPTR dirLock = CreateDir(createPath.c_str());
+ if (dirLock) {
+ UnLock(dirLock);
+ _bIsValid = true;
+ _bIsDirectory = true;
+ } else {
+ debug(6, "MorphOSFilesystemNode::createDirectory() failed -> Directory '%s' could not be created!", createPath.c_str());
+ }
return _bIsValid && _bIsDirectory;
}
diff --git a/backends/platform/sdl/morphos/morphos-main.cpp b/backends/platform/sdl/morphos/morphos-main.cpp
index c7bf71e5639..3e23ad8fd67 100644
--- a/backends/platform/sdl/morphos/morphos-main.cpp
+++ b/backends/platform/sdl/morphos/morphos-main.cpp
@@ -30,24 +30,24 @@
int main(int argc, char *argv[]) {
- // Set up a stack cookie to avoid crashes from a stack set too low
- static const char *stack_cookie __attribute__((used)) = "$STACK: 2048000";
+ // Set a stack cookie to avoid crashes from a too low stack.
+ static const char *stack_cookie __attribute__((used)) = "$STACK: 4096000";
- // Create our OSystem instance
+ // Create our OSystem instance.
g_system = new OSystem_MorphOS();
assert(g_system);
- // Pre initialize the backend
+ // Pre-initialize the backend.
g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
#endif
- // Invoke the actual ScummVM main entry point
+ // Invoke the actual ScummVM main entry point.
int res = scummvm_main(argc, argv);
- // Free OSystem
+ // Free OSystem.
g_system->destroy();
return res;
diff --git a/backends/platform/sdl/morphos/morphos.cpp b/backends/platform/sdl/morphos/morphos.cpp
index 363aff87d1a..a26e446b95b 100644
--- a/backends/platform/sdl/morphos/morphos.cpp
+++ b/backends/platform/sdl/morphos/morphos.cpp
@@ -28,7 +28,22 @@
#include "backends/fs/morphos/morphos-fs-factory.h"
#include "backends/dialogs/morphos/morphos-dialogs.h"
+static bool cleanupDone = false;
+
+static void cleanup() {
+ if (!cleanupDone)
+ g_system->destroy();
+}
+
+OSystem_MorphOS::~OSystem_MorphOS() {
+ cleanupDone = true;
+}
+
void OSystem_MorphOS::init() {
+ // Register cleanup function to avoid unfreed signals
+ if (atexit(cleanup))
+ warning("Failed to register cleanup function via atexit()");
+
// Initialze File System Factory
_fsFactory = new MorphOSFilesystemFactory();
@@ -41,8 +56,6 @@ void OSystem_MorphOS::init() {
}
bool OSystem_MorphOS::hasFeature(Feature f) {
- if (f == kFeatureOpenUrl)
- return true;
#if defined(USE_SYSDIALOGS)
if (f == kFeatureSystemBrowserDialog)
@@ -52,6 +65,29 @@ bool OSystem_MorphOS::hasFeature(Feature f) {
return OSystem_SDL::hasFeature(f);
}
+void OSystem_MorphOS::initBackend() {
+
+ // First time user defaults
+ ConfMan.registerDefault("audio_buffer_size", "2048");
+ ConfMan.registerDefault("extrapath", Common::Path("PROGDIR:extras/"));
+ ConfMan.registerDefault("savepath", Common::Path("PROGDIR:saves/"));
+ ConfMan.registerDefault("themepath", Common::Path("PROGDIR:themes/"));
+ // First time .ini defaults
+ if (!ConfMan.hasKey("audio_buffer_size")) {
+ ConfMan.set("audio_buffer_size", "2048");
+ }
+ if (!ConfMan.hasKey("extrapath")) {
+ ConfMan.setPath("extrapath", "PROGDIR:extras/");
+ }
+ if (!ConfMan.hasKey("savepath")) {
+ ConfMan.setPath("savepath", "PROGDIR:saves/");
+ }
+ if (!ConfMan.hasKey("themepath")) {
+ ConfMan.setPath("themepath", "PROGDIR:themes/");
+ }
+ OSystem_SDL::initBackend();
+}
+
void OSystem_MorphOS::logMessage(LogMessageType::Type type, const char * message) {
#ifdef DEBUG_BUILD
printf("%s\n", message);
diff --git a/backends/platform/sdl/morphos/morphos.h b/backends/platform/sdl/morphos/morphos.h
index 761823abe0c..849d62a3667 100644
--- a/backends/platform/sdl/morphos/morphos.h
+++ b/backends/platform/sdl/morphos/morphos.h
@@ -23,11 +23,18 @@
#define PLATFORM_SDL_MORPHOS_H
#include "backends/platform/sdl/sdl.h"
+#include "backends/base-backend.h"
class OSystem_MorphOS : public OSystem_SDL {
public:
+ OSystem_MorphOS() {}
+ virtual ~OSystem_MorphOS();
+
+ bool hasFeature(Feature f) override;
+
void init() override;
- virtual bool hasFeature(Feature f);
+
+ void initBackend() override;
void logMessage(LogMessageType::Type type, const char *message) override;
};
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index f694923ff9a..613ba6181d4 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -656,6 +656,16 @@ Common::WriteStream *OSystem_SDL::createLogFile() {
}
Common::String OSystem_SDL::getSystemLanguage() const {
+
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ SDL_Locale *locales = SDL_GetPreferredLocales();
+ if (locales) {
+ if (locales[0].language != NULL) {
+ return Common::String::format("%s_%s", locales[0].country, locales[0].language);
+ }
+ SDL_free(locales);
+ }
+#endif // SDL_VERSION_ATLEAST(2, 0, 14)
#if defined(USE_DETECTLANG) && !defined(WIN32)
// Activating current locale settings
const Common::String locale = setlocale(LC_ALL, "");
More information about the Scummvm-git-logs
mailing list