blob: 1536ccb7364be47445ba5f9f237f119d5e38f2e3 [file] [log] [blame]
diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp
--- a/backends/platform/sdl/posix/posix-main.cpp
+++ b/backends/platform/sdl/posix/posix-main.cpp
@@ -20,6 +20,13 @@
*
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_vprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
+#define FORBIDDEN_SYMBOL_EXCEPTION_setenv
+#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
+
#include "common/scummsys.h"
#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(MAEMO) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3)
@@ -28,7 +35,85 @@
#include "backends/plugins/sdl/sdl-provider.h"
#include "base/main.h"
+#if defined(NACL)
+#include <fcntl.h>
+#include <libtar.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <SDL/SDL_main.h>
+
+#include "nacl_io/nacl_io.h"
+#endif
+
+#if defined(NACL)
+
+#define CHECK(x) \
+ ret = x; \
+ if (ret != 0) \
+ perror(#x " failed"); \
+ assert(ret == 0) \
+
+void ExtractAll(const char* data_file) {
+ printf("Extracting: %s ...\n", data_file);
+ TAR* tar;
+ int ret;
+ CHECK(tar_open(&tar, const_cast<char*>(data_file), NULL, O_RDONLY, 0, 0));
+ CHECK(tar_extract_all(tar, const_cast<char*>("/")));
+ CHECK(tar_close(tar));
+}
+
+void CopyFile(const char* src, const char* dst) {
+ const size_t kBufferSize = 1024;
+ char buffer[kBufferSize];
+
+ int src_fd = open(src, O_RDONLY);
+ assert(src_fd != -1);
+ int dst_fd = open(dst, O_WRONLY | O_CREAT);
+ assert(dst_fd != -1);
+
+ int bytes_read;
+ int write_offset;
+ do {
+ bytes_read = read(src_fd, &buffer[0], kBufferSize);
+ assert(bytes_read >= 0);
+ int bytes_to_write = bytes_read;
+
+ write_offset = 0;
+ while (bytes_to_write > 0) {
+ int bytes_written = write(dst_fd, &buffer[write_offset], bytes_to_write);
+ assert(bytes_written >= 0);
+ bytes_to_write -= bytes_written;
+ write_offset += bytes_written;
+ }
+ } while(bytes_read > 0);
+
+ close(src_fd);
+ close(dst_fd);
+}
+
+bool FileExists(const char* path) {
+ struct stat buf;
+ return stat(path, &buf) == 0;
+}
+
+int SDL_main(int argc, char *argv[]) {
+ int ret;
+
+ ExtractAll("/mnt/http/runimage.tar");
+ ExtractAll("/mnt/http/bass.tar");
+ ExtractAll("/mnt/http/lure.tar");
+
+ const char kConfigFile[] = "/home/user/.scummvmrc";
+ if (!FileExists(kConfigFile)) {
+ // Initialize with a default .scummvmrm that already has the
+ // games loaded.
+ CopyFile("/mnt/http/scummvmrc", kConfigFile);
+ }
+#else
int main(int argc, char *argv[]) {
+#endif
// Create our OSystem instance
g_system = new OSystem_POSIX();
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -161,6 +161,9 @@ Common::WriteStream *OSystem_POSIX::createLogFile() {
}
bool OSystem_POSIX::displayLogFile() {
+#ifdef NACL
+ return false;
+#else
if (_logFilePath.empty())
return false;
@@ -209,6 +212,7 @@ bool OSystem_POSIX::displayLogFile() {
}
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
+#endif
}
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1374,6 +1374,16 @@ n64)
_host_cpu=mips
_host_alias=mips64
;;
+nacl-x86)
+ _host_os=nacl
+ _host_cpu=x86
+ _host_alias=${NACL_CROSS_PREFIX}
+ ;;
+nacl-arm)
+ _host_os=nacl
+ _host_cpu=arm
+ _host_alias=${NACL_CROSS_PREFIX}
+ ;;
neuros)
_host_os=linux
_host_cpu=arm
@@ -1383,6 +1393,11 @@ openpandora)
_host_cpu=arm
_host_alias=arm-angstrom-linux-gnueabi
;;
+pnacl)
+ _host_os=pnacl
+ _host_cpu=le32
+ _host_alias=${NACL_CROSS_PREFIX}
+ ;;
ppc-amigaos)
_host_os=amigaos
_host_cpu=ppc
@@ -1783,7 +1798,7 @@ if test "$have_gcc" = yes ; then
case $_host_os in
# newlib-based system include files suppress non-C89 function
# declarations under __STRICT_ANSI__
- amigaos* | android | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | ps3 | tizen | wii | wince )
+ amigaos* | android | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | ps3 | tizen | wii | wince | *nacl* )
;;
*)
CXXFLAGS="$CXXFLAGS -ansi"
@@ -1870,6 +1885,8 @@ if $_strings $TMPO.o | grep BIGenDianSyS >/dev/null; then
_endian=big
elif $_strings $TMPO.o | grep LiTTleEnDian >/dev/null; then
_endian=little
+elif [ "$_host_cpu" = "le32" ]; then
+ _endian=little
fi
echo $_endian;
cc_check_clean tmp_endianness_check.cpp
@@ -2027,10 +2044,12 @@ echo_n "Checking host CPU architecture... "
case $_host_cpu in
arm*)
echo "ARM"
- define_in_config_if_yes yes 'USE_ARM_SCALER_ASM'
- define_in_config_if_yes yes 'USE_ARM_SOUND_ASM'
- define_in_config_if_yes yes 'USE_ARM_SMUSH_ASM'
- define_in_config_if_yes yes 'USE_ARM_GFX_ASM'
+ if [ ! $_host_os = "nacl" ]; then
+ define_in_config_if_yes yes 'USE_ARM_SCALER_ASM'
+ define_in_config_if_yes yes 'USE_ARM_SOUND_ASM'
+ define_in_config_if_yes yes 'USE_ARM_SMUSH_ASM'
+ define_in_config_if_yes yes 'USE_ARM_GFX_ASM'
+ fi
# FIXME: The following feature exhibits a bug during the intro scene of Indy 4
# (on Pandora and iPhone at least)
#define_in_config_if_yes yes 'USE_ARM_COSTUME_ASM'
@@ -2053,6 +2072,9 @@ case $_host_cpu in
amd64 | x86_64)
echo "x86_64"
;;
+ le32)
+ echo "Generic le32"
+ ;;
*)
echo "unknown ($_host_cpu)"
;;
@@ -3103,7 +3125,7 @@ case $_host_os in
amigaos* | cygwin* | dreamcast | ds | gamecube | mingw* | n64 | ps2 | ps3 | psp | wii | wince)
_posix=no
;;
- android | beos* | bsd* | darwin* | freebsd* | gnu* | gph-linux | haiku* | hpux* | iphone | irix*| k*bsd*-gnu* | linux* | maemo | mint* | netbsd* | openbsd* | solaris* | sunos* | uclinux* | webos)
+ android | beos* | bsd* | darwin* | freebsd* | gnu* | gph-linux | haiku* | hpux* | iphone | irix*| k*bsd*-gnu* | linux* | maemo | mint* | netbsd* | openbsd* | solaris* | sunos* | uclinux* | webos | *nacl* )
_posix=yes
;;
os2-emx*)
diff --git a/graphics/scaler/scale2x.cpp b/graphics/scaler/scale2x.cpp
--- a/graphics/scaler/scale2x.cpp
+++ b/graphics/scaler/scale2x.cpp
@@ -201,9 +201,15 @@ static inline void scale2x_8_mmx_single(scale2x_uint8* dst, const scale2x_uint8*
"0:\n"
/* set the current, current_pre, current_next registers */
+#if defined(__x86_64__)
+ "movq %%nacl:-8(%%r15,%q1), %%mm0\n"
+ "movq %%nacl:(%%r15,%q1), %%mm7\n"
+ "movq %%nacl:8(%%r15,%q1), %%mm1\n"
+#else
"movq -8(%1), %%mm0\n"
"movq (%1), %%mm7\n"
"movq 8(%1), %%mm1\n"
+#endif
"psrlq $56, %%mm0\n"
"psllq $56, %%mm1\n"
"movq %%mm7, %%mm2\n"
@@ -214,7 +220,11 @@ static inline void scale2x_8_mmx_single(scale2x_uint8* dst, const scale2x_uint8*
"por %%mm3, %%mm1\n"
/* current_upper */
+#if defined(__x86_64__)
+ "movq %%nacl:(%%r15,%q0), %%mm6\n"
+#else
"movq (%0), %%mm6\n"
+#endif
/* compute the upper-left pixel for dst on %%mm2 */
/* compute the upper-right pixel for dst on %%mm4 */
@@ -224,8 +234,13 @@ static inline void scale2x_8_mmx_single(scale2x_uint8* dst, const scale2x_uint8*
"movq %%mm1, %%mm5\n"
"pcmpeqb %%mm6, %%mm2\n"
"pcmpeqb %%mm6, %%mm4\n"
+#if defined(__x86_64__)
+ "pcmpeqb %%nacl:(%%r15,%q2), %%mm3\n"
+ "pcmpeqb %%nacl:(%%r15,%q2), %%mm5\n"
+#else
"pcmpeqb (%2), %%mm3\n"
"pcmpeqb (%2), %%mm5\n"
+#endif
"pandn %%mm2, %%mm3\n"
"pandn %%mm4, %%mm5\n"
"movq %%mm0, %%mm2\n"
@@ -247,8 +262,13 @@ static inline void scale2x_8_mmx_single(scale2x_uint8* dst, const scale2x_uint8*
"movq %%mm2, %%mm3\n"
"punpcklbw %%mm4, %%mm2\n"
"punpckhbw %%mm4, %%mm3\n"
+#if defined(__x86_64__)
+ "movq %%mm2, %%nacl:(%%r15,%q3)\n"
+ "movq %%mm3, %%nacl:8(%%r15,%q3)\n"
+#else
"movq %%mm2, (%3)\n"
"movq %%mm3, 8(%3)\n"
+#endif
/* next */
"add $8, %0\n"
@@ -278,9 +298,15 @@ static inline void scale2x_16_mmx_single(scale2x_uint16* dst, const scale2x_uint
"0:\n"
/* set the current, current_pre, current_next registers */
+#if defined(__x86_64__)
+ "movq %%nacl:-8(%%r15,%q1), %%mm0\n"
+ "movq %%nacl:(%%r15,%q1), %%mm7\n"
+ "movq %%nacl:8(%%r15,%q1), %%mm1\n"
+#else
"movq -8(%1), %%mm0\n"
"movq (%1), %%mm7\n"
"movq 8(%1), %%mm1\n"
+#endif
"psrlq $48, %%mm0\n"
"psllq $48, %%mm1\n"
"movq %%mm7, %%mm2\n"
@@ -291,7 +317,11 @@ static inline void scale2x_16_mmx_single(scale2x_uint16* dst, const scale2x_uint
"por %%mm3, %%mm1\n"
/* current_upper */
+#if defined(__x86_64__)
+ "movq %%nacl:(%%r15,%q0), %%mm6\n"
+#else
"movq (%0), %%mm6\n"
+#endif
/* compute the upper-left pixel for dst on %%mm2 */
/* compute the upper-right pixel for dst on %%mm4 */
@@ -301,8 +331,13 @@ static inline void scale2x_16_mmx_single(scale2x_uint16* dst, const scale2x_uint
"movq %%mm1, %%mm5\n"
"pcmpeqw %%mm6, %%mm2\n"
"pcmpeqw %%mm6, %%mm4\n"
+#if defined(__x86_64__)
+ "pcmpeqw %%nacl:(%%r15,%q2), %%mm3\n"
+ "pcmpeqw %%nacl:(%%r15,%q2), %%mm5\n"
+#else
"pcmpeqw (%2), %%mm3\n"
"pcmpeqw (%2), %%mm5\n"
+#endif
"pandn %%mm2, %%mm3\n"
"pandn %%mm4, %%mm5\n"
"movq %%mm0, %%mm2\n"
@@ -324,8 +359,13 @@ static inline void scale2x_16_mmx_single(scale2x_uint16* dst, const scale2x_uint
"movq %%mm2, %%mm3\n"
"punpcklwd %%mm4, %%mm2\n"
"punpckhwd %%mm4, %%mm3\n"
+#if defined(__x86_64__)
+ "movq %%mm2, %%nacl:(%%r15,%q3)\n"
+ "movq %%mm3, %%nacl:8(%%r15,%q3)\n"
+#else
"movq %%mm2, (%3)\n"
"movq %%mm3, 8(%3)\n"
+#endif
/* next */
"add $8, %0\n"
@@ -355,9 +395,15 @@ static inline void scale2x_32_mmx_single(scale2x_uint32* dst, const scale2x_uint
"0:\n"
/* set the current, current_pre, current_next registers */
+#if defined(__x86_64__)
+ "movq %%nacl:-8(%%r15,%q1), %%mm0\n"
+ "movq %%nacl:(%%r15,%q1), %%mm7\n"
+ "movq %%nacl:8(%%r15,%q1), %%mm1\n"
+#else
"movq -8(%1), %%mm0\n"
"movq (%1), %%mm7\n"
"movq 8(%1), %%mm1\n"
+#endif
"psrlq $32, %%mm0\n"
"psllq $32, %%mm1\n"
"movq %%mm7, %%mm2\n"
@@ -368,7 +414,11 @@ static inline void scale2x_32_mmx_single(scale2x_uint32* dst, const scale2x_uint
"por %%mm3, %%mm1\n"
/* current_upper */
+#if defined(__x86_64__)
+ "movq %%nacl:(%%r15,%q0), %%mm6\n"
+#else
"movq (%0), %%mm6\n"
+#endif
/* compute the upper-left pixel for dst on %%mm2 */
/* compute the upper-right pixel for dst on %%mm4 */
@@ -378,8 +428,13 @@ static inline void scale2x_32_mmx_single(scale2x_uint32* dst, const scale2x_uint
"movq %%mm1, %%mm5\n"
"pcmpeqd %%mm6, %%mm2\n"
"pcmpeqd %%mm6, %%mm4\n"
+#if defined(__x86_64__)
+ "pcmpeqd %%nacl:(%%r15,%q2), %%mm3\n"
+ "pcmpeqd %%nacl:(%%r15,%q2), %%mm5\n"
+#else
"pcmpeqd (%2), %%mm3\n"
"pcmpeqd (%2), %%mm5\n"
+#endif
"pandn %%mm2, %%mm3\n"
"pandn %%mm4, %%mm5\n"
"movq %%mm0, %%mm2\n"
@@ -401,8 +456,13 @@ static inline void scale2x_32_mmx_single(scale2x_uint32* dst, const scale2x_uint
"movq %%mm2, %%mm3\n"
"punpckldq %%mm4, %%mm2\n"
"punpckhdq %%mm4, %%mm3\n"
+#if defined(__x86_64__)
+ "movq %%mm2, %%nacl:(%%r15,%q3)\n"
+ "movq %%mm3, %%nacl:8(%%r15,%q3)\n"
+#else
"movq %%mm2, (%3)\n"
"movq %%mm3, 8(%3)\n"
+#endif
/* next */
"add $8, %0\n"