summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-07-27 14:42:43 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-07-27 14:42:43 +0200
commit543e510da1869cf8d352225bade8fc732c598497 (patch)
tree3fe4cf0d6204b47acd76e4e08ee09add6bb136ea
parentab08c97e6010309d4ea0df26815d074b1f5d1a4b (diff)
doom: cleanup
-rw-r--r--sys/src/games/doom/d_main.c22
-rw-r--r--sys/src/games/doom/doomdef.h12
-rw-r--r--sys/src/games/doom/g_game.c7
-rw-r--r--sys/src/games/doom/i_system.c19
-rw-r--r--sys/src/games/doom/m_menu.c12
-rw-r--r--sys/src/games/doom/m_misc.c96
-rw-r--r--sys/src/games/doom/s_sound.c75
-rw-r--r--sys/src/games/doom/sounds.h8
8 files changed, 53 insertions, 198 deletions
diff --git a/sys/src/games/doom/d_main.c b/sys/src/games/doom/d_main.c
index 2f6c87e06..c5e3f02f5 100644
--- a/sys/src/games/doom/d_main.c
+++ b/sys/src/games/doom/d_main.c
@@ -398,11 +398,8 @@ void D_DoomLoop (void)
// Sound mixing for the buffer is snychronous.
I_UpdateSound();
- // Synchronous sound output is explicitly called.
-#ifndef SNDINTR
// Update sound output.
I_SubmitSound();
-#endif
}
}
@@ -725,8 +722,8 @@ void FindResponseFile (void)
//
void D_DoomMain (void)
{
- int p;
- char file[256];
+ int p;
+ char file[256];
FindResponseFile ();
@@ -804,16 +801,6 @@ void D_DoomMain (void)
if (devparm)
printf(D_DEVSTR);
- if (M_CheckParm("-cdrom"))
- {
- I_Error("PORTME d_main.c M_CheckParm -cdrom");
-/*
- printf(D_CDROM);
- mkdir("c:\\doomdata",0);
- strcpy (basedefault,"c:/doomdata/default.cfg");
-*/
- }
-
// turbo option
if ( (p=M_CheckParm ("-turbo")) )
{
@@ -1083,10 +1070,7 @@ void D_DoomMain (void)
p = M_CheckParm ("-loadgame");
if (p && p < myargc-1)
{
- if (M_CheckParm("-cdrom"))
- sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
- else
- sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
+ sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
G_LoadGame (file);
}
diff --git a/sys/src/games/doom/doomdef.h b/sys/src/games/doom/doomdef.h
index b34992b10..08378bcda 100644
--- a/sys/src/games/doom/doomdef.h
+++ b/sys/src/games/doom/doomdef.h
@@ -75,23 +75,11 @@ typedef enum
// most parameter validation debugging code will not be compiled
#define RANGECHECK
-// Do or do not use external soundserver.
-// The sndserver binary to be run separately
-// has been introduced by Dave Taylor.
-// The integrated sound support is experimental,
-// and unfinished. Default is synchronous.
-// Experimental asynchronous timer based is
-// handled by SNDINTR.
-//#define SNDSERV 1
-//#define SNDINTR 1
-
-
// This one switches between MIT SHM (no proper mouse)
// and XFree86 DGA (mickey sampling). The original
// linuxdoom used SHM, which is default.
//#define X11_DGA 1
-
//
// For resize of screen, at start of game.
// It will not work dynamically, see visplanes.
diff --git a/sys/src/games/doom/g_game.c b/sys/src/games/doom/g_game.c
index 43dda5303..4c9637ef1 100644
--- a/sys/src/games/doom/g_game.c
+++ b/sys/src/games/doom/g_game.c
@@ -1252,16 +1252,13 @@ G_SaveGame
void G_DoSaveGame (void)
{
- char name[100];
+ char name[256];
char name2[VERSIONSIZE];
char* description;
int length;
int i;
- if (M_CheckParm("-cdrom"))
- sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot);
- else
- sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
+ sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
description = savedescription;
save_p = savebuffer = screens[1]+0x4000;
diff --git a/sys/src/games/doom/i_system.c b/sys/src/games/doom/i_system.c
index 8e17da76b..e83d2f0db 100644
--- a/sys/src/games/doom/i_system.c
+++ b/sys/src/games/doom/i_system.c
@@ -113,7 +113,7 @@ void I_Error (char *error, ...)
int I_FileExists (char *filepath)
{
- return (0 == access(filepath, AREAD));
+ return access(filepath, AEXIST) == 0;
}
int I_Open (char *filepath)
@@ -138,17 +138,26 @@ int I_Read (int handle, void *buf, int n)
char* I_IdentifyWAD(char *wadname)
{
- char path[1024];
+ static char path[1024];
+ char *home;
- snprintf(path, sizeof path, "/sys/lib/doom/%s", wadname);
+ snprint(path, sizeof path, wadname);
if (I_FileExists (path))
return path;
- snprintf(path, sizeof path, "/sys/games/lib/doom/%s", wadname);
+ if(home = getenv("home")){
+ snprintf(path, sizeof path, "%s/lib/doom/%s", home, wadname);
+ free(home);
+
+ if (I_FileExists (path))
+ return path;
+ }
+
+ snprintf(path, sizeof path, "/sys/lib/doom/%s", wadname);
if (I_FileExists (path))
return path;
- snprintf(path, sizeof path, "%s/lib/doom/%s", getenv("home"), wadname);
+ snprintf(path, sizeof path, "/sys/games/lib/doom/%s", wadname);
if (I_FileExists (path))
return path;
diff --git a/sys/src/games/doom/m_menu.c b/sys/src/games/doom/m_menu.c
index d923b9378..4215d4d92 100644
--- a/sys/src/games/doom/m_menu.c
+++ b/sys/src/games/doom/m_menu.c
@@ -153,7 +153,7 @@ typedef struct menu_s
short numitems; // # of menu items
struct menu_s* prevMenu; // previous menu
menuitem_t* menuitems; // menu items
- void (*routine)(); // draw routine
+ void (*routine)(void); // draw routine
short x;
short y; // x,y of menu
short lastOn; // last item user was on in menu
@@ -509,10 +509,7 @@ void M_ReadSaveStrings(void)
for (i = 0;i < load_end;i++)
{
- if (M_CheckParm("-cdrom"))
- sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",i);
- else
- sprintf(name,SAVEGAMENAME"%d.dsg",i);
+ sprintf(name,SAVEGAMENAME"%d.dsg",i);
handle = I_Open (name);
if (handle == -1)
@@ -572,10 +569,7 @@ void M_LoadSelect(int choice)
{
char name[256];
- if (M_CheckParm("-cdrom"))
- sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice);
- else
- sprintf(name,SAVEGAMENAME"%d.dsg",choice);
+ sprintf(name,SAVEGAMENAME"%d.dsg",choice);
G_LoadGame (name);
M_ClearMenus ();
}
diff --git a/sys/src/games/doom/m_misc.c b/sys/src/games/doom/m_misc.c
index 3b36dc566..ca3d5ccec 100644
--- a/sys/src/games/doom/m_misc.c
+++ b/sys/src/games/doom/m_misc.c
@@ -97,10 +97,6 @@ M_DrawText
//
// M_WriteFile
//
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
boolean
M_WriteFile
( char const* name,
@@ -109,7 +105,7 @@ M_WriteFile
{
int fd, n;
- if((fd = create(name, OWRITE | OTRUNC, 0666)) < 0)
+ if((fd = create(name, OWRITE, 0644)) < 0)
return false;
n = write(fd, source, length);
close(fd);
@@ -188,29 +184,14 @@ extern int showMessages;
// machine-independent sound params
extern int numChannels;
-
-// UNIX hack, to be removed.
-#ifdef SNDSERV
-extern char* sndserver_filename;
-extern int mb_used;
-#endif
-
-#ifdef LINUX
-char* mousetype;
-char* mousedev;
-#endif
-
extern char* chat_macros[];
-
-
typedef struct
{
char* name;
- int* location;
+ void* location;
int defaultvalue;
- int scantranslate; // PC scan code hack
- int untranslated; // lousy hack
+ char* defaultstring;
} default_t;
default_t defaults[] =
@@ -233,17 +214,6 @@ default_t defaults[] =
{"key_strafe",&key_strafe, KEY_RALT},
{"key_speed",&key_speed, KEY_RSHIFT},
-// UNIX hack, to be removed.
-#ifdef SNDSERV
- {"sndserver", (int *) &sndserver_filename, (int) "sndserver"},
- {"mb_used", &mb_used, 2},
-#endif
-
-#ifdef LINUX
- {"mousedev", (int*)&mousedev, (int)"/dev/ttyS0"},
- {"mousetype", (int*)&mousetype, (int)"microsoft"},
-#endif
-
{"use_mouse",&usemouse, 1},
{"mouseb_fire",&mousebfire,0},
{"mouseb_strafe",&mousebstrafe,1},
@@ -260,34 +230,30 @@ default_t defaults[] =
{"snd_channels",&numChannels, 3},
-
-
{"usegamma",&usegamma, 0},
- {"chatmacro0", (int *) &chat_macros[0], (int) HUSTR_CHATMACRO0 },
- {"chatmacro1", (int *) &chat_macros[1], (int) HUSTR_CHATMACRO1 },
- {"chatmacro2", (int *) &chat_macros[2], (int) HUSTR_CHATMACRO2 },
- {"chatmacro3", (int *) &chat_macros[3], (int) HUSTR_CHATMACRO3 },
- {"chatmacro4", (int *) &chat_macros[4], (int) HUSTR_CHATMACRO4 },
- {"chatmacro5", (int *) &chat_macros[5], (int) HUSTR_CHATMACRO5 },
- {"chatmacro6", (int *) &chat_macros[6], (int) HUSTR_CHATMACRO6 },
- {"chatmacro7", (int *) &chat_macros[7], (int) HUSTR_CHATMACRO7 },
- {"chatmacro8", (int *) &chat_macros[8], (int) HUSTR_CHATMACRO8 },
- {"chatmacro9", (int *) &chat_macros[9], (int) HUSTR_CHATMACRO9 }
+ {"chatmacro0",&chat_macros[0], 0, HUSTR_CHATMACRO0 },
+ {"chatmacro1",&chat_macros[1], 0, HUSTR_CHATMACRO1 },
+ {"chatmacro2",&chat_macros[2], 0, HUSTR_CHATMACRO2 },
+ {"chatmacro3",&chat_macros[3], 0, HUSTR_CHATMACRO3 },
+ {"chatmacro4",&chat_macros[4], 0, HUSTR_CHATMACRO4 },
+ {"chatmacro5",&chat_macros[5], 0, HUSTR_CHATMACRO5 },
+ {"chatmacro6",&chat_macros[6], 0, HUSTR_CHATMACRO6 },
+ {"chatmacro7",&chat_macros[7], 0, HUSTR_CHATMACRO7 },
+ {"chatmacro8",&chat_macros[8], 0, HUSTR_CHATMACRO8 },
+ {"chatmacro9",&chat_macros[9], 0, HUSTR_CHATMACRO9 }
};
int numdefaults;
char* defaultfile;
-
//
// M_SaveDefaults
//
void M_SaveDefaults (void)
{
int i;
- int v;
FILE* f;
f = fopen (defaultfile, "w");
@@ -296,14 +262,13 @@ void M_SaveDefaults (void)
for (i=0 ; i<numdefaults ; i++)
{
- if (defaults[i].defaultvalue > -0xfff
- && defaults[i].defaultvalue < 0xfff)
+ if (defaults[i].defaultstring == 0)
{
- v = *defaults[i].location;
- fprintf (f,"%s\t\t%i\n",defaults[i].name,v);
+ fprintf (f,"%s\t\t%i\n",defaults[i].name,
+ *((int*)defaults[i].location));
} else {
fprintf (f,"%s\t\t\"%s\"\n",defaults[i].name,
- * (char **) (defaults[i].location));
+ *((char**)defaults[i].location));
}
}
@@ -314,8 +279,6 @@ void M_SaveDefaults (void)
//
// M_LoadDefaults
//
-extern byte scantokey[128];
-
void M_LoadDefaults (void)
{
int i;
@@ -323,14 +286,16 @@ void M_LoadDefaults (void)
FILE* f;
char def[80];
char strparm[100];
- char* newstring = (char *)0;
+ char* newstring;
int parm;
- boolean isstring;
// set everything to base values
numdefaults = sizeof(defaults)/sizeof(defaults[0]);
for (i=0 ; i<numdefaults ; i++)
- *defaults[i].location = defaults[i].defaultvalue;
+ if(defaults[i].defaultstring == 0)
+ *((int*)defaults[i].location) = defaults[i].defaultvalue;
+ else
+ *((char**)defaults[i].location) = defaults[i].defaultstring;
// check for a custom default file
i = M_CheckParm ("-config");
@@ -348,13 +313,13 @@ void M_LoadDefaults (void)
{
while (!feof(f))
{
- isstring = false;
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2)
{
+ parm = 0;
+ newstring = 0;
if (strparm[0] == '"')
{
// get a string default
- isstring = true;
len = strlen(strparm);
newstring = (char *) malloc(len);
strparm[len-1] = 0;
@@ -367,11 +332,10 @@ void M_LoadDefaults (void)
for (i=0 ; i<numdefaults ; i++)
if (!strcmp(def, defaults[i].name))
{
- if (!isstring)
- *defaults[i].location = parm;
- else
- *defaults[i].location =
- (int) newstring;
+ if (defaults[i].defaultstring == 0)
+ *((int*)defaults[i].location) = parm;
+ else if(newstring)
+ *((char**)defaults[i].location) = newstring;
break;
}
}
@@ -496,8 +460,8 @@ void M_ScreenShot (void)
{
lbmname[4] = i/10 + '0';
lbmname[5] = i%10 + '0';
- if (access(lbmname,0) == -1)
- break; // file doesn't exist
+ if (!I_FileExists (lbmname))
+ break;
}
if (i==100)
I_Error ("M_ScreenShot: Couldn't create a PCX");
diff --git a/sys/src/games/doom/s_sound.c b/sys/src/games/doom/s_sound.c
index f5f5289f0..18567ec26 100644
--- a/sys/src/games/doom/s_sound.c
+++ b/sys/src/games/doom/s_sound.c
@@ -123,10 +123,6 @@ static musicinfo_t* mus_playing=0;
// number of channels available
int numChannels;
-static int nextcleanup;
-
-
-
//
// Internals.
//
@@ -180,10 +176,6 @@ void S_Init
// no sounds are playing, and they are not mus_paused
mus_paused = 0;
-
- // Note that sounds have not been cached (yet).
- for (i=1 ; i<NUMSFX ; i++)
- S_sfx[i].lumpnum = S_sfx[i].usefulness = -1;
}
@@ -238,8 +230,6 @@ void S_Start(void)
// mnum -= mus_e3m9;
S_ChangeMusic(mnum, true);
-
- nextcleanup = 15;
}
@@ -263,11 +253,6 @@ S_StartSoundAtVolume
mobj_t* origin = (mobj_t *) origin_p;
- // Debug.
- /*fprintf( stderr,
- "S_StartSoundAtVolume: playing sound %d (%s)\n",
- sfx_id, S_sfx[sfx_id].name );*/
-
// check for bogus sound #
if (sfx_id < 1 || sfx_id > NUMSFX)
I_Error("Bad sfx #: %d", sfx_id);
@@ -307,7 +292,7 @@ S_StartSoundAtVolume
if ( origin->x == players[consoleplayer].mo->x
&& origin->y == players[consoleplayer].mo->y)
{
- sep = NORM_SEP;
+ sep = NORM_SEP;
}
if (!rc)
@@ -349,42 +334,9 @@ S_StartSoundAtVolume
if (cnum<0)
return;
- //
- // This is supposed to handle the loading/caching.
- // For some odd reason, the caching is done nearly
- // each time the sound is needed?
- //
-
- // get lumpnum if necessary
- if (sfx->lumpnum < 0)
- sfx->lumpnum = I_GetSfxLumpNum(sfx);
-
-#ifndef SNDSRV
- // cache data if necessary
- if (!sfx->data)
- {
-/* PORTME 9DOOM uncomment this back in later
- fprintf( stderr,
- "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");
-*/
-
- // DOS remains, 8bit handling
- //sfx->data = (void *) W_CacheLumpNum(sfx->lumpnum, PU_MUSIC);
- // fprintf( stderr,
- // "S_StartSoundAtVolume: loading %d (lump %d) : 0x%x\n",
- // sfx_id, sfx->lumpnum, (int)sfx->data );
-
- }
-#endif
-
- // increase the usefulness
- if (sfx->usefulness++ < 0)
- sfx->usefulness = 1;
-
// Assigns the handle to one of the channels in the
// mix/output buffer.
channels[cnum].handle = I_StartSound(sfx_id,
- /*sfx->data,*/
volume,
sep,
pitch,
@@ -524,28 +476,6 @@ void S_UpdateSounds(void* listener_p)
channel_t* c;
mobj_t* listener = (mobj_t*)listener_p;
-
-
-
- // Clean up unused data.
- // This is currently not done for 16bit (sounds cached static).
- // DOS 8bit remains.
- /*if (gametic > nextcleanup)
- {
- for (i=1 ; i<NUMSFX ; i++)
- {
- if (S_sfx[i].usefulness < 1
- && S_sfx[i].usefulness > -1)
- {
- if (--S_sfx[i].usefulness == -1)
- {
- Z_ChangeTag(S_sfx[i].data, PU_CACHE);
- S_sfx[i].data = 0;
- }
- }
- }
- nextcleanup = gametic + 15;
- }*/
for (cnum=0 ; cnum<numChannels ; cnum++)
{
@@ -731,9 +661,6 @@ void S_StopChannel(int cnum)
break;
}
}
-
- // degrade usefulness of sound data
- c->sfxinfo->usefulness--;
c->sfxinfo = 0;
}
diff --git a/sys/src/games/doom/sounds.h b/sys/src/games/doom/sounds.h
index 02ceedf85..61e290b75 100644
--- a/sys/src/games/doom/sounds.h
+++ b/sys/src/games/doom/sounds.h
@@ -51,14 +51,6 @@ struct sfxinfo_struct
// sound data
void* data;
-
- // this is checked every second to see if sound
- // can be thrown out (if 0, then decrement, if -1,
- // then throw out, if > 0, then it is in use)
- int usefulness;
-
- // lump number of sfx
- int lumpnum;
};