i_system.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code 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
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "Precompiled.h"
  21. #include "globaldata.h"
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <stdarg.h>
  26. #include "doomdef.h"
  27. #include "m_misc.h"
  28. #include "i_video.h"
  29. #include "i_sound.h"
  30. #include "d_net.h"
  31. #include "g_game.h"
  32. #ifdef __GNUG__
  33. #pragma implementation "i_system.h"
  34. #endif
  35. #include "i_system.h"
  36. #include "Main.h"
  37. #if 1
  38. ticcmd_t* I_BaseTiccmd(void)
  39. {
  40. return &::g->emptycmd;
  41. }
  42. int I_GetHeapSize (void)
  43. {
  44. return ::g->mb_used*1024*1024;
  45. }
  46. //
  47. // I_GetTime
  48. // returns time in 1/70th second tics
  49. //
  50. int I_GetTime (void)
  51. {
  52. return ::g->current_time;
  53. }
  54. void I_SetTime( int time_in )
  55. {
  56. ::g->current_time = time_in;
  57. }
  58. //
  59. // I_Init
  60. //
  61. void I_Init (void)
  62. {
  63. I_InitSound();
  64. // I_InitGraphics();
  65. }
  66. //
  67. // I_Quit
  68. //
  69. void I_Quit (void)
  70. {
  71. D_QuitNetGame ();
  72. I_ShutdownSound();
  73. I_ShutdownMusic();
  74. M_SaveDefaults ();
  75. I_ShutdownGraphics();
  76. // exit(0);
  77. // Exceptions disabled by default on PS3
  78. // throw;
  79. }
  80. void I_WaitVBL(int count)
  81. {
  82. // PS3 fixme
  83. //Sleep(0);
  84. }
  85. void I_BeginRead(void)
  86. {
  87. }
  88. void I_EndRead(void)
  89. {
  90. }
  91. //
  92. // I_Error
  93. //
  94. extern bool debugOutput;
  95. void I_Printf(char* msg, ...)
  96. {
  97. char pmsg[1024];
  98. va_list argptr;
  99. // Message first.
  100. if( debugOutput ) {
  101. va_start (argptr,msg);
  102. vsprintf (pmsg, msg, argptr);
  103. safeOutputDebug(pmsg);
  104. va_end (argptr);
  105. }
  106. }
  107. void I_PrintfE(char* msg, ...)
  108. {
  109. char pmsg[1024];
  110. va_list argptr;
  111. // Message first.
  112. if( debugOutput ) {
  113. va_start (argptr,msg);
  114. vsprintf (pmsg, msg, argptr);
  115. safeOutputDebug("ERROR: ");
  116. safeOutputDebug(pmsg);
  117. va_end (argptr);
  118. }
  119. }
  120. void I_Error(char *error, ...)
  121. {
  122. const int ERROR_MSG_SIZE = 1024;
  123. char error_msg[ERROR_MSG_SIZE];
  124. va_list argptr;
  125. // Message first.
  126. if( debugOutput ) {
  127. va_start (argptr,error);
  128. idStr::vsnPrintf (error_msg, ERROR_MSG_SIZE, error, argptr);
  129. safeOutputDebug("Error: ");
  130. safeOutputDebug(error_msg);
  131. safeOutputDebug("\n");
  132. va_end (argptr);
  133. }
  134. // CRASH DUMP - enable this to get extra info on error from crash dumps
  135. //*(int*)0x0 = 21;
  136. DoomLib::Interface.QuitCurrentGame();
  137. idLib::Printf( "DOOM Classic error: %s", error_msg );
  138. common->SwitchToGame( DOOM3_BFG );
  139. }
  140. #endif