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