summaryrefslogtreecommitdiff
path: root/src/i_system.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/i_system.c')
-rw-r--r--src/i_system.c184
1 files changed, 93 insertions, 91 deletions
diff --git a/src/i_system.c b/src/i_system.c
index f37b5bec..cd8ddcee 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -38,23 +38,19 @@
#include <unistd.h>
#endif
-#include "deh_main.h"
-#include "doomdef.h"
-#include "doomstat.h"
+#include "config.h"
+
+#include "deh_str.h"
+#include "doomtype.h"
#include "m_argv.h"
#include "m_config.h"
#include "m_misc.h"
#include "i_joystick.h"
+#include "i_sound.h"
#include "i_timer.h"
#include "i_video.h"
-#include "s_sound.h"
-
-#include "d_net.h"
-#include "g_game.h"
#include "i_system.h"
-#include "txt_main.h"
-
#include "w_wad.h"
#include "z_zone.h"
@@ -62,7 +58,29 @@
#define DEFAULT_RAM 16 /* MiB */
#define MIN_RAM 4 /* MiB */
-int show_endoom = 1;
+
+typedef struct atexit_listentry_s atexit_listentry_t;
+
+struct atexit_listentry_s
+{
+ atexit_func_t func;
+ boolean run_on_error;
+ atexit_listentry_t *next;
+};
+
+static atexit_listentry_t *exit_funcs = NULL;
+
+void I_AtExit(atexit_func_t func, boolean run_on_error)
+{
+ atexit_listentry_t *entry;
+
+ entry = malloc(sizeof(*entry));
+
+ entry->func = func;
+ entry->run_on_error = run_on_error;
+ entry->next = exit_funcs;
+ exit_funcs = entry;
+}
// Tactile feedback function, probably used for the Logitech Cyberman
@@ -192,7 +210,45 @@ byte *I_ZoneBase (int *size)
return zonemem;
}
-//
+void I_PrintBanner(char *msg)
+{
+ int i;
+ int spaces = 35 - (strlen(msg) / 2);
+
+ for (i=0; i<spaces; ++i)
+ putchar(' ');
+
+ puts(msg);
+}
+
+void I_PrintDivider(void)
+{
+ int i;
+
+ for (i=0; i<75; ++i)
+ {
+ putchar('=');
+ }
+
+ putchar('\n');
+}
+
+void I_PrintStartupBanner(char *gamedescription)
+{
+ I_PrintDivider();
+ I_PrintBanner(gamedescription);
+ I_PrintDivider();
+
+ printf(
+ " " PACKAGE_NAME " is free software, covered by the GNU General Public\n"
+ " License. There is NO warranty; not even for MERCHANTABILITY or FITNESS\n"
+ " FOR A PARTICULAR PURPOSE. You are welcome to change and distribute\n"
+ " copies under certain conditions. See the source for more information.\n");
+
+ I_PrintDivider();
+}
+
+//
// I_ConsoleStdout
//
// Returns true if stdout is a real console, false if it is a file
@@ -211,69 +267,21 @@ boolean I_ConsoleStdout(void)
//
// I_Init
//
+/*
void I_Init (void)
{
I_CheckIsScreensaver();
I_InitTimer();
I_InitJoystick();
}
-
-#define ENDOOM_W 80
-#define ENDOOM_H 25
-
-//
-// Displays the text mode ending screen after the game quits
-//
-
-void I_Endoom(void)
+void I_BindVariables(void)
{
- unsigned char *endoom_data;
- unsigned char *screendata;
- int y;
- int indent;
-
- endoom_data = W_CacheLumpName(DEH_String("ENDOOM"), PU_STATIC);
-
- // Set up text mode screen
-
- TXT_Init();
-
- // Make sure the new window has the right title and icon
-
- I_SetWindowCaption();
- I_SetWindowIcon();
-
- // Write the data to the screen memory
-
- screendata = TXT_GetScreenData();
-
- indent = (ENDOOM_W - TXT_SCREEN_W) / 2;
-
- for (y=0; y<TXT_SCREEN_H; ++y)
- {
- memcpy(screendata + (y * TXT_SCREEN_W * 2),
- endoom_data + (y * ENDOOM_W + indent) * 2,
- TXT_SCREEN_W * 2);
- }
-
- // Wait for a keypress
-
- while (true)
- {
- TXT_UpdateScreen();
-
- if (TXT_GetChar() >= 0)
- {
- break;
- }
-
- TXT_Sleep(0);
- }
-
- // Shut down text mode screen
-
- TXT_Shutdown();
+ I_BindVideoVariables();
+ I_BindJoystickVariables();
+ I_BindSoundVariables();
}
+*/
+
//
// I_Quit
@@ -281,40 +289,31 @@ void I_Endoom(void)
void I_Quit (void)
{
- D_QuitNetGame ();
- G_CheckDemoStatus();
- S_Shutdown();
+ atexit_listentry_t *entry;
- if (!screensaver_mode)
- {
- M_SaveDefaults ();
- }
-
- I_ShutdownGraphics();
+ // Run through all exit functions
+
+ entry = exit_funcs;
- if (show_endoom && !testcontrols && !screensaver_mode)
+ while (entry != NULL)
{
- I_Endoom();
+ entry->func();
+ entry = entry->next;
}
exit(0);
}
-void I_WaitVBL(int count)
-{
- I_Sleep((count * 1000) / 70);
-}
-
//
// I_Error
//
-extern boolean demorecording;
static boolean already_quitting = false;
void I_Error (char *error, ...)
{
- va_list argptr;
+ va_list argptr;
+ atexit_listentry_t *entry;
if (already_quitting)
{
@@ -336,15 +335,18 @@ void I_Error (char *error, ...)
// Shutdown. Here might be other errors.
- if (demorecording)
+ entry = exit_funcs;
+
+ while (entry != NULL)
{
- G_CheckDemoStatus();
- }
+ if (entry->run_on_error)
+ {
+ entry->func();
+ }
- D_QuitNetGame ();
- I_ShutdownGraphics();
- S_Shutdown();
-
+ entry = entry->next;
+ }
+
#ifdef _WIN32
// On Windows, pop up a dialog box with the error message.
{