doom

a minimalistic implementation of doom
git clone git://ssnf.xyz/doom
Log | Files | Refs

i_system.c (1188B)


      1 #include <stdlib.h>
      2 #include <stdio.h>
      3 #include <string.h>
      4 #include <stdarg.h>
      5 #include <sys/time.h>
      6 #include <unistd.h>
      7 
      8 #include "doomdef.h"
      9 #include "m_misc.h"
     10 #include "i_video.h"
     11 #include "i_sound.h"
     12 #include "d_net.h"
     13 #include "g_game.h"
     14 #include "i_system.h"
     15 
     16 int
     17 I_GetTime()
     18 {
     19     struct timeval tp;
     20     static int     basetime = 0;
     21     int            newtics;
     22   
     23     gettimeofday(&tp, NULL);
     24     if (!basetime)
     25 		basetime = tp.tv_sec;
     26 	newtics = (tp.tv_sec-basetime) * TICRATE + tp.tv_usec * TICRATE / 1000000;
     27     return newtics;
     28 }
     29 
     30 void
     31 I_Init()
     32 {
     33     I_InitSound();
     34 }
     35 
     36 void
     37 I_Quit()
     38 {
     39     D_QuitNetGame ();
     40     I_ShutdownSound();
     41     I_ShutdownMusic();
     42     I_ShutdownGraphics();
     43     exit(0);
     44 }
     45 
     46 void
     47 I_WaitVBL(int count)
     48 {
     49     usleep (count * (1000000/70) );                                
     50 }
     51 
     52 extern boolean demorecording;
     53 
     54 void
     55 I_Error(char *error, ...)
     56 {
     57     va_list	argptr;
     58 	int i;
     59     
     60     va_start(argptr,error);
     61     fprintf(stderr, "Error: ");
     62     vfprintf(stderr,error,argptr);
     63     fprintf(stderr, "\n");
     64     va_end(argptr);
     65     fflush(stderr);
     66     if (demorecording)
     67 		G_CheckDemoStatus();
     68     D_QuitNetGame();
     69     I_ShutdownGraphics();
     70 	i = *(int*)0;
     71     exit(i);
     72 }