aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorTravis Howell2009-06-06 00:10:40 +0000
committerTravis Howell2009-06-06 00:10:40 +0000
commit8ff3a568fa8fe564749080a9af5e20b897933d93 (patch)
tree3136763937adc1fb6bcd30993b00d1476f490b6f /backends
parentd65bbe1d7a5efbcf04831dbb68a45ca833db1ae1 (diff)
parentda36901b0751b9d4faaae30dce230b67d75e04e6 (diff)
downloadscummvm-rg350-8ff3a568fa8fe564749080a9af5e20b897933d93.tar.gz
scummvm-rg350-8ff3a568fa8fe564749080a9af5e20b897933d93.tar.bz2
scummvm-rg350-8ff3a568fa8fe564749080a9af5e20b897933d93.zip
Merged revisions 41154-41156,41160,41163-41181,41185-41186,41188-41189,41196-41202 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk ........ r41154 | thebluegr | 2009-06-04 18:25:48 +1000 (Thu, 04 Jun 2009) | 1 line Turned debug_weak_validations on by default again, as apparently some games like SQ3 fail in some validations (e.g. when loading). Also, fixed a potential out of bounds access when copying the value of __FILE__ into a buffer (as its value can be quite long in some cases). ........ r41155 | thebluegr | 2009-06-04 18:28:20 +1000 (Thu, 04 Jun 2009) | 1 line Reordered the numpad keys so that they make more sense, and simplified the code which returns the values of shifted function keys ........ r41156 | djwillis | 2009-06-04 18:30:31 +1000 (Thu, 04 Jun 2009) | 1 line Initial import of the GP2XWiz backend (based on the GP2X and SDL backends). Includes configure changes and one #ifdef to SDL backend. Also updates NEWS. ........ r41160 | strangerke | 2009-06-04 19:48:56 +1000 (Thu, 04 Jun 2009) | 1 line gob : _spriteBottom incorrectly saved and restored in Draw_v2::spriteOperation ........ r41163 | fingolfin | 2009-06-04 21:28:05 +1000 (Thu, 04 Jun 2009) | 1 line SCI: Renamed various debug related global variables to have a g_ prefix; and moved any 'extern' decls of them into a new header file ........ r41164 | waltervn | 2009-06-04 21:35:17 +1000 (Thu, 04 Jun 2009) | 2 lines SCI: Support for 16-bit DPCM. ........ r41165 | fingolfin | 2009-06-04 21:44:55 +1000 (Thu, 04 Jun 2009) | 1 line SCI: cleanup ........ r41166 | fingolfin | 2009-06-04 21:45:17 +1000 (Thu, 04 Jun 2009) | 1 line SCI: Moved MemObject code into a separate source file ........ r41167 | fingolfin | 2009-06-04 21:45:34 +1000 (Thu, 04 Jun 2009) | 1 line Code formatting in the gp2xwiz backend ........ r41168 | thebluegr | 2009-06-04 22:47:11 +1000 (Thu, 04 Jun 2009) | 1 line Updated the MSVC project files of the SCI engine ........ r41169 | waltervn | 2009-06-05 00:29:20 +1000 (Fri, 05 Jun 2009) | 2 lines SCI: Message: Added support for escape sequences. ........ r41170 | waltervn | 2009-06-05 01:56:11 +1000 (Fri, 05 Jun 2009) | 2 lines SCI: Added support for early SCI1.1 audio maps. ........ r41171 | waltervn | 2009-06-05 02:18:35 +1000 (Fri, 05 Jun 2009) | 2 lines SCI: Audio: Fixed bug in reading of SOL header. ........ r41172 | fingolfin | 2009-06-05 06:50:51 +1000 (Fri, 05 Jun 2009) | 1 line SCI: Added FIXME comment to not_register() ........ r41173 | fingolfin | 2009-06-05 06:51:09 +1000 (Fri, 05 Jun 2009) | 1 line SCI: cleanup ........ r41174 | fingolfin | 2009-06-05 06:51:24 +1000 (Fri, 05 Jun 2009) | 1 line SCI: Slightly modified kAddAfter so that it does not modify its arguments needlessly ........ r41175 | fingolfin | 2009-06-05 06:51:40 +1000 (Fri, 05 Jun 2009) | 1 line SCI: Added MemObject::isValidOffset method; use it to simplify determine_reg_type ........ r41176 | fingolfin | 2009-06-05 07:42:24 +1000 (Fri, 05 Jun 2009) | 1 line SCI: Renamed _kfuncTable -> _kernelFuncs; and simplified/streamlined the kernel func map in kernel.cpp a bit ........ r41177 | fingolfin | 2009-06-05 07:44:39 +1000 (Fri, 05 Jun 2009) | 1 line SCI: Renamed EngineState::flags and version to _flags and _version (following our conventions); also slightly changed the EngineState constructor to init _version & _flags, and used this to make them constant ........ r41178 | fingolfin | 2009-06-05 07:53:45 +1000 (Fri, 05 Jun 2009) | 1 line oops ........ r41179 | athrxx | 2009-06-05 08:12:13 +1000 (Fri, 05 Jun 2009) | 1 line LOL: implemented Vaelan's cube ........ r41180 | fingolfin | 2009-06-05 08:16:31 +1000 (Fri, 05 Jun 2009) | 1 line SCI: Made some members of class Resource protected; some cleanup ........ r41181 | waltervn | 2009-06-05 09:55:08 +1000 (Fri, 05 Jun 2009) | 3 lines SCI: Fixed some endian bugs related to speech handling. READ_UINT* are not LE, but use native endianness. Thanks to clone2727 for pointing this out. ........ r41185 | Kirben | 2009-06-05 10:57:58 +1000 (Fri, 05 Jun 2009) | 1 line Update sound code in HE80+ games, for sound rate differences. ........ r41186 | waltervn | 2009-06-05 11:12:52 +1000 (Fri, 05 Jun 2009) | 2 lines SCI: Audio: Fixed bug in sample length computation. ........ r41188 | Kirben | 2009-06-05 12:35:38 +1000 (Fri, 05 Jun 2009) | 1 line Fix issues selecting some items in arttime and football. ........ r41189 | Kirben | 2009-06-05 14:16:32 +1000 (Fri, 05 Jun 2009) | 1 line Minor cleanup. ........ r41196 | dreammaster | 2009-06-05 22:20:42 +1000 (Fri, 05 Jun 2009) | 1 line Tweaks to the code that pauses for a mouse press when displaying many text messages ........ r41197 | thebluegr | 2009-06-06 04:05:45 +1000 (Sat, 06 Jun 2009) | 1 line Removed some unused code and performed some cleanup ........ r41198 | thebluegr | 2009-06-06 05:04:14 +1000 (Sat, 06 Jun 2009) | 1 line Moved some more debug commands to ScummVM's coneole and removed some unused code ........ r41199 | athrxx | 2009-06-06 07:34:18 +1000 (Sat, 06 Jun 2009) | 1 line LOL: implemented another opcode ........ r41200 | mthreepwood | 2009-06-06 08:35:13 +1000 (Sat, 06 Jun 2009) | 1 line Make the PlayStation's abbreviation to all lower-case for consistency and change the description from Playstation to Sony PlayStation ........ r41201 | athrxx | 2009-06-06 08:53:36 +1000 (Sat, 06 Jun 2009) | 1 line LOL: minor bug fix ........ r41202 | thebluegr | 2009-06-06 09:08:35 +1000 (Sat, 06 Jun 2009) | 1 line Cleanup ........ svn-id: r41206
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/gp2xwiz/build/README-GP2XWIZ141
-rwxr-xr-xbackends/platform/gp2xwiz/build/build.sh19
-rwxr-xr-xbackends/platform/gp2xwiz/build/bundle.sh45
-rwxr-xr-xbackends/platform/gp2xwiz/build/clean.sh8
-rwxr-xr-xbackends/platform/gp2xwiz/build/config-alleng.sh22
-rwxr-xr-xbackends/platform/gp2xwiz/build/config.sh22
-rwxr-xr-xbackends/platform/gp2xwiz/build/scummvm.gpe11
-rw-r--r--backends/platform/gp2xwiz/build/scummvm.ini4
-rw-r--r--backends/platform/gp2xwiz/build/scummvm.pngbin0 -> 2810 bytes
-rw-r--r--backends/platform/gp2xwiz/gp2xwiz-events.cpp462
-rw-r--r--backends/platform/gp2xwiz/gp2xwiz-graphics.cpp33
-rw-r--r--backends/platform/gp2xwiz/gp2xwiz-hw.cpp74
-rw-r--r--backends/platform/gp2xwiz/gp2xwiz-hw.h73
-rw-r--r--backends/platform/gp2xwiz/gp2xwiz-main.cpp216
-rw-r--r--backends/platform/gp2xwiz/gp2xwiz-sdl.h62
-rw-r--r--backends/platform/gp2xwiz/module.mk16
-rw-r--r--backends/platform/sdl/main.cpp2
17 files changed, 1209 insertions, 1 deletions
diff --git a/backends/platform/gp2xwiz/build/README-GP2XWIZ b/backends/platform/gp2xwiz/build/README-GP2XWIZ
new file mode 100644
index 0000000000..95ac844a2c
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/README-GP2XWIZ
@@ -0,0 +1,141 @@
+ScummVM - GP2X WIZ SPECIFIC README - HEAD SVN
+------------------------------------------------------------------------
+
+Contents:
+
+ * About the backend/port <#About_the_backendport>
+ * Game compatability <#Game_compatibility>
+ * Included engines <#Included_engines>
+ * Supported audio options <#Supported_audio_options>
+ * Supported cut-scene options <#Supported_cut-scene_options>
+ * Recent changes <#Recent_changes>
+ * How to save <#How_to_save>
+ * Controller mappings <#Controller_mappings>
+ * Know issues <#Know_issues>
+ * Major TODO's <#Major_TODOs>
+ * Additional resources/links <#Additional_resourceslinks>
+ * Credits <#Credits>
+
+
+------------------------------------------------------------------------
+About the backend/port
+
+This is the readme for the offficial GP2X WIZ ScummVM backend (also known as
+the GP2X WIZ port).
+
+This is an SVN test release of ScummVM for the GP2X WIZ, it would be
+appreciated if this SVN test distribution was not mirrored and that
+people be directed to http://scummvm.distant-earth.com/ instead for
+updated SVN builds.
+
+Full supported official releases of the GP2X WIZ ScummVM backend are made in
+line with main official releases and are avalalble from the ScummVM
+downloads page <http://www.scummvm.org/downloads.php>.
+
+This build is in an active state of development and as such no
+"expected" behavior can be guaranteed ;).
+
+SVN builds are quickly tested with firmware 1.0.0 for reference.
+
+Please refer to the GP2X/GP2X WIZ ScummVM forum
+<http://forums.scummvm.org/viewforum.php?f=14> and WiKi
+<http://wiki.scummvm.org/index.php/GP2X> for the latest information on
+the port.
+
+------------------------------------------------------------------------
+Game compatibility
+
+For information on the compatability of a specific game please refer to
+the GP2X compatability section of the ScummVM WiKi
+<http://wiki.scummvm.org/index.php/GP2X#Compatibility_List>.
+
+Please note the version and date of the ScummVM build you are running
+when reviewing the above list.
+
+------------------------------------------------------------------------
+Supported audio options
+
+Raw audio.
+MP3 audio.
+OGG Vorbis audio.
+
+FLAC audio is currently unsupported.
+
+For best results use uncompressed audio in games.
+
+------------------------------------------------------------------------
+How to save
+
+NOTE: Everything is saved to the SD card, saves are stored in the saves
+folder under your main ScummVM executable unless you set another save
+location.
+
+The configiration file for ScummVM (.scummvmrc) is stored in the same
+place as the ScummVM executable.
+
+The save process below is for Scumm engine games but the principle is
+the same for all.
+
+In Game.
+
+1. Menu Button
+2. Select SAVE with B
+3. Select a position with B
+4. Right trigger puts 0 in the name box for some text.
+5. Press B to save
+
+Basically the emulated keys you can use are equivelent to the values
+buttons are mapped to,
+
+------------------------------------------------------------------------
+Controller mappings
+
+Touch screen:
+Touch: Move Pointer and Left click
+
+Mouse emulation:
+
+dPad: Move Pointer
+B: Left click
+X: Right click
+
+Keyboard emulation:
+
+Right Trigger: Return
+Select: Escape
+Y: Space Bar (Pause)
+Menu: Game Menu (Save, Load, Quit etc.)
+Volume Buttons: Increase and Decrease volume (5% per press)
+
+Fancy button combos:
+
+NOTE: To use button combos press and hold the Left Trigger then...
+
+Right Trigger: 0 (For skipping the copy protection in Monkey Island 2)
+Menu: Bring up the Global main menu for ScummVM
+Select: Exit ScummVM completely (and gracefully)
+
+------------------------------------------------------------------------
+Know issues
+
+Possible random crash (well SegFault). I have had this happen twice and
+have not tracked down the cause.
+It happens very infrequently, both times it was in the DOTT CD intro.
+
+------------------------------------------------------------------------
+Additional resources/links
+
+ * ScummVM WiKi GP2X page <http://wiki.scummvm.org/index.php/GP2X>
+ * ScummVM forums GP2X forum
+ <http://forums.scummvm.org/viewforum.php?f=14>
+ * My own ScummVM page <http://www.distant-earth.com/scummvm> (for
+ SVN/test builds)
+ * Main ScummVM site <http://www.scummvm.org> (for official supported
+ release builds)
+
+------------------------------------------------------------------------
+Credits
+
+Core ScummVM code (c) The ScummVM Team
+GP2X Wiz backend (c) John Willis
+Detailed (c) information can be found within the source code
diff --git a/backends/platform/gp2xwiz/build/build.sh b/backends/platform/gp2xwiz/build/build.sh
new file mode 100755
index 0000000000..1bdc020f17
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/build.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+echo Quick script to make building all the time less painful.
+
+# Set the paths up here to support the build.
+
+export PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin:$PATH
+export PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin:$PATH
+export CXX=arm-open2x-linux-g++
+export CC=arm-open2x-linux-gcc
+export CXXFLAGS="-mcpu=arm926ej-s -mtune=arm926ej-s"
+export ASFLAGS=-mfloat-abi=soft
+
+cd ../../../..
+
+echo Building ScummVM for GP2X.
+make
+
+echo Build for GP2X - SDL - complete - Please check build logs.
diff --git a/backends/platform/gp2xwiz/build/bundle.sh b/backends/platform/gp2xwiz/build/bundle.sh
new file mode 100755
index 0000000000..1dcdb6389e
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/bundle.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+echo Quick script to make building a distribution of the GP2X Wiz backend more consistent.
+
+echo Collecting files.
+mkdir "scummvm-wiz-`date '+%Y-%m-%d'`"
+mkdir "scummvm-wiz-`date '+%Y-%m-%d'`/scummvm"
+mkdir "scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/saves"
+mkdir "scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/plugins"
+mkdir "scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/engine-data"
+
+echo "Please put your save games in this dir" >> "scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/saves/PUT_SAVES_IN_THIS_DIR"
+
+cp ./scummvm.gpe ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ./scummvm.png ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ./README-GP2XWIZ ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ./scummvm.ini ./scummvm-wiz-`date '+%Y-%m-%d'`/
+cp ../../../../scummvm.wiz ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../AUTHORS ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../README ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../COPYING ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../COPYRIGHT ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../NEWS ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../gui/themes/scummmodern.zip ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../dists/pred.dic ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/
+cp ../../../../dists/engine-data/* ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/engine-data
+cp ../../../../plugins/* ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/plugins
+
+echo Making Stripped exe.
+arm-open2x-linux-strip ./scummvm-wiz-`date '+%Y-%m-%d'`/scummvm/scummvm.wiz
+
+echo Building ZIP bundle.
+if [ -f /usr/bin/zip ]
+ then
+ rm ./"scummvm-wiz-`date '+%Y-%m-%d'`.zip"
+ cd "scummvm-wiz-`date '+%Y-%m-%d'`"
+ zip -r -9 "../scummvm-wiz-`date '+%Y-%m-%d'`.zip" *
+ echo You should have a "scummvm-wiz-`date '+%Y-%m-%d'`.zip" for the GP2X Wiz backend ready to go.
+ cd ..
+ rm -R ./"scummvm-wiz-`date '+%Y-%m-%d'`"
+ else
+ echo - /usr/bin/zip not found, ZIP bundle not created.
+ echo All included files can also be found in ./"scummvm-wiz-`date '+%Y-%m-%d'`"
+ echo - Please use you preferred archive tool to bundle these files.
+fi
diff --git a/backends/platform/gp2xwiz/build/clean.sh b/backends/platform/gp2xwiz/build/clean.sh
new file mode 100755
index 0000000000..2862887bb3
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/clean.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+echo Quick script to make building all the time less painful.
+
+cd ../../../..
+
+echo Cleaning ScummVM for the GP2X Wiz.
+make clean
diff --git a/backends/platform/gp2xwiz/build/config-alleng.sh b/backends/platform/gp2xwiz/build/config-alleng.sh
new file mode 100755
index 0000000000..19ee308908
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/config-alleng.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+echo Quick script to make running configure all the time less painful
+echo and let all the build work be done from the backend/build folder.
+
+# Set the paths up here to generate the config.
+
+PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin:$PATH
+PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin:$PATH
+
+# Export the tool names for cross-compiling
+export CXX=arm-open2x-linux-g++
+export CXXFLAGS="-mcpu=arm926ej-s -mtune=arm926ej-s"
+export CPPFLAGS=-I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include
+export LDFLAGS=-L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib
+export DEFINES=-DNDEBUG
+
+# Edit the configure line to suit.
+cd ../../../..
+./configure --backend=gp2xwiz --disable-mt32emu --host=gp2xwiz --disable-flac --disable-nasm --disable-hq-scalers --with-sdl-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin --with-mpeg2-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-tremor --with-tremor-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-zlib --with-zlib-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-mad --with-mad-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-all-engines --enable-plugins --default-dynamic
+
+echo Generating config for GP2X Wiz complete. Check for errors.
diff --git a/backends/platform/gp2xwiz/build/config.sh b/backends/platform/gp2xwiz/build/config.sh
new file mode 100755
index 0000000000..b6889fe3ac
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/config.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+echo Quick script to make running configure all the time less painful
+echo and let all the build work be done from the backend/build folder.
+
+# Set the paths up here to generate the config.
+
+PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin:$PATH
+PATH=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin:$PATH
+
+# Export the tool names for cross-compiling
+export CXX=arm-open2x-linux-g++
+export CXXFLAGS="-mcpu=arm926ej-s -mtune=arm926ej-s"
+export CPPFLAGS=-I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include
+export LDFLAGS=-L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib
+export DEFINES=-DNDEBUG
+
+# Edit the configure line to suit.
+cd ../../../..
+./configure --backend=gp2xwiz --disable-mt32emu --host=gp2xwiz --disable-flac --disable-nasm --disable-hq-scalers --with-sdl-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin --with-mpeg2-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-tremor --with-tremor-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-zlib --with-zlib-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-mad --with-mad-prefix=/opt/open2x/gcc-4.1.1-glibc-2.3.6 --enable-plugins --default-dynamic
+
+echo Generating config for GP2X Wiz complete. Check for errors.
diff --git a/backends/platform/gp2xwiz/build/scummvm.gpe b/backends/platform/gp2xwiz/build/scummvm.gpe
new file mode 100755
index 0000000000..037b81d937
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/scummvm.gpe
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Run ScummVM, important this bit.
+./scummvm.wiz --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc
+
+# Sync the SD card to check that everything is written.
+sync
+
+# Return to the GPH menu screen
+cd /usr/gp2x
+exec /usr/gp2x/gp2xmenu
diff --git a/backends/platform/gp2xwiz/build/scummvm.ini b/backends/platform/gp2xwiz/build/scummvm.ini
new file mode 100644
index 0000000000..5a8e6eefa1
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/scummvm.ini
@@ -0,0 +1,4 @@
+[info]
+name="ScummVM"
+path="/scummvm/scummvm.gpe"
+icon="/scummvm/scummvm.png"
diff --git a/backends/platform/gp2xwiz/build/scummvm.png b/backends/platform/gp2xwiz/build/scummvm.png
new file mode 100644
index 0000000000..ede14b07e7
--- /dev/null
+++ b/backends/platform/gp2xwiz/build/scummvm.png
Binary files differ
diff --git a/backends/platform/gp2xwiz/gp2xwiz-events.cpp b/backends/platform/gp2xwiz/gp2xwiz-events.cpp
new file mode 100644
index 0000000000..ea1b191213
--- /dev/null
+++ b/backends/platform/gp2xwiz/gp2xwiz-events.cpp
@@ -0,0 +1,462 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/*
+ * GP2X Wiz: Device Specific Event Handling.
+ *
+ */
+
+#include "backends/platform/gp2xwiz/gp2xwiz-sdl.h"
+#include "backends/platform/gp2xwiz/gp2xwiz-hw.h"
+#include "backends/keymapper/keymapper.h"
+#include "common/util.h"
+#include "common/events.h"
+
+// FIXME move joystick defines out and replace with confile file options
+// we should really allow users to map any key to a joystick button using the keymapper.
+#define JOY_DEADZONE 2200
+
+#define JOY_XAXIS 0
+#define JOY_YAXIS 1
+
+static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
+ if (key >= SDLK_F1 && key <= SDLK_F9) {
+ return key - SDLK_F1 + Common::ASCII_F1;
+ } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
+ return key - SDLK_KP0 + '0';
+ } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
+ return key;
+ } else if (unicode) {
+ return unicode;
+ } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
+ return key & ~0x20;
+ } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
+ return 0;
+ }
+ return key;
+}
+
+void OSystem_GP2XWIZ::fillMouseEvent(Common::Event &event, int x, int y) {
+ event.mouse.x = x;
+ event.mouse.y = y;
+
+ // Update the "keyboard mouse" coords
+ _km.x = x;
+ _km.y = y;
+
+ // Adjust for the screen scaling
+ if (!_overlayVisible) {
+ event.mouse.x /= _videoMode.scaleFactor;
+ event.mouse.y /= _videoMode.scaleFactor;
+ if (_videoMode.aspectRatioCorrection)
+ event.mouse.y = aspect2Real(event.mouse.y);
+ }
+}
+
+static byte SDLModToOSystemKeyFlags(SDLMod mod) {
+ byte b = 0;
+ if (mod & KMOD_SHIFT)
+ b |= Common::KBD_SHIFT;
+ if (mod & KMOD_ALT)
+ b |= Common::KBD_ALT;
+ if (mod & KMOD_CTRL)
+ b |= Common::KBD_CTRL;
+
+ return b;
+}
+
+void OSystem_GP2XWIZ::moveStick() {
+ bool stickBtn[32];
+
+ memcpy(stickBtn, _stickBtn, sizeof(stickBtn));
+
+ if ((stickBtn[0])||(stickBtn[2])||(stickBtn[4])||(stickBtn[6]))
+ stickBtn[1] = stickBtn[3] = stickBtn[5] = stickBtn[7] = 0;
+
+ if ((stickBtn[1])||(stickBtn[2])||(stickBtn[3])) {
+ if (_km.x_down_count!=2) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else
+ _km.x_vel = -4;
+ } else if ((stickBtn[5])||(stickBtn[6])||(stickBtn[7])) {
+ if (_km.x_down_count!=2) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else
+ _km.x_vel = 4;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+
+ if ((stickBtn[0])||(stickBtn[1])||(stickBtn[7])) {
+ if (_km.y_down_count!=2) {
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else
+ _km.y_vel = -4;
+ } else if ((stickBtn[3])||(stickBtn[4])||(stickBtn[5])) {
+ if (_km.y_down_count!=2) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else
+ _km.y_vel = 4;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+}
+
+/* Quick default button states for modifiers. */
+int GP2X_BUTTON_STATE_L = false;
+
+/* Override the SDL pollEvent with the Wiz's own event code. */
+bool OSystem_GP2XWIZ::pollEvent(Common::Event &event) {
+ SDL_Event ev;
+ int axis;
+ byte b = 0;
+
+ handleKbdMouse();
+
+ // If the screen mode changed, send an Common::EVENT_SCREEN_CHANGED
+ if (_modeChanged) {
+ _modeChanged = false;
+ event.type = Common::EVENT_SCREEN_CHANGED;
+ return true;
+ }
+
+ // GP2X Wiz Input mappings.
+
+ /*
+ Single Button
+
+ Movement:
+
+ GP2X_BUTTON_UP Cursor Up
+ GP2X_BUTTON_DOWN Cursor Down
+ GP2X_BUTTON_LEFT Cursor Left
+ GP2X_BUTTON_RIGHT Cursor Right
+
+ GP2X_BUTTON_UPLEFT Cursor Up Left
+ GP2X_BUTTON_UPRIGHT Cursor Up Right
+ GP2X_BUTTON_DOWNLEFT Cursor Down Left
+ GP2X_BUTTON_DOWNRIGHT Cursor Down Right
+
+ Button Emulation:
+
+ GP2X_BUTTON_A . (Period)
+ GP2X_BUTTON_B Left Mouse Click
+ GP2X_BUTTON_Y Space Bar
+ GP2X_BUTTON_X Right Mouse Click
+ GP2X_BUTTON_L Combo Modifier (Left Trigger)
+ GP2X_BUTTON_R F5 (Right Trigger)
+ GP2X_BUTTON_MENU Return
+ GP2X_BUTTON_SELECT Escape
+ GP2X_BUTTON_VOLUP /dev/mixer Global Volume Up
+ GP2X_BUTTON_VOLDOWN /dev/mixer Global Volume Down
+
+ Combos:
+
+ GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP)
+ GP2X_BUTTON_L & GP2X_BUTTON_SELECT Common::EVENT_QUIT (Calls Sync() to make sure SD is flushed)
+ GP2X_BUTTON_L & GP2X_BUTTON_MENU Common::EVENT_MAINMENU (ScummVM Global Main Menu)
+ GP2X_BUTTON_L & GP2X_BUTTON_A Common::EVENT_PREDICTIVE_DIALOG for predictive text entry box (AGI games)
+ */
+
+ while (SDL_PollEvent(&ev)) {
+
+ switch(ev.type) {
+ case SDL_KEYDOWN:{
+ b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
+
+ const bool event_complete = remapKey(ev,event);
+
+ if (event_complete)
+ return true;
+
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+
+ return true;
+ }
+ case SDL_KEYUP:
+ {
+ const bool event_complete = remapKey(ev,event);
+
+ if (event_complete)
+ return true;
+
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+ b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
+
+ // Ctrl-Alt-<key> will change the GFX mode
+ if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
+ // Swallow these key up events
+ break;
+ }
+
+ return true;
+ }
+ case SDL_MOUSEMOTION:
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, ev.motion.x, ev.motion.y);
+
+ setMousePos(event.mouse.x, event.mouse.y);
+ return true;
+
+ case SDL_MOUSEBUTTONDOWN:
+ if (ev.button.button == SDL_BUTTON_LEFT)
+ event.type = Common::EVENT_LBUTTONDOWN;
+ else if (ev.button.button == SDL_BUTTON_RIGHT)
+ event.type = Common::EVENT_RBUTTONDOWN;
+#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
+ else if (ev.button.button == SDL_BUTTON_WHEELUP)
+ event.type = Common::EVENT_WHEELUP;
+ else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
+ event.type = Common::EVENT_WHEELDOWN;
+#endif
+#if defined(SDL_BUTTON_MIDDLE)
+ else if (ev.button.button == SDL_BUTTON_MIDDLE)
+ event.type = Common::EVENT_MBUTTONDOWN;
+#endif
+ else
+ break;
+
+ fillMouseEvent(event, ev.button.x, ev.button.y);
+
+ return true;
+
+ case SDL_MOUSEBUTTONUP:
+ if (ev.button.button == SDL_BUTTON_LEFT)
+ event.type = Common::EVENT_LBUTTONUP;
+ else if (ev.button.button == SDL_BUTTON_RIGHT)
+ event.type = Common::EVENT_RBUTTONUP;
+#if defined(SDL_BUTTON_MIDDLE)
+ else if (ev.button.button == SDL_BUTTON_MIDDLE)
+ event.type = Common::EVENT_MBUTTONUP;
+#endif
+ else
+ break;
+ fillMouseEvent(event, ev.button.x, ev.button.y);
+
+ return true;
+
+ case SDL_JOYBUTTONDOWN:
+ _stickBtn[ev.jbutton.button] = 1;
+ if (ev.jbutton.button == GP2X_BUTTON_B) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else if (ev.jbutton.button == GP2X_BUTTON_X) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else if (_stickBtn[GP2X_BUTTON_L] && (ev.jbutton.button == GP2X_BUTTON_SELECT)) {
+ event.type = Common::EVENT_QUIT;
+ } else if (ev.jbutton.button < 8) {
+ moveStick();
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else {
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.flags = 0;
+ switch (ev.jbutton.button) {
+ case GP2X_BUTTON_L:
+ GP2X_BUTTON_STATE_L = true;
+ break;
+ case GP2X_BUTTON_R:
+ if (GP2X_BUTTON_STATE_L == true) {
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
+ } else {
+ event.kbd.keycode = Common::KEYCODE_RETURN;
+ event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
+ }
+ break;
+ case GP2X_BUTTON_SELECT:
+ if (GP2X_BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_QUIT;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ }
+ break;
+ case GP2X_BUTTON_A:
+ if (GP2X_BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_PREDICTIVE_DIALOG;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ }
+ break;
+ case GP2X_BUTTON_Y:
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ break;
+ case GP2X_BUTTON_MENU:
+ if (GP2X_BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_MAINMENU;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ break;
+ case GP2X_BUTTON_VOLUP:
+ WIZ_HW::mixerMoveVolume(2);
+ if (WIZ_HW::volumeLevel == 100) {
+ displayMessageOnOSD("Maximum Volume");
+ } else {
+ displayMessageOnOSD("Increasing Volume");
+ }
+ break;
+
+ case GP2X_BUTTON_VOLDOWN:
+ WIZ_HW::mixerMoveVolume(1);
+ if (WIZ_HW::volumeLevel == 0) {
+ displayMessageOnOSD("Minimal Volume");
+ } else {
+ displayMessageOnOSD("Decreasing Volume");
+ }
+ break;
+ }
+ }
+ return true;
+
+ case SDL_JOYBUTTONUP:
+ _stickBtn[ev.jbutton.button] = 0;
+ if (ev.jbutton.button == GP2X_BUTTON_B) {
+ event.type = Common::EVENT_LBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else if (ev.jbutton.button == GP2X_BUTTON_X) {
+ event.type = Common::EVENT_RBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else if (ev.jbutton.button < 8) {
+ moveStick();
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else {
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.flags = 0;
+ switch (ev.jbutton.button) {
+ case GP2X_BUTTON_SELECT:
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ break;
+ case GP2X_BUTTON_A:
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ break;
+ case GP2X_BUTTON_Y:
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ break;
+ case GP2X_BUTTON_MENU:
+ if (GP2X_BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_MAINMENU;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ break;
+ case GP2X_BUTTON_L:
+ GP2X_BUTTON_STATE_L = false;
+ break;
+ case GP2X_BUTTON_R:
+ if (GP2X_BUTTON_STATE_L == true) {
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
+ } else {
+ event.kbd.keycode = Common::KEYCODE_RETURN;
+ event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
+ }
+ break;
+ case GP2X_BUTTON_VOLUP:
+ break;
+ case GP2X_BUTTON_VOLDOWN:
+ break;
+ }
+ }
+ return true;
+
+ case SDL_JOYAXISMOTION:
+ axis = ev.jaxis.value;
+ if ( axis > JOY_DEADZONE) {
+ axis -= JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else if ( axis < -JOY_DEADZONE ) {
+ axis += JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else
+ axis = 0;
+
+ if ( ev.jaxis.axis == JOY_XAXIS) {
+ if (axis != 0) {
+ _km.x_vel = (axis > 0) ? 1:-1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ } else if (ev.jaxis.axis == JOY_YAXIS) {
+#ifndef JOY_INVERT_Y
+ axis = -axis;
+#endif
+#ifdef JOY_ANALOG
+ _km.y_vel = -axis / 2000;
+ _km.y_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.y_vel = (-axis > 0) ? 1: -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+#endif
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case SDL_VIDEOEXPOSE:
+ _forceFull = true;
+ break;
+
+ case SDL_QUIT:
+ event.type = Common::EVENT_QUIT;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool OSystem_GP2XWIZ::remapKey(SDL_Event &ev,Common::Event &event) {
+ return false;
+}
diff --git a/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp b/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp
new file mode 100644
index 0000000000..2482051286
--- /dev/null
+++ b/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp
@@ -0,0 +1,33 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "backends/platform/gp2xwiz/gp2xwiz-sdl.h"
+
+
+/* TODO: Add code to ensure that overlay is always 320*240 and maybe invoke some custom scale code. */
+
+bool OSystem_GP2XWIZ::loadGFXMode() {
+ OSystem_SDL::loadGFXMode();
+}
diff --git a/backends/platform/gp2xwiz/gp2xwiz-hw.cpp b/backends/platform/gp2xwiz/gp2xwiz-hw.cpp
new file mode 100644
index 0000000000..c804b0d819
--- /dev/null
+++ b/backends/platform/gp2xwiz/gp2xwiz-hw.cpp
@@ -0,0 +1,74 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/*
+ * GP2X Wiz: Hardware Stuff.
+ *
+ */
+
+#include "backends/platform/gp2xwiz/gp2xwiz-hw.h"
+
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <sys/soundcard.h>
+#include <unistd.h>
+
+namespace WIZ_HW {
+
+int volumeLevel = VOLUME_INITIAL;
+
+void deviceInit() {
+}
+
+void deviceDeinit() {
+}
+
+void mixerMoveVolume(int direction) {
+ if (volumeLevel <= 10) {
+ if (direction == VOLUME_UP) volumeLevel += VOLUME_CHANGE_RATE/2;
+ if (direction == VOLUME_DOWN) volumeLevel -= VOLUME_CHANGE_RATE/2;
+ } else {
+ if(direction == VOLUME_UP) volumeLevel += VOLUME_CHANGE_RATE;
+ if(direction == VOLUME_DOWN) volumeLevel -= VOLUME_CHANGE_RATE;
+ }
+
+ if (volumeLevel < VOLUME_MIN) volumeLevel = VOLUME_MIN;
+ if (volumeLevel > VOLUME_MAX) volumeLevel = VOLUME_MAX;
+
+ unsigned long soundDev = open("/dev/mixer", O_RDWR);
+
+ if(soundDev) {
+ int vol = ((volumeLevel << 8) | volumeLevel);
+ ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol);
+ close(soundDev);
+ }
+}
+
+} /* namespace WIZ_HW */
diff --git a/backends/platform/gp2xwiz/gp2xwiz-hw.h b/backends/platform/gp2xwiz/gp2xwiz-hw.h
new file mode 100644
index 0000000000..577facc437
--- /dev/null
+++ b/backends/platform/gp2xwiz/gp2xwiz-hw.h
@@ -0,0 +1,73 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/*
+ * GP2X Wiz: Hardware Stuff.
+ *
+ */
+
+#ifndef GP2XWIZ_HW_H
+#define GP2XWIZ_HW_H
+
+/* GP2X Wiz: Main Joystick Mappings */
+
+#define GP2X_BUTTON_UP (0)
+#define GP2X_BUTTON_UPLEFT (1)
+#define GP2X_BUTTON_LEFT (2)
+#define GP2X_BUTTON_DOWNLEFT (3)
+#define GP2X_BUTTON_DOWN (4)
+#define GP2X_BUTTON_DOWNRIGHT (5)
+#define GP2X_BUTTON_RIGHT (6)
+#define GP2X_BUTTON_UPRIGHT (7)
+#define GP2X_BUTTON_MENU (8)
+#define GP2X_BUTTON_SELECT (9)
+#define GP2X_BUTTON_L (10)
+#define GP2X_BUTTON_R (11)
+#define GP2X_BUTTON_A (12)
+#define GP2X_BUTTON_B (13)
+#define GP2X_BUTTON_X (14)
+#define GP2X_BUTTON_Y (15)
+#define GP2X_BUTTON_VOLUP (16)
+#define GP2X_BUTTON_VOLDOWN (17)
+
+namespace WIZ_HW {
+
+#define VOLUME_MIN 0
+#define VOLUME_INITIAL 70 /* Default volume if you call mixerMoveVolume(0) without setting the global var. */
+#define VOLUME_MAX 100
+#define VOLUME_CHANGE_RATE 8
+#define VOLUME_NOCHG 0
+#define VOLUME_DOWN 1
+#define VOLUME_UP 2
+
+extern int volumeLevel;
+
+extern void deviceInit();
+extern void deviceDeinit();
+extern void mixerMoveVolume(int);
+
+} /* namespace WIZ_HW */
+
+#endif //GP2XWIZ_HW_H
diff --git a/backends/platform/gp2xwiz/gp2xwiz-main.cpp b/backends/platform/gp2xwiz/gp2xwiz-main.cpp
new file mode 100644
index 0000000000..4bd3f98211
--- /dev/null
+++ b/backends/platform/gp2xwiz/gp2xwiz-main.cpp
@@ -0,0 +1,216 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/scummsys.h"
+#include <SDL/SDL.h>
+
+#include "backends/platform/gp2xwiz/gp2xwiz-sdl.h"
+#include "backends/platform/gp2xwiz/gp2xwiz-hw.h"
+#include "backends/plugins/posix/posix-provider.h"
+#include "base/main.h"
+#include "base/internal_version.h"
+
+#include "common/archive.h"
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/events.h"
+#include "common/util.h"
+
+#include "common/file.h"
+#include "base/main.h"
+
+#include "backends/saves/default/default-saves.h"
+
+#include "backends/timer/default/default-timer.h"
+#include "sound/mixer_intern.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <time.h> // for getTimeAndDate()
+
+/* Dump console info to files. */
+// #define DUMP_STDOUT
+
+int main(int argc, char *argv[]) {
+
+ g_system = new OSystem_GP2XWIZ();
+ assert(g_system);
+
+#ifdef DYNAMIC_MODULES
+ PluginManager::instance().addPluginProvider(new POSIXPluginProvider());
+#endif
+
+ // Invoke the actual ScummVM main entry point:
+ int res = scummvm_main(argc, argv);
+ g_system->quit();
+
+ return res;
+}
+
+void OSystem_GP2XWIZ::initBackend() {
+
+ /* Setup default save path to be workingdir/saves */
+
+ char savePath[PATH_MAX+1];
+ char workDirName[PATH_MAX+1];
+
+ if (getcwd(workDirName, PATH_MAX) == NULL) {
+ error("Could not obtain current working directory.");
+ } else {
+ printf("Current working directory: %s\n", workDirName);
+ }
+
+ strcpy(savePath, workDirName);
+ strcat(savePath, "/saves");
+ printf("Current save directory: %s\n", savePath);
+ struct stat sb;
+ if (stat(savePath, &sb) == -1)
+ if (errno == ENOENT) // Create the dir if it does not exist
+ if (mkdir(savePath, 0755) != 0)
+ warning("mkdir for '%s' failed!", savePath);
+
+ _savefile = new DefaultSaveFileManager(savePath);
+
+ #ifdef DUMP_STDOUT
+ // The GP2X Wiz has a serial console on the breakout board but most users do not use this so we
+ // output all our STDOUT and STDERR to files for debug purposes.
+ char STDOUT_FILE[PATH_MAX+1];
+ char STDERR_FILE[PATH_MAX+1];
+
+ strcpy(STDOUT_FILE, workDirName);
+ strcpy(STDERR_FILE, workDirName);
+ strcat(STDOUT_FILE, "/scummvm.stdout.txt");
+ strcat(STDERR_FILE, "/scummvm.stderr.txt");
+
+ // Flush the output in case anything is queued
+ fclose(stdout);
+ fclose(stderr);
+
+ // Redirect standard input and standard output
+ FILE *newfp = freopen(STDOUT_FILE, "w", stdout);
+ if (newfp == NULL) {
+ #if !defined(stdout)
+ stdout = fopen(STDOUT_FILE, "w");
+ #else
+ newfp = fopen(STDOUT_FILE, "w");
+ if (newfp) {
+ *stdout = *newfp;
+ }
+ #endif
+ }
+
+ newfp = freopen(STDERR_FILE, "w", stderr);
+ if (newfp == NULL) {
+ #if !defined(stderr)
+ stderr = fopen(STDERR_FILE, "w");
+ #else
+ newfp = fopen(STDERR_FILE, "w");
+ if (newfp) {
+ *stderr = *newfp;
+ }
+ #endif
+ }
+
+ setbuf(stderr, NULL);
+ printf("%s\n", "Debug: STDOUT and STDERR redirected to text files.");
+ #endif /* DUMP_STDOUT */
+
+ /* Initialise any GP2X Wiz specific stuff we may want (Batt Status, scaler etc.) */
+ WIZ_HW::deviceInit();
+
+ /* Set Default hardware mixer volume to a preset level (VOLUME_INITIAL). This is done to 'reset' volume level if set by other apps. */
+ WIZ_HW::mixerMoveVolume(0);
+
+ /* Up default volume values as we use a seperate system level volume anyway. */
+ ConfMan.registerDefault("music_volume", 220);
+ ConfMan.registerDefault("sfx_volume", 220);
+ ConfMan.registerDefault("speech_volume", 220);
+
+ /* Trigger autosave every 4 minutes - On low batts 5 mins is about your warning time. */
+ ConfMan.registerDefault("autosave_period", 4 * 60);
+
+ /* Make sure that aspect ratio correction is enabled on the 1st run to stop users asking me what the 'wasted space' is ;-). */
+ ConfMan.registerDefault("aspect_ratio", true);
+
+ /* Make sure SDL knows that we have a joystick we want to use. */
+ ConfMan.setInt("joystick_num", 0);
+
+ printf("%s\n", "Passing to OSystem::SDL initBackend.");
+
+ /* Pass to SDL backend to do the heavy lifting */
+ OSystem_SDL::initBackend();
+}
+
+void OSystem_GP2XWIZ::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
+
+ /* Setup default extra data paths for engine data files and plugins */
+ char workDirName[PATH_MAX+1];
+
+ if (getcwd(workDirName, PATH_MAX) == NULL) {
+ error("Error: Could not obtain current working directory.");
+ }
+
+ Common::FSNode workdirNode(workDirName);
+ if (workdirNode.exists() && workdirNode.isDirectory()) {
+ s.add("__GP2XWIZ_WORKDIR__", new Common::FSDirectory(workDirName), priority);
+ }
+
+ char enginedataPath[PATH_MAX+1];
+
+ strcpy(enginedataPath, workDirName);
+ strcat(enginedataPath, "/engine-data");
+
+ Common::FSNode engineNode(enginedataPath);
+ if (engineNode.exists() && engineNode.isDirectory()) {
+ s.add("__GP2XWIZ_ENGDATA__", new Common::FSDirectory(enginedataPath), priority);
+ }
+
+ char pluginsPath[PATH_MAX+1];
+
+ strcpy(pluginsPath, workDirName);
+ strcat(pluginsPath, "/plugins");
+
+ Common::FSNode pluginsNode(pluginsPath);
+ if (pluginsNode.exists() && pluginsNode.isDirectory()) {
+ s.add("__GP2XWIZ_PLUGINS__", new Common::FSDirectory(pluginsPath), priority);
+ }
+}
+
+void OSystem_GP2XWIZ::quit() {
+
+ WIZ_HW::deviceDeinit();
+
+ #ifdef DUMP_STDOUT
+ printf("%s\n", "Debug: STDOUT and STDERR text files closed.");
+ fclose(stdout);
+ fclose(stderr);
+ #endif /* DUMP_STDOUT */
+
+ OSystem_SDL::quit();
+}
diff --git a/backends/platform/gp2xwiz/gp2xwiz-sdl.h b/backends/platform/gp2xwiz/gp2xwiz-sdl.h
new file mode 100644
index 0000000000..8811f86edf
--- /dev/null
+++ b/backends/platform/gp2xwiz/gp2xwiz-sdl.h
@@ -0,0 +1,62 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GP2XWIZ_SDL_H
+#define GP2XWIZ_SDL_H
+
+#include "backends/platform/sdl/sdl.h"
+
+#include <SDL.h>
+
+#define __GP2XWIZ__
+#define MIXER_DOUBLE_BUFFERING 1
+
+#ifndef PATH_MAX
+ #define PATH_MAX 255
+#endif
+
+class OSystem_GP2XWIZ : public OSystem_SDL {
+public:
+ OSystem_GP2XWIZ() {}
+
+ /* Graphics */
+ bool loadGFXMode();
+
+ /* Event Stuff */
+ bool pollEvent(Common::Event &event);
+ void moveStick();
+ void fillMouseEvent(Common::Event&, int, int);
+ bool remapKey(SDL_Event&, Common::Event&);
+
+ /* Platform Setup Stuff */
+ void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
+ void initBackend();
+ void quit();
+
+protected:
+ bool _stickBtn[32];
+};
+
+#endif
diff --git a/backends/platform/gp2xwiz/module.mk b/backends/platform/gp2xwiz/module.mk
new file mode 100644
index 0000000000..03241f7b60
--- /dev/null
+++ b/backends/platform/gp2xwiz/module.mk
@@ -0,0 +1,16 @@
+MODULE := backends/platform/gp2xwiz
+
+MODULE_OBJS := \
+ gp2xwiz-graphics.o \
+ gp2xwiz-events.o \
+ gp2xwiz-hw.o \
+ gp2xwiz-main.o \
+
+MODULE_DIRS += \
+ backends/platform/gp2xwiz/
+
+# We don't use the rules.mk here on purpose
+OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS)
+
+# Hack to ensure the SDL backend is built so we can use OSystem_SDL.
+-include $(srcdir)/backends/platform/sdl/module.mk \ No newline at end of file
diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp
index adb9cec08b..021bda155c 100644
--- a/backends/platform/sdl/main.cpp
+++ b/backends/platform/sdl/main.cpp
@@ -37,7 +37,7 @@
#include "SymbianOs.h"
#endif
-#if !defined(__MAEMO__) && !defined(_WIN32_WCE)
+#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)
#if defined (WIN32)
int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {