1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
4 // Copyright(C) 1993-1996 Id Software, Inc.
5 // Copyright(C) 2005 Simon Howard
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 //-----------------------------------------------------------------------------
35 #define WIN32_LEAN_AND_MEAN
47 #include "i_joystick.h"
65 // Tactile feedback function, probably used for the Logitech Cyberman
67 void I_Tactile(int on
, int off
, int total
)
71 int I_GetHeapSize (void)
78 // Specify the heap size, in MiB (default 16).
81 p
= M_CheckParm("-mb");
85 mb_used
= atoi(myargv
[p
+1]);
88 return mb_used
*1024*1024;
91 byte
*I_ZoneBase (int *size
)
95 *size
= I_GetHeapSize();
97 zonemem
= malloc(*size
);
101 I_Error("Failed to allocate %i bytes for zone memory", *size
);
104 printf("zone memory: %p, %x allocated for zone\n",
113 // Returns true if stdout is a real console, false if it is a file
116 boolean
I_ConsoleStdout(void)
119 // SDL "helpfully" always redirects stdout to a file.
122 return isatty(fileno(stdout
));
131 I_CheckIsScreensaver();
140 // Displays the text mode ending screen after the game quits
145 unsigned char *endoom_data
;
146 unsigned char *screendata
;
150 endoom_data
= W_CacheLumpName(DEH_String("ENDOOM"), PU_STATIC
);
152 // Set up text mode screen
156 // Make sure the new window has the right title and icon
158 I_SetWindowCaption();
161 // Write the data to the screen memory
163 screendata
= TXT_GetScreenData();
165 indent
= (ENDOOM_W
- TXT_SCREEN_W
) / 2;
167 for (y
=0; y
<TXT_SCREEN_H
; ++y
)
169 memcpy(screendata
+ (y
* TXT_SCREEN_W
* 2),
170 endoom_data
+ (y
* ENDOOM_W
+ indent
) * 2,
174 // Wait for a keypress
180 if (TXT_GetChar() >= 0)
188 // Shut down text mode screen
203 if (!screensaver_mode
)
208 I_ShutdownGraphics();
210 if (show_endoom
&& !testcontrols
&& !screensaver_mode
)
218 void I_WaitVBL(int count
)
220 I_Sleep((count
* 1000) / 70);
226 extern boolean demorecording
;
228 static boolean already_quitting
= false;
230 void I_Error (char *error
, ...)
234 if (already_quitting
)
236 fprintf(stderr
, "Warning: recursive call to I_Error detected.\n");
241 already_quitting
= true;
245 va_start(argptr
, error
);
246 fprintf(stderr
, "\nError: ");
247 vfprintf(stderr
, error
, argptr
);
248 fprintf(stderr
, "\n");
252 // Shutdown. Here might be other errors.
260 I_ShutdownGraphics();
264 // On Windows, pop up a dialog box with the error message.
267 wchar_t wmsgbuf
[512];
269 va_start(argptr
, error
);
270 memset(msgbuf
, 0, sizeof(msgbuf
));
271 vsnprintf(msgbuf
, sizeof(msgbuf
) - 1, error
, argptr
);
274 MultiByteToWideChar(CP_ACP
, 0,
275 msgbuf
, strlen(msgbuf
) + 1,
276 wmsgbuf
, sizeof(wmsgbuf
));
278 MessageBoxW(NULL
, wmsgbuf
, L
"Error", MB_OK
);