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