2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-2001 Id Software, Inc.
|
|
|
|
Copyright (C) 2002-2005 John Fitzgibbons and others
|
|
|
|
Copyright (C) 2007-2008 Kristian Duske
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2010-06-19 22:50:48 +00:00
|
|
|
|
2010-02-15 23:26:55 +00:00
|
|
|
#include "quakedef.h"
|
2010-06-19 22:50:48 +00:00
|
|
|
#include "SDL.h"
|
|
|
|
#include <stdio.h>
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-02-16 09:12:35 +00:00
|
|
|
#define DEFAULT_MEMORY 0x4000000
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2010-02-17 23:32:04 +00:00
|
|
|
SDL_Event event;
|
|
|
|
quakeparms_t parms;
|
|
|
|
int t;
|
|
|
|
int done = 0;
|
|
|
|
double time, oldtime, newtime;
|
|
|
|
|
|
|
|
parms.basedir = ".";
|
|
|
|
|
|
|
|
parms.argc = argc;
|
|
|
|
parms.argv = argv;
|
|
|
|
|
|
|
|
COM_InitArgv(parms.argc, parms.argv);
|
|
|
|
|
|
|
|
isDedicated = (COM_CheckParm("-dedicated") != 0);
|
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
Sys_Init();
|
|
|
|
|
2010-02-17 23:32:04 +00:00
|
|
|
// default memory size
|
|
|
|
parms.memsize = DEFAULT_MEMORY;
|
|
|
|
|
|
|
|
if (COM_CheckParm("-heapsize"))
|
|
|
|
{
|
|
|
|
t = COM_CheckParm("-heapsize") + 1;
|
|
|
|
if (t < com_argc)
|
|
|
|
parms.memsize = Q_atoi(com_argv[t]) * 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: dedicated server setup
|
|
|
|
|
|
|
|
parms.membase = malloc (parms.memsize);
|
|
|
|
|
|
|
|
if (!parms.membase)
|
|
|
|
Sys_Error ("Not enough memory free; check disk space\n");
|
|
|
|
|
main_sdl.c (main): Remove leading linefeed from the init message.
common.c (COM_InitArgv): Move the leading linefeed to the end of message.
Index: main_sdl.c
===================================================================
--- main_sdl.c (revision 157)
+++ main_sdl.c (working copy)
@@ -58,7 +58,7 @@
if (!parms.membase)
Sys_Error ("Not enough memory free; check disk space\n");
- Con_Printf("\nFitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
+ Con_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
Con_Printf("SDL port (c) Sleepwalkr, Baker\n");
Con_Printf("QuakeSpasm %1.2f.%d (c) Ozkan Sezer, Stevenaaus\n", FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
Index: common.c
===================================================================
--- common.c (revision 157)
+++ common.c (working copy)
@@ -1150,7 +1150,7 @@
if (n > 0 && com_cmdline[n-1] == ' ')
com_cmdline[n-1] = 0; //johnfitz -- kill the trailing space
- Con_Printf("\nCommand line: %s",com_cmdline);
+ Con_Printf("Command line: %s\n", com_cmdline);
safe = false;
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@158 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-27 07:15:19 +00:00
|
|
|
Con_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
|
2010-04-22 00:25:31 +00:00
|
|
|
Con_Printf("SDL port (c) Sleepwalkr, Baker\n");
|
|
|
|
Con_Printf("QuakeSpasm %1.2f.%d (c) Ozkan Sezer, Stevenaaus\n", FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
|
2010-02-17 23:32:04 +00:00
|
|
|
|
|
|
|
Con_Printf("Host_Init\n");
|
|
|
|
Host_Init(&parms);
|
|
|
|
|
|
|
|
oldtime = Sys_FloatTime();
|
2010-06-19 14:50:48 +00:00
|
|
|
if (isDedicated)
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
newtime = Sys_FloatTime ();
|
|
|
|
time = newtime - oldtime;
|
|
|
|
|
|
|
|
while (time < sys_ticrate.value )
|
|
|
|
{
|
|
|
|
SDL_Delay(1);
|
|
|
|
newtime = Sys_FloatTime ();
|
|
|
|
time = newtime - oldtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
Host_Frame (time);
|
|
|
|
oldtime = newtime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-02-17 23:32:04 +00:00
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
// TODO: dedicated server loop
|
|
|
|
|
2010-06-19 14:50:48 +00:00
|
|
|
while (!done && SDL_PollEvent (&event))
|
2010-02-17 23:32:04 +00:00
|
|
|
{
|
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case SDL_ACTIVEEVENT:
|
2010-02-18 10:33:33 +00:00
|
|
|
if (event.active.state & (SDL_APPACTIVE|SDL_APPINPUTFOCUS))
|
2010-02-17 23:32:04 +00:00
|
|
|
{
|
Under windows, run the game (windowed), go into a saved game,
press Esc to get the menu, minimize using the mouse on the
window's minimize icon and then restore and you'll have sound
all the same. HOWEVER: If you minimize by pressing the icon
on the start bar, sound will be lost upon restoring. Or, if
you use alt-tab to get away from the game window the same will
happen. Or, if you run the game fullscreen and use alt-tab to
go to the desktop (alt-tab is the only way I know) you will
lose the sound again. Here, we are probably are hitting an
SDL_APPACTIVE or SDL_APPINPUTFOCUS event more than once and
since the block counter goes > 1 we are not restoring properly.
For now, making snd_blocked to act as a boolean and not as a
counter fixes the issue. Hmmm...
* main_sdl.c: Revert revision 238 change, no longer necessary.
* snd_dma.c: Make snd_blocked act as a boolean and not as a
counter.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@241 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-07-25 12:20:17 +00:00
|
|
|
if (event.active.gain)
|
|
|
|
S_UnblockSound();
|
|
|
|
else
|
|
|
|
S_BlockSound();
|
2010-02-17 23:32:04 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
IN_MouseMove(event.motion.xrel, event.motion.yrel);
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
switch (event.button.button)
|
|
|
|
{
|
|
|
|
case SDL_BUTTON_LEFT:
|
|
|
|
Key_Event(K_MOUSE1, event.button.type == SDL_MOUSEBUTTONDOWN);
|
|
|
|
break;
|
|
|
|
case SDL_BUTTON_RIGHT:
|
|
|
|
Key_Event(K_MOUSE2, event.button.type == SDL_MOUSEBUTTONDOWN);
|
|
|
|
break;
|
|
|
|
case SDL_BUTTON_MIDDLE:
|
|
|
|
Key_Event(K_MOUSE3, event.button.type == SDL_MOUSEBUTTONDOWN);
|
|
|
|
break;
|
|
|
|
case SDL_BUTTON_WHEELUP:
|
|
|
|
Key_Event(K_MWHEELUP, event.button.type == SDL_MOUSEBUTTONDOWN);
|
|
|
|
break;
|
|
|
|
case SDL_BUTTON_WHEELDOWN:
|
|
|
|
Key_Event(K_MWHEELDOWN, event.button.type == SDL_MOUSEBUTTONDOWN);
|
|
|
|
break;
|
|
|
|
}
|
2010-06-19 14:10:19 +00:00
|
|
|
break;
|
2010-02-17 23:32:04 +00:00
|
|
|
case SDL_KEYDOWN:
|
|
|
|
case SDL_KEYUP:
|
|
|
|
// SHIFT + ESC and circomflex always opens the console no matter what
|
|
|
|
if ((event.key.keysym.sym == SDLK_ESCAPE && (event.key.keysym.mod & KMOD_SHIFT))
|
|
|
|
|| (event.key.keysym.sym == SDLK_CARET))
|
|
|
|
{
|
|
|
|
if (event.key.type == SDL_KEYDOWN)
|
|
|
|
Con_ToggleConsole_f();
|
|
|
|
}
|
|
|
|
else if ((event.key.keysym.sym == SDLK_RETURN) &&
|
|
|
|
(event.key.keysym.mod & KMOD_ALT))
|
|
|
|
{
|
|
|
|
if (event.key.type == SDL_KEYDOWN)
|
|
|
|
VID_Toggle();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_QUIT:
|
|
|
|
done = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-17 23:32:04 +00:00
|
|
|
newtime = Sys_FloatTime();
|
|
|
|
time = newtime - oldtime;
|
|
|
|
Host_Frame(time);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-02-17 23:32:04 +00:00
|
|
|
// throttle the game loop just a little bit - noone needs more than 1000fps, I think
|
|
|
|
if (newtime - oldtime < 1)
|
|
|
|
SDL_Delay(1);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-02-17 23:32:04 +00:00
|
|
|
oldtime = newtime;
|
|
|
|
}
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-02-17 23:32:04 +00:00
|
|
|
Sys_Quit();
|
|
|
|
return 0;
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
2010-02-17 23:32:04 +00:00
|
|
|
|