Subversion Repositories Kolibri OS

Rev

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

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