Rearange menu of mpegplayer. Add new menu with "settings" and "quit", and remove...
[kugel-rb.git] / apps / plugins / doom / i_system.c
blob601ffc3b272d6ff650c2b0efdddd217efff5197d
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // $Log: i_system.c,v $
19 // Revision 1.9 2006-04-15 22:08:36 kkurbjun
20 // Slight code cleanups, fixed sound parameter - now it saves. Old configurations will be reset.
22 // Revision 1.8 2006-04-14 21:07:55 kkurbjun
23 // Start of profiling support for doom.
25 // Revision 1.7 2006-04-04 11:16:44 dave
26 // Correct the #ifdef logic for timer_unregister() and add a comment describing why we need to surround the use of the user timer with #ifdefs
28 // Revision 1.6 2006-04-03 17:32:46 dave
29 // Clean up the (incorrect) #ifdef spaghetti for the timer. We now have a user timer on the ipods, so we use it.
31 // Revision 1.5 2006-04-03 17:11:42 kkurbjun
32 // Finishing touches
34 // Revision 1.4 2006-04-03 17:00:56 dave
35 // Doom can't use the user timer at the same time as using the grayscale lib.
37 // Revision 1.3 2006-04-02 12:45:29 amiconn
38 // Use TIMER_FREQ for timers in plugins. Fixes timer speed on iPod.
40 // Revision 1.2 2006-04-02 01:52:44 kkurbjun
41 // Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
43 // Revision 1.1 2006-03-28 15:44:01 dave
44 // Patch #2969 - Doom! Currently only working on the H300.
47 // DESCRIPTION:
49 //-----------------------------------------------------------------------------
51 #include "doomdef.h"
52 #include "m_misc.h"
53 #include "i_video.h"
54 #include "i_sound.h"
56 #include "d_net.h"
57 #include "g_game.h"
58 #include "z_zone.h"
60 #ifdef __GNUG__
61 #pragma implementation "i_system.h"
62 #endif
63 #include "i_system.h"
65 #include "rockmacros.h"
68 // I_GetTime
69 // returns time in 1/70th second tics
72 /* NOTE:
74 The user timer is used to generate a 70Hz tick for Doom. But it
75 is unavailable for the greyscale targets (it's used by the greyscale
76 lib) and is not implemented in the simulator - so we have to
77 approximate it using current_tick.
79 #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE)
80 volatile unsigned int doomtimer=0;
82 void doomtime(void)
84 doomtimer++;
86 #endif
88 int I_GetTime (void)
90 #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE)
91 return doomtimer;
92 #else
93 #if HZ==100
94 return ((7*(*rb->current_tick))/20);
95 #else
96 #error FIX - I assumed HZ was 100
97 #endif
98 #endif
102 // I_Init
105 // I was looking into this and comparing the speed versus Prboom
106 // Turns out they are running the game much slower then I thought the game was
107 // played. This explains why run was unusable other then through straight stretches
108 // The game is much slower now (in terms of game speed).
109 void I_Init (void)
111 #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE)
112 rb->timer_register(1, NULL, TIMER_FREQ/TICRATE, doomtime IF_COP(, CPU));
113 #endif
114 I_InitSound();
118 // I_Quit
121 void I_Quit (void)
123 I_ShutdownSound();
124 I_ShutdownMusic();
125 I_ShutdownGraphics();
126 #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE)
127 rb->timer_unregister();
128 #endif
129 doomexit=1;
132 void I_WaitVBL(int count)
134 rb->sleep(count);
138 // I_Error
140 extern boolean demorecording;
142 void I_Error (char *error, ...)
144 char p_buf[50];
145 va_list ap;
147 va_start(ap, error);
148 vsnprintf(p_buf,sizeof(p_buf), error, ap);
149 va_end(ap);
151 printf("%s\n",p_buf);
153 // Shutdown. Here might be other errors.
154 if (demorecording)
155 G_CheckDemoStatus();
157 I_Quit();
158 rb->sleep(HZ*2);