1 /*
2  * invent.c
3  *
4  * This source herein may be modified and/or distributed by anybody who
5  * so desires, with the following restrictions:
6  *    1.)  No portion of this notice shall be removed.
7  *    2.)  Credit shall not be taken for the creation of this source.
8  *    3.)  This code is not to be traded, sold, or used for personal
9  *         gain or profit.
10  *
11  */
12 
13 #include "rogue.h"
14 
15 #define swap_string(x,y) {t = x; x = y; y = t;}
16 
17 boolean is_wood[WANDS];
18 
19 char *wand_materials[WAND_MATERIALS] = {
20 	mesg[410], mesg[411], mesg[412], mesg[413], mesg[414], mesg[415],
21 	mesg[416], mesg[417], mesg[418], mesg[419], mesg[420], mesg[421],
22 	mesg[422], mesg[423], mesg[424], mesg[425], mesg[426], mesg[427],
23 	mesg[428], mesg[429], mesg[430], mesg[431], mesg[432], mesg[433],
24 	mesg[434], mesg[435], mesg[436], mesg[437], mesg[438], mesg[439]
25 };
26 
27 char *gems[GEMS] = {
28 	mesg[440], mesg[441], mesg[442], mesg[443], mesg[444], mesg[445],
29 	mesg[446], mesg[447], mesg[448], mesg[449], mesg[450], mesg[451],
30 	mesg[452], mesg[453]
31 };
32 
33 char *syllables[MAXSYLLABLES] = {
34 	mesg[454], mesg[455], mesg[456], mesg[457], mesg[458], mesg[459],
35 	mesg[460], mesg[461], mesg[462], mesg[463], mesg[464], mesg[465],
36 	mesg[466], mesg[467], mesg[468], mesg[469], mesg[470], mesg[471],
37 	mesg[472], mesg[473], mesg[474], mesg[475], mesg[476], mesg[477],
38 	mesg[478], mesg[479], mesg[480], mesg[481], mesg[482], mesg[483],
39 	mesg[484], mesg[485], mesg[486], mesg[487], mesg[488], mesg[489],
40 	mesg[490], mesg[491], mesg[492], mesg[493]
41 };
42 
43 extern boolean wizard;
44 
45 char descs[DROWS][DCOLS];	/* multi-purpose screen saver */
46 
47 void
inventory(pack,mask)48 inventory(pack, mask)
49 object *pack;
50 unsigned short mask;
51 {
52 	object *obj;
53 	short i, j, maxlen, n;
54 	short row, col;
55 	char *p;
56 #ifdef JAPAN
57 	char *msg = "  �᥹�ڡ��������Ƥ���������";
58 	short len = 30;
59 #else
60 	char *msg = " --Press space to continue--";
61 	short len = 28;
62 #endif
63 
64 	if (!(obj = pack->next_object)) {
65 		message(mesg[26], 0);
66 		return;
67 	}
68 
69 #define	Protected(obj)	((obj->what_is & ARMOR) && obj->is_protected)
70 nextpage:
71 	i = 0;
72 	maxlen = len;
73 	while (obj && i < DROWS - 2) {
74 		if (obj->what_is & mask) {
75 			p = descs[i];
76 			*p++ = ' ';
77 			*p++ = obj->ichar;
78 			*p++ = Protected(obj)? '}': ')';
79 			*p++ = ' ';
80 			get_desc(obj, p, 0);
81 			if ((n = strlen(descs[i])) > maxlen)
82 				maxlen = n;
83 			i++;
84 		}
85 		obj = obj->next_object;
86 	}
87 	(void) strcpy(descs[i++], msg);
88 
89 	if (i == 0)
90 		return;
91 
92 	col = DCOLS - (maxlen + 2);
93 	for (row = 0; row < i; row++) {
94 		if (row > 0) {
95 			for (j = col; j < DCOLS; j++) {
96 				descs[row-1][j-col] = mvinch(row, j);
97 			}
98 			descs[row-1][j-col] = 0;
99 		}
100 		mvaddstr(row, col, descs[row]);
101 		clrtoeol();
102 	}
103 	refresh();
104 	wait_for_ack();
105 
106 	move(0, 0);
107 	clrtoeol();
108 #ifdef COLOR
109 	for (j = 1; j < i; j++) {
110 		move(j, col);
111 		for (p = descs[j-1]; *p; p++)
112 			addch(colored(*p));
113 	}
114 #else
115 #if defined(CURSES) || !defined(JAPAN)	/* if.. by Yasha */
116 	for (j = 1; j < i; j++)
117 		mvaddstr(j, col, descs[j-1]);
118 #else
119 	for (j = 1; j < i; j++) {	/* by Yasha */
120 		move(j, col);		/* by Yasha */
121 		clrtoeol();		/* by Yasha */
122 		addstr(descs[j-1]);	/* by Yasha */
123 	}				/* by Yasha */
124 	move(DROWS - 1, 0);	/* by Yasha */
125 	clrtoeol();		/* by Yasha */
126 	print_stats(STAT_ALL);	/* by Yasha */
127 #endif
128 #endif
129 
130 #ifdef CURSES	/* if.. by Yasha */
131 #ifdef JAPAN
132 	for (j = 0; j < i; j++)
133 		touch(j, col, DCOLS-1);
134 #endif
135 #endif
136 	if (obj)
137 		goto nextpage;
138 }
139 
mix_colors()140 mix_colors()
141 {
142 	short i, j;
143 	char *t;
144 	extern char *po_color[];
145 
146 	for (i = 0; i < POTIONS; i++) {
147 		strcpy(id_potions[i].title, po_color[i]);	/* by Yahsa */
148 /*		id_potions[i].title = po_color[i];*/
149 	}
150 	for (i = 0; i < POTIONS; i++) {
151 		j = get_rand(i, POTIONS - 1);
152 		swap_string(id_potions[i].title, id_potions[j].title);
153 	}
154 }
155 
make_scroll_titles()156 make_scroll_titles()
157 {
158 	short i, j, n, len;
159 	short sylls, s;
160 
161 	for (i = 0; i < SCROLS; i++) {
162 		sylls = get_rand(2, 5);
163 #ifdef JAPAN
164 		(void) strcpy(id_scrolls[i].title, "��");
165 		len = 2;
166 		for (j = 0; j < sylls; j++) {
167 			s = get_rand(1, (MAXSYLLABLES-1));
168 			n = strlen(syllables[s]);
169 			if (len + n - 1 >= MAX_TITLE_LENGTH - 2)
170 				break;
171 			(void) strcat(id_scrolls[i].title, syllables[s]);
172 			len += n;
173 		}
174 		(void) strcpy(id_scrolls[i].title+(len-1), "��");
175 #else
176 		(void) strcpy(id_scrolls[i].title, "'");
177 		for (j = 0; j < sylls; j++) {
178 			s = get_rand(1, (MAXSYLLABLES-1));
179 			(void) strcat(id_scrolls[i].title, syllables[s]);
180 		}
181 		n = strlen(id_scrolls[i].title);
182 		(void) strcpy(id_scrolls[i].title+(n-1), "' ");
183 #endif
184 	}
185 }
186 
187 #ifdef JAPAN /* for whole function */
188 void
get_desc(obj,desc,capitalized)189 get_desc(obj, desc, capitalized)
190 register object *obj;
191 register char *desc;
192 boolean capitalized;
193 {
194 	char *item_name, *p;
195 	struct id *id_table;
196 	char more_info[32];
197 	short i;
198 
199 	*desc = 0;
200 	if (obj->what_is == AMULET) {
201 		(void) strcpy(desc, mesg[27]);
202 		return;
203 	}
204 	item_name = name_of(obj);
205 	if (obj->what_is == GOLD) {
206 		znum(desc, obj->quantity, 0);
207 		strcat(desc, mesg[28]);
208 		return;
209 	}
210 	if (obj->what_is == WEAPON && obj->quantity > 1) {
211 		znum(desc, obj->quantity, 0);
212 		strcat(desc, mesg[29]);
213 	} else if (obj->what_is == FOOD) {
214 		znum(desc, obj->quantity, 0);
215 		strcat(desc, (obj->which_kind == RATION)? mesg[30]: mesg[31]);
216 		(void) strcat(desc, item_name);
217 		goto ANA;
218 	} else if (obj->what_is != ARMOR && obj->quantity > 1) {
219 		znum(desc, obj->quantity, 0);
220 		strcat(desc, mesg[32]);
221 	}
222 	id_table = get_id_table(obj);
223 
224 	if (wizard) {
225 		goto ID;
226 	}
227 	if (obj->what_is & (WEAPON | ARMOR | WAND | RING)) {
228 		goto CHECK;
229 	}
230 
231 	switch(id_table[obj->which_kind].id_status) {
232 	case UNIDENTIFIED:
233 CHECK:
234 		switch(obj->what_is) {
235 		case SCROL:
236 			(void) strcat(desc, id_table[obj->which_kind].title);
237 			(void) strcat(desc, mesg[33]);
238 			(void) strcat(desc, item_name);
239 			break;
240 		case POTION:
241 			(void) strcat(desc, id_table[obj->which_kind].title);
242 			(void) strcat(desc, item_name);
243 			break;
244 		case WAND:
245 		case RING:
246 			if (obj->identified ||
247 			(id_table[obj->which_kind].id_status == IDENTIFIED)) {
248 				goto ID;
249 			}
250 			if (id_table[obj->which_kind].id_status == CALLED) {
251 				goto CALL;
252 			}
253 			(void) strcat(desc, id_table[obj->which_kind].title);
254 			(void) strcat(desc, item_name);
255 			break;
256 		case ARMOR:
257 			if (obj->identified) {
258 				goto ID;
259 			}
260 			(void) strcpy(desc, id_table[obj->which_kind].title);
261 			break;
262 		case WEAPON:
263 			if (obj->identified) {
264 				goto ID;
265 			}
266 			(void) strcat(desc, name_of(obj));
267 			break;
268 		}
269 		break;
270 	case CALLED:
271 CALL:	switch(obj->what_is) {
272 		case SCROL:
273 		case POTION:
274 		case WAND:
275 		case RING:
276 			p = id_table[obj->which_kind].title;
277 #ifdef EUC
278 			if (*desc && *p >= ' ' && !(0x80 & *p))	/* by Yasha */
279 #else	/* Shift JIS */
280 			if (*desc && (*p >= ' ' && *p <= '~' ||
281 						*p >= '\240' && *p < '\340'))
282 #endif
283 				(void) strcat(desc, " ");
284 			(void) strcat(desc, p);
285 			(void) strcat(desc, mesg[34]);
286 			(void) strcat(desc, item_name);
287 			break;
288 		}
289 		break;
290 	case IDENTIFIED:
291 ID:		switch(obj->what_is) {
292 		case SCROL:
293 		case POTION:
294 			(void) strcat(desc, id_table[obj->which_kind].real);
295 			(void) strcat(desc, item_name);
296 			break;
297 		case RING:
298 			(void) strcat(desc, id_table[obj->which_kind].real);
299 			if (wizard || obj->identified) {
300 				if ((obj->which_kind == DEXTERITY) ||
301 					(obj->which_kind == ADD_STRENGTH)) {
302 					strcpy(more_info, "��");
303 					znum(more_info, obj->class, 1);
304 					strcat(more_info, "��");
305 					(void) strcat(desc, more_info);
306 				}
307 			}
308 			(void) strcat(desc, item_name);
309 			break;
310 		case WAND:
311 			(void) strcat(desc, id_table[obj->which_kind].real);
312 			(void) strcat(desc, item_name);
313 			if (wizard || obj->identified) {
314 				strcpy(more_info, "��");
315 				znum(more_info, obj->class, 0);
316 				strcat(more_info, "��");
317 				(void) strcat(desc, more_info);
318 			}
319 			break;
320 		case ARMOR:
321 			strcpy(desc, "��");
322 			znum(desc, obj->d_enchant, 1);
323 			strcat(desc, "��");
324 			(void) strcat(desc, id_table[obj->which_kind].title);
325 			strcpy(more_info, "��");
326 			znum(more_info, get_armor_class(obj), 0);
327 			strcat(more_info, "��");
328 			(void) strcat(desc, more_info);
329 			break;
330 		case WEAPON:
331 			strcat(desc, "��");
332 			znum(desc, obj->hit_enchant, 1);
333 			strcat(desc, "��");
334 			znum(desc, obj->d_enchant, 1);
335 			strcat(desc, "��");
336 			(void) strcat(desc, name_of(obj));
337 			break;
338 		}
339 		break;
340 	}
341 ANA:
342 	i = obj->in_use_flags;
343 	if (i & BEING_WIELDED) {
344 		p = mesg[35];
345 	} else if (i & BEING_WORN) {
346 		p = mesg[36];
347 	} else if (i & ON_LEFT_HAND) {
348 		p = mesg[37];
349 	} else if (i & ON_RIGHT_HAND) {
350 		p = mesg[38];
351 	} else {
352 		p = "";
353 	}
354 	(void) strcat(desc, p);
355 }
356 
357 #else /*JAPAN for whole function get_desc */
358 
get_desc(obj,desc,capitalized)359 get_desc(obj, desc, capitalized)
360 object *obj;
361 char *desc;
362 boolean capitalized;
363 {
364 	char *p;
365 	char *item_name;
366 	struct id *id_table;
367 	char more_info[32];
368 	short i;
369 
370 	if (obj->what_is == AMULET) {
371 		(void) strcpy(desc, mesg[27]);
372 		if (!capitalized)
373 			*desc = 't';
374 		return;
375 	}
376 	item_name = name_of(obj);
377 
378 	if (obj->what_is == GOLD) {
379 		sprintf(desc, mesg[28], obj->quantity);
380 		return;
381 	}
382 
383 	if (obj->what_is != ARMOR) {
384 		if (obj->quantity == 1) {
385 			strcpy(desc, capitalized? "A ": "a ");
386 		} else {
387 			sprintf(desc, "%d ", obj->quantity);
388 		}
389 	}
390 	if (obj->what_is == FOOD) {
391 		if (obj->which_kind == RATION) {
392 			if (obj->quantity > 1) {
393 				sprintf(desc, mesg[30], obj->quantity);
394 			} else {
395 				strcpy(desc, capitalized? "Some ": "some ");
396 			}
397 		} else {
398 			strcpy(desc, capitalized? "A ": "a ");
399 		}
400 		(void) strcat(desc, item_name);
401 		goto ANA;
402 	}
403 	id_table = get_id_table(obj);
404 
405 	if (wizard) {
406 		goto ID;
407 	}
408 	if (obj->what_is & (WEAPON | ARMOR | WAND | RING)) {
409 		goto CHECK;
410 	}
411 
412 	switch(id_table[obj->which_kind].id_status) {
413 	case UNIDENTIFIED:
414 CHECK:
415 		switch(obj->what_is) {
416 		case SCROL:
417 			(void) strcat(desc, item_name);
418 			(void) strcat(desc, mesg[33]);
419 			(void) strcat(desc, id_table[obj->which_kind].title);
420 			break;
421 		case POTION:
422 			(void) strcat(desc, id_table[obj->which_kind].title);
423 			(void) strcat(desc, item_name);
424 			break;
425 		case WAND:
426 		case RING:
427 			if (obj->identified ||
428 			(id_table[obj->which_kind].id_status == IDENTIFIED)) {
429 				goto ID;
430 			}
431 			if (id_table[obj->which_kind].id_status == CALLED) {
432 				goto CALL;
433 			}
434 			(void) strcat(desc, id_table[obj->which_kind].title);
435 			(void) strcat(desc, item_name);
436 			break;
437 		case ARMOR:
438 			if (obj->identified) {
439 				goto ID;
440 			}
441 			(void) strcpy(desc, id_table[obj->which_kind].title);
442 			break;
443 		case WEAPON:
444 			if (obj->identified) {
445 				goto ID;
446 			}
447 			(void) strcat(desc, name_of(obj));
448 			break;
449 		}
450 		break;
451 	case CALLED:
452 CALL:	switch(obj->what_is) {
453 		case SCROL:
454 		case POTION:
455 		case WAND:
456 		case RING:
457 			(void) strcat(desc, item_name);
458 			(void) strcat(desc, mesg[34]);
459 			(void) strcat(desc, id_table[obj->which_kind].title);
460 			break;
461 		}
462 		break;
463 	case IDENTIFIED:
464 ID:		switch(obj->what_is) {
465 		case SCROL:
466 		case POTION:
467 			(void) strcat(desc, item_name);
468 			(void) strcat(desc, id_table[obj->which_kind].real);
469 			break;
470 		case RING:
471 			if (wizard || obj->identified) {
472 				if ((obj->which_kind == DEXTERITY) ||
473 					(obj->which_kind == ADD_STRENGTH)) {
474 					sprintf(more_info, "%s%d ",
475 						((obj->class > 0) ? "+" : ""),
476 						obj->class);
477 					(void) strcat(desc, more_info);
478 				}
479 			}
480 			(void) strcat(desc, item_name);
481 			(void) strcat(desc, id_table[obj->which_kind].real);
482 			break;
483 		case WAND:
484 			(void) strcat(desc, item_name);
485 			(void) strcat(desc, id_table[obj->which_kind].real);
486 			if (wizard || obj->identified) {
487 				sprintf(more_info, "[%d]", obj->class);
488 				(void) strcat(desc, more_info);
489 			}
490 			break;
491 		case ARMOR:
492 			sprintf(desc, "%s%d ",
493 				((obj->d_enchant >= 0) ? "+" : ""),
494 				obj->d_enchant);
495 			(void) strcat(desc, id_table[obj->which_kind].title);
496 			sprintf(more_info, "[%d] ", get_armor_class(obj));
497 			(void) strcat(desc, more_info);
498 			break;
499 		case WEAPON:
500 			sprintf(desc+strlen(desc), "%s%d, %s%d ",
501 				((obj->hit_enchant >= 0) ? "+" : ""),
502 				obj->hit_enchant,
503 				((obj->d_enchant >= 0) ? "+" : ""),
504 				obj->d_enchant);
505 			(void) strcat(desc, name_of(obj));
506 			break;
507 		}
508 		break;
509 	}
510 ANA:
511 	if (!strncmp(desc, (capitalized? "A ": "a "), 2)) {
512 		if (is_vowel(desc[2])) {
513 			for (i = strlen(desc) + 1; i > 1; i--) {
514 				desc[i] = desc[i-1];
515 			}
516 			desc[1] = 'n';
517 		}
518 	}
519 	i = obj->in_use_flags;
520 	if (i & BEING_WIELDED) {
521 		p = mesg[35];
522 	} else if (i & BEING_WORN) {
523 		p = mesg[36];
524 	} else if (i & ON_LEFT_HAND) {
525 		p = mesg[37];
526 	} else if (i & ON_RIGHT_HAND) {
527 		p = "(on right hand)";
528 	} else {
529 		p = "";
530 	}
531 	(void) strcat(desc, p);
532 }
533 #endif /*JAPAN for whole function get_desc() */
534 
get_wand_and_ring_materials()535 get_wand_and_ring_materials()
536 {
537 	short i, j;
538 	char *p;
539 	boolean used[WAND_MATERIALS];
540 
541 	for (i = 0; i < WAND_MATERIALS; i++) {
542 		used[i] = 0;
543 	}
544 	for (i = 0; i < WANDS; i++) {
545 		do {
546 			j = get_rand(0, WAND_MATERIALS-1);
547 		} while (used[j]);
548 		used[j] = 1;
549 		p = id_wands[i].title;
550 		(void) strcpy(p, wand_materials[j]);
551 #ifdef JAPAN
552 		(void) strcat(p, mesg[39]);
553 #endif
554 		is_wood[i] = (j > MAX_METAL);
555 	}
556 	for (i = 0; i < GEMS; i++) {
557 		used[i] = 0;
558 	}
559 	for (i = 0; i < RINGS; i++) {
560 		do {
561 			j = get_rand(0, GEMS-1);
562 		} while (used[j]);
563 		used[j] = 1;
564 		p = id_rings[i].title;
565 		(void) strcpy(p, gems[j]);
566 #ifdef JAPAN
567 		(void) strcat(p, mesg[40]);
568 #endif
569 	}
570 }
571 
572 void
single_inv(ichar)573 single_inv(ichar)
574 short ichar;
575 {
576 	short ch;
577 	char *p;
578 	object *obj;
579 	char desc[DCOLS];
580 
581 	ch = ichar? ichar: pack_letter(mesg[41], ALL_OBJECTS);
582 
583 	if (ch == CANCEL) {
584 		return;
585 	}
586 	if (!(obj = get_letter_object(ch))) {
587 		message(mesg[41], 0);
588 		return;
589 	}
590 	p = desc;
591 	*p++ = ch;
592 	*p++ = ((obj->what_is & ARMOR) && obj->is_protected) ? '}' : ')';
593 	*p++ = ' ';
594 	get_desc(obj, p, 1);
595 	message(desc, 0);
596 }
597 
598 struct id *
get_id_table(obj)599 get_id_table(obj)
600 object *obj;
601 {
602 	switch(obj->what_is) {
603 	case SCROL:
604 		return(id_scrolls);
605 	case POTION:
606 		return(id_potions);
607 	case WAND:
608 		return(id_wands);
609 	case RING:
610 		return(id_rings);
611 	case WEAPON:
612 		return(id_weapons);
613 	case ARMOR:
614 		return(id_armors);
615 	}
616 	return((struct id *) 0);
617 }
618 
inv_armor_weapon(is_weapon)619 inv_armor_weapon(is_weapon)
620 boolean is_weapon;
621 {
622 	if (is_weapon) {
623 		if (rogue.weapon) {
624 			single_inv(rogue.weapon->ichar);
625 		} else {
626 			message(mesg[43], 0);
627 		}
628 	} else {
629 		if (rogue.armor) {
630 			single_inv(rogue.armor->ichar);
631 		} else {
632 			message(mesg[44], 0);
633 		}
634 	}
635 }
636 
637 #ifndef ORIGINAL
638 struct	dlist {
639 	short	type, no;
640 	char	*name, *real;
641 #ifdef JAPAN
642 	char	*sub;
643 #endif
644 }	dlist[SCROLS + POTIONS + WANDS + RINGS + 4];
645 
646 struct	dobj {
647 	short	type;
648 	char	ch, max;
649 	char	*name;
650 	struct	id *id;
651 }	dobj[] = {
652 		{ SCROL,  '?', SCROLS,  mesg[3], id_scrolls },
653 		{ POTION, '!', POTIONS, mesg[4], id_potions },
654 		{ WAND,   '/', WANDS,   mesg[5], id_wands   },
655 		{ RING,   '=', RINGS,   mesg[8], id_rings   },
656 		{ 0 }
657 };
658 
659 void
discovered()660 discovered()
661 {
662 	short i, j, n;
663 	short ch, maxlen, found;
664 	short row, col;
665 	struct dlist *dp, *enddp;
666 	struct dobj *op;
667 	char *p;
668 #ifdef JAPAN
669 	char *msg = "  �᥹�ڡ��������Ƥ���������";
670 	short len = 30;
671 #else
672 	char *msg = " --Press space to continue--";
673 	short len = 28;
674 	char bf[30];
675 #endif
676 
677 	message(mesg[45], 0);
678 	while (r_index("?!/=*\033", (ch = rgetchar()), 0) == -1)
679 		sound_bell();
680 	check_message();
681 	if (ch == '\033')
682 		return;
683 
684 	found = 0;
685 	dp = dlist;
686 	for (op = dobj; op->type; op++) {
687 		if (ch != op->ch && ch != '*')
688 			continue;
689 		for (i = 0; i < op->max; i++) {
690 			j = op->id[i].id_status;
691 			if (j == IDENTIFIED || j == CALLED) {
692 				dp->type = op->type;
693 				dp->no = i;
694 #ifdef JAPAN
695 				dp->name = op->name;
696 #else
697 				sprintf(bf, op->name, "");
698 				dp->name = bf;
699 #endif
700 				if (wizard || j == IDENTIFIED) {
701 					dp->real = op->id[i].real;
702 #ifdef JAPAN
703 					dp->sub  = "";
704 #endif
705 				} else {
706 					dp->real = op->id[i].title;
707 #ifdef JAPAN
708 					dp->sub  = mesg[34];
709 #endif
710 				}
711 #ifndef JAPAN
712 				if (op->type == WAND && is_wood[i])
713 					dp->name = "staff ";
714 #endif
715 				found |= op->type;
716 				dp++;
717 			}
718 		}
719 		if ((found & op->type) == 0) {
720 			dp->type = op->type;
721 			dp->no = -1;
722 			dp->name = op->name;
723 			dp++;
724 		}
725 		dp->type = 0;
726 		dp++;
727 	}
728 	enddp = dp;
729 
730 	if (found == 0) {
731 		message(mesg[46], 0);
732 		return;
733 	}
734 
735 	dp = dlist;
736 
737 nextpage:
738 	i = 0;
739 	maxlen = len;
740 	while (dp < enddp && i < DROWS-2) {
741 		p = descs[i];
742 		if (dp->type == 0) {
743 			(void) strcpy(p, "");
744 		} else if (dp->no < 0) {
745 			(void) sprintf(p, mesg[47], dp->name);
746 #ifndef JAPAN
747 			descs[i][strlen(p)-1] = 's';
748 #endif
749 #ifdef JAPAN
750 		} else {
751 			(void) strcpy(p, "  ");
752 			(void) strcat(p, dp->real);
753 			(void) strcat(p, dp->sub);
754 			(void) strcat(p, dp->name);
755 #else
756 		} else {
757 			p[0] = ' ';
758 			(void) strcpy(p+1, dp->name);
759 			(void) strcat(p, dp->real);
760 			p[1] -= 'a' - 'A';
761 #endif
762 		}
763 		if ((n = strlen(p)) > maxlen)
764 			maxlen = n;
765 		i++;
766 		dp++;
767 	}
768 
769 	if (i == 0 || i == 1 && !descs[0][0]) {
770 		/*
771 		 * can be here only in 2nd pass (exactly one page)
772 		 */
773 		return;
774 	}
775 
776 	strcpy(descs[i++], msg);
777 	col = DCOLS - (maxlen + 2);
778 	for (row = 0; row < i; row++) {
779 		if (row > 0) {
780 			for (j = col; j < DCOLS; j++)
781 				descs[row-1][j-col] = mvinch(row, j);
782 			descs[row-1][j-col] = 0;
783 		}
784 		mvaddstr(row, col, descs[row]);
785 		clrtoeol();
786 	}
787 	refresh();
788 	wait_for_ack();
789 
790 	move(0, 0);
791 	clrtoeol();
792 #ifdef COLOR
793 	for (j = 1; j < i; j++) {
794 		move(j, col);
795 		for (p = descs[j-1]; *p; p++)
796 			addch(colored(*p));
797 	}
798 #else
799 #if defined(CURSES) || !defined(JAPAN)	/* if.. by Yasha */
800 	for (j = 1; j < i; j++)
801 		mvaddstr(j, col, descs[j-1]);
802 #else
803 	for (j = 1; j < i; j++) {	/* by Yasha */
804 		move(j, col);		/* by Yasha */
805 		clrtoeol();		/* by Yasha */
806 		addstr(descs[j-1]);	/* by Yasha */
807 	}				/* by Yasha */
808 	move(DROWS - 1, 0);	/* by Yasha */
809 	clrtoeol();		/* by Yasha */
810 	print_stats(STAT_ALL);	/* by Yasha */
811 #endif
812 #endif
813 
814 #ifdef CURSES	/* if.. by Yasha */
815 #ifdef JAPAN
816 	for (j = 0; j < i; j++)
817 		touch(j, col, DCOLS-1);
818 #endif
819 #endif
820 	if (dp < enddp)
821 		goto nextpage;
822 }
823 #endif /*ORIGINAL*/
824 
825 #ifdef JAPAN
826 static char *_num[10] = { "��","��","��","��","��","��","��","��","��","��" };
827 
znum(buf,n,plus)828 znum(buf, n, plus)
829 char *buf;
830 int n, plus;
831 {
832 	char s[10], *p;
833 
834 	while (*buf)
835 		buf++;
836 	if (plus && n >= 0) {
837 		strcpy(buf, "��");
838 		buf += 2;
839 	}
840 	sprintf(s, "%d", n);
841 	for (p = s; *p; p++) {
842 		strcpy(buf, (*p == '-')? "��": _num[*p - '0']);
843 		buf += 2;
844 	}
845 }
846 
lznum(buf,n,plus)847 lznum(buf, n, plus)
848 char *buf;
849 long n;
850 int plus;
851 {
852 	char s[13], *p;
853 
854 	while (*buf)
855 		buf++;
856 	if (plus && n >= 0L) {
857 		strcpy(buf, "��");
858 		buf += 2;
859 	}
860 	sprintf(s, "%ld", n);
861 	for (p = s; *p; p++) {
862 		strcpy(buf, (*p == '-')? "��": _num[*p - '0']);
863 		buf += 2;
864 	}
865 }
866 #endif
867