[Scummvm-git-logs] scummvm master -> 40a283def9d121d23937ad6cf531a1ee2f8b868e
dreammaster
dreammaster at scummvm.org
Sat Mar 13 19:14:43 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
80cb4183eb AGS: Move allegro error globals to Globals
766d3a5aa9 AGS: Move wordsdictionary.cpp globals to Globals
f758d84fe8 AGS: Remove unused platforms
40a283def9 AGS: Rename Linux platform driver to ScummVMPlatformDriver
Commit: 80cb4183eb7cb2758f5da16c1c9425c97053fd0e
https://github.com/scummvm/scummvm/commit/80cb4183eb7cb2758f5da16c1c9425c97053fd0e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-13T11:12:41-08:00
Commit Message:
AGS: Move allegro error globals to Globals
Changed paths:
R engines/ags/lib/allegro.cpp
R engines/ags/lib/allegro/error.cpp
engines/ags/engine/ac/file.cpp
engines/ags/engine/platform/base/agsplatformdriver.cpp
engines/ags/engine/platform/base/agsplatformdriver.h
engines/ags/globals.h
engines/ags/lib/allegro.h
engines/ags/lib/allegro/error.h
engines/ags/lib/allegro/fixed.cpp
engines/ags/lib/allegro/math.cpp
engines/ags/module.mk
engines/ags/shared/util/string_utils.cpp
diff --git a/engines/ags/engine/ac/file.cpp b/engines/ags/engine/ac/file.cpp
index 9d0845e0f3..00591d839d 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -76,7 +76,7 @@ int File_Delete(const char *fnmm) {
if (::remove(rp.FullPath) == 0)
return 1;
- if (errnum == AL_ENOENT && !rp.AltPath.IsEmpty() && rp.AltPath.Compare(rp.FullPath) != 0)
+ if (_G(errnum) == AL_ENOENT && !rp.AltPath.IsEmpty() && rp.AltPath.Compare(rp.FullPath) != 0)
return ::remove(rp.AltPath) == 0 ? 1 : 0;
return 0;
}
diff --git a/engines/ags/engine/platform/base/agsplatformdriver.cpp b/engines/ags/engine/platform/base/agsplatformdriver.cpp
index e90ad0a82c..e7796599cc 100644
--- a/engines/ags/engine/platform/base/agsplatformdriver.cpp
+++ b/engines/ags/engine/platform/base/agsplatformdriver.cpp
@@ -39,6 +39,7 @@
#include "ags/lib/system/datetime.h"
#include "ags/lib/std/algorithm.h"
#include "ags/lib/std/thread.h"
+#include "ags/globals.h"
#if defined (AGS_HAS_CD_AUDIO)
#include "libcda.h"
@@ -60,34 +61,52 @@ AGSPlatformDriver *AGSPlatformDriver::instance = nullptr;
void AGSPlatformDriver::AboutToQuitGame() {
}
+
void AGSPlatformDriver::PostAllegroInit(bool windowed) {
}
+
void AGSPlatformDriver::AttachToParentConsole() {
}
+
+int AGSPlatformDriver::GetLastSystemError() {
+ return _G(errnum);
+}
+
void AGSPlatformDriver::DisplaySwitchOut() {
}
+
void AGSPlatformDriver::DisplaySwitchIn() {
}
+
void AGSPlatformDriver::PauseApplication() {
}
+
void AGSPlatformDriver::ResumeApplication() {
}
+
void AGSPlatformDriver::GetSystemDisplayModes(std::vector<DisplayMode> &dms) {
}
+
bool AGSPlatformDriver::EnterFullscreenMode(const DisplayMode &dm) {
return true;
}
+
bool AGSPlatformDriver::ExitFullscreenMode() {
return true;
}
+
void AGSPlatformDriver::AdjustWindowStyleForFullscreen() {
}
+
void AGSPlatformDriver::AdjustWindowStyleForWindowed() {
}
+
void AGSPlatformDriver::RegisterGameWithGameExplorer() {
}
+
void AGSPlatformDriver::UnRegisterGameWithGameExplorer() {
}
+
void AGSPlatformDriver::PlayVideo(const char *name, int skip, int flags) {
}
@@ -166,12 +185,14 @@ int AGSPlatformDriver::ConvertKeycodeToScanCode(int keycode) {
bool AGSPlatformDriver::LockMouseToWindow() {
return false;
}
+
void AGSPlatformDriver::UnlockMouse() {
}
//-----------------------------------------------
// IOutputHandler implementation
//-----------------------------------------------
+
void AGSPlatformDriver::PrintMessage(const Shared::DebugMessage &msg) {
if (_logToStdErr) {
if (msg.GroupName.IsEmpty())
diff --git a/engines/ags/engine/platform/base/agsplatformdriver.h b/engines/ags/engine/platform/base/agsplatformdriver.h
index df140d4844..b4dd15b150 100644
--- a/engines/ags/engine/platform/base/agsplatformdriver.h
+++ b/engines/ags/engine/platform/base/agsplatformdriver.h
@@ -72,9 +72,7 @@ struct AGSPlatformDriver
virtual void Delay(int millis);
virtual void DisplayAlert(const char *, ...) = 0;
virtual void AttachToParentConsole();
- virtual int GetLastSystemError() {
- return (int)errnum;
- }
+ virtual int GetLastSystemError();
// Get root directory for storing per-game shared data
virtual const char *GetAllUsersDataDirectory() {
return ".";
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 5af938af2b..b26f93b499 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -163,6 +163,9 @@ public:
* @{
*/
+ int _errnum = 0;
+ int *_allegro_errno = &_errnum;
+
int __color_depth = 0;
int __rgb_r_shift_15 = DEFAULT_RGB_R_SHIFT_15; /* truecolor pixel format */
int __rgb_g_shift_15 = DEFAULT_RGB_G_SHIFT_15;
diff --git a/engines/ags/lib/allegro.cpp b/engines/ags/lib/allegro.cpp
deleted file mode 100644
index bf6962c217..0000000000
--- a/engines/ags/lib/allegro.cpp
+++ /dev/null
@@ -1,35 +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.
- *
- */
-
-#include "ags/lib/allegro.h"
-
-namespace AGS3 {
-
-int install_allegro() {
- errnum = AL_NOERROR;
- return 0;
-}
-
-void allegro_exit() {
-}
-
-} // namespace AGS3
diff --git a/engines/ags/lib/allegro.h b/engines/ags/lib/allegro.h
index 5bbccaae93..161554d3ad 100644
--- a/engines/ags/lib/allegro.h
+++ b/engines/ags/lib/allegro.h
@@ -42,8 +42,8 @@
namespace AGS3 {
-extern int install_allegro();
-extern void allegro_exit();
+inline int install_allegro() { return 0; }
+inline void allegro_exit() {}
} // namespace AGS3
diff --git a/engines/ags/lib/allegro/error.cpp b/engines/ags/lib/allegro/error.cpp
deleted file mode 100644
index 053c121f75..0000000000
--- a/engines/ags/lib/allegro/error.cpp
+++ /dev/null
@@ -1,30 +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.
- *
- */
-
-#include "ags/lib/allegro/error.h"
-
-namespace AGS3 {
-
-AllegroError errnum;
-AllegroError *allegro_errno = &errnum;
-
-} // namespace AGS3
diff --git a/engines/ags/lib/allegro/error.h b/engines/ags/lib/allegro/error.h
index bfbf79edf9..52131f6125 100644
--- a/engines/ags/lib/allegro/error.h
+++ b/engines/ags/lib/allegro/error.h
@@ -70,9 +70,6 @@ enum AllegroError {
AL_EILSEQ = 42
};
-extern AllegroError errnum;
-extern AllegroError *allegro_errno;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/lib/allegro/fixed.cpp b/engines/ags/lib/allegro/fixed.cpp
index f05588c196..cca27f2fbb 100644
--- a/engines/ags/lib/allegro/fixed.cpp
+++ b/engines/ags/lib/allegro/fixed.cpp
@@ -22,17 +22,18 @@
#include "ags/lib/allegro/fixed.h"
#include "ags/lib/allegro/error.h"
+#include "ags/globals.h"
namespace AGS3 {
fixed ftofix(double x) {
if (x > 32767.0) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return 0x7FFFFFFF;
}
if (x < -32767.0) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return (fixed) - 0x7FFFFFFF;
}
@@ -48,13 +49,13 @@ fixed fixadd(fixed x, fixed y) {
if (result >= 0) {
if ((x < 0) && (y < 0)) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return (fixed) - 0x7FFFFFFF;
} else
return result;
} else {
if ((x > 0) && (y > 0)) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return 0x7FFFFFFF;
} else
return result;
@@ -66,13 +67,13 @@ fixed fixsub(fixed x, fixed y) {
if (result >= 0) {
if ((x < 0) && (y > 0)) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return (fixed) - 0x7FFFFFFF;
} else
return result;
} else {
if ((x > 0) && (y < 0)) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return 0x7FFFFFFF;
} else
return result;
@@ -85,10 +86,10 @@ fixed fixmul(fixed x, fixed y) {
int64 lres = (lx * ly);
if (lres > 0x7FFFFFFF0000LL) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return 0x7FFFFFFF;
} else if (lres < -0x7FFFFFFF0000LL) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return 0x80000000;
} else {
int res = lres >> 16;
@@ -98,7 +99,7 @@ fixed fixmul(fixed x, fixed y) {
fixed fixdiv(fixed x, fixed y) {
if (y == 0) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return (fixed)(x < 0) ? -0x7FFFFFFF : 0x7FFFFFFF;
} else
return ftofix(fixtof(x) / fixtof(y));
@@ -115,7 +116,7 @@ int fixfloor(fixed x) {
int fixceil(fixed x) {
if (x > 0x7FFF0000) {
- *allegro_errno = AL_ERANGE;
+ *_G(allegro_errno) = AL_ERANGE;
return 0x7FFF;
}
@@ -149,7 +150,7 @@ fixed fixtan(fixed x) {
fixed fixacos(fixed x) {
if ((x < -65536) || (x > 65536)) {
- *allegro_errno = AL_EDOM;
+ *_G(allegro_errno) = AL_EDOM;
return 0;
}
@@ -159,7 +160,7 @@ fixed fixacos(fixed x) {
fixed fixasin(fixed x) {
if ((x < -65536) || (x > 65536)) {
- *allegro_errno = AL_EDOM;
+ *_G(allegro_errno) = AL_EDOM;
return 0;
}
diff --git a/engines/ags/lib/allegro/math.cpp b/engines/ags/lib/allegro/math.cpp
index 7c293b8c72..08f9013d1e 100644
--- a/engines/ags/lib/allegro/math.cpp
+++ b/engines/ags/lib/allegro/math.cpp
@@ -25,6 +25,7 @@
#include "ags/lib/allegro/error.h"
#include "ags/lib/allegro/fixed.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -248,17 +249,17 @@ fixed fixatan2(fixed y, fixed x) {
if (x == 0) {
if (y == 0) {
- *allegro_errno = AL_EDOM;
+ *_G(allegro_errno) = AL_EDOM;
return 0L;
} else
return ((y < 0) ? -0x00400000L : 0x00400000L);
}
- *allegro_errno = AL_NOERROR;
+ *_G(allegro_errno) = AL_NOERROR;
r = fixdiv(y, x);
- if (*allegro_errno) {
- *allegro_errno = AL_NOERROR;
+ if (*_G(allegro_errno)) {
+ *_G(allegro_errno) = AL_NOERROR;
return ((y < 0) ? -0x00400000L : 0x00400000L);
}
diff --git a/engines/ags/module.mk b/engines/ags/module.mk
index d7e7bb26b6..de0832c918 100644
--- a/engines/ags/module.mk
+++ b/engines/ags/module.mk
@@ -11,11 +11,9 @@ MODULE_OBJS = \
lib/aastr-0.1.1/aastr.o \
lib/aastr-0.1.1/aautil.o \
lib/alfont/alfont.o \
- lib/allegro.o \
lib/allegro/color.o \
lib/allegro/config.o \
lib/allegro/draw.o \
- lib/allegro/error.o \
lib/allegro/file.o \
lib/allegro/fixed.o \
lib/allegro/flood.o \
diff --git a/engines/ags/shared/util/string_utils.cpp b/engines/ags/shared/util/string_utils.cpp
index 0bc146dcdd..33a4b642a7 100644
--- a/engines/ags/shared/util/string_utils.cpp
+++ b/engines/ags/shared/util/string_utils.cpp
@@ -25,6 +25,7 @@
#include "ags/shared/util/string_utils.h"
#include "ags/shared/util/stream.h"
#include "ags/lib/allegro/error.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -57,11 +58,11 @@ StrUtil::ConversionError StrUtil::StringToInt(const String &s, int &val, int def
if (!s.GetCStr())
return StrUtil::kFailed;
char *stop_ptr;
- errnum = AL_NOERROR;
+ _G(errnum) = AL_NOERROR;
long lval = strtol(s.GetCStr(), &stop_ptr, 0);
if (stop_ptr != s.GetCStr() + s.GetLength())
return StrUtil::kFailed;
- if (lval > INT_MAX || lval < INT_MIN || errnum == AL_ERANGE)
+ if (lval > INT_MAX || lval < INT_MIN || _G(errnum) == AL_ERANGE)
return StrUtil::kOutOfRange;
val = (int)lval;
return StrUtil::kNoError;
Commit: 766d3a5aa911515633f27e71063cde551644bbfa
https://github.com/scummvm/scummvm/commit/766d3a5aa911515633f27e71063cde551644bbfa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-13T11:12:41-08:00
Commit Message:
AGS: Move wordsdictionary.cpp globals to Globals
Changed paths:
engines/ags/globals.h
engines/ags/shared/ac/common.cpp
engines/ags/shared/ac/common.h
engines/ags/shared/ac/wordsdictionary.cpp
engines/ags/shared/ac/wordsdictionary.h
engines/ags/shared/game/room_file.cpp
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index b26f93b499..f40d5ba2cb 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -1145,6 +1145,15 @@ public:
/**@}*/
+ /**
+ * \defgroup wordsdictionary globals
+ * @{
+ */
+
+ const char *_passwencstring = "Avis Durgan";
+
+ /**@}*/
+
public:
Globals();
~Globals();
diff --git a/engines/ags/shared/ac/common.cpp b/engines/ags/shared/ac/common.cpp
index 58c5bf644f..bf5cdbdd77 100644
--- a/engines/ags/shared/ac/common.cpp
+++ b/engines/ags/shared/ac/common.cpp
@@ -29,8 +29,6 @@ namespace AGS3 {
using namespace AGS::Shared;
-const char *game_file_sig = "Adventure Creator Game File v2";
-
void quitprintf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
diff --git a/engines/ags/shared/ac/common.h b/engines/ags/shared/ac/common.h
index 03ef906265..8551761d73 100644
--- a/engines/ags/shared/ac/common.h
+++ b/engines/ags/shared/ac/common.h
@@ -32,8 +32,6 @@ void update_polled_stuff_if_runtime();
void set_our_eip(int eip);
int get_our_eip();
-extern const char *game_file_sig;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/shared/ac/wordsdictionary.cpp b/engines/ags/shared/ac/wordsdictionary.cpp
index 44991caff1..f2dfd812ed 100644
--- a/engines/ags/shared/ac/wordsdictionary.cpp
+++ b/engines/ags/shared/ac/wordsdictionary.cpp
@@ -24,6 +24,7 @@
#include "ags/shared/ac/wordsdictionary.h"
#include "ags/shared/util/stream.h"
#include "ags/shared/util/string_compat.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -91,13 +92,11 @@ int WordsDictionary::find_index(const char *wrem) {
return -1;
}
-const char *passwencstring = "Avis Durgan";
-
void decrypt_text(char *toenc) {
int adx = 0;
while (1) {
- toenc[0] -= passwencstring[adx];
+ toenc[0] -= _G(passwencstring)[adx];
if (toenc[0] == 0)
break;
@@ -145,7 +144,7 @@ void encrypt_text(char *toenc) {
if (toenc[0] == 0)
tobreak = 1;
- toenc[0] += passwencstring[adx];
+ toenc[0] += _G(passwencstring)[adx];
adx++;
toenc++;
diff --git a/engines/ags/shared/ac/wordsdictionary.h b/engines/ags/shared/ac/wordsdictionary.h
index 24ac7efce4..ee8b6250f7 100644
--- a/engines/ags/shared/ac/wordsdictionary.h
+++ b/engines/ags/shared/ac/wordsdictionary.h
@@ -52,8 +52,6 @@ struct WordsDictionary {
int find_index(const char *);
};
-extern const char *passwencstring;
-
extern void decrypt_text(char *toenc);
extern void read_string_decrypt(Shared::Stream *in, char *buf, size_t buf_sz);
extern void read_dictionary(WordsDictionary *dict, Shared::Stream *in);
diff --git a/engines/ags/shared/game/room_file.cpp b/engines/ags/shared/game/room_file.cpp
index 916b7b9105..e8eb65159a 100644
--- a/engines/ags/shared/game/room_file.cpp
+++ b/engines/ags/shared/game/room_file.cpp
@@ -397,7 +397,7 @@ HRoomFileError ReadScriptBlock(char *&buf, Stream *in, RoomFileVersion data_ver)
in->Read(buf, len);
buf[len] = 0;
for (size_t i = 0; i < len; ++i)
- buf[i] += passwencstring[i % 11];
+ buf[i] += _G(passwencstring)[i % 11];
return HRoomFileError::None();
}
Commit: f758d84fe81f8c88bfd3cb942aa1678542d91092
https://github.com/scummvm/scummvm/commit/f758d84fe81f8c88bfd3cb942aa1678542d91092
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-13T11:12:41-08:00
Commit Message:
AGS: Remove unused platforms
Changed paths:
R engines/ags/engine/platform/android/acpland.cpp
R engines/ags/engine/platform/ios/acplios.cpp
R engines/ags/engine/platform/osx/acplmac.cpp
R engines/ags/engine/platform/osx/alplmac.mm
R engines/ags/engine/platform/util/libc.c
R engines/ags/engine/platform/util/pe.c
R engines/ags/engine/platform/util/pe.h
R engines/ags/engine/platform/windows/acplwin.cpp
R engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.cpp
R engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.h
R engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
R engines/ags/engine/platform/windows/gfx/ali3dd3d.h
R engines/ags/engine/platform/windows/minidump.cpp
R engines/ags/engine/platform/windows/setup/winsetup.cpp
R engines/ags/engine/platform/windows/setup/winsetup.h
R engines/ags/engine/platform/windows/win_ex_handling.cpp
R engines/ags/engine/platform/windows/win_ex_handling.h
R engines/ags/engine/platform/windows/winapi_exclusive.h
engines/ags/engine/main/engine.cpp
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index bb7983d6de..429654dd33 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -68,7 +68,6 @@
#include "ags/engine/main/main.h"
#include "ags/engine/main/main_allegro.h"
#include "ags/engine/media/audio/audio_system.h"
-#include "ags/engine/platform/util/pe.h"
#include "ags/shared/gfx/image.h"
#include "ags/shared/util/directory.h"
#include "ags/shared/util/error.h"
diff --git a/engines/ags/engine/platform/android/acpland.cpp b/engines/ags/engine/platform/android/acpland.cpp
deleted file mode 100644
index dfcd8dbd08..0000000000
--- a/engines/ags/engine/platform/android/acpland.cpp
+++ /dev/null
@@ -1,732 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_ANDROID
-
-#include "ags/lib/allegro.h"
-#include "ags/shared/platform/base/agsplatformdriver.h"
-#include "ags/shared/ac/runtime_defines.h"
-#include "ags/shared/main/config.h"
-#include "ags/shared/plugin/agsplugin.h"
-//include <stdio.h>
-//include <dirent.h>
-//include <sys/stat.h>
-//include <ctype.h>
-//include <unistd.h>
-#include "ags/shared/util/string_compat.h"
-
-
-
-//include <jni.h>
-//include <android/log.h>
-
-namespace AGS3 {
-
-using namespace AGS::Shared;
-
-#define ANDROID_CONFIG_FILENAME "android.cfg"
-
-bool ReadConfiguration(char *filename, bool read_everything);
-void ResetConfiguration();
-
-struct AGSAndroid : AGSPlatformDriver {
-
- virtual int CDPlayerCommand(int cmdd, int datt);
- virtual void Delay(int millis);
- virtual void DisplayAlert(const char *, ...);
- virtual const char *GetAppOutputDirectory();
- virtual unsigned long GetDiskFreeSpaceMB();
- virtual const char *GetNoMouseErrorString();
- virtual bool IsBackendResponsibleForMouseScaling() {
- return true;
- }
- virtual eScriptSystemOSID GetSystemOSID();
- virtual int InitializeCDPlayer();
- virtual void PostAllegroExit();
- virtual void SetGameWindowIcon();
- virtual void ShutdownCDPlayer();
- virtual void WriteStdOut(const char *fmt, ...);
- virtual void WriteStdErr(const char *fmt, ...);
-};
-
-
-//int psp_return_to_menu = 1;
-int psp_ignore_acsetup_cfg_file = 1;
-int psp_clear_cache_on_room_change = 0;
-int psp_rotation = 0;
-int psp_config_enabled = 0;
-char psp_translation[100];
-char *psp_translations[100];
-
-// Mouse option from Allegro.
-extern int config_mouse_control_mode;
-
-
-// Graphic options from the Allegro library.
-extern int psp_gfx_scaling;
-extern int psp_gfx_smoothing;
-
-
-// Audio options from the Allegro library.
-unsigned int psp_audio_samplerate = 44100;
-int psp_audio_enabled = 1;
-volatile int psp_audio_multithreaded = 1;
-int psp_audio_cachesize = 10;
-int psp_midi_enabled = 1;
-int psp_midi_preload_patches = 0;
-
-int psp_video_framedrop = 0;
-
-int psp_gfx_renderer = 0;
-int psp_gfx_super_sampling = 0;
-int psp_gfx_smooth_sprites = 0;
-
-int psp_debug_write_to_logcat = 0;
-
-int config_mouse_longclick = 0;
-
-extern int display_fps;
-extern int want_exit;
-extern void PauseGame();
-extern void UnPauseGame();
-extern int main(int argc, char *argv[]);
-
-char android_base_directory[256];
-char android_app_directory[256];
-char psp_game_file_name[256];
-char *psp_game_file_name_pointer = psp_game_file_name;
-
-bool psp_load_latest_savegame = false;
-extern char saveGameDirectory[260];
-extern const char *loadSaveGameOnStartup;
-char lastSaveGameName[200];
-
-
-extern JavaVM *android_jni_vm;
-JNIEnv *java_environment;
-jobject java_object;
-jclass java_class;
-jmethodID java_messageCallback;
-jmethodID java_blockExecution;
-jmethodID java_swapBuffers;
-jmethodID java_setRotation;
-jmethodID java_enableLongclick;
-
-bool reset_configuration = false;
-
-extern "C"
-{
-
- const int CONFIG_IGNORE_ACSETUP = 0;
- const int CONFIG_CLEAR_CACHE = 1;
- const int CONFIG_AUDIO_RATE = 2;
- const int CONFIG_AUDIO_ENABLED = 3;
- const int CONFIG_AUDIO_THREADED = 4;
- const int CONFIG_AUDIO_CACHESIZE = 5;
- const int CONFIG_MIDI_ENABLED = 6;
- const int CONFIG_MIDI_PRELOAD = 7;
- const int CONFIG_VIDEO_FRAMEDROP = 8;
- const int CONFIG_GFX_RENDERER = 9;
- const int CONFIG_GFX_SMOOTHING = 10;
- const int CONFIG_GFX_SCALING = 11;
- const int CONFIG_GFX_SS = 12;
- const int CONFIG_ROTATION = 13;
- const int CONFIG_ENABLED = 14;
- const int CONFIG_DEBUG_FPS = 15;
- const int CONFIG_GFX_SMOOTH_SPRITES = 16;
- const int CONFIG_TRANSLATION = 17;
- const int CONFIG_DEBUG_LOGCAT = 18;
- const int CONFIG_MOUSE_METHOD = 19;
- const int CONFIG_MOUSE_LONGCLICK = 20;
-
- extern void android_debug_printf(const char *format, ...);
-
- JNIEXPORT jboolean JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_readConfigFile(JNIEnv *env, jobject object, jstring directory) {
- const char *cdirectory = env->GetStringUTFChars(directory, NULL);
- chdir(cdirectory);
- env->ReleaseStringUTFChars(directory, cdirectory);
-
- ResetConfiguration();
-
- return ReadConfiguration(ANDROID_CONFIG_FILENAME, true);
- }
-
-
- JNIEXPORT jboolean JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_writeConfigFile(JNIEnv *env, jobject object) {
- FILE *config = fopen(ANDROID_CONFIG_FILENAME, "wb");
- if (config) {
- fprintf(config, "[misc]\n");
- fprintf(config, "config_enabled = %d\n", psp_config_enabled);
- fprintf(config, "rotation = %d\n", psp_rotation);
- fprintf(config, "translation = %s\n", psp_translation);
-
- fprintf(config, "[controls]\n");
- fprintf(config, "mouse_method = %d\n", config_mouse_control_mode);
- fprintf(config, "mouse_longclick = %d\n", config_mouse_longclick);
-
- fprintf(config, "[compatibility]\n");
-// fprintf(config, "ignore_acsetup_cfg_file = %d\n", psp_ignore_acsetup_cfg_file);
- fprintf(config, "clear_cache_on_room_change = %d\n", psp_clear_cache_on_room_change);
-
- fprintf(config, "[sound]\n");
- fprintf(config, "samplerate = %d\n", psp_audio_samplerate);
- fprintf(config, "enabled = %d\n", psp_audio_enabled);
- fprintf(config, "threaded = %d\n", psp_audio_multithreaded);
- fprintf(config, "cache_size = %d\n", psp_audio_cachesize);
-
- fprintf(config, "[midi]\n");
- fprintf(config, "enabled = %d\n", psp_midi_enabled);
- fprintf(config, "preload_patches = %d\n", psp_midi_preload_patches);
-
- fprintf(config, "[video]\n");
- fprintf(config, "framedrop = %d\n", psp_video_framedrop);
-
- fprintf(config, "[graphics]\n");
- fprintf(config, "renderer = %d\n", psp_gfx_renderer);
- fprintf(config, "smoothing = %d\n", psp_gfx_smoothing);
- fprintf(config, "scaling = %d\n", psp_gfx_scaling);
- fprintf(config, "super_sampling = %d\n", psp_gfx_super_sampling);
- fprintf(config, "smooth_sprites = %d\n", psp_gfx_smooth_sprites);
-
- fprintf(config, "[debug]\n");
- fprintf(config, "show_fps = %d\n", (display_fps == 2) ? 1 : 0);
- fprintf(config, "logging = %d\n", psp_debug_write_to_logcat);
-
- fclose(config);
-
- return true;
- }
-
- return false;
- }
-
-
- JNIEXPORT jint JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_readIntConfigValue(JNIEnv *env, jobject object, jint id) {
- switch (id) {
- case CONFIG_IGNORE_ACSETUP:
- return psp_ignore_acsetup_cfg_file;
- break;
- case CONFIG_CLEAR_CACHE:
- return psp_clear_cache_on_room_change;
- break;
- case CONFIG_AUDIO_RATE:
- return psp_audio_samplerate;
- break;
- case CONFIG_AUDIO_ENABLED:
- return psp_audio_enabled;
- break;
- case CONFIG_AUDIO_THREADED:
- return psp_audio_multithreaded;
- break;
- case CONFIG_AUDIO_CACHESIZE:
- return psp_audio_cachesize;
- break;
- case CONFIG_MIDI_ENABLED:
- return psp_midi_enabled;
- break;
- case CONFIG_MIDI_PRELOAD:
- return psp_midi_preload_patches;
- break;
- case CONFIG_VIDEO_FRAMEDROP:
- return psp_video_framedrop;
- break;
- case CONFIG_GFX_RENDERER:
- return psp_gfx_renderer;
- break;
- case CONFIG_GFX_SMOOTHING:
- return psp_gfx_smoothing;
- break;
- case CONFIG_GFX_SCALING:
- return psp_gfx_scaling;
- break;
- case CONFIG_GFX_SS:
- return psp_gfx_super_sampling;
- break;
- case CONFIG_GFX_SMOOTH_SPRITES:
- return psp_gfx_smooth_sprites;
- break;
- case CONFIG_ROTATION:
- return psp_rotation;
- break;
- case CONFIG_ENABLED:
- return psp_config_enabled;
- break;
- case CONFIG_DEBUG_FPS:
- return (display_fps == 2) ? 1 : 0;
- break;
- case CONFIG_DEBUG_LOGCAT:
- return psp_debug_write_to_logcat;
- break;
- case CONFIG_MOUSE_METHOD:
- return config_mouse_control_mode;
- break;
- case CONFIG_MOUSE_LONGCLICK:
- return config_mouse_longclick;
- break;
- default:
- return 0;
- break;
- }
- }
-
-
- JNIEXPORT jstring JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_readStringConfigValue(JNIEnv *env, jobject object, jint id, jstring value) {
- switch (id) {
- case CONFIG_TRANSLATION:
- return env->NewStringUTF(&psp_translation[0]);
- break;
- }
- }
-
-
- JNIEXPORT void JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_setIntConfigValue(JNIEnv *env, jobject object, jint id, jint value) {
- switch (id) {
- case CONFIG_IGNORE_ACSETUP:
- psp_ignore_acsetup_cfg_file = value;
- break;
- case CONFIG_CLEAR_CACHE:
- psp_clear_cache_on_room_change = value;
- break;
- case CONFIG_AUDIO_RATE:
- psp_audio_samplerate = value;
- break;
- case CONFIG_AUDIO_ENABLED:
- psp_audio_enabled = value;
- break;
- case CONFIG_AUDIO_THREADED:
- psp_audio_multithreaded = value;
- break;
- case CONFIG_AUDIO_CACHESIZE:
- psp_audio_cachesize = value;
- break;
- case CONFIG_MIDI_ENABLED:
- psp_midi_enabled = value;
- break;
- case CONFIG_MIDI_PRELOAD:
- psp_midi_preload_patches = value;
- break;
- case CONFIG_VIDEO_FRAMEDROP:
- psp_video_framedrop = value;
- break;
- case CONFIG_GFX_RENDERER:
- psp_gfx_renderer = value;
- break;
- case CONFIG_GFX_SMOOTHING:
- psp_gfx_smoothing = value;
- break;
- case CONFIG_GFX_SCALING:
- psp_gfx_scaling = value;
- break;
- case CONFIG_GFX_SS:
- psp_gfx_super_sampling = value;
- break;
- case CONFIG_GFX_SMOOTH_SPRITES:
- psp_gfx_smooth_sprites = value;
- break;
- case CONFIG_ROTATION:
- psp_rotation = value;
- break;
- case CONFIG_ENABLED:
- psp_config_enabled = value;
- break;
- case CONFIG_DEBUG_FPS:
- display_fps = (value == 1) ? 2 : 0;
- break;
- case CONFIG_DEBUG_LOGCAT:
- psp_debug_write_to_logcat = value;
- break;
- case CONFIG_MOUSE_METHOD:
- config_mouse_control_mode = value;
- break;
- case CONFIG_MOUSE_LONGCLICK:
- config_mouse_longclick = value;
- break;
- default:
- break;
- }
- }
-
-
- JNIEXPORT void JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_setStringConfigValue(JNIEnv *env, jobject object, jint id, jstring value) {
- const char *cstring = env->GetStringUTFChars(value, NULL);
-
- switch (id) {
- case CONFIG_TRANSLATION:
- strcpy(psp_translation, cstring);
- break;
- default:
- break;
- }
-
- env->ReleaseStringUTFChars(value, cstring);
- }
-
-
- JNIEXPORT jint JNICALL
- Java_com_bigbluecup_android_PreferencesActivity_getAvailableTranslations(JNIEnv *env, jobject object, jobjectArray translations) {
- int i = 0;
- int length;
- DIR *dir;
- struct dirent *entry;
- char buffer[200];
-
- dir = opendir(".");
- if (dir) {
- while ((entry = readdir(dir)) != 0) {
- length = strlen(entry->d_name);
- if (length > 4) {
- if (ags_stricmp(&entry->d_name[length - 4], ".tra") == 0) {
- memset(buffer, 0, 200);
- strncpy(buffer, entry->d_name, length - 4);
- psp_translations[i] = (char *)malloc(strlen(buffer) + 1);
- strcpy(psp_translations[i], buffer);
- env->SetObjectArrayElement(translations, i, env->NewStringUTF(&buffer[0]));
- i++;
- }
- }
- }
- closedir(dir);
- }
-
- return i;
- }
-
-
- JNIEXPORT void JNICALL
- Java_com_bigbluecup_android_EngineGlue_pauseEngine(JNIEnv *env, jobject object) {
- PauseGame();
- }
-
- JNIEXPORT void JNICALL
- Java_com_bigbluecup_android_EngineGlue_resumeEngine(JNIEnv *env, jobject object) {
- UnPauseGame();
- }
-
-
- JNIEXPORT void JNICALL
- Java_com_bigbluecup_android_EngineGlue_shutdownEngine(JNIEnv *env, jobject object) {
- want_exit = 1;
- }
-
-
- JNIEXPORT jboolean JNICALL
- Java_com_bigbluecup_android_EngineGlue_startEngine(JNIEnv *env, jobject object, jclass stringclass, jstring filename, jstring directory, jstring appDirectory, jboolean loadLastSave) {
- // Get JNI interfaces.
- java_object = env->NewGlobalRef(object);
- java_environment = env;
- java_class = (jclass)java_environment->NewGlobalRef(java_environment->GetObjectClass(object));
- java_messageCallback = java_environment->GetMethodID(java_class, "showMessage", "(Ljava/lang/String;)V");
- java_blockExecution = java_environment->GetMethodID(java_class, "blockExecution", "()V");
- java_setRotation = java_environment->GetMethodID(java_class, "setRotation", "(I)V");
- java_enableLongclick = java_environment->GetMethodID(java_class, "enableLongclick", "()V");
-
- // Initialize JNI for Allegro.
- android_allegro_initialize_jni(java_environment, java_class, java_object);
-
- // Get the file to run from Java.
- const char *cpath = java_environment->GetStringUTFChars(filename, NULL);
- strcpy(psp_game_file_name, cpath);
- java_environment->ReleaseStringUTFChars(filename, cpath);
-
- // Get the base directory (usually "/sdcard/ags").
- const char *cdirectory = java_environment->GetStringUTFChars(directory, NULL);
- chdir(cdirectory);
- strcpy(android_base_directory, cdirectory);
- java_environment->ReleaseStringUTFChars(directory, cdirectory);
-
- // Get the app directory (something like "/data/data/com.bigbluecup.android.launcher")
- const char *cappDirectory = java_environment->GetStringUTFChars(appDirectory, NULL);
- strcpy(android_app_directory, cappDirectory);
- java_environment->ReleaseStringUTFChars(appDirectory, cappDirectory);
-
- // Reset configuration.
- ResetConfiguration();
-
- // Read general configuration.
- ReadConfiguration(ANDROID_CONFIG_FILENAME, true);
-
- // Get the games path.
- char path[256];
- strcpy(path, psp_game_file_name);
- int lastindex = strlen(path) - 1;
- while (path[lastindex] != '/') {
- path[lastindex] = 0;
- lastindex--;
- }
- chdir(path);
-
- setenv("ULTRADIR", "..", 1);
-
- // Read game specific configuration.
- ReadConfiguration(ANDROID_CONFIG_FILENAME, false);
-
- // Set the screen rotation.
- if (psp_rotation > 0)
- java_environment->CallVoidMethod(java_object, java_setRotation, psp_rotation);
-
- if (config_mouse_longclick > 0)
- java_environment->CallVoidMethod(java_object, java_enableLongclick);
-
- psp_load_latest_savegame = loadLastSave;
-
- // Start the engine main function.
- main(1, &psp_game_file_name_pointer);
-
- // Explicitly quit here, otherwise the app will hang forever.
- exit(0);
-
- return true;
- }
-
-
- void selectLatestSavegame() {
- DIR *dir;
- struct dirent *entry;
- struct stat statBuffer;
- char buffer[200];
- time_t lastTime = 0;
-
- dir = opendir(saveGameDirectory);
-
- if (dir) {
- while ((entry = readdir(dir)) != 0) {
- if (ags_strnicmp(entry->d_name, "agssave", 7) == 0) {
- if (ags_stricmp(entry->d_name, "agssave.999") != 0) {
- strcpy(buffer, saveGameDirectory);
- strcat(buffer, entry->d_name);
- stat(buffer, &statBuffer);
- if (statBuffer.st_mtime > lastTime) {
- strcpy(lastSaveGameName, buffer);
- loadSaveGameOnStartup = lastSaveGameName;
- lastTime = statBuffer.st_mtime;
- }
- }
- }
- }
- closedir(dir);
- }
- }
-
-}
-
-
-int ReadInteger(int *variable, const ConfigTree &cfg, char *section, char *name, int minimum, int maximum, int default_value) {
- if (reset_configuration) {
- *variable = default_value;
- return 0;
- }
-
- int temp = INIreadint(cfg, section, name);
-
- if (temp == -1)
- return 0;
-
- if ((temp < minimum) || (temp > maximum))
- temp = default_value;
-
- *variable = temp;
-
- return 1;
-}
-
-
-
-int ReadString(char *variable, const ConfigTree &cfg, char *section, char *name, char *default_value) {
- if (reset_configuration) {
- strcpy(variable, default_value);
- return 0;
- }
-
- String temp;
- if (!INIreaditem(cfg, section, name, temp))
- temp = default_value;
-
- strcpy(variable, temp);
-
- return 1;
-}
-
-
-
-void ResetConfiguration() {
- reset_configuration = true;
-
- ReadConfiguration(ANDROID_CONFIG_FILENAME, true);
-
- reset_configuration = false;
-}
-
-
-
-bool ReadConfiguration(char *filename, bool read_everything) {
- ConfigTree cfg;
- if (IniUtil::Read(filename, cfg) || reset_configuration) {
-// ReadInteger((int*)&psp_disable_powersaving, "misc", "disable_power_saving", 0, 1, 1);
-
-// ReadInteger((int*)&psp_return_to_menu, "misc", "return_to_menu", 0, 1, 1);
-
- ReadString(&psp_translation[0], cfg, "misc", "translation", "default");
-
- ReadInteger((int *)&psp_config_enabled, cfg, "misc", "config_enabled", 0, 1, 0);
- if (!psp_config_enabled && !read_everything)
- return true;
-
- ReadInteger(&psp_debug_write_to_logcat, cfg, "debug", "logging", 0, 1, 0);
- ReadInteger(&display_fps, cfg, "debug", "show_fps", 0, 1, 0);
- if (display_fps == 1)
- display_fps = 2;
-
- ReadInteger((int *)&psp_rotation, cfg, "misc", "rotation", 0, 2, 0);
-
-// ReadInteger((int*)&psp_ignore_acsetup_cfg_file, "compatibility", "ignore_acsetup_cfg_file", 0, 1, 0);
- ReadInteger((int *)&psp_clear_cache_on_room_change, cfg, "compatibility", "clear_cache_on_room_change", 0, 1, 0);
-
- ReadInteger((int *)&psp_audio_samplerate, cfg, "sound", "samplerate", 0, 44100, 44100);
- ReadInteger((int *)&psp_audio_enabled, cfg, "sound", "enabled", 0, 1, 1);
- ReadInteger((int *)&psp_audio_multithreaded, cfg, "sound", "threaded", 0, 1, 1);
- ReadInteger((int *)&psp_audio_cachesize, cfg, "sound", "cache_size", 1, 50, 10);
-
- ReadInteger((int *)&psp_midi_enabled, cfg, "midi", "enabled", 0, 1, 1);
- ReadInteger((int *)&psp_midi_preload_patches, cfg, "midi", "preload_patches", 0, 1, 0);
-
- ReadInteger((int *)&psp_video_framedrop, cfg, "video", "framedrop", 0, 1, 0);
-
- ReadInteger((int *)&psp_gfx_renderer, cfg, "graphics", "renderer", 0, 2, 0);
- ReadInteger((int *)&psp_gfx_smoothing, cfg, "graphics", "smoothing", 0, 1, 1);
- ReadInteger((int *)&psp_gfx_scaling, cfg, "graphics", "scaling", 0, 2, 1);
- ReadInteger((int *)&psp_gfx_super_sampling, cfg, "graphics", "super_sampling", 0, 1, 0);
- ReadInteger((int *)&psp_gfx_smooth_sprites, cfg, "graphics", "smooth_sprites", 0, 1, 0);
-
- ReadInteger((int *)&config_mouse_control_mode, cfg, "controls", "mouse_method", 0, 1, 0);
- ReadInteger((int *)&config_mouse_longclick, cfg, "controls", "mouse_longclick", 0, 1, 1);
-
- return true;
- }
-
- return false;
-}
-
-
-
-int AGSAndroid::CDPlayerCommand(int cmdd, int datt) {
- return 1;//cd_player_control(cmdd, datt);
-}
-
-void AGSAndroid::DisplayAlert(const char *text, ...) {
- char displbuf[2000];
- va_list ap;
- va_start(ap, text);
- vsprintf(displbuf, text, ap);
- va_end(ap);
-
- // It is possible that this is called from a thread that is not yet known
- // to the Java VM. So attach it first before displaying the message.
- JNIEnv *thread_env;
- android_jni_vm->AttachCurrentThread(&thread_env, NULL);
-
- __android_log_print(ANDROID_LOG_DEBUG, "AGSNative", "%s", displbuf);
-
- jstring java_string = thread_env->NewStringUTF(displbuf);
- thread_env->CallVoidMethod(java_object, java_messageCallback, java_string);
- usleep(1000 * 1000);
- thread_env->CallVoidMethod(java_object, java_blockExecution);
-
-// android_jni_vm->DetachCurrentThread();
-}
-
-void AGSAndroid::Delay(int millis) {
- usleep(millis * 1000);
-}
-
-unsigned long AGSAndroid::GetDiskFreeSpaceMB() {
- // placeholder
- return 100;
-}
-
-const char *AGSAndroid::GetNoMouseErrorString() {
- return "This game requires a _GP(mouse). You need to configure and setup your mouse to play this game.\n";
-}
-
-eScriptSystemOSID AGSAndroid::GetSystemOSID() {
- return eOS_Android;
-}
-
-int AGSAndroid::InitializeCDPlayer() {
- return 1;//cd_player_init();
-}
-
-void AGSAndroid::PostAllegroExit() {
- java_environment->DeleteGlobalRef(java_class);
-}
-
-void AGSAndroid::SetGameWindowIcon() {
- // do nothing
-}
-
-void AGSAndroid::WriteStdOut(const char *fmt, ...) {
- // TODO: this check should probably be done once when setting up output targets for logging
- if (psp_debug_write_to_logcat) {
- va_list args;
- va_start(args, fmt);
- __android_log_vprint(ANDROID_LOG_DEBUG, "AGSNative", fmt, args);
- // NOTE: __android_log_* functions add trailing '\n'
- va_end(args);
- }
-}
-
-void AGSAndroid::WriteStdErr(const char *fmt, ...) {
- // TODO: find out if Android needs separate implementation for stderr
- if (psp_debug_write_to_logcat) {
- va_list args;
- va_start(args, fmt);
- __android_log_vprint(ANDROID_LOG_DEBUG, "AGSNative", fmt, args);
- // NOTE: __android_log_* functions add trailing '\n'
- va_end(args);
- }
-}
-
-void AGSAndroid::ShutdownCDPlayer() {
- //cd_exit();
-}
-
-const char *AGSAndroid::GetAppOutputDirectory() {
- return android_base_directory;
-}
-
-AGSPlatformDriver *AGSPlatformDriver::GetDriver() {
- if (instance == NULL)
- instance = new AGSAndroid();
-
- return instance;
-}
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/ios/acplios.cpp b/engines/ags/engine/platform/ios/acplios.cpp
deleted file mode 100644
index d3415efd50..0000000000
--- a/engines/ags/engine/platform/ios/acplios.cpp
+++ /dev/null
@@ -1,631 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_IOS
-
-//include <stdio.h>
-//include <dirent.h>
-//include <sys/stat.h>
-//include <ctype.h>
-
-#include "ags/lib/allegro.h"
-#include "ags/shared/platform/base/agsplatformdriver.h"
-#include "ags/shared/ac/runtime_defines.h"
-#include "ags/shared/main/config.h"
-#include "ags/shared/plugin/agsplugin.h"
-#include "ags/shared/util/string_utils.h"
-
-namespace AGS3 {
-
-using namespace AGS::Shared;
-
-#define IOS_CONFIG_FILENAME "ios.cfg"
-
-extern char *ios_document_directory;
-
-bool ReadConfiguration(char *filename, bool read_everything);
-void ResetConfiguration();
-
-//int psp_return_to_menu = 1;
-int psp_ignore_acsetup_cfg_file = 1;
-int psp_clear_cache_on_room_change = 0;
-int psp_rotation = 0;
-int psp_config_enabled = 0;
-char psp_translation[100];
-char *psp_translations[100];
-
-// Mouse option from Allegro.
-extern int config_mouse_control_mode;
-
-
-// Graphic options from the Allegro library.
-extern int psp_gfx_scaling;
-extern int psp_gfx_smoothing;
-
-
-// Audio options from the Allegro library.
-unsigned int psp_audio_samplerate = 44100;
-int psp_audio_enabled = 1;
-volatile int psp_audio_multithreaded = 1;
-int psp_audio_cachesize = 10;
-int psp_midi_enabled = 1;
-int psp_midi_preload_patches = 0;
-
-int psp_video_framedrop = 0;
-
-int psp_gfx_renderer = 0;
-int psp_gfx_super_sampling = 0;
-int psp_gfx_smooth_sprites = 0;
-
-int psp_debug_write_to_logcat = 0;
-
-int config_mouse_longclick = 0;
-
-extern int display_fps;
-extern int want_exit;
-extern void PauseGame();
-extern void UnPauseGame();
-extern int main(int argc, char *argv[]);
-
-char psp_game_file_name[256];
-char *psp_game_file_name_pointer = psp_game_file_name;
-
-bool psp_load_latest_savegame = false;
-extern char saveGameDirectory[260];
-extern const char *loadSaveGameOnStartup;
-char lastSaveGameName[200];
-
-bool reset_configuration = false;
-
-const int CONFIG_IGNORE_ACSETUP = 0;
-const int CONFIG_CLEAR_CACHE = 1;
-const int CONFIG_AUDIO_RATE = 2;
-const int CONFIG_AUDIO_ENABLED = 3;
-const int CONFIG_AUDIO_THREADED = 4;
-const int CONFIG_AUDIO_CACHESIZE = 5;
-const int CONFIG_MIDI_ENABLED = 6;
-const int CONFIG_MIDI_PRELOAD = 7;
-const int CONFIG_VIDEO_FRAMEDROP = 8;
-const int CONFIG_GFX_RENDERER = 9;
-const int CONFIG_GFX_SMOOTHING = 10;
-const int CONFIG_GFX_SCALING = 11;
-const int CONFIG_GFX_SS = 12;
-const int CONFIG_ROTATION = 13;
-const int CONFIG_ENABLED = 14;
-const int CONFIG_DEBUG_FPS = 15;
-const int CONFIG_GFX_SMOOTH_SPRITES = 16;
-const int CONFIG_TRANSLATION = 17;
-const int CONFIG_DEBUG_LOGCAT = 18;
-const int CONFIG_MOUSE_METHOD = 19;
-const int CONFIG_MOUSE_LONGCLICK = 20;
-
-
-
-struct AGSIOS : AGSPlatformDriver {
-
- virtual int CDPlayerCommand(int cmdd, int datt);
- virtual void Delay(int millis);
- virtual void DisplayAlert(const char *, ...);
- virtual const char *GetAppOutputDirectory();
- virtual unsigned long GetDiskFreeSpaceMB();
- virtual const char *GetNoMouseErrorString();
- virtual bool IsBackendResponsibleForMouseScaling() {
- return true;
- }
- virtual eScriptSystemOSID GetSystemOSID();
- virtual int InitializeCDPlayer();
- virtual void PostAllegroExit();
- virtual void SetGameWindowIcon();
- virtual void ShutdownCDPlayer();
-};
-
-
-
-bool readConfigFile(char *directory) {
- chdir(directory);
-
- ResetConfiguration();
-
- return ReadConfiguration(IOS_CONFIG_FILENAME, true);
-}
-
-
-bool writeConfigFile() {
- FILE *config = fopen(IOS_CONFIG_FILENAME, "wb");
- if (config) {
- fprintf(config, "[misc]\n");
- fprintf(config, "config_enabled = %d\n", psp_config_enabled);
- fprintf(config, "rotation = %d\n", psp_rotation);
- fprintf(config, "translation = %s\n", psp_translation);
-
- fprintf(config, "[controls]\n");
- fprintf(config, "mouse_method = %d\n", config_mouse_control_mode);
- fprintf(config, "mouse_longclick = %d\n", config_mouse_longclick);
-
- fprintf(config, "[compatibility]\n");
- fprintf(config, "clear_cache_on_room_change = %d\n", psp_clear_cache_on_room_change);
-
- fprintf(config, "[sound]\n");
- fprintf(config, "samplerate = %d\n", psp_audio_samplerate);
- fprintf(config, "enabled = %d\n", psp_audio_enabled);
- fprintf(config, "threaded = %d\n", psp_audio_multithreaded);
- fprintf(config, "cache_size = %d\n", psp_audio_cachesize);
-
- fprintf(config, "[midi]\n");
- fprintf(config, "enabled = %d\n", psp_midi_enabled);
- fprintf(config, "preload_patches = %d\n", psp_midi_preload_patches);
-
- fprintf(config, "[video]\n");
- fprintf(config, "framedrop = %d\n", psp_video_framedrop);
-
- fprintf(config, "[graphics]\n");
- fprintf(config, "renderer = %d\n", psp_gfx_renderer);
- fprintf(config, "smoothing = %d\n", psp_gfx_smoothing);
- fprintf(config, "scaling = %d\n", psp_gfx_scaling);
- fprintf(config, "super_sampling = %d\n", psp_gfx_super_sampling);
- fprintf(config, "smooth_sprites = %d\n", psp_gfx_smooth_sprites);
-
- fprintf(config, "[debug]\n");
- fprintf(config, "show_fps = %d\n", (display_fps == 2) ? 1 : 0);
- fprintf(config, "logging = %d\n", psp_debug_write_to_logcat);
-
- fclose(config);
-
- return true;
- }
-
- return false;
-}
-
-
-int readIntConfigValue(int id) {
- switch (id) {
- case CONFIG_IGNORE_ACSETUP:
- return psp_ignore_acsetup_cfg_file;
- break;
- case CONFIG_CLEAR_CACHE:
- return psp_clear_cache_on_room_change;
- break;
- case CONFIG_AUDIO_RATE:
- return psp_audio_samplerate;
- break;
- case CONFIG_AUDIO_ENABLED:
- return psp_audio_enabled;
- break;
- case CONFIG_AUDIO_THREADED:
- return psp_audio_multithreaded;
- break;
- case CONFIG_AUDIO_CACHESIZE:
- return psp_audio_cachesize;
- break;
- case CONFIG_MIDI_ENABLED:
- return psp_midi_enabled;
- break;
- case CONFIG_MIDI_PRELOAD:
- return psp_midi_preload_patches;
- break;
- case CONFIG_VIDEO_FRAMEDROP:
- return psp_video_framedrop;
- break;
- case CONFIG_GFX_RENDERER:
- return psp_gfx_renderer;
- break;
- case CONFIG_GFX_SMOOTHING:
- return psp_gfx_smoothing;
- break;
- case CONFIG_GFX_SCALING:
- return psp_gfx_scaling;
- break;
- case CONFIG_GFX_SS:
- return psp_gfx_super_sampling;
- break;
- case CONFIG_GFX_SMOOTH_SPRITES:
- return psp_gfx_smooth_sprites;
- break;
- case CONFIG_ROTATION:
- return psp_rotation;
- break;
- case CONFIG_ENABLED:
- return psp_config_enabled;
- break;
- case CONFIG_DEBUG_FPS:
- return (display_fps == 2) ? 1 : 0;
- break;
- case CONFIG_DEBUG_LOGCAT:
- return psp_debug_write_to_logcat;
- break;
- case CONFIG_MOUSE_METHOD:
- return config_mouse_control_mode;
- break;
- case CONFIG_MOUSE_LONGCLICK:
- return config_mouse_longclick;
- break;
- default:
- return 0;
- break;
- }
-}
-
-
-char *readStringConfigValue(int id) {
- switch (id) {
- case CONFIG_TRANSLATION:
- return &psp_translation[0];
- break;
- }
-}
-
-
-void setIntConfigValue(int id, int value) {
- switch (id) {
- case CONFIG_IGNORE_ACSETUP:
- psp_ignore_acsetup_cfg_file = value;
- break;
- case CONFIG_CLEAR_CACHE:
- psp_clear_cache_on_room_change = value;
- break;
- case CONFIG_AUDIO_RATE:
- psp_audio_samplerate = value;
- break;
- case CONFIG_AUDIO_ENABLED:
- psp_audio_enabled = value;
- break;
- case CONFIG_AUDIO_THREADED:
- psp_audio_multithreaded = value;
- break;
- case CONFIG_AUDIO_CACHESIZE:
- psp_audio_cachesize = value;
- break;
- case CONFIG_MIDI_ENABLED:
- psp_midi_enabled = value;
- break;
- case CONFIG_MIDI_PRELOAD:
- psp_midi_preload_patches = value;
- break;
- case CONFIG_VIDEO_FRAMEDROP:
- psp_video_framedrop = value;
- break;
- case CONFIG_GFX_RENDERER:
- psp_gfx_renderer = value;
- break;
- case CONFIG_GFX_SMOOTHING:
- psp_gfx_smoothing = value;
- break;
- case CONFIG_GFX_SCALING:
- psp_gfx_scaling = value;
- break;
- case CONFIG_GFX_SS:
- psp_gfx_super_sampling = value;
- break;
- case CONFIG_GFX_SMOOTH_SPRITES:
- psp_gfx_smooth_sprites = value;
- break;
- case CONFIG_ROTATION:
- psp_rotation = value;
- break;
- case CONFIG_ENABLED:
- psp_config_enabled = value;
- break;
- case CONFIG_DEBUG_FPS:
- display_fps = (value == 1) ? 2 : 0;
- break;
- case CONFIG_DEBUG_LOGCAT:
- psp_debug_write_to_logcat = value;
- break;
- case CONFIG_MOUSE_METHOD:
- config_mouse_control_mode = value;
- break;
- case CONFIG_MOUSE_LONGCLICK:
- config_mouse_longclick = value;
- break;
- default:
- break;
- }
-}
-
-
-void setStringConfigValue(int id, char *value) {
- switch (id) {
- case CONFIG_TRANSLATION:
- strcpy(psp_translation, value);
- break;
- default:
- break;
- }
-}
-
-/*
-int getAvailableTranslations(char* translations)
-{
- int i = 0;
- int length;
- DIR* dir;
- struct dirent* entry;
- char buffer[200];
-
- dir = opendir(".");
- if (dir)
- {
- while ((entry = readdir(dir)) != 0)
- {
- length = strlen(entry->d_name);
- if (length > 4)
- {
- if (ags_stricmp(&entry->d_name[length - 4], ".tra") == 0)
- {
- memset(buffer, 0, 200);
- strncpy(buffer, entry->d_name, length - 4);
- psp_translations[i] = (char*)malloc(strlen(buffer) + 1);
- strcpy(psp_translations[i], buffer);
- env->SetObjectArrayElement(translations, i, env->NewStringUTF(&buffer[0]));
- i++;
- }
- }
- }
- closedir(dir);
- }
-
- return i;
-}
-*/
-
-
-
-
-void selectLatestSavegame() {
- DIR *dir;
- struct dirent *entry;
- struct stat statBuffer;
- char buffer[200];
- time_t lastTime = 0;
-
- dir = opendir(saveGameDirectory);
-
- if (dir) {
- while ((entry = readdir(dir)) != 0) {
- if (ags_strnicmp(entry->d_name, "agssave", 7) == 0) {
- if (ags_stricmp(entry->d_name, "agssave.999") != 0) {
- strcpy(buffer, saveGameDirectory);
- strcat(buffer, entry->d_name);
- stat(buffer, &statBuffer);
- if (statBuffer.st_mtime > lastTime) {
- strcpy(lastSaveGameName, buffer);
- loadSaveGameOnStartup = lastSaveGameName;
- lastTime = statBuffer.st_mtime;
- }
- }
- }
- }
- closedir(dir);
- }
-}
-
-
-int ReadInteger(int *variable, const ConfigTree &cfg, char *section, char *name, int minimum, int maximum, int default_value) {
- if (reset_configuration) {
- *variable = default_value;
- return 0;
- }
-
- int temp = INIreadint(cfg, section, name);
-
- if (temp == -1)
- return 0;
-
- if ((temp < minimum) || (temp > maximum))
- temp = default_value;
-
- *variable = temp;
-
- return 1;
-}
-
-
-
-int ReadString(char *variable, const ConfigTree &cfg, char *section, char *name, char *default_value) {
- if (reset_configuration) {
- strcpy(variable, default_value);
- return 0;
- }
-
- String temp;
- if (!INIreaditem(cfg, section, name, temp))
- temp = default_value;
-
- strcpy(variable, temp);
-
- return 1;
-}
-
-
-
-void ResetConfiguration() {
- reset_configuration = true;
-
- ReadConfiguration(IOS_CONFIG_FILENAME, true);
-
- reset_configuration = false;
-}
-
-
-bool ReadConfiguration(char *filename, bool read_everything) {
- ConfigTree cfg;
- if (IniUtil::Read(filename, cfg) || reset_configuration) {
-// ReadInteger((int*)&psp_disable_powersaving, "misc", "disable_power_saving", 0, 1, 1);
-
-// ReadInteger((int*)&psp_return_to_menu, "misc", "return_to_menu", 0, 1, 1);
-
- ReadString(&psp_translation[0], cfg, "misc", "translation", "default");
-
- ReadInteger((int *)&psp_config_enabled, cfg, "misc", "config_enabled", 0, 1, 0);
- if (!psp_config_enabled && !read_everything)
- return true;
-
- ReadInteger(&psp_debug_write_to_logcat, cfg, "debug", "logging", 0, 1, 0);
- ReadInteger(&display_fps, cfg, "debug", "show_fps", 0, 1, 0);
- if (display_fps == 1)
- display_fps = 2;
-
- ReadInteger((int *)&psp_rotation, cfg, "misc", "rotation", 0, 2, 0);
-
-// ReadInteger((int*)&psp_ignore_acsetup_cfg_file, "compatibility", "ignore_acsetup_cfg_file", 0, 1, 0);
- ReadInteger((int *)&psp_clear_cache_on_room_change, cfg, "compatibility", "clear_cache_on_room_change", 0, 1, 0);
-
- ReadInteger((int *)&psp_audio_samplerate, cfg, "sound", "samplerate", 0, 44100, 44100);
- ReadInteger((int *)&psp_audio_enabled, cfg, "sound", "enabled", 0, 1, 1);
- ReadInteger((int *)&psp_audio_multithreaded, cfg, "sound", "threaded", 0, 1, 1);
- ReadInteger((int *)&psp_audio_cachesize, cfg, "sound", "cache_size", 1, 50, 10);
-
- ReadInteger((int *)&psp_midi_enabled, cfg, "midi", "enabled", 0, 1, 1);
- ReadInteger((int *)&psp_midi_preload_patches, cfg, "midi", "preload_patches", 0, 1, 0);
-
- ReadInteger((int *)&psp_video_framedrop, cfg, "video", "framedrop", 0, 1, 0);
-
- ReadInteger((int *)&psp_gfx_renderer, cfg, "graphics", "renderer", 0, 2, 0);
- ReadInteger((int *)&psp_gfx_smoothing, cfg, "graphics", "smoothing", 0, 1, 1);
- ReadInteger((int *)&psp_gfx_scaling, cfg, "graphics", "scaling", 0, 2, 1);
- ReadInteger((int *)&psp_gfx_super_sampling, cfg, "graphics", "super_sampling", 0, 1, 0);
- ReadInteger((int *)&psp_gfx_smooth_sprites, cfg, "graphics", "smooth_sprites", 0, 1, 0);
-
- ReadInteger((int *)&config_mouse_control_mode, cfg, "controls", "mouse_method", 0, 1, 0);
- ReadInteger((int *)&config_mouse_longclick, cfg, "controls", "mouse_longclick", 0, 1, 1);
-
- return true;
- }
-
- return false;
-}
-
-
-
-extern void ios_show_message_box(char *buffer);
-volatile int ios_wait_for_ui = 0;
-
-
-void startEngine(char *filename, char *directory, int loadLastSave) {
- strcpy(psp_game_file_name, filename);
-
- // Get the base directory (usually "/sdcard/ags").
- chdir(directory);
-
- // Reset configuration.
- ResetConfiguration();
-
- // Read general configuration.
- ReadConfiguration(IOS_CONFIG_FILENAME, true);
-
- // Get the games path.
- char path[256];
- strcpy(path, psp_game_file_name);
- int lastindex = strlen(path) - 1;
- while (path[lastindex] != '/') {
- path[lastindex] = 0;
- lastindex--;
- }
- chdir(path);
-
- setenv("ULTRADIR", "..", 1);
-
- // Read game specific configuration.
- ReadConfiguration(IOS_CONFIG_FILENAME, false);
-
- psp_load_latest_savegame = loadLastSave;
-
- // Start the engine main function.
- main(1, &psp_game_file_name_pointer);
-
- // Explicitly quit here, otherwise the app will hang forever.
- exit(0);
-}
-
-
-
-
-int AGSIOS::CDPlayerCommand(int cmdd, int datt) {
- return 0;//cd_player_control(cmdd, datt);
-}
-
-
-
-void AGSIOS::DisplayAlert(const char *text, ...) {
- char displbuf[2000];
- va_list ap;
- va_start(ap, text);
- vsprintf(displbuf, text, ap);
- va_end(ap);
- printf("%s", displbuf);
- ios_show_message_box(displbuf);
-
- while (ios_wait_for_ui)
- usleep(200);
-}
-
-void AGSIOS::Delay(int millis) {
- usleep(millis);
-}
-
-unsigned long AGSIOS::GetDiskFreeSpaceMB() {
- // placeholder
- return 100;
-}
-
-const char *AGSIOS::GetNoMouseErrorString() {
- return "This game requires a _GP(mouse). You need to configure and setup your mouse to play this game.\n";
-}
-
-eScriptSystemOSID AGSIOS::GetSystemOSID() {
- return eOS_iOS;
-}
-
-int AGSIOS::InitializeCDPlayer() {
- return 0;//cd_player_init();
-}
-
-void AGSIOS::PostAllegroExit() {
- // do nothing
-}
-
-void AGSIOS::SetGameWindowIcon() {
- // do nothing
-}
-
-
-
-void AGSIOS::ShutdownCDPlayer() {
- //cd_exit();
-}
-
-const char *AGSIOS::GetAppOutputDirectory() {
- return ios_document_directory;
-}
-
-AGSPlatformDriver *AGSPlatformDriver::GetDriver() {
- if (instance == NULL)
- instance = new AGSIOS();
- return instance;
-}
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/osx/acplmac.cpp b/engines/ags/engine/platform/osx/acplmac.cpp
deleted file mode 100644
index 6de8628862..0000000000
--- a/engines/ags/engine/platform/osx/acplmac.cpp
+++ /dev/null
@@ -1,155 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_MACOS
-
-// ********* MacOS PLACEHOLDER DRIVER *********
-
-//#include "ags/shared/util/wgt2allg.h"
-//#include "ags/shared/gfx/ali3d.h"
-//#include "ags/shared/ac/runtime_defines.h"
-//#include "ags/shared/main/config.h"
-//#include "ags/shared/plugin/agsplugin.h"
-////include <libcda.h>
-////include <pwd.h>
-////include <sys/stat.h>
-#include "ags/shared/platform/base/agsplatformdriver.h"
-#include "ags/shared/util/directory.h"
-#include "ags/shared/ac/common.h"
-#include "ags/shared/main/main.h"
-
-namespace AGS3 {
-
-void AGSMacInitPaths(char gamename[256], char appdata[PATH_MAX]);
-void AGSMacGetBundleDir(char gamepath[PATH_MAX]);
-//bool PlayMovie(char const *name, int skipType);
-
-static char libraryApplicationSupport[PATH_MAX];
-static char commonDataPath[PATH_MAX];
-
-struct AGSMac : AGSPlatformDriver {
- AGSMac();
-
- virtual int CDPlayerCommand(int cmdd, int datt) override;
- virtual void DisplayAlert(const char *, ...) override;
- virtual unsigned long GetDiskFreeSpaceMB() override;
- virtual const char *GetNoMouseErrorString() override;
- virtual eScriptSystemOSID GetSystemOSID() override;
- virtual int InitializeCDPlayer() override;
- virtual void PostAllegroExit() override;
- virtual void SetGameWindowIcon() override;
- virtual void ShutdownCDPlayer() override;
-
- virtual const char *GetUserSavedgamesDirectory() override;
- virtual const char *GetAllUsersDataDirectory() override;
- virtual const char *GetUserConfigDirectory() override;
- virtual const char *GetAppOutputDirectory() override;
- virtual const char *GetIllegalFileChars() override;
-};
-
-AGSMac::AGSMac() {
- AGSMacInitPaths(psp_game_file_name, libraryApplicationSupport);
-
- snprintf(commonDataPath, PATH_MAX, "%s/uk.co.adventuregamestudio", libraryApplicationSupport);
- AGS::Shared::Directory::CreateDirectory(commonDataPath);
-
- strcpy(psp_translation, "default");
-}
-
-int AGSMac::CDPlayerCommand(int cmdd, int datt) {
- return 0;//cd_player_control(cmdd, datt);
-}
-
-void AGSMac::DisplayAlert(const char *text, ...) {
- char displbuf[2000];
- va_list ap;
- va_start(ap, text);
- vsprintf(displbuf, text, ap);
- va_end(ap);
- if (_logToStdErr)
- fprintf(stderr, "%s\n", displbuf);
- else
- fprintf(stdout, "%s\n", displbuf);
-}
-
-unsigned long AGSMac::GetDiskFreeSpaceMB() {
- // placeholder
- return 100;
-}
-
-const char *AGSMac::GetNoMouseErrorString() {
- return "This game requires a _GP(mouse). You need to configure and setup your mouse to play this game.\n";
-}
-
-eScriptSystemOSID AGSMac::GetSystemOSID() {
- // override performed if `override.os` is set in config.
- return eOS_Mac;
-}
-
-int AGSMac::InitializeCDPlayer() {
- //return cd_player_init();
- return 0;
-}
-
-void AGSMac::PostAllegroExit() {
- // do nothing
-}
-
-void AGSMac::SetGameWindowIcon() {
- // do nothing
-}
-
-void AGSMac::ShutdownCDPlayer() {
- //cd_exit();
-}
-
-const char *AGSMac::GetAllUsersDataDirectory() {
- return commonDataPath;
-}
-
-const char *AGSMac::GetUserSavedgamesDirectory() {
- return libraryApplicationSupport;
-}
-
-const char *AGSMac::GetUserConfigDirectory() {
- return libraryApplicationSupport;
-}
-
-const char *AGSMac::GetAppOutputDirectory() {
- return commonDataPath;
-}
-
-const char *AGSMac::GetIllegalFileChars() {
- return "\\/:?\"<>|*"; // keep same as Windows so we can sync.
-}
-
-AGSPlatformDriver *AGSPlatformDriver::GetDriver() {
- if (instance == NULL)
- instance = new AGSMac();
- return instance;
-}
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/osx/alplmac.mm b/engines/ags/engine/platform/osx/alplmac.mm
deleted file mode 100644
index 9657721705..0000000000
--- a/engines/ags/engine/platform/osx/alplmac.mm
+++ /dev/null
@@ -1,30 +0,0 @@
-#import <Cocoa/Cocoa.h>
-
-//include <stdio.h>
-
-void AGSMacInitPaths(char gamename[256], char appdata[PATH_MAX])
-{
- strcpy(gamename, "game.ags");
-
- @autoreleasepool {
- NSBundle *bundle = [NSBundle mainBundle];
- NSString *resourcedir = [bundle resourcePath];
- [[NSFileManager defaultManager] changeCurrentDirectoryPath:resourcedir];
-
- NSURL *path = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
-
- snprintf(appdata, PATH_MAX, "%s", [[path path] UTF8String]);
- }
-}
-
-// e.g. "/Users/<username>/Library/Application Support/Steam/steamapps/common/<gamename>"
-void AGSMacGetBundleDir(char gamepath[PATH_MAX])
-{
- @autoreleasepool {
- NSBundle *bundle = [NSBundle mainBundle];
- NSString *bundleDir = [bundle bundlePath];
-
- NSString *parentDir = [bundleDir stringByDeletingLastPathComponent];
- strcpy(gamepath, [parentDir UTF8String]);
- }
-}
diff --git a/engines/ags/engine/platform/util/libc.c b/engines/ags/engine/platform/util/libc.c
deleted file mode 100644
index 02aacb202e..0000000000
--- a/engines/ags/engine/platform/util/libc.c
+++ /dev/null
@@ -1,54 +0,0 @@
-//=============================================================================
-//
-// Adventure Game Studio (AGS)
-//
-// Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
-// The full list of copyright holders can be found in the Copyright.txt
-// file, which is part of this source code distribution.
-//
-// The AGS source code is provided under the Artistic License 2.0.
-// A copy of this license can be found in the file License.txt and at
-// http://www.opensource.org/licenses/artistic-license-2.0.php
-//
-//=============================================================================
-//
-// Implementations for missing libc functions
-//
-//=============================================================================
-
-#include "ags/shared/core/platform.h"
-
-#if ! AGS_PLATFORM_OS_WINDOWS
-
-//include <string.h>
-//include <stdio.h>
-//include <stdlib.h>
-//include <wchar.h>
-//include <ctype.h>
-
-size_t mbstowcs(wchar_t *wcstr, const char *mbstr, size_t max)
-{
- int count = 0;
-
- while ((count < max) && (*mbstr != 0))
- {
- *wcstr++ = *mbstr++;
- count++;
- }
- return count;
-
-}
-
-size_t wcstombs(char* mbstr, const wchar_t *wcstr, size_t max)
-{
- int count = 0;
-
- while ((count < max) && (*wcstr != 0))
- {
- *mbstr++ = *wcstr++;
- count++;
- }
- return count;
-}
-
-#endif // ! AGS_PLATFORM_OS_WINDOWS
diff --git a/engines/ags/engine/platform/util/pe.c b/engines/ags/engine/platform/util/pe.c
deleted file mode 100644
index 2925f7e6d5..0000000000
--- a/engines/ags/engine/platform/util/pe.c
+++ /dev/null
@@ -1,311 +0,0 @@
-//=============================================================================
-//
-// Adventure Game Studio (AGS)
-//
-// Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
-// The full list of copyright holders can be found in the Copyright.txt
-// file, which is part of this source code distribution.
-//
-// The AGS source code is provided under the Artistic License 2.0.
-// A copy of this license can be found in the file License.txt and at
-// http://www.opensource.org/licenses/artistic-license-2.0.php
-//
-//=============================================================================
-//
-// Functions for reading version information from PE (Windows EXE) files
-//
-//=============================================================================
-
-#if defined(ANDROID) || defined(PSP)
-
-#include "ags/shared/pe.h"
-
-//include <string.h>
-//include <stdlib.h>
-#include "ags/shared/util/stdio_compat.h"
-
-
-// Simplified structs for PE files
-
-typedef struct {
- char padding[60];
- unsigned int e_lfanew;
-} IMAGE_DOS_HEADER;
-
-typedef struct {
- char padding[2];
- unsigned short NumberOfSections;
- char padding1[16];
-} IMAGE_FILE_HEADER;
-
-typedef struct {
- unsigned int Signature;
- IMAGE_FILE_HEADER FileHeader;
- char padding[224];
-} IMAGE_NT_HEADERS;
-
-typedef struct {
- char Name[8];
- char padding[4];
- unsigned int VirtualAddress;
- char padding1[4];
- unsigned int PointerToRawData;
- char padding2[16];
-} IMAGE_SECTION_HEADER;
-
-
-// These structs are original
-
-typedef struct {
- unsigned int Characteristics;
- unsigned int TimeDateStamp;
- unsigned short MajorVersion;
- unsigned short MinorVersion;
- unsigned short NumberOfNamedEntries;
- unsigned short NumberOfIdEntries;
-} IMAGE_RESOURCE_DIRECTORY;
-
-typedef struct {
- union {
- struct {
- unsigned int NameOffset:31;
- unsigned int NameIsString:1;
- };
- unsigned int Name;
- unsigned short Id;
- };
- union {
- unsigned int OffsetToData;
- struct {
- unsigned int OffsetToDirectory:31;
- unsigned int DataIsDirectory:1;
- };
- };
-} IMAGE_RESOURCE_DIRECTORY_ENTRY;
-
-typedef struct {
- unsigned int OffsetToData;
- unsigned int Size;
- unsigned int CodePage;
- unsigned int Reserved;
-} IMAGE_RESOURCE_DATA_ENTRY;
-
-
-
-// Version information
-
-typedef struct {
- unsigned int dwSignature;
- unsigned int dwStrucVersion;
- unsigned int dwFileVersionMS;
- unsigned int dwFileVersionLS;
- unsigned int dwProductVersionMS;
- unsigned int dwProductVersionLS;
- unsigned int dwFileFlagsMask;
- unsigned int dwFileFlags;
- unsigned int dwFileOS;
- unsigned int dwFileType;
- unsigned int dwFileSubtype;
- unsigned int dwFileDateMS;
- unsigned int dwFileDateLS;
-} VS_FIXEDFILEINFO;
-
-typedef struct {
- unsigned short wLength;
- unsigned short wValueLength;
- unsigned short wType;
-} STRINGFILEINFO_HEADER;
-
-
-
-IMAGE_DOS_HEADER dos_header;
-IMAGE_NT_HEADERS nt_headers;
-IMAGE_SECTION_HEADER section_header;
-IMAGE_RESOURCE_DIRECTORY resource_directory;
-IMAGE_RESOURCE_DIRECTORY_ENTRY resource_directory_entry;
-IMAGE_RESOURCE_DATA_ENTRY resource_data_entry;
-
-unsigned int resource_virtual_address;
-unsigned int resource_start;
-
-
-
-
-void fillBufferFromWidechar(unsigned short* inputBuffer, char* outputText)
-{
- unsigned short* input = inputBuffer;
- char* output = outputText;
-
- while (*input)
- *output++ = *input++;
-
- *output = '\0';
-}
-
-
-
-int getVersionString(char* version_data, unsigned int size, char* buffer, char* name)
-{
- char* current = version_data;
- char* last = version_data + size;
-
- char temp[200];
-
- // Skip header
- current += 0x28;
-
- // Skip VS_FIXEDFILEINFO
- current += sizeof(VS_FIXEDFILEINFO);
-
- // Now comes either "StringFileInfo" or "VarFileInfo"
- STRINGFILEINFO_HEADER* stringfileinfo_header = (STRINGFILEINFO_HEADER*)current;
- current += sizeof(STRINGFILEINFO_HEADER);
- fillBufferFromWidechar((unsigned short*)current, temp);
- if (strcmp(temp, "VarFileInfo") == 0)
- {
- current += (stringfileinfo_header->wLength - sizeof(STRINGFILEINFO_HEADER));
-
- // Skip "StringFileInfo" header too
- stringfileinfo_header = (STRINGFILEINFO_HEADER*)current;
- current += 0x3C;
- }
- else
- current += (0x3C - sizeof(STRINGFILEINFO_HEADER));
-
- while (current < last)
- {
- STRINGFILEINFO_HEADER* header = (STRINGFILEINFO_HEADER*)current;
- current += sizeof(STRINGFILEINFO_HEADER);
-
- // Read name
- fillBufferFromWidechar((unsigned short*)current, temp);
-
- if (strcmp(temp, name) == 0)
- {
- current += (2 + 2 * strlen(temp));
-
- // Next value is 32 bit aligned
- current = (char*)((unsigned long)(current + 3) & (~3));
-
- // Read value
- fillBufferFromWidechar((unsigned short*)current, buffer);
-
- return 1;
- }
- else
- current += (header->wLength - sizeof(STRINGFILEINFO_HEADER));
-
- // Next value is 32 bit aligned
- current = (char*)((unsigned long)(current + 3) & (~3));
- }
-
- return 0;
-}
-
-
-
-int seekToResource(FILE* pe, int id)
-{
- int i;
-
- // Read in resource directory
- fread(&resource_directory, sizeof(IMAGE_RESOURCE_DIRECTORY), 1, pe);
-
- // Loop through root node entries till we find the entry with the given id
- for (i = 0; i < resource_directory.NumberOfIdEntries + resource_directory.NumberOfNamedEntries; i++)
- {
- // Read in resource node
- fread(&resource_directory_entry, sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY), 1, pe);
-
- if ((!resource_directory_entry.NameIsString) && (resource_directory_entry.Id == id))
- {
- // Seek to end of subdirectory
- ags_fseek(pe, resource_start + resource_directory_entry.OffsetToDirectory, SEEK_SET);
- return 1;
- }
- }
-
- return 0;
-}
-
-
-
-int getVersionInformation(char* filename, version_info_t* version_info)
-{
- FILE* pe = fopen(filename, "rb");
-
- if (!pe)
- return 0;
-
- // Read in the DOS header, get the offset to the PE header and seek
- fread(&dos_header, sizeof(IMAGE_DOS_HEADER), 1, pe);
- ags_fseek(pe, dos_header.e_lfanew, SEEK_SET);
-
- // Read in the PE header
- fread(&nt_headers, sizeof(IMAGE_NT_HEADERS), 1, pe);
-
- // Loop through sections till we find the resource section
- int i;
- for (i = 0; i < nt_headers.FileHeader.NumberOfSections; i++)
- {
- fread(§ion_header, sizeof(IMAGE_SECTION_HEADER), 1, pe);
-
- if (strcmp(".rsrc", (char*)section_header.Name) == 0)
- break;
- }
-
- if (i == nt_headers.FileHeader.NumberOfSections)
- goto error_exit;
-
- // Save virtual address of the resource section
- resource_virtual_address = section_header.VirtualAddress;
-
- // Seek to the resource section
- ags_fseek(pe, section_header.PointerToRawData, SEEK_SET);
-
- // Save file offset to the resource section
- resource_start = section_header.PointerToRawData;
-
- // Search for the version resource in the resource tree
- if (!seekToResource(pe, 16))
- goto error_exit;
-
- // Enter the first subdirectory in the version resource
- if (!seekToResource(pe, 1))
- goto error_exit;
-
- // Hopefully found the resource
- fread(&resource_directory, sizeof(IMAGE_RESOURCE_DATA_ENTRY), 1, pe);
-
- // Read in resource node
- fread(&resource_directory_entry, sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY), 1, pe);
-
- // Seek to the resource data
- ags_fseek(pe, resource_start + resource_directory_entry.OffsetToData, SEEK_SET);
-
- // Read in version info
- fread(&resource_data_entry, sizeof(IMAGE_RESOURCE_DATA_ENTRY), 1, pe);
-
- // Finally we got a virtual address of the resource, now seek to it
- ags_fseek(pe, resource_start + resource_data_entry.OffsetToData - resource_virtual_address, SEEK_SET);
-
- // Read version resource
- char* version_data = (char*)malloc(resource_data_entry.Size);
- fread(version_data, resource_data_entry.Size, 1, pe);
-
- memset(version_info, 0, sizeof(version_info_t));
- getVersionString(version_data, resource_data_entry.Size, version_info->version, "FileVersion");
- getVersionString(version_data, resource_data_entry.Size, version_info->description, "FileDescription");
- getVersionString(version_data, resource_data_entry.Size, version_info->internal_name, "InternalName");
-
- free(version_data);
- fclose(pe);
-
- return 1;
-
-error_exit:
- fclose(pe);
- return 0;
-}
-
-#endif
\ No newline at end of file
diff --git a/engines/ags/engine/platform/util/pe.h b/engines/ags/engine/platform/util/pe.h
deleted file mode 100644
index 98bdc2227a..0000000000
--- a/engines/ags/engine/platform/util/pe.h
+++ /dev/null
@@ -1,46 +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.
- *
- */
-
-#ifndef AGS_ENGINE_PLATFORM_UTIL_PE_H
-#define AGS_ENGINE_PLATFORM_UTIL_PE_H
-
-namespace AGS3 {
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- typedef struct {
- char version[15];
- char description[100];
- char internal_name[100];
- } version_info_t;
-
- int getVersionInformation(char *filename, version_info_t *version_info);
-
-#ifdef __cplusplus
-}
-#endif
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/acplwin.cpp b/engines/ags/engine/platform/windows/acplwin.cpp
deleted file mode 100644
index 5222ef878a..0000000000
--- a/engines/ags/engine/platform/windows/acplwin.cpp
+++ /dev/null
@@ -1,983 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_WINDOWS
-
-// ********* WINDOWS *********
-
-//include <string.h>
-#include "ags/lib/allegro.h"
-//include <allegro/platform/aintwin.h>
-#include "ags/shared/ac/common.h"
-#include "ags/shared/ac/draw.h"
-#include "ags/shared/ac/gamesetup.h"
-#include "ags/shared/ac/gamesetupstruct.h"
-#include "ags/shared/ac/global_display.h"
-#include "ags/shared/ac/runtime_defines.h"
-#include "ags/shared/ac/string.h"
-#include "ags/shared/debugging/out.h"
-#include "ags/shared/gfx/graphicsdriver.h"
-#include "ags/shared/gfx/bitmap.h"
-#include "ags/shared/main/engine.h"
-#include "ags/shared/platform/base/agsplatformdriver.h"
-#include "ags/shared/platform/windows/setup/winsetup.h"
-#include "ags/shared/plugin/agsplugin.h"
-#include "ags/shared/util/file.h"
-#include "ags/shared/util/stream.h"
-#include "ags/shared/util/string_compat.h"
-#include "ags/shared/media/audio/audio_system.h"
-
-namespace AGS3 {
-
-using namespace AGS::Shared;
-using namespace AGS::Engine;
-
-extern GameSetup usetup;
-extern color palette[256];
-
-//include <shlobj.h>
-//include <time.h>
-//include <shlwapi.h>
-//include <windows.h>
-//include <rpcsal.h>
-//include <gameux.h>
-
-//include <libcda.h>
-
-
-#ifndef CSIDL_LOCAL_APPDATA
-#define CSIDL_LOCAL_APPDATA 0x001C
-#define CSIDL_COMMON_APPDATA 0x0023
-#endif
-
-typedef struct BMP_EXTRA_INFO {
- LPDIRECTDRAWSURFACE2 surf;
- struct BMP_EXTRA_INFO *next;
- struct BMP_EXTRA_INFO *prev;
- int flags;
- int lock_nesting;
-} BMP_EXTRA_INFO;
-
-// from Allegro DDraw driver
-extern "C" extern LPDIRECTDRAW2 directdraw;
-extern "C" extern LPDIRECTSOUND directsound;
-extern "C" extern LPDIRECTINPUTDEVICE mouse_dinput_device;
-extern "C" extern LPDIRECTINPUTDEVICE key_dinput_device;
-
-char win32SavedGamesDirectory[MAX_PATH] = "\0";
-char win32AppDataDirectory[MAX_PATH] = "\0";
-String win32OutputDirectory;
-
-const unsigned int win32TimerPeriod = 1;
-
-extern SetupReturnValue acwsetup(const ConfigTree &cfg_in, ConfigTree &cfg_out, const String &game_data_dir, const char *, const char *);
-
-struct AGSWin32 : AGSPlatformDriver {
- AGSWin32();
- ~AGSWin32();
-
- virtual void AboutToQuitGame();
- virtual int CDPlayerCommand(int cmdd, int datt);
- virtual void AttachToParentConsole();
- virtual void DisplayAlert(const char *, ...);
- virtual int GetLastSystemError();
- virtual const char *GetAllUsersDataDirectory();
- virtual const char *GetUserSavedgamesDirectory();
- virtual const char *GetUserConfigDirectory();
- virtual const char *GetUserGlobalConfigDirectory();
- virtual const char *GetAppOutputDirectory();
- virtual const char *GetIllegalFileChars();
- virtual const char *GetGraphicsTroubleshootingText();
- virtual unsigned long GetDiskFreeSpaceMB();
- virtual const char *GetNoMouseErrorString();
- virtual bool IsMouseControlSupported(bool windowed);
- virtual const char *GetAllegroFailUserHint();
- virtual eScriptSystemOSID GetSystemOSID();
- virtual int InitializeCDPlayer();
- virtual void PostAllegroInit(bool windowed);
- virtual void PostAllegroExit();
- virtual SetupReturnValue RunSetup(const ConfigTree &cfg_in, ConfigTree &cfg_out);
- virtual void SetGameWindowIcon();
- virtual void ShutdownCDPlayer();
- virtual void WriteStdOut(const char *fmt, ...);
- virtual void WriteStdErr(const char *fmt, ...);
- virtual void DisplaySwitchOut();
- virtual void DisplaySwitchIn();
- virtual void PauseApplication();
- virtual void ResumeApplication();
- virtual void GetSystemDisplayModes(std::vector<Engine::DisplayMode> &dms);
- virtual bool EnterFullscreenMode(const Engine::DisplayMode &dm);
- virtual bool ExitFullscreenMode();
- virtual void AdjustWindowStyleForFullscreen();
- virtual void AdjustWindowStyleForWindowed();
- virtual void RegisterGameWithGameExplorer();
- virtual void UnRegisterGameWithGameExplorer();
- virtual int ConvertKeycodeToScanCode(int keyCode);
- virtual void ValidateWindowSize(int &x, int &y, bool borderless) const;
- virtual bool LockMouseToWindow();
- virtual void UnlockMouse();
-
-
-private:
- void add_game_to_game_explorer(IGameExplorer *pFwGameExplorer, GUID *guid, const char *guidAsText, bool allUsers);
- void remove_game_from_game_explorer(IGameExplorer *pFwGameExplorer, GUID *guid, const char *guidAsText, bool allUsers);
- void add_tasks_for_game(const char *guidAsText, const char *gameEXE, const char *workingFolder, bool allUsers);
- void get_tasks_directory(char *directoryNameBuffer, const char *guidAsText, bool allUsers);
- void update_game_explorer(bool add);
- void create_shortcut(const char *pathToEXE, const char *workingFolder, const char *arguments, const char *shortcutPath);
- void register_file_extension(const char *exePath);
- void unregister_file_extension();
-
- bool SetSystemDisplayMode(const DisplayMode &dm, bool fullscreen);
-
- bool _isDebuggerPresent; // indicates if the win app is running in the context of a debugger
- DisplayMode _preFullscreenMode; // saved display mode before switching system to fullscreen
- bool _isAttachedToParentConsole; // indicates if the win app is attached to the parent console
-};
-
-AGSWin32::AGSWin32() :
- _isDebuggerPresent(::IsDebuggerPresent() != FALSE),
- _isAttachedToParentConsole(false) {
- // Do nothing.
-}
-
-AGSWin32::~AGSWin32() {
- if (_isAttachedToParentConsole) {
- ::FreeConsole();
- }
-}
-
-void check_parental_controls() {
- /* this doesn't work, it always just returns access depedning
- on whether unrated games are allowed because of digital signature
- BOOL bHasAccess = FALSE;
- IGameExplorer* pFwGameExplorer = NULL;
-
- CoInitialize(NULL);
- // Create an instance of the Game Explorer Interface
- HRESULT hr = CoCreateInstance( __uuidof(GameExplorer), NULL, CLSCTX_INPROC_SERVER, __uuidof(IGameExplorer), (void**)&pFwGameExplorer);
- if( FAILED(hr) || pFwGameExplorer == NULL ) {
- // not Vista, do nothing
- }
- else {
- char theexename[MAX_PATH] = "e:\\code\\ags\\acwin\\release\\acwin.exe";
- WCHAR wstrBinPath[MAX_PATH] = {0};
- MultiByteToWideChar(CP_ACP, 0, theexename, MAX_PATH, wstrBinPath, MAX_PATH);
- BSTR bstrGDFBinPath = SysAllocString(wstrBinPath);
-
- hr = pFwGameExplorer->VerifyAccess( bstrGDFBinPath, &bHasAccess );
- SysFreeString(bstrGDFBinPath);
-
- if( FAILED(hr) || !bHasAccess ) {
- char buff[300];
- sprintf(buff, "Parental controls block: %X b: %d", hr, bHasAccess);
- quit(buff);
- }
- else {
- platform->DisplayAlert("Parental controls: Access granted.");
- }
-
- }
-
- if( pFwGameExplorer ) pFwGameExplorer->Release();
- CoUninitialize();
- */
-}
-
-void AGSWin32::create_shortcut(const char *pathToEXE, const char *workingFolder, const char *arguments, const char *shortcutPath) {
- IShellLink *pShellLink = NULL;
- HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&pShellLink);
-
- if ((SUCCEEDED(hr)) && (pShellLink != NULL)) {
- IPersistFile *pPersistFile = NULL;
- if (FAILED(pShellLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) {
- this->DisplayAlert("Unable to add game tasks: QueryInterface for IPersistFile failed");
- pShellLink->Release();
- return;
- }
-
- // Set the path to the shortcut target and add the description
- if (FAILED(pShellLink->SetPath(pathToEXE))) {
- this->DisplayAlert("Unable to add game tasks: SetPath failed");
- } else if (FAILED(pShellLink->SetWorkingDirectory(workingFolder))) {
- this->DisplayAlert("Unable to add game tasks: SetWorkingDirectory failed");
- } else if ((arguments != NULL) && (FAILED(pShellLink->SetArguments(arguments)))) {
- this->DisplayAlert("Unable to add game tasks: SetArguments failed");
- } else {
- WCHAR wstrTemp[MAX_PATH] = {0};
- MultiByteToWideChar(CP_ACP, 0, shortcutPath, -1, wstrTemp, MAX_PATH);
-
- if (FAILED(pPersistFile->Save(wstrTemp, TRUE))) {
- this->DisplayAlert("Unable to add game tasks: IPersistFile::Save failed");
- }
- }
-
- pPersistFile->Release();
- }
-
- if (pShellLink) pShellLink->Release();
-}
-
-void CopyStringAndRemoveInvalidFilenameChars(const char *source, char *destinationBuffer) {
- int destIdx = 0;
- for (int i = 0; i < (int)strlen(source); i++) {
- if ((source[i] != '/') &&
- (source[i] != '\\') &&
- (source[i] != ':') &&
- (source[i] != '*') &&
- (source[i] != '?') &&
- (source[i] != '"') &&
- (source[i] != '<') &&
- (source[i] != '>') &&
- (source[i] != '|') &&
- (source[i] >= 32)) {
- destinationBuffer[destIdx] = source[i];
- destIdx++;
- }
- }
- destinationBuffer[destIdx] = 0;
-}
-
-void AGSWin32::get_tasks_directory(char *pathBuffer, const char *guidAsText, bool allUsers) {
- if (SHGetSpecialFolderPath(NULL, pathBuffer, allUsers ? CSIDL_COMMON_APPDATA : CSIDL_LOCAL_APPDATA, FALSE) == FALSE) {
- this->DisplayAlert("Unable to register game: SHGetSpecialFolderPath failed");
- return;
- }
-
- if (pathBuffer[strlen(pathBuffer) - 1] != '\\') {
- strcat(pathBuffer, "\\");
- }
-
- strcat(pathBuffer, "Microsoft\\Windows\\GameExplorer\\");
- strcat(pathBuffer, guidAsText);
- mkdir(pathBuffer);
- strcat(pathBuffer, "\\");
- strcat(pathBuffer, "PlayTasks");
- mkdir(pathBuffer);
-}
-
-void AGSWin32::add_tasks_for_game(const char *guidAsText, const char *gameEXE, const char *workingFolder, bool allUsers) {
- char pathBuffer[MAX_PATH];
- get_tasks_directory(pathBuffer, guidAsText, allUsers);
- strcat(pathBuffer, "\\");
- strcat(pathBuffer, "0");
- mkdir(pathBuffer);
-
- // Remove any existing "Play.lnk" from a previous version
- char shortcutLocation[MAX_PATH];
- sprintf(shortcutLocation, "%s\\Play.lnk", pathBuffer);
- ::remove(shortcutLocation);
-
- // Generate the shortcut file name (because it can appear on
- // the start menu's Recent area)
- char sanitisedGameName[MAX_PATH];
- CopyStringAndRemoveInvalidFilenameChars(game.gamename, sanitisedGameName);
- if (sanitisedGameName[0] == 0)
- strcpy(sanitisedGameName, "Play");
- sprintf(shortcutLocation, "%s\\%s.lnk", pathBuffer, sanitisedGameName);
-
- create_shortcut(gameEXE, workingFolder, NULL, shortcutLocation);
-
- pathBuffer[strlen(pathBuffer) - 1] = '1';
- mkdir(pathBuffer);
-
- sprintf(shortcutLocation, "%s\\Setup game.lnk", pathBuffer);
- create_shortcut(gameEXE, workingFolder, "--setup", shortcutLocation);
-}
-
-void AGSWin32::add_game_to_game_explorer(IGameExplorer *pFwGameExplorer, GUID *guid, const char *guidAsText, bool allUsers) {
- WCHAR wstrTemp[MAX_PATH] = {0};
- bool hadError = false;
-
- char theexename[MAX_PATH];
- GetModuleFileName(NULL, theexename, MAX_PATH);
-
- MultiByteToWideChar(CP_ACP, 0, theexename, MAX_PATH, wstrTemp, MAX_PATH);
- BSTR bstrGDFBinPath = SysAllocString(wstrTemp);
-
- char gameDirectory[MAX_PATH];
- strcpy(gameDirectory, theexename);
- strrchr(gameDirectory, '\\')[0] = 0;
-
- MultiByteToWideChar(CP_ACP, 0, gameDirectory, MAX_PATH, wstrTemp, MAX_PATH);
- BSTR bstrGameDirectory = SysAllocString(wstrTemp);
-
- HRESULT hr = pFwGameExplorer->AddGame(bstrGDFBinPath, bstrGameDirectory, allUsers ? GIS_ALL_USERS : GIS_CURRENT_USER, guid);
- if ((FAILED(hr)) || (hr == S_FALSE)) {
- if (hr == 0x80070715) {
- // No GDF XML -- do nothing. This means the game was compiled
- // without Game Explorer support.
- hadError = true;
- } else {
- // Game already exists or error
- HRESULT updateHr = pFwGameExplorer->UpdateGame(*guid);
- if (FAILED(updateHr)) {
- this->DisplayAlert("Failed to add the game to the game explorer: %08X, %08X", hr, updateHr);
- hadError = true;
- }
- }
- } else {
- add_tasks_for_game(guidAsText, theexename, gameDirectory, allUsers);
- }
-
- BOOL bHasAccess = FALSE;
- hr = pFwGameExplorer->VerifyAccess(bstrGDFBinPath, &bHasAccess);
-
- if ((FAILED(hr) || !bHasAccess) && (!hadError)) {
- this->DisplayAlert("Windows Parental Controls will not allow you to run this game.");
- }
-
- SysFreeString(bstrGDFBinPath);
- SysFreeString(bstrGameDirectory);
-}
-
-#define FA_SEARCH -1
-void delete_files_in_directory(const char *directoryName, const char *fileMask) {
- char srchBuffer[MAX_PATH];
- sprintf(srchBuffer, "%s\\%s", directoryName, fileMask);
- al_ffblk dfb;
- int dun = al_findfirst(srchBuffer, &dfb, FA_SEARCH);
- while (!dun) {
- ::remove(dfb.name);
- dun = al_findnext(&dfb);
- }
- al_findclose(&dfb);
-}
-
-void AGSWin32::remove_game_from_game_explorer(IGameExplorer *pFwGameExplorer, GUID *guid, const char *guidAsText, bool allUsers) {
- HRESULT hr = pFwGameExplorer->RemoveGame(*guid);
- if (FAILED(hr)) {
- this->DisplayAlert("Failed to un-register game: 0x%08X", hr);
- }
-}
-
-void AGSWin32::update_game_explorer(bool add) {
- IGameExplorer *pFwGameExplorer = NULL;
-
- CoInitialize(NULL);
- // Create an instance of the Game Explorer Interface
- HRESULT hr = CoCreateInstance(__uuidof(GameExplorer), NULL, CLSCTX_INPROC_SERVER, __uuidof(IGameExplorer), (void **)&pFwGameExplorer);
- if (FAILED(hr) || pFwGameExplorer == NULL) {
- Debug::Printf(kDbgMsg_Warn, "Game Explorer not found to register game, Windows Vista required");
- } else {
- ags_strupr(game.guid);
- WCHAR wstrTemp[MAX_PATH] = {0};
- GUID guid = GUID_NULL;
- MultiByteToWideChar(CP_ACP, 0, game.guid, MAX_GUID_LENGTH, wstrTemp, MAX_GUID_LENGTH);
- if (IIDFromString(wstrTemp, &guid) != S_OK) {
- this->DisplayAlert("Failed to register game: IIDFromString failed");
- } else if (add) {
- add_game_to_game_explorer(pFwGameExplorer, &guid, game.guid, true);
- } else {
- remove_game_from_game_explorer(pFwGameExplorer, &guid, game.guid, true);
- }
- }
-
- if (pFwGameExplorer) pFwGameExplorer->Release();
- CoUninitialize();
-}
-
-void AGSWin32::unregister_file_extension() {
- char keyname[MAX_PATH];
- sprintf(keyname, ".%s", game.saveGameFileExtension);
- if (SHDeleteKey(HKEY_CLASSES_ROOT, keyname) != ERROR_SUCCESS) {
- this->DisplayAlert("Unable to un-register the file extension. Make sure you are running this with admin rights.");
- return;
- }
-
- sprintf(keyname, "AGS.SaveGames.%s", game.saveGameFileExtension);
- SHDeleteKey(HKEY_CLASSES_ROOT, keyname);
-
- sprintf(keyname, "Software\\Microsoft\\Windows\\CurrentVersion\\PropertySystem\\PropertyHandlers\\.%s", game.saveGameFileExtension);
- SHDeleteKey(HKEY_LOCAL_MACHINE, keyname);
-
- // Tell Explorer to refresh its file association data
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-}
-
-void AGSWin32::register_file_extension(const char *exePath) {
- DWORD valType, valBufLen = MAX_PATH;
- valType = REG_SZ;
- char valBuf[MAX_PATH], keyname[MAX_PATH];
- char saveGameRegistryType[MAX_PATH];
- sprintf(saveGameRegistryType, "AGS.SaveGames.%s", game.saveGameFileExtension);
-
- // write HKEY_CLASSES_ROOT\.Extension = AGS.SaveGames.Extension
- strcpy(valBuf, saveGameRegistryType);
- sprintf(keyname, ".%s", game.saveGameFileExtension);
- if (RegSetValue(HKEY_CLASSES_ROOT, keyname, valType, valBuf, valBufLen)) {
- this->DisplayAlert("Unable to register file type. Make sure you are running this with Administrator rights.");
- return;
- }
-
- // create HKEY_CLASSES_ROOT\AGS.SaveGames.Extension
- strcpy(keyname, saveGameRegistryType);
- sprintf(valBuf, "%s Saved Game", game.gamename);
- RegSetValue(HKEY_CLASSES_ROOT, keyname, REG_SZ, valBuf, strlen(valBuf));
-
- // write HKEY_CLASSES_ROOT\AGS.SaveGames.Extension\DefaultIcon
- sprintf(keyname, "%s\\DefaultIcon", saveGameRegistryType);
- sprintf(valBuf, "\"%s\", 0", exePath);
- RegSetValue(HKEY_CLASSES_ROOT, keyname, REG_SZ, valBuf, strlen(valBuf));
-
- // write HKEY_CLASSES_ROOT\AGS.SaveGames.Extension\Shell\Open\Command
- sprintf(keyname, "%s\\Shell\\Open\\Command", saveGameRegistryType);
- sprintf(valBuf, "\"%s\" -loadSavedGame \"%%1\"", exePath);
- RegSetValue(HKEY_CLASSES_ROOT, keyname, REG_SZ, valBuf, strlen(valBuf));
-
- // ** BELOW IS VISTA-ONLY
-
- // write HKEY_CLASSES_ROOT\AGS.SaveGames.Extension, PreviewTitle
- strcpy(keyname, saveGameRegistryType);
- strcpy(valBuf, "prop:System.Game.RichSaveName;System.Game.RichApplicationName");
- SHSetValue(HKEY_CLASSES_ROOT, keyname, "PreviewTitle", REG_SZ, valBuf, strlen(valBuf));
-
- // write HKEY_CLASSES_ROOT\AGS.SaveGames.Extension, PreviewDetails
- strcpy(keyname, saveGameRegistryType);
- strcpy(valBuf, "prop:System.Game.RichLevel;System.DateChanged;System.Game.RichComment;System.DisplayName;System.DisplayType");
- SHSetValue(HKEY_CLASSES_ROOT, keyname, "PreviewDetails", REG_SZ, valBuf, strlen(valBuf));
-
- // write HKEY_CLASSES_ROOT\.Extension\ShellEx\{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}
- sprintf(keyname, ".%s\\ShellEx\\{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}", game.saveGameFileExtension);
- strcpy(valBuf, "{4E5BFBF8-F59A-4E87-9805-1F9B42CC254A}");
- RegSetValue(HKEY_CLASSES_ROOT, keyname, REG_SZ, valBuf, strlen(valBuf));
-
- // write HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers\.Extension
- sprintf(keyname, "Software\\Microsoft\\Windows\\CurrentVersion\\PropertySystem\\PropertyHandlers\\.%s", game.saveGameFileExtension);
- strcpy(valBuf, "{ECDD6472-2B9B-4B4B-AE36-F316DF3C8D60}");
- RegSetValue(HKEY_LOCAL_MACHINE, keyname, REG_SZ, valBuf, strlen(valBuf));
-
- // Tell Explorer to refresh its file association data
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-}
-
-void AGSWin32::RegisterGameWithGameExplorer() {
- update_game_explorer(true);
-
- if (game.saveGameFileExtension[0] != 0) {
- char theexename[MAX_PATH];
- GetModuleFileName(NULL, theexename, MAX_PATH);
-
- register_file_extension(theexename);
- }
-}
-
-void AGSWin32::UnRegisterGameWithGameExplorer() {
- update_game_explorer(false);
-
- if (game.saveGameFileExtension[0] != 0) {
- unregister_file_extension();
- }
-}
-
-void AGSWin32::PostAllegroInit(bool windowed) {
- check_parental_controls();
-
- // Set the Windows timer resolution to 1 ms so that calls to
- // Sleep() don't take more time than specified
- MMRESULT result = timeBeginPeriod(win32TimerPeriod);
- if (result != TIMERR_NOERROR)
- Debug::Printf(kDbgMsg_Error, "Failed to set the timer resolution to %d ms", win32TimerPeriod);
-}
-
-typedef UINT(CALLBACK *Dynamic_SHGetKnownFolderPathType)(GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
-GUID FOLDERID_SAVEDGAMES = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}};
-#define _WIN32_WINNT_VISTA 0x0600
-#define VER_MINORVERSION 0x0000001
-#define VER_MAJORVERSION 0x0000002
-#define VER_SERVICEPACKMAJOR 0x0000020
-#define VER_GREATER_EQUAL 3
-
-// These helpers copied from VersionHelpers.h in the Windows 8.1 SDK
-bool IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) {
- OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 };
- DWORDLONG const dwlConditionMask = VerSetConditionMask(
- VerSetConditionMask(
- VerSetConditionMask(
- 0, VER_MAJORVERSION, VER_GREATER_EQUAL),
- VER_MINORVERSION, VER_GREATER_EQUAL),
- VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
-
- osvi.dwMajorVersion = wMajorVersion;
- osvi.dwMinorVersion = wMinorVersion;
- osvi.wServicePackMajor = wServicePackMajor;
-
- return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
-}
-
-bool IsWindowsVistaOrGreater() {
- return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
-}
-
-void determine_app_data_folder() {
- if (win32AppDataDirectory[0] != 0) {
- // already discovered
- return;
- }
-
- WCHAR unicodePath[MAX_PATH];
- WCHAR unicodeShortPath[MAX_PATH];
- SHGetSpecialFolderPathW(NULL, unicodePath, CSIDL_COMMON_APPDATA, FALSE);
- if (GetShortPathNameW(unicodePath, unicodeShortPath, MAX_PATH) == 0) {
- platform->DisplayAlert("Unable to get App Data dir: GetShortPathNameW failed");
- return;
- }
- WideCharToMultiByte(CP_ACP, 0, unicodeShortPath, -1, win32AppDataDirectory, MAX_PATH, NULL, NULL);
-
- strcat(win32AppDataDirectory, "\\Adventure Game Studio");
- mkdir(win32AppDataDirectory);
-}
-
-void determine_saved_games_folder() {
- if (win32SavedGamesDirectory[0] != 0) {
- // already discovered
- return;
- }
-
- WCHAR unicodeSaveGameDir[MAX_PATH] = L"";
- WCHAR unicodeShortSaveGameDir[MAX_PATH] = L"";
-
- if (IsWindowsVistaOrGreater()) {
- HINSTANCE hShellDLL = LoadLibrary("shell32.dll");
- Dynamic_SHGetKnownFolderPathType Dynamic_SHGetKnownFolderPath = (Dynamic_SHGetKnownFolderPathType)GetProcAddress(hShellDLL, "SHGetKnownFolderPath");
-
- if (Dynamic_SHGetKnownFolderPath != NULL) {
- PWSTR path = NULL;
- if (SUCCEEDED(Dynamic_SHGetKnownFolderPath(FOLDERID_SAVEDGAMES, 0, NULL, &path))) {
- if (GetShortPathNameW(path, unicodeShortSaveGameDir, MAX_PATH) > 0) {
- WideCharToMultiByte(CP_ACP, 0, unicodeShortSaveGameDir, -1, win32SavedGamesDirectory, MAX_PATH, NULL, NULL);
- }
- CoTaskMemFree(path);
- }
- }
-
- FreeLibrary(hShellDLL);
- } else {
- // Windows XP didn't have a "My Saved Games" folder, so create one under "My Documents"
- SHGetSpecialFolderPathW(NULL, unicodeSaveGameDir, CSIDL_PERSONAL, FALSE);
- // workaround for case where My Documents path has unicode chars (eg.
- // with Russian Windows) -- so use Short File Name instead
- if (GetShortPathNameW(unicodeSaveGameDir, unicodeShortSaveGameDir, MAX_PATH) > 0) {
- WideCharToMultiByte(CP_ACP, 0, unicodeShortSaveGameDir, -1, win32SavedGamesDirectory, MAX_PATH, NULL, NULL);
- strcat(win32SavedGamesDirectory, "\\My Saved Games");
- mkdir(win32SavedGamesDirectory);
- }
- }
-
- // Fallback to a subdirectory of the app data directory
- if (win32SavedGamesDirectory[0] == '\0') {
- determine_app_data_folder();
- strcpy(win32SavedGamesDirectory, win32AppDataDirectory);
- strcat(win32SavedGamesDirectory, "\\Saved Games");
- mkdir(win32SavedGamesDirectory);
- }
-}
-
-void DetermineAppOutputDirectory() {
- if (!win32OutputDirectory.IsEmpty()) {
- return;
- }
-
- determine_saved_games_folder();
- bool log_to_saves_dir = false;
- if (win32SavedGamesDirectory[0]) {
- win32OutputDirectory = win32SavedGamesDirectory;
- win32OutputDirectory.Append("\\.ags");
- log_to_saves_dir = mkdir(win32OutputDirectory) == 0 || errnum == EEXIST;
- }
-
- if (!log_to_saves_dir) {
- char theexename[MAX_PATH + 1] = {0};
- GetModuleFileName(NULL, theexename, MAX_PATH);
- PathRemoveFileSpec(theexename);
- win32OutputDirectory = theexename;
- }
-}
-
-const char *AGSWin32::GetAllUsersDataDirectory() {
- determine_app_data_folder();
- return &win32AppDataDirectory[0];
-}
-
-const char *AGSWin32::GetUserSavedgamesDirectory() {
- determine_saved_games_folder();
- return win32SavedGamesDirectory;
-}
-
-const char *AGSWin32::GetUserConfigDirectory() {
- determine_saved_games_folder();
- return win32SavedGamesDirectory;
-}
-
-const char *AGSWin32::GetUserGlobalConfigDirectory() {
- DetermineAppOutputDirectory();
- return win32OutputDirectory;
-}
-
-const char *AGSWin32::GetAppOutputDirectory() {
- DetermineAppOutputDirectory();
- return win32OutputDirectory;
-}
-
-const char *AGSWin32::GetIllegalFileChars() {
- return "\\/:?\"<>|*";
-}
-
-const char *AGSWin32::GetGraphicsTroubleshootingText() {
- return "\n\nPossible causes:\n"
- "* your graphics card drivers do not support requested resolution. "
- "Run the game setup program and try another resolution.\n"
- "* the graphics driver you have selected does not work. Try switching to another graphics driver.\n"
- "* the graphics filter you have selected does not work. Try another filter.\n"
- "* your graphics card drivers are out of date. "
- "Try downloading updated graphics card drivers from your manufacturer's website.\n"
- "* there is a problem with your graphics card driver configuration. "
- "Run DXDiag using the Run command (Start->Run, type \"dxdiag.exe\") and correct any problems reported there.";
-}
-
-void AGSWin32::DisplaySwitchOut() {
- // If we have explicitly set up fullscreen mode then minimize the window
- if (_preFullscreenMode.IsValid())
- ShowWindow(win_get_window(), SW_MINIMIZE);
-}
-
-void AGSWin32::DisplaySwitchIn() {
- // If we have explicitly set up fullscreen mode then restore the window
- if (_preFullscreenMode.IsValid())
- ShowWindow(win_get_window(), SW_RESTORE);
-}
-
-void AGSWin32::PauseApplication() {
-}
-
-void AGSWin32::ResumeApplication() {
-}
-
-void AGSWin32::GetSystemDisplayModes(std::vector<DisplayMode> &dms) {
- dms.clear();
- GFX_MODE_LIST *gmlist = get_gfx_mode_list(GFX_DIRECTX);
- for (int i = 0; i < gmlist->num_modes; ++i) {
- const GFX_MODE &m = gmlist->mode[i];
- dms.push_back(DisplayMode(GraphicResolution(m.width, m.height, m.bpp)));
- }
- destroy_gfx_mode_list(gmlist);
-}
-
-bool AGSWin32::SetSystemDisplayMode(const DisplayMode &dm, bool fullscreen) {
- DEVMODE devmode;
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
- devmode.dmPelsWidth = dm.Width;
- devmode.dmPelsHeight = dm.Height;
- devmode.dmBitsPerPel = dm.ColorDepth;
- devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- return ChangeDisplaySettings(&devmode, fullscreen ? CDS_FULLSCREEN : 0) == DISP_CHANGE_SUCCESSFUL;
-}
-
-bool AGSWin32::EnterFullscreenMode(const DisplayMode &dm) {
- // Remember current mode
- get_desktop_resolution(&_preFullscreenMode.Width, &_preFullscreenMode.Height);
- _preFullscreenMode.ColorDepth = desktop_color_depth();
-
- // Set requested desktop mode
- return SetSystemDisplayMode(dm, true);
-}
-
-bool AGSWin32::ExitFullscreenMode() {
- if (!_preFullscreenMode.IsValid())
- return false;
-
- DisplayMode dm = _preFullscreenMode;
- _preFullscreenMode = DisplayMode();
- return SetSystemDisplayMode(dm, false);
-}
-
-void AGSWin32::AdjustWindowStyleForFullscreen() {
- // Remove the border in full-screen mode
- Size sz;
- get_desktop_resolution(&sz.Width, &sz.Height);
- HWND allegro_wnd = win_get_window();
- LONG winstyle = GetWindowLong(allegro_wnd, GWL_STYLE);
- SetWindowLong(allegro_wnd, GWL_STYLE, (winstyle & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
- SetWindowPos(allegro_wnd, HWND_TOP, 0, 0, sz.Width, sz.Height, 0);
-}
-
-void AGSWin32::AdjustWindowStyleForWindowed() {
- // Make a regular window with a border
- HWND allegro_wnd = win_get_window();
- LONG winstyle = GetWindowLong(allegro_wnd, GWL_STYLE);
- SetWindowLong(allegro_wnd, GWL_STYLE, (winstyle & ~WS_POPUP) | (WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX));
- // Make window go on top, but at the same time remove WS_EX_TOPMOST style (applied by Direct3D fullscreen mode)
- SetWindowPos(allegro_wnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
-}
-
-int AGSWin32::CDPlayerCommand(int cmdd, int datt) {
-#if defined (AGS_HAS_CD_AUDIO)
- return cd_player_control(cmdd, datt);
-#else
- return -1;
-#endif
-}
-
-void AGSWin32::AttachToParentConsole() {
- if (_isAttachedToParentConsole)
- return;
-
- _isAttachedToParentConsole = ::AttachConsole(ATTACH_PARENT_PROCESS) != FALSE;
- if (_isAttachedToParentConsole) {
- // Require that both STDOUT and STDERR are valid handles from the parent process.
- if (::GetStdHandle(STD_OUTPUT_HANDLE) != INVALID_HANDLE_VALUE &&
- ::GetStdHandle(STD_ERROR_HANDLE) != INVALID_HANDLE_VALUE) {
- // Re-open STDOUT and STDERR to the parent's.
- FILE *fp = NULL;
- freopen_s(&fp, "CONOUT$", "w", stdout);
- setvbuf(stdout, NULL, _IONBF, 0);
-
- freopen_s(&fp, "CONOUT$", "w", stderr);
- setvbuf(stderr, NULL, _IONBF, 0);
- } else {
- ::FreeConsole();
- _isAttachedToParentConsole = false;
- }
- }
-}
-
-void AGSWin32::DisplayAlert(const char *text, ...) {
- char displbuf[2500];
- va_list ap;
- va_start(ap, text);
- vsprintf(displbuf, text, ap);
- va_end(ap);
- if (_guiMode)
- MessageBox(win_get_window(), displbuf, "Adventure Game Studio", MB_OK | MB_ICONEXCLAMATION);
-
- // Always write to either stderr or stdout, even if message boxes are enabled.
- if (_logToStdErr)
- AGSWin32::WriteStdErr("%s", displbuf);
- else
- AGSWin32::WriteStdOut("%s", displbuf);
-}
-
-int AGSWin32::GetLastSystemError() {
- return ::GetLastError();
-}
-
-unsigned long AGSWin32::GetDiskFreeSpaceMB() {
- DWORD returnMb = 0;
- BOOL fResult;
- _G(our_eip) = -1891;
-
- // On Win9x, the last 3 params cannot be null, so need to supply values for all
- __int64 i64FreeBytesToCaller, i64Unused1, i64Unused2;
-
- // Win95 OSR2 or higher - use GetDiskFreeSpaceEx, since the
- // normal GetDiskFreeSpace returns erroneous values if the
- // free space is > 2 GB
- fResult = GetDiskFreeSpaceEx(NULL,
- (PULARGE_INTEGER)&i64FreeBytesToCaller,
- (PULARGE_INTEGER)&i64Unused1,
- (PULARGE_INTEGER)&i64Unused2);
-
- _G(our_eip) = -1893;
-
- // convert down to MB so we can fit it in a 32-bit long
- i64FreeBytesToCaller /= 1000000;
- returnMb = i64FreeBytesToCaller;
-
- return returnMb;
-}
-
-const char *AGSWin32::GetNoMouseErrorString() {
- return "No mouse was detected on your system, or your mouse is not configured to work with DirectInput. You must have a mouse to play this game.";
-}
-
-bool AGSWin32::IsMouseControlSupported(bool windowed) {
- return true; // supported for both fullscreen and windowed modes
-}
-
-const char *AGSWin32::GetAllegroFailUserHint() {
- return "Make sure you have DirectX 5 or above installed.";
-}
-
-eScriptSystemOSID AGSWin32::GetSystemOSID() {
- return eOS_Win;
-}
-
-int AGSWin32::InitializeCDPlayer() {
-#if defined (AGS_HAS_CD_AUDIO)
- return cd_player_init();
-#else
- return -1;
-#endif
-}
-
-void AGSWin32::AboutToQuitGame() {
-}
-
-void AGSWin32::PostAllegroExit() {
- // Release the timer setting
- timeEndPeriod(win32TimerPeriod);
-}
-
-SetupReturnValue AGSWin32::RunSetup(const ConfigTree &cfg_in, ConfigTree &cfg_out) {
- String version_str = String::FromFormat("Adventure Game Studio v%s setup", get_engine_version());
- return AGS::Engine::WinSetup(cfg_in, cfg_out, usetup.data_files_dir, version_str);
-}
-
-void AGSWin32::SetGameWindowIcon() {
- SetWinIcon();
-}
-
-void AGSWin32::WriteStdOut(const char *fmt, ...) {
- va_list ap;
- va_start(ap, fmt);
- if (_isDebuggerPresent) {
- // Add "AGS:" prefix when outputting to debugger, to make it clear that this
- // is a text from the program log
- char buf[STD_BUFFER_SIZE] = "AGS: ";
- vsnprintf(buf + 5, STD_BUFFER_SIZE - 5, fmt, ap);
- OutputDebugString(buf);
- OutputDebugString("\n");
- } else {
- vprintf(fmt, ap);
- printf("\n");
- }
- va_end(ap);
-}
-
-void AGSWin32::WriteStdErr(const char *fmt, ...) {
- va_list ap;
- va_start(ap, fmt);
- if (_isDebuggerPresent) {
- // Add "AGS:" prefix when outputting to debugger, to make it clear that this
- // is a text from the program log
- char buf[STD_BUFFER_SIZE] = "AGS ERR: ";
- vsnprintf(buf + 9, STD_BUFFER_SIZE - 9, fmt, ap);
- OutputDebugString(buf);
- OutputDebugString("\n");
- } else {
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- }
- va_end(ap);
-}
-
-void AGSWin32::ShutdownCDPlayer() {
- cd_exit();
-}
-
-extern "C" const unsigned char hw_to_mycode[256];
-
-int AGSWin32::ConvertKeycodeToScanCode(int keycode) {
- // ** HIDEOUS HACK TO WORK AROUND ALLEGRO BUG
- // the key[] array is hardcoded to qwerty keyboards, so we
- // have to re-map it to make it work on other keyboard layouts
- keycode += ('a' - 'A');
- int vkey = VkKeyScan(keycode);
- int scancode = MapVirtualKey(vkey, MAPVK_VK_TO_VSC);
- if ((scancode >= 0) && (scancode < 256))
- keycode = hw_to_mycode[scancode];
- return keycode;
-}
-
-void AGSWin32::ValidateWindowSize(int &x, int &y, bool borderless) const {
- RECT wa_rc, nc_rc;
- // This is the size of the available workspace on user's desktop
- SystemParametersInfo(SPI_GETWORKAREA, 0, &wa_rc, 0);
- // This is the maximal size that OS can reliably resize the window to (including any frame)
- const Size max_win(GetSystemMetrics(SM_CXMAXTRACK), GetSystemMetrics(SM_CYMAXTRACK));
- // This is the size of window's non-client area (frame, caption, etc)
- HWND allegro_wnd = win_get_window();
- LONG winstyle = borderless ? WS_POPUP : WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX;
- LONG winstyle_al = GetWindowLong(allegro_wnd, GWL_STYLE);
- SetRectEmpty(&nc_rc);
- AdjustWindowRect(&nc_rc, winstyle, FALSE);
- // Limit the window's full size to the system's window size limit,
- // and limit window's client size to the work space (visible area)
- x = Math::Min(x, (int)(max_win.Width - (nc_rc.right - nc_rc.left)));
- y = Math::Min(y, (int)(max_win.Height - (nc_rc.bottom - nc_rc.top)));
- x = Math::Clamp(x, 1, (int)(wa_rc.right - wa_rc.left));
- y = Math::Clamp(y, 1, (int)(wa_rc.bottom - wa_rc.top));
-}
-
-bool AGSWin32::LockMouseToWindow() {
- RECT rc;
- HWND allegro_wnd = win_get_window();
- GetClientRect(allegro_wnd, &rc);
- ClientToScreen(allegro_wnd, (POINT *)&rc);
- ClientToScreen(allegro_wnd, (POINT *)&rc.right);
- --rc.right;
- --rc.bottom;
- return ::ClipCursor(&rc) != 0;
-}
-
-void AGSWin32::UnlockMouse() {
- ::ClipCursor(NULL);
-}
-
-AGSPlatformDriver *AGSPlatformDriver::GetDriver() {
- if (instance == NULL)
- instance = new AGSWin32();
- return instance;
-}
-
-
-// *********** WINDOWS-SPECIFIC PLUGIN API FUNCTIONS *************
-
-HWND IAGSEngine::GetWindowHandle() {
- return win_get_window();
-}
-LPDIRECTDRAW2 IAGSEngine::GetDirectDraw2() {
- if (directdraw == NULL)
- quit("!This plugin requires DirectDraw based graphics driver (software driver).");
-
- return directdraw;
-}
-LPDIRECTDRAWSURFACE2 IAGSEngine::GetBitmapSurface(BITMAP *bmp) {
- if (directdraw == NULL)
- quit("!This plugin requires DirectDraw based graphics driver (software driver).");
-
- BMP_EXTRA_INFO *bei = (BMP_EXTRA_INFO *)bmp->extra;
-
- if (bmp == _G(gfxDriver)->GetMemoryBackBuffer()->GetAllegroBitmap())
- invalidate_screen();
-
- return bei->surf;
-}
-
-LPDIRECTSOUND IAGSEngine::GetDirectSound() {
- return directsound;
-}
-
-LPDIRECTINPUTDEVICE IAGSEngine::GetDirectInputKeyboard() {
- return key_dinput_device;
-}
-
-LPDIRECTINPUTDEVICE IAGSEngine::GetDirectInputMouse() {
- return mouse_dinput_device;
-}
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.cpp b/engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.cpp
deleted file mode 100644
index b97ecf460b..0000000000
--- a/engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.cpp
+++ /dev/null
@@ -1,100 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_WINDOWS
-
-#include "ags/shared/platform/windows/debug/namedpipesagsdebugger.h"
-
-//include <stdio.h> // sprintf
-
-namespace AGS3 {
-
-void NamedPipesAGSDebugger::SendAcknowledgement() {
- DWORD bytesWritten;
- WriteFile(_hPipeSending, "MSGACK", 6, &bytesWritten, NULL);
-}
-
-
-NamedPipesAGSDebugger::NamedPipesAGSDebugger(const char *instanceToken) {
- _hPipeSending = NULL;
- _hPipeReading = NULL;
- _instanceToken = instanceToken;
-}
-
-bool NamedPipesAGSDebugger::Initialize() {
- // can't use a single duplex pipe as it was deadlocking
- char pipeNameBuffer[MAX_PATH];
- sprintf(pipeNameBuffer, "\\\\.\\pipe\\AGSEditorDebuggerGameToEd%s", _instanceToken);
- _hPipeSending = CreateFile(pipeNameBuffer, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
-
- sprintf(pipeNameBuffer, "\\\\.\\pipe\\AGSEditorDebuggerEdToGame%s", _instanceToken);
- _hPipeReading = CreateFile(pipeNameBuffer, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
-
- if ((_hPipeReading == INVALID_HANDLE_VALUE) ||
- (_hPipeSending == INVALID_HANDLE_VALUE))
- return false;
-
- return true;
-}
-
-void NamedPipesAGSDebugger::Shutdown() {
- if (_hPipeReading != NULL) {
- CloseHandle(_hPipeReading);
- CloseHandle(_hPipeSending);
- _hPipeReading = NULL;
- }
-}
-
-bool NamedPipesAGSDebugger::SendMessageToEditor(const char *message) {
- DWORD bytesWritten;
- return (WriteFile(_hPipeSending, message, strlen(message), &bytesWritten, NULL) != 0);
-}
-
-bool NamedPipesAGSDebugger::IsMessageAvailable() {
- DWORD bytesAvailable = 0;
- PeekNamedPipe(_hPipeReading, NULL, 0, NULL, &bytesAvailable, NULL);
-
- return (bytesAvailable > 0);
-}
-
-char *NamedPipesAGSDebugger::GetNextMessage() {
- DWORD bytesAvailable = 0;
- PeekNamedPipe(_hPipeReading, NULL, 0, NULL, &bytesAvailable, NULL);
-
- if (bytesAvailable > 0) {
- char *buffer = (char *)malloc(bytesAvailable + 1);
- DWORD bytesRead = 0;
- ReadFile(_hPipeReading, buffer, bytesAvailable, &bytesRead, NULL);
- buffer[bytesRead] = 0;
-
- SendAcknowledgement();
- return buffer;
- } else {
- return NULL;
- }
-}
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.h b/engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.h
deleted file mode 100644
index 879f95faa2..0000000000
--- a/engines/ags/engine/platform/windows/debugging/namedpipesagsdebugger.h
+++ /dev/null
@@ -1,51 +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.
- *
- */
-
-#ifndef AGS_ENGINE_DEBUGGING_NAMEDPIPESAGSDEBUGGER_H
-#define AGS_ENGINE_DEBUGGING_NAMEDPIPESAGSDEBUGGER_H
-
-//include <windows.h>
-//include <io.h>
-#include "ags/shared/debugging/agseditordebugger.h"
-
-namespace AGS3 {
-
-struct NamedPipesAGSDebugger : IAGSEditorDebugger {
-private:
- HANDLE _hPipeSending;
- HANDLE _hPipeReading;
- const char *_instanceToken;
-
- void SendAcknowledgement();
-public:
-
- NamedPipesAGSDebugger(const char *instanceToken);
- virtual bool Initialize() override;
- virtual void Shutdown() override;
- virtual bool SendMessageToEditor(const char *message) override;
- virtual bool IsMessageAvailable() override;
- virtual char *GetNextMessage() override;
-};
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp b/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
deleted file mode 100644
index 0ce78f8663..0000000000
--- a/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
+++ /dev/null
@@ -1,1849 +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.
- *
- */
-
-//=============================================================================
-//
-// Allegro Interface for 3D; Direct 3D 9 driver
-//
-//=============================================================================
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_WINDOWS
-
-#include "ags/shared/platform/windows/gfx/ali3dd3d.h"
-
-#include "ags/lib/allegro.h"
-//include <allegro/platform/aintwin.h>
-#include "ags/shared/ac/timer.h"
-#include "ags/shared/debugging/assert.h"
-#include "ags/shared/debugging/out.h"
-#include "ags/shared/gfx/ali3dexception.h"
-#include "ags/shared/gfx/gfxfilter_d3d.h"
-#include "ags/shared/gfx/gfxfilter_aad3d.h"
-#include "ags/shared/gfx/gfx_util.h"
-#include "ags/shared/main/main_allegro.h"
-#include "ags/shared/platform/base/agsplatformdriver.h"
-#include "ags/shared/util/library.h"
-
-namespace AGS3 {
-
-using namespace AGS::Shared;
-
-//
-// Following functions implement various matrix operations. Normally they are found in the auxiliary d3d9x.dll,
-// but we do not want AGS to be dependent on it.
-//
-// Setup identity matrix
-void MatrixIdentity(D3DMATRIX &m) {
- m = {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
- };
-}
-// Setup translation matrix
-void MatrixTranslate(D3DMATRIX &m, float x, float y, float z) {
- MatrixIdentity(m);
- m.m[3][0] = x;
- m.m[3][1] = y;
- m.m[3][2] = z;
-}
-// Setup scaling matrix
-void MatrixScale(D3DMATRIX &m, float sx, float sy, float sz) {
- MatrixIdentity(m);
- m.m[0][0] = sx;
- m.m[1][1] = sy;
- m.m[2][2] = sz;
-}
-// Setup rotation around Z axis; angle is in radians
-void MatrixRotateZ(D3DMATRIX &m, float angle) {
- MatrixIdentity(m);
- m.m[0][0] = cos(angle);
- m.m[1][1] = cos(angle);
- m.m[0][1] = sin(angle);
- m.m[1][0] = -sin(angle);
-}
-// Matrix multiplication
-void MatrixMultiply(D3DMATRIX &mr, const D3DMATRIX &m1, const D3DMATRIX &m2) {
- for (int i = 0; i < 4; ++i)
- for (int j = 0; j < 4; ++j)
- mr.m[i][j] = m1.m[i][0] * m2.m[0][j] + m1.m[i][1] * m2.m[1][j] + m1.m[i][2] * m2.m[2][j] + m1.m[i][3] * m2.m[3][j];
-}
-// Setup full 2D transformation matrix
-void MatrixTransform2D(D3DMATRIX &m, float x, float y, float sx, float sy, float anglez) {
- D3DMATRIX translate;
- D3DMATRIX rotate;
- D3DMATRIX scale;
- MatrixTranslate(translate, x, y, 0.f);
- MatrixRotateZ(rotate, anglez);
- MatrixScale(scale, sx, sy, 1.f);
-
- D3DMATRIX tr1;
- MatrixMultiply(tr1, scale, rotate);
- MatrixMultiply(m, tr1, translate);
-}
-// Setup inverse 2D transformation matrix
-void MatrixTransformInverse2D(D3DMATRIX &m, float x, float y, float sx, float sy, float anglez) {
- D3DMATRIX translate;
- D3DMATRIX rotate;
- D3DMATRIX scale;
- MatrixTranslate(translate, x, y, 0.f);
- MatrixRotateZ(rotate, anglez);
- MatrixScale(scale, sx, sy, 1.f);
-
- D3DMATRIX tr1;
- MatrixMultiply(tr1, translate, rotate);
- MatrixMultiply(m, tr1, scale);
-}
-
-
-namespace AGS {
-namespace Engine {
-namespace D3D {
-
-using namespace Shared;
-
-void D3DBitmap::Dispose() {
- if (_tiles != NULL) {
- for (int i = 0; i < _numTiles; i++)
- _tiles[i].texture->Release();
-
- free(_tiles);
- _tiles = NULL;
- _numTiles = 0;
- }
- if (_vertex != NULL) {
- _vertex->Release();
- _vertex = NULL;
- }
-}
-
-static D3DFORMAT color_depth_to_d3d_format(int color_depth, bool wantAlpha);
-static int d3d_format_to_color_depth(D3DFORMAT format, bool secondary);
-
-bool D3DGfxModeList::GetMode(int index, DisplayMode &mode) const {
- if (_direct3d && index >= 0 && index < _modeCount) {
- D3DDISPLAYMODE d3d_mode;
- if (SUCCEEDED(_direct3d->EnumAdapterModes(D3DADAPTER_DEFAULT, _pixelFormat, index, &d3d_mode))) {
- mode.Width = d3d_mode.Width;
- mode.Height = d3d_mode.Height;
- mode.ColorDepth = d3d_format_to_color_depth(d3d_mode.Format, false);
- mode.RefreshRate = d3d_mode.RefreshRate;
- return true;
- }
- }
- return false;
-}
-
-
-void dummy_vsync() { }
-
-#define GFX_DIRECT3D_WIN AL_ID('D','X','3','W')
-#define GFX_DIRECT3D_FULL AL_ID('D','X','3','D')
-
-GFX_DRIVER gfx_direct3d_win = {
- GFX_DIRECT3D_WIN,
- empty_string,
- empty_string,
- "Direct3D windowed",
- NULL, // init
- NULL, // exit
- NULL, // AL_METHOD(int, scroll, (int x, int y));
- dummy_vsync, // vsync
- NULL, // setpalette
- NULL, // AL_METHOD(int, request_scroll, (int x, int y));
- NULL, // AL_METHOD(int, poll_scroll, (void));
- NULL, // AL_METHOD(void, enable_triple_buffer, (void));
- NULL, //create_video_bitmap
- NULL, //destroy_video_bitmap
- NULL, //show_video_bitmap
- NULL,
- NULL, //gfx_directx_create_system_bitmap,
- NULL, //gfx_directx_destroy_system_bitmap,
- NULL, //gfx_directx_set_mouse_sprite,
- NULL, //gfx_directx_show_mouse,
- NULL, //gfx_directx_hide_mouse,
- NULL, //gfx_directx_move_mouse,
- NULL, // AL_METHOD(void, drawing_mode, (void));
- NULL, // AL_METHOD(void, save_video_state, (void*));
- NULL, // AL_METHOD(void, restore_video_state, (void*));
- NULL, // AL_METHOD(void, set_blender_mode, (int mode, int r, int g, int b, int a));
- NULL, // AL_METHOD(int, fetch_mode_list, (void));
- 0, 0, // int w, h;
- FALSE, // int linear;
- 0, // long bank_size;
- 0, // long bank_gran;
- 0, // long vid_mem;
- 0, // long vid_phys_base;
- TRUE // int windowed;
-};
-
-GFX_DRIVER gfx_direct3d_full = {
- GFX_DIRECT3D_FULL,
- empty_string,
- empty_string,
- "Direct3D fullscreen",
- NULL, // init
- NULL, // exit
- NULL, // AL_METHOD(int, scroll, (int x, int y));
- dummy_vsync, // sync
- NULL, // setpalette
- NULL, // AL_METHOD(int, request_scroll, (int x, int y));
- NULL, // AL_METHOD(int, poll_scroll, (void));
- NULL, // AL_METHOD(void, enable_triple_buffer, (void));
- NULL, //create_video_bitmap
- NULL, //destroy_video_bitmap
- NULL, //show_video_bitmap
- NULL,
- NULL, //gfx_directx_create_system_bitmap,
- NULL, //gfx_directx_destroy_system_bitmap,
- NULL, //gfx_directx_set_mouse_sprite,
- NULL, //gfx_directx_show_mouse,
- NULL, //gfx_directx_hide_mouse,
- NULL, //gfx_directx_move_mouse,
- NULL, // AL_METHOD(void, drawing_mode, (void));
- NULL, // AL_METHOD(void, save_video_state, (void*));
- NULL, // AL_METHOD(void, restore_video_state, (void*));
- NULL, // AL_METHOD(void, set_blender_mode, (int mode, int r, int g, int b, int a));
- NULL, // AL_METHOD(int, fetch_mode_list, (void));
- 0, 0, // int w, h;
- FALSE, // int linear;
- 0, // long bank_size;
- 0, // long bank_gran;
- 0, // long vid_mem;
- 0, // long vid_phys_base;
- FALSE // int windowed;
-};
-
-// The custom FVF, which describes the custom vertex structure.
-#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
-
-static int wnd_create_device();
-// TODO: is there better way to not have this mode as a global static variable?
-// wnd_create_device() is being called using wnd_call_proc, which does not take
-// user parameters.
-static DisplayMode d3d_mode_to_init;
-
-D3DGraphicsDriver::D3DGraphicsDriver(IDirect3D9 *d3d) {
- direct3d = d3d;
- direct3ddevice = NULL;
- vertexbuffer = NULL;
- pixelShader = NULL;
- _legacyPixelShader = false;
- set_up_default_vertices();
- pNativeSurface = NULL;
- pNativeTexture = NULL;
- availableVideoMemory = 0;
- _smoothScaling = false;
- _pixelRenderXOffset = 0;
- _pixelRenderYOffset = 0;
- _renderSprAtScreenRes = false;
-
- // Shifts comply to D3DFMT_A8R8G8B8
- _vmem_a_shift_32 = 24;
- _vmem_r_shift_32 = 16;
- _vmem_g_shift_32 = 8;
- _vmem_b_shift_32 = 0;
-
- // Initialize default sprite batch, it will be used when no other batch was activated
- D3DGraphicsDriver::InitSpriteBatch(0, _spriteBatchDesc[0]);
-}
-
-void D3DGraphicsDriver::set_up_default_vertices() {
- defaultVertices[0].position.x = 0.0f;
- defaultVertices[0].position.y = 0.0f;
- defaultVertices[0].position.z = 0.0f;
- defaultVertices[0].normal.x = 0.0f;
- defaultVertices[0].normal.y = 0.0f;
- defaultVertices[0].normal.z = -1.0f;
- //defaultVertices[0].color=0xffffffff;
- defaultVertices[0].tu = 0.0;
- defaultVertices[0].tv = 0.0;
- defaultVertices[1].position.x = 1.0f;
- defaultVertices[1].position.y = 0.0f;
- defaultVertices[1].position.z = 0.0f;
- defaultVertices[1].normal.x = 0.0f;
- defaultVertices[1].normal.y = 0.0f;
- defaultVertices[1].normal.z = -1.0f;
- //defaultVertices[1].color=0xffffffff;
- defaultVertices[1].tu = 1.0;
- defaultVertices[1].tv = 0.0;
- defaultVertices[2].position.x = 0.0f;
- defaultVertices[2].position.y = -1.0f;
- defaultVertices[2].position.z = 0.0f;
- defaultVertices[2].normal.x = 0.0f;
- defaultVertices[2].normal.y = 0.0f;
- defaultVertices[2].normal.z = -1.0f;
- //defaultVertices[2].color=0xffffffff;
- defaultVertices[2].tu = 0.0;
- defaultVertices[2].tv = 1.0;
- defaultVertices[3].position.x = 1.0f;
- defaultVertices[3].position.y = -1.0f;
- defaultVertices[3].position.z = 0.0f;
- defaultVertices[3].normal.x = 0.0f;
- defaultVertices[3].normal.y = 0.0f;
- defaultVertices[3].normal.z = -1.0f;
- //defaultVertices[3].color=0xffffffff;
- defaultVertices[3].tu = 1.0;
- defaultVertices[3].tv = 1.0;
-}
-
-void D3DGraphicsDriver::Vsync() {
- // do nothing on D3D
-}
-
-void D3DGraphicsDriver::OnModeSet(const DisplayMode &mode) {
- GraphicsDriverBase::OnModeSet(mode);
-
- // The display mode has been set up successfully, save the
- // final refresh rate that we are using
- D3DDISPLAYMODE final_display_mode;
- if (direct3ddevice->GetDisplayMode(0, &final_display_mode) == D3D_OK) {
- _mode.RefreshRate = final_display_mode.RefreshRate;
- } else {
- _mode.RefreshRate = 0;
- }
-}
-
-void D3DGraphicsDriver::ReleaseDisplayMode() {
- if (!IsModeSet())
- return;
-
- OnModeReleased();
- ClearDrawLists();
- ClearDrawBackups();
- DestroyFxPool();
- DestroyAllStageScreens();
-
- gfx_driver = NULL;
-}
-
-int D3DGraphicsDriver::FirstTimeInit() {
- HRESULT hr;
-
- direct3ddevice->GetDeviceCaps(&direct3ddevicecaps);
-
- // the PixelShader.fx uses ps_1_4
- // the PixelShaderLegacy.fx needs ps_2_0
- int requiredPSMajorVersion = 1;
- int requiredPSMinorVersion = 4;
- if (_legacyPixelShader) {
- requiredPSMajorVersion = 2;
- requiredPSMinorVersion = 0;
- }
-
- if (direct3ddevicecaps.PixelShaderVersion < D3DPS_VERSION(requiredPSMajorVersion, requiredPSMinorVersion)) {
- direct3ddevice->Release();
- direct3ddevice = NULL;
- previousError =
- set_allegro_error("Graphics card does not support Pixel Shader %d.%d", requiredPSMajorVersion, requiredPSMinorVersion);
- return -1;
- }
-
- // Load the pixel shader!!
- HMODULE exeHandle = GetModuleHandle(NULL);
- HRSRC hRes = FindResource(exeHandle, (_legacyPixelShader) ? "PIXEL_SHADER_LEGACY" : "PIXEL_SHADER", "DATA");
- if (hRes) {
- HGLOBAL hGlobal = LoadResource(exeHandle, hRes);
- if (hGlobal) {
- DWORD resourceSize = SizeofResource(exeHandle, hRes);
- DWORD *dataPtr = (DWORD *)LockResource(hGlobal);
- hr = direct3ddevice->CreatePixelShader(dataPtr, &pixelShader);
- if (hr != D3D_OK) {
- direct3ddevice->Release();
- direct3ddevice = NULL;
- previousError = set_allegro_error("Failed to create pixel shader: 0x%08X", hr);
- return -1;
- }
- UnlockResource(hGlobal);
- }
- }
-
- if (pixelShader == NULL) {
- direct3ddevice->Release();
- direct3ddevice = NULL;
- previousError = set_allegro_error("Failed to load pixel shader resource");
- return -1;
- }
-
- if (direct3ddevice->CreateVertexBuffer(4 * sizeof(CUSTOMVERTEX), D3DUSAGE_WRITEONLY,
- D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &vertexbuffer, NULL) != D3D_OK) {
- direct3ddevice->Release();
- direct3ddevice = NULL;
- previousError = set_allegro_error("Failed to create vertex buffer");
- return -1;
- }
-
- // This line crashes because my card doesn't support 8-bit textures
- //direct3ddevice->SetCurrentTexturePalette(0);
-
- CUSTOMVERTEX *vertices;
- vertexbuffer->Lock(0, 0, (void **)&vertices, D3DLOCK_DISCARD);
-
- for (int i = 0; i < 4; i++) {
- vertices[i] = defaultVertices[i];
- }
-
- vertexbuffer->Unlock();
-
- direct3ddevice->GetGammaRamp(0, &defaultgammaramp);
-
- if (defaultgammaramp.red[255] < 256) {
- // correct bug in some gfx drivers that returns gamma ramp
- // values from 0-255 instead of 0-65535
- for (int i = 0; i < 256; i++) {
- defaultgammaramp.red[i] *= 256;
- defaultgammaramp.green[i] *= 256;
- defaultgammaramp.blue[i] *= 256;
- }
- }
- currentgammaramp = defaultgammaramp;
-
- return 0;
-}
-
-void D3DGraphicsDriver::initD3DDLL(const DisplayMode &mode) {
- if (!IsModeSupported(mode)) {
- error(get_allegro_error());
- }
-
- _enter_critical();
-
- d3d_mode_to_init = mode;
- // Set the display mode in the window's thread
- if (wnd_call_proc(wnd_create_device)) {
- _exit_critical();
- error(get_allegro_error());
- }
-
- availableVideoMemory = direct3ddevice->GetAvailableTextureMem();
-
- _exit_critical();
-
- // Set up a fake allegro gfx driver so that things like
- // the allegro mouse handler still work
- if (mode.Windowed)
- gfx_driver = &gfx_direct3d_win;
- else
- gfx_driver = &gfx_direct3d_full;
-
- return;
-}
-
-/* color_depth_to_d3d_format:
- * Convert a colour depth into the appropriate D3D tag
- */
-static D3DFORMAT color_depth_to_d3d_format(int color_depth, bool wantAlpha) {
- if (wantAlpha) {
- switch (color_depth) {
- case 8:
- return D3DFMT_P8;
- case 15:
- case 16:
- return D3DFMT_A1R5G5B5;
- case 24:
- case 32:
- return D3DFMT_A8R8G8B8;
- }
- } else {
- switch (color_depth) {
- case 8:
- return D3DFMT_P8;
- case 15: // don't use X1R5G5B5 because some cards don't support it
- return D3DFMT_A1R5G5B5;
- case 16:
- return D3DFMT_R5G6B5;
- case 24:
- return D3DFMT_R8G8B8;
- case 32:
- return D3DFMT_X8R8G8B8;
- }
- }
- return D3DFMT_UNKNOWN;
-}
-
-/* d3d_format_to_color_depth:
- * Convert a D3D tag to colour depth
- *
- * TODO: this is currently an inversion of color_depth_to_d3d_format;
- * check later if more formats should be handled
- */
-static int d3d_format_to_color_depth(D3DFORMAT format, bool secondary) {
- switch (format) {
- case D3DFMT_P8:
- return 8;
- case D3DFMT_A1R5G5B5:
- return secondary ? 15 : 16;
- case D3DFMT_X1R5G5B5:
- return secondary ? 15 : 16;
- case D3DFMT_R5G6B5:
- return 16;
- case D3DFMT_R8G8B8:
- return secondary ? 24 : 32;
- case D3DFMT_A8R8G8B8:
- case D3DFMT_X8R8G8B8:
- return 32;
- }
- return 0;
-}
-
-bool D3DGraphicsDriver::IsModeSupported(const DisplayMode &mode) {
- if (mode.Width <= 0 || mode.Height <= 0 || mode.ColorDepth <= 0) {
- set_allegro_error("Invalid resolution parameters: %d x %d x %d", mode.Width, mode.Height, mode.ColorDepth);
- return false;
- }
-
- if (mode.Windowed) {
- return true;
- }
-
- D3DFORMAT pixelFormat = color_depth_to_d3d_format(mode.ColorDepth, false);
- D3DDISPLAYMODE d3d_mode;
-
- int mode_count = direct3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, pixelFormat);
- for (int i = 0; i < mode_count; i++) {
- if (FAILED(direct3d->EnumAdapterModes(D3DADAPTER_DEFAULT, pixelFormat, i, &d3d_mode))) {
- set_allegro_error("IDirect3D9::EnumAdapterModes failed");
- return false;
- }
-
- if ((d3d_mode.Width == mode.Width) && (d3d_mode.Height == mode.Height)) {
- return true;
- }
- }
-
- set_allegro_error("The requested adapter mode is not supported");
- return false;
-}
-
-bool D3DGraphicsDriver::SupportsGammaControl() {
- if ((direct3ddevicecaps.Caps2 & D3DCAPS2_FULLSCREENGAMMA) == 0)
- return false;
-
- if (_mode.Windowed)
- return false;
-
- return true;
-}
-
-void D3DGraphicsDriver::SetGamma(int newGamma) {
- for (int i = 0; i < 256; i++) {
- int newValue = ((int)defaultgammaramp.red[i] * newGamma) / 100;
- if (newValue >= 65535)
- newValue = 65535;
- currentgammaramp.red[i] = newValue;
- currentgammaramp.green[i] = newValue;
- currentgammaramp.blue[i] = newValue;
- }
-
- direct3ddevice->SetGammaRamp(0, D3DSGR_NO_CALIBRATION, ¤tgammaramp);
-}
-
-/* wnd_set_video_mode:
- * Called by window thread to set a gfx mode; this is needed because DirectDraw can only
- * change the mode in the thread that handles the window.
- */
-static int wnd_create_device() {
- return D3DGraphicsFactory::GetD3DDriver()->_initDLLCallback(d3d_mode_to_init);
-}
-
-static int wnd_reset_device() {
- return D3DGraphicsFactory::GetD3DDriver()->_resetDeviceIfNecessary();
-}
-
-int D3DGraphicsDriver::_resetDeviceIfNecessary() {
- HRESULT hr = direct3ddevice->TestCooperativeLevel();
-
- if (hr == D3DERR_DEVICELOST) {
- Debug::Printf("D3DGraphicsDriver: D3D Device Lost");
- // user has alt+tabbed away from the game
- return 1;
- }
-
- if (hr == D3DERR_DEVICENOTRESET) {
- Debug::Printf("D3DGraphicsDriver: D3D Device Not Reset");
- hr = ResetD3DDevice();
- if (hr != D3D_OK) {
- Debug::Printf("D3DGraphicsDriver: Failed to reset D3D device");
- // can't throw exception because we're in the wrong thread,
- // so just return a value instead
- return 2;
- }
-
- InitializeD3DState();
- CreateVirtualScreen();
- direct3ddevice->SetGammaRamp(0, D3DSGR_NO_CALIBRATION, ¤tgammaramp);
- }
-
- return 0;
-}
-
-int D3DGraphicsDriver::_initDLLCallback(const DisplayMode &mode) {
- HWND allegro_wnd = win_get_window();
-
- if (mode.Windowed)
- platform->AdjustWindowStyleForWindowed();
- else
- platform->AdjustWindowStyleForFullscreen();
-
- memset(&d3dpp, 0, sizeof(d3dpp));
- d3dpp.BackBufferWidth = mode.Width;
- d3dpp.BackBufferHeight = mode.Height;
- d3dpp.BackBufferFormat = color_depth_to_d3d_format(mode.ColorDepth, false);
- d3dpp.BackBufferCount = 1;
- d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
- // THIS MUST BE SWAPEFFECT_COPY FOR PlayVideo TO WORK
- d3dpp.SwapEffect = D3DSWAPEFFECT_COPY; //D3DSWAPEFFECT_DISCARD;
- d3dpp.hDeviceWindow = allegro_wnd;
- d3dpp.Windowed = mode.Windowed;
- d3dpp.EnableAutoDepthStencil = FALSE;
- d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; // we need this flag to access the backbuffer with lockrect
- d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
- if (mode.Vsync)
- d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- else
- d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
-
- /* If full screen, specify the refresh rate */
- // TODO find a way to avoid the wrong refreshrate to be set on mode.RefreshRate
- // for now it's best to let it set automatically, so we prevent alt tab delays due to mismatching refreshrates
- //if ((d3dpp.Windowed == FALSE) && (mode.RefreshRate > 0))
- // d3dpp.FullScreen_RefreshRateInHz = mode.RefreshRate;
-
- if (_initGfxCallback != NULL)
- _initGfxCallback(&d3dpp);
-
- bool first_time_init = direct3ddevice == NULL;
- HRESULT hr = 0;
- if (direct3ddevice) {
- hr = ResetD3DDevice();
- } else
- hr = direct3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, allegro_wnd,
- D3DCREATE_MIXED_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, // multithreaded required for AVI player
- &d3dpp, &direct3ddevice);
- if (hr != D3D_OK) {
- if (!previousError.IsEmpty())
- set_allegro_error(previousError);
- else
- set_allegro_error("Failed to create Direct3D Device: 0x%08X", hr);
- return -1;
- }
-
- if (mode.Windowed) {
- if (adjust_window(mode.Width, mode.Height) != 0) {
- direct3ddevice->Release();
- direct3ddevice = NULL;
- set_allegro_error("Window size not supported");
- return -1;
- }
- }
-
- win_grab_input();
-
- if (first_time_init) {
- int ft_res = FirstTimeInit();
- if (ft_res != 0)
- return ft_res;
- }
- return 0;
-}
-
-void D3DGraphicsDriver::InitializeD3DState() {
- direct3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 0.5f, 0);
-
- // set the render flags.
- direct3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
-
- direct3ddevice->SetRenderState(D3DRS_LIGHTING, true);
- direct3ddevice->SetRenderState(D3DRS_ZENABLE, FALSE);
-
- direct3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- direct3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- direct3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
-
- direct3ddevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
- direct3ddevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
- direct3ddevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)0);
-
- direct3ddevice->SetFVF(D3DFVF_CUSTOMVERTEX);
-
- D3DMATERIAL9 material;
- ZeroMemory(&material, sizeof(material)); //zero memory ( NEW )
- material.Diffuse.r = 1.0f; //diffuse color ( NEW )
- material.Diffuse.g = 1.0f;
- material.Diffuse.b = 1.0f;
- direct3ddevice->SetMaterial(&material);
-
- D3DLIGHT9 d3dLight;
- ZeroMemory(&d3dLight, sizeof(D3DLIGHT9));
-
- // Set up a white point light.
- d3dLight.Type = D3DLIGHT_DIRECTIONAL;
- d3dLight.Diffuse.r = 1.0f;
- d3dLight.Diffuse.g = 1.0f;
- d3dLight.Diffuse.b = 1.0f;
- d3dLight.Diffuse.a = 1.0f;
- d3dLight.Ambient.r = 1.0f;
- d3dLight.Ambient.g = 1.0f;
- d3dLight.Ambient.b = 1.0f;
- d3dLight.Specular.r = 1.0f;
- d3dLight.Specular.g = 1.0f;
- d3dLight.Specular.b = 1.0f;
-
- // Position it high in the scene and behind the user.
- // Remember, these coordinates are in world space, so
- // the user could be anywhere in world space, too.
- // For the purposes of this example, assume the user
- // is at the origin of world space.
- d3dLight.Direction.x = 0.0f;
- d3dLight.Direction.y = 0.0f;
- d3dLight.Direction.z = 1.0f;
-
- // Don't attenuate.
- d3dLight.Attenuation0 = 1.0f;
- d3dLight.Range = 1000.0f;
-
- // Set the property information for the first light.
- direct3ddevice->SetLight(0, &d3dLight);
- direct3ddevice->LightEnable(0, TRUE);
-
- // If we already have a render frame configured, then setup viewport immediately
- SetupViewport();
-}
-
-void D3DGraphicsDriver::SetupViewport() {
- if (!IsModeSet() || !IsRenderFrameValid() || !IsNativeSizeValid())
- return;
-
- const float src_width = _srcRect.GetWidth();
- const float src_height = _srcRect.GetHeight();
- const float disp_width = _mode.Width;
- const float disp_height = _mode.Height;
-
- // Setup orthographic projection matrix
- D3DMATRIX matOrtho = {
- (2.0f / src_width), 0.0, 0.0, 0.0,
- 0.0, (2.0f / src_height), 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
- };
-
- D3DMATRIX matIdentity = {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
- };
-
- direct3ddevice->SetTransform(D3DTS_PROJECTION, &matOrtho);
- direct3ddevice->SetTransform(D3DTS_WORLD, &matIdentity);
- direct3ddevice->SetTransform(D3DTS_VIEW, &matIdentity);
-
- // See "Directly Mapping Texels to Pixels" MSDN article for why this is necessary
- // http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690.aspx
- _pixelRenderXOffset = (src_width / disp_width) / 2.0f;
- _pixelRenderYOffset = (src_height / disp_height) / 2.0f;
-
- // Clear the screen before setting a viewport.
- ClearScreenRect(RectWH(0, 0, _mode.Width, _mode.Height), nullptr);
-
- // Set Viewport.
- ZeroMemory(&_d3dViewport, sizeof(D3DVIEWPORT9));
- _d3dViewport.X = _dstRect.Left;
- _d3dViewport.Y = _dstRect.Top;
- _d3dViewport.Width = _dstRect.GetWidth();
- _d3dViewport.Height = _dstRect.GetHeight();
- _d3dViewport.MinZ = 0.0f;
- _d3dViewport.MaxZ = 1.0f;
- direct3ddevice->SetViewport(&_d3dViewport);
-
- viewport_rect.left = _dstRect.Left;
- viewport_rect.right = _dstRect.Right + 1;
- viewport_rect.top = _dstRect.Top;
- viewport_rect.bottom = _dstRect.Bottom + 1;
-}
-
-void D3DGraphicsDriver::SetGraphicsFilter(PD3DFilter filter) {
- _filter = filter;
- OnSetFilter();
-}
-
-void D3DGraphicsDriver::SetTintMethod(TintMethod method) {
- _legacyPixelShader = (method == TintReColourise);
-}
-
-bool D3DGraphicsDriver::SetDisplayMode(const DisplayMode &mode, volatile int *loopTimer) {
- ReleaseDisplayMode();
-
- if (mode.ColorDepth < 15) {
- set_allegro_error("Direct3D driver does not support 256-color display mode");
- return false;
- }
-
- try {
- initD3DDLL(mode);
- } catch (Ali3DException exception) {
- if (exception._message != get_allegro_error())
- set_allegro_error(exception._message);
- return false;
- }
- OnInit(loopTimer);
- OnModeSet(mode);
- InitializeD3DState();
- CreateVirtualScreen();
- return true;
-}
-
-void D3DGraphicsDriver::CreateVirtualScreen() {
- if (!IsModeSet() || !IsNativeSizeValid())
- return;
-
- // set up native surface
- if (pNativeSurface != NULL) {
- pNativeSurface->Release();
- pNativeSurface = NULL;
- }
- if (pNativeTexture != NULL) {
- pNativeTexture->Release();
- pNativeTexture = NULL;
- }
- if (direct3ddevice->CreateTexture(
- _srcRect.GetWidth(),
- _srcRect.GetHeight(),
- 1,
- D3DUSAGE_RENDERTARGET,
- color_depth_to_d3d_format(_mode.ColorDepth, false),
- D3DPOOL_DEFAULT,
- &pNativeTexture,
- NULL) != D3D_OK) {
- error("CreateTexture failed");
- }
- if (pNativeTexture->GetSurfaceLevel(0, &pNativeSurface) != D3D_OK) {
- error("GetSurfaceLevel failed");
- }
-
- direct3ddevice->ColorFill(pNativeSurface, NULL, 0);
-
- // create initial stage screen for plugin raw drawing
- _stageVirtualScreen = CreateStageScreen(0, _srcRect.GetSize());
- // we must set Allegro's screen pointer to **something**
- screen = (BITMAP *)_stageVirtualScreen->GetAllegroBitmap();
-}
-
-HRESULT D3DGraphicsDriver::ResetD3DDevice() {
- // Direct3D documentation:
- // Before calling the IDirect3DDevice9::Reset method for a device,
- // an application should release any explicit render targets, depth stencil
- // surfaces, additional swap chains, state blocks, and D3DPOOL_DEFAULT
- // resources associated with the device.
- if (pNativeSurface != NULL) {
- pNativeSurface->Release();
- pNativeSurface = NULL;
- }
- if (pNativeTexture != NULL) {
- pNativeTexture->Release();
- pNativeTexture = NULL;
- }
- return direct3ddevice->Reset(&d3dpp);
-}
-
-bool D3DGraphicsDriver::SetNativeSize(const Size &src_size) {
- OnSetNativeSize(src_size);
- // Also make sure viewport is updated using new native & destination rectangles
- SetupViewport();
- CreateVirtualScreen();
- return !_srcRect.IsEmpty();
-}
-
-bool D3DGraphicsDriver::SetRenderFrame(const Rect &dst_rect) {
- OnSetRenderFrame(dst_rect);
- // Also make sure viewport is updated using new native & destination rectangles
- SetupViewport();
- return !_dstRect.IsEmpty();
-}
-
-int D3DGraphicsDriver::GetDisplayDepthForNativeDepth(int native_color_depth) const {
- // TODO: check for device caps to know which depth is supported?
- return 32;
-}
-
-IGfxModeList *D3DGraphicsDriver::GetSupportedModeList(int color_depth) {
- direct3d->AddRef();
- return new D3DGfxModeList(direct3d, color_depth_to_d3d_format(color_depth, false));
-}
-
-PGfxFilter D3DGraphicsDriver::GetGraphicsFilter() const {
- return _filter;
-}
-
-void D3DGraphicsDriver::UnInit() {
- OnUnInit();
- ReleaseDisplayMode();
-
- if (pNativeSurface) {
- pNativeSurface->Release();
- pNativeSurface = NULL;
- }
- if (pNativeTexture) {
- pNativeTexture->Release();
- pNativeTexture = NULL;
- }
-
- if (vertexbuffer) {
- vertexbuffer->Release();
- vertexbuffer = NULL;
- }
-
- if (pixelShader) {
- pixelShader->Release();
- pixelShader = NULL;
- }
-
- if (direct3ddevice) {
- direct3ddevice->Release();
- direct3ddevice = NULL;
- }
-}
-
-D3DGraphicsDriver::~D3DGraphicsDriver() {
- D3DGraphicsDriver::UnInit();
-
- if (direct3d)
- direct3d->Release();
-}
-
-void D3DGraphicsDriver::ClearRectangle(int x1, int y1, int x2, int y2, RGB *colorToUse) {
- // NOTE: this function is practically useless at the moment, because D3D redraws whole game frame each time
- if (!direct3ddevice) return;
- Rect r(x1, y1, x2, y2);
- r = _scaling.ScaleRange(r);
- ClearScreenRect(r, colorToUse);
-}
-
-void D3DGraphicsDriver::ClearScreenRect(const Rect &r, RGB *colorToUse) {
- D3DRECT rectToClear;
- rectToClear.x1 = r.Left;
- rectToClear.y1 = r.Top;
- rectToClear.x2 = r.Right + 1;
- rectToClear.y2 = r.Bottom + 1;
- DWORD colorDword = 0;
- if (colorToUse != NULL)
- colorDword = D3DCOLOR_XRGB(colorToUse->r, colorToUse->g, colorToUse->b);
- direct3ddevice->Clear(1, &rectToClear, D3DCLEAR_TARGET, colorDword, 0.5f, 0);
-}
-
-bool D3DGraphicsDriver::GetCopyOfScreenIntoBitmap(Bitmap *destination, bool at_native_res, GraphicResolution *want_fmt) {
- // Currently don't support copying in screen resolution when we are rendering in native
- if (!_renderSprAtScreenRes)
- at_native_res = true;
- Size need_size = at_native_res ? _srcRect.GetSize() : _dstRect.GetSize();
- if (destination->GetColorDepth() != _mode.ColorDepth || destination->GetSize() != need_size) {
- if (want_fmt)
- *want_fmt = GraphicResolution(need_size.Width, need_size.Height, _mode.ColorDepth);
- return false;
- }
- // If we are rendering sprites at the screen resolution, and requested native res,
- // re-render last frame to the native surface
- if (at_native_res && _renderSprAtScreenRes) {
- _renderSprAtScreenRes = false;
- _reDrawLastFrame();
- _render(true);
- _renderSprAtScreenRes = true;
- }
-
- IDirect3DSurface9 *surface = NULL;
- {
- if (_pollingCallback)
- _pollingCallback();
-
- if (at_native_res) {
- // with render to texture the texture mipmap surface can't be locked directly
- // we have to create a surface with D3DPOOL_SYSTEMMEM for GetRenderTargetData
- if (direct3ddevice->CreateOffscreenPlainSurface(
- _srcRect.GetWidth(),
- _srcRect.GetHeight(),
- color_depth_to_d3d_format(_mode.ColorDepth, false),
- D3DPOOL_SYSTEMMEM,
- &surface,
- NULL) != D3D_OK) {
- error("CreateOffscreenPlainSurface failed");
- }
- if (direct3ddevice->GetRenderTargetData(pNativeSurface, surface) != D3D_OK) {
- error("GetRenderTargetData failed");
- }
-
- }
- // Get the back buffer surface
- else if (direct3ddevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &surface) != D3D_OK) {
- error("IDirect3DDevice9::GetBackBuffer failed");
- }
-
- if (_pollingCallback)
- _pollingCallback();
-
- D3DLOCKED_RECT lockedRect;
- if (surface->LockRect(&lockedRect, (at_native_res ? NULL : &viewport_rect), D3DLOCK_READONLY) != D3D_OK) {
- error("IDirect3DSurface9::LockRect failed");
- }
-
- BitmapHelper::ReadPixelsFromMemory(destination, (uint8_t *)lockedRect.pBits, lockedRect.Pitch);
-
- surface->UnlockRect();
- surface->Release();
-
- if (_pollingCallback)
- _pollingCallback();
- }
- return true;
-}
-
-void D3DGraphicsDriver::RenderToBackBuffer() {
- error("D3D driver does not have a back buffer");
-}
-
-void D3DGraphicsDriver::Render() {
- Render(0, 0, kFlip_None);
-}
-
-void D3DGraphicsDriver::Render(int /*xoff*/, int /*yoff*/, GlobalFlipType /*flip*/) {
- if (wnd_call_proc(wnd_reset_device)) {
- throw Ali3DFullscreenLostException();
- }
-
- _renderAndPresent(true);
-}
-
-void D3DGraphicsDriver::_reDrawLastFrame() {
- RestoreDrawLists();
-}
-
-void D3DGraphicsDriver::_renderSprite(const D3DDrawListEntry *drawListEntry, const D3DMATRIX &matGlobal) {
- HRESULT hr;
- D3DBitmap *bmpToDraw = drawListEntry->bitmap;
- D3DMATRIX matSelfTransform;
- D3DMATRIX matTransform;
-
- if (bmpToDraw->_transparency >= 255)
- return;
-
- if (bmpToDraw->_tintSaturation > 0) {
- // Use custom pixel shader
- float vector[8];
- if (_legacyPixelShader) {
- rgb_to_hsv(bmpToDraw->_red, bmpToDraw->_green, bmpToDraw->_blue, &vector[0], &vector[1], &vector[2]);
- vector[0] /= 360.0; // In HSV, Hue is 0-360
- } else {
- vector[0] = (float)bmpToDraw->_red / 256.0;
- vector[1] = (float)bmpToDraw->_green / 256.0;
- vector[2] = (float)bmpToDraw->_blue / 256.0;
- }
-
- vector[3] = (float)bmpToDraw->_tintSaturation / 256.0;
-
- if (bmpToDraw->_transparency > 0)
- vector[4] = (float)bmpToDraw->_transparency / 256.0;
- else
- vector[4] = 1.0f;
-
- if (bmpToDraw->_lightLevel > 0)
- vector[5] = (float)bmpToDraw->_lightLevel / 256.0;
- else
- vector[5] = 1.0f;
-
- direct3ddevice->SetPixelShaderConstantF(0, &vector[0], 2);
- direct3ddevice->SetPixelShader(pixelShader);
- } else {
- // Not using custom pixel shader; set up the default one
- direct3ddevice->SetPixelShader(NULL);
- int useTintRed = 255;
- int useTintGreen = 255;
- int useTintBlue = 255;
- int useTransparency = 0xff;
- int textureColorOp = D3DTOP_MODULATE;
-
- if ((bmpToDraw->_lightLevel > 0) && (bmpToDraw->_lightLevel < 256)) {
- // darkening the sprite... this stupid calculation is for
- // consistency with the allegro software-mode code that does
- // a trans blend with a (8,8,8) sprite
- useTintRed = (bmpToDraw->_lightLevel * 192) / 256 + 64;
- useTintGreen = useTintRed;
- useTintBlue = useTintRed;
- } else if (bmpToDraw->_lightLevel > 256) {
- // ideally we would use a multi-stage operation here
- // because we need to do TEXTURE + (TEXTURE x LIGHT)
- // but is it worth having to set the device to 2-stage?
- textureColorOp = D3DTOP_ADD;
- useTintRed = (bmpToDraw->_lightLevel - 256) / 2;
- useTintGreen = useTintRed;
- useTintBlue = useTintRed;
- }
-
- if (bmpToDraw->_transparency > 0) {
- useTransparency = bmpToDraw->_transparency;
- }
-
- direct3ddevice->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(useTintRed, useTintGreen, useTintBlue, useTransparency));
- direct3ddevice->SetTextureStageState(0, D3DTSS_COLOROP, textureColorOp);
- direct3ddevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- direct3ddevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-
- if (bmpToDraw->_transparency == 0) {
- // No transparency, use texture alpha component
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- } else {
- // Fixed transparency, use (TextureAlpha x FixedTranslucency)
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
- }
- }
-
- if (bmpToDraw->_vertex == NULL) {
- hr = direct3ddevice->SetStreamSource(0, vertexbuffer, 0, sizeof(CUSTOMVERTEX));
- } else {
- hr = direct3ddevice->SetStreamSource(0, bmpToDraw->_vertex, 0, sizeof(CUSTOMVERTEX));
- }
- if (hr != D3D_OK) {
- error("IDirect3DDevice9::SetStreamSource failed");
- }
-
- float width = bmpToDraw->GetWidthToRender();
- float height = bmpToDraw->GetHeightToRender();
- float xProportion = width / (float)bmpToDraw->_width;
- float yProportion = height / (float)bmpToDraw->_height;
- float drawAtX = drawListEntry->x;
- float drawAtY = drawListEntry->y;
-
- for (int ti = 0; ti < bmpToDraw->_numTiles; ti++) {
- width = bmpToDraw->_tiles[ti].width * xProportion;
- height = bmpToDraw->_tiles[ti].height * yProportion;
- float xOffs;
- float yOffs = bmpToDraw->_tiles[ti].y * yProportion;
- if (bmpToDraw->_flipped)
- xOffs = (bmpToDraw->_width - (bmpToDraw->_tiles[ti].x + bmpToDraw->_tiles[ti].width)) * xProportion;
- else
- xOffs = bmpToDraw->_tiles[ti].x * xProportion;
- float thisX = drawAtX + xOffs;
- float thisY = drawAtY + yOffs;
- thisX = (-(_srcRect.GetWidth() / 2)) + thisX;
- thisY = (_srcRect.GetHeight() / 2) - thisY;
-
- //Setup translation and scaling matrices
- float widthToScale = (float)width;
- float heightToScale = (float)height;
- if (bmpToDraw->_flipped) {
- // The usual transform changes 0..1 into 0..width
- // So first negate it (which changes 0..w into -w..0)
- widthToScale = -widthToScale;
- // and now shift it over to make it 0..w again
- thisX += width;
- }
-
- // Multiply object's own and global matrixes
- MatrixTransform2D(matSelfTransform, (float)thisX - _pixelRenderXOffset, (float)thisY + _pixelRenderYOffset, widthToScale, heightToScale, 0.f);
- MatrixMultiply(matTransform, matSelfTransform, matGlobal);
-
- if ((_smoothScaling) && bmpToDraw->_useResampler && (bmpToDraw->_stretchToHeight > 0) &&
- ((bmpToDraw->_stretchToHeight != bmpToDraw->_height) ||
- (bmpToDraw->_stretchToWidth != bmpToDraw->_width))) {
- direct3ddevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- direct3ddevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- } else if (!_renderSprAtScreenRes) {
- direct3ddevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- direct3ddevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- } else {
- _filter->SetSamplerStateForStandardSprite(direct3ddevice);
- }
-
- direct3ddevice->SetTransform(D3DTS_WORLD, &matTransform);
- direct3ddevice->SetTexture(0, bmpToDraw->_tiles[ti].texture);
-
- hr = direct3ddevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, ti * 4, 2);
- if (hr != D3D_OK) {
- error("IDirect3DDevice9::DrawPrimitive failed");
- }
-
- }
-}
-
-void D3DGraphicsDriver::_renderFromTexture() {
- if (direct3ddevice->SetStreamSource(0, vertexbuffer, 0, sizeof(CUSTOMVERTEX)) != D3D_OK) {
- error("IDirect3DDevice9::SetStreamSource failed");
- }
-
- float width = _srcRect.GetWidth();
- float height = _srcRect.GetHeight();
- float drawAtX = -(_srcRect.GetWidth() / 2);
- float drawAtY = _srcRect.GetHeight() / 2;
-
- D3DMATRIX matrix;
- MatrixTransform2D(matrix, (float)drawAtX - _pixelRenderXOffset, (float)drawAtY + _pixelRenderYOffset, width, height, 0.f);
-
- direct3ddevice->SetTransform(D3DTS_WORLD, &matrix);
-
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
- direct3ddevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
-
- _filter->SetSamplerStateForStandardSprite(direct3ddevice);
-
- direct3ddevice->SetTexture(0, pNativeTexture);
-
- if (direct3ddevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) != D3D_OK) {
- error("IDirect3DDevice9::DrawPrimitive failed");
- }
-}
-
-void D3DGraphicsDriver::_renderAndPresent(bool clearDrawListAfterwards) {
- _render(clearDrawListAfterwards);
- direct3ddevice->Present(NULL, NULL, NULL, NULL);
-}
-
-void D3DGraphicsDriver::_render(bool clearDrawListAfterwards) {
- IDirect3DSurface9 *pBackBuffer = NULL;
-
- if (direct3ddevice->GetRenderTarget(0, &pBackBuffer) != D3D_OK) {
- error("IDirect3DSurface9::GetRenderTarget failed");
- }
- direct3ddevice->ColorFill(pBackBuffer, nullptr, D3DCOLOR_RGBA(0, 0, 0, 255));
-
- if (!_renderSprAtScreenRes) {
- if (direct3ddevice->SetRenderTarget(0, pNativeSurface) != D3D_OK) {
- error("IDirect3DSurface9::SetRenderTarget failed");
- }
- }
-
- direct3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 0.5f, 0);
- if (direct3ddevice->BeginScene() != D3D_OK)
- error("IDirect3DDevice9::BeginScene failed");
-
- // if showing at 2x size, the sprite can get distorted otherwise
- direct3ddevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- direct3ddevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- direct3ddevice->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
-
- RenderSpriteBatches();
-
- if (!_renderSprAtScreenRes) {
- if (direct3ddevice->SetRenderTarget(0, pBackBuffer) != D3D_OK) {
- error("IDirect3DSurface9::SetRenderTarget failed");
- }
- direct3ddevice->SetViewport(&_d3dViewport);
- _renderFromTexture();
- }
-
- direct3ddevice->EndScene();
-
- pBackBuffer->Release();
-
- if (clearDrawListAfterwards) {
- BackupDrawLists();
- ClearDrawLists();
- }
- ResetFxPool();
-}
-
-void D3DGraphicsDriver::RenderSpriteBatches() {
- // Render all the sprite batches with necessary transformations
- for (size_t i = 0; i <= _actSpriteBatch; ++i) {
- const Rect &viewport = _spriteBatches[i].Viewport;
- const D3DSpriteBatch &batch = _spriteBatches[i];
- if (!viewport.IsEmpty()) {
- direct3ddevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
- RECT scissor;
- if (_renderSprAtScreenRes) {
- scissor.left = _scaling.X.ScalePt(viewport.Left);
- scissor.top = _scaling.Y.ScalePt(viewport.Top);
- scissor.right = _scaling.X.ScalePt(viewport.Right + 1);
- scissor.bottom = _scaling.Y.ScalePt(viewport.Bottom + 1);
- } else {
- scissor.left = viewport.Left;
- scissor.top = viewport.Top;
- scissor.right = viewport.Right + 1;
- scissor.bottom = viewport.Bottom + 1;
- }
- direct3ddevice->SetScissorRect(&scissor);
- } else {
- direct3ddevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- }
- _stageVirtualScreen = GetStageScreen(i);
- RenderSpriteBatch(batch);
- }
-
- _stageVirtualScreen = GetStageScreen(0);
- direct3ddevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
-}
-
-void D3DGraphicsDriver::RenderSpriteBatch(const D3DSpriteBatch &batch) {
- D3DDrawListEntry stageEntry; // raw-draw plugin support
-
- const std::vector<D3DDrawListEntry> &listToDraw = batch.List;
- for (size_t i = 0; i < listToDraw.size(); ++i) {
- if (listToDraw[i].skip)
- continue;
-
- const D3DDrawListEntry *sprite = &listToDraw[i];
- if (listToDraw[i].bitmap == NULL) {
- if (DoNullSpriteCallback(listToDraw[i].x, (int)direct3ddevice))
- stageEntry = D3DDrawListEntry((D3DBitmap *)_stageVirtualScreenDDB);
- else
- continue;
- sprite = &stageEntry;
- }
-
- this->_renderSprite(sprite, batch.Matrix);
- }
-}
-
-void D3DGraphicsDriver::InitSpriteBatch(size_t index, const SpriteBatchDesc &desc) {
- if (_spriteBatches.size() <= index)
- _spriteBatches.resize(index + 1);
- _spriteBatches[index].List.clear();
-
- Rect viewport = desc.Viewport;
- // Combine both world transform and viewport transform into one matrix for faster perfomance
- D3DMATRIX matRoomToViewport, matViewport, matViewportFinal;
- // IMPORTANT: while the sprites are usually transformed in the order of Scale-Rotate-Translate,
- // the camera's transformation is essentially reverse world transformation. And the operations
- // are inverse: Translate-Rotate-Scale
- MatrixTransformInverse2D(matRoomToViewport,
- desc.Transform.X, -(desc.Transform.Y),
- desc.Transform.ScaleX, desc.Transform.ScaleY, desc.Transform.Rotate);
- // Next step is translate to viewport position; remove this if this is
- // changed to a separate operation at some point
- // TODO: find out if this is an optimal way to translate scaled room into Top-Left screen coordinates
- float scaled_offx = (_srcRect.GetWidth() - desc.Transform.ScaleX * (float)_srcRect.GetWidth()) / 2.f;
- float scaled_offy = (_srcRect.GetHeight() - desc.Transform.ScaleY * (float)_srcRect.GetHeight()) / 2.f;
- MatrixTranslate(matViewport, viewport.Left - scaled_offx, -(viewport.Top - scaled_offy), 0.f);
- MatrixMultiply(matViewportFinal, matRoomToViewport, matViewport);
-
- // Then apply global node transformation (flip and offset)
- int node_tx = desc.Offset.X, node_ty = desc.Offset.Y;
- float node_sx = 1.f, node_sy = 1.f;
- if ((desc.Flip == kFlip_Vertical) || (desc.Flip == kFlip_Both)) {
- int left = _srcRect.GetWidth() - (viewport.Right + 1);
- viewport.MoveToX(left);
- node_sx = -1.f;
- }
- if ((desc.Flip == kFlip_Horizontal) || (desc.Flip == kFlip_Both)) {
- int top = _srcRect.GetHeight() - (viewport.Bottom + 1);
- viewport.MoveToY(top);
- node_sy = -1.f;
- }
- viewport = Rect::MoveBy(viewport, node_tx, node_ty);
- D3DMATRIX matFlip;
- MatrixTransform2D(matFlip, node_tx, -(node_ty), node_sx, node_sy, 0.f);
- MatrixMultiply(_spriteBatches[index].Matrix, matViewportFinal, matFlip);
- _spriteBatches[index].Viewport = viewport;
-
- // create stage screen for plugin raw drawing
- int src_w = viewport.GetWidth() / desc.Transform.ScaleX;
- int src_h = viewport.GetHeight() / desc.Transform.ScaleY;
- CreateStageScreen(index, Size(src_w, src_h));
-}
-
-void D3DGraphicsDriver::ResetAllBatches() {
- for (size_t i = 0; i < _spriteBatches.size(); ++i)
- _spriteBatches[i].List.clear();
-}
-
-void D3DGraphicsDriver::ClearDrawBackups() {
- _backupBatchDescs.clear();
- _backupBatches.clear();
-}
-
-void D3DGraphicsDriver::BackupDrawLists() {
- ClearDrawBackups();
- for (size_t i = 0; i <= _actSpriteBatch; ++i) {
- _backupBatchDescs.push_back(_spriteBatchDesc[i]);
- _backupBatches.push_back(_spriteBatches[i]);
- }
-}
-
-void D3DGraphicsDriver::RestoreDrawLists() {
- if (_backupBatchDescs.size() == 0) {
- ClearDrawLists();
- return;
- }
- _spriteBatchDesc = _backupBatchDescs;
- _spriteBatches = _backupBatches;
- _actSpriteBatch = _backupBatchDescs.size() - 1;
-}
-
-void D3DGraphicsDriver::DrawSprite(int x, int y, IDriverDependantBitmap *bitmap) {
- _spriteBatches[_actSpriteBatch].List.push_back(D3DDrawListEntry((D3DBitmap *)bitmap, x, y));
-}
-
-void D3DGraphicsDriver::DestroyDDB(IDriverDependantBitmap *bitmap) {
- // Remove deleted DDB from backups
- for (D3DSpriteBatches::iterator it = _backupBatches.begin(); it != _backupBatches.end(); ++it) {
- std::vector<D3DDrawListEntry> &drawlist = it->List;
- for (size_t i = 0; i < drawlist.size(); i++) {
- if (drawlist[i].bitmap == bitmap)
- drawlist[i].skip = true;
- }
- }
- delete bitmap;
-}
-
-void D3DGraphicsDriver::UpdateTextureRegion(D3DTextureTile *tile, Bitmap *bitmap, D3DBitmap *target, bool hasAlpha) {
- IDirect3DTexture9 *newTexture = tile->texture;
-
- D3DLOCKED_RECT lockedRegion;
- HRESULT hr = newTexture->LockRect(0, &lockedRegion, NULL, D3DLOCK_NOSYSLOCK | D3DLOCK_DISCARD);
- if (hr != D3D_OK) {
- error("Unable to lock texture");
- }
-
- bool usingLinearFiltering = _filter->NeedToColourEdgeLines();
- char *memPtr = (char *)lockedRegion.pBits;
-
- if (target->_opaque)
- BitmapToVideoMemOpaque(bitmap, hasAlpha, tile, target, memPtr, lockedRegion.Pitch);
- else
- BitmapToVideoMem(bitmap, hasAlpha, tile, target, memPtr, lockedRegion.Pitch, usingLinearFiltering);
-
- newTexture->UnlockRect(0);
-}
-
-void D3DGraphicsDriver::UpdateDDBFromBitmap(IDriverDependantBitmap *bitmapToUpdate, Bitmap *bitmap, bool hasAlpha) {
- D3DBitmap *target = (D3DBitmap *)bitmapToUpdate;
- if (target->_width != bitmap->GetWidth() || target->_height != bitmap->GetHeight())
- error("UpdateDDBFromBitmap: mismatched bitmap size");
- const int color_depth = bitmap->GetColorDepth();
- if (color_depth != target->_colDepth)
- error("UpdateDDBFromBitmap: mismatched colour depths");
-
- target->_hasAlpha = hasAlpha;
- if (color_depth == 8)
- select_palette(palette);
-
- for (int i = 0; i < target->_numTiles; i++) {
- UpdateTextureRegion(&target->_tiles[i], bitmap, target, hasAlpha);
- }
-
- if (color_depth == 8)
- unselect_palette();
-}
-
-int D3DGraphicsDriver::GetCompatibleBitmapFormat(int color_depth) {
- if (color_depth == 8)
- return 8;
- if (color_depth > 8 && color_depth <= 16)
- return 16;
- return 32;
-}
-
-void D3DGraphicsDriver::AdjustSizeToNearestSupportedByCard(int *width, int *height) {
- int allocatedWidth = *width, allocatedHeight = *height;
-
- if (direct3ddevicecaps.TextureCaps & D3DPTEXTURECAPS_POW2) {
- bool foundWidth = false, foundHeight = false;
- int tryThis = 2;
- while ((!foundWidth) || (!foundHeight)) {
- if ((tryThis >= allocatedWidth) && (!foundWidth)) {
- allocatedWidth = tryThis;
- foundWidth = true;
- }
-
- if ((tryThis >= allocatedHeight) && (!foundHeight)) {
- allocatedHeight = tryThis;
- foundHeight = true;
- }
-
- tryThis = tryThis << 1;
- }
- }
-
- if (direct3ddevicecaps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) {
- if (allocatedWidth > allocatedHeight) {
- allocatedHeight = allocatedWidth;
- } else {
- allocatedWidth = allocatedHeight;
- }
- }
-
- *width = allocatedWidth;
- *height = allocatedHeight;
-}
-
-bool D3DGraphicsDriver::IsTextureFormatOk(D3DFORMAT TextureFormat, D3DFORMAT AdapterFormat) {
- HRESULT hr = direct3d->CheckDeviceFormat(D3DADAPTER_DEFAULT,
- D3DDEVTYPE_HAL,
- AdapterFormat,
- 0,
- D3DRTYPE_TEXTURE,
- TextureFormat);
-
- return SUCCEEDED(hr);
-}
-
-IDriverDependantBitmap *D3DGraphicsDriver::CreateDDBFromBitmap(Bitmap *bitmap, bool hasAlpha, bool opaque) {
- int allocatedWidth = bitmap->GetWidth();
- int allocatedHeight = bitmap->GetHeight();
- if (bitmap->GetColorDepth() != GetCompatibleBitmapFormat(bitmap->GetColorDepth()))
- error("CreateDDBFromBitmap: bitmap colour depth not supported");
- int colourDepth = bitmap->GetColorDepth();
-
- D3DBitmap *ddb = new D3DBitmap(bitmap->GetWidth(), bitmap->GetHeight(), colourDepth, opaque);
-
- AdjustSizeToNearestSupportedByCard(&allocatedWidth, &allocatedHeight);
- int tilesAcross = 1, tilesDown = 1;
-
- // *************** REMOVE THESE LINES *************
- //direct3ddevicecaps.MaxTextureWidth = 64;
- //direct3ddevicecaps.MaxTextureHeight = 256;
- // *************** END REMOVE THESE LINES *************
-
- // Calculate how many textures will be necessary to
- // store this image
- tilesAcross = (allocatedWidth + direct3ddevicecaps.MaxTextureWidth - 1) / direct3ddevicecaps.MaxTextureWidth;
- tilesDown = (allocatedHeight + direct3ddevicecaps.MaxTextureHeight - 1) / direct3ddevicecaps.MaxTextureHeight;
- int tileWidth = bitmap->GetWidth() / tilesAcross;
- int lastTileExtraWidth = bitmap->GetWidth() % tilesAcross;
- int tileHeight = bitmap->GetHeight() / tilesDown;
- int lastTileExtraHeight = bitmap->GetHeight() % tilesDown;
- int tileAllocatedWidth = tileWidth;
- int tileAllocatedHeight = tileHeight;
-
- AdjustSizeToNearestSupportedByCard(&tileAllocatedWidth, &tileAllocatedHeight);
-
- int numTiles = tilesAcross * tilesDown;
- D3DTextureTile *tiles = (D3DTextureTile *)malloc(sizeof(D3DTextureTile) * numTiles);
- memset(tiles, 0, sizeof(D3DTextureTile) * numTiles);
-
- CUSTOMVERTEX *vertices = NULL;
-
- if ((numTiles == 1) &&
- (allocatedWidth == bitmap->GetWidth()) &&
- (allocatedHeight == bitmap->GetHeight())) {
- // use default whole-image vertices
- } else {
- // The texture is not the same as the bitmap, so create some custom vertices
- // so that only the relevant portion of the texture is rendered
- int vertexBufferSize = numTiles * 4 * sizeof(CUSTOMVERTEX);
- HRESULT hr = direct3ddevice->CreateVertexBuffer(vertexBufferSize, 0,
- D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &ddb->_vertex, NULL);
-
- if (hr != D3D_OK) {
- free(tiles);
- char errorMessage[200];
- sprintf(errorMessage, "Direct3DDevice9::CreateVertexBuffer(Length=%d) for texture failed: error code %08X", vertexBufferSize, hr);
- error(errorMessage);
- }
-
- if (ddb->_vertex->Lock(0, 0, (void **)&vertices, D3DLOCK_DISCARD) != D3D_OK) {
- free(tiles);
- error("Failed to lock vertex buffer");
- }
- }
-
- for (int x = 0; x < tilesAcross; x++) {
- for (int y = 0; y < tilesDown; y++) {
- D3DTextureTile *thisTile = &tiles[y * tilesAcross + x];
- int thisAllocatedWidth = tileAllocatedWidth;
- int thisAllocatedHeight = tileAllocatedHeight;
- thisTile->x = x * tileWidth;
- thisTile->y = y * tileHeight;
- thisTile->width = tileWidth;
- thisTile->height = tileHeight;
- if (x == tilesAcross - 1) {
- thisTile->width += lastTileExtraWidth;
- thisAllocatedWidth = thisTile->width;
- AdjustSizeToNearestSupportedByCard(&thisAllocatedWidth, &thisAllocatedHeight);
- }
- if (y == tilesDown - 1) {
- thisTile->height += lastTileExtraHeight;
- thisAllocatedHeight = thisTile->height;
- AdjustSizeToNearestSupportedByCard(&thisAllocatedWidth, &thisAllocatedHeight);
- }
-
- if (vertices != NULL) {
- for (int vidx = 0; vidx < 4; vidx++) {
- int i = (y * tilesAcross + x) * 4 + vidx;
- vertices[i] = defaultVertices[vidx];
- if (vertices[i].tu > 0.0) {
- vertices[i].tu = (float)thisTile->width / (float)thisAllocatedWidth;
- }
- if (vertices[i].tv > 0.0) {
- vertices[i].tv = (float)thisTile->height / (float)thisAllocatedHeight;
- }
- }
- }
-
- // NOTE: pay attention that the texture format depends on the **display mode**'s color format,
- // rather than source bitmap's color depth!
- D3DFORMAT textureFormat = color_depth_to_d3d_format(_mode.ColorDepth, !opaque);
- HRESULT hr = direct3ddevice->CreateTexture(thisAllocatedWidth, thisAllocatedHeight, 1, 0,
- textureFormat,
- D3DPOOL_MANAGED, &thisTile->texture, NULL);
- if (hr != D3D_OK) {
- char errorMessage[200];
- sprintf(errorMessage, "Direct3DDevice9::CreateTexture(X=%d, Y=%d, FMT=%d) failed: error code %08X", thisAllocatedWidth, thisAllocatedHeight, textureFormat, hr);
- error(errorMessage);
- }
-
- }
- }
-
- if (vertices != NULL) {
- ddb->_vertex->Unlock();
- }
-
- ddb->_numTiles = numTiles;
- ddb->_tiles = tiles;
-
- UpdateDDBFromBitmap(ddb, bitmap, hasAlpha);
-
- return ddb;
-}
-
-void D3DGraphicsDriver::do_fade(bool fadingOut, int speed, int targetColourRed, int targetColourGreen, int targetColourBlue) {
- // Construct scene in order: game screen, fade fx, post game overlay
- // NOTE: please keep in mind: redrawing last saved frame here instead of constructing new one
- // is done because of backwards-compatibility issue: originally AGS faded out using frame
- // drawn before the script that triggers blocking fade (e.g. instigated by ChangeRoom).
- // Unfortunately some existing games were changing looks of the screen during same function,
- // but these were not supposed to get on screen until before fade-in.
- if (fadingOut)
- this->_reDrawLastFrame();
- else if (_drawScreenCallback != NULL)
- _drawScreenCallback();
- Bitmap *blackSquare = BitmapHelper::CreateBitmap(16, 16, 32);
- blackSquare->Clear(makecol32(targetColourRed, targetColourGreen, targetColourBlue));
- IDriverDependantBitmap *d3db = this->CreateDDBFromBitmap(blackSquare, false, true);
- delete blackSquare;
- BeginSpriteBatch(_srcRect, SpriteTransform());
- d3db->SetStretch(_srcRect.GetWidth(), _srcRect.GetHeight(), false);
- this->DrawSprite(0, 0, d3db);
- if (_drawPostScreenCallback != NULL)
- _drawPostScreenCallback();
-
- if (speed <= 0) speed = 16;
- speed *= 2; // harmonise speeds with software driver which is faster
- for (int a = 1; a < 255; a += speed) {
- d3db->SetTransparency(fadingOut ? a : (255 - a));
- this->_renderAndPresent(false);
-
- if (_pollingCallback)
- _pollingCallback();
- WaitForNextFrame();
- }
-
- if (fadingOut) {
- d3db->SetTransparency(0);
- this->_renderAndPresent(false);
- }
-
- this->DestroyDDB(d3db);
- this->ClearDrawLists();
- ResetFxPool();
-}
-
-void D3DGraphicsDriver::FadeOut(int speed, int targetColourRed, int targetColourGreen, int targetColourBlue) {
- do_fade(true, speed, targetColourRed, targetColourGreen, targetColourBlue);
-}
-
-void D3DGraphicsDriver::FadeIn(int speed, PALETTE p, int targetColourRed, int targetColourGreen, int targetColourBlue) {
- do_fade(false, speed, targetColourRed, targetColourGreen, targetColourBlue);
-}
-
-void D3DGraphicsDriver::BoxOutEffect(bool blackingOut, int speed, int delay) {
- // Construct scene in order: game screen, fade fx, post game overlay
- if (blackingOut)
- this->_reDrawLastFrame();
- else if (_drawScreenCallback != NULL)
- _drawScreenCallback();
- Bitmap *blackSquare = BitmapHelper::CreateBitmap(16, 16, 32);
- blackSquare->Clear();
- IDriverDependantBitmap *d3db = this->CreateDDBFromBitmap(blackSquare, false, true);
- delete blackSquare;
- BeginSpriteBatch(_srcRect, SpriteTransform());
- size_t fx_batch = _actSpriteBatch;
- d3db->SetStretch(_srcRect.GetWidth(), _srcRect.GetHeight(), false);
- this->DrawSprite(0, 0, d3db);
- if (!blackingOut) {
- // when fading in, draw four black boxes, one
- // across each side of the screen
- this->DrawSprite(0, 0, d3db);
- this->DrawSprite(0, 0, d3db);
- this->DrawSprite(0, 0, d3db);
- }
- if (_drawPostScreenCallback != NULL)
- _drawPostScreenCallback();
-
- int yspeed = _srcRect.GetHeight() / (_srcRect.GetWidth() / speed);
- int boxWidth = speed;
- int boxHeight = yspeed;
-
- while (boxWidth < _srcRect.GetWidth()) {
- boxWidth += speed;
- boxHeight += yspeed;
- D3DSpriteBatch &batch = _spriteBatches[fx_batch];
- std::vector<D3DDrawListEntry> &drawList = batch.List;
- const size_t last = drawList.size() - 1;
- if (blackingOut) {
- drawList[last].x = _srcRect.GetWidth() / 2 - boxWidth / 2;
- drawList[last].y = _srcRect.GetHeight() / 2 - boxHeight / 2;
- d3db->SetStretch(boxWidth, boxHeight, false);
- } else {
- drawList[last - 3].x = _srcRect.GetWidth() / 2 - boxWidth / 2 - _srcRect.GetWidth();
- drawList[last - 2].y = _srcRect.GetHeight() / 2 - boxHeight / 2 - _srcRect.GetHeight();
- drawList[last - 1].x = _srcRect.GetWidth() / 2 + boxWidth / 2;
- drawList[last ].y = _srcRect.GetHeight() / 2 + boxHeight / 2;
- d3db->SetStretch(_srcRect.GetWidth(), _srcRect.GetHeight(), false);
- }
-
- this->_renderAndPresent(false);
-
- if (_pollingCallback)
- _pollingCallback();
- platform->Delay(delay);
- }
-
- this->DestroyDDB(d3db);
- this->ClearDrawLists();
- ResetFxPool();
-}
-
-void D3DGraphicsDriver::SetScreenFade(int red, int green, int blue) {
- D3DBitmap *ddb = static_cast<D3DBitmap *>(MakeFx(red, green, blue));
- ddb->SetStretch(_spriteBatches[_actSpriteBatch].Viewport.GetWidth(),
- _spriteBatches[_actSpriteBatch].Viewport.GetHeight(), false);
- ddb->SetTransparency(0);
- _spriteBatches[_actSpriteBatch].List.push_back(D3DDrawListEntry(ddb));
-}
-
-void D3DGraphicsDriver::SetScreenTint(int red, int green, int blue) {
- if (red == 0 && green == 0 && blue == 0) return;
- D3DBitmap *ddb = static_cast<D3DBitmap *>(MakeFx(red, green, blue));
- ddb->SetStretch(_spriteBatches[_actSpriteBatch].Viewport.GetWidth(),
- _spriteBatches[_actSpriteBatch].Viewport.GetHeight(), false);
- ddb->SetTransparency(128);
- _spriteBatches[_actSpriteBatch].List.push_back(D3DDrawListEntry(ddb));
-}
-
-
-D3DGraphicsFactory *D3DGraphicsFactory::_factory = NULL;
-Library D3DGraphicsFactory::_library;
-
-D3DGraphicsFactory::~D3DGraphicsFactory() {
- DestroyDriver(); // driver must be destroyed before d3d library is disposed
- ULONG ref_cnt = _direct3d->Release();
- if (ref_cnt > 0)
- Debug::Printf(kDbgMsg_Warn, "WARNING: Not all of the Direct3D resources have been disposed; ID3D ref count: %d", ref_cnt);
- _factory = NULL;
-}
-
-size_t D3DGraphicsFactory::GetFilterCount() const {
- return 2;
-}
-
-const GfxFilterInfo *D3DGraphicsFactory::GetFilterInfo(size_t index) const {
- switch (index) {
- case 0:
- return &D3DGfxFilter::FilterInfo;
- case 1:
- return &AAD3DGfxFilter::FilterInfo;
- default:
- return NULL;
- }
-}
-
-String D3DGraphicsFactory::GetDefaultFilterID() const {
- return D3DGfxFilter::FilterInfo.Id;
-}
-
-/* static */ D3DGraphicsFactory *D3DGraphicsFactory::GetFactory() {
- if (!_factory) {
- _factory = new D3DGraphicsFactory();
- if (!_factory->Init()) {
- delete _factory;
- _factory = NULL;
- }
- }
- return _factory;
-}
-
-/* static */ D3DGraphicsDriver *D3DGraphicsFactory::GetD3DDriver() {
- if (!_factory)
- _factory = GetFactory();
- if (_factory)
- return _factory->EnsureDriverCreated();
- return NULL;
-}
-
-
-D3DGraphicsFactory::D3DGraphicsFactory()
- : _direct3d(NULL) {
-}
-
-D3DGraphicsDriver *D3DGraphicsFactory::EnsureDriverCreated() {
- if (!_driver) {
- _factory->_direct3d->AddRef();
- _driver = new D3DGraphicsDriver(_factory->_direct3d);
- }
- return _driver;
-}
-
-D3DGfxFilter *D3DGraphicsFactory::CreateFilter(const String &id) {
- if (D3DGfxFilter::FilterInfo.Id.CompareNoCase(id) == 0)
- return new D3DGfxFilter();
- else if (AAD3DGfxFilter::FilterInfo.Id.CompareNoCase(id) == 0)
- return new AAD3DGfxFilter();
- return NULL;
-}
-
-bool D3DGraphicsFactory::Init() {
- assert(_direct3d == NULL);
- if (_direct3d)
- return true;
-
- if (!_library.Load("d3d9")) {
- set_allegro_error("Direct3D 9 is not installed");
- return false;
- }
-
- typedef IDirect3D9 *WINAPI D3D9CreateFn(UINT);
- D3D9CreateFn *lpDirect3DCreate9 = (D3D9CreateFn *)_library.GetFunctionAddress("Direct3DCreate9");
- if (!lpDirect3DCreate9) {
- _library.Unload();
- set_allegro_error("Entry point not found in d3d9.dll");
- return false;
- }
- _direct3d = lpDirect3DCreate9(D3D_SDK_VERSION);
- if (!_direct3d) {
- _library.Unload();
- set_allegro_error("Direct3DCreate failed!");
- return false;
- }
- return true;
-}
-
-} // namespace D3D
-} // namespace Engine
-} // namespace AGS
-} // namsepace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/gfx/ali3dd3d.h b/engines/ags/engine/platform/windows/gfx/ali3dd3d.h
deleted file mode 100644
index 1f7784f52c..0000000000
--- a/engines/ags/engine/platform/windows/gfx/ali3dd3d.h
+++ /dev/null
@@ -1,352 +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.
- *
- */
-
-//=============================================================================
-//
-// Direct3D graphics factory
-//
-//=============================================================================
-
-#ifndef AGS_ENGINE_PLATFORM_WINDOWS_ALI3DD3D_H
-#define AGS_ENGINE_PLATFORM_WINDOWS_ALI3DD3D_H
-
-#include "ags/shared/core/platform.h"
-
-#if ! AGS_PLATFORM_OS_WINDOWS
-#error This file should only be included on the Windows build
-#endif
-
-#include "ags/lib/std/memory.h"
-#include "ags/lib/allegro.h"
-//include <winalleg.h>
-//include <d3d9.h>
-#include "ags/shared/gfx/bitmap.h"
-#include "ags/shared/gfx/ddb.h"
-#include "ags/shared/gfx/gfxdriverfactorybase.h"
-#include "ags/shared/gfx/gfxdriverbase.h"
-#include "ags/shared/util/library.h"
-#include "ags/shared/util/string.h"
-
-namespace AGS3 {
-
-namespace AGS {
-namespace Engine {
-namespace D3D {
-
-using AGS::Shared::Bitmap;
-using AGS::Shared::String;
-class D3DGfxFilter;
-
-struct D3DTextureTile : public TextureTile {
- IDirect3DTexture9 *texture;
-};
-
-class D3DBitmap : public VideoMemDDB {
-public:
- // Transparency is a bit counter-intuitive
- // 0=not transparent, 255=invisible, 1..254 barely visible .. mostly visible
- void SetTransparency(int transparency) override {
- _transparency = transparency;
- }
- void SetFlippedLeftRight(bool isFlipped) override {
- _flipped = isFlipped;
- }
- void SetStretch(int width, int height, bool useResampler = true) override {
- _stretchToWidth = width;
- _stretchToHeight = height;
- _useResampler = useResampler;
- }
- void SetLightLevel(int lightLevel) override {
- _lightLevel = lightLevel;
- }
- void SetTint(int red, int green, int blue, int tintSaturation) override {
- _red = red;
- _green = green;
- _blue = blue;
- _tintSaturation = tintSaturation;
- }
-
- bool _flipped;
- int _stretchToWidth, _stretchToHeight;
- bool _useResampler;
- int _red, _green, _blue;
- int _tintSaturation;
- int _lightLevel;
- bool _hasAlpha;
- int _transparency;
- IDirect3DVertexBuffer9 *_vertex;
- D3DTextureTile *_tiles;
- int _numTiles;
-
- D3DBitmap(int width, int height, int colDepth, bool opaque) {
- _width = width;
- _height = height;
- _colDepth = colDepth;
- _flipped = false;
- _hasAlpha = false;
- _stretchToWidth = 0;
- _stretchToHeight = 0;
- _useResampler = false;
- _red = _green = _blue = 0;
- _tintSaturation = 0;
- _lightLevel = 0;
- _transparency = 0;
- _opaque = opaque;
- _vertex = NULL;
- _tiles = NULL;
- _numTiles = 0;
- }
-
- int GetWidthToRender() {
- return (_stretchToWidth > 0) ? _stretchToWidth : _width;
- }
- int GetHeightToRender() {
- return (_stretchToHeight > 0) ? _stretchToHeight : _height;
- }
-
- void Dispose();
-
- ~D3DBitmap() override {
- Dispose();
- }
-};
-
-class D3DGfxModeList : public IGfxModeList {
-public:
- D3DGfxModeList(IDirect3D9 *direct3d, D3DFORMAT d3dformat)
- : _direct3d(direct3d)
- , _pixelFormat(d3dformat) {
- _modeCount = _direct3d ? _direct3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, _pixelFormat) : 0;
- }
-
- ~D3DGfxModeList() override {
- if (_direct3d)
- _direct3d->Release();
- }
-
- int GetModeCount() const override {
- return _modeCount;
- }
-
- bool GetMode(int index, DisplayMode &mode) const override;
-
-private:
- IDirect3D9 *_direct3d;
- D3DFORMAT _pixelFormat;
- int _modeCount;
-};
-
-struct CUSTOMVERTEX {
- D3DVECTOR position; // The position.
- D3DVECTOR normal;
- FLOAT tu, tv; // The texture coordinates.
-};
-
-typedef SpriteDrawListEntry<D3DBitmap> D3DDrawListEntry;
-// D3D renderer's sprite batch
-struct D3DSpriteBatch {
- // List of sprites to render
- std::vector<D3DDrawListEntry> List;
- // Clipping viewport
- Rect Viewport;
- // Transformation matrix, built from the batch description
- D3DMATRIX Matrix;
-};
-typedef std::vector<D3DSpriteBatch> D3DSpriteBatches;
-
-
-class D3DGraphicsDriver : public VideoMemoryGraphicsDriver {
-public:
- const char *GetDriverName() override {
- return "Direct3D 9";
- }
- const char *GetDriverID() override {
- return "D3D9";
- }
- void SetTintMethod(TintMethod method) override;
- bool SetDisplayMode(const DisplayMode &mode, volatile int *loopTimer) override;
- bool SetNativeSize(const Size &src_size) override;
- bool SetRenderFrame(const Rect &dst_rect) override;
- int GetDisplayDepthForNativeDepth(int native_color_depth) const override;
- IGfxModeList *GetSupportedModeList(int color_depth) override;
- bool IsModeSupported(const DisplayMode &mode) override;
- PGfxFilter GetGraphicsFilter() const override;
- // Clears the screen rectangle. The coordinates are expected in the **native game resolution**.
- void ClearRectangle(int x1, int y1, int x2, int y2, RGB *colorToUse) override;
- int GetCompatibleBitmapFormat(int color_depth) override;
- IDriverDependantBitmap *CreateDDBFromBitmap(Bitmap *bitmap, bool hasAlpha, bool opaque) override;
- void UpdateDDBFromBitmap(IDriverDependantBitmap *bitmapToUpdate, Bitmap *bitmap, bool hasAlpha) override;
- void DestroyDDB(IDriverDependantBitmap *bitmap) override;
- void DrawSprite(int x, int y, IDriverDependantBitmap *bitmap) override;
- void SetScreenFade(int red, int green, int blue) override;
- void SetScreenTint(int red, int green, int blue) override;
- void RenderToBackBuffer() override;
- void Render() override;
- void Render(int xoff, int yoff, GlobalFlipType flip) override;
- bool GetCopyOfScreenIntoBitmap(Bitmap *destination, bool at_native_res, GraphicResolution *want_fmt) override;
- void EnableVsyncBeforeRender(bool enabled) override {
- }
- void Vsync() override;
- void RenderSpritesAtScreenResolution(bool enabled, int supersampling) override {
- _renderSprAtScreenRes = enabled;
- };
- void FadeOut(int speed, int targetColourRed, int targetColourGreen, int targetColourBlue) override;
- void FadeIn(int speed, PALETTE p, int targetColourRed, int targetColourGreen, int targetColourBlue) override;
- void BoxOutEffect(bool blackingOut, int speed, int delay) override;
- bool SupportsGammaControl() override;
- void SetGamma(int newGamma) override;
- void UseSmoothScaling(bool enabled) override {
- _smoothScaling = enabled;
- }
- bool RequiresFullRedrawEachFrame() override {
- return true;
- }
- bool HasAcceleratedTransform() override {
- return true;
- }
-
- typedef std::shared_ptr<D3DGfxFilter> PD3DFilter;
-
- // Clears screen rect, coordinates are expected in display resolution
- void ClearScreenRect(const Rect &r, RGB *colorToUse);
- void UnInit();
- void SetGraphicsFilter(PD3DFilter filter);
-
- // Internal; TODO: find a way to hide these
- int _initDLLCallback(const DisplayMode &mode);
- int _resetDeviceIfNecessary();
-
- D3DGraphicsDriver(IDirect3D9 *d3d);
- ~D3DGraphicsDriver() override;
-
-private:
- PD3DFilter _filter;
-
- IDirect3D9 *direct3d;
- D3DPRESENT_PARAMETERS d3dpp;
- IDirect3DDevice9 *direct3ddevice;
- D3DGAMMARAMP defaultgammaramp;
- D3DGAMMARAMP currentgammaramp;
- D3DCAPS9 direct3ddevicecaps;
- IDirect3DVertexBuffer9 *vertexbuffer;
- IDirect3DSurface9 *pNativeSurface;
- IDirect3DTexture9 *pNativeTexture;
- RECT viewport_rect;
- UINT availableVideoMemory;
- CUSTOMVERTEX defaultVertices[4];
- String previousError;
- IDirect3DPixelShader9 *pixelShader;
- bool _smoothScaling;
- bool _legacyPixelShader;
- float _pixelRenderXOffset;
- float _pixelRenderYOffset;
- bool _renderSprAtScreenRes;
-
- D3DSpriteBatches _spriteBatches;
- // TODO: these draw list backups are needed only for the fade-in/out effects
- // find out if it's possible to reimplement these effects in main drawing routine.
- SpriteBatchDescs _backupBatchDescs;
- D3DSpriteBatches _backupBatches;
-
- D3DVIEWPORT9 _d3dViewport;
-
- // Called after new mode was successfully initialized
- void OnModeSet(const DisplayMode &mode) override;
- void InitSpriteBatch(size_t index, const SpriteBatchDesc &desc) override;
- void ResetAllBatches() override;
- // Called when the direct3d device is created for the first time
- int FirstTimeInit();
- void initD3DDLL(const DisplayMode &mode);
- void InitializeD3DState();
- void SetupViewport();
- HRESULT ResetD3DDevice();
- // Unset parameters and release resources related to the display mode
- void ReleaseDisplayMode();
- void set_up_default_vertices();
- void AdjustSizeToNearestSupportedByCard(int *width, int *height);
- void UpdateTextureRegion(D3DTextureTile *tile, Bitmap *bitmap, D3DBitmap *target, bool hasAlpha);
- void CreateVirtualScreen();
- void do_fade(bool fadingOut, int speed, int targetColourRed, int targetColourGreen, int targetColourBlue);
- bool IsTextureFormatOk(D3DFORMAT TextureFormat, D3DFORMAT AdapterFormat);
- // Backup all draw lists in the temp storage
- void BackupDrawLists();
- // Restore draw lists from the temp storage
- void RestoreDrawLists();
- // Deletes draw list backups
- void ClearDrawBackups();
- void _renderAndPresent(bool clearDrawListAfterwards);
- void _render(bool clearDrawListAfterwards);
- void _reDrawLastFrame();
- void RenderSpriteBatches();
- void RenderSpriteBatch(const D3DSpriteBatch &batch);
- void _renderSprite(const D3DDrawListEntry *entry, const D3DMATRIX &matGlobal);
- void _renderFromTexture();
-};
-
-
-class D3DGraphicsFactory : public GfxDriverFactoryBase<D3DGraphicsDriver, D3DGfxFilter> {
-public:
- ~D3DGraphicsFactory() override;
-
- size_t GetFilterCount() const override;
- const GfxFilterInfo *GetFilterInfo(size_t index) const override;
- String GetDefaultFilterID() const override;
-
- static D3DGraphicsFactory *GetFactory();
- static D3DGraphicsDriver *GetD3DDriver();
-
-private:
- D3DGraphicsFactory();
-
- D3DGraphicsDriver *EnsureDriverCreated() override;
- D3DGfxFilter *CreateFilter(const String &id) override;
-
- bool Init();
-
- static D3DGraphicsFactory *_factory;
- //
- // IMPORTANT NOTE: since the Direct3d9 device is created with
- // D3DCREATE_MULTITHREADED behavior flag, once it is created the d3d9.dll may
- // only be unloaded after window is destroyed, as noted in the MSDN's article
- // on "D3DCREATE"
- // (http://msdn.microsoft.com/en-us/library/windows/desktop/bb172527.aspx).
- // Otherwise window becomes either destroyed prematurely or broken (details
- // are unclear), which causes errors during Allegro deinitialization.
- //
- // Curiously, this problem was only confirmed under WinXP so far.
- //
- // For the purpose of avoiding this problem, we have a static library wrapper
- // that unloads library only at the very program exit (except cases of device
- // creation failure).
- //
- // TODO: find out if there is better solution.
- //
- static Library _library;
- IDirect3D9 *_direct3d;
-};
-
-} // namespace D3D
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/minidump.cpp b/engines/ags/engine/platform/windows/minidump.cpp
deleted file mode 100644
index c25b96d3b3..0000000000
--- a/engines/ags/engine/platform/windows/minidump.cpp
+++ /dev/null
@@ -1,119 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_WINDOWS && !AGS_PLATFORM_DEBUG
-#define UNICODE
-//include <stdio.h> // sprintf
-#include "ags/shared/windows.h"
-//include <crtdbg.h>
-#include "ags/shared/main/main.h"
-
-namespace AGS3 {
-
-CONTEXT cpustate;
-EXCEPTION_RECORD excinfo;
-int miniDumpResultCode = 0;
-
-typedef enum _MINIDUMP_TYPE {
- MiniDumpNormal = 0x0000,
- MiniDumpWithDataSegs = 0x0001,
- MiniDumpWithFullMemory = 0x0002,
- MiniDumpWithHandleData = 0x0004,
- MiniDumpFilterMemory = 0x0008,
- MiniDumpScanMemory = 0x0010,
- MiniDumpWithUnloadedModules = 0x0020,
- MiniDumpWithIndirectlyReferencedMemory = 0x0040,
- MiniDumpFilterModulePaths = 0x0080,
- MiniDumpWithProcessThreadData = 0x0100,
- MiniDumpWithPrivateReadWriteMemory = 0x0200,
- MiniDumpWithoutOptionalData = 0x0400,
-} MINIDUMP_TYPE;
-
-typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
- DWORD ThreadId;
- PEXCEPTION_POINTERS ExceptionPointers;
- BOOL ClientPointers;
-} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
-
-typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD ProcessId,
- HANDLE hFile, MINIDUMP_TYPE DumpType,
- CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
- CONST void *UserStreamParam,
- CONST void *CallbackParam);
-
-MINIDUMPWRITEDUMP _MiniDumpWriteDump;
-
-
-void CreateMiniDump(EXCEPTION_POINTERS *pep) {
- HMODULE dllHandle = LoadLibrary(L"dbghelp.dll");
- if (dllHandle == NULL) {
- miniDumpResultCode = 1;
- return;
- }
-
- _MiniDumpWriteDump = (MINIDUMPWRITEDUMP)GetProcAddress(dllHandle, "MiniDumpWriteDump");
- if (_MiniDumpWriteDump == NULL) {
- FreeLibrary(dllHandle);
- miniDumpResultCode = 2;
- return;
- }
-
- char fileName[80];
- sprintf(fileName, "CrashInfo.%s.dmp", EngineVersion.LongString.GetCStr());
- HANDLE hFile = CreateFileA(fileName, GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-
- if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) {
- MINIDUMP_EXCEPTION_INFORMATION mdei;
-
- mdei.ThreadId = GetCurrentThreadId();
- mdei.ExceptionPointers = pep;
- mdei.ClientPointers = FALSE;
-
- MINIDUMP_TYPE mdt = MiniDumpNormal; //MiniDumpWithPrivateReadWriteMemory;
-
- BOOL rv = _MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
- hFile, mdt, (pep != 0) ? &mdei : 0, NULL, NULL);
-
- if (!rv)
- miniDumpResultCode = 4;
-
- CloseHandle(hFile);
- } else
- miniDumpResultCode = 3;
-
- FreeLibrary(dllHandle);
-}
-
-int CustomExceptionHandler(LPEXCEPTION_POINTERS exinfo) {
- cpustate = exinfo->ContextRecord[0];
- excinfo = exinfo->ExceptionRecord[0];
- CreateMiniDump(exinfo);
-
- return EXCEPTION_EXECUTE_HANDLER;
-}
-
-} // namespace AGS3
-
-#endif // AGS_PLATFORM_OS_WINDOWS && !AGS_PLATFORM_DEBUG
diff --git a/engines/ags/engine/platform/windows/setup/winsetup.cpp b/engines/ags/engine/platform/windows/setup/winsetup.cpp
deleted file mode 100644
index cc88d145fc..0000000000
--- a/engines/ags/engine/platform/windows/setup/winsetup.cpp
+++ /dev/null
@@ -1,1146 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_WINDOWS
-
-//include <windows.h>
-//include <commctrl.h>
-//include <crtdbg.h>
-//include <shlobj.h>
-//include <shlwapi.h>
-#include "ags/lib/std/memory.h"
-//include <algorithm>
-//include <set>
-#include "ags/lib/std/vector.h"
-#include "ags/shared/ac/gamestructdefines.h"
-#undef RGB
-#undef PALETTE
-#define RGB void*
-#define PALETTE void*
-#include "ags/shared/gfx/gfxdriverfactory.h"
-#include "ags/shared/gfx/gfxfilter.h"
-#include "ags/shared/gfx/graphicsdriver.h"
-#include "ags/shared/main/config.h"
-#include "ags/shared/main/graphics_mode.h"
-#include "ags/shared/platform/base/agsplatformdriver.h"
-#include "ags/shared/resource/resource.h"
-#include "ags/shared/util/file.h"
-#include "ags/shared/util/string_utils.h"
-
-namespace AGS3 {
-
-#define AL_ID(a,b,c,d) (((a)<<24) | ((b)<<16) | ((c)<<8) | (d))
-
-#define DIGI_DIRECTAMX(n) AL_ID('A','X','A'+(n),' ')
-// This DirectX hardware mixer is crap, it crashes the program
-// when two sound effects are played at once
-#define DIGI_DIRECTX(n) AL_ID('D','X','A'+(n),' ')
-#define DIGI_WAVOUTID(n) AL_ID('W','O','A'+(n),' ')
-#define DIGI_NONE 0
-#define MIDI_AUTODETECT -1
-#define MIDI_NONE 0
-#define MIDI_WIN32MAPPER AL_ID('W','3','2','M')
-
-extern "C"
-{
- HWND win_get_window();
-}
-
-namespace AGS {
-namespace Engine {
-
-using namespace AGS::Shared;
-
-//=============================================================================
-//
-// WinConfig struct, keeps all configurable data.
-//
-//=============================================================================
-struct WinConfig {
- String Title;
- String VersionString;
-
- String DataDirectory;
- String UserSaveDir;
- GameResolutionType GameResType;
- Size GameResolution;
- int GameColourDepth;
- bool LetterboxByDesign;
-
- String GfxDriverId;
- String GfxFilterId;
- Size ScreenSize;
- GameFrameSetup FsGameFrame;
- GameFrameSetup WinGameFrame;
- int RefreshRate;
- bool Windowed;
- bool VSync;
- bool RenderAtScreenRes;
- bool AntialiasSprites;
-
- bool UseVoicePack;
-
- bool MouseAutoLock;
- float MouseSpeed;
-
- int SpriteCacheSize;
- String DefaultLanguageName;
- String Language;
-
- WinConfig();
- void SetDefaults();
- void Load(const ConfigTree &cfg);
- void Save(ConfigTree &cfg);
-};
-
-WinConfig::WinConfig() {
- SetDefaults();
-}
-
-void WinConfig::SetDefaults() {
- DataDirectory = ".";
- GameResType = kGameResolution_Undefined;
- GameColourDepth = 0;
- LetterboxByDesign = false;
-
- GfxFilterId = "StdScale";
- GfxDriverId = "D3D9";
- ScreenSize = get_desktop_size();
- FsGameFrame.ScaleDef = kFrame_MaxProportional;
- WinGameFrame.ScaleDef = kFrame_MaxRound;
- RefreshRate = 0;
- Windowed = false;
- VSync = false;
- RenderAtScreenRes = false;
- AntialiasSprites = false;
-
- MouseAutoLock = false;
- MouseSpeed = 1.f;
-
- UseVoicePack = true;
-
- SpriteCacheSize = 1024 * 128;
- DefaultLanguageName = "Game Default";
-
- Title = "Game Setup";
-}
-
-void WinConfig::Load(const ConfigTree &cfg) {
- DataDirectory = INIreadstring(cfg, "misc", "datadir", DataDirectory);
- UserSaveDir = INIreadstring(cfg, "misc", "user_data_dir");
- // Backward-compatible resolution type
- GameResType = (GameResolutionType)INIreadint(cfg, "misc", "defaultres", GameResType);
- if (GameResType < kGameResolution_Undefined || GameResType >= kNumGameResolutions)
- GameResType = kGameResolution_Undefined;
- GameResolution.Width = INIreadint(cfg, "misc", "game_width", GameResolution.Width);
- GameResolution.Height = INIreadint(cfg, "misc", "game_height", GameResolution.Height);
- GameColourDepth = INIreadint(cfg, "misc", "gamecolordepth", GameColourDepth);
- LetterboxByDesign = INIreadint(cfg, "misc", "letterbox", 0) != 0;
-
- GfxDriverId = INIreadstring(cfg, "graphics", "driver", GfxDriverId);
- GfxFilterId = INIreadstring(cfg, "graphics", "filter", GfxFilterId);
- ScreenSize.Width = INIreadint(cfg, "graphics", "screen_width", ScreenSize.Width);
- ScreenSize.Height = INIreadint(cfg, "graphics", "screen_height", ScreenSize.Height);
-
- parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_fs", make_scaling_option(FsGameFrame)), FsGameFrame);
- parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_win", make_scaling_option(WinGameFrame)), WinGameFrame);
-
- RefreshRate = INIreadint(cfg, "graphics", "refresh", RefreshRate);
- Windowed = INIreadint(cfg, "graphics", "windowed", Windowed ? 1 : 0) != 0;
- VSync = INIreadint(cfg, "graphics", "vsync", VSync ? 1 : 0) != 0;
- RenderAtScreenRes = INIreadint(cfg, "graphics", "render_at_screenres", RenderAtScreenRes ? 1 : 0) != 0;
-
- AntialiasSprites = INIreadint(cfg, "misc", "antialias", AntialiasSprites ? 1 : 0) != 0;
-
- UseVoicePack = INIreadint(cfg, "sound", "usespeech", UseVoicePack ? 1 : 0) != 0;
-
- MouseAutoLock = INIreadint(cfg, "mouse", "auto_lock", MouseAutoLock ? 1 : 0) != 0;
- MouseSpeed = INIreadfloat(cfg, "mouse", "speed", 1.f);
- if (MouseSpeed <= 0.f)
- MouseSpeed = 1.f;
-
- SpriteCacheSize = INIreadint(cfg, "misc", "cachemax", SpriteCacheSize);
-
- if (ConfMan.getActiveDomain()->tryGetVal("translation", translation) && !translation.empty())
- Language = translation;
- else
- Language = INIreadstring(cfg, "language", "translation", Language);
- DefaultLanguageName = INIreadstring(cfg, "language", "default_translation_name", DefaultLanguageName);
-
- Title = INIreadstring(cfg, "misc", "titletext", Title);
-}
-
-void WinConfig::Save(ConfigTree &cfg) {
- INIwritestring(cfg, "misc", "user_data_dir", UserSaveDir);
-
- INIwritestring(cfg, "graphics", "driver", GfxDriverId);
- INIwritestring(cfg, "graphics", "filter", GfxFilterId);
- INIwritestring(cfg, "graphics", "screen_def", Windowed ? "scaling" : "explicit");
- INIwriteint(cfg, "graphics", "screen_width", ScreenSize.Width);
- INIwriteint(cfg, "graphics", "screen_height", ScreenSize.Height);
- INIwritestring(cfg, "graphics", "game_scale_fs", make_scaling_option(FsGameFrame));
- INIwritestring(cfg, "graphics", "game_scale_win", make_scaling_option(WinGameFrame));
- INIwriteint(cfg, "graphics", "refresh", RefreshRate);
- INIwriteint(cfg, "graphics", "windowed", Windowed ? 1 : 0);
- INIwriteint(cfg, "graphics", "vsync", VSync ? 1 : 0);
- INIwriteint(cfg, "graphics", "render_at_screenres", RenderAtScreenRes ? 1 : 0);
-
- INIwriteint(cfg, "misc", "antialias", AntialiasSprites ? 1 : 0);
-
- INIwriteint(cfg, "sound", "usespeech", UseVoicePack ? 1 : 0);
-
- INIwriteint(cfg, "mouse", "auto_lock", MouseAutoLock ? 1 : 0);
- INIwritestring(cfg, "mouse", "speed", String::FromFormat("%0.1f", MouseSpeed));
-
- INIwriteint(cfg, "misc", "cachemax", SpriteCacheSize);
- INIwritestring(cfg, "language", "translation", Language);
-
- if (Language.empty()) {
- if (ConfMan.getActiveDomain()->contains("translation"))
- ConfMan.getActiveDomain()->erase("translation");
- } else
- ConfMan.getActiveDomain()->setVal("translation", Language);
-
- ConfMan.flushToDisk();
-}
-
-
-//=============================================================================
-//
-// WinAPI interaction helpers
-//
-//=============================================================================
-
-int AddString(HWND hwnd, LPCTSTR text, DWORD_PTR data = 0L) {
- int index = SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)text);
- if (index >= 0)
- SendMessage(hwnd, CB_SETITEMDATA, index, data);
- return index;
-}
-
-int InsertString(HWND hwnd, LPCTSTR text, int at_index, DWORD_PTR data = 0L) {
- int index = SendMessage(hwnd, CB_INSERTSTRING, at_index, (LPARAM)text);
- if (index >= 0)
- SendMessage(hwnd, CB_SETITEMDATA, index, data);
- return index;
-}
-
-int GetItemCount(HWND hwnd) {
- return SendMessage(hwnd, CB_GETCOUNT, 0, 0L);
-}
-
-bool GetCheck(HWND hwnd) {
- return SendMessage(hwnd, BM_GETCHECK, 0, 0) != FALSE;
-}
-
-void SetCheck(HWND hwnd, bool check) {
- SendMessage(hwnd, BM_SETCHECK, check ? BST_CHECKED : BST_UNCHECKED, 0);
-}
-
-int GetCurSel(HWND hwnd) {
- return SendMessage(hwnd, CB_GETCURSEL, 0, 0);
-}
-
-void SetCurSel(HWND hwnd, int cur_sel) {
- SendMessage(hwnd, CB_SETCURSEL, cur_sel, 0);
-}
-
-typedef bool (*PfnCompareCBItemData)(DWORD_PTR data1, DWORD_PTR data2);
-
-bool CmpICBItemDataAsStr(DWORD_PTR data1, DWORD_PTR data2) {
- LPCTSTR text_ptr1 = (LPCTSTR)data1;
- LPCTSTR text_ptr2 = (LPCTSTR)data2;
- return text_ptr1 && text_ptr2 && StrCmpI(text_ptr1, text_ptr2) == 0 || !text_ptr1 && !text_ptr2;
-}
-
-int SetCurSelToItemData(HWND hwnd, DWORD_PTR data, PfnCompareCBItemData pfn_cmp = NULL, int def_sel = -1) {
- int count = SendMessage(hwnd, CB_GETCOUNT, 0, 0);
- for (int i = 0; i < count; ++i) {
- DWORD_PTR item_data = SendMessage(hwnd, CB_GETITEMDATA, i, 0);
- if (pfn_cmp && pfn_cmp(item_data, data) || !pfn_cmp && item_data == data) {
- LRESULT res = SendMessage(hwnd, CB_SETCURSEL, i, 0);
- if (res != CB_ERR)
- return res;
- break;
- }
- }
- return SendMessage(hwnd, CB_SETCURSEL, def_sel, 0);
-}
-
-int SetCurSelToItemDataStr(HWND hwnd, LPCTSTR text, int def_sel = -1) {
- return SetCurSelToItemData(hwnd, (DWORD_PTR)text, CmpICBItemDataAsStr, def_sel);
-}
-
-DWORD_PTR GetCurItemData(HWND hwnd, DWORD_PTR def_value = 0) {
- int index = SendMessage(hwnd, CB_GETCURSEL, 0, 0);
- if (index >= 0)
- return SendMessage(hwnd, CB_GETITEMDATA, index, 0);
- return def_value;
-}
-
-String GetText(HWND hwnd) {
- TCHAR short_buf[MAX_PATH + 1];
- int len = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
- if (len > 0) {
- TCHAR *buf = len >= sizeof(short_buf) ? new TCHAR[len + 1] : short_buf;
- SendMessage(hwnd, WM_GETTEXT, len + 1, (LPARAM)buf);
- String s = buf;
- if (buf != short_buf)
- delete [] buf;
- return s;
- }
- return "";
-}
-
-void SetText(HWND hwnd, LPCTSTR text) {
- SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)text);
-}
-
-void ResetContent(HWND hwnd) {
- SendMessage(hwnd, CB_RESETCONTENT, 0, 0);
-}
-
-void SetSliderRange(HWND hwnd, int min, int max) {
- SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(min, max));
-}
-
-int GetSliderPos(HWND hwnd) {
- return SendMessage(hwnd, TBM_GETPOS, 0, 0);
-}
-
-void SetSliderPos(HWND hwnd, int pos) {
- SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pos);
-}
-
-void MakeFullLongPath(const char *path, char *out_buf, int buf_len) {
- GetFullPathName(path, buf_len, out_buf, NULL);
- GetLongPathName(out_buf, out_buf, buf_len);
-}
-
-
-//=============================================================================
-//
-// Browse-for-folder dialog
-//
-//=============================================================================
-
-int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) {
- if (uMsg == BFFM_INITIALIZED) {
- // Set initial selection
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpData);
- }
- return 0;
-}
-
-bool BrowseForFolder(String &dir_buf) {
- bool res = false;
- CoInitialize(NULL);
-
- BROWSEINFO bi = { 0 };
- bi.lpszTitle = "Select location for game saves and custom data files";
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS;
- bi.lpfn = BrowseCallbackProc;
- bi.lParam = (LPARAM)dir_buf.GetCStr();
- LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
- if (pidl) {
- char path[MAX_PATH];
- if (SHGetPathFromIDList(pidl, path) != FALSE) {
- dir_buf = path;
- res = true;
- }
- CoTaskMemFree(pidl);
- }
-
- CoUninitialize();
- return res;
-}
-
-
-//=============================================================================
-//
-// WinSetupDialog, handles the dialog UI.
-//
-//=============================================================================
-class WinSetupDialog {
-public:
- enum GfxModeSpecial {
- kGfxMode_None = -1,
- kGfxMode_Desktop = -2,
- kGfxMode_GameRes = -3,
- };
-
- static const int MouseSpeedMin = 1;
- static const int MouseSpeedMax = 100;
-
-public:
- WinSetupDialog(const ConfigTree &cfg_in, ConfigTree &cfg_out, const String &data_dir, const String &version_str);
- ~WinSetupDialog();
- static SetupReturnValue ShowModal(const ConfigTree &cfg_in, ConfigTree &cfg_out,
- const String &data_dir, const String &version_str);
-
-private:
- static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
- // Event handlers
- INT_PTR OnInitDialog(HWND hwnd);
- INT_PTR OnCommand(WORD id);
- INT_PTR OnListSelection(WORD id);
- void OnCustomSaveDirBtn();
- void OnCustomSaveDirCheck();
- void OnGfxDriverUpdate();
- void OnGfxFilterUpdate();
- void OnGfxModeUpdate();
- void OnScalingUpdate(HWND hlist, GameFrameSetup &frame_setup, bool windowed);
- void OnWindowedUpdate();
- void ShowAdvancedOptions();
-
- // Helper structs
- typedef std::vector<DisplayMode> VDispModes;
- // NOTE: we have to implement IGfxModeList for now because we are using
- // few engine functions that take IGfxModeList as parameter
- struct GfxModes : public IGfxModeList {
- VDispModes Modes;
-
- virtual int GetModeCount() const;
- virtual bool GetMode(int index, DisplayMode &mode) const;
- };
-
- typedef std::vector<GfxFilterInfo> VFilters;
- struct DriverDesc {
- String Id; // internal id
- String UserName; // human-friendly driver name
- GfxModes GfxModeList; // list of supported modes
- VFilters FilterList; // list of supported filters
- int UseColorDepth; // recommended display depth
- };
-
- // Operations
- void AddScalingString(HWND hlist, int scaling_factor);
- void FillGfxFilterList();
- void FillGfxModeList();
- void FillLanguageList();
- void FillScalingList(HWND hlist, GameFrameSetup &frame_setup, bool windowed);
- void InitGfxModes();
- void InitDriverDescFromFactory(const String &id);
- void SaveSetup();
- void SelectNearestGfxMode(const Size screen_size);
- void SetGfxModeText();
- void UpdateMouseSpeedText();
-
- // Dialog singleton and properties
- static WinSetupDialog *_dlg;
- HWND _hwnd;
- WinConfig _winCfg;
- const ConfigTree &_cfgIn;
- ConfigTree &_cfgOut;
- // Window size
- Size _winSize;
- Size _baseSize;
- // Driver descriptions
- typedef std::shared_ptr<DriverDesc> PDriverDesc;
- typedef std::map<String, PDriverDesc> DriverDescMap;
- DriverDescMap _drvDescMap;
- PDriverDesc _drvDesc;
- GfxFilterInfo _gfxFilterInfo;
- // Resolution limits
- Size _desktopSize;
- Size _maxWindowSize;
- Size _minGameSize;
- int _maxGameScale = 0;
- int _minGameScale = 0;
-
- // Dialog controls
- HWND _hVersionText = NULL;
- HWND _hCustomSaveDir = NULL;
- HWND _hCustomSaveDirBtn = NULL;
- HWND _hCustomSaveDirCheck = NULL;
- HWND _hGfxDriverList = NULL;
- HWND _hGfxModeList = NULL;
- HWND _hGfxFilterList = NULL;
- HWND _hFsScalingList = NULL;
- HWND _hWinScalingList = NULL;
- HWND _hDigiDriverList = NULL;
- HWND _hMidiDriverList = NULL;
- HWND _hLanguageList = NULL;
- HWND _hSpriteCacheList = NULL;
- HWND _hWindowed = NULL;
- HWND _hVSync = NULL;
- HWND _hRenderAtScreenRes = NULL;
- HWND _hRefresh85Hz = NULL;
- HWND _hAntialiasSprites = NULL;
- HWND _hThreadedAudio = NULL;
- HWND _hUseVoicePack = NULL;
- HWND _hAdvanced = NULL;
- HWND _hGameResolutionText = NULL;
- HWND _hGfxModeText = NULL;
- HWND _hMouseLock = NULL;
- HWND _hMouseSpeed = NULL;
- HWND _hMouseSpeedText = NULL;
-};
-
-WinSetupDialog *WinSetupDialog::_dlg = NULL;
-
-WinSetupDialog::WinSetupDialog(const ConfigTree &cfg_in, ConfigTree &cfg_out, const String &data_dir, const String &version_str)
- : _hwnd(NULL)
- , _cfgIn(cfg_in)
- , _cfgOut(cfg_out) {
- _winCfg.DataDirectory = data_dir;
- _winCfg.VersionString = version_str;
-}
-
-WinSetupDialog::~WinSetupDialog() {
-}
-
-SetupReturnValue WinSetupDialog::ShowModal(const ConfigTree &cfg_in, ConfigTree &cfg_out,
- const String &data_dir, const String &version_str) {
- _dlg = new WinSetupDialog(cfg_in, cfg_out, data_dir, version_str);
- INT_PTR dlg_res = DialogBoxParam(GetModuleHandle(NULL), (LPCTSTR)IDD_SETUP, win_get_window(),
- (DLGPROC)WinSetupDialog::DialogProc, 0L);
- delete _dlg;
- _dlg = NULL;
-
- switch (dlg_res) {
- case IDOKRUN:
- return kSetup_RunGame;
- case IDOK:
- return kSetup_Done;
- default:
- return kSetup_Cancel;
- }
-}
-
-INT_PTR WinSetupDialog::OnInitDialog(HWND hwnd) {
- _hwnd = hwnd;
- _hVersionText = GetDlgItem(_hwnd, IDC_VERSION);
- _hCustomSaveDir = GetDlgItem(_hwnd, IDC_CUSTOMSAVEDIR);
- _hCustomSaveDirBtn = GetDlgItem(_hwnd, IDC_CUSTOMSAVEDIRBTN);
- _hCustomSaveDirCheck = GetDlgItem(_hwnd, IDC_CUSTOMSAVEDIRCHECK);
- _hGfxDriverList = GetDlgItem(_hwnd, IDC_GFXDRIVER);
- _hGfxModeList = GetDlgItem(_hwnd, IDC_GFXMODE);
- _hGfxFilterList = GetDlgItem(_hwnd, IDC_GFXFILTER);
- _hFsScalingList = GetDlgItem(_hwnd, IDC_FSSCALING);
- _hWinScalingList = GetDlgItem(_hwnd, IDC_WINDOWSCALING);
- _hDigiDriverList = GetDlgItem(_hwnd, IDC_DIGISOUND);
- _hMidiDriverList = GetDlgItem(_hwnd, IDC_MIDIMUSIC);
- _hLanguageList = GetDlgItem(_hwnd, IDC_LANGUAGE);
- _hSpriteCacheList = GetDlgItem(_hwnd, IDC_SPRITECACHE);
- _hWindowed = GetDlgItem(_hwnd, IDC_WINDOWED);
- _hVSync = GetDlgItem(_hwnd, IDC_VSYNC);
- _hRenderAtScreenRes = GetDlgItem(_hwnd, IDC_RENDERATSCREENRES);
- _hRefresh85Hz = GetDlgItem(_hwnd, IDC_REFRESH_85HZ);
- _hAntialiasSprites = GetDlgItem(_hwnd, IDC_ANTIALIAS);
- _hThreadedAudio = GetDlgItem(_hwnd, IDC_THREADEDAUDIO);
- _hUseVoicePack = GetDlgItem(_hwnd, IDC_VOICEPACK);
- _hAdvanced = GetDlgItem(_hwnd, IDC_ADVANCED);
- _hGameResolutionText = GetDlgItem(_hwnd, IDC_RESOLUTION);
- _hGfxModeText = GetDlgItem(_hwnd, IDC_GFXMODETEXT);
- _hMouseLock = GetDlgItem(_hwnd, IDC_MOUSE_AUTOLOCK);
- _hMouseSpeed = GetDlgItem(_hwnd, IDC_MOUSESPEED);
- _hMouseSpeedText = GetDlgItem(_hwnd, IDC_MOUSESPEED_TEXT);
-
- _desktopSize = get_desktop_size();
- _maxWindowSize = _desktopSize;
- AGSPlatformDriver::GetDriver()->ValidateWindowSize(_maxWindowSize.Width, _maxWindowSize.Height, false);
- _minGameSize = Size(320, 200);
- _maxGameScale = 1;
- _minGameScale = 1;
-
- _winCfg.Load(_cfgIn);
-
- // Custom save dir controls
- String custom_save_dir = _winCfg.UserSaveDir;
- bool has_save_dir = !custom_save_dir.IsEmpty();
- if (!has_save_dir)
- custom_save_dir = _winCfg.DataDirectory;
- SetCheck(_hCustomSaveDirCheck, has_save_dir);
- char full_save_dir[MAX_PATH] = {0};
- MakeFullLongPath(custom_save_dir, full_save_dir, MAX_PATH);
- SetText(_hCustomSaveDir, full_save_dir);
- EnableWindow(_hCustomSaveDir, has_save_dir ? TRUE : FALSE);
- EnableWindow(_hCustomSaveDirBtn, has_save_dir ? TRUE : FALSE);
-
- // Resolution controls
- if (_winCfg.GameResolution.IsNull() &&
- (_winCfg.GameResType == kGameResolution_Undefined || _winCfg.GameResType == kGameResolution_Custom) ||
- _winCfg.GameColourDepth == 0)
- MessageBox(_hwnd, "Essential information about the game is missing in the configuration file. Setup program may be unable to deduce graphic modes properly.", "Initialization error", MB_OK | MB_ICONWARNING);
-
- if (_winCfg.GameResolution.IsNull())
- _winCfg.GameResolution = ResolutionTypeToSize(_winCfg.GameResType, _winCfg.LetterboxByDesign);
-
- SetText(_hwnd, _winCfg.Title);
- SetText(win_get_window(), _winCfg.Title);
- SetText(_hGameResolutionText, String::FromFormat("Native game resolution: %d x %d x %d",
- _winCfg.GameResolution.Width, _winCfg.GameResolution.Height, _winCfg.GameColourDepth));
-
- SetText(_hVersionText, _winCfg.VersionString);
-
- InitGfxModes();
-
- for (DriverDescMap::const_iterator it = _drvDescMap.begin(); it != _drvDescMap.end(); ++it)
- AddString(_hGfxDriverList, it->second->UserName, (DWORD_PTR)it->second->Id.GetCStr());
- SetCurSelToItemDataStr(_hGfxDriverList, _winCfg.GfxDriverId.GetCStr(), 0);
- OnGfxDriverUpdate();
-
- SetCheck(_hWindowed, _winCfg.Windowed);
- OnWindowedUpdate();
-
- FillScalingList(_hFsScalingList, _winCfg.FsGameFrame, false);
- FillScalingList(_hWinScalingList, _winCfg.WinGameFrame, true);
-
- SetCheck(_hVSync, _winCfg.VSync);
-
- SetCheck(_hRenderAtScreenRes, _winCfg.RenderAtScreenRes);
-
- FillLanguageList();
-
- SetCheck(_hMouseLock, _winCfg.MouseAutoLock);
-
- SetSliderRange(_hMouseSpeed, MouseSpeedMin, MouseSpeedMax);
- int slider_pos = (int)(_winCfg.MouseSpeed * 10.f + .5f);
- SetSliderPos(_hMouseSpeed, slider_pos);
- UpdateMouseSpeedText();
-
- AddString(_hSpriteCacheList, "16 MB", 16);
- AddString(_hSpriteCacheList, "32 MB", 32);
- AddString(_hSpriteCacheList, "64 MB", 64);
- AddString(_hSpriteCacheList, "128 MB (default)", 128);
- AddString(_hSpriteCacheList, "256 MB", 256);
- AddString(_hSpriteCacheList, "384 MB", 384);
- AddString(_hSpriteCacheList, "512 MB", 512);
- SetCurSelToItemData(_hSpriteCacheList, _winCfg.SpriteCacheSize / 1024, NULL, 3);
-
- SetCheck(_hRefresh85Hz, _winCfg.RefreshRate == 85);
- SetCheck(_hAntialiasSprites, _winCfg.AntialiasSprites);
- SetCheck(_hUseVoicePack, _winCfg.UseVoicePack);
- if (!File::TestReadFile("speech.vox"))
- EnableWindow(_hUseVoicePack, FALSE);
-
- if (INIreadint(_cfgIn, "disabled", "threaded_audio", 0) != 0)
- EnableWindow(_hThreadedAudio, FALSE);
- if (INIreadint(_cfgIn, "disabled", "speechvox", 0) != 0)
- EnableWindow(_hUseVoicePack, FALSE);
- if (INIreadint(_cfgIn, "disabled", "filters", 0) != 0)
- EnableWindow(_hGfxFilterList, FALSE);
- if (INIreadint(_cfgIn, "disabled", "render_at_screenres", 0) != 0)
- EnableWindow(_hRenderAtScreenRes, FALSE);
-
- RECT win_rect, gfx_rect, adv_rect, border;
- GetWindowRect(_hwnd, &win_rect);
- GetWindowRect(GetDlgItem(_hwnd, IDC_GFXOPTIONS), &gfx_rect);
- _winSize.Width = win_rect.right - win_rect.left;
- _winSize.Height = win_rect.bottom - win_rect.top;
- GetWindowRect(_hAdvanced, &adv_rect);
- border.left = border.top = border.right = border.bottom = 9;
- MapDialogRect(_hwnd, &border);
- _baseSize.Width = (adv_rect.right + (gfx_rect.left - win_rect.left)) - win_rect.left;
- _baseSize.Height = adv_rect.bottom - win_rect.top + border.bottom;
-
- MoveWindow(_hwnd, max(0, win_rect.left + (_winSize.Width - _baseSize.Width) / 2),
- max(0, win_rect.top + (_winSize.Height - _baseSize.Height) / 2),
- _baseSize.Width, _baseSize.Height, TRUE);
- SetFocus(GetDlgItem(_hwnd, IDOK));
- return FALSE; // notify WinAPI that we set focus ourselves
-}
-
-INT_PTR WinSetupDialog::OnCommand(WORD id) {
- switch (id) {
- case IDC_ADVANCED:
- ShowAdvancedOptions();
- break;
- case IDC_WINDOWED:
- OnWindowedUpdate();
- break;
- case IDC_CUSTOMSAVEDIRBTN:
- OnCustomSaveDirBtn();
- break;
- case IDC_CUSTOMSAVEDIRCHECK:
- OnCustomSaveDirCheck();
- break;
- case IDOK:
- case IDOKRUN:
- SaveSetup();
- // fall-through intended
- case IDCANCEL:
- EndDialog(_hwnd, id);
- return TRUE;
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-INT_PTR WinSetupDialog::OnListSelection(WORD id) {
- switch (id) {
- case IDC_GFXDRIVER:
- OnGfxDriverUpdate();
- break;
- case IDC_GFXFILTER:
- OnGfxFilterUpdate();
- break;
- case IDC_GFXMODE:
- OnGfxModeUpdate();
- break;
- case IDC_FSSCALING:
- OnScalingUpdate(_hFsScalingList, _winCfg.FsGameFrame, false);
- break;
- case IDC_WINDOWSCALING:
- OnScalingUpdate(_hWinScalingList, _winCfg.WinGameFrame, true);
- break;
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-void WinSetupDialog::OnCustomSaveDirBtn() {
- String save_dir = GetText(_hCustomSaveDir);
- if (BrowseForFolder(save_dir)) {
- SetText(_hCustomSaveDir, save_dir);
- }
-}
-
-void WinSetupDialog::OnCustomSaveDirCheck() {
- bool custom_save_dir = GetCheck(_hCustomSaveDirCheck);
- EnableWindow(_hCustomSaveDir, custom_save_dir ? TRUE : FALSE);
- EnableWindow(_hCustomSaveDirBtn, custom_save_dir ? TRUE : FALSE);
-}
-
-void WinSetupDialog::OnGfxDriverUpdate() {
- _winCfg.GfxDriverId = (LPCTSTR)GetCurItemData(_hGfxDriverList);
-
- DriverDescMap::const_iterator it = _drvDescMap.find(_winCfg.GfxDriverId);
- if (it != _drvDescMap.end())
- _drvDesc = it->second;
- else
- _drvDesc.reset();
-
- FillGfxModeList();
- FillGfxFilterList();
-}
-
-void WinSetupDialog::OnGfxFilterUpdate() {
- _winCfg.GfxFilterId = (LPCTSTR)GetCurItemData(_hGfxFilterList);
-
- _gfxFilterInfo = GfxFilterInfo();
- for (size_t i = 0; i < _drvDesc->FilterList.size(); ++i) {
- if (_drvDesc->FilterList[i].Id.CompareNoCase(_winCfg.GfxFilterId) == 0) {
- _gfxFilterInfo = _drvDesc->FilterList[i];
- break;
- }
- }
-}
-
-void WinSetupDialog::OnGfxModeUpdate() {
- DWORD_PTR sel = GetCurItemData(_hGfxModeList);
- if (sel == kGfxMode_Desktop)
- _winCfg.ScreenSize = _desktopSize;
- else if (sel == kGfxMode_GameRes)
- _winCfg.ScreenSize = _winCfg.GameResolution;
- else {
- const DisplayMode &mode = _drvDesc->GfxModeList.Modes[sel];
- _winCfg.ScreenSize = Size(mode.Width, mode.Height);
- }
-}
-
-void WinSetupDialog::OnScalingUpdate(HWND hlist, GameFrameSetup &frame_setup, bool windowed) {
- int scale = GetCurItemData(hlist);
- if (scale >= 0 && scale < kNumFrameScaleDef) {
- frame_setup.ScaleDef = (FrameScaleDefinition)scale;
- frame_setup.ScaleFactor = 0;
- } else {
- frame_setup.ScaleDef = kFrame_IntScale;
- frame_setup.ScaleFactor = scale >= 0 ? scale - kNumFrameScaleDef : scale;
- }
-
- if (windowed)
- SetGfxModeText();
-}
-
-void WinSetupDialog::OnWindowedUpdate() {
- _winCfg.Windowed = GetCheck(_hWindowed);
-
- if (_winCfg.Windowed) {
- ShowWindow(_hGfxModeList, SW_HIDE);
- ShowWindow(_hGfxModeText, SW_SHOW);
- SetGfxModeText();
- } else {
- ShowWindow(_hGfxModeList, SW_SHOW);
- ShowWindow(_hGfxModeText, SW_HIDE);
- }
-
- SelectNearestGfxMode(_winCfg.ScreenSize);
-}
-
-void WinSetupDialog::ShowAdvancedOptions() {
- // Reveal the advanced bit of the window
- ShowWindow(_hAdvanced, SW_HIDE);
-
- RECT win_rect;
- GetWindowRect(_hwnd, &win_rect);
- MoveWindow(_hwnd, max(0, win_rect.left + (_baseSize.Width - _winSize.Width) / 2),
- max(0, win_rect.top + (_baseSize.Height - _winSize.Height) / 2),
- _winSize.Width, _winSize.Height, TRUE);
-
- int offset = _winSize.Height - _baseSize.Height;
- RECT rc;
- int ctrl_ids[] = { IDC_VERSION, IDOK, IDOKRUN, IDCANCEL, 0 };
- for (int i = 0; ctrl_ids[i]; ++i) {
- HWND hctrl = GetDlgItem(_hwnd, ctrl_ids[i]);
- GetWindowRect(hctrl, &rc);
- ScreenToClient(_hwnd, (POINT *)&rc);
- ScreenToClient(_hwnd, (POINT *)&rc.right);
- MoveWindow(hctrl, rc.left, rc.top + offset, rc.right - rc.left, rc.bottom - rc.top, TRUE);
- }
-}
-
-INT_PTR CALLBACK WinSetupDialog::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- switch (uMsg) {
- case WM_INITDIALOG:
- _ASSERT(_dlg != NULL && _dlg->_hwnd == NULL);
- return _dlg->OnInitDialog(hwndDlg);
- case WM_COMMAND:
- _ASSERT(_dlg != NULL && _dlg->_hwnd != NULL);
- if (HIWORD(wParam) == CBN_SELCHANGE)
- return _dlg->OnListSelection(LOWORD(wParam));
- return _dlg->OnCommand(LOWORD(wParam));
- case WM_HSCROLL:
- _ASSERT(_dlg != NULL && _dlg->_hwnd != NULL);
- _dlg->UpdateMouseSpeedText();
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-int WinSetupDialog::GfxModes::GetModeCount() const {
- return Modes.size();
-}
-
-bool WinSetupDialog::GfxModes::GetMode(int index, DisplayMode &mode) const {
- if (index >= 0 && (size_t)index < Modes.size()) {
- mode = Modes[index];
- return true;
- }
- return false;
-}
-
-void WinSetupDialog::AddScalingString(HWND hlist, int scaling_factor) {
- String s;
- if (scaling_factor >= 0)
- s = String::FromFormat("x%d", scaling_factor);
- else
- s = String::FromFormat("1/%d", -scaling_factor);
- AddString(hlist, s, (DWORD_PTR)(scaling_factor >= 0 ? scaling_factor + kNumFrameScaleDef : scaling_factor));
-}
-
-void WinSetupDialog::FillGfxFilterList() {
- ResetContent(_hGfxFilterList);
-
- if (!_drvDesc) {
- _gfxFilterInfo = GfxFilterInfo();
- return;
- }
-
- for (size_t i = 0; i < _drvDesc->FilterList.size(); ++i) {
- const GfxFilterInfo &info = _drvDesc->FilterList[i];
- if (INIreadint(_cfgIn, "disabled", info.Id, 0) == 0)
- AddString(_hGfxFilterList, info.Name, (DWORD_PTR)info.Id.GetCStr());
- }
-
- SetCurSelToItemDataStr(_hGfxFilterList, _winCfg.GfxFilterId, 0);
- OnGfxFilterUpdate();
-}
-
-void WinSetupDialog::FillGfxModeList() {
- ResetContent(_hGfxModeList);
-
- if (!_drvDesc) {
- OnGfxModeUpdate();
- return;
- }
-
- const VDispModes &modes = _drvDesc->GfxModeList.Modes;
- bool has_desktop_mode = false;
- bool has_native_mode = false;
- String buf;
- for (VDispModes::const_iterator mode = modes.begin(); mode != modes.end(); ++mode) {
- if (mode->Width == _desktopSize.Width && mode->Height == _desktopSize.Height) {
- has_desktop_mode = true;
- continue;
- } else if (mode->Width == _winCfg.GameResolution.Width && mode->Height == _winCfg.GameResolution.Height) {
- has_native_mode = true;
- continue;
- }
- buf.Format("%d x %d", mode->Width, mode->Height);
- AddString(_hGfxModeList, buf, (DWORD_PTR)(mode - modes.begin()));
- }
-
- int spec_mode_idx = 0;
- if (has_desktop_mode)
- InsertString(_hGfxModeList, String::FromFormat("Desktop resolution (%d x %d)",
- _desktopSize.Width, _desktopSize.Height), spec_mode_idx++, (DWORD_PTR)kGfxMode_Desktop);
- if (has_native_mode)
- InsertString(_hGfxModeList, String::FromFormat("Native game resolution (%d x %d)",
- _winCfg.GameResolution.Width, _winCfg.GameResolution.Height), spec_mode_idx++, (DWORD_PTR)kGfxMode_GameRes);
-
- SelectNearestGfxMode(_winCfg.ScreenSize);
-}
-
-void WinSetupDialog::FillLanguageList() {
- ResetContent(_hLanguageList);
- AddString(_hLanguageList, _winCfg.DefaultLanguageName.GetCStr());
- SetCurSel(_hLanguageList, 0);
-
- String path_mask = String::FromFormat("%s\\*.tra", _winCfg.DataDirectory.GetCStr());
- WIN32_FIND_DATAA file_data;
- HANDLE find_handle = FindFirstFile(path_mask, &file_data);
- if (find_handle != INVALID_HANDLE_VALUE) {
- bool found_sel = false;
- do {
- LPTSTR ext = PathFindExtension(file_data.cFileName);
- if (ext && StrCmpI(ext, ".tra") == 0) {
- file_data.cFileName[0] = toupper(file_data.cFileName[0]);
- *ext = 0;
- int index = AddString(_hLanguageList, file_data.cFileName);
- if (!found_sel && _winCfg.Language.CompareNoCase(file_data.cFileName) == 0) {
- SetCurSel(_hLanguageList, index);
- found_sel = true;
- }
- }
- } while (FindNextFileA(find_handle, &file_data) != FALSE);
- FindClose(find_handle);
- }
-}
-
-void WinSetupDialog::FillScalingList(HWND hlist, GameFrameSetup &frame_setup, bool windowed) {
- ResetContent(hlist);
-
- const int min_scale = min(_winCfg.GameResolution.Width / _minGameSize.Width, _winCfg.GameResolution.Height / _minGameSize.Height);
- const Size max_size = windowed ? _maxWindowSize : _winCfg.ScreenSize;
- const int max_scale = _winCfg.GameResolution.IsNull() ? 1 :
- min(max_size.Width / _winCfg.GameResolution.Width, max_size.Height / _winCfg.GameResolution.Height);
- _maxGameScale = max(1, max_scale);
- _minGameScale = -max(1, min_scale);
-
- if (windowed)
- AddString(hlist, "None (original game size)", 1 + kNumFrameScaleDef);
-
- AddString(hlist, "Max round multiplier", kFrame_MaxRound);
- AddString(hlist, "Fill whole screen", kFrame_MaxStretch);
- AddString(hlist, "Stretch, preserving aspect ratio", kFrame_MaxProportional);
-
- if (windowed && !_winCfg.GameResolution.IsNull()) {
- // Add integer multipliers
- for (int scale = 2; scale <= _maxGameScale; ++scale)
- AddScalingString(hlist, scale);
- }
-
- SetCurSelToItemData(hlist,
- frame_setup.ScaleDef == kFrame_IntScale ? frame_setup.ScaleFactor + kNumFrameScaleDef : frame_setup.ScaleDef, NULL, 0);
-
- EnableWindow(hlist, SendMessage(hlist, CB_GETCOUNT, 0, 0) > 1 ? TRUE : FALSE);
- OnScalingUpdate(hlist, frame_setup, windowed);
-}
-
-void WinSetupDialog::InitGfxModes() {
- InitDriverDescFromFactory("D3D9");
- InitDriverDescFromFactory("OGL");
- InitDriverDescFromFactory("Software");
-
- if (_drvDescMap.size() == 0)
- MessageBox(_hwnd, "Unable to detect any supported graphic drivers!", "Initialization error", MB_OK | MB_ICONERROR);
-}
-
-// "Less" predicate that compares two display modes only by their screen metrics
-bool SizeLess(const DisplayMode &first, const DisplayMode &second) {
- return Size(first.Width, first.Height) < Size(second.Width, second.Height);
-}
-
-void WinSetupDialog::InitDriverDescFromFactory(const String &id) {
- IGfxDriverFactory *gfx_factory = GetGfxDriverFactory(id);
- if (!gfx_factory)
- return;
- IGraphicsDriver *gfx_driver = gfx_factory->GetDriver();
- if (!gfx_driver) {
- gfx_factory->Shutdown();
- return;
- }
-
- PDriverDesc drv_desc(new DriverDesc());
- drv_desc->Id = gfx_driver->GetDriverID();
- drv_desc->UserName = gfx_driver->GetDriverName();
- drv_desc->UseColorDepth =
- gfx_driver->GetDisplayDepthForNativeDepth(_winCfg.GameColourDepth ? _winCfg.GameColourDepth : 32);
-
- IGfxModeList *gfxm_list = gfx_driver->GetSupportedModeList(drv_desc->UseColorDepth);
- VDispModes &modes = drv_desc->GfxModeList.Modes;
- if (gfxm_list) {
- std::set<Size> unique_sizes; // trying to hide modes which only have different refresh rates
- for (int i = 0; i < gfxm_list->GetModeCount(); ++i) {
- DisplayMode mode;
- gfxm_list->GetMode(i, mode);
- if (mode.ColorDepth != drv_desc->UseColorDepth || unique_sizes.count(Size(mode.Width, mode.Height)) != 0)
- continue;
- unique_sizes.insert(Size(mode.Width, mode.Height));
- modes.push_back(mode);
- }
- std::sort(modes.begin(), modes.end(), SizeLess);
- delete gfxm_list;
- }
- if (modes.size() == 0) {
- // Add two default modes in hope that engine will be able to handle them (or fallbacks to something else)
- modes.push_back(DisplayMode(GraphicResolution(_desktopSize.Width, _desktopSize.Height, drv_desc->UseColorDepth)));
- modes.push_back(DisplayMode(GraphicResolution(_winCfg.GameResolution.Width, _winCfg.GameResolution.Height, drv_desc->UseColorDepth)));
- }
-
- drv_desc->FilterList.resize(gfx_factory->GetFilterCount());
- for (size_t i = 0; i < drv_desc->FilterList.size(); ++i) {
- drv_desc->FilterList[i] = *gfx_factory->GetFilterInfo(i);
- }
-
- gfx_factory->Shutdown();
- _drvDescMap[drv_desc->Id] = drv_desc;
-}
-
-void WinSetupDialog::SaveSetup() {
- const bool custom_save_dir = GetCheck(_hCustomSaveDirCheck);
- if (custom_save_dir) {
- // Compare user path with the game data directory. If user chose
- // path pointing inside game's directory, then store relative
- // path instead; thus the path will keep pointing at game's
- // directory if user moves game elsewhere.
- String save_dir;
- save_dir = GetText(_hCustomSaveDir);
- char full_data_dir[MAX_PATH] = {0};
- char full_save_dir[MAX_PATH] = {0};
- MakeFullLongPath(_winCfg.DataDirectory, full_data_dir, MAX_PATH);
- MakeFullLongPath(save_dir, full_save_dir, MAX_PATH);
- char rel_save_dir[MAX_PATH] = {0};
- if (PathRelativePathTo(rel_save_dir, full_data_dir, FILE_ATTRIBUTE_DIRECTORY, full_save_dir, FILE_ATTRIBUTE_DIRECTORY) &&
- strstr(rel_save_dir, "..") == NULL) {
- _winCfg.UserSaveDir = rel_save_dir;
- } else {
- _winCfg.UserSaveDir = save_dir;
- }
- } else {
- _winCfg.UserSaveDir = "";
- }
-
- if (GetCurSel(_hLanguageList) == 0)
- _winCfg.Language.Empty();
- else
- _winCfg.Language = GetText(_hLanguageList);
- _winCfg.SpriteCacheSize = GetCurItemData(_hSpriteCacheList) * 1024;
- _winCfg.UseVoicePack = GetCheck(_hUseVoicePack);
- _winCfg.VSync = GetCheck(_hVSync);
- _winCfg.RenderAtScreenRes = GetCheck(_hRenderAtScreenRes);
- _winCfg.AntialiasSprites = GetCheck(_hAntialiasSprites);
- _winCfg.RefreshRate = GetCheck(_hRefresh85Hz) ? 85 : 0;
- _winCfg.GfxFilterId = (LPCTSTR)GetCurItemData(_hGfxFilterList);
-
- _winCfg.MouseAutoLock = GetCheck(_hMouseLock);
- int slider_pos = GetSliderPos(_hMouseSpeed);
- _winCfg.MouseSpeed = (float)slider_pos / 10.f;
-
- _winCfg.Save(_cfgOut);
-}
-
-void WinSetupDialog::SelectNearestGfxMode(const Size screen_size) {
- if (!_drvDesc) {
- OnGfxModeUpdate();
- return;
- }
-
- // First check two special modes
- if (screen_size == _desktopSize) {
- SetCurSelToItemData(_hGfxModeList, kGfxMode_Desktop);
- } else if (screen_size == _winCfg.GameResolution) {
- SetCurSelToItemData(_hGfxModeList, kGfxMode_GameRes);
- } else {
- // Look up for the nearest supported mode
- int index = -1;
- DisplayMode dm;
- if (find_nearest_supported_mode(_drvDesc->GfxModeList, screen_size, _drvDesc->UseColorDepth,
- NULL, NULL, dm, &index)) {
- SetCurSelToItemData(_hGfxModeList, index, NULL, kGfxMode_Desktop);
- } else
- SetCurSelToItemData(_hGfxModeList, kGfxMode_Desktop);
- }
- OnGfxModeUpdate();
-}
-
-void WinSetupDialog::SetGfxModeText() {
- Size sz;
- const GameFrameSetup &frame_setup = _winCfg.WinGameFrame;
- if (frame_setup.ScaleDef == kFrame_MaxStretch) {
- sz = _maxWindowSize;
- } else if (frame_setup.ScaleDef == kFrame_MaxProportional) {
- sz = ProportionalStretch(_maxWindowSize, _winCfg.GameResolution);
- } else {
- int scale = 0;
- if (frame_setup.ScaleDef == kFrame_MaxRound)
- scale = _maxGameScale;
- else
- scale = frame_setup.ScaleFactor;
-
- if (scale >= 0) {
- sz.Width = _winCfg.GameResolution.Width * scale;
- sz.Height = _winCfg.GameResolution.Height * scale;
- } else {
- sz.Width = _winCfg.GameResolution.Width / (-scale);
- sz.Height = _winCfg.GameResolution.Height / (-scale);
- }
- }
- String text = String::FromFormat("%d x %d", sz.Width, sz.Height);
- SetText(_hGfxModeText, text);
-}
-
-void WinSetupDialog::UpdateMouseSpeedText() {
- int slider_pos = GetSliderPos(_hMouseSpeed);
- float mouse_speed = (float)slider_pos / 10.f;
- String text = mouse_speed == 1.f ? "Mouse speed: x 1.0 (Default)" : String::FromFormat("Mouse speed: x %0.1f", mouse_speed);
- SetText(_hMouseSpeedText, text);
-}
-
-//=============================================================================
-//
-// Windows setup entry point.
-//
-//=============================================================================
-void SetWinIcon() {
- SetClassLong(win_get_window(), GCL_HICON,
- (LONG) LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)));
-}
-
-SetupReturnValue WinSetup(const ConfigTree &cfg_in, ConfigTree &cfg_out,
- const String &game_data_dir, const String &version_str) {
- return WinSetupDialog::ShowModal(cfg_in, cfg_out, game_data_dir, version_str);
-}
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/setup/winsetup.h b/engines/ags/engine/platform/windows/setup/winsetup.h
deleted file mode 100644
index dc4c9bb8c1..0000000000
--- a/engines/ags/engine/platform/windows/setup/winsetup.h
+++ /dev/null
@@ -1,49 +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.
- *
- */
-
-//=============================================================================
-//
-// Built-in setup dialog for Windows version
-//
-//=============================================================================
-
-#ifndef AGS_ENGINE_PLATFORM_WINDOWS_SETUP_WINSETUP_H
-#define AGS_ENGINE_PLATFORM_WINDOWS_SETUP_WINSETUP_H
-
-#include "ags/shared/util/ini_util.h"
-
-namespace AGS3 {
-
-namespace AGS {
-namespace Engine {
-
-using namespace Shared;
-
-void SetWinIcon();
-SetupReturnValue WinSetup(const ConfigTree &cfg_in, ConfigTree &cfg_out,
- const String &game_data_dir, const String &version_str);
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/win_ex_handling.cpp b/engines/ags/engine/platform/windows/win_ex_handling.cpp
deleted file mode 100644
index f103d107f7..0000000000
--- a/engines/ags/engine/platform/windows/win_ex_handling.cpp
+++ /dev/null
@@ -1,100 +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.
- *
- */
-
-#include "ags/shared/core/platform.h"
-
-#if AGS_PLATFORM_OS_WINDOWS
-//include <new.h>
-#include "ags/lib/allegro.h"
-//include <winalleg.h>
-#include "ags/shared/ac/common.h"
-#include "ags/shared/ac/common_defines.h"
-#include "ags/shared/debugging/debugger.h"
-#include "ags/shared/debugging/out.h"
-#include "ags/shared/main/main.h"
-#include "ags/shared/util/ini_util.h"
-
-#if !AGS_PLATFORM_DEBUG
-#define USE_CUSTOM_EXCEPTION_HANDLER
-#endif
-
-namespace AGS3 {
-
-using namespace AGS::Shared;
-
-extern int proper_exit;
-
-char tempmsg[100];
-char *printfworkingspace;
-
-#ifdef USE_CUSTOM_EXCEPTION_HANDLER
-void CreateMiniDump(EXCEPTION_POINTERS *pep);
-
-extern int CustomExceptionHandler(LPEXCEPTION_POINTERS exinfo);
-extern EXCEPTION_RECORD excinfo;
-extern int miniDumpResultCode;
-
-static void DisplayException() {
- String script_callstack = get_cur_script(5);
- sprintf(printfworkingspace, "An exception 0x%X occurred in ACWIN.EXE at EIP = 0x%08X; program pointer is %+d, ACI version %s, gtags (%d,%d)\n\n"
- "AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.\n\n%s\n\n"
- "Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.\n\n%s (code %d)",
- excinfo.ExceptionCode, (intptr_t)excinfo.ExceptionAddress, _G(our_eip), EngineVersion.LongString.GetCStr(), _G(eip_guinum), _G(eip_guiobj), script_callstack.GetCStr(),
- (miniDumpResultCode == 0) ? "An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums." :
- "Unable to create an error dump file.", miniDumpResultCode);
- MessageBoxA(win_get_window(), printfworkingspace, "Illegal exception", MB_ICONSTOP | MB_OK);
-}
-
-int initialize_engine_with_exception_handling(
- int (initialize_engine)(const AGS::Shared::ConfigTree &startup_opts),
- const ConfigTree &startup_opts) {
- __try {
- Debug::Printf(kDbgMsg_Info, "Installing exception handler");
- return initialize_engine(startup_opts);
- } __except (CustomExceptionHandler(GetExceptionInformation())) {
- DisplayException();
- proper_exit = 1;
- }
- return EXIT_CRASH;
-}
-#endif // USE_CUSTOM_EXCEPTION_HANDLER
-
-
-int malloc_fail_handler(size_t amountwanted) {
-#ifdef USE_CUSTOM_EXCEPTION_HANDLER
- CreateMiniDump(NULL);
-#endif
- free(printfworkingspace);
- sprintf(tempmsg, "Out of memory: failed to allocate %ld bytes (at PP=%d)", amountwanted, _G(our_eip));
- quit(tempmsg);
- return 0;
-}
-
-void setup_malloc_handling() {
- _set_new_handler(malloc_fail_handler);
- _set_new_mode(1);
- printfworkingspace = (char *)malloc(7000);
-}
-
-} // namespace AGS3
-
-#endif // AGS_PLATFORM_OS_WINDOWS
diff --git a/engines/ags/engine/platform/windows/win_ex_handling.h b/engines/ags/engine/platform/windows/win_ex_handling.h
deleted file mode 100644
index 4f2d6d234f..0000000000
--- a/engines/ags/engine/platform/windows/win_ex_handling.h
+++ /dev/null
@@ -1,37 +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.
- *
- */
-
-#ifndef AGS_ENGINE_PLATFORM_WINDOWS_WIN_EX_HANDLING_H
-#define AGS_ENGINE_PLATFORM_WINDOWS_WIN_EX_HANDLING_H
-
-#include "ags/shared/util/ini_util.h"
-
-namespace AGS3 {
-
-void setup_malloc_handling();
-int initialize_engine_with_exception_handling(
- int (initialize_engine)(const AGS::Shared::ConfigTree &startup_opts),
- const AGS::Shared::ConfigTree &startup_opts);
-
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/platform/windows/winapi_exclusive.h b/engines/ags/engine/platform/windows/winapi_exclusive.h
deleted file mode 100644
index dedc890e6a..0000000000
--- a/engines/ags/engine/platform/windows/winapi_exclusive.h
+++ /dev/null
@@ -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.
- *
- */
-
-//=============================================================================
-//
-// An excerpt from <windows.h>, declaring most commonly used WinAPI types
-// and attributes. Meant to avoid including <windows.h> itself when it may
-// cause naming conflicts with its dreaded heap of macros.
-//
-//=============================================================================
-
-#ifndef AGS_ENGINE_PLATFORM_WINDOWS_WINAPI_EXCLUSIVE_H
-#define AGS_ENGINE_PLATFORM_WINDOWS_WINAPI_EXCLUSIVE_H
-
-namespace AGS3 {
-
-#ifndef _WINDOWS_ // do not include if windows.h was included first
-#define _WINDOWS_ // there can be only one
-
-typedef unsigned long DWORD;
-typedef int BOOL;
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef char CHAR;
-#define CONST const
-typedef CONST CHAR *LPCSTR, *PCSTR;
-
-#define DECLSPEC_IMPORT __declspec(dllimport)
-#define WINBASEAPI DECLSPEC_IMPORT
-#define WINAPI __stdcall
-
-typedef void *PVOID;
-typedef PVOID HANDLE;
-typedef HANDLE HINSTANCE;
-typedef HANDLE HMODULE;
-typedef HANDLE HWND;
-
-#define FAR
-#define NEAR
-
-typedef int (FAR WINAPI *FARPROC)();
-
-#endif
-
-} // namespace AGS3
-
-#endif
Commit: 40a283def9d121d23937ad6cf531a1ee2f8b868e
https://github.com/scummvm/scummvm/commit/40a283def9d121d23937ad6cf531a1ee2f8b868e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-13T11:13:48-08:00
Commit Message:
AGS: Rename Linux platform driver to ScummVMPlatformDriver
Changed paths:
A engines/ags/engine/platform/scummvm/scummvm_platform_driver.cpp
R engines/ags/engine/platform/linux/acpllnx.cpp
R engines/ags/engine/platform/linux/icon.xpm
engines/ags/module.mk
diff --git a/engines/ags/engine/platform/linux/icon.xpm b/engines/ags/engine/platform/linux/icon.xpm
deleted file mode 100644
index 61854643f8..0000000000
--- a/engines/ags/engine/platform/linux/icon.xpm
+++ /dev/null
@@ -1,1103 +0,0 @@
-/* XPM */
-static const char * icon_xpm[] = {
-"48 48 1052 2",
-" c None",
-". c #5258BE",
-"+ c #4449B4",
-"@ c #2E33AA",
-"# c #2226A6",
-"$ c #2527A8",
-"% c #282CAA",
-"& c #3539AF",
-"* c #464CB5",
-"= c #4C51B6",
-"- c #4D53BE",
-"; c #2B2EA8",
-"> c #090B8C",
-", c #010180",
-"' c #000079",
-") c #00007B",
-"! c #010187",
-"~ c #060894",
-"{ c #1B1FA7",
-"] c #3138B2",
-"^ c #2D33B0",
-"/ c #262CAE",
-"( c #3036B0",
-"_ c #2E33B0",
-": c #282EAC",
-"< c #2F34AD",
-"[ c #4C51BC",
-"} c #121398",
-"| c #00007D",
-"1 c #000072",
-"2 c #04046C",
-"3 c #06066C",
-"4 c #0A0A74",
-"5 c #0C0C81",
-"6 c #0C0D8D",
-"7 c #0E1199",
-"8 c #292EAC",
-"9 c #474EB8",
-"0 c #474EB9",
-"a c #444BB9",
-"b c #5861C2",
-"c c #666FCA",
-"d c #6770CC",
-"e c #555FC4",
-"f c #292EB1",
-"g c #1F20A6",
-"h c #585DBB",
-"i c #1E20A6",
-"j c #000081",
-"k c #060473",
-"l c #070674",
-"m c #090977",
-"n c #090975",
-"o c #090974",
-"p c #0A0A79",
-"q c #0C0C83",
-"r c #0F1198",
-"s c #2C31AA",
-"t c #4B51B6",
-"u c #474EB6",
-"v c #3F44B5",
-"w c #5058BC",
-"x c #636BC4",
-"y c #6C75CB",
-"z c #717AD1",
-"A c #5C66CD",
-"B c #2B30BA",
-"C c #0C0EA2",
-"D c #2023A8",
-"E c #070A9B",
-"F c #010179",
-"G c #0C0A75",
-"H c #0A0A7D",
-"I c #09097A",
-"J c #090978",
-"K c #090976",
-"L c #0C0C86",
-"M c #0C0C8D",
-"N c #0F1196",
-"O c #2B2FA7",
-"P c #4A51B3",
-"Q c #484FB4",
-"R c #3B41B2",
-"S c #4A52BA",
-"T c #6069C2",
-"U c #6A73CA",
-"V c #6F78CF",
-"W c #5E66CC",
-"X c #3A40C1",
-"Y c #2A2DB3",
-"Z c #11139C",
-"` c #1F22A6",
-" . c #2C2FB2",
-".. c #00007C",
-"+. c #09096F",
-"@. c #0B0C7E",
-"#. c #0A0A7E",
-"$. c #09097C",
-"%. c #08086F",
-"&. c #080870",
-"*. c #0B0B77",
-"=. c #0C0C7D",
-"-. c #0C0D84",
-";. c #1C1F92",
-">. c #31369E",
-",. c #3338A3",
-"'. c #282CA5",
-"). c #363BAC",
-"!. c #4E55B8",
-"~. c #5E67C2",
-"{. c #6A73CC",
-"]. c #5D65CD",
-"^. c #3C42C1",
-"/. c #2B31B7",
-"(. c #2A2FA1",
-"_. c #090A94",
-":. c #4247B3",
-"<. c #0D0F9B",
-"[. c #04056D",
-"}. c #0C0C82",
-"|. c #0A0A80",
-"1. c #080874",
-"2. c #07076A",
-"3. c #070765",
-"4. c #060663",
-"5. c #060665",
-"6. c #0B0B6C",
-"7. c #0C0C74",
-"8. c #0C0E7B",
-"9. c #131585",
-"0. c #1D1F91",
-"a. c #1F2295",
-"b. c #1B1D99",
-"c. c #22249E",
-"d. c #3134A7",
-"e. c #3F45B0",
-"f. c #4E55BA",
-"g. c #5056C3",
-"h. c #3A40C2",
-"i. c #2B30B9",
-"j. c #2A30A5",
-"k. c #12158D",
-"l. c #1E21A5",
-"m. c #101299",
-"n. c #06066F",
-"o. c #09097D",
-"p. c #060664",
-"q. c #05055E",
-"r. c #060662",
-"s. c #060661",
-"t. c #0A0A69",
-"u. c #0C0C6F",
-"v. c #0C0E76",
-"w. c #101280",
-"x. c #14168A",
-"y. c #181990",
-"z. c #151695",
-"A. c #1A1A9B",
-"B. c #2527A1",
-"C. c #2E33A9",
-"D. c #363BAE",
-"E. c #353BB2",
-"F. c #2C31B4",
-"G. c #272BB6",
-"H. c #272AA6",
-"I. c #14178C",
-"J. c #1B1DA3",
-"K. c #1B1EAB",
-"L. c #05057C",
-"M. c #050560",
-"N. c #050552",
-"O. c #050556",
-"P. c #06065C",
-"Q. c #06065E",
-"R. c #06065F",
-"S. c #080862",
-"T. c #090967",
-"U. c #0B0D6E",
-"V. c #0D0F77",
-"W. c #101281",
-"X. c #111388",
-"Y. c #0F118E",
-"Z. c #131495",
-"`. c #1A1C9C",
-" + c #2325A3",
-".+ c #292DAA",
-"++ c #2A2DAD",
-"@+ c #2225AC",
-"#+ c #1D20AA",
-"$+ c #20229F",
-"%+ c #131597",
-"&+ c #1B1CAE",
-"*+ c #3F46C0",
-"=+ c #131598",
-"-+ c #00003C",
-";+ c #03033F",
-">+ c #050550",
-",+ c #050554",
-"'+ c #050558",
-")+ c #05055B",
-"!+ c #05055A",
-"~+ c #05055C",
-"{+ c #080860",
-"]+ c #080863",
-"^+ c #0A0967",
-"/+ c #0C0E6F",
-"(+ c #0F1178",
-"_+ c #0E107F",
-":+ c #0D0F85",
-"<+ c #0E108D",
-"[+ c #141694",
-"}+ c #1A1C9B",
-"|+ c #2022A2",
-"1+ c #2024A6",
-"2+ c #1E21A6",
-"3+ c #181BA0",
-"4+ c #181A98",
-"5+ c #0E10A6",
-"6+ c #1B1DB5",
-"7+ c #525CB3",
-"8+ c #6069D4",
-"9+ c #14168E",
-"0+ c #000036",
-"a+ c #00002F",
-"b+ c #040442",
-"c+ c #05054D",
-"d+ c #060657",
-"e+ c #070759",
-"f+ c #07075C",
-"g+ c #08085F",
-"h+ c #0A0A66",
-"i+ c #0C0D6D",
-"j+ c #0C0F74",
-"k+ c #0C0F7A",
-"l+ c #0E1081",
-"m+ c #13158E",
-"n+ c #181B95",
-"o+ c #1B1C97",
-"p+ c #1B1C96",
-"q+ c #171899",
-"r+ c #1719A8",
-"s+ c #0B0CAE",
-"t+ c #1A1AB8",
-"u+ c #2C329B",
-"v+ c #7A86CB",
-"w+ c #7985E4",
-"x+ c #262BB0",
-"y+ c #000059",
-"z+ c #01002A",
-"A+ c #020236",
-"B+ c #040441",
-"C+ c #05054A",
-"D+ c #05054C",
-"E+ c #05054E",
-"F+ c #060651",
-"G+ c #080856",
-"H+ c #09085B",
-"I+ c #0A0A5F",
-"J+ c #010565",
-"K+ c #03076C",
-"L+ c #0C0F6B",
-"M+ c #0F126C",
-"N+ c #121374",
-"O+ c #141685",
-"P+ c #17199B",
-"Q+ c #1719AC",
-"R+ c #1314AE",
-"S+ c #0607A9",
-"T+ c #1E1FB2",
-"U+ c #34356C",
-"V+ c #0D0D68",
-"W+ c #0E1180",
-"X+ c #262798",
-"Y+ c #262A98",
-"Z+ c #4249AF",
-"`+ c #7D88CF",
-" @ c #919DE8",
-".@ c #5C64DB",
-"+@ c #2326A8",
-"@@ c #070775",
-"#@ c #00004C",
-"$@ c #000034",
-"%@ c #00002B",
-"&@ c #000028",
-"*@ c #010029",
-"=@ c #01002C",
-"-@ c #030230",
-";@ c #020334",
-">@ c #010239",
-",@ c #2C183D",
-"'@ c #251642",
-")@ c #02075B",
-"!@ c #0F1276",
-"~@ c #151793",
-"{@ c #1518AC",
-"]@ c #1314B2",
-"^@ c #1011A4",
-"/@ c #0D0D9C",
-"(@ c #0D0DA8",
-"_@ c #0D0EA2",
-":@ c #070954",
-"<@ c #000054",
-"[@ c #171A81",
-"}@ c #3941AA",
-"|@ c #3942B7",
-"1@ c #232BA8",
-"2@ c #575CAF",
-"3@ c #2E319C",
-"4@ c #3B41AC",
-"5@ c #5259BC",
-"6@ c #7580CE",
-"7@ c #9AA9E3",
-"8@ c #95A3EB",
-"9@ c #6973DF",
-"0@ c #3A40C7",
-"a@ c #2125AD",
-"b@ c #161797",
-"c@ c #0F1188",
-"d@ c #0B0D7A",
-"e@ c #0A0B71",
-"f@ c #0A0B70",
-"g@ c #0A0B75",
-"h@ c #0B0D82",
-"i@ c #3B2A90",
-"j@ c #744763",
-"k@ c #322684",
-"l@ c #131BC1",
-"m@ c #1618B6",
-"n@ c #0F10A4",
-"o@ c #0C0B93",
-"p@ c #0D0D94",
-"q@ c #0D0DAA",
-"r@ c #0D0DA0",
-"s@ c #090B5C",
-"t@ c #171A7F",
-"u@ c #3F47B7",
-"v@ c #383FC1",
-"w@ c #2A2FBA",
-"x@ c #3037BC",
-"y@ c #1F24A6",
-"z@ c #6569B4",
-"A@ c #2A2E99",
-"B@ c #3940AA",
-"C@ c #575FBE",
-"D@ c #6D76CC",
-"E@ c #828DD8",
-"F@ c #919FE1",
-"G@ c #95A3E3",
-"H@ c #8995E1",
-"I@ c #7984DC",
-"J@ c #6C76D9",
-"K@ c #5B64D3",
-"L@ c #4F57CF",
-"M@ c #464CCD",
-"N@ c #3F45C7",
-"O@ c #3C42C3",
-"P@ c #3D42C1",
-"Q@ c #2F3ECA",
-"R@ c #51489D",
-"S@ c #58426E",
-"T@ c #1C239E",
-"U@ c #12148D",
-"V@ c #090981",
-"W@ c #0A0A88",
-"X@ c #0D0D95",
-"Y@ c #0D0EAB",
-"Z@ c #0E109E",
-"`@ c #10126B",
-" # c #20239F",
-".# c #2D31BC",
-"+# c #2529B9",
-"@# c #2528BA",
-"## c #1F23B1",
-"$# c #24269F",
-"%# c #242896",
-"&# c #383EA9",
-"*# c #565DBC",
-"=# c #717BCF",
-"-# c #8E9BDC",
-";# c #97A5E1",
-"># c #8895DE",
-",# c #727CD8",
-"'# c #646CD3",
-")# c #626BCF",
-"!# c #636DCA",
-"~# c #626BC3",
-"{# c #5E66BA",
-"]# c #5960B5",
-"^# c #525AB0",
-"/# c #4E54AB",
-"(# c #3F4AAA",
-"_# c #4D4889",
-":# c #4E3961",
-"<# c #141A81",
-"[# c #0C117D",
-"}# c #0B0C78",
-"|# c #0D0D96",
-"1# c #0E109C",
-"2# c #14167C",
-"3# c #2125AF",
-"4# c #2226B9",
-"5# c #1D21B5",
-"6# c #252AB9",
-"7# c #2B2FBF",
-"8# c #262BBA",
-"9# c #0A0D9D",
-"0# c #252994",
-"a# c #333AA6",
-"b# c #545BBC",
-"c# c #747ECF",
-"d# c #96A3DF",
-"e# c #A3B2E6",
-"f# c #96A4E2",
-"g# c #7984DA",
-"h# c #6068D2",
-"i# c #535BCA",
-"j# c #4E55C2",
-"k# c #484FB9",
-"l# c #454CB1",
-"m# c #4147AB",
-"n# c #3D44A7",
-"o# c #343CA0",
-"p# c #20289D",
-"q# c #372E7E",
-"r# c #422C57",
-"s# c #080B76",
-"t# c #090972",
-"u# c #09097B",
-"v# c #0F10AC",
-"w# c #0F119E",
-"x# c #161986",
-"y# c #4145AC",
-"z# c #1D1D75",
-"A# c #181B87",
-"B# c #2C32B8",
-"C# c #1316AC",
-"D# c #4244A5",
-"E# c #2E3198",
-"F# c #2E34A4",
-"G# c #7580CF",
-"H# c #9AA7E0",
-"I# c #ACB8E8",
-"J# c #9DAAE3",
-"K# c #7D87DA",
-"L# c #636AD2",
-"M# c #545CCA",
-"N# c #4A51C0",
-"O# c #4046B6",
-"P# c #333AAC",
-"Q# c #2A30A4",
-"R# c #22269E",
-"S# c #1A1D97",
-"T# c #090E95",
-"U# c #291E76",
-"V# c #3F2851",
-"W# c #040770",
-"X# c #060871",
-"Y# c #090971",
-"Z# c #090985",
-"`# c #0C0C91",
-" $ c #1010AC",
-".$ c #0F119C",
-"+$ c #171A88",
-"@$ c #1417A6",
-"#$ c #292FB7",
-"$$ c #323381",
-"%$ c #090B7F",
-"&$ c #2027B6",
-"*$ c #2A2CA1",
-"=$ c #3C409F",
-"-$ c #272CA1",
-";$ c #7681D1",
-">$ c #9EAAE0",
-",$ c #B1BDE9",
-"'$ c #A2AFE5",
-")$ c #808CDB",
-"!$ c #646DD2",
-"~$ c #535AC9",
-"{$ c #474EBF",
-"]$ c #383FB4",
-"^$ c #282DA8",
-"/$ c #1A1C9E",
-"($ c #131399",
-"_$ c #0F1092",
-":$ c #020790",
-"<$ c #271871",
-"[$ c #3E254C",
-"}$ c #03066B",
-"|$ c #05076C",
-"1$ c #09096D",
-"2$ c #0C0C90",
-"3$ c #1213AF",
-"4$ c #0E0E98",
-"5$ c #0A0E81",
-"6$ c #2224AA",
-"7$ c #4D5098",
-"8$ c #07088C",
-"9$ c #3236AD",
-"0$ c #3940BC",
-"a$ c #1B1E9F",
-"b$ c #34389B",
-"c$ c #292FA2",
-"d$ c #545ABC",
-"e$ c #7782D0",
-"f$ c #A0ACE2",
-"g$ c #B5C0EA",
-"h$ c #A6B2E6",
-"i$ c #838FDC",
-"j$ c #666FD1",
-"k$ c #454CBF",
-"l$ c #353BB3",
-"m$ c #2325A7",
-"n$ c #16179D",
-"o$ c #101297",
-"p$ c #0C0F90",
-"q$ c #00018D",
-"r$ c #20126F",
-"s$ c #372048",
-"t$ c #000067",
-"u$ c #020468",
-"v$ c #070769",
-"w$ c #09097F",
-"x$ c #0C0B8E",
-"y$ c #1112AE",
-"z$ c #13149B",
-"A$ c #181B7F",
-"B$ c #434588",
-"C$ c #3D3F8E",
-"D$ c #101197",
-"E$ c #3035B2",
-"F$ c #4D54C3",
-"G$ c #1D20A1",
-"H$ c #36399B",
-"I$ c #2A30A2",
-"J$ c #535BBC",
-"K$ c #7783D0",
-"L$ c #A1ADE1",
-"M$ c #B8C1EB",
-"N$ c #A9B5E7",
-"O$ c #8592DD",
-"P$ c #6770D2",
-"Q$ c #343BB3",
-"R$ c #15189D",
-"S$ c #0E1296",
-"T$ c #06078E",
-"U$ c #00038A",
-"V$ c #6C5D7D",
-"W$ c #967A53",
-"X$ c #333068",
-"Y$ c #000065",
-"Z$ c #020366",
-"`$ c #09097E",
-" % c #0B0B8D",
-".% c #1011B3",
-"+% c #282988",
-"@% c #3C3D8F",
-"#% c #13149E",
-"$% c #2F35B7",
-"%% c #5861C8",
-"&% c #2427A4",
-"*% c #474AA4",
-"=% c #262BA1",
-"-% c #535ABC",
-";% c #A1AEE1",
-">% c #B9C0EB",
-",% c #ABB7E7",
-"'% c #8794DD",
-")% c #6972D2",
-"!% c #555CC9",
-"~% c #454DBF",
-"{% c #343CB3",
-"]% c #2327A7",
-"^% c #0E0F96",
-"/% c #000089",
-"(% c #62609E",
-"_% c #CDC18D",
-":% c #A49567",
-"<% c #E7D376",
-"[% c #57506A",
-"}% c #000064",
-"|% c #040471",
-"1% c #0C0C8E",
-"2% c #1213B7",
-"3% c #272A7A",
-"4% c #1314A2",
-"5% c #343ABC",
-"6% c #626DCC",
-"7% c #2529A6",
-"8% c #4245A1",
-"9% c #262BA0",
-"0% c #5259BB",
-"a% c #7681CF",
-"b% c #A1ACE1",
-"c% c #B9C1EB",
-"d% c #ADB9E7",
-"e% c #8A97DD",
-"f% c #6B75D3",
-"g% c #575FC9",
-"h% c #363CB4",
-"i% c #2427A8",
-"j% c #17199E",
-"k% c #000092",
-"l% c #33329C",
-"m% c #ECE4B3",
-"n% c #F9E78D",
-"o% c #E8D67D",
-"p% c #EEDA7C",
-"q% c #F5E17D",
-"r% c #61596F",
-"s% c #00006F",
-"t% c #06057E",
-"u% c #0D0E91",
-"v% c #1313B7",
-"w% c #131563",
-"x% c #1315A6",
-"y% c #3D45C1",
-"z% c #6873D1",
-"A% c #22259D",
-"B% c #5356A8",
-"C% c #22289D",
-"D% c #5058B9",
-"E% c #9FACE0",
-"F% c #B9C1EA",
-"G% c #AEB9E6",
-"H% c #8B98DD",
-"I% c #6C76D2",
-"J% c #5760C9",
-"K% c #484FBE",
-"L% c #373EB4",
-"M% c #262AA8",
-"N% c #0E0F9D",
-"O% c #151899",
-"P% c #CBCABE",
-"Q% c #FFFAAA",
-"R% c #E7D484",
-"S% c #E4D17C",
-"T% c #E0CE81",
-"U% c #FBE884",
-"V% c #AE9F74",
-"W% c #05056F",
-"X% c #00017E",
-"Y% c #1416B8",
-"Z% c #111371",
-"`% c #1417A7",
-" & c #5159C8",
-".& c #616CCF",
-"+& c #161980",
-"@& c #7B7EBC",
-"#& c #1B2196",
-"$& c #4E55B7",
-"%& c #737ECC",
-"&& c #B8C2EA",
-"*& c #AFBAE8",
-"=& c #8D99DC",
-"-& c #6D77D1",
-";& c #474FBE",
-">& c #262CA9",
-",& c #05089A",
-"'& c #3636A0",
-")& c #EEEABC",
-"!& c #F7E99D",
-"~& c #E5D381",
-"{& c #E4D27F",
-"]& c #E3D386",
-"^& c #F2DF86",
-"/& c #BAAA74",
-"(& c #0E0D71",
-"_& c #00007F",
-":& c #0F1099",
-"<& c #090949",
-"[& c #08092A",
-"}& c #121388",
-"|& c #6C79D2",
-"1& c #4B53C5",
-"2& c #070959",
-"3& c #212696",
-"4& c #4C53B3",
-"5& c #717CC9",
-"6& c #9CA9DC",
-"7& c #B8C1E8",
-"8& c #B0BAE4",
-"9& c #6D77D0",
-"0& c #575FC8",
-"a& c #474FBF",
-"b& c #383FB5",
-"c& c #272CAA",
-"d& c #06099B",
-"e& c #3030A0",
-"f& c #E6DFB4",
-"g& c #F5E594",
-"h& c #E5D586",
-"i& c #E4D48C",
-"j& c #EDDA85",
-"k& c #CDB96E",
-"l& c #181671",
-"m& c #000080",
-"n& c #10109A",
-"o& c #1314B7",
-"p& c #121391",
-"q& c #07081B",
-"r& c #02030E",
-"s& c #101268",
-"t& c #101295",
-"u& c #3A41BC",
-"v& c #727FD4",
-"w& c #2227AB",
-"x& c #272B97",
-"y& c #4A4FB0",
-"z& c #6F78C5",
-"A& c #99A6DA",
-"B& c #B5BFE6",
-"C& c #AEB8E4",
-"D& c #8D99DA",
-"E& c #6D76CE",
-"F& c #575EC5",
-"G& c #474EBD",
-"H& c #090B9B",
-"I& c #2D2D9E",
-"J& c #E4DAAB",
-"K& c #F5E38D",
-"L& c #E5D384",
-"M& c #E9D98F",
-"N& c #ECDE96",
-"O& c #EFDE88",
-"P& c #E2D06E",
-"Q& c #2A286F",
-"R& c #000082",
-"S& c #11119D",
-"T& c #1415B2",
-"U& c #141599",
-"V& c #0E1051",
-"W& c #03051D",
-"X& c #0D105C",
-"Y& c #13148B",
-"Z& c #1B1CA4",
-"`& c #626BCD",
-" * c #484FC4",
-".* c #0C0D7A",
-"+* c #232895",
-"@* c #454CAD",
-"#* c #6C75C1",
-"$* c #95A2D6",
-"%* c #B1BCE4",
-"&* c #ACB6E4",
-"** c #8C98D8",
-"=* c #6C75CC",
-"-* c #565DC3",
-";* c #474EBC",
-">* c #282CA9",
-",* c #090C9D",
-"'* c #27299B",
-")* c #DFD4A3",
-"!* c #EDDD90",
-"~* c #E7D78F",
-"{* c #D3BF7D",
-"]* c #CFB96D",
-"^* c #C5AD4E",
-"/* c #3F3A70",
-"(* c #000085",
-"_* c #11119F",
-":* c #161897",
-"<* c #161981",
-"[* c #0B0D5D",
-"}* c #0F127A",
-"|* c #16189A",
-"1* c #474DBD",
-"2* c #555DC9",
-"3* c #181CA7",
-"4* c #060735",
-"5* c #242799",
-"6* c #4248AA",
-"7* c #6771BD",
-"8* c #909CD1",
-"9* c #ACB6E0",
-"0* c #A8B3E1",
-"a* c #8A97D6",
-"b* c #6B75CA",
-"c* c #555DC0",
-"d* c #474EBA",
-"e* c #383FB2",
-"f* c #282DA9",
-"g* c #0B0E9D",
-"h* c #222499",
-"i* c #DED69F",
-"j* c #B69B52",
-"k* c #B49B5F",
-"l* c #B0985E",
-"m* c #967A44",
-"n* c #92763C",
-"o* c #B6983B",
-"p* c #574F73",
-"q* c #000087",
-"r* c #1111A1",
-"s* c #1316B1",
-"t* c #181B97",
-"u* c #1A1D8D",
-"v* c #0D0F68",
-"w* c #141786",
-"x* c #383FB0",
-"y* c #4B53C4",
-"z* c #2225B5",
-"A* c #0B0C5E",
-"B* c #000000",
-"C* c #212799",
-"D* c #3E45A7",
-"E* c #626AB9",
-"F* c #8894CD",
-"G* c #A0ADDB",
-"H* c #A0ADDA",
-"I* c #8794D2",
-"J* c #6973C5",
-"K* c #454BB6",
-"L* c #383EAF",
-"M* c #282CA6",
-"N* c #0B0E9B",
-"O* c #242596",
-"P* c #D8CA8F",
-"Q* c #9D7D3A",
-"R* c #7D5C2E",
-"S* c #967944",
-"T* c #C3AB6A",
-"U* c #987A3D",
-"V* c #A7852C",
-"W* c #5C5063",
-"X* c #00008C",
-"Y* c #1111A3",
-"Z* c #1315AF",
-"`* c #181993",
-" = c #1F22A1",
-".= c #1A1C8A",
-"+= c #2A2FA5",
-"@= c #2F36BA",
-"#= c #1B1EAD",
-"$= c #0B0D65",
-"%= c #010108",
-"&= c #212599",
-"*= c #3A40A5",
-"== c #5A63B4",
-"-= c #7D88C5",
-";= c #94A0D3",
-">= c #95A4D6",
-",= c #818ECD",
-"'= c #6670C0",
-")= c #525AB9",
-"!= c #444AB2",
-"~= c #363DAC",
-"{= c #272CA4",
-"]= c #0B0D99",
-"^= c #2A2A96",
-"/= c #BEAA72",
-"(= c #825D21",
-"_= c #81602E",
-":= c #8E6D36",
-"<= c #926F33",
-"[= c #C0A147",
-"}= c #C9AB41",
-"|= c #554C66",
-"1= c #00008B",
-"2= c #1011A6",
-"3= c #1313AE",
-"4= c #12137E",
-"5= c #1D1EA0",
-"6= c #2022AD",
-"7= c #1C1FA7",
-"8= c #12138B",
-"9= c #080947",
-"0= c #000002",
-"a= c #1E2292",
-"b= c #343AA3",
-"c= c #525AAE",
-"d= c #6F78BD",
-"e= c #8591C8",
-"f= c #8A95CD",
-"g= c #7983C7",
-"h= c #636BBD",
-"i= c #5057B5",
-"j= c #4349B0",
-"k= c #363CA9",
-"l= c #282BA1",
-"m= c #0A0C97",
-"n= c #252895",
-"o= c #BDA666",
-"p= c #DCC261",
-"q= c #DED282",
-"r= c #B9A86E",
-"s= c #92855F",
-"t= c #58514E",
-"u= c #222051",
-"v= c #040470",
-"w= c #08088B",
-"x= c #100FA9",
-"y= c #1012A8",
-"z= c #0D0E5B",
-"A= c #0D0E5F",
-"B= c #0C0E5C",
-"C= c #08093F",
-"D= c #01010E",
-"E= c #191C7E",
-"F= c #3035A5",
-"G= c #4A50A9",
-"H= c #626BB6",
-"I= c #757FBF",
-"J= c #7A85C2",
-"K= c #6F78BF",
-"L= c #5D64B6",
-"M= c #4D54B1",
-"N= c #4146AC",
-"O= c #343AA5",
-"P= c #252A9E",
-"Q= c #131595",
-"R= c #0D0F8C",
-"S= c #686286",
-"T= c #625C78",
-"U= c #1F1D63",
-"V= c #000057",
-"W= c #00005A",
-"X= c #00016C",
-"Y= c #07087E",
-"Z= c #0E0EB1",
-"`= c #0B0B7C",
-" - c #000102",
-".- c #121463",
-"+- c #4248A4",
-"@- c #565DAE",
-"#- c #646CB7",
-"$- c #6870B9",
-"%- c #636AB7",
-"&- c #555CB1",
-"*- c #484EAB",
-"=- c #3E44A7",
-"-- c #3238A3",
-";- c #24289C",
-">- c #171993",
-",- c #0C0E8A",
-"'- c #000073",
-")- c #00006B",
-"!- c #000167",
-"~- c #050567",
-"{- c #07086C",
-"]- c #0A0A75",
-"^- c #0A0A83",
-"/- c #0D0DB6",
-"(- c #07074F",
-"_- c #0E104E",
-":- c #2529A1",
-"<- c #393FA0",
-"[- c #4A51A8",
-"}- c #565EAF",
-"|- c #5B63B2",
-"1- c #575FB1",
-"2- c #4D54AD",
-"3- c #4248A7",
-"4- c #393EA4",
-"5- c #2F34A0",
-"6- c #222598",
-"7- c #141691",
-"8- c #0E1089",
-"9- c #0B0C7F",
-"0- c #08086C",
-"a- c #060667",
-"b- c #060668",
-"c- c #0B0B88",
-"d- c #0C0DB7",
-"e- c #050537",
-"f- c #03041D",
-"g- c #1C2093",
-"h- c #3138A4",
-"i- c #4047A2",
-"j- c #4950A9",
-"k- c #4E55AC",
-"l- c #4C53AB",
-"m- c #454BA9",
-"n- c #3B42A5",
-"o- c #3339A1",
-"p- c #2A2F9C",
-"q- c #1E2096",
-"r- c #13158F",
-"s- c #0D0F86",
-"t- c #0B0B7E",
-"u- c #0B0B8C",
-"v- c #0D0DAE",
-"w- c #0A0B93",
-"x- c #01010D",
-"y- c #0E0F4E",
-"z- c #272BA8",
-"A- c #353BA1",
-"B- c #3D45A1",
-"C- c #4248A5",
-"D- c #4147A7",
-"E- c #3C42A5",
-"F- c #353AA1",
-"G- c #2E339E",
-"H- c #252999",
-"I- c #1C1E94",
-"J- c #13148C",
-"K- c #0D0E83",
-"L- c #0C0B7B",
-"M- c #09096C",
-"N- c #0C0C9E",
-"O- c #040539",
-"P- c #0E1150",
-"Q- c #23279E",
-"R- c #2F34A3",
-"S- c #353C9F",
-"T- c #3238A1",
-"U- c #2D339D",
-"V- c #272A9A",
-"W- c #1F2196",
-"X- c #171991",
-"Y- c #111288",
-"Z- c #0C0D80",
-"`- c #090970",
-" ; c #090982",
-".; c #0B0B99",
-"+; c #0A0B99",
-"@; c #04043B",
-"#; c #060726",
-"$; c #151870",
-"%; c #212597",
-"&; c #282C9F",
-"*; c #262B9E",
-"=; c #24279B",
-"-; c #202397",
-";; c #1B1C93",
-">; c #0E1186",
-",; c #0C0D7F",
-"'; c #090980",
-"); c #080889",
-"!; c #090987",
-"~; c #070761",
-"{; c #020215",
-"]; c #050622",
-"^; c #0D0E4A",
-"/; c #131467",
-"(; c #16177F",
-"_; c #15188A",
-":; c #0F138A",
-"<; c #0C0E85",
-"[; c #0B0B81",
-"}; c #08087A",
-"|; c #07076F",
-"1; c #050540",
-"2; c #030318",
-"3; c #01020F",
-"4; c #02031B",
-"5; c #040524",
-"6; c #040526",
-"7; c #030427",
-"8; c #030327",
-"9; c #030322",
-"0; c #020318",
-"a; c #010100",
-" ",
-" ",
-" ",
-" . + @ # $ % & * = ",
-" - ; > , ' ) ! ~ { ] ^ / ( _ : < ",
-" [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h ",
-" i j k l m n o p q 6 r s t u v w x y z A B C D ",
-" E F G H I J K n I L M N O P Q R S T U V W X Y Z ` ",
-" ...+. at .#.$.I o %.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:. ",
-" <.[.K }.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l. ",
-" m.n.o.m p.q.r.r.s.r.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J. ",
-" K.L.M.N.O.P.Q.R.q.R.S.T.U.V.W.X.Y.Z.`. +.+++ at +#+$+%+&+ ",
-" *+=+-+;+>+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+1+2+3+4+5+6+ ",
-" 7+8+9+0+a+b+c+,+O.d+e+f+g+h+i+j+k+l+X.m+n+o+p+q+r+s+t+ ",
-" u+v+w+x+y+a+z+A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+ U+V+W+X+ ",
-" Y+Z+`+ @. at +@@@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@[@}@|@1 at 2@ ",
-" 3 at 4@5 at 6@7 at 8@9 at 0@a at b@c at d@e at f@g at h@i at j@k at l@m at n@o at M p at q@r at s@t at u@v at w@x at y@z@ ",
-" A at B@C at D@E at F@G at H@I at J@K at L@M at N@O at P@Q at R@S at T@U at 5 V at W@X at Y@Z@`@ #.#+#+#@###$# ",
-" %#&#*#=#-#;#>#,#'#)#!#~#{#]#^#/#(#_#:#<#[#}#$.W@|#Y at 1#2#3#4#5#6#7#8#9# ",
-" 0#a#b#c#d#e#f#g#h#i#j#k#l#m#n#o#p#q#r#s#g at t#u#W at X@v#w#x###+#y#z#A#B#C#D# ",
-" E#F#b#G#H#I#J#K#L#M#N#O#P#Q#R#S#T#U#V#W#X#Y#J Z#`# $.$+$@$#$ $$%$C.&$*$ ",
-" =$-$b#;$>$,$'$)$!$~${$]$^$/$($_$:$<$[$}$|$1$n V at 2$3$4$5$6$ 7$8$9$0$a$ ",
-" b$c$d$e$f$g$h$i$j$~$k$l$m$n$o$p$q$r$s$t$u$v$t#w$x$y$z$A$B$ C$D$E$F$G$ ",
-" H$I$J$K$L$M$N$O$P$~$k$Q$# R$S$T$U$V$W$X$Y$Z$Y#`$ %.%+% @%#%$%%%&% ",
-" *%=%-%e$;%>%,%'%)%!%~%{%]%R$^%/%(%_%:%<%[%}%|%o.1%2% 3%4%5%6%7% ",
-" 8%9%0%a%b%c%d%e%f%g%{$h%i%j%k%l%m%n%o%p%q%r%s%t%u%v% w%x%y%z%A% ",
-" B%C%D%6 at E%F%G%H%I%J%K%L%M%N%O%P%Q%R%S%T%U%V%W%X%^%Y% Z%`% &.&+& ",
-" @&#&$&%&>$&&*&=&-&g%;&]$>&,&'&)&!&~&{&]&^&/&(&_&:&Y%<& [&}&K.|&1&2& ",
-" 3&4&5&6&7&8&=&9&0&a&b&c&d&e&f&g&~&h&i&j&k&l&m&n&o&p&q& r&s&t&u&v&w& ",
-" x&y&z&A&B&C&D&E&F&G&]$% H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&`& *.* ",
-" +*@*#*$*%*&***=*-*;*]$>*,*'*)*n%!*~*{*]*^*/*(*_*T&:*<*[*}*|*1*2*3*4* ",
-" 5*6*7*8*9*0*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*A*B*B* ",
-" C*D*E*F*G*H*I*J*b#K*L*M*N*O*P*Q*R*S*T*U*V*W*X*Y*Z*`* =.=+=@=#=$=%=B* ",
-" &=*===-=;=>=,='=)=!=~={=]=^=/=(=_=:=<=[=}=|=1=2=3=4=5=6=7=8=9=0=B* ",
-" a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z=A=B=C=D=B*B* ",
-" E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=T=U=V=<@W=X=Y=1%Z=`= -B*B*B*B*B* ",
-" .-Q#+- at -#-$-%-&-*-=---;->-,-_&'-)-!-~-{-]-^-X@/-(-B*B*B*B* ",
-" _-:-<-[-}-|-1-2-3-4-5-6-7-8-9-n 0-a-b-1$J c-/@d-e-B*B*B* ",
-" f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-o 0-v$0-t#`$u-v-w-x-B*B* ",
-" y-z-A-B-C-D-E-F-G-H-I-J-K-L-t#M-1$+.J ^-N-v-O-B* ",
-" P-Q-R-S-A-T-U-V-W-X-Y-Z-}#t#+.`-K ;.;+;@;B* ",
-" #;$;%;&;*;=;-;;;9+>;,;*.K I ';);!;~;{;B* ",
-" ];^;/;(;_;J-:;<;[;#.};|;P.1;2;B* ",
-" 3;4;5;6;7;8;9;0;x-a; ",
-" ",
-" ",
-" ",
-" "};
diff --git a/engines/ags/engine/platform/linux/acpllnx.cpp b/engines/ags/engine/platform/scummvm/scummvm_platform_driver.cpp
similarity index 69%
rename from engines/ags/engine/platform/linux/acpllnx.cpp
rename to engines/ags/engine/platform/scummvm/scummvm_platform_driver.cpp
index 063e3a5796..9b8eb99bbe 100644
--- a/engines/ags/engine/platform/linux/acpllnx.cpp
+++ b/engines/ags/engine/platform/scummvm/scummvm_platform_driver.cpp
@@ -23,9 +23,7 @@
#include "ags/shared/core/platform.h"
#include "ags/ags.h"
-#if AGS_PLATFORM_OS_LINUX
-
-// ********* LINUX PLACEHOLDER DRIVER *********
+#if AGS_PLATFORM_SCUMMVM
#include "ags/lib/allegro.h"
#include "ags/engine/ac/runtime_defines.h"
@@ -38,8 +36,7 @@ namespace AGS3 {
using AGS::Shared::String;
-struct AGSLinux : AGSPlatformDriver {
-
+struct ScummVMPlatformDriver : AGSPlatformDriver {
int CDPlayerCommand(int cmdd, int datt) override;
void DisplayAlert(const char *, ...) override;
const char *GetAllUsersDataDirectory() override;
@@ -61,13 +58,13 @@ struct AGSLinux : AGSPlatformDriver {
};
-int AGSLinux::CDPlayerCommand(int cmdd, int datt) {
+int ScummVMPlatformDriver::CDPlayerCommand(int cmdd, int datt) {
warning("CDPlayerCommand(%d,%d)", cmdd, datt);
//return cd_player_control(cmdd, datt);
return 0;
}
-void AGSLinux::DisplayAlert(const char *text, ...) {
+void ScummVMPlatformDriver::DisplayAlert(const char *text, ...) {
va_list ap;
va_start(ap, text);
Common::String msg = Common::String::vformat(text, ap);
@@ -79,83 +76,74 @@ void AGSLinux::DisplayAlert(const char *text, ...) {
::AGS::g_vm->GUIError(msg);
}
-const char *AGSLinux::GetAllUsersDataDirectory() {
+const char *ScummVMPlatformDriver::GetAllUsersDataDirectory() {
return "";
}
-const char *AGSLinux::GetUserSavedgamesDirectory() {
+const char *ScummVMPlatformDriver::GetUserSavedgamesDirectory() {
return "";
}
-const char *AGSLinux::GetUserConfigDirectory() {
+const char *ScummVMPlatformDriver::GetUserConfigDirectory() {
return GetUserSavedgamesDirectory();
}
-const char *AGSLinux::GetUserGlobalConfigDirectory() {
+const char *ScummVMPlatformDriver::GetUserGlobalConfigDirectory() {
return GetUserSavedgamesDirectory();
}
-const char *AGSLinux::GetAppOutputDirectory() {
+const char *ScummVMPlatformDriver::GetAppOutputDirectory() {
return "";
}
-unsigned long AGSLinux::GetDiskFreeSpaceMB() {
+unsigned long ScummVMPlatformDriver::GetDiskFreeSpaceMB() {
// placeholder
return 100;
}
-const char *AGSLinux::GetNoMouseErrorString() {
- return "This game requires a _GP(mouse). You need to configure and setup your mouse to play this game.\n";
+const char *ScummVMPlatformDriver::GetNoMouseErrorString() {
+ return "This game requires a mouse. You need to configure and setup your mouse to play this game.\n";
}
-const char *AGSLinux::GetAllegroFailUserHint() {
+const char *ScummVMPlatformDriver::GetAllegroFailUserHint() {
return nullptr;
}
-eScriptSystemOSID AGSLinux::GetSystemOSID() {
+eScriptSystemOSID ScummVMPlatformDriver::GetSystemOSID() {
return eOS_Linux;
}
-int AGSLinux::InitializeCDPlayer() {
+int ScummVMPlatformDriver::InitializeCDPlayer() {
//return cd_player_init();
return 0;
}
-void AGSLinux::PostAllegroExit() {
+void ScummVMPlatformDriver::PostAllegroExit() {
// do nothing
}
-void AGSLinux::SetGameWindowIcon() {
+void ScummVMPlatformDriver::SetGameWindowIcon() {
// do nothing
}
-void AGSLinux::ShutdownCDPlayer() {
+void ScummVMPlatformDriver::ShutdownCDPlayer() {
//cd_exit();
}
AGSPlatformDriver *AGSPlatformDriver::GetDriver() {
if (instance == nullptr)
- instance = new AGSLinux();
+ instance = new ScummVMPlatformDriver();
return instance;
}
-bool AGSLinux::LockMouseToWindow() {
-#if 0
- return XGrabPointer(_xwin.display, _xwin.window, False,
- PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
- GrabModeAsync, GrabModeAsync, _xwin.window, None, CurrentTime) == GrabSuccess;
-#else
+bool ScummVMPlatformDriver::LockMouseToWindow() {
return false;
-#endif
}
-void AGSLinux::UnlockMouse() {
-#if 0
- XUngrabPointer(_xwin.display, CurrentTime);
-#endif
+void ScummVMPlatformDriver::UnlockMouse() {
}
-void AGSLinux::GetSystemDisplayModes(std::vector<Engine::DisplayMode> &dms) {
+void ScummVMPlatformDriver::GetSystemDisplayModes(std::vector<Engine::DisplayMode> &dms) {
dms.clear();
GFX_MODE_LIST *gmlist = get_gfx_mode_list(GFX_SCUMMVM_FULLSCREEN);
for (int i = 0; i < gmlist->num_modes; ++i) {
diff --git a/engines/ags/module.mk b/engines/ags/module.mk
index de0832c918..979348db6b 100644
--- a/engines/ags/module.mk
+++ b/engines/ags/module.mk
@@ -272,7 +272,7 @@ MODULE_OBJS = \
engine/media/audio/soundclip.o \
engine/media/video/video.o \
engine/platform/base/agsplatformdriver.o \
- engine/platform/linux/acpllnx.o \
+ engine/platform/scummvm/scummvm_platform_driver.o \
engine/script/cc_instance.o \
engine/script/executingscript.o \
engine/script/exports.o \
More information about the Scummvm-git-logs
mailing list