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.c169
1 files changed, 92 insertions, 77 deletions
diff --git a/src/i_system.c b/src/i_system.c
index fe596a60..1003075f 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -38,29 +38,47 @@
#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"
int mb_used = 16;
-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
@@ -102,6 +120,44 @@ 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
//
@@ -121,56 +177,21 @@ boolean I_ConsoleStdout(void)
//
// I_Init
//
+/*
void I_Init (void)
{
I_CheckIsScreensaver();
I_InitTimer();
I_InitJoystick();
}
-
-//
-// 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;
-
- 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();
- memcpy(screendata, endoom_data, 4000);
-
- // 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
@@ -178,40 +199,31 @@ void I_Endoom(void)
void I_Quit (void)
{
- D_QuitNetGame ();
- G_CheckDemoStatus();
- S_Shutdown();
-
- if (!screensaver_mode)
- {
- M_SaveDefaults ();
- }
+ atexit_listentry_t *entry;
- 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)
{
@@ -233,15 +245,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.
{