Subversion Repositories Kolibri OS

Rev

Rev 9211 | Rev 9785 | 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 <time.h>
  30. #include <string.h>
  31. #include <errno.h>
  32.  
  33. #include "SDL_error.h"
  34. #include "SDL_timer.h"
  35. #include "SDL_timer_c.h"
  36. #include "kos32sys.h"
  37.  
  38. #if _POSIX_THREAD_SYSCALL_SOFT
  39. #include <pthread.h>
  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(unsigned ms){
  89.     unsigned start = SDL_GetTicks();
  90.     do{
  91.        delay(1);
  92.     }while (SDL_GetTicks()-start < ms);
  93. }
  94.  
  95. int SDL_SYS_TimerInit(void)
  96. {
  97.         return(0);
  98. }
  99.  
  100. void SDL_SYS_TimerQuit(void)
  101. {
  102. }
  103.  
  104. int SDL_SYS_StartTimer(void)
  105. {
  106.         return(0);
  107. }
  108.  
  109. void SDL_SYS_StopTimer(void)
  110. {
  111. }
  112.