1 1.10 dholland /* $NetBSD: display.c,v 1.10 2012/06/19 05:30:43 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.10 dholland __RCSID("$NetBSD: display.c,v 1.10 2012/06/19 05:30:43 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.10 dholland bottomline(void) 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.10 dholland bottomhp(void) 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.10 dholland bottomspell(void) 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.10 dholland bottomdo(void) 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.10 dholland bot_linex(void) 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.10 dholland bottomgold(void) 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.10 dholland draws(int xmin, int xmax, int ymin, int ymax) 248 1.4 christos { 249 1.4 christos int i, idx; 250 1.4 christos if (xmin == 0 && xmax == MAXX) { /* clear section of screen as 251 1.4 christos * needed */ 252 1.4 christos if (ymin == 0) 253 1.4 christos cl_up(79, ymax); 254 1.4 christos else 255 1.4 christos for (i = ymin; i < ymin; i++) 256 1.4 christos cl_line(1, i + 1); 257 1.1 cgd xmin = -1; 258 1.4 christos } 259 1.4 christos d_xmin = xmin; 260 1.4 christos d_xmax = xmax; 261 1.4 christos d_ymin = ymin; 262 1.4 christos d_ymax = ymax; /* for limited screen drawing */ 263 1.1 cgd drawscreen(); 264 1.4 christos if (xmin <= 0 && xmax == MAXX) { /* draw stuff on right side 265 1.4 christos * of screen as needed */ 266 1.4 christos for (i = ymin; i < ymax; i++) { 267 1.1 cgd idx = bot_data[i].typ; 268 1.4 christos if (c[idx]) { 269 1.4 christos cursor(70, i + 1); 270 1.4 christos lprcat(bot_data[i].string); 271 1.1 cgd } 272 1.4 christos cbak[idx] = c[idx]; 273 1.1 cgd } 274 1.1 cgd } 275 1.4 christos } 276 1.1 cgd 277 1.1 cgd /* 278 1.1 cgd drawscreen() 279 1.1 cgd 280 1.1 cgd subroutine to redraw the whole screen as the player knows it 281 1.1 cgd */ 282 1.9 dholland u_char screen[MAXX][MAXY]; /* template for the screen */ 283 1.9 dholland static u_char d_flag; 284 1.4 christos void 285 1.10 dholland drawscreen(void) 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.10 dholland showcell(int x, int y) 379 1.4 christos { 380 1.7 dholland int i, j, kk, mm; 381 1.4 christos if (c[BLINDCOUNT]) 382 1.4 christos return; /* see nothing if blind */ 383 1.4 christos if (c[AWARENESS]) { 384 1.4 christos minx = x - 3; 385 1.4 christos maxx = x + 3; 386 1.4 christos miny = y - 3; 387 1.4 christos maxy = y + 3; 388 1.4 christos } else { 389 1.4 christos minx = x - 1; 390 1.4 christos maxx = x + 1; 391 1.4 christos miny = y - 1; 392 1.4 christos maxy = y + 1; 393 1.4 christos } 394 1.4 christos 395 1.4 christos if (minx < 0) 396 1.4 christos minx = 0; 397 1.4 christos if (maxx > MAXX - 1) 398 1.4 christos maxx = MAXX - 1; 399 1.4 christos if (miny < 0) 400 1.4 christos miny = 0; 401 1.4 christos if (maxy > MAXY - 1) 402 1.4 christos maxy = MAXY - 1; 403 1.4 christos 404 1.4 christos for (j = miny; j <= maxy; j++) 405 1.7 dholland for (mm = minx; mm <= maxx; mm++) 406 1.7 dholland if (know[mm][j] == 0) { 407 1.7 dholland cursor(mm + 1, j + 1); 408 1.4 christos x = maxx; 409 1.4 christos while (know[x][j]) 410 1.4 christos --x; 411 1.7 dholland for (i = mm; i <= x; i++) { 412 1.7 dholland if ((kk = mitem[i][j]) != 0) 413 1.7 dholland lprc(monstnamelist[kk]); 414 1.4 christos else 415 1.7 dholland switch (kk = item[i][j]) { 416 1.4 christos case OWALL: 417 1.4 christos case 0: 418 1.4 christos case OIVTELETRAP: 419 1.4 christos case OTRAPARROWIV: 420 1.4 christos case OIVDARTRAP: 421 1.4 christos case OIVTRAPDOOR: 422 1.7 dholland lprc(objnamelist[kk]); 423 1.4 christos break; 424 1.4 christos 425 1.4 christos default: 426 1.4 christos setbold(); 427 1.7 dholland lprc(objnamelist[kk]); 428 1.4 christos resetbold(); 429 1.4 christos }; 430 1.4 christos know[i][j] = 1; 431 1.1 cgd } 432 1.7 dholland mm = maxx; 433 1.1 cgd } 434 1.4 christos } 435 1.1 cgd 436 1.1 cgd /* 437 1.1 cgd this routine shows only the spot that is given it. the spaces around 438 1.1 cgd these coordinated are not shown 439 1.1 cgd used in godirect() in monster.c for missile weapons display 440 1.1 cgd */ 441 1.4 christos void 442 1.10 dholland show1cell(int x, int y) 443 1.4 christos { 444 1.4 christos if (c[BLINDCOUNT]) 445 1.4 christos return; /* see nothing if blind */ 446 1.4 christos cursor(x + 1, y + 1); 447 1.4 christos if ((k = mitem[x][y]) != 0) 448 1.4 christos lprc(monstnamelist[k]); 449 1.4 christos else 450 1.4 christos switch (k = item[x][y]) { 451 1.4 christos case OWALL: 452 1.4 christos case 0: 453 1.4 christos case OIVTELETRAP: 454 1.4 christos case OTRAPARROWIV: 455 1.4 christos case OIVDARTRAP: 456 1.4 christos case OIVTRAPDOOR: 457 1.4 christos lprc(objnamelist[k]); 458 1.4 christos break; 459 1.4 christos 460 1.4 christos default: 461 1.4 christos setbold(); 462 1.4 christos lprc(objnamelist[k]); 463 1.4 christos resetbold(); 464 1.4 christos }; 465 1.4 christos know[x][y] |= 1; /* we end up knowing about it */ 466 1.4 christos } 467 1.1 cgd 468 1.1 cgd /* 469 1.1 cgd showplayer() 470 1.1 cgd 471 1.1 cgd subroutine to show where the player is on the screen 472 1.1 cgd cursor values start from 1 up 473 1.1 cgd */ 474 1.4 christos void 475 1.10 dholland showplayer(void) 476 1.4 christos { 477 1.4 christos cursor(playerx + 1, playery + 1); 478 1.4 christos oldx = playerx; 479 1.4 christos oldy = playery; 480 1.4 christos } 481 1.1 cgd 482 1.1 cgd /* 483 1.1 cgd moveplayer(dir) 484 1.1 cgd 485 1.1 cgd subroutine to move the player from one room to another 486 1.1 cgd returns 0 if can't move in that direction or hit a monster or on an object 487 1.1 cgd else returns 1 488 1.1 cgd nomove is set to 1 to stop the next move (inadvertent monsters hitting 489 1.1 cgd players when walking into walls) if player walks off screen or into wall 490 1.1 cgd */ 491 1.4 christos short diroffx[] = {0, 0, 1, 0, -1, 1, -1, 1, -1}; 492 1.4 christos short diroffy[] = {0, 1, 0, -1, 0, -1, -1, 1, 1}; 493 1.4 christos int 494 1.10 dholland moveplayer(int dir) 495 1.10 dholland /* from = present room # direction = 496 1.4 christos * [1-north] [2-east] [3-south] [4-west] 497 1.4 christos * [5-northeast] [6-northwest] [7-southeast] 498 1.4 christos * [8-southwest] if direction=0, don't 499 1.4 christos * move--just show where he is */ 500 1.4 christos { 501 1.7 dholland int kk, mm, i, j; 502 1.4 christos if (c[CONFUSE]) 503 1.4 christos if (c[LEVEL] < rnd(30)) 504 1.4 christos dir = rund(9); /* if confused any dir */ 505 1.7 dholland kk = playerx + diroffx[dir]; 506 1.7 dholland mm = playery + diroffy[dir]; 507 1.7 dholland if (kk < 0 || kk >= MAXX || mm < 0 || mm >= MAXY) { 508 1.4 christos nomove = 1; 509 1.4 christos return (yrepcount = 0); 510 1.4 christos } 511 1.7 dholland i = item[kk][mm]; 512 1.7 dholland j = mitem[kk][mm]; 513 1.4 christos if (i == OWALL && c[WTW] == 0) { 514 1.4 christos nomove = 1; 515 1.4 christos return (yrepcount = 0); 516 1.4 christos } /* hit a wall */ 517 1.7 dholland if (kk == 33 && mm == MAXY - 1 && level == 1) { 518 1.4 christos newcavelevel(0); 519 1.7 dholland for (kk = 0; kk < MAXX; kk++) 520 1.7 dholland for (mm = 0; mm < MAXY; mm++) 521 1.7 dholland if (item[kk][mm] == OENTRANCE) { 522 1.7 dholland playerx = kk; 523 1.7 dholland playery = mm; 524 1.4 christos positionplayer(); 525 1.4 christos drawscreen(); 526 1.4 christos return (0); 527 1.4 christos } 528 1.1 cgd } 529 1.4 christos if (j > 0) { 530 1.7 dholland hitmonster(kk, mm); 531 1.4 christos return (yrepcount = 0); 532 1.4 christos } /* hit a monster */ 533 1.4 christos lastpx = playerx; 534 1.4 christos lastpy = playery; 535 1.7 dholland playerx = kk; 536 1.7 dholland playery = mm; 537 1.4 christos if (i && i != OTRAPARROWIV && i != OIVTELETRAP && i != OIVDARTRAP && i != OIVTRAPDOOR) 538 1.4 christos return (yrepcount = 0); 539 1.4 christos else 540 1.4 christos return (1); 541 1.4 christos } 542 1.4 christos 543 1.4 christos 544 1.1 cgd /* 545 1.1 cgd * function to show what magic items have been discovered thus far 546 1.1 cgd * enter with -1 for just spells, anything else will give scrolls & potions 547 1.1 cgd */ 548 1.4 christos static int lincount, count; 549 1.4 christos void 550 1.10 dholland seemagic(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.8 dholland static void 618 1.8 dholland seepage(void) 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