Home | History | Annotate | Line # | Download | only in larn
savelev.c revision 1.6.26.1
      1  1.6.26.1      yamt /*	$NetBSD: savelev.c,v 1.6.26.1 2012/10/30 18:58:24 yamt Exp $	*/
      2       1.2   mycroft 
      3       1.1       cgd /* savelev.c		 Larn is copyrighted 1986 by Noah Morgan. */
      4       1.4  christos #include <sys/cdefs.h>
      5       1.4  christos #ifndef lint
      6  1.6.26.1      yamt __RCSID("$NetBSD: savelev.c,v 1.6.26.1 2012/10/30 18:58:24 yamt Exp $");
      7       1.4  christos #endif				/* not lint */
      8       1.1       cgd #include "header.h"
      9       1.4  christos #include "extern.h"
     10       1.1       cgd 
     11       1.1       cgd /*
     12       1.1       cgd  *	routine to save the present level into storage
     13       1.1       cgd  */
     14       1.4  christos void
     15  1.6.26.1      yamt savelevel(void)
     16       1.4  christos {
     17       1.4  christos 	struct cel *pcel;
     18       1.5  dholland 	u_char  *pitem, *pknow, *pmitem;
     19       1.4  christos 	short *phitp, *piarg;
     20       1.4  christos 	struct cel *pecel;
     21       1.4  christos 	pcel = &cell[level * MAXX * MAXY];	/* pointer to this level's
     22       1.4  christos 						 * cells */
     23       1.4  christos 	pecel = pcel + MAXX * MAXY;	/* pointer to past end of this
     24       1.4  christos 					 * level's cells */
     25       1.4  christos 	pitem = item[0];
     26       1.4  christos 	piarg = iarg[0];
     27       1.4  christos 	pknow = know[0];
     28       1.4  christos 	pmitem = mitem[0];
     29       1.4  christos 	phitp = hitp[0];
     30       1.4  christos 	while (pcel < pecel) {
     31       1.4  christos 		pcel->mitem = *pmitem++;
     32       1.4  christos 		pcel->hitp = *phitp++;
     33       1.4  christos 		pcel->item = *pitem++;
     34       1.4  christos 		pcel->know = *pknow++;
     35       1.6  dholland 		pcel->iarg = *piarg++;
     36       1.6  dholland 		pcel++;
     37       1.1       cgd 	}
     38       1.4  christos }
     39       1.1       cgd 
     40       1.1       cgd /*
     41       1.1       cgd  *	routine to restore a level from storage
     42       1.1       cgd  */
     43       1.4  christos void
     44  1.6.26.1      yamt getlevel(void)
     45       1.4  christos {
     46       1.4  christos 	struct cel *pcel;
     47       1.5  dholland 	u_char  *pitem, *pknow, *pmitem;
     48       1.4  christos 	short *phitp, *piarg;
     49       1.4  christos 	struct cel *pecel;
     50       1.4  christos 	pcel = &cell[level * MAXX * MAXY];	/* pointer to this level's
     51       1.4  christos 						 * cells */
     52       1.4  christos 	pecel = pcel + MAXX * MAXY;	/* pointer to past end of this
     53       1.4  christos 					 * level's cells */
     54       1.4  christos 	pitem = item[0];
     55       1.4  christos 	piarg = iarg[0];
     56       1.4  christos 	pknow = know[0];
     57       1.4  christos 	pmitem = mitem[0];
     58       1.4  christos 	phitp = hitp[0];
     59       1.4  christos 	while (pcel < pecel) {
     60       1.1       cgd 		*pmitem++ = pcel->mitem;
     61       1.1       cgd 		*phitp++ = pcel->hitp;
     62       1.1       cgd 		*pitem++ = pcel->item;
     63       1.1       cgd 		*pknow++ = pcel->know;
     64       1.6  dholland 		*piarg++ = pcel->iarg;
     65       1.6  dholland 		pcel++;
     66       1.1       cgd 	}
     67       1.4  christos }
     68