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