display.c revision 1.9 1 1.9 dholland /* $NetBSD: display.c,v 1.9 2009/08/12 08:04:05 dholland Exp $ */
2 1.4 christos
3 1.4 christos /* display.c Larn is copyrighted 1986 by Noah Morgan. */
4 1.4 christos #include <sys/cdefs.h>
5 1.2 mycroft #ifndef lint
6 1.9 dholland __RCSID("$NetBSD: display.c,v 1.9 2009/08/12 08:04:05 dholland Exp $");
7 1.2 mycroft #endif /* not lint */
8 1.2 mycroft
9 1.1 cgd #include "header.h"
10 1.4 christos #include "extern.h"
11 1.8 dholland
12 1.1 cgd #define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c))
13 1.1 cgd
14 1.8 dholland static void bot_hpx(void);
15 1.8 dholland static void bot_spellx(void);
16 1.8 dholland static void botside(void);
17 1.7 dholland static void botsub(int, const char *);
18 1.8 dholland static void seepage(void);
19 1.4 christos
20 1.4 christos static int minx, maxx, miny, maxy, k, m;
21 1.4 christos static char bot1f = 0, bot2f = 0, bot3f = 0;
22 1.9 dholland static char always = 0;
23 1.1 cgd /*
24 1.1 cgd bottomline()
25 1.1 cgd
26 1.1 cgd now for the bottom line of the display
27 1.1 cgd */
28 1.4 christos void
29 1.1 cgd bottomline()
30 1.4 christos {
31 1.4 christos recalc();
32 1.4 christos bot1f = 1;
33 1.4 christos }
34 1.4 christos
35 1.4 christos void
36 1.1 cgd bottomhp()
37 1.4 christos {
38 1.4 christos bot2f = 1;
39 1.4 christos }
40 1.4 christos
41 1.4 christos void
42 1.1 cgd bottomspell()
43 1.4 christos {
44 1.4 christos bot3f = 1;
45 1.4 christos }
46 1.4 christos
47 1.4 christos void
48 1.1 cgd bottomdo()
49 1.4 christos {
50 1.4 christos if (bot1f) {
51 1.4 christos bot3f = bot1f = bot2f = 0;
52 1.4 christos bot_linex();
53 1.4 christos return;
54 1.4 christos }
55 1.4 christos if (bot2f) {
56 1.4 christos bot2f = 0;
57 1.4 christos bot_hpx();
58 1.4 christos }
59 1.4 christos if (bot3f) {
60 1.4 christos bot3f = 0;
61 1.4 christos bot_spellx();
62 1.1 cgd }
63 1.4 christos }
64 1.1 cgd
65 1.4 christos void
66 1.1 cgd bot_linex()
67 1.4 christos {
68 1.4 christos int i;
69 1.4 christos if (cbak[SPELLS] <= -50 || (always)) {
70 1.4 christos cursor(1, 18);
71 1.4 christos if (c[SPELLMAX] > 99)
72 1.6 dholland lprintf("Spells:%3ld(%3ld)", (long) c[SPELLS], (long) c[SPELLMAX]);
73 1.4 christos else
74 1.6 dholland lprintf("Spells:%3ld(%2ld) ", (long) c[SPELLS], (long) c[SPELLMAX]);
75 1.6 dholland lprintf(" AC: %-3ld WC: %-3ld Level", (long) c[AC], (long) c[WCLASS]);
76 1.4 christos if (c[LEVEL] > 99)
77 1.6 dholland lprintf("%3ld", (long) c[LEVEL]);
78 1.4 christos else
79 1.6 dholland lprintf(" %-2ld", (long) c[LEVEL]);
80 1.6 dholland lprintf(" Exp: %-9ld %s\n", (long) c[EXPERIENCE], class[c[LEVEL] - 1]);
81 1.6 dholland lprintf("HP: %3ld(%3ld) STR=%-2ld INT=%-2ld ",
82 1.4 christos (long) c[HP], (long) c[HPMAX], (long) (c[STRENGTH] + c[STREXTRA]), (long) c[INTELLIGENCE]);
83 1.6 dholland lprintf("WIS=%-2ld CON=%-2ld DEX=%-2ld CHA=%-2ld LV:",
84 1.4 christos (long) c[WISDOM], (long) c[CONSTITUTION], (long) c[DEXTERITY], (long) c[CHARISMA]);
85 1.1 cgd
86 1.4 christos if ((level == 0) || (wizard))
87 1.4 christos c[TELEFLAG] = 0;
88 1.4 christos if (c[TELEFLAG])
89 1.4 christos lprcat(" ?");
90 1.4 christos else
91 1.4 christos lprcat(levelname[level]);
92 1.6 dholland lprintf(" Gold: %-6ld", (long) c[GOLD]);
93 1.4 christos always = 1;
94 1.4 christos botside();
95 1.4 christos c[TMP] = c[STRENGTH] + c[STREXTRA];
96 1.4 christos for (i = 0; i < 100; i++)
97 1.4 christos cbak[i] = c[i];
98 1.1 cgd return;
99 1.4 christos }
100 1.7 dholland botsub(makecode(SPELLS, 8, 18), "%3ld");
101 1.4 christos if (c[SPELLMAX] > 99)
102 1.7 dholland botsub(makecode(SPELLMAX, 12, 18), "%3ld)");
103 1.4 christos else
104 1.7 dholland botsub(makecode(SPELLMAX, 12, 18), "%2ld) ");
105 1.7 dholland botsub(makecode(HP, 5, 19), "%3ld");
106 1.7 dholland botsub(makecode(HPMAX, 9, 19), "%3ld");
107 1.7 dholland botsub(makecode(AC, 21, 18), "%-3ld");
108 1.7 dholland botsub(makecode(WCLASS, 30, 18), "%-3ld");
109 1.7 dholland botsub(makecode(EXPERIENCE, 49, 18), "%-9ld");
110 1.4 christos if (c[LEVEL] != cbak[LEVEL]) {
111 1.4 christos cursor(59, 18);
112 1.4 christos lprcat(class[c[LEVEL] - 1]);
113 1.4 christos }
114 1.4 christos if (c[LEVEL] > 99)
115 1.7 dholland botsub(makecode(LEVEL, 40, 18), "%3ld");
116 1.4 christos else
117 1.7 dholland botsub(makecode(LEVEL, 40, 18), " %-2ld");
118 1.4 christos c[TMP] = c[STRENGTH] + c[STREXTRA];
119 1.7 dholland botsub(makecode(TMP, 18, 19), "%-2ld");
120 1.7 dholland botsub(makecode(INTELLIGENCE, 25, 19), "%-2ld");
121 1.7 dholland botsub(makecode(WISDOM, 32, 19), "%-2ld");
122 1.7 dholland botsub(makecode(CONSTITUTION, 39, 19), "%-2ld");
123 1.7 dholland botsub(makecode(DEXTERITY, 46, 19), "%-2ld");
124 1.7 dholland botsub(makecode(CHARISMA, 53, 19), "%-2ld");
125 1.4 christos if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG])) {
126 1.4 christos if ((level == 0) || (wizard))
127 1.4 christos c[TELEFLAG] = 0;
128 1.1 cgd cbak[TELEFLAG] = c[TELEFLAG];
129 1.4 christos cbak[CAVELEVEL] = level;
130 1.4 christos cursor(59, 19);
131 1.4 christos if (c[TELEFLAG])
132 1.4 christos lprcat(" ?");
133 1.4 christos else
134 1.4 christos lprcat(levelname[level]);
135 1.4 christos }
136 1.7 dholland botsub(makecode(GOLD, 69, 19), "%-6ld");
137 1.1 cgd botside();
138 1.4 christos }
139 1.1 cgd
140 1.1 cgd /*
141 1.1 cgd special subroutine to update only the gold number on the bottomlines
142 1.1 cgd called from ogold()
143 1.1 cgd */
144 1.4 christos void
145 1.1 cgd bottomgold()
146 1.4 christos {
147 1.7 dholland botsub(makecode(GOLD, 69, 19), "%-6ld");
148 1.7 dholland /* botsub(GOLD,"%-6ld",69,19); */
149 1.4 christos }
150 1.1 cgd
151 1.1 cgd /*
152 1.1 cgd special routine to update hp and level fields on bottom lines
153 1.1 cgd called in monster.c hitplayer() and spattack()
154 1.1 cgd */
155 1.8 dholland static void
156 1.8 dholland bot_hpx(void)
157 1.4 christos {
158 1.4 christos if (c[EXPERIENCE] != cbak[EXPERIENCE]) {
159 1.4 christos recalc();
160 1.4 christos bot_linex();
161 1.4 christos } else
162 1.7 dholland botsub(makecode(HP, 5, 19), "%3ld");
163 1.4 christos }
164 1.1 cgd
165 1.1 cgd /*
166 1.1 cgd special routine to update number of spells called from regen()
167 1.1 cgd */
168 1.8 dholland static void
169 1.8 dholland bot_spellx(void)
170 1.4 christos {
171 1.7 dholland botsub(makecode(SPELLS, 9, 18), "%2ld");
172 1.4 christos }
173 1.1 cgd
174 1.1 cgd /*
175 1.1 cgd common subroutine for a more economical bottomline()
176 1.1 cgd */
177 1.4 christos static struct bot_side_def {
178 1.4 christos int typ;
179 1.7 dholland const char *string;
180 1.4 christos }
181 1.4 christos bot_data[] =
182 1.4 christos {
183 1.4 christos { STEALTH, "stealth"},
184 1.4 christos { UNDEADPRO, "undead pro" },
185 1.4 christos { SPIRITPRO, "spirit pro" },
186 1.4 christos { CHARMCOUNT, "Charm"},
187 1.4 christos { TIMESTOP, "Time Stop" },
188 1.4 christos { HOLDMONST, "Hold Monst" },
189 1.4 christos { GIANTSTR, "Giant Str"},
190 1.4 christos { FIRERESISTANCE, "Fire Resit" },
191 1.4 christos { DEXCOUNT, "Dexterity" },
192 1.4 christos { STRCOUNT, "Strength"},
193 1.4 christos { SCAREMONST, "Scare" },
194 1.4 christos { HASTESELF, "Haste Self" },
195 1.4 christos { CANCELLATION, "Cancel"},
196 1.4 christos { INVISIBILITY, "Invisible" },
197 1.4 christos { ALTPRO, "Protect 3" },
198 1.4 christos { PROTECTIONTIME, "Protect 2"},
199 1.4 christos { WTW, "Wall-Walk" }
200 1.4 christos };
201 1.1 cgd
202 1.8 dholland static void
203 1.8 dholland botside(void)
204 1.4 christos {
205 1.4 christos int i, idx;
206 1.4 christos for (i = 0; i < 17; i++) {
207 1.1 cgd idx = bot_data[i].typ;
208 1.4 christos if ((always) || (c[idx] != cbak[idx])) {
209 1.4 christos if ((always) || (cbak[idx] == 0)) {
210 1.4 christos if (c[idx]) {
211 1.4 christos cursor(70, i + 1);
212 1.4 christos lprcat(bot_data[i].string);
213 1.4 christos }
214 1.4 christos } else if (c[idx] == 0) {
215 1.4 christos cursor(70, i + 1);
216 1.4 christos lprcat(" ");
217 1.4 christos }
218 1.4 christos cbak[idx] = c[idx];
219 1.1 cgd }
220 1.1 cgd }
221 1.4 christos always = 0;
222 1.4 christos }
223 1.1 cgd
224 1.1 cgd static void
225 1.7 dholland botsub(int idx, const char *str)
226 1.4 christos {
227 1.4 christos int x, y;
228 1.4 christos y = idx & 0xff;
229 1.4 christos x = (idx >> 8) & 0xff;
230 1.4 christos idx >>= 16;
231 1.4 christos if (c[idx] != cbak[idx]) {
232 1.4 christos cbak[idx] = c[idx];
233 1.4 christos cursor(x, y);
234 1.4 christos lprintf(str, (long) c[idx]);
235 1.1 cgd }
236 1.4 christos }
237 1.1 cgd
238 1.1 cgd /*
239 1.1 cgd * subroutine to draw only a section of the screen
240 1.4 christos * only the top section of the screen is updated.
241 1.4 christos * If entire lines are being drawn, then they will be cleared first.
242 1.1 cgd */
243 1.4 christos /* for limited screen drawing */
244 1.9 dholland static int d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY;
245 1.4 christos
246 1.4 christos void
247 1.4 christos draws(xmin, xmax, ymin, ymax)
248 1.4 christos int xmin, xmax, ymin, ymax;
249 1.4 christos {
250 1.4 christos int i, idx;
251 1.4 christos if (xmin == 0 && xmax == MAXX) { /* clear section of screen as
252 1.4 christos * needed */
253 1.4 christos if (ymin == 0)
254 1.4 christos cl_up(79, ymax);
255 1.4 christos else
256 1.4 christos for (i = ymin; i < ymin; i++)
257 1.4 christos cl_line(1, i + 1);
258 1.1 cgd xmin = -1;
259 1.4 christos }
260 1.4 christos d_xmin = xmin;
261 1.4 christos d_xmax = xmax;
262 1.4 christos d_ymin = ymin;
263 1.4 christos d_ymax = ymax; /* for limited screen drawing */
264 1.1 cgd drawscreen();
265 1.4 christos if (xmin <= 0 && xmax == MAXX) { /* draw stuff on right side
266 1.4 christos * of screen as needed */
267 1.4 christos for (i = ymin; i < ymax; i++) {
268 1.1 cgd idx = bot_data[i].typ;
269 1.4 christos if (c[idx]) {
270 1.4 christos cursor(70, i + 1);
271 1.4 christos lprcat(bot_data[i].string);
272 1.1 cgd }
273 1.4 christos cbak[idx] = c[idx];
274 1.1 cgd }
275 1.1 cgd }
276 1.4 christos }
277 1.1 cgd
278 1.1 cgd /*
279 1.1 cgd drawscreen()
280 1.1 cgd
281 1.1 cgd subroutine to redraw the whole screen as the player knows it
282 1.1 cgd */
283 1.9 dholland u_char screen[MAXX][MAXY]; /* template for the screen */
284 1.9 dholland static u_char d_flag;
285 1.4 christos void
286 1.1 cgd drawscreen()
287 1.4 christos {
288 1.7 dholland int i, j, kk;
289 1.4 christos int lastx, lasty; /* variables used to optimize the
290 1.4 christos * object printing */
291 1.4 christos if (d_xmin == 0 && d_xmax == MAXX && d_ymin == 0 && d_ymax == MAXY) {
292 1.4 christos d_flag = 1;
293 1.4 christos clear(); /* clear the screen */
294 1.4 christos } else {
295 1.4 christos d_flag = 0;
296 1.4 christos cursor(1, 1);
297 1.4 christos }
298 1.4 christos if (d_xmin < 0)
299 1.4 christos d_xmin = 0; /* d_xmin=-1 means display all without
300 1.4 christos * bottomline */
301 1.4 christos
302 1.4 christos for (i = d_ymin; i < d_ymax; i++)
303 1.4 christos for (j = d_xmin; j < d_xmax; j++)
304 1.4 christos if (know[j][i] == 0)
305 1.4 christos screen[j][i] = ' ';
306 1.7 dholland else if ((kk = mitem[j][i]) != 0)
307 1.7 dholland screen[j][i] = monstnamelist[kk];
308 1.7 dholland else if ((kk = item[j][i]) == OWALL)
309 1.4 christos screen[j][i] = '#';
310 1.4 christos else
311 1.4 christos screen[j][i] = ' ';
312 1.4 christos
313 1.4 christos for (i = d_ymin; i < d_ymax; i++) {
314 1.4 christos j = d_xmin;
315 1.4 christos while ((screen[j][i] == ' ') && (j < d_xmax))
316 1.4 christos j++;
317 1.1 cgd /* was m=0 */
318 1.4 christos if (j >= d_xmax)
319 1.4 christos m = d_xmin; /* don't search backwards if blank
320 1.4 christos * line */
321 1.4 christos else { /* search backwards for end of line */
322 1.4 christos m = d_xmax - 1;
323 1.4 christos while ((screen[m][i] == ' ') && (m > d_xmin))
324 1.4 christos --m;
325 1.4 christos if (j <= m)
326 1.4 christos cursor(j + 1, i + 1);
327 1.4 christos else
328 1.4 christos continue;
329 1.4 christos }
330 1.4 christos while (j <= m) {
331 1.4 christos if (j <= m - 3) {
332 1.7 dholland for (kk = j; kk <= j + 3; kk++)
333 1.7 dholland if (screen[kk][i] != ' ')
334 1.7 dholland kk = 1000;
335 1.7 dholland if (kk < 1000) {
336 1.4 christos while (screen[j][i] == ' ' && j <= m)
337 1.4 christos j++;
338 1.4 christos cursor(j + 1, i + 1);
339 1.4 christos }
340 1.1 cgd }
341 1.1 cgd lprc(screen[j++][i]);
342 1.1 cgd }
343 1.4 christos }
344 1.1 cgd setbold(); /* print out only bold objects now */
345 1.1 cgd
346 1.4 christos for (lastx = lasty = 127, i = d_ymin; i < d_ymax; i++)
347 1.4 christos for (j = d_xmin; j < d_xmax; j++) {
348 1.7 dholland if ((kk = item[j][i]) != 0)
349 1.7 dholland if (kk != OWALL)
350 1.4 christos if ((know[j][i]) && (mitem[j][i] == 0))
351 1.7 dholland if (objnamelist[kk] != ' ') {
352 1.4 christos if (lasty != i + 1 || lastx != j)
353 1.4 christos cursor(lastx = j + 1, lasty = i + 1);
354 1.4 christos else
355 1.4 christos lastx++;
356 1.7 dholland lprc(objnamelist[kk]);
357 1.4 christos }
358 1.4 christos }
359 1.4 christos
360 1.4 christos resetbold();
361 1.4 christos if (d_flag) {
362 1.4 christos always = 1;
363 1.4 christos botside();
364 1.4 christos always = 1;
365 1.4 christos bot_linex();
366 1.4 christos }
367 1.4 christos oldx = 99;
368 1.4 christos d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY; /* for limited screen
369 1.4 christos * drawing */
370 1.4 christos }
371 1.4 christos
372 1.1 cgd
373 1.1 cgd /*
374 1.1 cgd showcell(x,y)
375 1.1 cgd
376 1.1 cgd subroutine to display a cell location on the screen
377 1.1 cgd */
378 1.4 christos void
379 1.4 christos showcell(x, y)
380 1.4 christos int x, y;
381 1.4 christos {
382 1.7 dholland int i, j, kk, mm;
383 1.4 christos if (c[BLINDCOUNT])
384 1.4 christos return; /* see nothing if blind */
385 1.4 christos if (c[AWARENESS]) {
386 1.4 christos minx = x - 3;
387 1.4 christos maxx = x + 3;
388 1.4 christos miny = y - 3;
389 1.4 christos maxy = y + 3;
390 1.4 christos } else {
391 1.4 christos minx = x - 1;
392 1.4 christos maxx = x + 1;
393 1.4 christos miny = y - 1;
394 1.4 christos maxy = y + 1;
395 1.4 christos }
396 1.4 christos
397 1.4 christos if (minx < 0)
398 1.4 christos minx = 0;
399 1.4 christos if (maxx > MAXX - 1)
400 1.4 christos maxx = MAXX - 1;
401 1.4 christos if (miny < 0)
402 1.4 christos miny = 0;
403 1.4 christos if (maxy > MAXY - 1)
404 1.4 christos maxy = MAXY - 1;
405 1.4 christos
406 1.4 christos for (j = miny; j <= maxy; j++)
407 1.7 dholland for (mm = minx; mm <= maxx; mm++)
408 1.7 dholland if (know[mm][j] == 0) {
409 1.7 dholland cursor(mm + 1, j + 1);
410 1.4 christos x = maxx;
411 1.4 christos while (know[x][j])
412 1.4 christos --x;
413 1.7 dholland for (i = mm; i <= x; i++) {
414 1.7 dholland if ((kk = mitem[i][j]) != 0)
415 1.7 dholland lprc(monstnamelist[kk]);
416 1.4 christos else
417 1.7 dholland switch (kk = item[i][j]) {
418 1.4 christos case OWALL:
419 1.4 christos case 0:
420 1.4 christos case OIVTELETRAP:
421 1.4 christos case OTRAPARROWIV:
422 1.4 christos case OIVDARTRAP:
423 1.4 christos case OIVTRAPDOOR:
424 1.7 dholland lprc(objnamelist[kk]);
425 1.4 christos break;
426 1.4 christos
427 1.4 christos default:
428 1.4 christos setbold();
429 1.7 dholland lprc(objnamelist[kk]);
430 1.4 christos resetbold();
431 1.4 christos };
432 1.4 christos know[i][j] = 1;
433 1.1 cgd }
434 1.7 dholland mm = maxx;
435 1.1 cgd }
436 1.4 christos }
437 1.1 cgd
438 1.1 cgd /*
439 1.1 cgd this routine shows only the spot that is given it. the spaces around
440 1.1 cgd these coordinated are not shown
441 1.1 cgd used in godirect() in monster.c for missile weapons display
442 1.1 cgd */
443 1.4 christos void
444 1.4 christos show1cell(x, y)
445 1.4 christos int x, y;
446 1.4 christos {
447 1.4 christos if (c[BLINDCOUNT])
448 1.4 christos return; /* see nothing if blind */
449 1.4 christos cursor(x + 1, y + 1);
450 1.4 christos if ((k = mitem[x][y]) != 0)
451 1.4 christos lprc(monstnamelist[k]);
452 1.4 christos else
453 1.4 christos switch (k = item[x][y]) {
454 1.4 christos case OWALL:
455 1.4 christos case 0:
456 1.4 christos case OIVTELETRAP:
457 1.4 christos case OTRAPARROWIV:
458 1.4 christos case OIVDARTRAP:
459 1.4 christos case OIVTRAPDOOR:
460 1.4 christos lprc(objnamelist[k]);
461 1.4 christos break;
462 1.4 christos
463 1.4 christos default:
464 1.4 christos setbold();
465 1.4 christos lprc(objnamelist[k]);
466 1.4 christos resetbold();
467 1.4 christos };
468 1.4 christos know[x][y] |= 1; /* we end up knowing about it */
469 1.4 christos }
470 1.1 cgd
471 1.1 cgd /*
472 1.1 cgd showplayer()
473 1.1 cgd
474 1.1 cgd subroutine to show where the player is on the screen
475 1.1 cgd cursor values start from 1 up
476 1.1 cgd */
477 1.4 christos void
478 1.1 cgd showplayer()
479 1.4 christos {
480 1.4 christos cursor(playerx + 1, playery + 1);
481 1.4 christos oldx = playerx;
482 1.4 christos oldy = playery;
483 1.4 christos }
484 1.1 cgd
485 1.1 cgd /*
486 1.1 cgd moveplayer(dir)
487 1.1 cgd
488 1.1 cgd subroutine to move the player from one room to another
489 1.1 cgd returns 0 if can't move in that direction or hit a monster or on an object
490 1.1 cgd else returns 1
491 1.1 cgd nomove is set to 1 to stop the next move (inadvertent monsters hitting
492 1.1 cgd players when walking into walls) if player walks off screen or into wall
493 1.1 cgd */
494 1.4 christos short diroffx[] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
495 1.4 christos short diroffy[] = {0, 1, 0, -1, 0, -1, -1, 1, 1};
496 1.4 christos int
497 1.1 cgd moveplayer(dir)
498 1.4 christos int dir; /* from = present room # direction =
499 1.4 christos * [1-north] [2-east] [3-south] [4-west]
500 1.4 christos * [5-northeast] [6-northwest] [7-southeast]
501 1.4 christos * [8-southwest] if direction=0, don't
502 1.4 christos * move--just show where he is */
503 1.4 christos {
504 1.7 dholland int kk, mm, i, j;
505 1.4 christos if (c[CONFUSE])
506 1.4 christos if (c[LEVEL] < rnd(30))
507 1.4 christos dir = rund(9); /* if confused any dir */
508 1.7 dholland kk = playerx + diroffx[dir];
509 1.7 dholland mm = playery + diroffy[dir];
510 1.7 dholland if (kk < 0 || kk >= MAXX || mm < 0 || mm >= MAXY) {
511 1.4 christos nomove = 1;
512 1.4 christos return (yrepcount = 0);
513 1.4 christos }
514 1.7 dholland i = item[kk][mm];
515 1.7 dholland j = mitem[kk][mm];
516 1.4 christos if (i == OWALL && c[WTW] == 0) {
517 1.4 christos nomove = 1;
518 1.4 christos return (yrepcount = 0);
519 1.4 christos } /* hit a wall */
520 1.7 dholland if (kk == 33 && mm == MAXY - 1 && level == 1) {
521 1.4 christos newcavelevel(0);
522 1.7 dholland for (kk = 0; kk < MAXX; kk++)
523 1.7 dholland for (mm = 0; mm < MAXY; mm++)
524 1.7 dholland if (item[kk][mm] == OENTRANCE) {
525 1.7 dholland playerx = kk;
526 1.7 dholland playery = mm;
527 1.4 christos positionplayer();
528 1.4 christos drawscreen();
529 1.4 christos return (0);
530 1.4 christos }
531 1.1 cgd }
532 1.4 christos if (j > 0) {
533 1.7 dholland hitmonster(kk, mm);
534 1.4 christos return (yrepcount = 0);
535 1.4 christos } /* hit a monster */
536 1.4 christos lastpx = playerx;
537 1.4 christos lastpy = playery;
538 1.7 dholland playerx = kk;
539 1.7 dholland playery = mm;
540 1.4 christos if (i && i != OTRAPARROWIV && i != OIVTELETRAP && i != OIVDARTRAP && i != OIVTRAPDOOR)
541 1.4 christos return (yrepcount = 0);
542 1.4 christos else
543 1.4 christos return (1);
544 1.4 christos }
545 1.4 christos
546 1.4 christos
547 1.1 cgd /*
548 1.1 cgd * function to show what magic items have been discovered thus far
549 1.1 cgd * enter with -1 for just spells, anything else will give scrolls & potions
550 1.1 cgd */
551 1.4 christos static int lincount, count;
552 1.4 christos void
553 1.1 cgd seemagic(arg)
554 1.4 christos int arg;
555 1.4 christos {
556 1.4 christos int i, number = 0;
557 1.4 christos count = lincount = 0;
558 1.4 christos nosignal = 1;
559 1.4 christos
560 1.4 christos if (arg == -1) { /* if display spells while casting one */
561 1.4 christos for (number = i = 0; i < SPNUM; i++)
562 1.4 christos if (spelknow[i])
563 1.4 christos number++;
564 1.4 christos number = (number + 2) / 3 + 4; /* # lines needed to display */
565 1.4 christos cl_up(79, number);
566 1.4 christos cursor(1, 1);
567 1.4 christos } else {
568 1.4 christos resetscroll();
569 1.4 christos clear();
570 1.4 christos }
571 1.1 cgd
572 1.1 cgd lprcat("The magic spells you have discovered thus far:\n\n");
573 1.4 christos for (i = 0; i < SPNUM; i++)
574 1.4 christos if (spelknow[i]) {
575 1.4 christos lprintf("%s %-20s ", spelcode[i], spelname[i]);
576 1.4 christos seepage();
577 1.4 christos }
578 1.4 christos if (arg == -1) {
579 1.4 christos seepage();
580 1.4 christos more();
581 1.4 christos nosignal = 0;
582 1.4 christos draws(0, MAXX, 0, number);
583 1.4 christos return;
584 1.4 christos }
585 1.4 christos lincount += 3;
586 1.4 christos if (count != 0) {
587 1.4 christos count = 2;
588 1.4 christos seepage();
589 1.4 christos }
590 1.1 cgd lprcat("\nThe magic scrolls you have found to date are:\n\n");
591 1.4 christos count = 0;
592 1.4 christos for (i = 0; i < MAXSCROLL; i++)
593 1.1 cgd if (scrollname[i][0])
594 1.4 christos if (scrollname[i][1] != ' ') {
595 1.4 christos lprintf("%-26s", &scrollname[i][1]);
596 1.4 christos seepage();
597 1.4 christos }
598 1.4 christos lincount += 3;
599 1.4 christos if (count != 0) {
600 1.4 christos count = 2;
601 1.4 christos seepage();
602 1.4 christos }
603 1.1 cgd lprcat("\nThe magic potions you have found to date are:\n\n");
604 1.4 christos count = 0;
605 1.4 christos for (i = 0; i < MAXPOTION; i++)
606 1.1 cgd if (potionname[i][0])
607 1.4 christos if (potionname[i][1] != ' ') {
608 1.4 christos lprintf("%-26s", &potionname[i][1]);
609 1.4 christos seepage();
610 1.4 christos }
611 1.4 christos if (lincount != 0)
612 1.4 christos more();
613 1.4 christos nosignal = 0;
614 1.4 christos setscroll();
615 1.4 christos drawscreen();
616 1.4 christos }
617 1.1 cgd
618 1.1 cgd /*
619 1.1 cgd * subroutine to paginate the seemagic function
620 1.1 cgd */
621 1.8 dholland static void
622 1.8 dholland seepage(void)
623 1.4 christos {
624 1.4 christos if (++count == 3) {
625 1.4 christos lincount++;
626 1.4 christos count = 0;
627 1.4 christos lprc('\n');
628 1.4 christos if (lincount > 17) {
629 1.4 christos lincount = 0;
630 1.4 christos more();
631 1.4 christos clear();
632 1.1 cgd }
633 1.1 cgd }
634 1.4 christos }
635