]> git.lizzy.rs Git - plan9front.git/commitdiff
doom: fix music for patch wads
authorqwx <devnull@localhost>
Sat, 20 Oct 2018 22:11:39 +0000 (00:11 +0200)
committerqwx <devnull@localhost>
Sat, 20 Oct 2018 22:11:39 +0000 (00:11 +0200)
revert last change, which used games/wadfs to expose genmidi and music lumps.
replacements from patch wads were never seen that way.  instead, write genmidi
and music lumps to /tmp and play them from there.

rc/bin/dmus
sys/src/games/doom/d_main.c
sys/src/games/doom/i_sound.c

index 51950d033f8051975adda9f61d4f75165f0c9288..c0c7f4a6601da24554d7d5aae766184fc2b6e8a9 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/rc
-if(test -f /mnt/wad/genmidi)
-       c=(games/dmid '|' games/opl3)
+if(test -f /tmp/genmidi.*)
+       c=(games/dmid -i /tmp/genmidi.* '|' games/opl3)
 if not
        c=(games/midi -c)
 if(~ `{file -m $1} audio/mus)
index 7063069125b2177206fa33121454497cc453a170..6f1e8621545e224ade980acf47397386b62749b1 100644 (file)
@@ -635,11 +635,6 @@ void IdentifyVersion (void)
                gamemode = indetermined;
                return;
        }
-       if(gamemode != indetermined && rfork(RFPROC|RFFDG) == 0){
-               close(2);
-               execl("/bin/games/wadfs", "wadfs", wadfile, nil);
-               sysfatal("execl: %r");
-       }
        strncpy(basedefault, wadfile, sizeof(basedefault)-5);
        basedefault[sizeof(basedefault)-5] = '\0';
        slash = strrchr(basedefault, '/');
index e15e988ab78443f073d7e50bf6ecf6d46cb0abb9..50f1f118e176dc79370cced27dd5ab496942ed33 100644 (file)
@@ -422,6 +422,19 @@ void I_UpdateSoundParams(int handle, int vol, int sep, int pitch)
 
 void I_InitMusic(void)
 {
+       int fd, n, sz;
+       char name[64];
+       uchar *gm;
+
+       n = W_GetNumForName("GENMIDI");
+       sz = W_LumpLength(n);
+       gm = (uchar *)W_CacheLumpNum(n, PU_STATIC);
+       snprint(name, sizeof(name), "/tmp/genmidi.%d", getpid());
+       if((fd = create(name, ORDWR|ORCLOSE, 0666)) < 0)
+               sysfatal("create: %r");
+       if(write(fd, gm, sz) != sz)
+                       sysfatal("write: %r");
+       Z_Free(gm);
 }
 
 void I_ShutdownMusic(void)
@@ -462,7 +475,15 @@ void I_PlaySong(musicinfo_t *m, int loop)
        case 0:
                dup(mpfd[1], 1);
                for(n=3; n<20; n++) close(n);
-               snprint(name, sizeof(name), "/mnt/wad/d_%s", m->name);
+               close(0);
+               snprint(name, sizeof(name), "/tmp/doom.%d", getpid());
+               if(create(name, ORDWR|ORCLOSE, 0666) != 0)
+                       sysfatal("create: %r");
+               n = W_LumpLength(m->lumpnum);
+               if(write(0, m->data, n) != n)
+                       sysfatal("write: %r");
+               if(seek(0, 0, 0) != 0)
+                       sysfatal("seek: %r");
                if(bind("/fd/1", "/dev/audio", MREPL) < 0)
                        sysfatal("bind: %r");
                while(loop && fork() > 0){