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