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