]> git.lizzy.rs Git - plan9front.git/commitdiff
doom: cleanup
authorcinap_lenrek <cinap_lenrek@gmx.de>
Fri, 27 Jul 2012 12:42:43 +0000 (14:42 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Fri, 27 Jul 2012 12:42:43 +0000 (14:42 +0200)
sys/src/games/doom/d_main.c
sys/src/games/doom/doomdef.h
sys/src/games/doom/g_game.c
sys/src/games/doom/i_system.c
sys/src/games/doom/m_menu.c
sys/src/games/doom/m_misc.c
sys/src/games/doom/s_sound.c
sys/src/games/doom/sounds.h

index 2f6c87e06c6ce9ae8a7bf6006a96535f6b7de67e..c5e3f02f5e0647972ac7115763bf46ebdba81a69 100644 (file)
@@ -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);
     }
        
index b34992b1062bb603544ea009be49a611c843e6e1..08378bcda2a42351f09defd0aa95417dba0d98b0 100644 (file)
@@ -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.
index 43dda5303da028d7b3ea7ec3c078b8cec95ab377..4c9637ef1033ffb9036420ec5f877e4293171bf1 100644 (file)
@@ -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; 
index 8e17da76b35ca09e6e29763e230fe59decd52a87..e83d2f0db691a23b9dacd261d52c66c3302b1388 100644 (file)
@@ -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;
 
index d923b9378ad59a87373fcfe95d3db0db35b92436..4215d4d92fef9a653cf4f8167077374d4f77df80 100644 (file)
@@ -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 ();
 }
index 3b36dc56695fb15594b30bca56fbf8c88f3bc4d1..ca3d5ccec4357d4bd8e7036f294d356a8a05817a 100644 (file)
@@ -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");
index f5f5289f092ec3afc4a254e4efb4f4f1b7fddb36..18567ec2603e16392ddda3d18a49d94ba53e5e61 100644 (file)
@@ -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;
     }
index 02ceedf85204499cb36b1518ea451e3097de2fe9..61e290b753359b5c55b48d42a252cd92ce0ffde8 100644 (file)
@@ -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;                
 };