[Scummvm-cvs-logs] SF.net SVN: scummvm: [27728] scummvm/trunk/backends/platform/gp2x

djwillis at users.sourceforge.net djwillis at users.sourceforge.net
Tue Jun 26 10:50:11 CEST 2007


Revision: 27728
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27728&view=rev
Author:   djwillis
Date:     2007-06-26 01:50:11 -0700 (Tue, 26 Jun 2007)

Log Message:
-----------
Cleanup of the GP2X port to fix compile issues (and the odd warning).

Modified Paths:
--------------
    scummvm/trunk/backends/platform/gp2x/build/build.sh
    scummvm/trunk/backends/platform/gp2x/build/bundle.sh
    scummvm/trunk/backends/platform/gp2x/events.cpp
    scummvm/trunk/backends/platform/gp2x/gp2x-common.h
    scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp
    scummvm/trunk/backends/platform/gp2x/gp2x-hw.h
    scummvm/trunk/backends/platform/gp2x/gp2x-mem.c
    scummvm/trunk/backends/platform/gp2x/gp2x-mem.h
    scummvm/trunk/backends/platform/gp2x/gp2x.cpp
    scummvm/trunk/backends/platform/gp2x/graphics.cpp

Added Paths:
-----------
    scummvm/trunk/backends/platform/gp2x/build/mmuhack.o

Modified: scummvm/trunk/backends/platform/gp2x/build/build.sh
===================================================================
--- scummvm/trunk/backends/platform/gp2x/build/build.sh	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/build/build.sh	2007-06-26 08:50:11 UTC (rev 27728)
@@ -10,6 +10,7 @@
 export CC=arm-open2x-linux-gcc
 export CXXFLAGS=-march=armv4t
 export LDFLAGS=-static
+export ASFLAGS=-mfloat-abi=soft
 
 cd ../../../..
 

Modified: scummvm/trunk/backends/platform/gp2x/build/bundle.sh
===================================================================
--- scummvm/trunk/backends/platform/gp2x/build/bundle.sh	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/build/bundle.sh	2007-06-26 08:50:11 UTC (rev 27728)
@@ -19,6 +19,7 @@
 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 ../../../../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
+

Added: scummvm/trunk/backends/platform/gp2x/build/mmuhack.o
===================================================================
(Binary files differ)


Property changes on: scummvm/trunk/backends/platform/gp2x/build/mmuhack.o
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: scummvm/trunk/backends/platform/gp2x/events.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/events.cpp	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/events.cpp	2007-06-26 08:50:11 UTC (rev 27728)
@@ -72,7 +72,7 @@
 		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 @@
 	//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 @@
 	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 @@
 				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 @@
 				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 @@
 						}
 						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 @@
 				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 @@
 					_km.x_vel = 0;
 					_km.x_down_count = 0;
 				}
-#endif
 
 			} else if (ev.jaxis.axis == JOY_YAXIS) {
 #ifndef JOY_INVERT_Y

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-common.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-common.h	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-common.h	2007-06-26 08:50:11 UTC (rev 27728)
@@ -181,7 +181,6 @@
 	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 @@
 	int _mode;
 	int _transactionMode;
 	bool _fullscreen;
+	
+	bool _screenIsLocked;
+	Graphics::Surface _framebuffer;
 
 	/** Current video mode flags (see DF_* constants) */
 	uint32 _modeFlags;
@@ -382,14 +384,13 @@
 
 	/** 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);

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp	2007-06-26 08:50:11 UTC (rev 27728)
@@ -33,18 +33,21 @@
 #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>
+#include <sys/time.h>
+#include <unistd.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;
-
 /* system registers */
 static struct
 {
@@ -67,20 +70,28 @@
 
 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]);
+	{
+		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;
+	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.
 

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-hw.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-hw.h	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-hw.h	2007-06-26 08:50:11 UTC (rev 27728)
@@ -65,7 +65,6 @@
 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) */

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-mem.c
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-mem.c	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-mem.c	2007-06-26 08:50:11 UTC (rev 27728)
@@ -39,21 +39,23 @@
 
 #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);
-	}
-}
+char uname[256];
 
-void CloseRam (void)
-{
-	if(gp2x_dev) close(gp2x_dev);
-}
+//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 @@
     // 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);
+    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 ("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 @@
 	    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 @@
     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;
+}

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-mem.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-mem.h	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-mem.h	2007-06-26 08:50:11 UTC (rev 27728)
@@ -39,18 +39,21 @@
 // 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
     }
 #endif

Modified: scummvm/trunk/backends/platform/gp2x/gp2x.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2007-06-26 08:50:11 UTC (rev 27728)
@@ -60,11 +60,6 @@
 }
 
 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 @@
 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 @@
 		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 @@
 
 	// 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 @@
 		// 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 @@
 		else
 			_modeFlags &= ~DF_WANT_RECT_OPTIM;
 		break;
+	case kFeatureDisableKeyFiltering:
+		// TODO: Extend as more support for this is added to engines.
+		return;
 	default:
 		break;
 	}

Modified: scummvm/trunk/backends/platform/gp2x/graphics.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/graphics.cpp	2007-06-26 08:42:50 UTC (rev 27727)
+++ scummvm/trunk/backends/platform/gp2x/graphics.cpp	2007-06-26 08:50:11 UTC (rev 27728)
@@ -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::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 @@
 
 	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 @@
 	_km.y_max = effectiveScreenHeight() - 1;
 	_km.delay_time = 25;
 	_km.last_time = 0;
-
 }
 
 void OSystem_GP2X::unloadGFXMode() {
@@ -691,8 +681,10 @@
 	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 @@
 }
 
 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 @@
 }
 
 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 @@
 		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 @@
 	/* 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 last = _mouseVisible;
 	_mouseVisible = visible;
 
-	//updateScreen();
-
 	return last;
 }
 
@@ -1174,7 +1187,6 @@
 	if (x != _mouseCurState.x || y != _mouseCurState.y) {
 		_mouseCurState.x = x;
 		_mouseCurState.y = y;
-		//updateScreen();
 	}
 }
 
@@ -1521,7 +1533,6 @@
 		zoomdst.h = (tmpScreenHeight);
 
 		SDL_GP2X_Display(&zoomdst);
-
 	};
 
 
@@ -1545,6 +1556,8 @@
 	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 @@
 				displayMessageOnOSD(buffer);
 			}
 		}
-
 	}
-
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list