Spacewar Gngngngnnnn!!!

Robert Best bob at turnkey.TCC.COM
Tue Jun 21 08:53:38 AEST 1988


Spacewar patch for Xenix 386 (286?)
from Bob Best (bob at dhw68k.cts.com)

The following patches can be used as input to Larry Wall's patch program
to revise the following files:
	update.c
	cmd.c
	play.c
All patches involve manipulation of alarm(2) system calls that were causing
spacewar to fail during execution.  Since these patches are timing related,
no guaranty can be made regarding their success on varying systems.  These
patches have only been tested on Xenix 386 2.2.2.

To generate the patches, enter 'patch <patchfile' at shell prompt, where
this file is 'patchfile'.  This must be done from directory containing source.
Next, run 'make', install binaries in directory specified in spacewar.h and
then, hopefully, type 'psw.sh' and TAKE OFF!

*** /usr/tmp/sw/org/update.c
--- update.c
**************
*** 4,10
   * Copyright 1985 obo Systems, Inc.
   * Copyright 1985 Dan Rosenblatt
   */
- 
  #include "spacewar.h"
  #ifndef VMS
  #include <sys/types.h>
--- 4,9 -----
   * Copyright 1985 obo Systems, Inc.
   * Copyright 1985 Dan Rosenblatt
   */
  #include "spacewar.h"
  #ifndef VMS
  #include <sys/types.h>
**************
*** 30,35
  	char *s,*lckmsg();
  	extern int numpling;
  
  #ifdef DEBUG
  	DBG("update()\n");
  #endif
--- 29,35 -----
  	char *s,*lckmsg();
  	extern int numpling;
  
+ 	alarm(0);/*RSB - alarm off during update*/
  #ifdef DEBUG
  	DBG("update()\n");
  #endif
**************
*** 60,65
  	    }
  	}
  
  	/* movement of objects */
  	updobjs();
  	updmov();
--- 60,66 -----
  	    }
  	}
  
+ 	if (gametime%10L == 0) { /*RSB - do update on every 10th call*/
  	/* movement of objects */
  	updobjs();
  	updmov();
**************
*** 76,82
  
  	/* direction, sensors, homing */
  	upddsh();
! 
  	/* player's screens */
  	for (plogin=loginlst;plogin < loginlst+MAXLOGIN;++plogin) {
  	    if (!plogin->ln_tty || !(puniv=plogin->ln_play.ip_ptr)) continue;
--- 77,83 -----
  
  	/* direction, sensors, homing */
  	upddsh();
! 	}
  	/* player's screens */
  	for (plogin=loginlst;plogin < loginlst+MAXLOGIN;++plogin) {
  	    if (!plogin->ln_tty || !(puniv=plogin->ln_play.ip_ptr)) continue;
**************
*** 85,91
  	    output(plogin,0,0,0);
  	    pcrft->cr_time += 1;
  	}
- 
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
--- 86,91 -----
  	    output(plogin,0,0,0);
  	    pcrft->cr_time += 1;
  	}
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
**************
*** 89,92
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
  }
--- 89,93 -----
  #ifdef DEBUG
  	VDBG("update return\n");
  #endif
+         alarm(1);/*RSB - alarm on*/
  }

*** /usr/tmp/sw/org/cmd.c
--- cmd.c
**************
*** 357,363
  	struct uio2 inp2;
  #endif /* VMS */
  #endif /* BSD */
- 
  #ifdef DEBUG
  	DBG("getinp()\n");
  #endif /* DEBUG */
--- 357,362 -----
  	struct uio2 inp2;
  #endif /* VMS */
  #endif /* BSD */
  #ifdef DEBUG
  	DBG("getinp()\n");
  #endif /* DEBUG */
**************
*** 372,377
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif
  			return(NULL);
  		}
  		doproctrap = 1;
--- 371,377 -----
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif
+ 			alarm(1);/*RSB*/
  			return(NULL);
  		}
  		doproctrap = 1;
**************
*** 394,399
  			continue;
  		}
  #endif /* VMS BSD SYSIII SYSV */
  		doproctrap = 0;
  #ifdef DEBUG
  #ifndef BSD
--- 394,400 -----
  			continue;
  		}
  #endif /* VMS BSD SYSIII SYSV */
+ 		alarm(0);/*RSB*/
  		doproctrap = 0;
  #ifdef DEBUG
  #ifndef BSD
**************
*** 457,462
  #ifdef DEBUG
  			    VDBG("getinp return\n");
  #endif /* DEBUG */
  			    return(inp.uio_lgn);
  
  			case '\025':	/* control-U */
--- 458,464 -----
  #ifdef DEBUG
  			    VDBG("getinp return\n");
  #endif /* DEBUG */
+ 			alarm(1);/*RSB*/
  			    return(inp.uio_lgn);
  
  			case '\025':	/* control-U */
**************
*** 495,500
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif /* DEBUG */
  			return(inp.uio_lgn);
  		    }
  
--- 497,503 -----
  #ifdef DEBUG
  			VDBG("getinp return\n");
  #endif /* DEBUG */
+ 			alarm(1);/*RSB*/
  			return(inp.uio_lgn);
  		    }
  

*** /usr/tmp/sw/org/play.c
--- play.c
**************
*** 58,63
  	char ucargs[9][20+1],inuc=0;
  	dsplcmnt tmpdspl;
  
  #ifdef DEBUG
  	DBG("play(#%d/%s)\n",plogin-loginlst,plogin->ln_name);
  #endif
--- 58,64 -----
  	char ucargs[9][20+1],inuc=0;
  	dsplcmnt tmpdspl;
  
+ 	alarm(0);/*RSB*/
  #ifdef DEBUG
  	DBG("play(#%d/%s)\n",plogin-loginlst,plogin->ln_name);
  #endif
**************
*** 65,70
  	/* if not yet placed into the universe, try doing so */
  	if (!plogin->ln_play.ip_ptr) {
  	    if (plinit(plogin)) {
  		pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
  		sprintf(plogin->ln_input,"Wlcm abrd the %s captain %s",
  		plogin->ln_crft,plogin->ln_name);
--- 66,72 -----
  	/* if not yet placed into the universe, try doing so */
  	if (!plogin->ln_play.ip_ptr) {
  	    if (plinit(plogin)) {
+                 alarm(0);/*RSB*/
  		pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
  		sprintf(plogin->ln_input,"Wlcm abrd the %s captain %s",
  		plogin->ln_crft,plogin->ln_name);
**************
*** 74,79
  #ifdef DEBUG
  	    VDBG("play return\n");
  #endif
  	    return;
  	}
  	pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
--- 76,82 -----
  #ifdef DEBUG
  	    VDBG("play return\n");
  #endif
+ 	    alarm(1);/*RSB*/
  	    return;
  	}
  	pcrft = plogin->ln_play.ip_ptr->uv_ptr.uv_crft;
**************
*** 527,532
  		    output(plogin,'E',0,0);
  		    output(plogin,'C',0,PROMPT);
  		    output(plogin,0,0,0);
  		    return;
  		}
  		sprintf(buf,"%.14s - not docked and BAD != 0",plogin->ln_input);
--- 530,536 -----
  		    output(plogin,'E',0,0);
  		    output(plogin,'C',0,PROMPT);
  		    output(plogin,0,0,0);
+ 		    alarm(1);/*RSB*/
  		    return;
  		}
  		sprintf(buf,"%.14s - not docked and BAD != 0",plogin->ln_input);
**************
*** 1149,1154
  #ifdef DEBUG
  	VDBG("play return\n");
  #endif
  	return;
  }
  
--- 1153,1159 -----
  #ifdef DEBUG
  	VDBG("play return\n");
  #endif
+ 	alarm(1);/*RSB*/
  	return;
  }
  



More information about the Comp.unix.xenix mailing list