ref: f5c6a870bfb6d92f623aaa42bb60f074638e37fe
parent: b4eb667f02c32f007290b68adc95c8fbd9a2c3cd
author: qwx <devnull@localhost>
date: Sat Oct 20 20:11:39 EDT 2018
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.
--- 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)
--- a/sys/src/games/doom/d_main.c
+++ b/sys/src/games/doom/d_main.c
@@ -635,11 +635,6 @@
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, '/');
--- a/sys/src/games/doom/i_sound.c
+++ b/sys/src/games/doom/i_sound.c
@@ -422,6 +422,19 @@
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 @@
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){