diff options
author | John Willis | 2009-06-04 08:30:31 +0000 |
---|---|---|
committer | John Willis | 2009-06-04 08:30:31 +0000 |
commit | 929ef3e4a8eaf83e5fda75fb1047feb6647e7799 (patch) | |
tree | 4c9cf9ce363eb977371e3be19ae88b84b6f207a1 | |
parent | 70effa46e55100630df3b902918c75e77d505188 (diff) | |
download | scummvm-rg350-929ef3e4a8eaf83e5fda75fb1047feb6647e7799.tar.gz scummvm-rg350-929ef3e4a8eaf83e5fda75fb1047feb6647e7799.tar.bz2 scummvm-rg350-929ef3e4a8eaf83e5fda75fb1047feb6647e7799.zip |
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.
svn-id: r41156
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/build/README-GP2XWIZ | 141 | ||||
-rwxr-xr-x | backends/platform/gp2xwiz/build/build.sh | 19 | ||||
-rwxr-xr-x | backends/platform/gp2xwiz/build/bundle.sh | 45 | ||||
-rwxr-xr-x | backends/platform/gp2xwiz/build/clean.sh | 8 | ||||
-rwxr-xr-x | backends/platform/gp2xwiz/build/config-alleng.sh | 22 | ||||
-rwxr-xr-x | backends/platform/gp2xwiz/build/config.sh | 22 | ||||
-rwxr-xr-x | backends/platform/gp2xwiz/build/scummvm.gpe | 11 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/build/scummvm.ini | 4 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/build/scummvm.png | bin | 0 -> 2810 bytes | |||
-rw-r--r-- | backends/platform/gp2xwiz/gp2xwiz-events.cpp | 464 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/gp2xwiz-graphics.cpp | 33 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/gp2xwiz-hw.cpp | 79 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/gp2xwiz-hw.h | 73 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/gp2xwiz-main.cpp | 216 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/gp2xwiz-sdl.h | 62 | ||||
-rw-r--r-- | backends/platform/gp2xwiz/module.mk | 16 | ||||
-rw-r--r-- | backends/platform/sdl/main.cpp | 2 | ||||
-rwxr-xr-x | configure | 55 |
19 files changed, 1272 insertions, 3 deletions
@@ -31,6 +31,9 @@ For a more comprehensive changelog for the latest experimental SVN code, see: KYRA: - Added support for PC Speaker based music and sound effects. + New Ports: + - Added GP2X Wiz port. + 0.13.1 (2009-04-27) AGOS: - Fixed crash after OmniTV video is played in The Feeble Files 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 Binary files differnew file mode 100644 index 0000000000..ede14b07e7 --- /dev/null +++ b/backends/platform/gp2xwiz/build/scummvm.png diff --git a/backends/platform/gp2xwiz/gp2xwiz-events.cpp b/backends/platform/gp2xwiz/gp2xwiz-events.cpp new file mode 100644 index 0000000000..fa03e247d9 --- /dev/null +++ b/backends/platform/gp2xwiz/gp2xwiz-events.cpp @@ -0,0 +1,464 @@ +/* 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..7133614a3e --- /dev/null +++ b/backends/platform/gp2xwiz/gp2xwiz-hw.cpp @@ -0,0 +1,79 @@ +/* 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..6b61f9c26a --- /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*/) { @@ -271,9 +271,12 @@ get_system_exe_extension() { arm-riscos) _exeext=",ff8" ;; + gp2xwiz-linux) + _exeext=".wiz" + ;; gp2x-linux) _exeext=".gp2x" - ;; + ;; dreamcast | wii | gamecube | psp) _exeext=".elf" ;; @@ -548,7 +551,7 @@ Usage: $0 [OPTIONS]... Configuration: -h, --help display this help and exit - --backend=BACKEND backend to build (sdl, morphos, dc, gp2x, iphone, wii, psp, null) [sdl] + --backend=BACKEND backend to build (sdl, morphos, dc, gp2x, gp2xwiz, iphone, wii, psp, null) [sdl] Installation directories: --prefix=DIR use this prefix for installing ScummVM [/usr/local] @@ -782,6 +785,11 @@ ppc-amigaos) _host_os=amigaos _host_cpu=ppc ;; +gp2xwiz) + _host_os=gp2xwiz-linux + _host_cpu=arm + _host_alias=arm-open2x-linux + ;; gp2x) _host_os=gp2x-linux _host_cpu=arm @@ -1177,6 +1185,24 @@ if test -n "$_host"; then _ranlib=$_host-ranlib _strip=$_host-strip ;; + gp2xwiz) + echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes" + DEFINES="$DEFINES -DUNIX -DGP2XWIZ -DNDEBUG -DUSE_ARM_SMUSH_ASM" + CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" + LDFLAGS="$LDFLAGS" + _endian=little + _need_memalign=yes + type_1_byte='char' + type_2_byte='short' + type_4_byte='int' + _ar="$_host_alias-ar cru" + _ranlib=$_host_alias-ranlib + add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' + add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' + _backend="gp2xwiz" + _build_hq_scalers="no" + _mt32emu="no" + ;; gp2x) echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes" DEFINES="$DEFINES -DUNIX -DGP2X -DNDEBUG -DUSE_ARM_SMUSH_ASM" @@ -1476,6 +1502,24 @@ PRE_OBJS_FLAGS := -Wl,--whole-archive POST_OBJS_FLAGS := -Wl,--export-all-symbols -Wl,--no-whole-archive -Wl,--out-implib,./libscummvm.a ' ;; + gp2xwiz*) +_def_plugin=' +#define PLUGIN_PREFIX "" +#define PLUGIN_SUFFIX ".plugin" +' +_mak_plugins=' +DYNAMIC_MODULES := 1 +PLUGIN_PREFIX := +PLUGIN_SUFFIX := .plugin +PLUGIN_EXTRA_DEPS = $(EXECUTABLE) +CXXFLAGS += -DDYNAMIC_MODULES +CXXFLAGS += -fpic +PLUGIN_LDFLAGS += -shared +PRE_OBJS_FLAGS := -Wl,-export-dynamic -Wl,-whole-archive +POST_OBJS_FLAGS := -Wl,-no-whole-archive +LIBS += -ldl +' + ;; dreamcast) _def_plugin=' #define PLUGIN_PREFIX "" @@ -1861,6 +1905,13 @@ case $_backend in LDFLAGS="$LDFLAGS -static" CXXFLAGS="$CXXFLAGS -march=armv4t" ;; + gp2xwiz) + find_sdlconfig + INCLUDES="$INCLUDES `$_sdlconfig --prefix="$_sdlpath" --cflags`" + LIBS="$LIBS `$_sdlconfig --prefix="$_sdlpath" --libs`" + LDFLAGS="$LDFLAGS" + CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" + ;; iphone) OBJCFLAGS="$OBJCFLAGS --std=c99" LIBS="$LIBS -lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES -framework QuartzCore -framework GraphicsServices -framework CoreFoundation -framework Foundation -framework AudioToolbox -framework CoreAudio" |