i_system.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. static const char
  23. rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include <stdarg.h>
  28. #include <sys/time.h>
  29. #include <unistd.h>
  30. #include "doomdef.h"
  31. #include "m_misc.h"
  32. #include "i_video.h"
  33. #include "i_sound.h"
  34. #include "d_net.h"
  35. #include "g_game.h"
  36. #ifdef __GNUG__
  37. #pragma implementation "i_system.h"
  38. #endif
  39. #include "i_system.h"
  40. int mb_used = 6;
  41. void
  42. I_Tactile
  43. ( int on,
  44. int off,
  45. int total )
  46. {
  47. // UNUSED.
  48. on = off = total = 0;
  49. }
  50. ticcmd_t emptycmd;
  51. ticcmd_t* I_BaseTiccmd(void)
  52. {
  53. return &emptycmd;
  54. }
  55. int I_GetHeapSize (void)
  56. {
  57. return mb_used*1024*1024;
  58. }
  59. byte* I_ZoneBase (int* size)
  60. {
  61. *size = mb_used*1024*1024;
  62. return (byte *) malloc (*size);
  63. }
  64. //
  65. // I_GetTime
  66. // returns time in 1/70th second tics
  67. //
  68. int I_GetTime (void)
  69. {
  70. struct timeval tp;
  71. struct timezone tzp;
  72. int newtics;
  73. static int basetime=0;
  74. gettimeofday(&tp, &tzp);
  75. if (!basetime)
  76. basetime = tp.tv_sec;
  77. newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
  78. return newtics;
  79. }
  80. //
  81. // I_Init
  82. //
  83. void I_Init (void)
  84. {
  85. I_InitSound();
  86. // I_InitGraphics();
  87. }
  88. //
  89. // I_Quit
  90. //
  91. void I_Quit (void)
  92. {
  93. D_QuitNetGame ();
  94. I_ShutdownSound();
  95. I_ShutdownMusic();
  96. M_SaveDefaults ();
  97. I_ShutdownGraphics();
  98. exit(0);
  99. }
  100. void I_WaitVBL(int count)
  101. {
  102. #ifdef SGI
  103. sginap(1);
  104. #else
  105. #ifdef SUN
  106. sleep(0);
  107. #else
  108. usleep (count * (1000000/70) );
  109. #endif
  110. #endif
  111. }
  112. void I_BeginRead(void)
  113. {
  114. }
  115. void I_EndRead(void)
  116. {
  117. }
  118. byte* I_AllocLow(int length)
  119. {
  120. byte* mem;
  121. mem = (byte *)malloc (length);
  122. memset (mem,0,length);
  123. return mem;
  124. }
  125. //
  126. // I_Error
  127. //
  128. extern boolean demorecording;
  129. void I_Error (char *error, ...)
  130. {
  131. va_list argptr;
  132. // Message first.
  133. va_start (argptr,error);
  134. fprintf (stderr, "Error: ");
  135. vfprintf (stderr,error,argptr);
  136. fprintf (stderr, "\n");
  137. va_end (argptr);
  138. fflush( stderr );
  139. // Shutdown. Here might be other errors.
  140. if (demorecording)
  141. G_CheckDemoStatus();
  142. D_QuitNetGame ();
  143. I_ShutdownGraphics();
  144. exit(-1);
  145. }