[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src be_base.h,1.4,1.5 be_os5.cpp,1.3,1.4 be_os5.h,1.3,1.4

Chris Apers chrilith at users.sourceforge.net
Sun Dec 11 11:57:07 CET 2005


Update of /cvsroot/scummvm/scummvm/backends/PalmOS/Src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32062

Modified Files:
	be_base.h be_os5.cpp be_os5.h 
Log Message:
Added true timer support
New OS5 ARM backend, preliminary support

Index: be_base.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/be_base.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- be_base.h	5 Nov 2005 10:15:41 -0000	1.4
+++ be_base.h	11 Dec 2005 19:56:31 -0000	1.5
@@ -50,14 +50,16 @@
 #define kDrawBatLow		3020
 #define kDrawFight		3030
 
+typedef struct {
+	uint32 duration, nextExpiry;
+	bool active;
+	OSystem::TimerProc callback;
+} TimerType, *TimerPtr;
+
+extern "C" void SysEventGet(EventType *, Int32);
+
 class OSystem_PalmBase : public OSystem {
 private:
-	struct {
-		uint32 duration, nextExpiry;
-		bool active;
-		TimerProc callback;
-	} _timer;
-
 	virtual void int_initBackend() { }
 	
 	virtual const GraphicsMode *int_getSupportedGraphicsModes() const;
@@ -77,14 +79,15 @@
 //	virtual bool check_hard_keys() = 0;
 	virtual bool check_event(Event &event, EventPtr ev) = 0;
 	
-	void timer_handler();
+	virtual void timer_handler();
 	void battery_handler();
 	virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y) = 0;
 	void simulate_mouse(Event &event, Int8 iHoriz, Int8 iVert, Coord *xr, Coord *yr);
 	virtual void sound_handler() {};
-	virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0);
 
 protected:
+	virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0);
+
 	enum {
 		kKeyNone			= 0,
 		kKeyMouseMove		= 1	<< 0,
@@ -101,6 +104,8 @@
 		int16 x,y,w,h;
 	};
 
+	TimerType _timer;
+
 	RGBColorType _currentPalette[256];
 	uint _paletteDirtyStart, _paletteDirtyEnd;
 	
@@ -129,6 +134,7 @@
 		UInt32 bitLeft;
 		UInt32 bitRight;
 		UInt32 bitButLeft;
+		Boolean hasMore;
 	} _keyMouse;
 
 	bool _mouseVisible;
@@ -214,7 +220,7 @@
 	virtual uint32 getMillis();
 	virtual void delayMillis(uint msecs);
 	
-	void setTimerCallback(TimerProc callback, int interval);
+	virtual void setTimerCallback(TimerProc callback, int interval);
 
 	MutexRef createMutex() { return NULL; }
 	void lockMutex(MutexRef mutex) {}

Index: be_os5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/be_os5.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- be_os5.cpp	5 Nov 2005 10:15:41 -0000	1.3
+++ be_os5.cpp	11 Dec 2005 19:56:31 -0000	1.4
@@ -22,16 +22,92 @@
  */
 
 #include "be_os5.h"
+#include "oscalls.h"
+#include "palmdefs.h"
+
+#ifndef __TWKEYS_H__
+#include <PalmNavigator.h>
+#include <HsKeyCommon.h>
+#endif
+
+static TimerExType _timerEx;
 
 OSystem_PalmOS5::OSystem_PalmOS5() : OSystem_PalmBase() {
 	_sound.active = false;
+	_timerEx.timerID = 0;
+	_timerEx.timer = &_timer;
+
+#ifdef PALMOS_ARM
+	// CHECK : is this ok for OS5 too ?
+	if (HALHRTimerTicksPerSecond(&_timerEx.ticks))
+		_timerEx.ticks = SysTicksPerSecond();
+#endif
+}
+
+#ifdef PALMOS_ARM
+
+static SYSTEM_CALLBACK void timer_handler(void *userDataP) {
+	CALLBACK_PROLOGUE
+	TimerExPtr _timerEx = (TimerExPtr)userDataP;
+	TimerPtr _timer = _timerEx->timer;
+	_timer->duration = _timer->callback(_timer->duration);
+	KALTimerSet(_timerEx->timerID, (_timer->duration * _timerEx->ticks / 1000));
+	CALLBACK_EPILOGUE
+}
+
+void OSystem_PalmOS5::setTimerCallback(TimerProc callback, int timer) {
+	if (_timer.active && _timerEx.timerID)
+		KALTimerDelete(_timerEx.timerID);
+
+	if (callback != NULL) {
+		Err e;
+		CALLBACK_INIT(_timerEx);
+		_timer.duration = timer;
+		_timer.callback = callback;
+
+		// create the timer
+		e = KALTimerCreate(&_timerEx.timerID, appFileCreator, &::timer_handler, &_timerEx);
+		if (!e) {
+			e = KALTimerSet(_timerEx.timerID, (timer * _timerEx.ticks / 1000));
+			if (e) KALTimerDelete(_timerEx.timerID);
+		}
+		_timer.active = (!e);
+
+	} else {
+		_timer.active = false;
+	}
+	
+	if (!_timer.active)
+		_timerEx.timerID = 0;
 }
 
+#endif
+
 void OSystem_PalmOS5::int_initBackend() {
+	if (OPTIONS_TST(kOpt5WayNavigatorV1)) {
+		_keyMouse.bitUp		= keyBitPageUp;
+		_keyMouse.bitDown	= keyBitPageDown;
+		_keyMouse.bitLeft	= keyBitNavLeft;
+		_keyMouse.bitRight	= keyBitNavRight;
+		_keyMouse.bitButLeft= keyBitNavSelect;
+		_keyMouse.hasMore	= true;
+
+	} else if (OPTIONS_TST(kOpt5WayNavigatorV2)) {
+		_keyMouse.bitUp		= keyBitRockerUp;
+		_keyMouse.bitDown	= keyBitRockerDown;
+		_keyMouse.bitLeft	= keyBitRockerLeft;
+		_keyMouse.bitRight	= keyBitRockerRight;
+		_keyMouse.bitButLeft= keyBitRockerCenter;
+		_keyMouse.hasMore	= true;
+	}
 }
 
 void OSystem_PalmOS5::int_quit() {
-	unload_gfx_mode();
+#ifdef PALMOS_ARM
+	if (_timerEx.timerID)
+		KALTimerDelete(_timerEx.timerID);
+#endif
 	clearSoundCallback();
+	unload_gfx_mode();
 	exit(0);
 }

Index: be_os5.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/be_os5.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- be_os5.h	5 Nov 2005 10:15:41 -0000	1.3
+++ be_os5.h	11 Dec 2005 19:56:31 -0000	1.4
@@ -26,9 +26,51 @@
 
 #include "be_base.h"
 
+#if !defined(SYSTEM_CALLBACK) || defined(PALMOS_68K)
+#	define SYSTEM_CALLBACK
+#	ifdef PALMOS_ARM
+#		define CALLBACK_PROLOGUE \
+			__asm { \
+				stmfd  r13!,{r9,r10}; \
+				ldr	   r9,[r0]; \
+				ldr	   r10,[r0,#4]; \
+			}
+#		define CALLBACK_EPILOGUE __asm { ldmfd  r13!,{r9,r10} }
+#		define CALLBACK_INIT(regs) \
+			__asm { \
+				ldr  r0, = regs; \
+				add	 r0,r0,r10; \
+				str	 r9,[r0]; \
+				str	 r10,[r0,#4]; \
+			}
+#	else
+#		define CALLBACK_PROLOGUE \
+			asm (	\
+				movem.l a4-a5, -(sp);	\
+				move.l UserDataP, a0;	\
+				move.l 0(a0), a4;	\
+				move.l 4(a0), a5;	\
+			);
+#		define CALLBACK_EPILOGUE asm ( movem.l (sp)+, a4-a5 );
+#		define CALLBACK_INIT(regs) \
+			{	\
+				void *ptr = ®s; \
+				asm (	\
+					move.l	ptr, a0;	\
+					move.l	a4, 0(a0);	\
+					move.l	a5, 4(a0);	\
+				); \
+			}
+#	endif
+#else
+#	define CALLBACK_PROLOGUE
+#	define CALLBACK_EPILOGUE
+#	define CALLBACK_INIT(regs)
+#endif
+
 typedef struct {
-	UInt32 __a4;
-	UInt32 __a5;
+	UInt32 __reg1;
+	UInt32 __reg2;
 
 	void *proc;
 	void *param;
@@ -36,9 +78,21 @@
 	SndStreamRef handle;
 	Boolean	active;
 } SoundDataType;
+extern SoundDataType _sound;
+
+typedef struct {
+	UInt32 __r9;
+	UInt32 __r10;
+	TimerPtr timer;
+	UInt32 timerID;
+	UInt32 ticks;
+} TimerExType, *TimerExPtr;
 
 class OSystem_PalmOS5 : public OSystem_PalmBase {
 private:
+	byte *_overlayP;
+	WinHandle _overlayH;
+
 	virtual void int_initBackend();
 	virtual void int_updateScreen();
 	virtual void int_initSize(uint w, uint h, int overlayScale);
@@ -49,11 +103,14 @@
 	void draw_mouse();
 	void undraw_mouse();
 	virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y);
-	virtual bool check_event(Event &event, EventPtr ev) { return false;}
+	virtual bool check_event(Event &event, EventPtr ev);
+
+#ifdef PALMOS_ARM
+	void timer_handler() {};
+#endif
 
 protected:
 	UInt16 _sysOldCoord, _sysOldOrientation;
-	SoundDataType _sound;
 
 public:
 	OSystem_PalmOS5();
@@ -64,14 +121,18 @@
 
 	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale);
 
-	virtual void showOverlay() {};
-	virtual void hideOverlay() {};
-	virtual void clearOverlay() {};
-	virtual void grabOverlay(OverlayColor *buf, int pitch) {};
-	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {};
+	virtual void showOverlay();
+	virtual void hideOverlay();
+	virtual void clearOverlay();
+	virtual void grabOverlay(OverlayColor *buf, int pitch);
+	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
 	virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
 	virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
 
+#ifdef PALMOS_ARM
+	void setTimerCallback(TimerProc callback, int interval);
+#endif
+
 	bool setSoundCallback(SoundProc proc, void *param);
 	void clearSoundCallback();
 	





More information about the Scummvm-git-logs mailing list