patch to make corewars run under XENIX 286

Felix Gaehtgens felix at netmbx.UUCP
Thu Feb 9 02:33:12 AEST 1989


[ here is a patch you need for corewars to run under XENIX 286. it should
work on microport 286 as well, although i haven't tried it.
just feed this article to patch and don't forget to use the -n option for
patch! ]


Index: MakeInt
1c1
< CFLAGS = -DSMALL
---
> CFLAGS = -O -DSMALL -Ml -LARGE
4c4
< 	cc -o interp  main.o load.o output.o play.o inst.o -lcurses -ltermcap
---
> 	cc -g -Zi -Ml -LARGE -F 7000 -o interp  main.o load.o output.o play.o inst.o -lcurses -ltermlib -lx
10c10
< 	cc -c $(CFLAG) load.c -o load.o
---
> 	cc -c $(CFLAGS) load.c -o load.o
19c19
< 	cc -c $(FLAGS) inst.c -o inst.o
---
> 	cc -c $(CFLAGS) inst.c -o inst.o
Index: README
211a212,214
> Felix Gaehtgens ported this version to XENIX 286, making a[] a pointer
> array. He also fixed some bugs where the tty-settings were not reset
> after an exit().
Index: amain.c
10c10
< #include <strings.h>
---
> #include <string.h>
33c33
< 	if (!(dot = rindex(newstr,'.')))
---
> 	if (!(dot = strrchr(newstr,'.')))
Index: inst.c
8a9,10
> #include <sys/types.h>
> #include <ctype.h>
12c14
< extern	cell	a[];		/* core */
---
> extern	cell	*a[];		/* core */
52c54
< 	temp = getdirect(temp, a[temp].para2);	/* This time it's for real */
---
> 	temp = getdirect(temp, a[temp]->para2);	/* This time it's for real */
72c74
< 	exit(1);
---
> 	bye(1);
85c87
< 	if (a[ins].m1 == immed)
---
> 	if (a[ins]->m1 == immed)
89c91
< 		temp.para2 = a[ins].para1;
---
> 		temp.para2 = a[ins]->para1;
94,95c96,97
< 		realpos = getpara(ins, a[ins].m1, a[ins].para1);
< 		temp = a[realpos];
---
> 		realpos = getpara(ins, a[ins]->m1, a[ins]->para1);
> 		temp = *a[realpos];
98c100
< 	if (a[ins].m2 == immed)
---
> 	if (a[ins]->m2 == immed)
102c104
< 		exit(1);
---
> 		bye(1);
105c107
< 		realpos = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		realpos = getpara(ins, a[ins]->m2, a[ins]->para2);
107,108c109,110
< 	a[realpos] = temp;
< 	a[realpos].lastmod = pid;
---
> 	memcpy(a[realpos],&temp,sizeof(cell));
> 	a[realpos]->lastmod = pid;
122,123c124,125
< 	if (a[ins].m1 == immed)
< 		x = a[ins].para1;
---
> 	if (a[ins]->m1 == immed)
> 		x = a[ins]->para1;
125c127
< 		x = a[getpara(ins, a[ins].m1, a[ins].para1)].para2;
---
> 		x = a[getpara(ins, a[ins]->m1, a[ins]->para1)]->para2;
127c129
< 	if (a[ins].m2 == immed)
---
> 	if (a[ins]->m2 == immed)
131c133
< 		exit(1);
---
> 		bye(1);
134c136
< 		realpos = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		realpos = getpara(ins, a[ins]->m2, a[ins]->para2);
136,138c138,140
< 	a[realpos].para2 += x;
< 	a[realpos].lastmod = pid;
< 	correct(&(a[realpos].para2));
---
> 	a[realpos]->para2 += x;
> 	a[realpos]->lastmod = pid;
> 	correct(&(a[realpos]->para2));
152,153c154,155
< 	if (a[ins].m1 == immed)
< 		x = a[ins].para1;
---
> 	if (a[ins]->m1 == immed)
> 		x = a[ins]->para1;
155c157
< 		x = a[getpara(ins, a[ins].m1, a[ins].para1)].para2;
---
> 		x = a[getpara(ins, a[ins]->m1, a[ins]->para1)]->para2;
157c159
< 	if (a[ins].m2 == immed)
---
> 	if (a[ins]->m2 == immed)
161c163
< 		exit(1);
---
> 		bye(1);
164c166
< 		realpos = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		realpos = getpara(ins, a[ins]->m2, a[ins]->para2);
166,168c168,170
< 	a[realpos].para2 -= x;
< 	a[realpos].lastmod = pid;
< 	correct(&(a[realpos].para2));
---
> 	a[realpos]->para2 -= x;
> 	a[realpos]->lastmod = pid;
> 	correct(&(a[realpos]->para2));
177c179
< 	if (a[ins].m2 == immed)
---
> 	if (a[ins]->m2 == immed)
181c183
< 		exit(1);
---
> 		bye(1);
184c186
< 		*pc = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		*pc = getpara(ins, a[ins]->m2, a[ins]->para2);
195,196c197,198
< 	if (a[ins].m2 == immed)
< 		value = a[ins].para2;
---
> 	if (a[ins]->m2 == immed)
> 		value = a[ins]->para2;
199c201
< 		value = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		value = getpara(ins, a[ins]->m2, a[ins]->para2);
201c203
< 		value = a[value].para2;
---
> 		value = a[value]->para2;
209c211
< 		*pc = getpara(ins, a[ins].m1, a[ins].para1);
---
> 		*pc = getpara(ins, a[ins]->m1, a[ins]->para1);
220,221c222,223
< 	if (a[ins].m2 == immed)
< 		value = a[ins].para2;
---
> 	if (a[ins]->m2 == immed)
> 		value = a[ins]->para2;
224c226
< 		value = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		value = getpara(ins, a[ins]->m2, a[ins]->para2);
226c228
< 		value = a[value].para2;
---
> 		value = a[value]->para2;
230c232
< 		*pc = getpara(ins, a[ins].m1, a[ins].para1);
---
> 		*pc = getpara(ins, a[ins]->m1, a[ins]->para1);
242c244
< 	if (a[ins].m2 == immed)
---
> 	if (a[ins]->m2 == immed)
246c248
< 		exit(1);
---
> 		bye(1);
249c251
< 		temp = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		temp = getpara(ins, a[ins]->m2, a[ins]->para2);
251,253c253,255
< 	(a[temp].para2)--;
< 	correct(&(a[temp].para2));
< 	a[temp].lastmod = pid;
---
> 	(a[temp]->para2)--;
> 	correct(&(a[temp]->para2));
> 	a[temp]->lastmod = pid;
255c257
< 	if (!a[temp].para2)
---
> 	if (!a[temp]->para2)
258c260
< 		*pc = getpara(ins, a[ins].m1, a[ins].para1);
---
> 		*pc = getpara(ins, a[ins]->m1, a[ins]->para1);
269,270c271,272
< 	if (a[ins].m1 == immed)
< 		value1 = a[ins].para1;
---
> 	if (a[ins]->m1 == immed)
> 		value1 = a[ins]->para1;
272c274
< 		value1 = a[getpara(ins, a[ins].m1, a[ins].para1)].para2;
---
> 		value1 = a[getpara(ins, a[ins]->m1, a[ins]->para1)]->para2;
274,275c276,277
< 	if (a[ins].m2 == immed)
< 		value2 = a[ins].para2;
---
> 	if (a[ins]->m2 == immed)
> 		value2 = a[ins]->para2;
277c279
< 		value2 = a[getpara(ins, a[ins].m2, a[ins].para2)].para2;
---
> 		value2 = a[getpara(ins, a[ins]->m2, a[ins]->para2)]->para2;
297c299
< 	if (a[ins].m2 == immed)
---
> 	if (a[ins]->m2 == immed)
301c303
< 		exit(1);
---
> 		bye(1);
304c306
< 		newpc = getpara(ins, a[ins].m2, a[ins].para2);
---
> 		newpc = getpara(ins, a[ins]->m2, a[ins]->para2);
310c312
< 		exit(1);
---
> 		bye(1);
Index: load.c
4a5,6
> #include <sys/types.h>
> #include <ctype.h>
9,10c11,12
< #define IO(i,j) if((i) < (j)){printf("error reading file\n");exit(1);}
< extern	cell	a[];
---
> #define IO(i,j) if((i) < (j)){printf("error reading file\n");bye(1);}
> extern	cell	*a[];
66c68
< 		memcpy(&a[(counter+position)%SIZE],&ele[counter],sizeof(memory));
---
> 		memcpy(a[(counter+position)%SIZE],&ele[counter],sizeof(memory));
74c76
< 		a[(counter+position)%SIZE].lastmod = no;
---
> 		a[(counter+position)%SIZE]->lastmod = no;
77,82c79,84
< 			a[(counter+position)%SIZE].inst,
< 			a[(counter+position)%SIZE].para1,
< 			a[(counter+position)%SIZE].para2,
< 			a[(counter+position)%SIZE].m1,
< 			a[(counter+position)%SIZE].m2,
< 			a[(counter+position)%SIZE].lastmod);
---
> 			a[(counter+position)%SIZE]->inst,
> 			a[(counter+position)%SIZE]->para1,
> 			a[(counter+position)%SIZE]->para2,
> 			a[(counter+position)%SIZE]->m1,
> 			a[(counter+position)%SIZE]->m2,
> 			a[(counter+position)%SIZE]->lastmod);
87c89
< 		exit(1);
---
> 		bye(1);
113c115
< 		if (a[(counter+start)%SIZE].lastmod) {
---
> 		if (a[(counter+start)%SIZE]->lastmod) {
Index: lookup.c
17c17
< #include <strings.h>
---
> #include <string.h>
Index: main.c
8d7
< #include <ctype.h>
9a9,13
> #include <ctype.h>
> #include <sys/types.h>
> /* #include <time.h>
> #include <sys/times.h> */
> #include <malloc.h>
16c20
< cell	a[SIZE];
---
> cell	*a[SIZE];
48a53
> 	long	blafasel;
50c55,60
< 	counter = (int) time(0);
---
> 	for (counter=0; counter <= SIZE; counter++)
> 		if (!(a[counter] = (cell *) malloc (sizeof(cell)))) {
> 			printf ("PANIC: can't allocate mem --- initialize\n");
> 			bye(1);
> 		}
> 	counter = (int) time(&blafasel);
52a63
> 	savetty();		/* save tty flags for later */
60c71
< 	for (counter = 0; counter++; counter < SIZE)
---
> 	for (counter = 0; counter < SIZE; counter++)
63a75,83
> 
> bye(whatever)
> int whatever;
> {
> 	resetty();		/* restore tty flags */
> 	exit(whatever);
> }
> 
> 
76c96
< 		exit(1);
---
> 		bye(1);
82c102
< 		exit(1);
---
> 		bye(1);
88c108
< 		exit(1);
---
> 		bye(1);
95c115
< 		exit(1);
---
> 		bye(1);
102c122
< 		exit(1);
---
> 		bye(1);
109c129
< 		exit(1);
---
> 		bye(1);
128c148
< 	getch(errcode);
---
> 	getch();
Index: output.c
6a7,8
> #include <sys/types.h>
> #include <ctype.h>
8c10
< extern	cell	a[];
---
> extern	cell	*a[];
17c19
< 		if (a[i].lastmod == 0)
---
> 		if (a[i]->lastmod == 0)
19c21
< 		else if (a[i].lastmod == 1)
---
> 		else if (a[i]->lastmod == 1)
21c23
< 		else if (a[i].lastmod == 2)
---
> 		else if (a[i]->lastmod == 2)
25c27
< 			printf("\nerror lastmod == %d", a[i].lastmod);
---
> 			printf("\nerror lastmod == %d", a[i]->lastmod);
27c29
< 			exit(1);
---
> 			bye(1);
83c85
< 			if (a[i].lastmod == 0)
---
> 			if (a[i]->lastmod == 0)
85c87
< 			else if (a[i].lastmod == 1)
---
> 			else if (a[i]->lastmod == 1)
87c89
< 			else if (a[i].lastmod == 2)
---
> 			else if (a[i]->lastmod == 2)
93c95
< 				exit(1);
---
> 				bye(1); 
128c130
< 			if (a[i].lastmod == 0)
---
> 			if (*a[i]->lastmod == 0)
130c132
< 			if (a[i].lastmod == 1)
---
> 			if (*a[i]->lastmod == 1)
Index: parse.c
12c12
< #include <strings.h>
---
> #include <string.h>
Index: play.c
8a9,10
> #include <sys/types.h>
> #include <ctype.h>
13c15
< extern  cell	a[];
---
> extern  cell	*a[];
85c87
< 	temp = a[x].inst;
---
> 	temp = a[x]->inst;
117c119
< 		exit(1);
---
> 		bye(1);
Index: tokenize.c
15c15
< #include <strings.h>
---
> #include <string.h>
-- 
BANG: ..pyramid!tub!netmbx!xaos!felix	SMART: felix at xaos.sub
>In as much as a number of excellent hallucinogens already exist, I would not
>reccomend going to the trouble of extracting the adrenal gland from living
>humans.  I personally also have ethical problems with this procedure ....



More information about the Alt.sources mailing list