aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/gp2x
diff options
context:
space:
mode:
authorNorbert Lange2009-08-08 19:09:30 +0000
committerNorbert Lange2009-08-08 19:09:30 +0000
commit0350a1598deea8d1af252ddd96a490699d10e2e2 (patch)
tree11557d7a87ee5da2ee20e6c13e8be7d2607f393c /backends/platform/gp2x
parentdf06592be1b4c9904acde5a843d3ab3d076c65ac (diff)
parent65a39cc2b0ebb989444330c561743ba0466c1a9c (diff)
downloadscummvm-rg350-0350a1598deea8d1af252ddd96a490699d10e2e2.tar.gz
scummvm-rg350-0350a1598deea8d1af252ddd96a490699d10e2e2.tar.bz2
scummvm-rg350-0350a1598deea8d1af252ddd96a490699d10e2e2.zip
merge with trunk
svn-id: r43134
Diffstat (limited to 'backends/platform/gp2x')
-rw-r--r--backends/platform/gp2x/build/README-GP2X38
-rw-r--r--backends/platform/gp2x/build/README-GP2X.html369
-rwxr-xr-xbackends/platform/gp2x/build/bundle.sh1
-rwxr-xr-xbackends/platform/gp2x/build/config-alleng.sh2
-rwxr-xr-xbackends/platform/gp2x/build/config.sh2
-rw-r--r--backends/platform/gp2x/events.cpp31
-rw-r--r--backends/platform/gp2x/gp2x-hw.cpp96
-rw-r--r--backends/platform/gp2x/gp2x-hw.h18
-rw-r--r--backends/platform/gp2x/gp2x.cpp17
-rw-r--r--backends/platform/gp2x/graphics.cpp1
10 files changed, 87 insertions, 488 deletions
diff --git a/backends/platform/gp2x/build/README-GP2X b/backends/platform/gp2x/build/README-GP2X
index 7e10fc484e..f95a974230 100644
--- a/backends/platform/gp2x/build/README-GP2X
+++ b/backends/platform/gp2x/build/README-GP2X
@@ -12,10 +12,19 @@ Contents:
* How to save <#How_to_save>
* Controller mappings <#Controller_mappings>
* Know issues <#Know_issues>
- * Major TODO's <#Major_TODOs>
+ * TODO's <#Major_TODOs>
* Additional resources/links <#Additional_resourceslinks>
* Credits <#Credits>
+------------------------------------------------------------------------
+
+Please refer to the:
+
+GP2X/GP2XWiz ScummVM Forum: <http://forums.scummvm.org/viewforum.php?f=14>
+WiKi: <http://wiki.scummvm.org/index.php/GP2X>
+
+for the most current information on the port and any updates to this
+documentation.
------------------------------------------------------------------------
About the backend/port
@@ -58,22 +67,6 @@ Included engines
Just because an engine is included does not mean any/all of its games
are supported. Please check game compatability for more infomation.
- * Scumm - (All games supported by ScummVM should work to some
- extent, using the hardware scalar if needed)
- * AGOS (AKA Simon) - (Simon the Sorcerer one and two).
- * Sky - (Beneath a Steel Sky)
- * Sword - (Broken Sword 1) - This engine uses the hardware scalar to
- downsize the graphics to fix on the GP2X. It is NOT very nice to
- look at.
- * Sword2 - (Broken Sword 2) - This engine uses the hardware scalar
- to downsize the graphics to fix on the GP2X. It is NOT very nice
- to look at.
- * Gob - (Goblins one)
- * Queen - (Flight of the Amazon Queen)
- * Kyra - (The Legend of Kyrandia)
-
-All other game engines are disabled in this release.
-
------------------------------------------------------------------------
Supported audio options
@@ -169,16 +162,10 @@ It happens very infrequently, both times it was in the DOTT CD intro.
Saving often is never a bad idea anyhow.
------------------------------------------------------------------------
-Major TODO's
+TODO's
Fix save support when using the Sky engine (Beneath a Steel Sky) - You
CAN'T save at the moment but auto save works.
-Look into inconsistencies with AGOS engine and map Y key to a button
-combination to allow clean quitting (Simon 1/2).
-Add splash-screen and pre-ScummVM config menu (CPU speed, LCD timings
-etc.) - Partly done.
-Fix TV out, maybe make it an option in the pre-ScummVM config menu.
-Any help appreciated :).
------------------------------------------------------------------------
Additional resources/links
@@ -186,7 +173,7 @@ 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
+ * My own ScummVM page <http://scummvm.distant-earth.com/> (for
SVN/test builds)
* Main ScummVM site <http://www.scummvm.org> (for official supported
release builds)
@@ -197,4 +184,3 @@ Credits
Core ScummVM code (c) The ScummVM Team
Portions of the GP2X backend (c) John Willis
Detailed (c) information can be found within the source code
-
diff --git a/backends/platform/gp2x/build/README-GP2X.html b/backends/platform/gp2x/build/README-GP2X.html
deleted file mode 100644
index 1b5f1a4173..0000000000
--- a/backends/platform/gp2x/build/README-GP2X.html
+++ /dev/null
@@ -1,369 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <title>ScummVM - GP2X SPECIFIC README</title>
-
-
-</head>
-
-
-<body>
-
-<span style="font-weight: bold;">ScummVM -
-GP2X&nbsp;SPECIFIC README - HEAD SVN<br>
-
-</span>
-<hr style="width: 100%; height: 2px;"><br>
-
-<span style="font-weight: bold;">Contents:</span><br>
-
-<ul>
-
- <li><a href="#About_the_backendport">About the
-backend/port</a></li>
-
- <li><a href="#Game_compatibility">Game
-compatability</a></li>
-
- <li><a href="#Included_engines">Included engines</a></li>
-
- <li><a href="#Supported_audio_options">Supported
-audio options</a></li>
-
- <li><a href="#Supported_cut-scene_options">Supported
-cut-scene options</a></li>
-
- <li><a href="#Recent_changes">Recent changes</a></li>
-
- <li><a href="#How_to_save">How to save</a></li>
-
- <li><a href="#Controller_mappings">Controller
-mappings</a></li>
-
- <li><a href="#Know_issues">Know issues</a></li>
-
- <li><a href="#Major_TODOs">Major TODO's</a></li>
-
- <li><a href="#Additional_resourceslinks">Additional
-resources/links</a></li>
-
- <li><a href="#Credits">Credits</a></li>
-
-</ul>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="About_the_backendport"></a><span style="font-weight: bold;">About the backend/port</span><br>
-
-<br>
-
-This is the readme for the offficial GP2X ScummVM backend (also known
-as the GP2X port).<br>
-
-<br>
-
-This is an SVN test release of ScummVM for the GP2X, it would be
-appreciated
-if this SVN test distribution was not mirrored and that people be
-directed to <a href="http://www.distant-earth.com/scummvm">http://www.distant-earth.com/scummvm</a>
-instead for updated SVN builds.<br>
-
-<br>
-
-Full supported official releases of the GP2X ScummVM backend are made
-in line with main official releases and are avalalble from the <a href="http://www.scummvm.org/downloads.php">ScummVM
-downloads page</a>.<br>
-
-<br>
-
-This build is in an active state of development and as such no
-&lsquo;expected&rsquo; behavior can be guaranteed ;).<br>
-
-<br>
-
-SVN builds are quickly tested with firmware 2.0.0 for reference.<br>
-
-<br>
-
-Please refer to the <a href="http://forums.scummvm.org/viewforum.php?f=14">GP2X
-ScummVM forum</a> and <a href="http://wiki.scummvm.org/index.php/GP2X">WiKi</a>
-for the latest information on the port.<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Game_compatibility"></a><span style="font-weight: bold;">Game compatibility</span><br>
-
-<br>
-
-For information on the compatability of a specific game please refer to
-the <a href="http://wiki.scummvm.org/index.php/GP2X#Compatibility_List">GP2X
-compatability section of the ScummVM WiKi</a>.<br>
-
-<br>
-
-Please note the version and date of the ScummVM build you are running
-when reviewing the above list.<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Included_engines"></a><span style="font-weight: bold;">Included engines</span><br>
-
-<br>
-
-Just because an engine is included does not mean any/all of its games
-are supported. Please check game compatability for more infomation.<br>
-
-<ul>
-
- <li>Scumm - (All games supported by ScummVM should work to some
-extent, using the hardware scalar if needed)</li>
-
- <li>AGOS (AKA Simon) - (Simon the Sorcerer one and two).</li>
-
- <li>Sky - (Beneath a Steel Sky)</li>
-
- <li>Sword - (Broken Sword 1) - This engine uses the hardware
-scalar to
-downsize the graphics to fix on the GP2X. It is NOT very nice to look
-at.</li>
-
- <li>Sword2 - (Broken Sword 2) - This engine uses the hardware
-scalar to downsize the graphics to fix on the GP2X. It is NOT very nice
-to look at.</li>
-
- <li>Gob - (Goblins one)</li>
-
- <li>Queen - (Flight of the Amazon Queen)</li>
-
- <li>Kyra - (The Legend of Kyrandia)</li>
-
-</ul>
-
-All other game engines are disabled in this release.<br>
-
-<br style="font-weight: bold;">
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Supported_audio_options"></a><span style="font-weight: bold;">Supported audio options</span><br>
-
-<br>
-
-Raw audio.<br>
-
-MP3 audio.<br>
-
-OGG Vorbis audio.<br>
-
-<br>
-
-FLAC audio is currently unsupported.<br>
-
-<br>
-
-For best results use uncompressed audio in games.<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Supported_cut-scene_options"></a><span style="font-weight: bold;">Supported cut-scene options</span><br>
-
-<br>
-
-No cut scene compression options are currently supported. <br>
-
-<br>
-
-DXA video support will be added as soon as it is stable.<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Recent_changes"></a><span style="font-weight: bold;">Recent changes<br>
-
-<br>
-
-</span>Refined audio hacks to reduce audio delay a little more.<br>
-
-Enabled hardware scalar code.<br>
-
-Now built using SDL 1.2.9 for the parts of the port that use SDL (some
-parts now hit the hardware directly).<br>
-
-Enabled new launcher - (Ensure defaulttheme.zip is in the same folder
-as the executable).<br>
-
-Aspect Ratio Correction can now be disabled &lsquo;per
-game&rsquo;. When adding a game you can find this option on the GFX
-tab. <br>
-
-Note: This will cause the game to run with a black border at the bottom
-as it will be rendered to a 320*200 frame.<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="How_to_save"></a><span style="font-weight: bold;">How to save</span><br>
-
-<br>
-
-<span style="font-weight: bold;">NOTE:</span>
-Everything is saved to the SD card, saves are stored in the <span style="font-weight: bold;">saves</span> folder under
-your main ScummVM executable unless you set another save location.<br>
-
-<br>
-
-The configiration file for ScummVM (.scummvmrc) is stored in the
-same place as the ScummVM executable.<br>
-
-<br>
-
-The save process below is&nbsp;for Scumm engine games but the
-principle is the same for all.<br>
-
-<br>
-
-In Game.<br>
-
-<br>
-
-1. Right Trigger<br>
-
-2. Select SAVE with B<br>
-
-3. Select a position with B<br>
-
-4. Right trigger puts ? in the name box for some text.<br>
-
-5. Press B to save<br>
-
-<br>
-
-Basically the emulated keys you can use are equivelent to the values
-buttons are mapped to, <br>
-
-<br>
-
-I have a virtual keyboard like the GP32 one (left/right on the stick to
-pick chars) to add in at some point ;-)<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Controller_mappings"></a><span style="font-weight: bold;">Controller mappings</span><br>
-
-<br>
-
-<span style="font-weight: bold;">Mouse emulation:</span><br>
-
-<br>
-
-Stick: Move Pointer<br>
-
-Stick Click: &lsquo;light&rsquo; Left Click<br>
-
-B: Left click<br>
-
-X: Right click<br>
-
-<br>
-
-<span style="font-weight: bold;">Keyboard emulation:</span><br>
-
-<br>
-
-Start: Return<br>
-
-Select: Escape<br>
-
-Y: Space Bar (Pause)<br>
-
-Right Trigger: Game Menu (Save, Load, Quit etc.)<br>
-
-Volume Buttons: Increase and Decrease volume (5% per press)<br>
-
-<br>
-
-<span style="font-weight: bold;">Fancy button combos:</span><br>
-
-<br>
-
-NOTE: To use button combos press and hold the Left Trigger then...<br>
-
-<br>
-
-Y: Toggle "zoom" mode - Try it in larger games like Broken Sword.<br>
-
-Volume Buttons: Increase and Decrease subtitle speed (In SCUMM games)<br>
-
-Right Trigger: 0 (For skipping the copy protection in Monkey Island 2)<br>
-
-Select: Exit ScummVM completely (and gracefully)<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Know_issues"></a><span style="font-weight: bold;">Know issues</span><br>
-
-<br>
-
-Possible random crash (well SegFault). I have had this happen twice and
-have not tracked down the cause. <br>
-
-It happens very infrequently, both times it was in the DOTT CD intro.
-Saving often is never a bad idea anyhow.<br>
-
-<br>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Major_TODOs"></a><span style="font-weight: bold;">Major TODO's</span><br>
-
-<br>
-
-Fix save support when using the Sky engine (Beneath a Steel Sky) - You
-CAN'T save at the moment but auto save works.<br>
-
-Look into inconsistencies with AGOS engine and map Y key to a button
-combination to allow clean quitting (Simon 1/2).<br>
-
-Add splash-screen and pre-ScummVM config menu (CPU speed, LCD timings
-etc.) - Partly done.<br>
-
-Fix TV out, maybe make it an option in the pre-ScummVM config menu.<br>
-
-Any help appreciated :).<br>
-
-<br style="font-weight: bold;">
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Additional_resourceslinks"></a><span style="font-weight: bold;">Additional resources/links<br>
-
-<br>
-
-</span><span style="font-weight: bold;">Note:</span>
-When providing feedback,
-requests, forum posts, bug reports or anything like that always include
-a mention of the version of ScummVM you are using (the build version,
-date and time can be seen in the main game launcher window).<br>
-
-<ul>
-
- <li><a href="http://wiki.scummvm.org/index.php/GP2X">ScummVM
-WiKi GP2X page</a></li>
-
- <li><a href="http://forums.scummvm.org/viewforum.php?f=14">ScummVM
-forums GP2X forum</a></li>
-
- <li><a href="http://www.distant-earth.com/scummvm">My
-own ScummVM page</a> (for SVN/test builds)</li>
-
- <li><a href="http://www.scummvm.org">Main ScummVM
-site</a> (for official supported release builds)</li>
-
-</ul>
-
-<hr style="width: 100%; height: 2px;"><a style="font-weight: bold;" name="Credits"></a><span style="font-weight: bold;">Credits</span><br>
-
-<br>
-
-Core ScummVM code (c) The ScummVM Team<br>
-
-Portions of the GP2X backend (c) John Willis<br>
-
-Detailed (c) information can be found within the source code<br>
-
-<br>
-
-</body>
-</html>
diff --git a/backends/platform/gp2x/build/bundle.sh b/backends/platform/gp2x/build/bundle.sh
index 560f096ed4..c68c62191b 100755
--- a/backends/platform/gp2x/build/bundle.sh
+++ b/backends/platform/gp2x/build/bundle.sh
@@ -19,7 +19,6 @@ echo "Please put your save games in this dir" >> "scummvm-gp2x-`date '+%Y-%m-%d'
cp ./scummvm.gpe ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ./scummvm.png ./scummvm-gp2x-`date '+%Y-%m-%d'`/
-cp ./README-GP2X.html ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ./README-GP2X ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ./mmuhack.o ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../scummvm.gp2x ./scummvm-gp2x-`date '+%Y-%m-%d'`/
diff --git a/backends/platform/gp2x/build/config-alleng.sh b/backends/platform/gp2x/build/config-alleng.sh
index 5724f39dc5..4a3526d50c 100755
--- a/backends/platform/gp2x/build/config-alleng.sh
+++ b/backends/platform/gp2x/build/config-alleng.sh
@@ -18,6 +18,6 @@ export DEFINES=-DNDEBUG
# Edit the configure line to suit.
cd ../../../..
./configure --backend=gp2x --disable-mt32emu --host=gp2x --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-vkeybd
-# --enable-plugins --default-dynamic
+#--enable-plugins --default-dynamic
echo Generating config for GP2X complete. Check for errors.
diff --git a/backends/platform/gp2x/build/config.sh b/backends/platform/gp2x/build/config.sh
index 55954d6231..2bc49564f7 100755
--- a/backends/platform/gp2x/build/config.sh
+++ b/backends/platform/gp2x/build/config.sh
@@ -18,6 +18,6 @@ export DEFINES=-DNDEBUG
# Edit the configure line to suit.
cd ../../../..
./configure --backend=gp2x --disable-mt32emu --host=gp2x --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-vkeybd
-# --enable-plugins --default-dynamic
+#--enable-plugins --default-dynamic
echo Generating config for GP2X complete. Check for errors.
diff --git a/backends/platform/gp2x/events.cpp b/backends/platform/gp2x/events.cpp
index 9a9a59765d..8cd034d2d5 100644
--- a/backends/platform/gp2x/events.cpp
+++ b/backends/platform/gp2x/events.cpp
@@ -35,7 +35,7 @@
#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
+// we should really allow users to map any key to a joystick button using the keymapper.
#define JOY_DEADZONE 2200
#define JOY_XAXIS 0
@@ -273,7 +273,7 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
Combos:
- GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP)
+ GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP) or Virtual Keyboard if enabled
GP2X_BUTTON_L & GP2X_BUTTON_SELECT Common::EVENT_QUIT (Calls Sync() to make sure SD is flushed)
GP2X_BUTTON_L & GP2X_BUTTON_Y Toggles setZoomOnMouse() for larger then 320*240 games to scale to the point + raduis.
GP2X_BUTTON_L & GP2X_BUTTON_START Common::EVENT_MAINMENU (ScummVM Global Main Menu)
@@ -434,29 +434,22 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
}
break;
case GP2X_BUTTON_VOLUP:
- //if (GP2X_BUTTON_STATE_L == TRUE) {
- // displayMessageOnOSD("Setting CPU Speed at 230MHz");
- // GP2X_setCpuspeed(200);
- //event.kbd.keycode = Common::KEYCODE_PLUS;
- //event.kbd.ascii = mapKey(SDLK_PLUS, ev.key.keysym.mod, 0);
- //} else {
- GP2X_mixer_move_volume(1);
+ GP2X_HW::mixerMoveVolume(2);
+ if (GP2X_HW::volumeLevel == 100) {
+ displayMessageOnOSD("Maximum Volume");
+ } else {
displayMessageOnOSD("Increasing Volume");
- //}
+ }
break;
case GP2X_BUTTON_VOLDOWN:
- //if (GP2X_BUTTON_STATE_L == TRUE) {
- // displayMessageOnOSD("Setting CPU Speed at 60MHz");
- // GP2X_setCpuspeed(60);
- //event.kbd.keycode = Common::KEYCODE_MINUS;
- //event.kbd.ascii = mapKey(SDLK_MINUS, ev.key.keysym.mod, 0);
- //} else {
- GP2X_mixer_move_volume(0);
+ GP2X_HW::mixerMoveVolume(1);
+ if (GP2X_HW::volumeLevel == 0) {
+ displayMessageOnOSD("Minimal Volume");
+ } else {
displayMessageOnOSD("Decreasing Volume");
- //}
+ }
break;
-
}
}
return true;
diff --git a/backends/platform/gp2x/gp2x-hw.cpp b/backends/platform/gp2x/gp2x-hw.cpp
index fe02e029f7..38799ea7ad 100644
--- a/backends/platform/gp2x/gp2x-hw.cpp
+++ b/backends/platform/gp2x/gp2x-hw.cpp
@@ -48,6 +48,20 @@
#include <sys/time.h>
#include <unistd.h>
+namespace GP2X_HW {
+
+enum {
+ VOLUME_NOCHG = 0,
+ VOLUME_DOWN = 1,
+ VOLUME_UP = 2,
+ VOLUME_CHANGE_RATE = 8,
+ VOLUME_MIN = 0,
+ VOLUME_INITIAL = 70,
+ VOLUME_MAX = 100
+};
+
+int volumeLevel = VOLUME_INITIAL;
+
/* system registers */
static struct
{
@@ -61,14 +75,14 @@ static volatile unsigned short *MEM_REG;
#define SYS_CLK_FREQ 7372800
-void GP2X_device_init() {
+void deviceInit() {
// Open devices
if (!gp2x_dev[0]) gp2x_dev[0] = open("/dev/mixer", O_RDWR);
if (!gp2x_dev[1]) gp2x_dev[1] = open("/dev/batt", O_RDONLY);
if (!gp2x_dev[2]) gp2x_dev[2] = open("/dev/mem", O_RDWR);
}
-void GP2X_device_deinit() {
+void deviceDeinit() {
// Close devices
{
int i;
@@ -92,68 +106,35 @@ void GP2X_device_deinit() {
unpatchMMU();
}
-// Vairous mixer level fudges.
-// TODO: Clean up and merge quick hacks.
-
-void GP2X_mixer_set_volume(int L /*0..100*/, int R /*0..100*/) {
-
- /* Set an arbitrary percentage value for the hardware mixer volume.
-
- Parameters:
- L (0..100) - volume percentage for the left channel
- R (0..100) - volume percentage for the right channel
-
- Note:
- - A higher percentage than 100 will distort your sound.
- */
-
- unsigned char temp[4];
-
- if (L < 0) L = 0;
- if (L > GP2X_MAXVOL) L = GP2X_MAXVOL;
- if (R < 0) R = 0;
- if (R > GP2X_MAXVOL) R = GP2X_MAXVOL;
-
- temp[0]=(unsigned char)L;
- temp[1]=(unsigned char)R;
- temp[2]=temp[3]=0;
-
- //warning("GP2X_mixer_set_volume is about to set %d %d", L, R);
- ioctl(gp2x_dev[0], SOUND_MIXER_WRITE_PCM, temp);
-}
-
-int GP2X_mixer_get_volume() {
- int vol;
- ioctl(gp2x_dev[0], SOUND_MIXER_READ_PCM, &vol);
- //warning("GP2X_mixer_get_volume returned %d %d", (int)((vol & 0xff)), (int)((vol >> 8) & 0xff));
- return (int)((vol & 0xff));
+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);
+ }
}
-void GP2X_mixer_move_volume(int UpDown) {
- // Raise volume 5% if 1 passed, lower 5% if 0.
- int curvol, newvol;
- ioctl(gp2x_dev[0], SOUND_MIXER_READ_PCM, &curvol);
- curvol = ((int)((curvol & 0xff)));
- newvol = ((int)((curvol & 0xff)));
- //warning("GP2X_mixer_move_volume got current volume @ %d", curvol);
- if (UpDown == 1) {
- newvol = (curvol + 5);
- } else if (UpDown == 0) {
- newvol = (curvol - 5);
- }
- //warning("GP2X_mixer_move_volume is about to set volume @ %d", newvol);
- GP2X_mixer_set_volume(newvol, newvol);
- return;
-}
-
-void GP2X_setCpuspeed(unsigned int mhz)
+void setCpuspeed(unsigned int mhz)
{
set_FCLK(mhz);
set_DCLK_Div(0);
set_920_Div(0);
}
-int GP2X_getBattLevel() {
+int getBattLevel() {
int devbatt;
unsigned short currentval=0;
devbatt = open("/dev/batt", O_RDONLY);
@@ -213,3 +194,6 @@ void gp2x_video_wait_vsync(void)
MEM_REG[0x2846>>1]=(MEM_REG[0x2846>>1] | 0x20) & ~2;
while (!(MEM_REG[0x2846>>1] & 2));
}
+
+} /* namespace GP2X_HW */
+
diff --git a/backends/platform/gp2x/gp2x-hw.h b/backends/platform/gp2x/gp2x-hw.h
index 89ad1093e4..7e72812cc4 100644
--- a/backends/platform/gp2x/gp2x-hw.h
+++ b/backends/platform/gp2x/gp2x-hw.h
@@ -31,16 +31,18 @@
#ifndef GP2X_HW_H
#define GP2X_HW_H
+namespace GP2X_HW {
+
#define GP2X_MAXVOL 100 // Highest level permitted by GP2X's mixer
#define SYS_CLK_FREQ 7372800 // Clock Frequency
-extern void GP2X_device_init();
-extern void GP2X_device_deinit();
-extern void GP2X_mixer_set_volume(int, int);
-extern int GP2X_mixer_get_volume();
-extern void GP2X_mixer_move_volume(int);
-extern void GP2X_setCpuspeed(unsigned int cpuspeed);
-extern int GP2X_getBattLevel();
+extern int volumeLevel;
+
+extern void deviceInit();
+extern void deviceDeinit();
+extern void mixerMoveVolume(int);
+extern void setCpuspeed(unsigned int cpuspeed);
+extern int getBattLevel();
extern void save_system_regs(void); /* save some registers */
extern void set_display_clock_div(unsigned div);
@@ -50,4 +52,6 @@ extern void set_DCLK_Div(unsigned short div); /* 0 to 7 divider (freq=FCLK/(1+di
extern void Disable_940(void); /* 940t down */
extern void gp2x_video_wait_vsync(void);
+} /* namespace GP2X_HW */
+
#endif //GP2X_HW_H
diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp
index 15b5e19e5d..3d416f8415 100644
--- a/backends/platform/gp2x/gp2x.cpp
+++ b/backends/platform/gp2x/gp2x.cpp
@@ -34,6 +34,7 @@
#include "common/archive.h"
#include "common/config-manager.h"
#include "common/debug.h"
+#include "common/EventRecorder.h"
#include "common/events.h"
#include "common/util.h"
@@ -232,15 +233,16 @@ void OSystem_GP2X::initBackend() {
// switch. Still, it's a potential future change to keep in mind.
_timer = new DefaultTimerManager();
_timerID = SDL_AddTimer(10, &timer_handler, _timer);
+ }
+
+ /* Initialise any GP2X specific stuff we may want (Batt Status, scaler etc.) */
+ GP2X_HW::deviceInit();
- // Initialise any GP2X specific stuff we may want (Volume, Batt Status etc.)
- GP2X_device_init();
+ /* Set Default hardware mixer volume to a preset level (VOLUME_INITIAL). This is done to 'reset' volume level if set by other apps. */
+ GP2X_HW::mixerMoveVolume(0);
// Set Default hardware mixer volume to a plesent level.
// This is done to 'reset' volume level if set by other apps.
- GP2X_mixer_set_volume(70, 70);
-
- }
//if (SDL_GP2X_MouseType() == 0) {
// // No mouse, F100 default state.
@@ -318,7 +320,7 @@ OSystem_GP2X::~OSystem_GP2X() {
uint32 OSystem_GP2X::getMillis() {
uint32 millis = SDL_GetTicks();
- getEventManager()->processMillis(millis);
+ g_eventRec.processMillis(millis);
return millis;
}
@@ -446,8 +448,7 @@ void OSystem_GP2X::quit() {
if (_joystick)
SDL_JoystickClose(_joystick);
- //CloseRam();
- GP2X_device_deinit();
+ GP2X_HW::deviceDeinit();
SDL_RemoveTimer(_timerID);
closeMixer();
diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp
index 775c3afb73..a77afd88b7 100644
--- a/backends/platform/gp2x/graphics.cpp
+++ b/backends/platform/gp2x/graphics.cpp
@@ -30,6 +30,7 @@
#include "backends/platform/gp2x/gp2x-common.h"
#include "common/util.h"
+#include "common/mutex.h"
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "graphics/scaler.h"