Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
8211 maxcodehac 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 
9202 turbocat 29
#include 
8211 maxcodehac 30
#include 
31
#include 
32
 
33
#include "SDL_error.h"
34
#include "SDL_timer.h"
35
#include "SDL_timer_c.h"
9202 turbocat 36
#include "SDL_kos.h"
8211 maxcodehac 37
 
38
#if _POSIX_THREAD_SYSCALL_SOFT
39
#include 
40
#endif
41
 
42
#if defined(DISABLE_THREADS) || defined(FORK_HACK)
43
#define USE_ITIMER
44
#endif
45
 
46
 
47
/* The first ticks value of the application */
48
//static struct timeval start;
49
//static unsigned startlo,starthi;
50
//static unsigned clockrate;
51
static unsigned starttime;
52
 
53
void SDL_StartTicks(void)
54
{
55
// gettimeofday(&start, NULL);
56
//  __asm__ ("int $0x40" : "=a"(clockrate) : "a"(18),"b"(5));
57
//  __asm__ ("rdtsc" : "=a"(startlo),"=d"(starthi));
58
	__asm__ ("int $0x40" : "=a"(starttime) : "a"(26),"b"(9));
59
}
60
 
61
 
62
Uint32 SDL_GetTicks (void)
63
{
64
/* struct timeval now;
65
 Uint32 ticks;
66
 gettimeofday(&now, NULL);
67
 ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
68
 return(ticks);*/
69
	/*int res;
70
	__asm__ ("rdtsc\n\t"
71
		"sub (_startlo),%%eax\n\t"
72
		"sbb (_starthi),%%edx\n\t"
73
		"push %%eax\n\t"
74
		"mov %%edx,%%eax\n\t"
75
		"mov $1000,%%ecx\n\t"
76
		"mul %%ecx\n\t"
77
		"xchg (%%esp),%%eax\n\t"
78
		"mul %%ecx\n\t"
79
		"add %%edx,(%%esp)\n\t"
80
		"pop %%edx\n\t"
81
		"divl (_clockrate)\n\t" : "=a"(res));
82
	return res;*/
83
	unsigned curtime;
84
	__asm__ ("int $0x40" : "=a"(curtime) : "a"(26),"b"(9));
85
	return (curtime-starttime)*10;
86
}
87
 
88
void SDL_Delay (Uint32 ms)
89
{
9202 turbocat 90
    __kos__delay100(ms);
8211 maxcodehac 91
/*  Uint32 start = SDL_GetTicks();
92
  do
93
    __asm__("int $0x40" :: "a"(68),"b"(1));
94
  while (SDL_GetTicks()-start < ms);*/
95
}
96
 
97
int SDL_SYS_TimerInit(void)
98
{
99
	return(0);
100
}
101
 
102
void SDL_SYS_TimerQuit(void)
103
{
104
}
105
 
106
int SDL_SYS_StartTimer(void)
107
{
108
	return(0);
109
}
110
 
111
void SDL_SYS_StopTimer(void)
112
{
113
}