Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. // Emacs style mode select   -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //
  21. //-----------------------------------------------------------------------------
  22.  
  23. static const char
  24. rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
  25.  
  26.  
  27. #include <stdlib.h>
  28. #include <stdarg.h>
  29. #include <ctype.h>
  30. #include "SDL.h"
  31. #include "SDL_timer.h"
  32.  
  33. #include "doomdef.h"
  34. #include "m_misc.h"
  35. #include "i_video.h"
  36. #include "i_sound.h"
  37.  
  38. #include "d_net.h"
  39. #include "g_game.h"
  40.  
  41. #ifdef __GNUG__
  42. #pragma implementation "i_system.h"
  43. #endif
  44. #include "i_system.h"
  45.  
  46.  
  47.  
  48.  
  49. int     mb_used = 6;
  50.  
  51.  
  52. int I_strncasecmp(char *str1, char *str2, int len)
  53. {
  54.         char c1, c2;
  55.  
  56.         while ( *str1 && *str2 && len-- ) {
  57.                 c1 = *str1++;
  58.                 c2 = *str2++;
  59.                 if ( toupper(c1) != toupper(c2) )
  60.                         return(1);
  61.         }
  62.         return(0);
  63. }
  64.  
  65. void
  66. I_Tactile
  67. ( int   on,
  68.   int   off,
  69.   int   total )
  70. {
  71.   // UNUSED.
  72.   on = off = total = 0;
  73. }
  74.  
  75. ticcmd_t        emptycmd;
  76. ticcmd_t*       I_BaseTiccmd(void)
  77. {
  78.     return &emptycmd;
  79. }
  80.  
  81.  
  82. int  I_GetHeapSize (void)
  83. {
  84.     return mb_used*1024*1024;
  85. }
  86.  
  87. byte* I_ZoneBase (int*  size)
  88. {
  89.     *size = mb_used*1024*1024;
  90.     return (byte *) malloc (*size);
  91. }
  92.  
  93.  
  94.  
  95. //
  96. // I_GetTime
  97. // returns time in 1/35 second tics
  98. //
  99. int  I_GetTime (void)
  100. {
  101.     return (SDL_GetTicks()*TICRATE)/1000;
  102. }
  103.  
  104.  
  105.  
  106. //
  107. // I_Init
  108. //
  109. void I_Init (void)
  110. {
  111.     if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
  112.         I_Error("Could not initialize SDL: %s", SDL_GetError());
  113.  
  114.     I_InitSound();
  115.     //  I_InitGraphics();
  116. }
  117.  
  118. //
  119. // I_Quit
  120. //
  121. void I_Quit (void)
  122. {
  123.     D_QuitNetGame ();
  124.     I_ShutdownSound();
  125.     I_ShutdownMusic();
  126.     M_SaveDefaults ();
  127.     I_ShutdownGraphics();
  128.     exit(0);
  129. }
  130.  
  131. void I_WaitVBL(int count)
  132. {
  133.     SDL_Delay((count*1000)/70);
  134. }
  135.  
  136. void I_BeginRead(void)
  137. {
  138. }
  139.  
  140. void I_EndRead(void)
  141. {
  142. }
  143.  
  144. byte*   I_AllocLow(int length)
  145. {
  146.     byte*       mem;
  147.        
  148.     mem = (byte *)malloc (length);
  149.     memset (mem,0,length);
  150.     return mem;
  151. }
  152.  
  153.  
  154. //
  155. // I_Error
  156. //
  157. extern boolean demorecording;
  158.  
  159. void I_Error (char *error, ...)
  160. {
  161.     va_list     argptr;
  162.  
  163.     // Message first.
  164.     va_start (argptr,error);
  165.     fprintf (stderr, "Error: ");
  166.     vfprintf (stderr,error,argptr);
  167.     fprintf (stderr, "\n");
  168.     va_end (argptr);
  169.  
  170.     fflush( stderr );
  171.  
  172.     // Shutdown. Here might be other errors.
  173.     if (demorecording)
  174.         G_CheckDemoStatus();
  175.  
  176.     D_QuitNetGame ();
  177.     I_ShutdownGraphics();
  178.    
  179.     exit(-1);
  180. }
  181.