summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqwx <devnull@localhost>2018-10-21 00:11:39 +0200
committerqwx <devnull@localhost>2018-10-21 00:11:39 +0200
commitf5c6a870bfb6d92f623aaa42bb60f074638e37fe (patch)
tree30aa568eff9d1d34b6fc82d98fca0bea8aa9422f
parentb4eb667f02c32f007290b68adc95c8fbd9a2c3cd (diff)
downloadplan9front-f5c6a870bfb6d92f623aaa42bb60f074638e37fe.tar.xz
doom: fix music for patch wads
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.
-rwxr-xr-xrc/bin/dmus4
-rw-r--r--sys/src/games/doom/d_main.c5
-rw-r--r--sys/src/games/doom/i_sound.c23
3 files changed, 24 insertions, 8 deletions
diff --git a/rc/bin/dmus b/rc/bin/dmus
index 51950d033..c0c7f4a66 100755
--- a/rc/bin/dmus
+++ b/rc/bin/dmus
@@ -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)
diff --git a/sys/src/games/doom/d_main.c b/sys/src/games/doom/d_main.c
index 706306912..6f1e86215 100644
--- a/sys/src/games/doom/d_main.c
+++ b/sys/src/games/doom/d_main.c
@@ -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, '/');
diff --git a/sys/src/games/doom/i_sound.c b/sys/src/games/doom/i_sound.c
index e15e988ab..50f1f118e 100644
--- a/sys/src/games/doom/i_sound.c
+++ b/sys/src/games/doom/i_sound.c
@@ -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){