~ubuntu-branches/ubuntu/raring/scummvm/raring

« back to all changes in this revision

Viewing changes to backends/platform/psp/rtc.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff
  • Date: 2011-05-25 19:02:23 UTC
  • mto: (21.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20110525190223-fiqm0oaec714xk31
Tags: upstream-1.3.0
ImportĀ upstreamĀ versionĀ 1.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/psp/osys_psp.cpp $
22
 
 * $Id: osys_psp.cpp 49903 2010-06-16 09:04:27Z Bluddy $
 
21
 * $URL$
 
22
 * $Id$
23
23
 *
24
24
 */
25
25
 
26
 
#include <time.h> 
 
26
#include <time.h>
27
27
#include <psptypes.h>
28
28
#include <psprtc.h>
29
 
 
30
 
#include "common/scummsys.h" 
31
 
#include "backends/platform/psp/rtc.h" 
32
 
 
 
29
 
 
30
#include "common/scummsys.h"
 
31
#include "backends/platform/psp/rtc.h"
 
32
 
33
33
//#define __PSP_DEBUG_FUNCS__   /* For debugging function calls */
34
34
//#define __PSP_DEBUG_PRINT__   /* For debug printouts */
35
35
 
37
37
 
38
38
 
39
39
// Class PspRtc ---------------------------------------------------------------
40
 
DECLARE_SINGLETON(PspRtc)
 
40
DECLARE_SINGLETON(PspRtc);
41
41
 
42
42
void PspRtc::init() {                                           // init our starting ticks
43
43
        uint32 ticks[2];
51
51
#define MS_LOOP_AROUND 4294967                          /* We loop every 2^32 / 1000 = 71 minutes */
52
52
#define MS_LOOP_CHECK  60000                            /* Threading can cause weird mixups without this */
53
53
 
54
 
// Note that after we fill up 32 bits ie 50 days we'll loop back to 0, which may cause 
 
54
// Note that after we fill up 32 bits ie 50 days we'll loop back to 0, which may cause
55
55
// unpredictable results
56
56
uint32 PspRtc::getMillis() {
57
57
        uint32 ticks[2];
58
 
        
 
58
 
59
59
        sceRtcGetCurrentTick((u64 *)ticks);             // can introduce weird thread delays
60
 
        
 
60
 
61
61
        uint32 millis = ticks[0]/1000;
62
62
        millis -= _startMillis;                                 // get ms since start of program
63
63
 
66
66
                        _looped = true;
67
67
                        _milliOffset += MS_LOOP_AROUND;         // add the needed offset
68
68
                        PSP_DEBUG_PRINT("looping around. last ms[%d], curr ms[%d]\n", _lastMillis, millis);
69
 
                }       
 
69
                }
70
70
        } else {
71
71
                _looped = false;
72
72
        }
73
 
        
74
 
        _lastMillis = millis;   
75
 
        
 
73
 
 
74
        _lastMillis = millis;
 
75
 
76
76
        return millis + _milliOffset;
77
77
}
78
78
 
79
79
uint32 PspRtc::getMicros() {
80
80
        uint32 ticks[2];
81
 
        
 
81
 
82
82
        sceRtcGetCurrentTick((u64 *)ticks);
83
83
        ticks[0] -= _startMicros;
84
 
        
85
 
        return ticks[0]; 
 
84
 
 
85
        return ticks[0];
86
86
}
87
87