aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorJohn Willis2007-06-26 08:50:11 +0000
committerJohn Willis2007-06-26 08:50:11 +0000
commit11fccdbff242ec238d9ccd86525bfa5a41be01bc (patch)
tree000f978497697b56311fd2602bcb4ed64fde3a96 /backends/platform
parentcf0eb563adb10454b1a4c9b0d7c387526b348b30 (diff)
downloadscummvm-rg350-11fccdbff242ec238d9ccd86525bfa5a41be01bc.tar.gz
scummvm-rg350-11fccdbff242ec238d9ccd86525bfa5a41be01bc.tar.bz2
scummvm-rg350-11fccdbff242ec238d9ccd86525bfa5a41be01bc.zip
Cleanup of the GP2X port to fix compile issues (and the odd warning).
svn-id: r27728
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/gp2x/build/build.sh1
-rw-r--r--backends/platform/gp2x/build/bundle.sh16
-rw-r--r--backends/platform/gp2x/build/mmuhack.obin0 -> 1720 bytes
-rw-r--r--backends/platform/gp2x/events.cpp53
-rw-r--r--backends/platform/gp2x/gp2x-common.h15
-rw-r--r--backends/platform/gp2x/gp2x-hw.cpp49
-rw-r--r--backends/platform/gp2x/gp2x-hw.h1
-rw-r--r--backends/platform/gp2x/gp2x-mem.c124
-rw-r--r--backends/platform/gp2x/gp2x-mem.h17
-rw-r--r--backends/platform/gp2x/gp2x.cpp30
-rw-r--r--backends/platform/gp2x/graphics.cpp55
11 files changed, 195 insertions, 166 deletions
diff --git a/backends/platform/gp2x/build/build.sh b/backends/platform/gp2x/build/build.sh
index dc2f56cb18..1ea77f4937 100644
--- a/backends/platform/gp2x/build/build.sh
+++ b/backends/platform/gp2x/build/build.sh
@@ -10,6 +10,7 @@ export CXX=arm-open2x-linux-g++
export CC=arm-open2x-linux-gcc
export CXXFLAGS=-march=armv4t
export LDFLAGS=-static
+export ASFLAGS=-mfloat-abi=soft
cd ../../../..
diff --git a/backends/platform/gp2x/build/bundle.sh b/backends/platform/gp2x/build/bundle.sh
index 93ae45f0e3..cdadaa8116 100644
--- a/backends/platform/gp2x/build/bundle.sh
+++ b/backends/platform/gp2x/build/bundle.sh
@@ -19,6 +19,7 @@ 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'`/
cp ../../../../AUTHORS ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../README ./scummvm-gp2x-`date '+%Y-%m-%d'`/
@@ -27,10 +28,21 @@ cp ../../../../COPYRIGHT ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../NEWS ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../gui/themes/modern.ini ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../gui/themes/modern.zip ./scummvm-gp2x-`date '+%Y-%m-%d'`/
-
+cp ../../../../dists/pred.dic ./scummvm-gp2x-`date '+%Y-%m-%d'`/
echo Making Stripped GPE.
arm-open2x-linux-strip ./scummvm-gp2x-`date '+%Y-%m-%d'`/scummvm.gp2x
echo Building ZIP bundle.
-echo You should have a "scummvm-gp2x-`date '+%Y-%m-%d'`.zip" for the GP2X port ready to go.
+if [ -f /usr/bin/zip ]
+ then
+ cd "scummvm-gp2x-`date '+%Y-%m-%d'`"
+ zip "../scummvm-gp2x-`date '+%Y-%m-%d'`.zip" * -r -9
+ echo You should have a "scummvm-gp2x-`date '+%Y-%m-%d'`.zip" for the GP2X port ready to go.
+ echo All included files can also be found in ./"scummvm-gp2x-`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-gp2x-`date '+%Y-%m-%d'`"
+ echo - Please use you preferred archive tool to bundle these files.
+fi
+
diff --git a/backends/platform/gp2x/build/mmuhack.o b/backends/platform/gp2x/build/mmuhack.o
new file mode 100644
index 0000000000..475f4a54ae
--- /dev/null
+++ b/backends/platform/gp2x/build/mmuhack.o
Binary files differ
diff --git a/backends/platform/gp2x/events.cpp b/backends/platform/gp2x/events.cpp
index ff3c0e65f0..ef39ab333e 100644
--- a/backends/platform/gp2x/events.cpp
+++ b/backends/platform/gp2x/events.cpp
@@ -72,7 +72,7 @@ static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode)
return key;
} else if (unicode) {
return unicode;
- } else if (key >= 'a' && key <= 'z' && mod & KMOD_SHIFT) {
+ } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
return key & ~0x20;
} else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
return 0;
@@ -239,7 +239,7 @@ void OSystem_GP2X::moveStick() {
//int GP2X_BUTTON_STATE_B = FALSE;
//int GP2X_BUTTON_STATE_Y = FALSE;
//int GP2X_BUTTON_STATE_X = FALSE;
- int GP2X_BUTTON_STATE_L = FALSE;
+ int GP2X_BUTTON_STATE_L = FALSE;
//int GP2X_BUTTON_STATE_R = FALSE;
//int GP2X_BUTTON_STATE_START = FALSE;
//int GP2X_BUTTON_STATE_SELECT = FALSE;
@@ -299,6 +299,7 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
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_Y Toggles setZoomOnMouse() for larger then 320*240 games to scale to the point + raduis.
+ GP2X_BUTTON_L & GP2X_BUTTON_A Common::EVENT_PREDICTIVE_DIALOG for predictive text entry box (AGI games)
*/
while(SDL_PollEvent(&ev)) {
@@ -334,45 +335,13 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
break;
}
- // Ctrl-m toggles mouse capture
- //if (b == Common::KBD_CTRL && ev.key.keysym.sym == 'm') {
- // toggleMouseGrab();
- // break;
- //}
-
-//#ifdef MACOSX
-// // On Macintosh', Cmd-Q quits
-// if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') {
-// event.type = Common::EVENT_QUIT;
-// return true;
-// }
-//#elif defined(UNIX)
-// // On other unices, Control-Q quits
-// if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') {
-// event.type = Common::EVENT_QUIT;
-// return true;
-// }
-//#else
-// // Ctrl-z and Alt-X quit
-// if ((b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT && ev.key.keysym.sym == 'x')) {
-// event.type = Common::EVENT_QUIT;
-// return true;
-// }
-//#endif
-//
-// // Ctrl-Alt-<key> will change the GFX mode
-// if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
-//
-// handleScalerHotkeys(ev.key);
-// break;
-// }
const bool event_complete = remapKey(ev,event);
if (event_complete)
return true;
event.type = Common::EVENT_KEYDOWN;
- event.kbd.keycode = ev.key.keysym.sym;
+ 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;
@@ -385,7 +354,7 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
return true;
event.type = Common::EVENT_KEYUP;
- event.kbd.keycode = ev.key.keysym.sym;
+ 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());
@@ -477,8 +446,15 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
}
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);
+ }
+// event.kbd.keycode = Common::KEYCODE_PERIOD;
+// event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+
break;
case GP2X_BUTTON_Y:
if (GP2X_BUTTON_STATE_L == TRUE) {
@@ -599,10 +575,6 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
axis = 0;
if ( ev.jaxis.axis == JOY_XAXIS) {
-#ifdef JOY_ANALOG
- _km.x_vel = axis/2000;
- _km.x_down_count = 0;
-#else
if (axis != 0) {
_km.x_vel = (axis > 0) ? 1:-1;
_km.x_down_count = 1;
@@ -610,7 +582,6 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
_km.x_vel = 0;
_km.x_down_count = 0;
}
-#endif
} else if (ev.jaxis.axis == JOY_YAXIS) {
#ifndef JOY_INVERT_Y
diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h
index 68f2fb997e..a48239222b 100644
--- a/backends/platform/gp2x/gp2x-common.h
+++ b/backends/platform/gp2x/gp2x-common.h
@@ -181,7 +181,6 @@ public:
virtual bool setGraphicsMode(int mode);
virtual int getGraphicsMode() const;
- //virtual void setWindowCaption(const char *caption);
virtual bool openCD(int drive);
virtual int getOutputSampleRate() const;
@@ -267,6 +266,9 @@ protected:
int _mode;
int _transactionMode;
bool _fullscreen;
+
+ bool _screenIsLocked;
+ Graphics::Surface _framebuffer;
/** Current video mode flags (see DF_* constants) */
uint32 _modeFlags;
@@ -382,14 +384,13 @@ protected:
/** Set the position of the virtual mouse cursor. */
void setMousePos(int x, int y);
- virtual void fillMouseEvent(Common::Event &event, int x, int y);
- //void toggleMouseGrab();
+ void fillMouseEvent(Common::Event &event, int x, int y);
- virtual void internUpdateScreen();
+ void internUpdateScreen();
- virtual void loadGFXMode();
- virtual void unloadGFXMode();
- virtual void hotswapGFXMode();
+ void loadGFXMode();
+ void unloadGFXMode();
+ void hotswapGFXMode();
void setFullscreenMode(bool enable);
void setAspectRatioCorrection(bool enable);
diff --git a/backends/platform/gp2x/gp2x-hw.cpp b/backends/platform/gp2x/gp2x-hw.cpp
index d1b6f80a1e..d322aa5d08 100644
--- a/backends/platform/gp2x/gp2x-hw.cpp
+++ b/backends/platform/gp2x/gp2x-hw.cpp
@@ -33,17 +33,20 @@
#include "gp2x-common.h"
#include "gp2x-hw.h"
+#include "gp2x-mem.h"
-// Linux includes to let us goof about with the system.
+// Linux includes to let us goof about with the system in a 'standard' way.
+#include <fcntl.h>
+#include <pthread.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 <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-static unsigned long gp2x_dev[8]={0,0,0,0,0,0,0,0};//, gp2x_ticks_per_second;
-static volatile unsigned short *gp2x_memregs;
+#include <sys/time.h>
+#include <unistd.h>
/* system registers */
static struct
@@ -67,19 +70,27 @@ void GP2X_device_init() {
void GP2X_device_deinit() {
// Close devices
- if (gp2x_dev[0]) close(gp2x_dev[0]);
- if (gp2x_dev[1]) close(gp2x_dev[1]);
- if (gp2x_dev[2]) close(gp2x_dev[2]);
-
- MEM_REG[0x91c>>1]=system_reg.SYSCSETREG;
- MEM_REG[0x910>>1]=system_reg.FPLLVSETREG;
- MEM_REG[0x3B40>>1]=system_reg.DUALINT920;
- MEM_REG[0x3B42>>1]=system_reg.DUALINT940;
- MEM_REG[0x3B48>>1]=system_reg.DUALCTRL940;
- MEM_REG[0x904>>1]=system_reg.SYSCLKENREG;
- MEM_REG[0x924>>1]=dispclockdiv;
-}
+ {
+ int i;
+ for(i=0;i<8;i++)
+ {
+ if(gp2x_dev[i])
+ {
+ close(gp2x_dev[i]);
+ }
+ }
+ }
+
+ MEM_REG[0x91c>>1] = system_reg.SYSCSETREG;
+ MEM_REG[0x910>>1] = system_reg.FPLLVSETREG;
+ MEM_REG[0x3B40>>1] = system_reg.DUALINT920;
+ MEM_REG[0x3B42>>1] = system_reg.DUALINT940;
+ MEM_REG[0x3B48>>1] = system_reg.DUALCTRL940;
+ MEM_REG[0x904>>1] = system_reg.SYSCLKENREG;
+ MEM_REG[0x924>>1] = dispclockdiv;
+ unpatchMMU();
+}
// Vairous mixer level fudges.
// TODO: Clean up and merge quick hacks.
diff --git a/backends/platform/gp2x/gp2x-hw.h b/backends/platform/gp2x/gp2x-hw.h
index bb681154d7..0427698bc4 100644
--- a/backends/platform/gp2x/gp2x-hw.h
+++ b/backends/platform/gp2x/gp2x-hw.h
@@ -65,7 +65,6 @@ extern void GP2X_mixer_move_volume(int);
extern void GP2X_setCpuspeed(unsigned int cpuspeed);
extern int GP2X_getBattLevel();
-
extern void save_system_regs(void); /* save some registers */
extern void set_display_clock_div(unsigned div);
extern void set_FCLK(unsigned MHZ); /* adjust the clock frequency (in Mhz units) */
diff --git a/backends/platform/gp2x/gp2x-mem.c b/backends/platform/gp2x/gp2x-mem.c
index f129deb783..1c2c1562a8 100644
--- a/backends/platform/gp2x/gp2x-mem.c
+++ b/backends/platform/gp2x/gp2x-mem.c
@@ -39,20 +39,22 @@
#include "gp2x-mem.h"
-void InitRam (void)
-{
- if(!gp2x_dev)
- {
- gp2x_dev = open("/dev/mem", O_RDWR);
- gp2x_ram = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0x03000000);
- gp2x_memregs = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0xc0000000);
- }
-}
-
-void CloseRam (void)
-{
- if(gp2x_dev) close(gp2x_dev);
-}
+char uname[256];
+
+//void InitRam (void)
+//{
+// if(!gp2x_dev)
+// {
+// gp2x_dev = open("/dev/mem", O_RDWR);
+// gp2x_ram = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0x03000000);
+// gp2x_memregs = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0xc0000000);
+// }
+//}
+
+//void CloseRam (void)
+//{
+// if(gp2x_dev) close(gp2x_dev);
+//}
/*
****** [BEGIN] Squidge's MMU hack code ******
@@ -201,34 +203,30 @@ int hackpgtable (void)
// do this in user mode, so we have to patch the kernel to get it to run it for us in supervisor mode. We dothis
// at the moment by overwriting the sys_newuname function and then calling it.
- lseek (gp2x_dev, 0x6ec00, SEEK_SET); // fixme: We should ask the kernel for this address rather than assuming it...
- read (gp2x_dev, &oldc1, 4);
- read (gp2x_dev, &oldc2, 4);
- read (gp2x_dev, &oldc3, 4);
- read (gp2x_dev, &oldc4, 4);
-
- printf ("0:%08X %08X - %08X %08X\n", oldc1, oldc2, newc1, newc2);
-
+ lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); // fixme: We should ask the kernel for this address rather than assuming it...
+ read (gp2x_dev[2], &oldc1, 4);
+ read (gp2x_dev[2], &oldc2, 4);
+ read (gp2x_dev[2], &oldc3, 4);
+ read (gp2x_dev[2], &oldc4, 4);
+ //printf ("0:%08X %08X - %08X %08X\n", oldc1, oldc2, newc1, newc2);
+ //printf ("point1 %d\n",a);
- printf ("point1 %d\n",a);
do {
- lseek (gp2x_dev, 0x6ec00, SEEK_SET);
- a+=write (gp2x_dev, &newc1, 4);
- a+=write (gp2x_dev, &newc2, 4);
+ lseek (gp2x_dev[2], 0x6ec00, SEEK_SET);
+ a+=write (gp2x_dev[2], &newc1, 4);
+ a+=write (gp2x_dev[2], &newc2, 4);
SDL_Delay(200);
try++;
- ttb = myuname(name);
- printf ("2:%08X try %d\n", ttb,try);
+ ttb = myuname(uname);
+ //printf ("2:%08X try %d\n", ttb,try);
} while (ttb==0 && try<4);
+ lseek (gp2x_dev[2], 0x6ec00, SEEK_SET);
+ a+=write (gp2x_dev[2], &oldc1, 4);
+ a+=write (gp2x_dev[2], &oldc2, 4);
-
- lseek (gp2x_dev, 0x6ec00, SEEK_SET);
- a+=write (gp2x_dev, &oldc1, 4);
- a+=write (gp2x_dev, &oldc2, 4);
-
- printf ("2:%08X %d\n", ttb,a);
+ //printf ("2:%08X %d\n", ttb,a);
if (ttb!=0) {
@@ -243,28 +241,28 @@ int hackpgtable (void)
unsigned int tlbc3 = 0xee080f17; // mcr 15, 0, r0, cr8, cr7, 0
unsigned int tlbc4 = 0xe1a0f00e; // mov pc, lr
- lseek (gp2x_dev, 0x6ec00, SEEK_SET);
- write (gp2x_dev, &tlbc1, 4);
- write (gp2x_dev, &tlbc2, 4);
- write (gp2x_dev, &tlbc3, 4);
- write (gp2x_dev, &tlbc4, 4);
+ lseek (gp2x_dev[2], 0x6ec00, SEEK_SET);
+ write (gp2x_dev[2], &tlbc1, 4);
+ write (gp2x_dev[2], &tlbc2, 4);
+ write (gp2x_dev[2], &tlbc3, 4);
+ write (gp2x_dev[2], &tlbc4, 4);
SDL_Delay(200);
- ttx = myuname(name);
+ ttx = myuname(uname);
printf ("Return from uname: %08X\n", ttx);
- lseek (gp2x_dev, 0x6ec00, SEEK_SET);
- write (gp2x_dev, &oldc1, 4);
- write (gp2x_dev, &oldc2, 4);
- write (gp2x_dev, &oldc3, 4);
- write (gp2x_dev, &oldc4, 4);
- lseek (gp2x_dev, 0x0, SEEK_SET);
+ lseek (gp2x_dev[2], 0x6ec00, SEEK_SET);
+ write (gp2x_dev[2], &oldc1, 4);
+ write (gp2x_dev[2], &oldc2, 4);
+ write (gp2x_dev[2], &oldc3, 4);
+ write (gp2x_dev[2], &oldc4, 4);
+ lseek (gp2x_dev[2], 0x0, SEEK_SET);
return 0;
}
- lseek (gp2x_dev, 0x0, SEEK_SET);
+ lseek (gp2x_dev[2], 0x0, SEEK_SET);
return 1;
//printf ("Restored contents\n");
@@ -292,10 +290,34 @@ void SetClock (unsigned c)
gp2x_memregs[0x910>>1] = v;
}
-void MMUpatch (void)
+void patchMMU (void)
{
- volatile unsigned int *secbuf = (unsigned int *)malloc (204800);
+ //volatile unsigned int *secbuf = (unsigned int *)malloc (204800);
- // Squidge's MMU hack
- hackpgtable();
+ printf ("Reconfiguring cached memory regions...\n");
+
+ //hackpgtable();
+ //printf ("Sucess...\n");
+
+ system("/sbin/rmmod mmuhack");
+ system("/sbin/insmod -f mmuhack.o");
+
+ int mmufd = open("/dev/mmuhack", O_RDWR);
+
+ if(mmufd < 0)
+ {
+ printf ("Upper memory uncached (attempt failed, access to upper memory will be slower)...\n");
+ }
+ else
+ {
+ printf ("Upper memory cached...\n");
+ close(mmufd);
+ }
+}
+
+void unpatchMMU (void)
+{
+ printf ("Restoreing cached memory regions...\n");
+ system("/sbin/rmmod mmuhack");
+ return 1;
}
diff --git a/backends/platform/gp2x/gp2x-mem.h b/backends/platform/gp2x/gp2x-mem.h
index bf2d050623..b4df7b3a00 100644
--- a/backends/platform/gp2x/gp2x-mem.h
+++ b/backends/platform/gp2x/gp2x-mem.h
@@ -39,17 +39,20 @@ extern "C" {
// Use Squidge's MMU patch rather then myown (his is neater).
// The effect if not that great but cacheing the upper RAM is no bad thing (tm) ;).
-void InitRam (void);
-void CloseRam (void);
+//extern void InitRam (void);
+//extern void CloseRam (void);
// Set ARM920t clock frequency
-void SetClock (unsigned c);
-void MMUpatch (void);
+extern void SetClock (unsigned c);
+extern void patchMMU (void);
+extern void unpatchMMU (void);
#define SYS_CLK_FREQ 7372800
-char name[256];
-unsigned long gp2x_dev;
-volatile unsigned short *gp2x_ram, *gp2x_memregs;
+//unsigned long gp2x_dev;
+//volatile unsigned short *gp2x_ram, *gp2x_memregs;
+
+static unsigned long gp2x_dev[8]={0,0,0,0,0,0,0,0};//, gp2x_ticks_per_second;
+static volatile unsigned short *gp2x_ram, *gp2x_memregs;
#ifdef __cplusplus
}
diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp
index 42a9345762..3cf5df2e3a 100644
--- a/backends/platform/gp2x/gp2x.cpp
+++ b/backends/platform/gp2x/gp2x.cpp
@@ -60,11 +60,6 @@ static Uint32 timer_handler(Uint32 interval, void *param) {
}
int main(int argc, char *argv[]) {
-
- // Setup GP2X upper 32MB caching
- //InitRam();
- //MMUpatch();
-
extern OSystem *OSystem_GP2X_create();
g_system = OSystem_GP2X_create();
assert(g_system);
@@ -82,7 +77,7 @@ OSystem *OSystem_GP2X_create() {
void OSystem_GP2X::initBackend() {
assert(!_inited);
- ConfMan.set("joystick_num", 0);
+ ConfMan.setInt("joystick_num", 0);
int joystick_num = ConfMan.getInt("joystick_num");
uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
@@ -96,6 +91,7 @@ void OSystem_GP2X::initBackend() {
error("Could not initialize SDL: %s", SDL_GetError());
}
+ SDL_ShowCursor(SDL_DISABLE);
// Setup default save path to be workingdir/saves
#ifndef PATH_MAX
@@ -187,19 +183,10 @@ void OSystem_GP2X::initBackend() {
// enable joystick
if (joystick_num > -1 && SDL_NumJoysticks() > 0) {
- printf("Using joystick: %s\n", SDL_JoystickName(0));
+ //printf("Using joystick: %s\n", SDL_JoystickName(0));
_joystick = SDL_JoystickOpen(joystick_num);
}
- // Initialise any GP2X specific stuff we may want (Volume, Batt Status etc.)
- GP2X_device_init();
-
- // 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);
-
- SDL_ShowCursor(SDL_DISABLE);
-
// Create the savefile manager, if none exists yet (we check for this to
// allow subclasses to provide their own).
if (_savefile == 0) {
@@ -225,6 +212,14 @@ void OSystem_GP2X::initBackend() {
// switch. But it's a long term goal to do just that!
_timer = new DefaultTimerManager();
_timerID = SDL_AddTimer(10, &timer_handler, _timer);
+
+ // Initialise any GP2X specific stuff we may want (Volume, Batt Status etc.)
+ GP2X_device_init();
+
+ // 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);
+
}
OSystem::initBackend();
@@ -321,6 +316,9 @@ void OSystem_GP2X::setFeatureState(Feature f, bool enable) {
else
_modeFlags &= ~DF_WANT_RECT_OPTIM;
break;
+ case kFeatureDisableKeyFiltering:
+ // TODO: Extend as more support for this is added to engines.
+ return;
default:
break;
}
diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp
index c3ed5c627c..1aa7519f86 100644
--- a/backends/platform/gp2x/graphics.cpp
+++ b/backends/platform/gp2x/graphics.cpp
@@ -29,10 +29,10 @@
*/
#include "backends/platform/gp2x/gp2x-common.h"
-#include "graphics/scaler.h"
#include "common/util.h"
#include "graphics/font.h"
#include "graphics/fontman.h"
+#include "graphics/scaler.h"
#include "graphics/surface.h"
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
@@ -236,17 +236,12 @@ void OSystem_GP2X::initSize(uint w, uint h){
}
void OSystem_GP2X::loadGFXMode() {
-
- //enable 320x240 image to fit the 320x240 display area (aka, disable scaling)
- //gp2x_video_RGB_setscaling(320,240);
-
assert(_inited);
_forceFull = true;
_modeFlags |= DF_UPDATE_EXPAND_1_PIXEL;
int hwW, hwH;
-#ifndef __MAEMO__
_overlayWidth = _screenWidth * _scaleFactor;
_overlayHeight = _screenHeight * _scaleFactor;
@@ -258,10 +253,6 @@ void OSystem_GP2X::loadGFXMode() {
hwW = _screenWidth * _scaleFactor;
hwH = effectiveScreenHeight();
-#else
- hwW = _overlayWidth;
- hwH = _overlayHeight;
-#endif
//
// Create the surface that contains the 8 bit game data
@@ -349,7 +340,6 @@ void OSystem_GP2X::loadGFXMode() {
_km.y_max = effectiveScreenHeight() - 1;
_km.delay_time = 25;
_km.last_time = 0;
-
}
void OSystem_GP2X::unloadGFXMode() {
@@ -691,8 +681,10 @@ void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, in
assert (_transactionMode == kTransactionNone);
assert(src);
- if (_screen == NULL)
+ if (_screen == NULL) {
+ warning("OSystem_GP2X::copyRectToScreen: _screen == NULL");
return;
+ }
Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
@@ -757,6 +749,19 @@ void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, in
}
Graphics::Surface *OSystem_GP2X::lockScreen() {
+ assert (_transactionMode == kTransactionNone);
+
+ // Lock the graphics mutex
+ lockMutex(_graphicsMutex);
+
+ // paranoia check
+ assert(!_screenIsLocked);
+ _screenIsLocked = true;
+
+ // Try to lock the screen surface
+ if (SDL_LockSurface(_screen) == -1)
+ error("SDL_LockSurface failed: %s", SDL_GetError());
+
_framebuffer.pixels = _screen->pixels;
_framebuffer.w = _screen->w;
_framebuffer.h = _screen->h;
@@ -767,8 +772,20 @@ Graphics::Surface *OSystem_GP2X::lockScreen() {
}
void OSystem_GP2X::unlockScreen() {
- // Force screen update
+ assert (_transactionMode == kTransactionNone);
+
+ // paranoia check
+ assert(_screenIsLocked);
+ _screenIsLocked = false;
+
+ // Unlock the screen surface
+ SDL_UnlockSurface(_screen);
+
+ // Trigger a full screen update
_forceFull = true;
+
+ // Finally unlock the graphics mutex
+ unlockMutex(_graphicsMutex);
}
void OSystem_GP2X::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) {
@@ -818,11 +835,9 @@ void OSystem_GP2X::addDirtyRect(int x, int y, int w, int h, bool realCoordinates
h = height - y;
}
-#ifndef DISABLE_SCALERS
if (_adjustAspectRatio && !_overlayVisible && !realCoordinates) {
makeRectStretchable(x, y, w, h);
}
-#endif
if (w == width && h == height) {
_forceFull = true;
@@ -851,7 +866,7 @@ void OSystem_GP2X::makeChecksums(const byte *buf) {
/* the 8x8 blocks in buf are enumerated starting in the top left corner and
* reading each line at a time from left to right */
for (y = 0; y != last_y; y++, buf += _screenWidth * (8 - 1))
- for (x = 0; x != last_x; x++, buf += 8) { // Adler32 checksum algorithm (from RFC1950, used by gzip and zlib).
+ for (x = 0; x != last_x; x++, buf += 8) {
// Adler32 checksum algorithm (from RFC1950, used by gzip and zlib).
// This computes the Adler32 checksum of a 8x8 pixel block. Note
// that we can do the modulo operation (which is the slowest part)
@@ -1165,8 +1180,6 @@ bool OSystem_GP2X::showMouse(bool visible) {
bool last = _mouseVisible;
_mouseVisible = visible;
- //updateScreen();
-
return last;
}
@@ -1174,7 +1187,6 @@ void OSystem_GP2X::setMousePos(int x, int y) {
if (x != _mouseCurState.x || y != _mouseCurState.y) {
_mouseCurState.x = x;
_mouseCurState.y = y;
- //updateScreen();
}
}
@@ -1521,7 +1533,6 @@ void OSystem_GP2X::drawMouse() {
zoomdst.h = (tmpScreenHeight);
SDL_GP2X_Display(&zoomdst);
-
};
@@ -1545,6 +1556,8 @@ void OSystem_GP2X::displayMessageOnOSD(const char *msg) {
assert (_transactionMode == kTransactionNone);
assert(msg);
+ Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+
uint i;
// Lock the OSD surface for drawing
@@ -1696,7 +1709,5 @@ void OSystem_GP2X::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
displayMessageOnOSD(buffer);
}
}
-
}
-
}