aboutsummaryrefslogtreecommitdiffstats
path: root/games/linuxdoom/files/patch-aa
blob: 6e6d548ce5724be5a6f823e216b6be0a9a2007a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
diff -ruN ../virgin/Makefile ./Makefile
--- ../virgin/Makefile  Wed Dec 31 18:00:00 1969
+++ ./Makefile  Tue Dec 10 11:42:20 1996
@@ -0,0 +1,24 @@
+
+SUBDIR+= joystick4doom
+SUBDIR+= musserver
+
+all: doom.sh
+
+install:
+   mkdir -p ${PREFIX}/libexec/doom
+   mkdir -p ${PREFIX}/share/doom
+   install -c -m 755 doom.sh ${PREFIX}/bin/doom
+   for i in xdoom sndserver; do \
+       install -c -m 755 doom-1.8/$$i ${PREFIX}/libexec/doom; \
+   done
+   for i in doom1.wad README README.config README.linuxx; do \
+       install -c -m 644 doom-1.8/$$i ${PREFIX}/share/doom; \
+   done
+   (cd musserver; make install)
+   (cd joystick4doom; make install)
+
+.include <bsd.subdir.mk>
+
+doom.sh:
+   sed "s,@PREFIX@,${PREFIX}," doom.sh.in >doom.sh
+
Binary files ../virgin/doom-1.8/pat and ./doom-1.8/pat differ
Binary files ../virgin/doom-1.8/sdoom and ./doom-1.8/sdoom differ
Binary files ../virgin/doom-1.8/xdoom and ./doom-1.8/xdoom differ
diff -ruN ../virgin/doom.sh.in ./doom.sh.in
--- ../virgin/doom.sh.in    Wed Dec 31 18:00:00 1969
+++ ./doom.sh.in    Wed Dec 11 09:58:06 1996
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ -e /dev/joy0 ]; then
+   if sh -c 'exec 9</dev/joy0' 2>/dev/null; then
+       echo using joystick
+       exec 9>&-
+       [ -f /tmp/joystick4doom.pid ] && @PREFIX@/libexec/doom/joystick4xdoom -k
+       @PREFIX@/libexec/doom/joystick4xdoom /dev/joy0 Control Space &
+   fi
+fi
+
+DOOMWADDIR=@PREFIX@/share/doom; export DOOMWADDIR
+PATH=@PREFIX@/libexec/doom:${PATH}
+
+cd @PREFIX@/libexec/doom
+@PREFIX@/libexec/doom/xdoom $*
+[ -f /tmp/joystick4doom.pid ] && @PREFIX@/libexec/doom/joystick4xdoom -k
+
+ipcrm $(ipcs -m |sed -n 's,^\(m  *[0-9][0-9]*\).*,-\1,p')
+
diff -ruN ../virgin/joystick4doom/Makefile ./joystick4doom/Makefile
--- ../virgin/joystick4doom/Makefile    Wed Dec 14 01:27:14 1994
+++ ./joystick4doom/Makefile    Tue Dec 10 11:39:26 1996
@@ -13,8 +13,8 @@
 # Define this to be the file where the joystick settings are saved.
 DATFILE = \"/usr/local/lib/joystick.dat\"
 
-CFLAGS = -O2 $(DEBUG) $(THRESHOLD) -I. -DJOYSTICK_DAT=$(DATFILE)
-XLDPATH = -L/usr/X11R6/lib
+CFLAGS = -O2 $(DEBUG) $(THRESHOLD) -I${X11BASE}/include -DJOYSTICK_DAT=$(DATFILE)
+XLDPATH = -L${X11BASE}/lib
 LDFLAGS = -s
 XLIBS = -lX11
 
@@ -22,15 +22,16 @@
 OBJS = joystick4doom.o
 XBIN = joystick4xdoom
 SBIN = joystick4sdoom
-PRGS = $(XBIN) $(SBIN)
+PRGS = $(XBIN)
 
 all: $(PRGS) $(SRCS)
 
 $(XBIN):
    $(CC) -DX11 $(CFLAGS) $(LDFLAGS) $(SRCS) -o $(XBIN) $(XLDPATH) $(XLIBS)
 
-$(SBIN):
-   $(CC) $(CFLAGS) $(LDFLAGS) $(SRCS) -o $(SBIN)
-
 clean:
    $(RM) $(OBJS) $(PRGS)
+
+install: ${XBIN}
+   install -cs ${XBIN} ${PREFIX}/libexec/doom
+
diff -ruN ../virgin/joystick4doom/README.FreeBSD ./joystick4doom/README.FreeBSD
--- ../virgin/joystick4doom/README.FreeBSD  Wed Dec 31 18:00:00 1969
+++ ./joystick4doom/README.FreeBSD  Tue Dec 10 11:20:58 1996
@@ -0,0 +1,27 @@
+Sun Nov 12 23:52:35 PST 1995
+Hi,
+
+The Linux Joystick for doom has been ported to FreeBSD and it is at:
+rah.star-gate.com:/pub/joystick4doom.tar.gz
+
+I have included  in the tar file the original FreeBSD joystick.c 
+test program . joystick.c is not part of the original linux's
+joystick tar distribution.
+
+to compile the joystick4doom:
+
+ cc -o joystick4doom -I/usr/X11R6/include  -DX11 joystick4doom.c -L/usr/X11R6/lib -lX11 -lm
+
+now calibrate it:
+./joystick4doom  -c /dev/joy0
+
+To run, I use the following command:
+./joystick4doom  /dev/joy0 Control Space 
+
+Now run xdoom and have a ball 8)
+
+   Amancio
+
+
+
+
diff -ruN ../virgin/joystick4doom/joystick.c ./joystick4doom/joystick.c
--- ../virgin/joystick4doom/joystick.c  Wed Dec 31 18:00:00 1969
+++ ./joystick4doom/joystick.c  Tue Dec 10 11:20:58 1996
@@ -0,0 +1,320 @@
+/*
+ * Joystick test program for FreeBSD
+ *
+ * Compile with: cc -o joystick joystick.c -lncurses
+ *
+ * 
+ * (C) Copyright 1995 Dave Bodenstab
+ * All rights reserved.
+ *
+ * This program and/or source code may be used or distributed without
+ * restriction provided this copyright notice is preserved, no fee is
+ * charged, and this source code is included with any binary distribution.
+ * Commercial use (i.e. you make money using this software) is prohibited
+ * without the express written consent of the author.  The author may be
+ * contacted at the following address:
+ *
+ *      Dave Bodenstab
+ *      22W451 Oldwoods Drive
+ *      Naperville, Illinois 60565
+ *      USA
+ */
+#include <stdio.h>
+#include <fcntl.h>
+#include <ncurses.h>
+#include <machine/joystick.h>
+
+const char m_align_ul[] ="Move stick to upper left corner and press a button";
+const char m_align_lr[] ="Move stick to lower right corner and press a button";
+const char m_button[] ="Press a button to continue";
+
+main( int argc, char **argv )
+{
+  int js, x, y, button1, button2;
+  int xLeft, xRight, yTop, yBotton;
+  int quitLeftX, quitTopY, quitRightX, quitBottomY;
+  WINDOW *winMovement, *winButton1Outline, *winButton2Outline, *winButton1, *winButton2, *winQuit;
+  struct joystick joystick;
+  char buffer[100];
+
+  if ( (js = open("/dev/joy0",O_RDONLY)) == -1 )
+    {
+      perror( "/dev/joy0" );
+      exit( 1 );
+    }
+
+  initscr();
+  curs_set( 0 );
+  leaveok( stdscr, TRUE );
+  border( 0, 0, 0, 0, 0, 0, 0, 0 );
+
+  /*
+   * Align the stick...
+   */
+  x = (COLS - 2 - strlen( m_align_ul )) / 2;
+  y = (LINES - 2) / 2;
+  mvaddstr( y, x, (char*)m_align_ul );
+  refresh();
+
+  for( ; ; napms(100) )    /* Wait for a button press... */
+    {
+      if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+        {
+     endwin();
+     perror( "read /dev/joy0" );
+     exit( 1 );
+   }
+
+      if ( joystick.b1 || joystick.b2 )
+        {
+     xLeft = joystick.x;
+     yTop = joystick.y;
+
+     /* Wait for the button(s) to be released... */
+     for( ; ; napms(100) )
+       {
+         if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+       {
+         endwin();
+         perror( "read /dev/joy0" );
+         exit( 1 );
+       }
+
+         if ( ! (joystick.b1 || joystick.b2) )
+       break;
+       }
+
+     break;
+   }
+    }
+
+  x = (COLS - 2 - strlen( m_align_lr )) / 2;
+  mvaddstr( y + 1, x, (char*)m_align_lr );
+  refresh();
+
+  for( ; ; napms(100) )    /* Wait for a button press... */
+    {
+      if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+        {
+     endwin();
+     perror( "read /dev/joy0" );
+     exit( 1 );
+   }
+
+      if ( joystick.b1 || joystick.b2 )
+        {
+     xRight = joystick.x;
+     yBotton = joystick.y;
+
+     /* Wait for the button(s) to be released... */
+     for( ; ; napms(100) )
+       {
+         if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+       {
+         endwin();
+         perror( "read /dev/joy0" );
+         exit( 1 );
+       }
+
+         if ( ! (joystick.b1 || joystick.b2) )
+       break;
+       }
+
+     break;
+   }
+    }
+
+  sprintf( buffer, "Upper left = (%d,%d)", xLeft, yTop );
+  x = (COLS - 2 - strlen( buffer )) / 2;
+  mvaddstr( y+2, x, buffer );
+  sprintf( buffer, "Lower right = (%d,%d)", xRight, yBotton );
+  x = (COLS - 2 - strlen( buffer )) / 2;
+  mvaddstr( y+3, x, buffer );
+  x = (COLS - 2 - strlen( m_button )) / 2;
+  mvaddstr( y+4, x, (char*)m_button );
+  refresh();
+
+  if ( xLeft >= xRight || yTop >= yBotton )
+    {
+      endwin();
+
+      printf( "The stick cannot be aligned properly.  Either you didn't align the\n"
+              "stick properly in the upper-left and lower-right corners, or your\n"
+         "hardware is not working.\n" );
+
+      exit( 1 );
+    }
+
+  /* Wait for a button press... */
+  for( ; ; napms(100) )
+    {
+      if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+        {
+     endwin();
+     perror( "read /dev/joy0" );
+     exit( 1 );
+   }
+
+      if ( joystick.b1 || joystick.b2 )
+        {
+     /* Wait for the button(s) to be released... */
+     for( ; ; napms(100) )
+       {
+         if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+       {
+         endwin();
+         perror( "read /dev/joy0" );
+         exit( 1 );
+       }
+
+         if ( ! (joystick.b1 || joystick.b2) )
+       break;
+       }
+
+     break;
+   }
+    }
+
+  /*
+   * Create the button windows, the movement window, and the QUIT window
+   */
+  x = (COLS - 2 - 2*7) / 3;
+  winButton1Outline = subwin( stdscr, 3, 7, LINES-3, x+1 );
+  wborder( winButton1Outline, 0, 0, 0, 0, 0, 0, ACS_BTEE, ACS_BTEE );
+  winButton1 = derwin( winButton1Outline, 1, 5, 1, 1 );
+
+  winButton2Outline = subwin( stdscr, 3, 7, LINES-3, COLS-1 - x - 1 - (7 - 1) );
+  wborder( winButton2Outline, 0, 0, 0, 0, 0, 0, ACS_BTEE, ACS_BTEE );
+  winButton2 = derwin( winButton2Outline, 1, 5, 1, 1 );
+
+  winMovement = subwin( stdscr, LINES-4, COLS-2, 1, 1 );
+  werase( winMovement );
+
+  winQuit = newwin( 5, 10, (LINES-4)/3 - 5/2, (COLS-2)/2 - 10/2 );
+  getbegyx( winQuit, quitTopY, quitLeftX );
+  getmaxyx( winQuit, quitBottomY, quitRightX );
+  quitRightX += quitLeftX - 1;
+  quitBottomY += quitTopY - 1;
+  wborder( winQuit, 0, 0, 0, 0, 0, 0, 0, 0 );
+  mvwaddstr( winQuit, 2, 3, "QUIT" );
+  overwrite( winQuit, winMovement );
+
+  touchwin( stdscr );
+  refresh();
+
+  /*
+   * Read the joystick, moving an '*' around the movement window.  When a
+   * button is pressed, highlight the corresponding button window.  If the
+   * current position is within the QUIT window and a button is pressed,
+   * exit the program.
+   */
+  button1 = 0;
+  button2 = 0;
+  x = (COLS-2) / 2;
+  y = (LINES-4) / 2;
+  mvwaddch( winMovement, y, x, '*' );
+  wrefresh( winMovement );
+
+  for( ; ; napms(100) )
+    {
+      if ( read(js,&joystick,sizeof(joystick)) != sizeof(joystick) )
+        {
+     endwin();
+     perror( "read /dev/joy0" );
+     exit( 1 );
+   }
+
+      if ( button1 != joystick.b1 )            /* Check for button 1 */
+        {
+     touchwin( winMovement );
+
+     switch( button1 = joystick.b1 )
+       {
+     case 0:
+         wattroff( winButton1, A_REVERSE );
+         break;
+     case 1:
+         wattron( winButton1, A_REVERSE );
+         break;
+       }
+     
+     mvwaddstr( winButton1, 0, 0, "     " );
+     wrefresh( winButton1 );
+   }
+
+      if ( button2 != joystick.b2 )            /* Check for button 2 */
+        {
+     touchwin( winMovement );
+
+     switch( button2 = joystick.b2 )
+       {
+     case 0:
+         wattroff( winButton2, A_REVERSE );
+         break;
+     case 1:
+         wattron( winButton2, A_REVERSE );
+         break;
+       }
+     
+     mvwaddstr( winButton2, 0, 0, "     " );
+     wrefresh( winButton2 );
+   }
+
+      if ( joystick.x != x || joystick.y != y )        /* Check for movement */
+        {
+     int nx, ny;
+
+     /* Scale the actual coordinates to the nearest character coordinate */
+     nx = ((joystick.x - xLeft) * (COLS-2 - 1)) / (xRight - xLeft);
+     if ( nx < 0 )
+       nx = 0;
+     else
+       if ( nx > COLS-2 - 1 )
+         nx = COLS-2 - 1;
+
+     ny = ((joystick.y - yTop) * (LINES-4 - 1)) / (yBotton - yTop);
+     if ( ny < 0 )
+       ny = 0;
+     else
+       if ( ny > LINES-4 - 1 )
+         ny = LINES-4 - 1;
+
+     if ( x != nx || y != ny )         /* Check for visible movement */
+       {
+         mvwaddch( winMovement, y, x, ' ' );
+
+         /*
+          * If the old (x,y) was within the QUIT window, then it must be
+          * refreshed to restore any character that was overwritten by the
+          * '*'
+          */
+         if ( x+1 >= quitLeftX && x+1 <= quitRightX && y+1 >= quitTopY && y+1 <= quitBottomY )
+       {
+         touchwin( stdscr );
+         overwrite( winQuit, winMovement );
+       }
+
+         mvwaddch( winMovement, y = ny, x = nx, '*' );
+         wrefresh( winMovement );
+
+         /* Show the current coordinates */
+         sprintf( buffer, "[%3d,%3d]", x, y );
+         mvaddstr( LINES-2, COLS-1 -3 - strlen(buffer), buffer );
+         refresh();
+       }
+
+     /*
+      * If (x,y) is within the QUIT window, then we exit if either button
+      * is pressed
+      */
+     if ( x+1 >= quitLeftX && x+1 <= quitRightX && y+1 >= quitTopY && y+1 <= quitBottomY )
+       {
+         if ( button1 || button2 )
+       break;
+       }
+   }
+    }
+
+  endwin();
+  exit( 0 );
+}
diff -ruN ../virgin/joystick4doom/joystick4doom.c ./joystick4doom/joystick4doom.c
--- ../virgin/joystick4doom/joystick4doom.c Wed Dec 14 01:26:42 1994
+++ ./joystick4doom/joystick4doom.c Tue Dec 10 11:20:58 1996
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <signal.h>
-
+#include <machine/joystick.h>
 #ifdef X11
 #define XK_MISCELLANY
 #define XK_LATIN1
@@ -41,19 +41,19 @@
 #define FALSE  0
 #endif /* X11 */
 
-#include <linux/joystick.h>
+/*#include <linux/joystick.h> */
 
 #define PIDFILE        "/tmp/joystick4doom.pid"
 #ifndef JOYSTICK_DAT
-#define JOYSTICK_DAT   "/usr/local/lib/joystick.dat"
+#define JOYSTICK_DAT   "/usr/local/share/doom/joystick.dat"
 #endif
 
 #define PAUSETIME  100000
 
 #define RELEASED   0
 #define PRESSED        1
-#define HOLDDOWN   2
-#define UNPRESSED  3
+#define HOLDDOWN       1
+#define UNPRESSED      -1
 
 #define FIRST_BUTTON   0
 #define SECOND_BUTTON  1
@@ -99,13 +99,15 @@
 char           *progname;
 int            joystick_device;
 char           *device_name;
-struct JS_DATA_TYPE    js;
+/*struct JS_DATA_TYPE  js; */
+ struct joystick js;
 int            button[2];
 int            xpos_left, xpos_middle, xpos_right, xpos_actual;
 int            ypos_upper,ypos_middle, ypos_lower, ypos_actual;
 int            i,j;
 
 /* Keep track of where the joystick is */
+#define JS_RETURN 16
 #define    CENTERED    0x00
 #define CUTRIGHT   0x01
 #define CUTLEFT        0x02
@@ -182,9 +184,10 @@
     "left", 0x69, 0xe9,
   };
 #endif /* X11 */
-
+   
   fprintf(stdout, "Joystick4Doom, 1994 by Artsoft Development\n");
-
+  button[0] = 0;
+  button[1] = 0;
   /* Kill an existing joystick process if requested */
   if ( (argc == 2) && (strcmp(argv[1], "-k") == 0) ) {
     if ( (pidfile=fopen(PIDFILE, "r")) != NULL ) {
@@ -300,7 +303,7 @@
 
     for(i=0;i<2;i++)
     {
-      if (button[i]==PRESSED)
+      if (button[i]==1)
       {
 #ifdef X11
    SendKeyEvent(KeyPress,joykey[key[i]].pressed,joykey[key[i]].key);
@@ -321,7 +324,7 @@
 #endif
    }
       }
-      if (button[i]==RELEASED)
+      if (button[i]==0)
       {
 #ifdef X11
    SendKeyEvent(KeyRelease,joykey[key[i]].released,joykey[key[i]].key);
@@ -492,7 +495,7 @@
   WaitButton();
   xpos_left =js.x;
   ypos_upper=js.y;
-  fprintf(stdout, "xpos_left = %d\nypos_upper = %d\n", js.x,  js.y);
+
 
   fprintf(stdout, "Move joystick to the lower right and press any button!\n");
   WaitButton();
@@ -524,13 +527,14 @@
     exit(-1);
   }
 
-  for(i=0;i<2;i++)
-  {
-    if (js.buttons & (1<<i))
-      button[i] = (JB_UNPRESSED(i) ? PRESSED : HOLDDOWN);
-    else
-      button[i] = (JB_PRESSED(i) ? RELEASED : UNPRESSED);
-  }
+  if (button[0] == 0 && js.b1 == 0 ) {
+    button[0] = -1;
+  } else button[0]= js.b1;
+
+  if (button[1] == 0 && js.b2 == 0 ) {
+    button[1] = -1;
+  } else button[1]= js.b2;
+          
 
   xpos_actual=js.x;
   ypos_actual=js.y;
@@ -583,8 +587,11 @@
 #else
 void SendKeyEvent(char key)
 {
+
   if ( ioctl(console, TIOCSTI, &key) < 0 )
         perror("ioctl(TIOCSTI)");
 }
 #endif /* X11 */
+
+
 
Binary files ../virgin/joystick4doom/joystick4sdoom and ./joystick4doom/joystick4sdoom differ
Binary files ../virgin/joystick4doom/joystick4xdoom and ./joystick4doom/joystick4xdoom differ
diff -ruN ../virgin/joystick4doom/linux/joystick.h ./joystick4doom/linux/joystick.h
--- ../virgin/joystick4doom/linux/joystick.h    Tue Nov  8 02:11:32 1994
+++ ./joystick4doom/linux/joystick.h    Tue Dec 10 11:20:59 1996
@@ -1,12 +1,11 @@
 
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/major.h>
-#include <asm/io.h>
+/*#include <linux/sched.h> */
+#include <errno.h>
+/*#include <asm/io.h>
 #include <asm/segment.h>
 #include <asm/system.h>
 #include <linux/module.h>
-
+*/
 #define JS_RETURN sizeof(struct JS_DATA_TYPE)  /*number of bytes returned by js_read*/
 #define JS_TRUE 1
 #define JS_FALSE 0
diff -ruN ../virgin/joystick4doom/linux/joystick.h~ ./joystick4doom/linux/joystick.h~
--- ../virgin/joystick4doom/linux/joystick.h~   Wed Dec 31 18:00:00 1969
+++ ./joystick4doom/linux/joystick.h~   Tue Dec 10 11:20:59 1996
@@ -0,0 +1,58 @@
+
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/major.h>
+#include <asm/io.h>
+#include <asm/segment.h>
+#include <asm/system.h>
+#include <linux/module.h>
+
+#define JS_RETURN sizeof(struct JS_DATA_TYPE)  /*number of bytes returned by js_read*/
+#define JS_TRUE 1
+#define JS_FALSE 0
+#define JS_PORT 0x201      /*io port for joystick operations*/
+#define JS_DEF_TIMEOUT 0x1300  /*default timeout value for js_read()*/
+#define JS_DEF_CORR    0   /*default correction factor*/
+#define JS_DEF_TIMELIMIT 10L   /*default data valid time =10 jiffies == 100ms*/
+#define JS_X_0 0x01        /*bit mask for x-axis js0*/
+#define JS_Y_0 0x02        /*bit mask for y-axis js0*/
+#define JS_X_1 0x04        /*bit mask for x-axis js1*/
+#define JS_Y_1 0x08        /*bit mask for y-axis js1*/
+#define JS_MAX 2       /*Max number of joysticks*/
+#define PIT_MODE 0x43      /*io port for timer 0*/
+#define PIT_COUNTER_0 0x40 /*io port for timer 0*/
+#define JS_SET_CAL 0x01        /*ioctl cmd to set joystick correction factor*/
+#define JS_GET_CAL 0x02        /*ioctl cmd to get joystick correction factor*/
+#define JS_SET_TIMEOUT 0x03    /*ioctl cmd to set maximum number of iterations
+                 to wait for a timeout*/
+#define JS_GET_TIMEOUT     0x04    /*as above, to get*/
+#define JS_SET_TIMELIMIT   0x05    /*set data retention time*/
+#define JS_GET_TIMELIMIT   0x06    /*get data retention time*/
+#define JS_GET_ALL     0x07    /*get the whole JS_DATA[minor] struct*/
+#define JS_SET_ALL     0x08    /*set the whole JS_DATA[minor] struct
+                         except JS_BUSY!*/
+
+/*This union is used for the ioctl to set the scaling factor and to return
+  the current values for a joystick. 'buttons' is ignored on the ioctl call*/
+
+struct JS_DATA_TYPE {
+   int buttons;
+   int x;
+   int y;
+};
+
+/* This struct is used for misc data about the joystick*/
+struct JS_DATA_SAVE_TYPE {
+   int JS_TIMEOUT;     /*timeout*/
+   int BUSY;       /*joystick is in use*/
+   long JS_EXPIRETIME; /*Time when stick after which stick must be re-read*/
+   long JS_TIMELIMIT;  /*Max time before data is invalid*/
+   struct JS_DATA_TYPE JS_SAVE;    /*last read data*/
+   struct JS_DATA_TYPE JS_CORR;    /*correction factor*/
+};
+
+#define LATCH (1193180L/HZ)    /*initial timer 0 value*/
+#define DELTA_TIME(X,Y) ((X)-(Y)+(((X)>=(Y))?0:LATCH))
+#define CURRENT_JIFFIES (jiffies)
+
+#define JOYSTICK_MAJOR     15
diff -ruN ../virgin/musserver/Makefile ./musserver/Makefile
--- ../virgin/musserver/Makefile    Fri Jul 28 01:30:47 1995
+++ ./musserver/Makefile    Tue Dec 10 11:43:30 1996
@@ -7,12 +7,12 @@
 
 # Uncomment this line for extra debugging output
 #CFLAGS = -g -DDEBUG -I. -Wall -O2 -m486
-CFLAGS = -g -I. -Wall -O2 -m486
+CFLAGS = -I. -Wall -O2 -m486
 #CFLAGS = -I. -Wall
 LIBS   = -s
 
 INSTALL = install
-DESTDIR = /usr/local/bin
+DESTDIR = /usr/local/libexec/doom
 SHELL = /bin/sh
 
 #############################################
@@ -21,16 +21,25 @@
 
 OBJS = musserver.o readwad.o playmus.o sequencer.o
 
-musserver: $(OBJS)
+musserver.bin: $(OBJS)
       $(CC) $(LIBS) -o $@ $(OBJS)
 
+musserver.sh: musserver.sh.in
+      sed "s,@PREFIX@,${PREFIX}," musserver.sh.in >$@
+
 clean:
-   rm -f $(OBJS) ipc.o ipc musserver
+   rm -f $(OBJS) ipc.o ipc musserver.bin
 
-all: musserver
+all: musserver.bin musserver.sh doom-patch
 
 install: all
-   $(INSTALL) musserver $(DESTDIR)
+   $(INSTALL) -cs musserver.bin $(DESTDIR)
+   ${INSTALL} -c -m 755 musserver.sh ${DESTDIR}/musserver
 
 ipc:   ipc.o
    $(CC) -o $@ ipc.o
+
+doom-patch:
+   zcat doompat.tgz |(cd ../doom-1.8; pax -rv)
+   @cd ../doom-1.8; ./pat @mus11.pat@xdoom || (/usr/bin/linux; ./pat @mus11.pat@xdoom)
+   touch doom-patch
Binary files ../virgin/musserver/musserver and ./musserver/musserver differ
diff -ruN ../virgin/musserver/musserver.c ./musserver/musserver.c
--- ../virgin/musserver/musserver.c Tue Aug 22 20:50:56 1995
+++ ./musserver/musserver.c Tue Dec 10 11:20:57 1996
@@ -28,6 +28,7 @@
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include "musserver.h"
+#include <sys/errno.h>
 
 extern int use_synth;
 extern int seqfd;
diff -ruN ../virgin/musserver/musserver.h ./musserver/musserver.h
--- ../virgin/musserver/musserver.h Wed Aug  9 04:18:00 1995
+++ ./musserver/musserver.h Tue Dec 10 11:20:57 1996
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *************************************************************************/
 
-#include <sys/soundcard.h>
+#include <machine/soundcard.h>
 
 struct mus_header {            /* header of music lump */
    char        id[4];
diff -ruN ../virgin/musserver/musserver.sh.in ./musserver/musserver.sh.in
--- ../virgin/musserver/musserver.sh.in Wed Dec 31 18:00:00 1969
+++ ./musserver/musserver.sh.in Tue Dec 10 11:20:57 1996
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec @PREFIX@/libexec/doom/musserver.bin -f $*
diff -ruN ../virgin/musserver/playmus.c ./musserver/playmus.c
--- ../virgin/musserver/playmus.c   Tue Aug 22 20:14:30 1995
+++ ./musserver/playmus.c   Tue Dec 10 11:20:57 1996
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "musserver.h"
+#include <sys/errno.h>
 
 void seqbuf_dump(void);
 void reset_midi(void);
@@ -52,6 +53,8 @@
 
 int returnval = 0;
 
+#define msgbuf mymsg
+
 static char *doom2names[] = {
         "D_RUNNIN", "D_STALKS", "D_COUNTD", "D_BETWEE", "D_DOOM", "D_THE_DA",
         "D_SHAWN", "D_DDTBLU", "D_IN_CIT", "D_DEAD", "D_STLKS2", "D_THEDA2",
@@ -152,6 +155,7 @@
           }
         cleanup(1);
         break;
+#if 0
       case EIDRM:
         if (verbose)
           {
@@ -160,6 +164,7 @@
           }
         cleanup(1);
         break;
+#endif
       case EINTR:
         if (verbose)
           printf("Could not receive IPC message: received an interrupt signal\n");
@@ -172,8 +177,10 @@
           }
         cleanup(1);
         break;
+#if 0
       case ENOMSG:
         break;
+#endif
       }
   free(recv);
   }