display.c revision 1.8 1 1.8 dholland /* $NetBSD: display.c,v 1.8 2008/02/03 19:20:41 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.8 dholland __RCSID("$NetBSD: display.c,v 1.8 2008/02/03 19:20:41 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.4 christos 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.4 christos 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.4 christos u_char screen[MAXX][MAXY], d_flag; /* template for the screen */
284 1.4 christos void
285 1.1 cgd drawscreen()
286 1.4 christos {
287 1.7 dholland int i, j, kk;
288 1.4 christos int lastx, lasty; /* variables used to optimize the
289 1.4 christos * object printing */
290 1.4 christos if (d_xmin == 0 && d_xmax == MAXX && d_ymin == 0 && d_ymax == MAXY) {
291 1.4 christos d_flag = 1;
292 1.4 christos clear(); /* clear the screen */
293 1.4 christos } else {
294 1.4 christos d_flag = 0;
295 1.4 christos cursor(1, 1);
296 1.4 christos }
297 1.4 christos if (d_xmin < 0)
298 1.4 christos d_xmin = 0; /* d_xmin=-1 means display all without
299 1.4 christos * bottomline */
300 1.4 christos
301 1.4 christos for (i = d_ymin; i < d_ymax; i++)
302 1.4 christos for (j = d_xmin; j < d_xmax; j++)
303 1.4 christos if (know[j][i] == 0)
304 1.4 christos screen[j][i] = ' ';
305 1.7 dholland else if ((kk = mitem[j][i]) != 0)
306 1.7 dholland screen[j][i] = monstnamelist[kk];
307 1.7 dholland else if ((kk = item[j][i]) == OWALL)
308 1.4 christos screen[j][i] = '#';
309 1.4 christos else
310 1.4 christos screen[j][i] = ' ';
311 1.4 christos
312 1.4 christos for (i = d_ymin; i < d_ymax; i++) {
313 1.4 christos j = d_xmin;
314 1.4 christos while ((screen[j][i] == ' ') && (j < d_xmax))
315 1.4 christos j++;
316 1.1 cgd /* was m=0 */
317 1.4 christos if (j >= d_xmax)
318 1.4 christos m = d_xmin; /* don't search backwards if blank
319 1.4 christos * line */
320 1.4 christos else { /* search backwards for end of line */
321 1.4 christos m = d_xmax - 1;
322 1.4 christos while ((screen[m][i] == ' ') && (m > d_xmin))
323 1.4 christos --m;
324 1.4 christos if (j <= m)
325 1.4 christos cursor(j + 1, i + 1);
326 1.4 christos else
327 1.4 christos continue;
328 1.4 christos }
329 1.4 christos while (j <= m) {
330 1.4 christos if (j <= m - 3) {
331 1.7 dholland for (kk = j; kk <= j + 3; kk++)
332 1.7 dholland if (screen[kk][i] != ' ')
333 1.7 dholland kk = 1000;
334 1.7 dholland if (kk < 1000) {
335 1.4 christos while (screen[j][i] == ' ' && j <= m)
336 1.4 christos j++;
337 1.4 christos cursor(j + 1, i + 1);
338 1.4 christos }
339 1.1 cgd }
340 1.1 cgd lprc(screen[j++][i]);
341 1.1 cgd }
342 1.4 christos }
343 1.1 cgd setbold(); /* print out only bold objects now */
344 1.1 cgd
345 1.4 christos for (lastx = lasty = 127, i = d_ymin; i < d_ymax; i++)
346 1.4 christos for (j = d_xmin; j < d_xmax; j++) {
347 1.7 dholland if ((kk = item[j][i]) != 0)
348 1.7 dholland if (kk != OWALL)
349 1.4 christos if ((know[j][i]) && (mitem[j][i] == 0))
350 1.7 dholland if (objnamelist[kk] != ' ') {
351 1.4 christos if (lasty != i + 1 || lastx != j)
352 1.4 christos cursor(lastx = j + 1, lasty = i + 1);
353 1.4 christos else
354 1.4 christos lastx++;
355 1.7 dholland lprc(objnamelist[kk]);
356 1.4 christos }
357 1.4 christos }
358 1.4 christos
359 1.4 christos resetbold();
360 1.4 christos if (d_flag) {
361 1.4 christos always = 1;
362 1.4 christos botside();
363 1.4 christos always = 1;
364 1.4 christos bot_linex();
365 1.4 christos }
366 1.4 christos oldx = 99;
367 1.4 christos d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY; /* for limited screen
368 1.4 christos * drawing */
369 1.4 christos }
370 1.4 christos
371 1.1 cgd
372 1.1 cgd /*
373 1.1 cgd showcell(x,y)
374 1.1 cgd
375 1.1 cgd subroutine to display a cell location on the screen
376 1.1 cgd */
377 1.4 christos void
378 1.4 christos showcell(x, y)
379 1.4 christos int x, y;
380 1.4 christos {
381 1.7 dholland int i, j, kk, mm;
382 1.4 christos if (c[BLINDCOUNT])
383 1.4 christos return; /* see nothing if blind */
384 1.4 christos if (c[AWARENESS]) {
385 1.4 christos minx = x - 3;
386 1.4 christos maxx = x + 3;
387 1.4 christos miny = y - 3;
388 1.4 christos maxy = y + 3;
389 1.4 christos } else {
390 1.4 christos minx = x - 1;
391 1.4 christos maxx = x + 1;
392 1.4 christos miny = y - 1;
393 1.4 christos maxy = y + 1;
394 1.4 christos }
395 1.4 christos
396 1.4 christos if (minx < 0)
397 1.4 christos minx = 0;
398 1.4 christos if (maxx > MAXX - 1)
399 1.4 christos maxx = MAXX - 1;
400 1.4 christos if (miny < 0)
401 1.4 christos miny = 0;
402 1.4 christos if (maxy > MAXY - 1)
403 1.4 christos maxy = MAXY - 1;
404 1.4 christos
405 1.4 christos for (j = miny; j <= maxy; j++)
406 1.7 dholland for (mm = minx; mm <= maxx; mm++)
407 1.7 dholland if (know[mm][j] == 0) {
408 1.7 dholland cursor(mm + 1, j + 1);
409 1.4 christos x = maxx;
410 1.4 christos while (know[x][j])
411 1.4 christos --x;
412 1.7 dholland for (i = mm; i <= x; i++) {
413 1.7 dholland if ((kk = mitem[i][j]) != 0)
414 1.7 dholland lprc(monstnamelist[kk]);
415 1.4 christos else
416 1.7 dholland switch (kk = item[i][j]) {
417 1.4 christos case OWALL:
418 1.4 christos case 0:
419 1.4 christos case OIVTELETRAP:
420 1.4 christos case OTRAPARROWIV:
421 1.4 christos case OIVDARTRAP:
422 1.4 christos case OIVTRAPDOOR:
423 1.7 dholland lprc(objnamelist[kk]);
424 1.4 christos break;
425 1.4 christos
426 1.4 christos default:
427 1.4 christos setbold();
428 1.7 dholland lprc(objnamelist[kk]);
429 1.4 christos resetbold();
430 1.4 christos };
431 1.4 christos know[i][j] = 1;
432 1.1 cgd }
433 1.7 dholland mm = maxx;
434 1.1 cgd }
435 1.4 christos }
436 1.1 cgd
437 1.1 cgd /*
438 1.1 cgd this routine shows only the spot that is given it. the spaces around
439 1.1 cgd these coordinated are not shown
440 1.1 cgd used in godirect() in monster.c for missile weapons display
441 1.1 cgd */
442 1.4 christos void
443 1.4 christos show1cell(x, y)
444 1.4 christos int x, y;
445 1.4 christos {
446 1.4 christos if (c[BLINDCOUNT])
447 1.4 christos return; /* see nothing if blind */
448 1.4 christos cursor(x + 1, y + 1);
449 1.4 christos if ((k = mitem[x][y]) != 0)
450 1.4 christos lprc(monstnamelist[k]);
451 1.4 christos else
452 1.4 christos switch (k = item[x][y]) {
453 1.4 christos case OWALL:
454 1.4 christos case 0:
455 1.4 christos case OIVTELETRAP:
456 1.4 christos case OTRAPARROWIV:
457 1.4 christos case OIVDARTRAP:
458 1.4 christos case OIVTRAPDOOR:
459 1.4 christos lprc(objnamelist[k]);
460 1.4 christos break;
461 1.4 christos
462 1.4 christos default:
463 1.4 christos setbold();
464 1.4 christos lprc(objnamelist[k]);
465 1.4 christos resetbold();
466 1.4 christos };
467 1.4 christos know[x][y] |= 1; /* we end up knowing about it */
468 1.4 christos }
469 1.1 cgd
470 1.1 cgd /*
471 1.1 cgd showplayer()
472 1.1 cgd
473 1.1 cgd subroutine to show where the player is on the screen
474 1.1 cgd cursor values start from 1 up
475 1.1 cgd */
476 1.4 christos void
477 1.1 cgd showplayer()
478 1.4 christos {
479 1.4 christos cursor(playerx + 1, playery + 1);
480 1.4 christos oldx = playerx;
481 1.4 christos oldy = playery;
482 1.4 christos }
483 1.1 cgd
484 1.1 cgd /*
485 1.1 cgd moveplayer(dir)
486 1.1 cgd
487 1.1 cgd subroutine to move the player from one room to another
488 1.1 cgd returns 0 if can't move in that direction or hit a monster or on an object
489 1.1 cgd else returns 1
490 1.1 cgd nomove is set to 1 to stop the next move (inadvertent monsters hitting
491 1.1 cgd players when walking into walls) if player walks off screen or into wall
492 1.1 cgd */
493 1.4 christos short diroffx[] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
494 1.4 christos short diroffy[] = {0, 1, 0, -1, 0, -1, -1, 1, 1};
495 1.4 christos int
496 1.1 cgd moveplayer(dir)
497 1.4 christos int dir; /* from = present room # direction =
498 1.4 christos * [1-north] [2-east] [3-south] [4-west]
499 1.4 christos * [5-northeast] [6-northwest] [7-southeast]
500 1.4 christos * [8-southwest] if direction=0, don't
501 1.4 christos * move--just show where he is */
502 1.4 christos {
503 1.7 dholland int kk, mm, i, j;
504 1.4 christos if (c[CONFUSE])
505 1.4 christos if (c[LEVEL] < rnd(30))
506 1.4 christos dir = rund(9); /* if confused any dir */
507 1.7 dholland kk = playerx + diroffx[dir];
508 1.7 dholland mm = playery + diroffy[dir];
509 1.7 dholland if (kk < 0 || kk >= MAXX || mm < 0 || mm >= MAXY) {
510 1.4 christos nomove = 1;
511 1.4 christos return (yrepcount = 0);
512 1.4 christos }
513 1.7 dholland i = item[kk][mm];
514 1.7 dholland j = mitem[kk][mm];
515 1.4 christos if (i == OWALL && c[WTW] == 0) {
516 1.4 christos nomove = 1;
517 1.4 christos return (yrepcount = 0);
518 1.4 christos } /* hit a wall */
519 1.7 dholland if (kk == 33 && mm == MAXY - 1 && level == 1) {
520 1.4 christos newcavelevel(0);
521 1.7 dholland for (kk = 0; kk < MAXX; kk++)
522 1.7 dholland for (mm = 0; mm < MAXY; mm++)
523 1.7 dholland if (item[kk][mm] == OENTRANCE) {
524 1.7 dholland playerx = kk;
525 1.7 dholland playery = mm;
526 1.4 christos positionplayer();
527 1.4 christos drawscreen();
528 1.4 christos return (0);
529 1.4 christos }
530 1.1 cgd }
531 1.4 christos if (j > 0) {
532 1.7 dholland hitmonster(kk, mm);
533 1.4 christos return (yrepcount = 0);
534 1.4 christos } /* hit a monster */
535 1.4 christos lastpx = playerx;
536 1.4 christos lastpy = playery;
537 1.7 dholland playerx = kk;
538 1.7 dholland playery = mm;
539 1.4 christos if (i && i != OTRAPARROWIV && i != OIVTELETRAP && i != OIVDARTRAP && i != OIVTRAPDOOR)
540 1.4 christos return (yrepcount = 0);
541 1.4 christos else
542 1.4 christos return (1);
543 1.4 christos }
544 1.4 christos
545 1.4 christos
546 1.1 cgd /*
547 1.1 cgd * function to show what magic items have been discovered thus far
548 1.1 cgd * enter with -1 for just spells, anything else will give scrolls & potions
549 1.1 cgd */
550 1.4 christos static int lincount, count;
551 1.4 christos void
552 1.1 cgd seemagic(arg)
553 1.4 christos int arg;
554 1.4 christos {
555 1.4 christos int i, number = 0;
556 1.4 christos count = lincount = 0;
557 1.4 christos nosignal = 1;
558 1.4 christos
559 1.4 christos if (arg == -1) { /* if display spells while casting one */
560 1.4 christos for (number = i = 0; i < SPNUM; i++)
561 1.4 christos if (spelknow[i])
562 1.4 christos number++;
563 1.4 christos number = (number + 2) / 3 + 4; /* # lines needed to display */
564 1.4 christos cl_up(79, number);
565 1.4 christos cursor(1, 1);
566 1.4 christos } else {
567 1.4 christos resetscroll();
568 1.4 christos clear();
569 1.4 christos }
570 1.1 cgd
571 1.1 cgd lprcat("The magic spells you have discovered thus far:\n\n");
572 1.4 christos for (i = 0; i < SPNUM; i++)
573 1.4 christos if (spelknow[i]) {
574 1.4 christos lprintf("%s %-20s ", spelcode[i], spelname[i]);
575 1.4 christos seepage();
576 1.4 christos }
577 1.4 christos if (arg == -1) {
578 1.4 christos seepage();
579 1.4 christos more();
580 1.4 christos nosignal = 0;
581 1.4 christos draws(0, MAXX, 0, number);
582 1.4 christos return;
583 1.4 christos }
584 1.4 christos lincount += 3;
585 1.4 christos if (count != 0) {
586 1.4 christos count = 2;
587 1.4 christos seepage();
588 1.4 christos }
589 1.1 cgd lprcat("\nThe magic scrolls you have found to date are:\n\n");
590 1.4 christos count = 0;
591 1.4 christos for (i = 0; i < MAXSCROLL; i++)
592 1.1 cgd if (scrollname[i][0])
593 1.4 christos if (scrollname[i][1] != ' ') {
594 1.4 christos lprintf("%-26s", &scrollname[i][1]);
595 1.4 christos seepage();
596 1.4 christos }
597 1.4 christos lincount += 3;
598 1.4 christos if (count != 0) {
599 1.4 christos count = 2;
600 1.4 christos seepage();
601 1.4 christos }
602 1.1 cgd lprcat("\nThe magic potions you have found to date are:\n\n");
603 1.4 christos count = 0;
604 1.4 christos for (i = 0; i < MAXPOTION; i++)
605 1.1 cgd if (potionname[i][0])
606 1.4 christos if (potionname[i][1] != ' ') {
607 1.4 christos lprintf("%-26s", &potionname[i][1]);
608 1.4 christos seepage();
609 1.4 christos }
610 1.4 christos if (lincount != 0)
611 1.4 christos more();
612 1.4 christos nosignal = 0;
613 1.4 christos setscroll();
614 1.4 christos drawscreen();
615 1.4 christos }
616 1.1 cgd
617 1.1 cgd /*
618 1.1 cgd * subroutine to paginate the seemagic function
619 1.1 cgd */
620 1.8 dholland static void
621 1.8 dholland seepage(void)
622 1.4 christos {
623 1.4 christos if (++count == 3) {
624 1.4 christos lincount++;
625 1.4 christos count = 0;
626 1.4 christos lprc('\n');
627 1.4 christos if (lincount > 17) {
628 1.4 christos lincount = 0;
629 1.4 christos more();
630 1.4 christos clear();
631 1.1 cgd }
632 1.1 cgd }
633 1.4 christos }
634