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

Bluddy at users.sourceforge.net Bluddy at users.sourceforge.net
Mon Jun 21 17:13:37 CEST 2010


Revision: 50116
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50116&view=rev
Author:   Bluddy
Date:     2010-06-21 15:13:36 +0000 (Mon, 21 Jun 2010)

Log Message:
-----------
PSP: moved RTC to singleton to allow usage by classes other than Osystem

Modified Paths:
--------------
    scummvm/trunk/backends/platform/psp/Makefile
    scummvm/trunk/backends/platform/psp/module.mk
    scummvm/trunk/backends/platform/psp/osys_psp.cpp
    scummvm/trunk/backends/platform/psp/osys_psp.h
    scummvm/trunk/backends/platform/psp/thread.cpp
    scummvm/trunk/backends/platform/psp/thread.h

Added Paths:
-----------
    scummvm/trunk/backends/platform/psp/rtc.cpp
    scummvm/trunk/backends/platform/psp/rtc.h

Modified: scummvm/trunk/backends/platform/psp/Makefile
===================================================================
--- scummvm/trunk/backends/platform/psp/Makefile	2010-06-21 15:05:48 UTC (rev 50115)
+++ scummvm/trunk/backends/platform/psp/Makefile	2010-06-21 15:13:36 UTC (rev 50116)
@@ -147,6 +147,7 @@
 	pspkeyboard.o \
 	audio.o \
 	thread.o \
+	rtc.o \
 	mp3.o
 
 # Include common Scummvm makefile

Modified: scummvm/trunk/backends/platform/psp/module.mk
===================================================================
--- scummvm/trunk/backends/platform/psp/module.mk	2010-06-21 15:05:48 UTC (rev 50115)
+++ scummvm/trunk/backends/platform/psp/module.mk	2010-06-21 15:13:36 UTC (rev 50116)
@@ -15,6 +15,7 @@
 	pspkeyboard.o \
 	audio.o \
 	thread.o \
+	rtc.o \
 	mp3.o
 
 MODULE_DIRS += \

Modified: scummvm/trunk/backends/platform/psp/osys_psp.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp.cpp	2010-06-21 15:05:48 UTC (rev 50115)
+++ scummvm/trunk/backends/platform/psp/osys_psp.cpp	2010-06-21 15:13:36 UTC (rev 50116)
@@ -37,6 +37,7 @@
 #include "backends/platform/psp/psppixelformat.h"
 #include "backends/platform/psp/osys_psp.h"
 #include "backends/platform/psp/powerman.h"
+#include "backends/platform/psp/rtc.h"
 
 #include "backends/saves/psp/psp-saves.h"
 #include "backends/timer/default/default-timer.h"
@@ -64,6 +65,9 @@
 void OSystem_PSP::initBackend() {
 	DEBUG_ENTER_FUNC();
 
+	// Instantiate real time clock
+	PspRtc::instance();
+	
 	_cursor.enableCursorPalette(false);
 	_cursor.setXY(PSP_SCREEN_WIDTH >> 1, PSP_SCREEN_HEIGHT >> 1);	// Mouse in the middle of the screen
 
@@ -320,7 +324,7 @@
 }
 
 uint32 OSystem_PSP::getMillis() {
-	return _pspRtc.getMillis();
+	return PspRtc::instance().getMillis();
 }
 
 void OSystem_PSP::delayMillis(uint msecs) {

Modified: scummvm/trunk/backends/platform/psp/osys_psp.h
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp.h	2010-06-21 15:05:48 UTC (rev 50115)
+++ scummvm/trunk/backends/platform/psp/osys_psp.h	2010-06-21 15:13:36 UTC (rev 50116)
@@ -60,7 +60,6 @@
 	InputHandler _inputHandler;
 	PspAudio _audio;
 	PspTimer _pspTimer;
-	PspRtc _pspRtc;
 
 public:
 	OSystem_PSP() : _savefile(0), _mixer(0), _timer(0), _pendingUpdate(false), _pendingUpdateCounter(0) {}

Added: scummvm/trunk/backends/platform/psp/rtc.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/rtc.cpp	                        (rev 0)
+++ scummvm/trunk/backends/platform/psp/rtc.cpp	2010-06-21 15:13:36 UTC (rev 50116)
@@ -0,0 +1,87 @@
+/* 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: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/psp/osys_psp.cpp $
+ * $Id: osys_psp.cpp 49903 2010-06-16 09:04:27Z Bluddy $
+ *
+ */
+
+#include <time.h> 
+#include <psptypes.h>
+#include <psprtc.h>
+ 
+#include "common/scummsys.h" 
+#include "backends/platform/psp/rtc.h" 
+ 
+//#define __PSP_DEBUG_FUNCS__	/* For debugging function calls */
+//#define __PSP_DEBUG_PRINT__	/* For debug printouts */
+
+#include "backends/platform/psp/trace.h"
+
+
+// Class PspRtc ---------------------------------------------------------------
+DECLARE_SINGLETON(PspRtc)
+
+void PspRtc::init() {						// init our starting ticks
+	uint32 ticks[2];
+	sceRtcGetCurrentTick((u64 *)ticks);
+
+	_startMillis = ticks[0]/1000;
+	_startMicros = ticks[0];
+	//_lastMillis = ticks[0]/1000;	//debug - only when we don't subtract startMillis
+}
+
+#define MS_LOOP_AROUND 4294967				/* We loop every 2^32 / 1000 = 71 minutes */
+#define MS_LOOP_CHECK  60000				/* Threading can cause weird mixups without this */
+
+// Note that after we fill up 32 bits ie 50 days we'll loop back to 0, which may cause 
+// unpredictable results
+uint32 PspRtc::getMillis() {
+	uint32 ticks[2];
+	
+	sceRtcGetCurrentTick((u64 *)ticks);		// can introduce weird thread delays
+	
+	uint32 millis = ticks[0]/1000;
+	millis -= _startMillis;					// get ms since start of program
+
+	if ((int)_lastMillis - (int)millis > MS_LOOP_CHECK) {		// we must have looped around
+		if (_looped == false) {					// check to make sure threads do this once
+			_looped = true;
+			_milliOffset += MS_LOOP_AROUND;		// add the needed offset
+			PSP_DEBUG_PRINT("looping around. last ms[%d], curr ms[%d]\n", _lastMillis, millis);
+		}	
+	} else {
+		_looped = false;
+	}
+	
+	_lastMillis = millis;	
+	
+	return millis + _milliOffset;
+}
+
+uint32 PspRtc::getMicros() {
+	uint32 ticks[2];
+	
+	sceRtcGetCurrentTick((u64 *)ticks);
+	ticks[0] -= _startMicros;
+	
+	return ticks[0]; 
+}
+


Property changes on: scummvm/trunk/backends/platform/psp/rtc.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: scummvm/trunk/backends/platform/psp/rtc.h
===================================================================
--- scummvm/trunk/backends/platform/psp/rtc.h	                        (rev 0)
+++ scummvm/trunk/backends/platform/psp/rtc.h	2010-06-21 15:13:36 UTC (rev 50116)
@@ -0,0 +1,45 @@
+/* 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: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/psp/osys_psp.cpp $
+ * $Id: osys_psp.cpp 49903 2010-06-16 09:04:27Z Bluddy $
+ *
+ */
+
+#ifndef _PSP_RTC_H_
+#define _PSP_RTC_H_
+
+#include "common/singleton.h"
+ 
+class PspRtc : public Common::Singleton<PspRtc>{
+private:
+	uint32 _startMillis;
+	uint32 _startMicros;
+	uint32 _lastMillis;
+	uint32 _milliOffset;		// to prevent looping around of millis
+	bool _looped;				// make sure we only loop once - for threading
+public:
+	PspRtc() : _startMillis(0), _startMicros(0), _lastMillis(0), _milliOffset(0), _looped(false) { init(); }
+	void init();
+	uint32 getMillis();
+	uint32 getMicros();
+};
+
+#endif
\ No newline at end of file


Property changes on: scummvm/trunk/backends/platform/psp/rtc.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: scummvm/trunk/backends/platform/psp/thread.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/thread.cpp	2010-06-21 15:05:48 UTC (rev 50115)
+++ scummvm/trunk/backends/platform/psp/thread.cpp	2010-06-21 15:13:36 UTC (rev 50116)
@@ -23,9 +23,6 @@
  *
  */
 
-#include <time.h> 
-#include <psptypes.h>
-#include <psprtc.h>
 #include <pspthreadman.h> 
 
 #include "backends/platform/psp/thread.h"
@@ -192,57 +189,3 @@
         externalMutex.lock();		// must lock external mutex here for continuation
 }
 
-//#define __PSP_DEBUG_FUNCS__	/* For debugging function calls */
-//#define __PSP_DEBUG_PRINT__	/* For debug printouts */
-
-#include "backends/platform/psp/trace.h"
-
-
-// Class PspRtc ---------------------------------------------------------------
-
-void PspRtc::init() {						// init our starting ticks
-	uint32 ticks[2];
-	sceRtcGetCurrentTick((u64 *)ticks);
-
-	_startMillis = ticks[0]/1000;
-	_startMicros = ticks[0];
-	//_lastMillis = ticks[0]/1000;	//debug - only when we don't subtract startMillis
-}
-
-#define MS_LOOP_AROUND 4294967				/* We loop every 2^32 / 1000 = 71 minutes */
-#define MS_LOOP_CHECK  60000				/* Threading can cause weird mixups without this */
-
-// Note that after we fill up 32 bits ie 50 days we'll loop back to 0, which may cause 
-// unpredictable results
-uint32 PspRtc::getMillis() {
-	uint32 ticks[2];
-	
-	sceRtcGetCurrentTick((u64 *)ticks);		// can introduce weird thread delays
-	
-	uint32 millis = ticks[0]/1000;
-	millis -= _startMillis;					// get ms since start of program
-
-	if ((int)_lastMillis - (int)millis > MS_LOOP_CHECK) {		// we must have looped around
-		if (_looped == false) {					// check to make sure threads do this once
-			_looped = true;
-			_milliOffset += MS_LOOP_AROUND;		// add the needed offset
-			PSP_DEBUG_PRINT("looping around. last ms[%d], curr ms[%d]\n", _lastMillis, millis);
-		}	
-	} else {
-		_looped = false;
-	}
-	
-	_lastMillis = millis;	
-	
-	return millis + _milliOffset;
-}
-
-uint32 PspRtc::getMicros() {
-	uint32 ticks[2];
-	
-	sceRtcGetCurrentTick((u64 *)ticks);
-	ticks[0] -= _startMicros;
-	
-	return ticks[0]; 
-}
-

Modified: scummvm/trunk/backends/platform/psp/thread.h
===================================================================
--- scummvm/trunk/backends/platform/psp/thread.h	2010-06-21 15:05:48 UTC (rev 50115)
+++ scummvm/trunk/backends/platform/psp/thread.h	2010-06-21 15:13:36 UTC (rev 50116)
@@ -73,24 +73,9 @@
 	PspCondition() : _mutex(true), _waitingThreads(0), _signaledThreads(0),
 								_waitSem(0), _doneSem(0) {}
 	void wait(PspMutex &externalMutex);
-	void releaseAll();	
+	void releaseAll();
 };
 
-
-class PspRtc {
-private:
-	uint32 _startMillis;
-	uint32 _startMicros;
-	uint32 _lastMillis;
-	uint32 _milliOffset;		// to prevent looping around of millis
-	bool _looped;				// make sure we only loop once
-public:
-	PspRtc() : _startMillis(0), _startMicros(0), _lastMillis(0), _milliOffset(0), _looped(false) { init(); }
-	void init();
-	uint32 getMillis();
-	uint32 getMicros();
-};
-
 enum ThreadPriority {
 	PRIORITY_MAIN_THREAD = 36,
 	PRIORITY_TIMER_THREAD = 30,


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