xref: /csrg-svn/games/larn/savelev.c (revision 36997)
1*36997Sbostic /* savelev.c		 Larn is copyrighted 1986 by Noah Morgan. */
2*36997Sbostic #include "header.h"
3*36997Sbostic extern struct cel *cell;
4*36997Sbostic 
5*36997Sbostic /*
6*36997Sbostic  *	routine to save the present level into storage
7*36997Sbostic  */
savelevel()8*36997Sbostic savelevel()
9*36997Sbostic 	{
10*36997Sbostic 	register struct cel *pcel;
11*36997Sbostic 	register char *pitem,*pknow,*pmitem;
12*36997Sbostic 	register short *phitp,*piarg;
13*36997Sbostic 	register struct cel *pecel;
14*36997Sbostic 	pcel = &cell[level*MAXX*MAXY];	/* pointer to this level's cells */
15*36997Sbostic 	pecel = pcel + MAXX*MAXY;	/* pointer to past end of this level's cells */
16*36997Sbostic 	pitem=item[0]; piarg=iarg[0]; pknow=know[0]; pmitem=mitem[0]; phitp=hitp[0];
17*36997Sbostic 	while (pcel < pecel)
18*36997Sbostic 		{
19*36997Sbostic 		pcel->mitem  = *pmitem++;
20*36997Sbostic 		pcel->hitp   = *phitp++;
21*36997Sbostic 		pcel->item   = *pitem++;
22*36997Sbostic 		pcel->know   = *pknow++;
23*36997Sbostic 		pcel++->iarg = *piarg++;
24*36997Sbostic 		}
25*36997Sbostic 	}
26*36997Sbostic 
27*36997Sbostic /*
28*36997Sbostic  *	routine to restore a level from storage
29*36997Sbostic  */
getlevel()30*36997Sbostic getlevel()
31*36997Sbostic 	{
32*36997Sbostic 	register struct cel *pcel;
33*36997Sbostic 	register char *pitem,*pknow,*pmitem;
34*36997Sbostic 	register short *phitp,*piarg;
35*36997Sbostic 	register struct cel *pecel;
36*36997Sbostic 	pcel = &cell[level*MAXX*MAXY];	/* pointer to this level's cells */
37*36997Sbostic 	pecel = pcel + MAXX*MAXY;	/* pointer to past end of this level's cells */
38*36997Sbostic 	pitem=item[0]; piarg=iarg[0]; pknow=know[0]; pmitem=mitem[0]; phitp=hitp[0];
39*36997Sbostic 	while (pcel < pecel)
40*36997Sbostic 		{
41*36997Sbostic 		*pmitem++ = pcel->mitem;
42*36997Sbostic 		*phitp++ = pcel->hitp;
43*36997Sbostic 		*pitem++ = pcel->item;
44*36997Sbostic 		*pknow++ = pcel->know;
45*36997Sbostic 		*piarg++ = pcel++->iarg;
46*36997Sbostic 		}
47*36997Sbostic 	}
48