summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/doom/d_main.c2
-rw-r--r--src/doom/wi_stuff.c34
-rw-r--r--src/heretic/d_main.c2
-rw-r--r--src/hexen/h2_main.c2
-rw-r--r--src/i_endoom.c5
-rw-r--r--src/i_main.c38
-rw-r--r--src/i_video.c37
-rw-r--r--src/i_video.h1
-rw-r--r--src/m_config.c1
-rw-r--r--src/w_file_win32.c372
11 files changed, 271 insertions, 227 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a2267b9..10f9c2c5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,7 @@ games_PROGRAMS = chocolate-doom \
chocolate-server \
chocolate-setup
-AM_CFLAGS = -Idoom -I../textscreen -I../pcsound @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
+AM_CFLAGS = -I../textscreen -I../pcsound @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
# Common source files used by absolutely everything:
@@ -35,7 +35,7 @@ net_structrw.c net_structrw.h \
z_native.c z_zone.h
chocolate_server_SOURCES=$(COMMON_SOURCE_FILES) $(DEDSERV_FILES)
-chocolate_server_LDADD = @LDFLAGS@ @SDL_LIBS@ @SDLNET_LIBS@
+chocolate_server_LDADD = @LDFLAGS@ @SDLNET_LIBS@
# Source files used by the game binaries (chocolate-doom, etc.)
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index c8a91e74..70518a75 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -422,10 +422,10 @@ void D_DoomLoop (void)
TryRunTics();
+ I_SetWindowTitle(gamedescription);
I_InitGraphics();
I_EnableLoadingDisk();
I_SetGrabMouseCallback(D_GrabMouseCallback);
- I_SetWindowTitle(gamedescription);
V_RestoreBuffer();
R_ExecuteSetViewSize();
diff --git a/src/doom/wi_stuff.c b/src/doom/wi_stuff.c
index 7cfbdfa9..dea5d71b 100644
--- a/src/doom/wi_stuff.c
+++ b/src/doom/wi_stuff.c
@@ -424,17 +424,31 @@ void WI_drawLF(void)
{
int y = WI_TITLEY;
- // draw <LevelName>
- V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2,
- y,
- lnames[wbs->last]);
+ if (gamemode != commercial || wbs->last < NUMCMAPS)
+ {
+ // draw <LevelName>
+ V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2,
+ y, lnames[wbs->last]);
- // draw "Finished!"
- y += (5*SHORT(lnames[wbs->last]->height))/4;
-
- V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2,
- y,
- finished);
+ // draw "Finished!"
+ y += (5*SHORT(lnames[wbs->last]->height))/4;
+ }
+ else if (wbs->last == NUMCMAPS)
+ {
+ // MAP33 - nothing is displayed!
+ }
+ else if (wbs->last > NUMCMAPS)
+ {
+ // > MAP33. Doom bombs out here with a Bad V_DrawPatch error.
+ // I'm pretty sure that doom2.exe is just reading into random
+ // bits of memory at this point, but let's try to be accurate
+ // anyway. This deliberately triggers a V_DrawPatch error.
+
+ patch_t tmp = { SCREENWIDTH, SCREENHEIGHT, 1, 1,
+ { 0, 0, 0, 0, 0, 0, 0, 0 } };
+
+ V_DrawPatch(0, y, &tmp);
+ }
}
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index bba09e65..9e4558c1 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -237,8 +237,8 @@ void D_DoomLoop(void)
sprintf(filename, "debug%i.txt", consoleplayer);
debugfile = fopen(filename, "w");
}
- I_InitGraphics();
I_SetWindowTitle(gamedescription);
+ I_InitGraphics();
I_SetGrabMouseCallback(D_GrabMouseCallback);
while (1)
diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index 72e323c5..166c3064 100644
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -532,9 +532,9 @@ void H2_GameLoop(void)
sprintf(filename, "debug%i.txt", consoleplayer);
debugfile = fopen(filename, "w");
}
+ I_SetWindowTitle("Hexen");
I_InitGraphics();
I_SetGrabMouseCallback(D_GrabMouseCallback);
- I_SetWindowTitle("Hexen");
while (1)
{
diff --git a/src/i_endoom.c b/src/i_endoom.c
index b943e47c..b053b433 100644
--- a/src/i_endoom.c
+++ b/src/i_endoom.c
@@ -40,11 +40,6 @@ void I_Endoom(byte *endoom_data)
TXT_Init();
- // Make sure the new window has the right title and icon
-
- I_SetWindowTitle("Exit screen");
- I_SetWindowIcon();
-
// Write the data to the screen memory
screendata = TXT_GetScreenData();
diff --git a/src/i_main.c b/src/i_main.c
index bab514dd..d7cdcef6 100644
--- a/src/i_main.c
+++ b/src/i_main.c
@@ -25,6 +25,8 @@
//-----------------------------------------------------------------------------
+#include "config.h"
+
#include "SDL.h"
#include <signal.h>
@@ -32,7 +34,9 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#else
+#endif
+
+#ifdef HAVE_SCHED_SETAFFINITY
#include <unistd.h>
#include <sched.h>
#endif
@@ -49,25 +53,34 @@
void D_DoomMain (void);
-int main(int argc, char **argv)
-{
+#if !defined(_WIN32) && !defined(HAVE_SCHED_SETAFFINITY)
+#warning No known way to set processor affinity on this platform.
+#warning You may experience crashes due to SDL_mixer.
+#endif
+
+int main(int argc, char **argv)
+{
// save arguments
- myargc = argc;
- myargv = argv;
+ myargc = argc;
+ myargv = argv;
+
+#ifdef _WIN32
// Set the process affinity mask so that all threads
- // run on the same processor. This is a workaround for a bug in
+ // run on the same processor. This is a workaround for a bug in
// SDL_mixer that causes occasional crashes.
-#ifdef _WIN32
if (!SetProcessAffinityMask(GetCurrentProcess(), 1))
{
fprintf(stderr, "Failed to set process affinity mask (%d)\n",
(int) GetLastError());
}
-#elif !defined(__APPLE__)
- // POSIX version:
+#endif
+
+#ifdef HAVE_SCHED_SETAFFINITY
+
+ // Linux version:
{
cpu_set_t set;
@@ -77,12 +90,13 @@ int main(int argc, char **argv)
sched_setaffinity(getpid(), sizeof(set), &set);
}
+
#endif
// start doom
-
- D_DoomMain ();
+
+ D_DoomMain ();
return 0;
-}
+}
diff --git a/src/i_video.c b/src/i_video.c
index 39aedc0c..8360ab9e 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -20,7 +20,7 @@
// 02111-1307, USA.
//
// DESCRIPTION:
-// Low level graphics code using SDL.
+// DOOM graphics stuff for SDL.
//
//-----------------------------------------------------------------------------
@@ -128,8 +128,14 @@ static screen_mode_t *screen_modes_corrected[] = {
char *video_driver = "";
+// SDL surface for the screen.
+
static SDL_Surface *screen;
+// Window title
+
+static char *window_title = "";
+
// palette
static SDL_Color palette[256];
@@ -752,6 +758,11 @@ static void I_ReadMouse(void)
//
void I_StartTic (void)
{
+ if (!initialised)
+ {
+ return;
+ }
+
I_GetEvent();
if (usemouse && !nomouse)
@@ -999,11 +1010,21 @@ void I_SetPalette (byte *doompalette)
void I_SetWindowTitle(char *title)
{
+ window_title = title;
+}
+
+//
+// Call the SDL function to set the window title, based on
+// the title set with I_SetWindowTitle.
+//
+
+static void I_InitWindowTitle(void)
+{
char *buf;
- buf = Z_Malloc(strlen(title) + strlen(PACKAGE_STRING) + 5,
+ buf = Z_Malloc(strlen(window_title) + strlen(PACKAGE_STRING) + 5,
PU_STATIC, NULL);
- sprintf(buf, "%s - %s", title, PACKAGE_STRING);
+ sprintf(buf, "%s - %s", window_title, PACKAGE_STRING);
SDL_WM_SetCaption(buf, NULL);
@@ -1012,7 +1033,7 @@ void I_SetWindowTitle(char *title)
// Set the application icon
-void I_SetWindowIcon(void)
+static void I_InitWindowIcon(void)
{
SDL_Surface *surface;
Uint8 *mask;
@@ -1669,6 +1690,12 @@ void I_InitGraphics(void)
}
}
+ // Set up title and icon. Windows cares about the ordering; this
+ // has to be done before the call to SDL_SetVideoMode.
+
+ I_InitWindowTitle();
+ I_InitWindowIcon();
+
// Set the video mode.
flags |= SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
@@ -1706,8 +1733,6 @@ void I_InitGraphics(void)
I_SetPalette(doompal);
SDL_SetColors(screen, palette, 0, 256);
- I_SetWindowIcon();
-
CreateCursors();
UpdateFocus();
diff --git a/src/i_video.h b/src/i_video.h
index 1c668474..af865287 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -91,7 +91,6 @@ void I_BeginRead (void);
void I_EndRead (void);
void I_SetWindowTitle(char *title);
-void I_SetWindowIcon(void);
void I_CheckIsScreensaver(void);
void I_SetGrabMouseCallback(grabmouse_callback_t func);
diff --git a/src/m_config.c b/src/m_config.c
index a4db1c98..cfdf12a5 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -34,7 +34,6 @@
#include "config.h"
-#include "d_englsh.h"
#include "doomtype.h"
#include "doomkeys.h"
#include "doomfeatures.h"
diff --git a/src/w_file_win32.c b/src/w_file_win32.c
index 0af7928e..05d3c445 100644
--- a/src/w_file_win32.c
+++ b/src/w_file_win32.c
@@ -1,187 +1,185 @@
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 2008 Simon Howard
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-// DESCRIPTION:
-// WAD I/O functions.
-//
-//-----------------------------------------------------------------------------
-
-#include "config.h"
-
-#ifdef _WIN32
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include <stdio.h>
-
-#include "i_system.h"
-#include "w_file.h"
-#include "z_zone.h"
-
-typedef struct
-{
- wad_file_t wad;
- HANDLE handle;
- HANDLE handle_map;
-} win32_wad_file_t;
-
-extern wad_file_class_t win32_wad_file;
-
-static void MapFile(win32_wad_file_t *wad, char *filename)
-{
- wad->handle_map = CreateFileMapping(wad->handle,
- NULL,
- PAGE_WRITECOPY,
- 0,
- 0,
- NULL);
-
- if (wad->handle_map == NULL)
- {
- fprintf(stderr, "W_Win32_OpenFile: Unable to CreateFileMapping() "
- "for %s\n", filename);
- return;
- }
-
- wad->wad.mapped = MapViewOfFile(wad->handle_map,
- FILE_MAP_COPY,
- 0, 0, 0);
-
- if (wad->wad.mapped == NULL)
- {
- fprintf(stderr, "W_Win32_OpenFile: Unable to MapViewOfFile() for %s\n",
- filename);
- }
-}
-
-unsigned int GetFileLength(HANDLE handle)
-{
- DWORD result;
-
- result = SetFilePointer(handle, 0, NULL, FILE_END);
-
- if (result == INVALID_SET_FILE_POINTER)
- {
- I_Error("W_Win32_OpenFile: Failed to read file length");
- }
-
- return result;
-}
-
-static wad_file_t *W_Win32_OpenFile(char *path)
-{
- win32_wad_file_t *result;
- HANDLE handle;
- OFSTRUCT fileinfo;
-
- handle = (HANDLE) OpenFile(path, &fileinfo, OF_READ);
-
- if (handle == (HANDLE) HFILE_ERROR)
- {
- return NULL;
- }
-
- // Create a new win32_wad_file_t to hold the file handle.
-
- result = Z_Malloc(sizeof(win32_wad_file_t), PU_STATIC, 0);
- result->wad.file_class = &win32_wad_file;
- result->wad.length = GetFileLength(handle);
- result->handle = handle;
-
- // Try to map the file into memory with mmap:
-
- MapFile(result, path);
-
- return &result->wad;
-}
-
-static void W_Win32_CloseFile(wad_file_t *wad)
-{
- win32_wad_file_t *win32_wad;
-
- win32_wad = (win32_wad_file_t *) wad;
-
- // If mapped, unmap it.
-
- if (win32_wad->wad.mapped != NULL)
- {
- UnmapViewOfFile(win32_wad->wad.mapped);
- }
-
- if (win32_wad->handle_map != NULL)
- {
- CloseHandle(win32_wad->handle_map);
- }
-
- // Close the file
-
- if (win32_wad->handle != NULL)
- {
- CloseHandle(win32_wad->handle);
- }
-
- Z_Free(win32_wad);
-}
-
-// Read data from the specified position in the file into the
-// provided buffer. Returns the number of bytes read.
-
-size_t W_Win32_Read(wad_file_t *wad, unsigned int offset,
- void *buffer, size_t buffer_len)
-{
- win32_wad_file_t *win32_wad;
- DWORD bytes_read;
- DWORD result;
-
- win32_wad = (win32_wad_file_t *) wad;
-
- // Jump to the specified position in the file.
-
- result = SetFilePointer(win32_wad->handle, offset, NULL, FILE_BEGIN);
-
- if (result == INVALID_SET_FILE_POINTER)
- {
- I_Error("W_Win32_Read: Failed to set file pointer to %i",
- offset);
- }
-
- // Read into the buffer.
-
- if (!ReadFile(win32_wad->handle, buffer, buffer_len, &bytes_read, NULL))
- {
- I_Error("W_Win32_Read: Error reading from file");
- }
-
- return bytes_read;
-}
-
-
-wad_file_class_t win32_wad_file =
-{
- W_Win32_OpenFile,
- W_Win32_CloseFile,
- W_Win32_Read,
-};
-
-
-#endif /* #ifdef _WIN32 */
-
+// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 2008 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+// DESCRIPTION:
+// WAD I/O functions.
+//
+//-----------------------------------------------------------------------------
+
+#include "config.h"
+
+#ifdef _WIN32
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include "i_system.h"
+#include "w_file.h"
+#include "z_zone.h"
+
+typedef struct
+{
+ wad_file_t wad;
+ HANDLE handle;
+ HANDLE handle_map;
+} win32_wad_file_t;
+
+extern wad_file_class_t win32_wad_file;
+
+static void MapFile(win32_wad_file_t *wad, char *filename)
+{
+ wad->handle_map = CreateFileMapping(wad->handle,
+ NULL,
+ PAGE_WRITECOPY,
+ 0,
+ 0,
+ NULL);
+
+ if (wad->handle_map == NULL)
+ {
+ fprintf(stderr, "W_Win32_OpenFile: Unable to CreateFileMapping() "
+ "for %s\n", filename);
+ return;
+ }
+
+ wad->wad.mapped = MapViewOfFile(wad->handle_map,
+ FILE_MAP_COPY,
+ 0, 0, 0);
+
+ if (wad->wad.mapped == NULL)
+ {
+ fprintf(stderr, "W_Win32_OpenFile: Unable to MapViewOfFile() for %s\n",
+ filename);
+ }
+}
+
+unsigned int GetFileLength(HANDLE handle)
+{
+ DWORD result;
+
+ result = SetFilePointer(handle, 0, NULL, FILE_END);
+
+ if (result == INVALID_SET_FILE_POINTER)
+ {
+ I_Error("W_Win32_OpenFile: Failed to read file length");
+ }
+
+ return result;
+}
+
+static wad_file_t *W_Win32_OpenFile(char *path)
+{
+ win32_wad_file_t *result;
+ HANDLE handle;
+ OFSTRUCT fileinfo;
+
+ handle = (HANDLE) OpenFile(path, &fileinfo, OF_READ);
+
+ if (handle == (HANDLE) HFILE_ERROR)
+ {
+ return NULL;
+ }
+
+ // Create a new win32_wad_file_t to hold the file handle.
+
+ result = Z_Malloc(sizeof(win32_wad_file_t), PU_STATIC, 0);
+ result->wad.file_class = &win32_wad_file;
+ result->wad.length = GetFileLength(handle);
+ result->handle = handle;
+
+ // Try to map the file into memory with mmap:
+
+ MapFile(result, path);
+
+ return &result->wad;
+}
+
+static void W_Win32_CloseFile(wad_file_t *wad)
+{
+ win32_wad_file_t *win32_wad;
+
+ win32_wad = (win32_wad_file_t *) wad;
+
+ // If mapped, unmap it.
+
+ if (win32_wad->wad.mapped != NULL)
+ {
+ UnmapViewOfFile(win32_wad->wad.mapped);
+ }
+
+ if (win32_wad->handle_map != NULL)
+ {
+ CloseHandle(win32_wad->handle_map);
+ }
+
+ // Close the file
+
+ if (win32_wad->handle != NULL)
+ {
+ CloseHandle(win32_wad->handle);
+ }
+
+ Z_Free(win32_wad);
+}
+
+// Read data from the specified position in the file into the
+// provided buffer. Returns the number of bytes read.
+
+size_t W_Win32_Read(wad_file_t *wad, unsigned int offset,
+ void *buffer, size_t buffer_len)
+{
+ win32_wad_file_t *win32_wad;
+ DWORD bytes_read;
+ DWORD result;
+
+ win32_wad = (win32_wad_file_t *) wad;
+
+ // Jump to the specified position in the file.
+
+ result = SetFilePointer(win32_wad->handle, offset, NULL, FILE_BEGIN);
+
+ if (result == INVALID_SET_FILE_POINTER)
+ {
+ I_Error("W_Win32_Read: Failed to set file pointer to %i",
+ offset);
+ }
+
+ // Read into the buffer.
+
+ if (!ReadFile(win32_wad->handle, buffer, buffer_len, &bytes_read, NULL))
+ {
+ I_Error("W_Win32_Read: Error reading from file");
+ }
+
+ return bytes_read;
+}
+
+
+wad_file_class_t win32_wad_file =
+{
+ W_Win32_OpenFile,
+ W_Win32_CloseFile,
+ W_Win32_Read,
+};
+
+
+#endif /* #ifdef _WIN32 */
+