Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / games / larn / savelev.c
blobe4ea9ff1701688af9d12305a4038598a83a935c6
1 /* $NetBSD: savelev.c,v 1.5 2008/01/28 05:38:54 dholland Exp $ */
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.5 2008/01/28 05:38:54 dholland Exp $");
7 #endif /* not lint */
8 #include "header.h"
9 #include "extern.h"
12 * routine to save the present level into storage
14 void
15 savelevel()
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++;
41 * routine to restore a level from storage
43 void
44 getlevel()
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++;