Subversion Repositories Kolibri OS

Rev

Rev 5131 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5131 clevermous 1
/*
2
    SDL - Simple DirectMedia Layer
3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
4
 
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Library General Public
7
    License as published by the Free Software Foundation; either
8
    version 2 of the License, or (at your option) any later version.
9
 
10
    This library is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
    Library General Public License for more details.
14
 
15
    You should have received a copy of the GNU Library General Public
16
    License along with this library; if not, write to the Free
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
19
    Sam Lantinga
20
    slouken@devolution.com
21
*/
22
 
23
#ifdef SAVE_RCSID
24
static char rcsid =
25
 "@(#) $Id: SDL_systimer.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
26
#endif
27
 
28
#include 
29
#include 
30
#include 
31
#include 
32
#include 
33
#include 
6356 ashmew2 34
#include 
5131 clevermous 35
 
36
#include "SDL_error.h"
37
#include "SDL_timer.h"
38
#include "SDL_timer_c.h"
39
 
40
#if _POSIX_THREAD_SYSCALL_SOFT
41
#include 
42
#endif
43
 
44
#if defined(DISABLE_THREADS) || defined(FORK_HACK)
45
#define USE_ITIMER
46
#endif
47
 
48
 
49
/* The first ticks value of the application */
50
//static struct timeval start;
51
//static unsigned startlo,starthi;
52
//static unsigned clockrate;
53
static unsigned starttime;
54
 
55
void SDL_StartTicks(void)
56
{
57
// gettimeofday(&start, NULL);
58
//  __asm__ ("int $0x40" : "=a"(clockrate) : "a"(18),"b"(5));
59
//  __asm__ ("rdtsc" : "=a"(startlo),"=d"(starthi));
60
	__asm__ ("int $0x40" : "=a"(starttime) : "a"(26),"b"(9));
61
}
62
 
63
 
64
Uint32 SDL_GetTicks (void)
65
{
66
/* struct timeval now;
67
 Uint32 ticks;
68
 gettimeofday(&now, NULL);
69
 ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
70
 return(ticks);*/
71
	/*int res;
72
	__asm__ ("rdtsc\n\t"
73
		"sub (_startlo),%%eax\n\t"
74
		"sbb (_starthi),%%edx\n\t"
75
		"push %%eax\n\t"
76
		"mov %%edx,%%eax\n\t"
77
		"mov $1000,%%ecx\n\t"
78
		"mul %%ecx\n\t"
79
		"xchg (%%esp),%%eax\n\t"
80
		"mul %%ecx\n\t"
81
		"add %%edx,(%%esp)\n\t"
82
		"pop %%edx\n\t"
83
		"divl (_clockrate)\n\t" : "=a"(res));
84
	return res;*/
85
	unsigned curtime;
86
	__asm__ ("int $0x40" : "=a"(curtime) : "a"(26),"b"(9));
87
	return (curtime-starttime)*10;
88
}
89
 
90
void SDL_Delay (Uint32 ms)
91
{
6356 ashmew2 92
delay(ms * 100);
5131 clevermous 93
/*  Uint32 start = SDL_GetTicks();
94
  do
95
    __asm__("int $0x40" :: "a"(68),"b"(1));
96
  while (SDL_GetTicks()-start < ms);*/
97
}
98
 
99
int SDL_SYS_TimerInit(void)
100
{
101
	return(0);
102
}
103
 
104
void SDL_SYS_TimerQuit(void)
105
{
106
}
107
 
108
int SDL_SYS_StartTimer(void)
109
{
110
	return(0);
111
}
112
 
113
void SDL_SYS_StopTimer(void)
114
{
115
}