shithub: riscv

Download patch

ref: e7b1c1aad896c131fb30b6b0836ff65a63a6eae3
parent: 1a751a59393ad696cdd7f6db882e3d0118e0b54e
author: qwx <devnull@localhost>
date: Sun Jul 15 02:31:45 EDT 2018

doom: use wadfs to expose music lumps

launch wadfs after detecting main wad, exposing GENMIDI and music lumps
under /mnt/wad.  /bin/dmus can then use them directly, and wadfs doesn't
need to be started manually.

--- a/sys/src/games/doom/d_main.c
+++ b/sys/src/games/doom/d_main.c
@@ -635,6 +635,11 @@
 		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
@@ -462,15 +462,7 @@
 	case 0:
 		dup(mpfd[1], 1);
 		for(n=3; n<20; n++) close(n);
-		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");
+		snprint(name, sizeof(name), "/mnt/wad/d_%s", m->name);
 		if(bind("/fd/1", "/dev/audio", MREPL) < 0)
 			sysfatal("bind: %r");
 		while(loop && fork() > 0){