OSDN Git Service

object_is_weapon_armour_ammo()のプロトタイプ宣言が2重になっていたので
[hengbandforosx/hengbandosx.git] / src / cmd4.c
1 /* File: cmd4.c */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.
9  */
10
11 /* Purpose: Interface commands */
12
13 #include "angband.h"
14
15
16
17 /*
18  * A set of functions to maintain automatic dumps of various kinds.
19  * -Mogami-
20  *
21  * remove_auto_dump(orig_file, mark)
22  *     Remove the old automatic dump of type "mark".
23  * auto_dump_printf(fmt, ...)
24  *     Dump a formatted string using fprintf().
25  * open_auto_dump(buf, mark)
26  *     Open a file, remove old dump, and add new header.
27  * close_auto_dump(void)
28  *     Add a footer, and close the file.
29  *
30  *    The dump commands of original Angband simply add new lines to
31  * existing files; these files will become bigger and bigger unless
32  * an user deletes some or all of these files by hand at some
33  * point.
34  *
35  *     These three functions automatically delete old dumped lines 
36  * before adding new ones.  Since there are various kinds of automatic 
37  * dumps in a single file, we add a header and a footer with a type 
38  * name for every automatic dump, and kill old lines only when the 
39  * lines have the correct type of header and footer.
40  *
41  *     We need to be quite paranoid about correctness; the user might 
42  * (mistakenly) edit the file by hand, and see all their work come
43  * to nothing on the next auto dump otherwise.  The current code only 
44  * detects changes by noting inconsistencies between the actual number 
45  * of lines and the number written in the footer.  Note that this will 
46  * not catch single-line edits.
47  */
48
49 /*
50  *  Mark strings for auto dump
51  */
52 static char auto_dump_header[] = "# vvvvvvv== %s ==vvvvvvv";
53 static char auto_dump_footer[] = "# ^^^^^^^== %s ==^^^^^^^";
54
55 /*
56  * Variables for auto dump
57  */
58 static FILE *auto_dump_stream;
59 static cptr auto_dump_mark;
60 static int auto_dump_line_num;
61
62 /*
63  * Remove old lines automatically generated before.
64  */
65 static void remove_auto_dump(cptr orig_file)
66 {
67         FILE *tmp_fff, *orig_fff;
68
69         char tmp_file[1024];
70         char buf[1024];
71         bool between_mark = FALSE;
72         bool changed = FALSE;
73         int line_num = 0;
74         long header_location = 0;
75         char header_mark_str[80];
76         char footer_mark_str[80];
77         size_t mark_len;
78
79         /* Prepare a header/footer mark string */
80         sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
81         sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
82
83         mark_len = strlen(footer_mark_str);
84
85         /* Open an old dump file in read-only mode */
86         orig_fff = my_fopen(orig_file, "r");
87
88         /* If original file does not exist, nothing to do */
89         if (!orig_fff) return;
90
91         /* Open a new (temporary) file */
92         tmp_fff = my_fopen_temp(tmp_file, 1024);
93
94         if (!tmp_fff)
95         {
96 #ifdef JP
97             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", tmp_file);
98 #else
99             msg_format("Failed to create temporary file %s.", tmp_file);
100 #endif
101             msg_print(NULL);
102             return;
103         }
104
105         /* Loop for every line */
106         while (TRUE)
107         {
108                 /* Read a line */
109                 if (my_fgets(orig_fff, buf, sizeof(buf)))
110                 {
111                         /* Read error: Assume End of File */
112
113                         /*
114                          * Was looking for the footer, but not found.
115                          *
116                          * Since automatic dump might be edited by hand,
117                          * it's dangerous to kill these lines.
118                          * Seek back to the next line of the (pseudo) header,
119                          * and read again.
120                          */
121                         if (between_mark)
122                         {
123                                 fseek(orig_fff, header_location, SEEK_SET);
124                                 between_mark = FALSE;
125                                 continue;
126                         }
127
128                         /* Success -- End the loop */
129                         else
130                         {
131                                 break;
132                         }
133                 }
134
135                 /* We are looking for the header mark of automatic dump */
136                 if (!between_mark)
137                 {
138                         /* Is this line a header? */
139                         if (!strcmp(buf, header_mark_str))
140                         {
141                                 /* Memorise seek point of this line */
142                                 header_location = ftell(orig_fff);
143
144                                 /* Initialize counter for number of lines */
145                                 line_num = 0;
146
147                                 /* Look for the footer from now */
148                                 between_mark = TRUE;
149
150                                 /* There are some changes */
151                                 changed = TRUE;
152                         }
153
154                         /* Not a header */
155                         else
156                         {
157                                 /* Copy orginally lines */
158                                 fprintf(tmp_fff, "%s\n", buf);
159                         }
160                 }
161
162                 /* We are looking for the footer mark of automatic dump */
163                 else
164                 {
165                         /* Is this line a footer? */
166                         if (!strncmp(buf, footer_mark_str, mark_len))
167                         {
168                                 int tmp;
169
170                                 /*
171                                  * Compare the number of lines
172                                  *
173                                  * If there is an inconsistency between
174                                  * actual number of lines and the
175                                  * number here, the automatic dump
176                                  * might be edited by hand.  So it's
177                                  * dangerous to kill these lines.
178                                  * Seek back to the next line of the
179                                  * (pseudo) header, and read again.
180                                  */
181                                 if (!sscanf(buf + mark_len, " (%d)", &tmp)
182                                     || tmp != line_num)
183                                 {
184                                         fseek(orig_fff, header_location, SEEK_SET);
185                                 }
186
187                                 /* Look for another header */
188                                 between_mark = FALSE;
189                         }
190
191                         /* Not a footer */
192                         else
193                         {
194                                 /* Ignore old line, and count number of lines */
195                                 line_num++;
196                         }
197                 }
198         }
199
200         /* Close files */
201         my_fclose(orig_fff);
202         my_fclose(tmp_fff);
203
204         /* If there are some changes, overwrite the original file with new one */
205         if (changed)
206         {
207                 /* Copy contents of temporary file */
208
209                 tmp_fff = my_fopen(tmp_file, "r");
210                 orig_fff = my_fopen(orig_file, "w");
211
212                 while (!my_fgets(tmp_fff, buf, sizeof(buf)))
213                         fprintf(orig_fff, "%s\n", buf);
214
215                 my_fclose(orig_fff);
216                 my_fclose(tmp_fff);
217         }
218
219         /* Kill the temporary file */
220         fd_kill(tmp_file);
221
222         return;
223 }
224
225
226 /*
227  * Dump a formatted line, using "vstrnfmt()".
228  */
229 static void auto_dump_printf(cptr fmt, ...)
230 {
231         cptr p;
232         va_list vp;
233
234         char buf[1024];
235
236         /* Begin the Varargs Stuff */
237         va_start(vp, fmt);
238
239         /* Format the args, save the length */
240         (void)vstrnfmt(buf, sizeof(buf), fmt, vp);
241
242         /* End the Varargs Stuff */
243         va_end(vp);
244
245         /* Count number of lines */
246         for (p = buf; *p; p++)
247         {
248                 if (*p == '\n') auto_dump_line_num++;
249         }
250
251         /* Dump it */
252         fprintf(auto_dump_stream, "%s", buf);
253 }
254
255
256 /*
257  *  Open file to append auto dump.
258  */
259 static bool open_auto_dump(cptr buf, cptr mark)
260 {
261
262         char header_mark_str[80];
263
264         /* Save the mark string */
265         auto_dump_mark = mark;
266
267         /* Prepare a header mark string */
268         sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
269
270         /* Remove old macro dumps */
271         remove_auto_dump(buf);
272
273         /* Append to the file */
274         auto_dump_stream = my_fopen(buf, "a");
275
276         /* Failure */
277         if (!auto_dump_stream) {
278 #ifdef JP
279                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
280 #else
281                 msg_format("Failed to open %s.", buf);
282 #endif
283                 msg_print(NULL);
284
285                 /* Failed */
286                 return FALSE;
287         }
288
289         /* Start dumping */
290         fprintf(auto_dump_stream, "%s\n", header_mark_str);
291
292         /* Initialize counter */
293         auto_dump_line_num = 0;
294
295 #ifdef JP
296         auto_dump_printf("# *·Ù¹ð!!* °Ê¹ß¤Î¹Ô¤Ï¼«Æ°À¸À®¤µ¤ì¤¿¤â¤Î¤Ç¤¹¡£\n");
297         auto_dump_printf("# *·Ù¹ð!!* ¸å¤Ç¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤ë¤Î¤ÇÊÔ½¸¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£\n");
298 #else
299         auto_dump_printf("# *Warning!*  The lines below are an automatic dump.\n");
300         auto_dump_printf("# Don't edit them; changes will be deleted and replaced automatically.\n");
301 #endif
302
303         /* Success */
304         return TRUE;
305 }
306
307 /*
308  *  Append foot part and close auto dump.
309  */
310 static void close_auto_dump(void)
311 {
312         char footer_mark_str[80];
313
314         /* Prepare a footer mark string */
315         sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
316
317 #ifdef JP
318         auto_dump_printf("# *·Ù¹ð!!* °Ê¾å¤Î¹Ô¤Ï¼«Æ°À¸À®¤µ¤ì¤¿¤â¤Î¤Ç¤¹¡£\n");
319         auto_dump_printf("# *·Ù¹ð!!* ¸å¤Ç¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤ë¤Î¤ÇÊÔ½¸¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£\n");
320 #else
321         auto_dump_printf("# *Warning!*  The lines above are an automatic dump.\n");
322         auto_dump_printf("# Don't edit them; changes will be deleted and replaced automatically.\n");
323 #endif
324
325         /* End of dump */
326         fprintf(auto_dump_stream, "%s (%d)\n", footer_mark_str, auto_dump_line_num);
327
328         /* Close */
329         my_fclose(auto_dump_stream);
330
331         return;
332 }
333
334
335 #ifndef JP
336 /*
337  * Return suffix of ordinal number
338  */
339 cptr get_ordinal_number_suffix(int num)
340 {
341         num = ABS(num) % 100;
342         switch (num % 10)
343         {
344         case 1:
345                 return (num == 11) ? "th" : "st";
346         case 2:
347                 return (num == 12) ? "th" : "nd";
348         case 3:
349                 return (num == 13) ? "th" : "rd";
350         default:
351                 return "th";
352         }
353 }
354 #endif
355
356
357 /*
358  *   Take note to the diary.
359  */
360 errr do_cmd_write_nikki(int type, int num, cptr note)
361 {
362         int day, hour, min;
363         FILE *fff = NULL;
364         char file_name[80];
365         char buf[1024];
366         cptr note_level = "";
367         bool do_level = TRUE;
368         char note_level_buf[40];
369         int q_idx;
370
371         static bool disable_nikki = FALSE;
372
373         extract_day_hour_min(&day, &hour, &min);
374
375         if (disable_nikki) return(-1);
376
377         if (type == NIKKI_FIX_QUEST_C ||
378             type == NIKKI_FIX_QUEST_F ||
379             type == NIKKI_RAND_QUEST_C ||
380             type == NIKKI_RAND_QUEST_F ||
381             type == NIKKI_TO_QUEST)
382         {
383                 int old_quest;
384
385                 old_quest = p_ptr->inside_quest;
386                 p_ptr->inside_quest = (quest[num].type == QUEST_TYPE_RANDOM) ? 0 : num;
387
388                 /* Get the quest text */
389                 init_flags = INIT_ASSIGN;
390
391                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
392
393                 /* Reset the old quest number */
394                 p_ptr->inside_quest = old_quest;
395         }
396
397 #ifdef JP
398         sprintf(file_name,"playrecord-%s.txt",savefile_base);
399 #else
400         /* different filne name to avoid mixing */
401         sprintf(file_name,"playrec-%s.txt",savefile_base);
402 #endif
403
404         /* Build the filename */
405         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
406
407         /* File type is "TEXT" */
408         FILE_TYPE(FILE_TYPE_TEXT);
409
410         fff = my_fopen(buf, "a");
411
412         /* Failure */
413         if (!fff)
414         {
415 #ifdef JP
416                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£¥×¥ì¥¤µ­Ï¿¤ò°ì»þÄä»ß¤·¤Þ¤¹¡£", buf);
417 #else
418                 msg_format("Failed to open %s. Play-Record is disabled temporally.", buf);
419 #endif
420                 msg_format(NULL);
421                 disable_nikki=TRUE;
422                 return (-1);
423         }
424
425         q_idx = quest_number(dun_level);
426
427         if (write_level)
428         {
429                 if (p_ptr->inside_arena)
430 #ifdef JP
431                         note_level = "¥¢¥ê¡¼¥Ê:";
432 #else
433                         note_level = "Arane:";
434 #endif
435                 else if (!dun_level)
436 #ifdef JP
437                         note_level = "ÃϾå:";
438 #else
439                         note_level = "Surface:";
440 #endif
441                 else if (q_idx && (is_fixed_quest_idx(q_idx)
442                          && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
443 #ifdef JP
444                         note_level = "¥¯¥¨¥¹¥È:";
445 #else
446                         note_level = "Quest:";
447 #endif
448                 else
449                 {
450 #ifdef JP
451                         sprintf(note_level_buf, "%d³¬(%s):", dun_level, d_name+d_info[dungeon_type].name);
452 #else
453                         sprintf(note_level_buf, "%s L%d:", d_name+d_info[dungeon_type].name, dun_level);
454 #endif
455                         note_level = note_level_buf;
456                 }
457         }
458
459         switch(type)
460         {
461                 case NIKKI_HIGAWARI:
462                 {
463 #ifdef JP
464                         if (day < MAX_DAYS) fprintf(fff, "%dÆüÌÜ\n", day);
465                         else fputs("*****ÆüÌÜ\n", fff);
466 #else
467                         if (day < MAX_DAYS) fprintf(fff, "Day %d\n", day);
468                         else fputs("Day *****\n", fff);
469 #endif
470                         do_level = FALSE;
471                         break;
472                 }
473                 case NIKKI_BUNSHOU:
474                 {
475                         if (num)
476                         {
477                                 fprintf(fff, "%s\n",note);
478                                 do_level = FALSE;
479                         }
480                         else
481                                 fprintf(fff, " %2d:%02d %20s %s\n",hour, min, note_level, note);
482                         break;
483                 }
484                 case NIKKI_ART:
485                 {
486 #ifdef JP
487                         fprintf(fff, " %2d:%02d %20s %s¤òȯ¸«¤·¤¿¡£\n", hour, min, note_level, note);
488 #else
489                         fprintf(fff, " %2d:%02d %20s discovered %s.\n", hour, min, note_level, note);
490 #endif
491                         break;
492                 }
493                 case NIKKI_UNIQUE:
494                 {
495 #ifdef JP
496                         fprintf(fff, " %2d:%02d %20s %s¤òÅݤ·¤¿¡£\n", hour, min, note_level, note);
497 #else
498                         fprintf(fff, " %2d:%02d %20s defeated %s.\n", hour, min, note_level, note);
499 #endif
500                         break;
501                 }
502                 case NIKKI_FIX_QUEST_C:
503                 {
504                         if (quest[num].flags & QUEST_FLAG_SILENT) break;
505 #ifdef JP
506                         fprintf(fff, " %2d:%02d %20s ¥¯¥¨¥¹¥È¡Ö%s¡×¤òãÀ®¤·¤¿¡£\n", hour, min, note_level, quest[num].name);
507 #else
508                         fprintf(fff, " %2d:%02d %20s completed quest '%s'.\n", hour, min, note_level, quest[num].name);
509 #endif
510                         break;
511                 }
512                 case NIKKI_FIX_QUEST_F:
513                 {
514                         if (quest[num].flags & QUEST_FLAG_SILENT) break;
515 #ifdef JP
516                         fprintf(fff, " %2d:%02d %20s ¥¯¥¨¥¹¥È¡Ö%s¡×¤«¤éÌ¿¤«¤é¤¬¤éƨ¤²µ¢¤Ã¤¿¡£\n", hour, min, note_level, quest[num].name);
517 #else
518                         fprintf(fff, " %2d:%02d %20s run away from quest '%s'.\n", hour, min, note_level, quest[num].name);
519 #endif
520                         break;
521                 }
522                 case NIKKI_RAND_QUEST_C:
523                 {
524                         char name[80];
525                         strcpy(name, r_name+r_info[quest[num].r_idx].name);
526 #ifdef JP
527                         fprintf(fff, " %2d:%02d %20s ¥é¥ó¥À¥à¥¯¥¨¥¹¥È(%s)¤òãÀ®¤·¤¿¡£\n", hour, min, note_level, name);
528 #else
529                         fprintf(fff, " %2d:%02d %20s completed random quest '%s'\n", hour, min, note_level, name);
530 #endif
531                         break;
532                 }
533                 case NIKKI_RAND_QUEST_F:
534                 {
535                         char name[80];
536                         strcpy(name, r_name+r_info[quest[num].r_idx].name);
537 #ifdef JP
538                         fprintf(fff, " %2d:%02d %20s ¥é¥ó¥À¥à¥¯¥¨¥¹¥È(%s)¤«¤éƨ¤²½Ð¤·¤¿¡£\n", hour, min, note_level, name);
539 #else
540                         fprintf(fff, " %2d:%02d %20s ran away from quest '%s'.\n", hour, min, note_level, name);
541 #endif
542                         break;
543                 }
544                 case NIKKI_MAXDEAPTH:
545                 {
546 #ifdef JP
547                         fprintf(fff, " %2d:%02d %20s %s¤ÎºÇ¿¼³¬%d³¬¤ËÅþ㤷¤¿¡£\n", hour, min, note_level, d_name+d_info[dungeon_type].name, num);
548 #else
549                         fprintf(fff, " %2d:%02d %20s reached level %d of %s for the first time.\n", hour, min, note_level, num, d_name+d_info[dungeon_type].name);
550 #endif
551                         break;
552                 }
553                 case NIKKI_TRUMP:
554                 {
555 #ifdef JP
556                         fprintf(fff, " %2d:%02d %20s %s%s¤ÎºÇ¿¼³¬¤ò%d³¬¤Ë¥»¥Ã¥È¤·¤¿¡£\n", hour, min, note_level, note, d_name + d_info[num].name, max_dlv[num]);
557 #else
558                         fprintf(fff, " %2d:%02d %20s reset recall level of %s to %d %s.\n", hour, min, note_level, d_name + d_info[num].name, max_dlv[num], note);
559 #endif
560                         break;
561                 }
562                 case NIKKI_STAIR:
563                 {
564                         cptr to;
565                         if (q_idx && (is_fixed_quest_idx(q_idx)
566                              && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
567                         {
568 #ifdef JP
569                                 to = "ÃϾå";
570 #else
571                                 to = "the surface";
572 #endif
573                         }
574                         else
575                         {
576 #ifdef JP
577                                 if (!(dun_level+num)) to = "ÃϾå";
578                                 else to = format("%d³¬", dun_level+num);
579 #else
580                                 if (!(dun_level+num)) to = "the surface";
581                                 else to = format("level %d", dun_level+num);
582 #endif
583                         }
584
585 #ifdef JP 
586                         fprintf(fff, " %2d:%02d %20s %s¤Ø%s¡£\n", hour, min, note_level, to, note);
587 #else
588                         fprintf(fff, " %2d:%02d %20s %s %s.\n", hour, min, note_level, note, to);
589 #endif
590                         break;
591                 }
592                 case NIKKI_RECALL:
593                 {
594                         if (!num)
595 #ifdef JP
596                                 fprintf(fff, " %2d:%02d %20s µ¢´Ô¤ò»È¤Ã¤Æ%s¤Î%d³¬¤Ø²¼¤ê¤¿¡£\n", hour, min, note_level, d_name+d_info[dungeon_type].name, max_dlv[dungeon_type]);
597 #else
598                                 fprintf(fff, " %2d:%02d %20s recalled to dungeon level %d of %s.\n", hour, min, note_level, max_dlv[dungeon_type], d_name+d_info[dungeon_type].name);
599 #endif
600                         else
601 #ifdef JP
602                                 fprintf(fff, " %2d:%02d %20s µ¢´Ô¤ò»È¤Ã¤ÆÃϾå¤Ø¤ÈÌá¤Ã¤¿¡£\n", hour, min, note_level);
603 #else
604                                 fprintf(fff, " %2d:%02d %20s recalled from dungeon to surface.\n", hour, min, note_level);
605 #endif
606                         break;
607                 }
608                 case NIKKI_TO_QUEST:
609                 {
610                         if (quest[num].flags & QUEST_FLAG_SILENT) break;
611 #ifdef JP
612                         fprintf(fff, " %2d:%02d %20s ¥¯¥¨¥¹¥È¡Ö%s¡×¤Ø¤ÈÆÍÆþ¤·¤¿¡£\n", hour, min, note_level, quest[num].name);
613 #else
614                         fprintf(fff, " %2d:%02d %20s entered the quest '%s'.\n", hour, min, note_level, quest[num].name);
615 #endif
616                         break;
617                 }
618                 case NIKKI_TELE_LEV:
619                 {
620 #ifdef JP
621                         fprintf(fff, " %2d:%02d %20s ¥ì¥Ù¥ë¡¦¥Æ¥ì¥Ý¡¼¥È¤Çæ½Ð¤·¤¿¡£\n", hour, min, note_level);
622 #else
623                         fprintf(fff, " %2d:%02d %20s Got out using teleport level.\n", hour, min, note_level);
624 #endif
625                         break;
626                 }
627                 case NIKKI_BUY:
628                 {
629 #ifdef JP
630                         fprintf(fff, " %2d:%02d %20s %s¤ò¹ØÆþ¤·¤¿¡£\n", hour, min, note_level, note);
631 #else
632                         fprintf(fff, " %2d:%02d %20s bought %s.\n", hour, min, note_level, note);
633 #endif
634                         break;
635                 }
636                 case NIKKI_SELL:
637                 {
638 #ifdef JP
639                         fprintf(fff, " %2d:%02d %20s %s¤òÇäµÑ¤·¤¿¡£\n", hour, min, note_level, note);
640 #else
641                         fprintf(fff, " %2d:%02d %20s sold %s.\n", hour, min, note_level, note);
642 #endif
643                         break;
644                 }
645                 case NIKKI_ARENA:
646                 {
647                         if (num < 0)
648                         {
649 #ifdef JP
650                                 fprintf(fff, " %2d:%02d %20s Æ®µ»¾ì¤Î%d²óÀï¤Ç¡¢%s¤ÎÁ°¤ËÇÔ¤ìµî¤Ã¤¿¡£\n", hour, min, note_level, -num, note);
651 #else
652                                 int n = -num;
653                                 fprintf(fff, " %2d:%02d %20s beaten by %s in the %d%s fight.\n", hour, min, note_level, note, n, get_ordinal_number_suffix(n));
654 #endif
655                                 break;
656                         }
657 #ifdef JP
658                         fprintf(fff, " %2d:%02d %20s Æ®µ»¾ì¤Î%d²óÀï(%s)¤Ë¾¡Íø¤·¤¿¡£\n", hour, min, note_level, num, note);
659 #else
660                         fprintf(fff, " %2d:%02d %20s won the %d%s fight (%s).\n", hour, min, note_level, num, get_ordinal_number_suffix(num), note);
661 #endif
662                         if (num == MAX_ARENA_MONS)
663                         {
664 #ifdef JP
665                                 fprintf(fff, "                 Æ®µ»¾ì¤Î¤¹¤Ù¤Æ¤ÎŨ¤Ë¾¡Íø¤·¡¢¥Á¥ã¥ó¥Ô¥ª¥ó¤È¤Ê¤Ã¤¿¡£\n");
666 #else
667                                 fprintf(fff, "                 won all fight to become a Chanpion.\n");
668 #endif
669                                 do_level = FALSE;
670                         }
671                         break;
672                 }
673                 case NIKKI_HANMEI:
674                 {
675 #ifdef JP
676                         fprintf(fff, " %2d:%02d %20s %s¤ò¼±Ê̤·¤¿¡£\n", hour, min, note_level, note);
677 #else
678                         fprintf(fff, " %2d:%02d %20s identified %s.\n", hour, min, note_level, note);
679 #endif
680                         break;
681                 }
682                 case NIKKI_WIZ_TELE:
683                 {
684                         cptr to;
685                         if (!dun_level)
686 #ifdef JP
687                                 to = "ÃϾå";
688 #else
689                                 to = "the surface";
690 #endif
691                         else
692 #ifdef JP
693                                 to = format("%d³¬(%s)", dun_level, d_name+d_info[dungeon_type].name);
694 #else
695                                 to = format("level %d of %s", dun_level, d_name+d_info[dungeon_type].name);
696 #endif
697
698 #ifdef JP
699                         fprintf(fff, " %2d:%02d %20s %s¤Ø¤È¥¦¥£¥¶¡¼¥É¡¦¥Æ¥ì¥Ý¡¼¥È¤Ç°ÜÆ°¤·¤¿¡£\n", hour, min, note_level, to);
700 #else
701                         fprintf(fff, " %2d:%02d %20s wizard-teleport to %s.\n", hour, min, note_level, to);
702 #endif
703                         break;
704                 }
705                 case NIKKI_PAT_TELE:
706                 {
707                         cptr to;
708                         if (!dun_level)
709 #ifdef JP
710                                 to = "ÃϾå";
711 #else
712                                 to = "the surface";
713 #endif
714                         else
715 #ifdef JP
716                                 to = format("%d³¬(%s)", dun_level, d_name+d_info[dungeon_type].name);
717 #else
718                                 to = format("level %d of %s", dun_level, d_name+d_info[dungeon_type].name);
719 #endif
720
721 #ifdef JP
722                         fprintf(fff, " %2d:%02d %20s %s¤Ø¤È¥Ñ¥¿¡¼¥ó¤ÎÎϤǰÜÆ°¤·¤¿¡£\n", hour, min, note_level, to);
723 #else
724                         fprintf(fff, " %2d:%02d %20s used Pattern to teleport to %s.\n", hour, min, note_level, to);
725 #endif
726                         break;
727                 }
728                 case NIKKI_LEVELUP:
729                 {
730 #ifdef JP
731                         fprintf(fff, " %2d:%02d %20s ¥ì¥Ù¥ë¤¬%d¤Ë¾å¤¬¤Ã¤¿¡£\n", hour, min, note_level, num);
732 #else
733                         fprintf(fff, " %2d:%02d %20s reached player level %d.\n", hour, min, note_level, num);
734 #endif
735                         break;
736                 }
737                 case NIKKI_GAMESTART:
738                 {
739                         time_t ct = time((time_t*)0);
740                         do_level = FALSE;
741                         if (num)
742                         {
743                                 fprintf(fff, "%s %s",note, ctime(&ct));
744                         }
745                         else
746                                 fprintf(fff, " %2d:%02d %20s %s %s",hour, min, note_level, note, ctime(&ct));
747                         break;
748                 }
749                 case NIKKI_NAMED_PET:
750                 {
751                         fprintf(fff, " %2d:%02d %20s ", hour, min, note_level);
752                         switch (num)
753                         {
754                                 case RECORD_NAMED_PET_NAME:
755 #ifdef JP
756                                         fprintf(fff, "%s¤òι¤Îͧ¤Ë¤¹¤ë¤³¤È¤Ë·è¤á¤¿¡£\n", note);
757 #else
758                                         fprintf(fff, "decided to travel together with %s.\n", note);
759 #endif
760                                         break;
761                                 case RECORD_NAMED_PET_UNNAME:
762 #ifdef JP
763                                         fprintf(fff, "%s¤Î̾Á°¤ò¾Ã¤·¤¿¡£\n", note);
764 #else
765                                         fprintf(fff, "unnamed %s.\n", note);
766 #endif
767                                         break;
768                                 case RECORD_NAMED_PET_DISMISS:
769 #ifdef JP
770                                         fprintf(fff, "%s¤ò²òÊü¤·¤¿¡£\n", note);
771 #else
772                                         fprintf(fff, "dismissed %s.\n", note);
773 #endif
774                                         break;
775                                 case RECORD_NAMED_PET_DEATH:
776 #ifdef JP
777                                         fprintf(fff, "%s¤¬»à¤ó¤Ç¤·¤Þ¤Ã¤¿¡£\n", note);
778 #else
779                                         fprintf(fff, "%s died.\n", note);
780 #endif
781                                         break;
782                                 case RECORD_NAMED_PET_MOVED:
783 #ifdef JP
784                                         fprintf(fff, "%s¤ò¤ª¤¤¤ÆÊ̤ΥޥåפذÜÆ°¤·¤¿¡£\n", note);
785 #else
786                                         fprintf(fff, "moved to another map leaving %s behind.\n", note);
787 #endif
788                                         break;
789                                 case RECORD_NAMED_PET_LOST_SIGHT:
790 #ifdef JP
791                                         fprintf(fff, "%s¤È¤Ï¤°¤ì¤Æ¤·¤Þ¤Ã¤¿¡£\n", note);
792 #else
793                                         fprintf(fff, "lost sight of %s.\n", note);
794 #endif
795                                         break;
796                                 case RECORD_NAMED_PET_DESTROY:
797 #ifdef JP
798                                         fprintf(fff, "%s¤¬*Ç˲õ*¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
799 #else
800                                         fprintf(fff, "%s was made disappeared by *destruction*.\n", note);
801 #endif
802                                         break;
803                                 case RECORD_NAMED_PET_EARTHQUAKE:
804 #ifdef JP
805                                         fprintf(fff, "%s¤¬´äÀФ˲¡¤·ÄÙ¤µ¤ì¤¿¡£\n", note);
806 #else
807                                         fprintf(fff, "%s was crushed by falling rocks.\n", note);
808 #endif
809                                         break;
810                                 case RECORD_NAMED_PET_GENOCIDE:
811 #ifdef JP
812                                         fprintf(fff, "%s¤¬Ëõ»¦¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
813 #else
814                                         fprintf(fff, "%s was made disappeared by genocide.\n", note);
815 #endif
816                                         break;
817                                 case RECORD_NAMED_PET_WIZ_ZAP:
818 #ifdef JP
819                                         fprintf(fff, "%s¤¬¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
820 #else
821                                         fprintf(fff, "%s was removed by debug command.\n", note);
822 #endif
823                                         break;
824                                 case RECORD_NAMED_PET_TELE_LEVEL:
825 #ifdef JP
826                                         fprintf(fff, "%s¤¬¥Æ¥ì¥Ý¡¼¥È¡¦¥ì¥Ù¥ë¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
827 #else
828                                         fprintf(fff, "%s was made disappeared by teleport level.\n", note);
829 #endif
830                                         break;
831                                 case RECORD_NAMED_PET_BLAST:
832 #ifdef JP
833                                         fprintf(fff, "%s¤òÇúÇˤ·¤¿¡£\n", note);
834 #else
835                                         fprintf(fff, "blasted %s.\n", note);
836 #endif
837                                         break;
838                                 case RECORD_NAMED_PET_HEAL_LEPER:
839 #ifdef JP
840                                         fprintf(fff, "%s¤Îɵ¤¤¬¼£¤ê餫¤é³°¤ì¤¿¡£\n", note);
841 #else
842                                         fprintf(fff, "%s was healed and left.\n", note);
843 #endif
844                                         break;
845                                 case RECORD_NAMED_PET_COMPACT:
846 #ifdef JP
847                                         fprintf(fff, "%s¤¬¥â¥ó¥¹¥¿¡¼¾ðÊ󰵽̤ˤè¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
848 #else
849                                         fprintf(fff, "%s was made disappeared by compacting monsters.\n", note);
850 #endif
851                                         break;
852                                 case RECORD_NAMED_PET_LOSE_PARENT:
853 #ifdef JP
854                                         fprintf(fff, "%s¤Î¾¤´­¼Ô¤¬´û¤Ë¤¤¤Ê¤¤¤¿¤á¾Ã¤¨µî¤Ã¤¿¡£\n", note);
855 #else
856                                         fprintf(fff, "%s disappeared because there does not exist summoner.\n", note);
857 #endif
858                                         break;
859                                 default:
860                                         fprintf(fff, "\n");
861                                         break;
862                         }
863                         break;
864                 }
865                 default:
866                         break;
867         }
868
869         my_fclose(fff);
870
871         if (do_level) write_level = FALSE;
872
873         return (0);
874 }
875
876
877 #define MAX_SUBTITLE (sizeof(subtitle)/sizeof(subtitle[0]))
878
879 static void do_cmd_disp_nikki(void)
880 {
881         char nikki_title[256];
882         char file_name[80];
883         char buf[1024];
884         char tmp[80];
885 #ifdef JP
886         static const char subtitle[][30] = {"ºÇ¶¯¤ÎÆùÂΤòµá¤á¤Æ",
887                                            "¿ÍÀ¸¤½¤ì¤Ï¤Ï¤«¤Ê¤¤",
888                                            "ÌÀÆü¤Ë¸þ¤«¤Ã¤Æ",
889                                            "꤫¤é¤Ü¤¿¤â¤Á",
890                                            "¤¢¤È¤Îº×¤ê",
891                                            "¤½¤ì¤Ï¤¤¤¤¹Í¤¨¤À",
892                                            "²¿¤È¤Ç¤â¸À¤¨",
893                                            "ÅƤˤâ³Ñ¤Ë¤â",
894                                            "¥¦¥½¤À¤±¤É",
895                                            "¤â¤Ï¤ä¤³¤ì¤Þ¤Ç",
896                                            "¤Ê¤ó¤Ç¤³¤¦¤Ê¤ë¤Î",
897                                            "¤½¤ì¤Ï̵Íý¤À",
898                                            "Åݤ¹¤Ù¤­Å¨¤Ï¥²¡û¥Ä",
899                                            "¤ó¡Á¡©Ê¹¤³¤¨¤ó¤Ê¤¡",
900                                            "¥ª¥ì¤Î̾¤ò¸À¤Ã¤Æ¤ß¤í",
901                                            "Ƭ¤¬ÊѤˤʤäÁ¤ã¤Ã¤¿",
902                                            "¸ß´¹¤·¤Þ¤»¤ó",
903                                            "¤»¤Ã¤«¤¯¤À¤«¤é",
904                                            "¤Þ¤À¤Þ¤À´Å¤¤¤Í",
905                                            "¤à¤´¤¤¤à¤´¤¹¤®¤ë",
906                                            "¤³¤ó¤Ê¤â¤ó¤¸¤ã¤Ê¤¤",
907                                            "¤À¤á¤À¤³¤ê¤ã",
908                                            "¼¡¤¤¤Ã¤Æ¤ß¤è¤¦",
909                                            "¤Á¤ç¤Ã¤È¤À¤±¤è",
910                                            "°¥¤·¤­ËÁ¸±¼Ô",
911                                            "Ìî˾¤Î²Ì¤Æ",
912                                            "̵¸ÂÃϹö",
913                                            "¿À¤Ë·ö²Þ¤òÇä¤ë¼Ô",
914                                            "̤ÃΤÎÀ¤³¦¤Ø",
915                                            "ºÇ¹â¤ÎƬǾ¤òµá¤á¤Æ"};
916 #else
917         static const char subtitle[][51] ={"Quest of The World's Toughest Body",
918                                            "Attack is the best form of defence.",
919                                            "Might is right.",
920                                            "An unexpected windfall",
921                                            "A drowning man will catch at a straw",
922                                            "Don't count your chickens before they are hatched.",
923                                            "It is no use crying over spilt milk.",
924                                            "Seeing is believing.",
925                                            "Strike the iron while it is hot.",
926                                            "I don't care what follows.",
927                                            "To dig a well to put out a house on fire.",
928                                            "Tomorrow is another day.",
929                                            "Easy come, easy go.",
930                                            "The more haste, the less speed.",
931                                            "Where there is life, there is hope.",
932                                            "There is no royal road to *WINNER*.",
933                                            "Danger past, God forgotten.",
934                                            "The best thing to do now is to run away.",
935                                            "Life is but an empty dream.",
936                                            "Dead men tell no tales.",
937                                            "A book that remains shut is but a block.",
938                                            "Misfortunes never come singly.",
939                                            "A little knowledge is a dangerous thing.",
940                                            "History repeats itself.",
941                                            "*WINNER* was not built in a day.",
942                                            "Ignorance is bliss.",
943                                            "To lose is to win?",
944                                            "No medicine can cure folly.",
945                                            "All good things come to an end.",
946                                            "M$ Empire strikes back.",
947                                            "To see is to believe",
948                                            "Time is money.",
949                                            "Quest of The World's Greatest Brain"};
950 #endif
951 #ifdef JP
952         sprintf(file_name,"playrecord-%s.txt",savefile_base);
953 #else
954         sprintf(file_name,"playrec-%s.txt",savefile_base);
955 #endif
956
957         /* Build the filename */
958         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
959
960         if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_MONK || p_ptr->pclass == CLASS_SAMURAI || p_ptr->pclass == CLASS_BERSERKER)
961                 strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-1)]);
962         else if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)
963                 strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-1)+1]);
964         else strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-2)+1]);
965
966 #ifdef JP
967         sprintf(nikki_title, "¡Ö%s%s%s¤ÎÅÁÀâ -%s-¡×",
968                 ap_ptr->title, ap_ptr->no ? "¤Î" : "", player_name, tmp);
969 #else
970         sprintf(nikki_title, "Legend of %s %s '%s'",
971                 ap_ptr->title, player_name, tmp);
972 #endif
973
974         /* Display the file contents */
975         show_file(FALSE, buf, nikki_title, -1, 0);
976 }
977
978 static void do_cmd_bunshou(void)
979 {
980         char tmp[80] = "\0";
981         char bunshou[80] = "\0";
982
983 #ifdef JP
984         if (get_string("ÆâÍÆ: ", tmp, 79))
985 #else
986         if (get_string("diary note: ", tmp, 79))
987 #endif
988         {
989                 strcpy(bunshou, tmp);
990
991                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, bunshou);
992         }
993 }
994
995 static void do_cmd_last_get(void)
996 {
997         char buf[256];
998         s32b turn_tmp;
999
1000         if (record_o_name[0] == '\0') return;
1001
1002 #ifdef JP
1003         sprintf(buf,"%s¤ÎÆþ¼ê¤òµ­Ï¿¤·¤Þ¤¹¡£",record_o_name);
1004 #else
1005         sprintf(buf,"Do you really want to record getting %s? ",record_o_name);
1006 #endif
1007         if (!get_check(buf)) return;
1008
1009         turn_tmp = turn;
1010         turn = record_turn;
1011 #ifdef JP
1012         sprintf(buf,"%s¤ò¼ê¤ËÆþ¤ì¤¿¡£", record_o_name);
1013 #else
1014         sprintf(buf,"descover %s.", record_o_name);
1015 #endif
1016         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
1017         turn = turn_tmp;
1018 }
1019
1020 static void do_cmd_erase_nikki(void)
1021 {
1022         char file_name[80];
1023         char buf[256];
1024         FILE *fff = NULL;
1025
1026 #ifdef JP
1027         if (!get_check("ËÜÅö¤Ëµ­Ï¿¤ò¾Ãµî¤·¤Þ¤¹¤«¡©")) return;
1028 #else
1029         if (!get_check("Do you really want to delete all your record? ")) return;
1030 #endif
1031
1032 #ifdef JP
1033         sprintf(file_name,"playrecord-%s.txt",savefile_base);
1034 #else
1035         sprintf(file_name,"playrec-%s.txt",savefile_base);
1036 #endif
1037
1038         /* Build the filename */
1039         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
1040
1041         /* Remove the file */
1042         fd_kill(buf);
1043
1044         fff = my_fopen(buf, "w");
1045         if(fff){
1046                 my_fclose(fff);
1047 #ifdef JP
1048                 msg_format("µ­Ï¿¤ò¾Ãµî¤·¤Þ¤·¤¿¡£");
1049 #else
1050                 msg_format("deleted record.");
1051 #endif
1052         }else{
1053 #ifdef JP
1054                 msg_format("%s ¤Î¾Ãµî¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", buf);
1055 #else
1056                 msg_format("failed to delete %s.", buf);
1057 #endif
1058         }
1059         msg_print(NULL);
1060 }
1061
1062
1063 void do_cmd_nikki(void)
1064 {
1065         int i;
1066
1067         /* File type is "TEXT" */
1068         FILE_TYPE(FILE_TYPE_TEXT);
1069
1070         /* Save the screen */
1071         screen_save();
1072
1073         /* Interact until done */
1074         while (1)
1075         {
1076                 /* Clear screen */
1077                 Term_clear();
1078
1079                 /* Ask for a choice */
1080 #ifdef JP
1081                 prt("[ µ­Ï¿¤ÎÀßÄê ]", 2, 0);
1082 #else
1083                 prt("[ Play Record ]", 2, 0);
1084 #endif
1085
1086
1087                 /* Give some choices */
1088 #ifdef JP
1089                 prt("(1) µ­Ï¿¤ò¸«¤ë", 4, 5);
1090                 prt("(2) Ê¸¾Ï¤òµ­Ï¿¤¹¤ë", 5, 5);
1091                 prt("(3) Ä¾Á°¤ËÆþ¼êËô¤Ï´ÕÄꤷ¤¿¤â¤Î¤òµ­Ï¿¤¹¤ë", 6, 5);
1092                 prt("(4) µ­Ï¿¤ò¾Ãµî¤¹¤ë", 7, 5);
1093 #else
1094                 prt("(1) Display your record", 4, 5);
1095                 prt("(2) Add record", 5, 5);
1096                 prt("(3) Record item you last get/identify", 6, 5);
1097                 prt("(4) Delete your record", 7, 5);
1098 #endif
1099
1100
1101                 /* Prompt */
1102 #ifdef JP
1103                 prt("¥³¥Þ¥ó¥É:", 18, 0);
1104 #else
1105                 prt("Command: ", 18, 0);
1106 #endif
1107
1108
1109                 /* Prompt */
1110                 i = inkey();
1111
1112                 /* Done */
1113                 if (i == ESCAPE) break;
1114
1115                 switch (i)
1116                 {
1117                 case '1':
1118                         do_cmd_disp_nikki();
1119                         break;
1120                 case '2':
1121                         do_cmd_bunshou();
1122                         break;
1123                 case '3':
1124                         do_cmd_last_get();
1125                         break;
1126                 case '4':
1127                         do_cmd_erase_nikki();
1128                         break;
1129                 default: /* Unknown option */
1130                         bell();
1131                 }
1132
1133                 /* Flush messages */
1134                 msg_print(NULL);
1135         }
1136
1137         /* Restore the screen */
1138         screen_load();
1139 }
1140
1141 /*
1142  * Hack -- redraw the screen
1143  *
1144  * This command performs various low level updates, clears all the "extra"
1145  * windows, does a total redraw of the main window, and requests all of the
1146  * interesting updates and redraws that I can think of.
1147  *
1148  * This command is also used to "instantiate" the results of the user
1149  * selecting various things, such as graphics mode, so it must call
1150  * the "TERM_XTRA_REACT" hook before redrawing the windows.
1151  */
1152 void do_cmd_redraw(void)
1153 {
1154         int j;
1155
1156         term *old = Term;
1157
1158
1159         /* Hack -- react to changes */
1160         Term_xtra(TERM_XTRA_REACT, 0);
1161
1162
1163         /* Combine and Reorder the pack (later) */
1164         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1165
1166
1167         /* Update torch */
1168         p_ptr->update |= (PU_TORCH);
1169
1170         /* Update stuff */
1171         p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1172
1173         /* Forget lite/view */
1174         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1175
1176         /* Update lite/view */
1177         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1178
1179         /* Update monsters */
1180         p_ptr->update |= (PU_MONSTERS);
1181
1182         /* Redraw everything */
1183         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1184
1185         /* Window stuff */
1186         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1187
1188         /* Window stuff */
1189         p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1190
1191         update_playtime();
1192
1193         /* Hack -- update */
1194         handle_stuff();
1195
1196         if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
1197
1198
1199         /* Redraw every window */
1200         for (j = 0; j < 8; j++)
1201         {
1202                 /* Dead window */
1203                 if (!angband_term[j]) continue;
1204
1205                 /* Activate */
1206                 Term_activate(angband_term[j]);
1207
1208                 /* Redraw */
1209                 Term_redraw();
1210
1211                 /* Refresh */
1212                 Term_fresh();
1213
1214                 /* Restore */
1215                 Term_activate(old);
1216         }
1217 }
1218
1219
1220 /*
1221  * Hack -- change name
1222  */
1223 void do_cmd_change_name(void)
1224 {
1225         char    c;
1226
1227         int             mode = 0;
1228
1229         char    tmp[160];
1230
1231
1232         /* Save the screen */
1233         screen_save();
1234
1235         /* Forever */
1236         while (1)
1237         {
1238                 update_playtime();
1239
1240                 /* Display the player */
1241                 display_player(mode);
1242
1243                 if (mode == 4)
1244                 {
1245                         mode = 0;
1246                         display_player(mode);
1247                 }
1248
1249                 /* Prompt */
1250 #ifdef JP
1251                 Term_putstr(2, 23, -1, TERM_WHITE,
1252                             "['c'¤Ç̾Á°Êѹ¹, 'f'¤Ç¥Õ¥¡¥¤¥ë¤Ø½ñ½Ð, 'h'¤Ç¥â¡¼¥ÉÊѹ¹, ESC¤Ç½ªÎ»]");
1253 #else
1254                 Term_putstr(2, 23, -1, TERM_WHITE,
1255                         "['c' to change name, 'f' to file, 'h' to change mode, or ESC]");
1256 #endif
1257
1258
1259                 /* Query */
1260                 c = inkey();
1261
1262                 /* Exit */
1263                 if (c == ESCAPE) break;
1264
1265                 /* Change name */
1266                 if (c == 'c')
1267                 {
1268                         get_name();
1269
1270                         /* Process the player name */
1271                         process_player_name(FALSE);
1272                 }
1273
1274                 /* File dump */
1275                 else if (c == 'f')
1276                 {
1277                         sprintf(tmp, "%s.txt", player_base);
1278 #ifdef JP
1279                         if (get_string("¥Õ¥¡¥¤¥ë̾: ", tmp, 80))
1280 #else
1281                         if (get_string("File name: ", tmp, 80))
1282 #endif
1283
1284                         {
1285                                 if (tmp[0] && (tmp[0] != ' '))
1286                                 {
1287                                         file_character(tmp);
1288                                 }
1289                         }
1290                 }
1291
1292                 /* Toggle mode */
1293                 else if (c == 'h')
1294                 {
1295                         mode++;
1296                 }
1297
1298                 /* Oops */
1299                 else
1300                 {
1301                         bell();
1302                 }
1303
1304                 /* Flush messages */
1305                 msg_print(NULL);
1306         }
1307
1308         /* Restore the screen */
1309         screen_load();
1310
1311         /* Redraw everything */
1312         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1313
1314         handle_stuff();
1315 }
1316
1317
1318 /*
1319  * Recall the most recent message
1320  */
1321 void do_cmd_message_one(void)
1322 {
1323         /* Recall one message XXX XXX XXX */
1324         prt(format("> %s", message_str(0)), 0, 0);
1325 }
1326
1327
1328 /*
1329  * Show previous messages to the user   -BEN-
1330  *
1331  * The screen format uses line 0 and 23 for headers and prompts,
1332  * skips line 1 and 22, and uses line 2 thru 21 for old messages.
1333  *
1334  * This command shows you which commands you are viewing, and allows
1335  * you to "search" for strings in the recall.
1336  *
1337  * Note that messages may be longer than 80 characters, but they are
1338  * displayed using "infinite" length, with a special sub-command to
1339  * "slide" the virtual display to the left or right.
1340  *
1341  * Attempt to only hilite the matching portions of the string.
1342  */
1343 void do_cmd_messages(int num_now)
1344 {
1345         int i, n;
1346
1347         char shower_str[81];
1348         char finder_str[81];
1349         char back_str[81];
1350         cptr shower = NULL;
1351         int wid, hgt;
1352         int num_lines;
1353
1354         /* Get size */
1355         Term_get_size(&wid, &hgt);
1356
1357         /* Number of message lines in a screen */
1358         num_lines = hgt - 4;
1359
1360         /* Wipe finder */
1361         strcpy(finder_str, "");
1362
1363         /* Wipe shower */
1364         strcpy(shower_str, "");
1365
1366         /* Total messages */
1367         n = message_num();
1368
1369         /* Start on first message */
1370         i = 0;
1371
1372         /* Save the screen */
1373         screen_save();
1374
1375         /* Clear screen */
1376         Term_clear();
1377
1378         /* Process requests until done */
1379         while (1)
1380         {
1381                 int j;
1382                 int skey;
1383
1384                 /* Dump up to 20 lines of messages */
1385                 for (j = 0; (j < num_lines) && (i + j < n); j++)
1386                 {
1387                         cptr msg = message_str(i+j);
1388
1389                         /* Dump the messages, bottom to top */
1390                         c_prt((i + j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
1391
1392                         /* Hilite "shower" */
1393                         if (shower && shower[0])
1394                         {
1395                                 cptr str = msg;
1396
1397                                 /* Display matches */
1398                                 while ((str = my_strstr(str, shower)) != NULL)
1399                                 {
1400                                         int len = strlen(shower);
1401
1402                                         /* Display the match */
1403                                         Term_putstr(str-msg, num_lines + 1 - j, len, TERM_YELLOW, shower);
1404
1405                                         /* Advance */
1406                                         str += len;
1407                                 }
1408                         }
1409                 }
1410
1411                 /* Erase remaining lines */
1412                 for (; j < num_lines; j++)
1413                 {
1414                         Term_erase(0, num_lines + 1 - j, 255);
1415                 }
1416
1417                 /* Display header XXX XXX XXX */
1418 #ifdef JP
1419                 /* translation */
1420                 prt(format("°ÊÁ°¤Î¥á¥Ã¥»¡¼¥¸ %d-%d Á´Éô¤Ç(%d)",
1421                            i, i + j - 1, n), 0, 0);
1422 #else
1423                 prt(format("Message Recall (%d-%d of %d)",
1424                            i, i + j - 1, n), 0, 0);
1425 #endif
1426
1427                 /* Display prompt (not very informative) */
1428 #ifdef JP
1429                 prt("[ 'p' ¤Ç¹¹¤Ë¸Å¤¤¤â¤Î, 'n' ¤Ç¹¹¤Ë¿·¤·¤¤¤â¤Î, '/' ¤Ç¸¡º÷, ESC ¤ÇÃæÃÇ ]", hgt - 1, 0);
1430 #else
1431                 prt("[Press 'p' for older, 'n' for newer, ..., or ESCAPE]", hgt - 1, 0);
1432 #endif
1433
1434                 /* Get a command */
1435                 skey = inkey_special(TRUE);
1436
1437                 /* Exit on Escape */
1438                 if (skey == ESCAPE) break;
1439
1440                 /* Hack -- Save the old index */
1441                 j = i;
1442
1443                 switch (skey)
1444                 {
1445                 /* Hack -- handle show */
1446                 case '=':
1447                         /* Prompt */
1448 #ifdef JP
1449                         prt("¶¯Ä´: ", hgt - 1, 0);
1450 #else
1451                         prt("Show: ", hgt - 1, 0);
1452 #endif
1453
1454                         /* Get a "shower" string, or continue */
1455                         strcpy(back_str, shower_str);
1456                         if (askfor(shower_str, 80))
1457                         {
1458                                 /* Show it */
1459                                 shower = shower_str[0] ? shower_str : NULL;
1460                         }
1461                         else strcpy(shower_str, back_str);
1462
1463                         /* Okay */
1464                         continue;
1465
1466                 /* Hack -- handle find */
1467                 case '/':
1468                 case KTRL('s'):
1469                         {
1470                                 int z;
1471
1472                                 /* Prompt */
1473 #ifdef JP
1474                                 prt("¸¡º÷: ", hgt - 1, 0);
1475 #else
1476                                 prt("Find: ", hgt - 1, 0);
1477 #endif
1478
1479                                 /* Get a "finder" string, or continue */
1480                                 strcpy(back_str, finder_str);
1481                                 if (!askfor(finder_str, 80))
1482                                 {
1483                                         strcpy(finder_str, back_str);
1484                                         continue;
1485                                 }
1486                                 else if (!finder_str[0])
1487                                 {
1488                                         shower = NULL; /* Stop showing */
1489                                         continue;
1490                                 }
1491
1492                                 /* Show it */
1493                                 shower = finder_str;
1494
1495                                 /* Scan messages */
1496                                 for (z = i + 1; z < n; z++)
1497                                 {
1498                                         cptr msg = message_str(z);
1499
1500                                         /* Search for it */
1501                                         if (my_strstr(msg, finder_str))
1502                                         {
1503                                                 /* New location */
1504                                                 i = z;
1505
1506                                                 /* Done */
1507                                                 break;
1508                                         }
1509                                 }
1510                         }
1511                         break;
1512
1513                 /* Recall 1 older message */
1514                 case SKEY_TOP:
1515                         /* Go to the oldest line */
1516                         i = n - num_lines;
1517                         break;
1518
1519                 /* Recall 1 newer message */
1520                 case SKEY_BOTTOM:
1521                         /* Go to the newest line */
1522                         i = 0;
1523                         break;
1524
1525                 /* Recall 1 older message */
1526                 case '8':
1527                 case SKEY_UP:
1528                 case '\n':
1529                 case '\r':
1530                         /* Go older if legal */
1531                         i = MIN(i + 1, n - num_lines);
1532                         break;
1533
1534                 /* Recall 10 older messages */
1535                 case '+':
1536                         /* Go older if legal */
1537                         i = MIN(i + 10, n - num_lines);
1538                         break;
1539
1540                 /* Recall 20 older messages */
1541                 case 'p':
1542                 case KTRL('P'):
1543                 case ' ':
1544                 case SKEY_PGUP:
1545                         /* Go older if legal */
1546                         i = MIN(i + num_lines, n - num_lines);
1547                         break;
1548
1549                 /* Recall 20 newer messages */
1550                 case 'n':
1551                 case KTRL('N'):
1552                 case SKEY_PGDOWN:
1553                         /* Go newer (if able) */
1554                         i = MAX(0, i - num_lines);
1555                         break;
1556
1557                 /* Recall 10 newer messages */
1558                 case '-':
1559                         /* Go newer (if able) */
1560                         i = MAX(0, i - 10);
1561                         break;
1562
1563                 /* Recall 1 newer messages */
1564                 case '2':
1565                 case SKEY_DOWN:
1566                         /* Go newer (if able) */
1567                         i = MAX(0, i - 1);
1568                         break;
1569                 }
1570
1571                 /* Hack -- Error of some kind */
1572                 if (i == j) bell();
1573         }
1574
1575         /* Restore the screen */
1576         screen_load();
1577 }
1578
1579
1580
1581 /*
1582  * Number of cheating options
1583  */
1584 #define CHEAT_MAX 7
1585
1586 /*
1587  * Cheating options
1588  */
1589 static option_type cheat_info[CHEAT_MAX] =
1590 {
1591         { &cheat_peek,          FALSE,  255,    0x01, 0x00,
1592 #ifdef JP
1593         "cheat_peek",           "¥¢¥¤¥Æ¥à¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
1594 #else
1595         "cheat_peek",           "Peek into object creation"
1596 #endif
1597         },
1598
1599         { &cheat_hear,          FALSE,  255,    0x02, 0x00,
1600 #ifdef JP
1601         "cheat_hear",           "¥â¥ó¥¹¥¿¡¼¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
1602 #else
1603         "cheat_hear",           "Peek into monster creation"
1604 #endif
1605         },
1606
1607         { &cheat_room,          FALSE,  255,    0x04, 0x00,
1608 #ifdef JP
1609         "cheat_room",           "¥À¥ó¥¸¥ç¥ó¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
1610 #else
1611         "cheat_room",           "Peek into dungeon creation"
1612 #endif
1613         },
1614
1615         { &cheat_xtra,          FALSE,  255,    0x08, 0x00,
1616 #ifdef JP
1617         "cheat_xtra",           "¤½¤Î¾¤Î»ö¤ò¤Î¤¾¤­¸«¤ë"
1618 #else
1619         "cheat_xtra",           "Peek into something else"
1620 #endif
1621         },
1622
1623         { &cheat_know,          FALSE,  255,    0x10, 0x00,
1624 #ifdef JP
1625         "cheat_know",           "´°Á´¤Ê¥â¥ó¥¹¥¿¡¼¤Î»×¤¤½Ð¤òÃΤë"
1626 #else
1627         "cheat_know",           "Know complete monster info"
1628 #endif
1629         },
1630
1631         { &cheat_live,          FALSE,  255,    0x20, 0x00,
1632 #ifdef JP
1633         "cheat_live",           "»à¤ò²óÈò¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë"
1634 #else
1635         "cheat_live",           "Allow player to avoid death"
1636 #endif
1637         },
1638
1639         { &cheat_save,          FALSE,  255,    0x40, 0x00,
1640 #ifdef JP
1641         "cheat_save",           "»à¤ó¤À»þ¥»¡¼¥Ö¤¹¤ë¤«³Îǧ¤¹¤ë"
1642 #else
1643         "cheat_save",           "Ask for saving death"
1644 #endif
1645         }
1646 };
1647
1648 /*
1649  * Interact with some options for cheating
1650  */
1651 static void do_cmd_options_cheat(cptr info)
1652 {
1653         char    ch;
1654
1655         int             i, k = 0, n = CHEAT_MAX;
1656
1657         char    buf[80];
1658
1659
1660         /* Clear screen */
1661         Term_clear();
1662
1663         /* Interact with the player */
1664         while (TRUE)
1665         {
1666                 int dir;
1667
1668                 /* Prompt XXX XXX XXX */
1669 #ifdef JP
1670                 sprintf(buf, "%s ( ¥ê¥¿¡¼¥ó¤Ç¼¡¤Ø, y/n ¤Ç¥»¥Ã¥È, ESC ¤Ç·èÄê )", info);
1671 #else
1672                 sprintf(buf, "%s (RET to advance, y/n to set, ESC to accept) ", info);
1673 #endif
1674
1675                 prt(buf, 0, 0);
1676
1677 #ifdef JP
1678                 /* º¾µ½¥ª¥×¥·¥ç¥ó¤ò¤¦¤Ã¤«¤ê¤¤¤¸¤Ã¤Æ¤·¤Þ¤¦¿Í¤¬¤¤¤ë¤è¤¦¤Ê¤Î¤ÇÃí°Õ */
1679                 prt("                                 <<  Ãí°Õ  >>", 11, 0);
1680                 prt("      º¾µ½¥ª¥×¥·¥ç¥ó¤ò°ìÅ٤ǤâÀßÄꤹ¤ë¤È¡¢¥¹¥³¥¢µ­Ï¿¤¬»Ä¤é¤Ê¤¯¤Ê¤ê¤Þ¤¹¡ª", 12, 0);
1681                 prt("      ¸å¤Ë²ò½ü¤·¤Æ¤â¥À¥á¤Ç¤¹¤Î¤Ç¡¢¾¡Íø¼Ô¤òÌܻؤ¹Êý¤Ï¤³¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¤¤", 13, 0);
1682                 prt("      ¤¸¤é¤Ê¤¤¤è¤¦¤Ë¤·¤Æ²¼¤µ¤¤¡£", 14, 0);
1683 #endif
1684                 /* Display the options */
1685                 for (i = 0; i < n; i++)
1686                 {
1687                         byte a = TERM_WHITE;
1688
1689                         /* Color current option */
1690                         if (i == k) a = TERM_L_BLUE;
1691
1692                         /* Display the option text */
1693                         sprintf(buf, "%-48s: %s (%s)",
1694                             cheat_info[i].o_desc,
1695 #ifdef JP
1696                             (*cheat_info[i].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
1697 #else
1698                             (*cheat_info[i].o_var ? "yes" : "no "),
1699 #endif
1700
1701                             cheat_info[i].o_text);
1702                         c_prt(a, buf, i + 2, 0);
1703                 }
1704
1705                 /* Hilite current option */
1706                 move_cursor(k + 2, 50);
1707
1708                 /* Get a key */
1709                 ch = inkey();
1710
1711                 /*
1712                  * HACK - Try to translate the key into a direction
1713                  * to allow using the roguelike keys for navigation.
1714                  */
1715                 dir = get_keymap_dir(ch);
1716                 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
1717                         ch = I2D(dir);
1718
1719                 /* Analyze */
1720                 switch (ch)
1721                 {
1722                         case ESCAPE:
1723                         {
1724                                 return;
1725                         }
1726
1727                         case '-':
1728                         case '8':
1729                         {
1730                                 k = (n + k - 1) % n;
1731                                 break;
1732                         }
1733
1734                         case ' ':
1735                         case '\n':
1736                         case '\r':
1737                         case '2':
1738                         {
1739                                 k = (k + 1) % n;
1740                                 break;
1741                         }
1742
1743                         case 'y':
1744                         case 'Y':
1745                         case '6':
1746                         {
1747                                 if(!p_ptr->noscore)
1748 #ifdef JP
1749                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "º¾µ½¥ª¥×¥·¥ç¥ó¤òON¤Ë¤·¤Æ¡¢¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
1750 #else
1751                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up sending score to use cheating options.");
1752 #endif
1753                                 p_ptr->noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
1754                                 (*cheat_info[k].o_var) = TRUE;
1755                                 k = (k + 1) % n;
1756                                 break;
1757                         }
1758
1759                         case 'n':
1760                         case 'N':
1761                         case '4':
1762                         {
1763                                 (*cheat_info[k].o_var) = FALSE;
1764                                 k = (k + 1) % n;
1765                                 break;
1766                         }
1767
1768                         case '?':
1769                         {
1770 #ifdef JP
1771                                 strnfmt(buf, sizeof(buf), "joption.txt#%s", cheat_info[k].o_text);
1772 #else
1773                                 strnfmt(buf, sizeof(buf), "option.txt#%s", cheat_info[k].o_text);
1774 #endif
1775                                 /* Peruse the help file */
1776                                 (void)show_file(TRUE, buf, NULL, 0, 0);
1777
1778                                 Term_clear(); 
1779                                 break;
1780                         }
1781
1782                         default:
1783                         {
1784                                 bell();
1785                                 break;
1786                         }
1787                 }
1788         }
1789 }
1790
1791
1792 static option_type autosave_info[2] =
1793 {
1794         { &autosave_l,      FALSE, 255, 0x01, 0x00,
1795 #ifdef JP
1796             "autosave_l",    "¿·¤·¤¤³¬¤ËÆþ¤ëÅ٤˼«Æ°¥»¡¼¥Ö¤¹¤ë" },
1797 #else
1798             "autosave_l",    "Autosave when entering new levels" },
1799 #endif
1800
1801
1802         { &autosave_t,      FALSE, 255, 0x02, 0x00,
1803 #ifdef JP
1804             "autosave_t",   "°ìÄ꥿¡¼¥óËè¤Ë¼«Æ°¥»¡¼¥Ö¤¹¤ë" },
1805 #else
1806             "autosave_t",   "Timed autosave" },
1807 #endif
1808
1809 };
1810
1811
1812 static s16b toggle_frequency(s16b current)
1813 {
1814         switch (current)
1815         {
1816         case 0: return 50;
1817         case 50: return 100;
1818         case 100: return 250;
1819         case 250: return 500;
1820         case 500: return 1000;
1821         case 1000: return 2500;
1822         case 2500: return 5000;
1823         case 5000: return 10000;
1824         case 10000: return 25000;
1825         default: return 0;
1826         }
1827 }
1828
1829
1830 /*
1831  * Interact with some options for cheating
1832  */
1833 static void do_cmd_options_autosave(cptr info)
1834 {
1835         char    ch;
1836
1837         int     i, k = 0, n = 2;
1838
1839         char    buf[80];
1840
1841
1842         /* Clear screen */
1843         Term_clear();
1844
1845         /* Interact with the player */
1846         while (TRUE)
1847         {
1848                 /* Prompt XXX XXX XXX */
1849 #ifdef JP
1850                 sprintf(buf, "%s ( ¥ê¥¿¡¼¥ó¤Ç¼¡¤Ø, y/n ¤Ç¥»¥Ã¥È, F ¤ÇÉÑÅÙ¤òÆþÎÏ, ESC ¤Ç·èÄê ) ", info);
1851 #else
1852                 sprintf(buf, "%s (RET to advance, y/n to set, 'F' for frequency, ESC to accept) ", info);
1853 #endif
1854
1855                 prt(buf, 0, 0);
1856
1857                 /* Display the options */
1858                 for (i = 0; i < n; i++)
1859                 {
1860                         byte a = TERM_WHITE;
1861
1862                         /* Color current option */
1863                         if (i == k) a = TERM_L_BLUE;
1864
1865                         /* Display the option text */
1866                         sprintf(buf, "%-48s: %s (%s)",
1867                             autosave_info[i].o_desc,
1868 #ifdef JP
1869                             (*autosave_info[i].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
1870 #else
1871                             (*autosave_info[i].o_var ? "yes" : "no "),
1872 #endif
1873
1874                             autosave_info[i].o_text);
1875                         c_prt(a, buf, i + 2, 0);
1876                 }
1877
1878 #ifdef JP
1879                 prt(format("¼«Æ°¥»¡¼¥Ö¤ÎÉÑÅÙ¡§ %d ¥¿¡¼¥óËè",  autosave_freq), 5, 0);
1880 #else
1881                 prt(format("Timed autosave frequency: every %d turns",  autosave_freq), 5, 0);
1882 #endif
1883
1884
1885
1886                 /* Hilite current option */
1887                 move_cursor(k + 2, 50);
1888
1889                 /* Get a key */
1890                 ch = inkey();
1891
1892                 /* Analyze */
1893                 switch (ch)
1894                 {
1895                         case ESCAPE:
1896                         {
1897                                 return;
1898                         }
1899
1900                         case '-':
1901                         case '8':
1902                         {
1903                                 k = (n + k - 1) % n;
1904                                 break;
1905                         }
1906
1907                         case ' ':
1908                         case '\n':
1909                         case '\r':
1910                         case '2':
1911                         {
1912                                 k = (k + 1) % n;
1913                                 break;
1914                         }
1915
1916                         case 'y':
1917                         case 'Y':
1918                         case '6':
1919                         {
1920
1921                                 (*autosave_info[k].o_var) = TRUE;
1922                                 k = (k + 1) % n;
1923                                 break;
1924                         }
1925
1926                         case 'n':
1927                         case 'N':
1928                         case '4':
1929                         {
1930                                 (*autosave_info[k].o_var) = FALSE;
1931                                 k = (k + 1) % n;
1932                                 break;
1933                         }
1934
1935                         case 'f':
1936                         case 'F':
1937                         {
1938                                 autosave_freq = toggle_frequency(autosave_freq);
1939 #ifdef JP
1940                                 prt(format("¼«Æ°¥»¡¼¥Ö¤ÎÉÑÅÙ¡§ %d ¥¿¡¼¥óËè", 
1941                                            autosave_freq), 5, 0);
1942 #else
1943                                 prt(format("Timed autosave frequency: every %d turns",
1944                                            autosave_freq), 5, 0);
1945 #endif
1946                                 break;
1947                         }
1948
1949                         case '?':
1950                         {
1951 #ifdef JP
1952                                 (void)show_file(TRUE, "joption.txt#Autosave", NULL, 0, 0);
1953 #else
1954                                 (void)show_file(TRUE, "option.txt#Autosave", NULL, 0, 0);
1955 #endif
1956
1957
1958                                 Term_clear(); 
1959                                 break;
1960                         }
1961
1962                         default:
1963                         {
1964                                 bell();
1965                                 break;
1966                         }
1967                 }
1968         }
1969 }
1970
1971
1972 /*
1973  * Interact with some options
1974  */
1975 void do_cmd_options_aux(int page, cptr info)
1976 {
1977         char    ch;
1978         int     i, k = 0, n = 0, l;
1979         int     opt[24];
1980         char    buf[80];
1981         bool    browse_only = (page == OPT_PAGE_BIRTH) && character_generated &&
1982                               (!p_ptr->wizard || !allow_debug_opts);
1983
1984
1985         /* Lookup the options */
1986         for (i = 0; i < 24; i++) opt[i] = 0;
1987
1988         /* Scan the options */
1989         for (i = 0; option_info[i].o_desc; i++)
1990         {
1991                 /* Notice options on this "page" */
1992                 if (option_info[i].o_page == page) opt[n++] = i;
1993         }
1994
1995
1996         /* Clear screen */
1997         Term_clear();
1998
1999         /* Interact with the player */
2000         while (TRUE)
2001         {
2002                 int dir;
2003
2004                 /* Prompt XXX XXX XXX */
2005 #ifdef JP
2006                 sprintf(buf, "%s (¥ê¥¿¡¼¥ó:¼¡, %sESC:½ªÎ», ?:¥Ø¥ë¥×) ", info, browse_only ? "" : "y/n:Êѹ¹, ");
2007 #else
2008                 sprintf(buf, "%s (RET:next, %s, ?:help) ", info, browse_only ? "ESC:exit" : "y/n:change, ESC:accept");
2009 #endif
2010
2011                 prt(buf, 0, 0);
2012
2013
2014                 /* HACK -- description for easy-auto-destroy options */
2015 #ifdef JP
2016                 if (page == OPT_PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "°Ê²¼¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢´Ê°×¼«Æ°Ç˲õ¤ò»ÈÍѤ¹¤ë¤È¤­¤Î¤ßÍ­¸ú", 6, 6);
2017 #else
2018                 if (page == OPT_PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "Following options will protect items from easy auto-destroyer.", 6, 3);
2019 #endif
2020
2021                 /* Display the options */
2022                 for (i = 0; i < n; i++)
2023                 {
2024                         byte a = TERM_WHITE;
2025
2026                         /* Color current option */
2027                         if (i == k) a = TERM_L_BLUE;
2028
2029                         /* Display the option text */
2030                         sprintf(buf, "%-48s: %s (%.19s)",
2031                                 option_info[opt[i]].o_desc,
2032 #ifdef JP
2033                                 (*option_info[opt[i]].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
2034 #else
2035                                 (*option_info[opt[i]].o_var ? "yes" : "no "),
2036 #endif
2037
2038                                 option_info[opt[i]].o_text);
2039                         if ((page == OPT_PAGE_AUTODESTROY) && i > 2) c_prt(a, buf, i + 5, 0);
2040                         else c_prt(a, buf, i + 2, 0);
2041                 }
2042
2043                 if ((page == OPT_PAGE_AUTODESTROY) && (k > 2)) l = 3;
2044                 else l = 0;
2045
2046                 /* Hilite current option */
2047                 move_cursor(k + 2 + l, 50);
2048
2049                 /* Get a key */
2050                 ch = inkey();
2051
2052                 /*
2053                  * HACK - Try to translate the key into a direction
2054                  * to allow using the roguelike keys for navigation.
2055                  */
2056                 dir = get_keymap_dir(ch);
2057                 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
2058                         ch = I2D(dir);
2059
2060                 /* Analyze */
2061                 switch (ch)
2062                 {
2063                         case ESCAPE:
2064                         {
2065                                 return;
2066                         }
2067
2068                         case '-':
2069                         case '8':
2070                         {
2071                                 k = (n + k - 1) % n;
2072                                 break;
2073                         }
2074
2075                         case ' ':
2076                         case '\n':
2077                         case '\r':
2078                         case '2':
2079                         {
2080                                 k = (k + 1) % n;
2081                                 break;
2082                         }
2083
2084                         case 'y':
2085                         case 'Y':
2086                         case '6':
2087                         {
2088                                 if (browse_only) break;
2089                                 (*option_info[opt[k]].o_var) = TRUE;
2090                                 k = (k + 1) % n;
2091                                 break;
2092                         }
2093
2094                         case 'n':
2095                         case 'N':
2096                         case '4':
2097                         {
2098                                 if (browse_only) break;
2099                                 (*option_info[opt[k]].o_var) = FALSE;
2100                                 k = (k + 1) % n;
2101                                 break;
2102                         }
2103
2104                         case 't':
2105                         case 'T':
2106                         {
2107                                 if (!browse_only) (*option_info[opt[k]].o_var) = !(*option_info[opt[k]].o_var);
2108                                 break;
2109                         }
2110
2111                         case '?':
2112                         {
2113 #ifdef JP
2114                                 strnfmt(buf, sizeof(buf), "joption.txt#%s", option_info[opt[k]].o_text);
2115 #else
2116                                 strnfmt(buf, sizeof(buf), "option.txt#%s", option_info[opt[k]].o_text);
2117 #endif
2118                                 /* Peruse the help file */
2119                                 (void)show_file(TRUE, buf, NULL, 0, 0);
2120
2121                                 Term_clear();
2122                                 break;
2123                         }
2124
2125                         default:
2126                         {
2127                                 bell();
2128                                 break;
2129                         }
2130                 }
2131         }
2132 }
2133
2134
2135 /*
2136  * Modify the "window" options
2137  */
2138 static void do_cmd_options_win(void)
2139 {
2140         int i, j, d;
2141
2142         int y = 0;
2143         int x = 0;
2144
2145         char ch;
2146
2147         bool go = TRUE;
2148
2149         u32b old_flag[8];
2150
2151
2152         /* Memorize old flags */
2153         for (j = 0; j < 8; j++)
2154         {
2155                 /* Acquire current flags */
2156                 old_flag[j] = window_flag[j];
2157         }
2158
2159
2160         /* Clear screen */
2161         Term_clear();
2162
2163         /* Interact */
2164         while (go)
2165         {
2166                 /* Prompt XXX XXX XXX */
2167 #ifdef JP
2168                 prt("¥¦¥£¥ó¥É¥¦¡¦¥Õ¥é¥° (<Êý¸þ>¤Ç°ÜÆ°, t¤Ç¥Á¥§¥ó¥¸, y/n ¤Ç¥»¥Ã¥È, ESC)", 0, 0);
2169 #else
2170                 prt("Window Flags (<dir>, t, y, n, ESC) ", 0, 0);
2171 #endif
2172
2173
2174                 /* Display the windows */
2175                 for (j = 0; j < 8; j++)
2176                 {
2177                         byte a = TERM_WHITE;
2178
2179                         cptr s = angband_term_name[j];
2180
2181                         /* Use color */
2182                         if (j == x) a = TERM_L_BLUE;
2183
2184                         /* Window name, staggered, centered */
2185                         Term_putstr(35 + j * 5 - strlen(s) / 2, 2 + j % 2, -1, a, s);
2186                 }
2187
2188                 /* Display the options */
2189                 for (i = 0; i < 16; i++)
2190                 {
2191                         byte a = TERM_WHITE;
2192
2193                         cptr str = window_flag_desc[i];
2194
2195                         /* Use color */
2196                         if (i == y) a = TERM_L_BLUE;
2197
2198                         /* Unused option */
2199 #ifdef JP
2200                         if (!str) str = "(̤»ÈÍÑ)";
2201 #else
2202                         if (!str) str = "(Unused option)";
2203 #endif
2204
2205
2206                         /* Flag name */
2207                         Term_putstr(0, i + 5, -1, a, str);
2208
2209                         /* Display the windows */
2210                         for (j = 0; j < 8; j++)
2211                         {
2212                                 byte a = TERM_WHITE;
2213
2214                                 char c = '.';
2215
2216                                 /* Use color */
2217                                 if ((i == y) && (j == x)) a = TERM_L_BLUE;
2218
2219                                 /* Active flag */
2220                                 if (window_flag[j] & (1L << i)) c = 'X';
2221
2222                                 /* Flag value */
2223                                 Term_putch(35 + j * 5, i + 5, a, c);
2224                         }
2225                 }
2226
2227                 /* Place Cursor */
2228                 Term_gotoxy(35 + x * 5, y + 5);
2229
2230                 /* Get key */
2231                 ch = inkey();
2232
2233                 /* Analyze */
2234                 switch (ch)
2235                 {
2236                         case ESCAPE:
2237                         {
2238                                 go = FALSE;
2239                                 break;
2240                         }
2241
2242                         case 'T':
2243                         case 't':
2244                         {
2245                                 /* Clear windows */
2246                                 for (j = 0; j < 8; j++)
2247                                 {
2248                                         window_flag[j] &= ~(1L << y);
2249                                 }
2250
2251                                 /* Clear flags */
2252                                 for (i = 0; i < 16; i++)
2253                                 {
2254                                         window_flag[x] &= ~(1L << i);
2255                                 }
2256
2257                                 /* Fall through */
2258                         }
2259
2260                         case 'y':
2261                         case 'Y':
2262                         {
2263                                 /* Ignore screen */
2264                                 if (x == 0) break;
2265
2266                                 /* Set flag */
2267                                 window_flag[x] |= (1L << y);
2268                                 break;
2269                         }
2270
2271                         case 'n':
2272                         case 'N':
2273                         {
2274                                 /* Clear flag */
2275                                 window_flag[x] &= ~(1L << y);
2276                                 break;
2277                         }
2278
2279                         case '?':
2280                         {
2281 #ifdef JP
2282                                 (void)show_file(TRUE, "joption.txt#Window", NULL, 0, 0);
2283 #else
2284                                 (void)show_file(TRUE, "option.txt#Window", NULL, 0, 0);
2285 #endif
2286
2287
2288                                 Term_clear(); 
2289                                 break;
2290                         }
2291
2292                         default:
2293                         {
2294                                 d = get_keymap_dir(ch);
2295
2296                                 x = (x + ddx[d] + 8) % 8;
2297                                 y = (y + ddy[d] + 16) % 16;
2298
2299                                 if (!d) bell();
2300                         }
2301                 }
2302         }
2303
2304         /* Notice changes */
2305         for (j = 0; j < 8; j++)
2306         {
2307                 term *old = Term;
2308
2309                 /* Dead window */
2310                 if (!angband_term[j]) continue;
2311
2312                 /* Ignore non-changes */
2313                 if (window_flag[j] == old_flag[j]) continue;
2314
2315                 /* Activate */
2316                 Term_activate(angband_term[j]);
2317
2318                 /* Erase */
2319                 Term_clear();
2320
2321                 /* Refresh */
2322                 Term_fresh();
2323
2324                 /* Restore */
2325                 Term_activate(old);
2326         }
2327 }
2328
2329
2330
2331
2332 /*
2333  * Set or unset various options.
2334  *
2335  * The user must use the "Ctrl-R" command to "adapt" to changes
2336  * in any options which control "visual" aspects of the game.
2337  */
2338 void do_cmd_options(void)
2339 {
2340         int k;
2341
2342
2343         /* Save the screen */
2344         screen_save();
2345
2346         /* Interact */
2347         while (1)
2348         {
2349                 /* Clear screen */
2350                 Term_clear();
2351
2352                 /* Why are we here */
2353 #ifdef JP
2354                 prt("[ ¥ª¥×¥·¥ç¥ó¤ÎÀßÄê ]", 1, 0);
2355 #else
2356                 prt("Options", 1, 0);
2357 #endif
2358
2359
2360                 /* Give some choices */
2361 #ifdef JP
2362                 prt("(1)      ¥­¡¼ÆþÎÏ        ¥ª¥×¥·¥ç¥ó", 2, 5);
2363                 prt("(2)     ¥Þ¥Ã¥×²èÌÌ       ¥ª¥×¥·¥ç¥ó", 3, 5);
2364                 prt("(3)    ¥Æ¥­¥¹¥Èɽ¼¨      ¥ª¥×¥·¥ç¥ó", 4, 5);
2365                 prt("(4)    ¥²¡¼¥à¥×¥ì¥¤      ¥ª¥×¥·¥ç¥ó", 5, 5);
2366                 prt("(5)    ¹ÔÆ°Ãæ»ß´Ø·¸      ¥ª¥×¥·¥ç¥ó", 6, 5);
2367                 prt("(6)    ´Ê°×¼«Æ°Ç˲õ      ¥ª¥×¥·¥ç¥ó", 7, 5);
2368                 prt("(R)     ¥×¥ì¥¤µ­Ï¿       ¥ª¥×¥·¥ç¥ó", 8, 5);
2369
2370                 /* Special choices */
2371                 prt("(P)  ¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿", 10, 5);
2372                 prt("(D)   ´ðËÜ¥¦¥§¥¤¥ÈÎÌ", 11, 5);
2373                 prt("(H) Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð", 12, 5);
2374                 prt("(M)    ÄãËâÎÏ¿§ïçÃÍ", 13, 5);
2375                 prt("(A)     ¼«Æ°¥»¡¼¥Ö       ¥ª¥×¥·¥ç¥ó", 14, 5);
2376                 /* Window flags */
2377                 prt("(W)  ¥¦¥¤¥ó¥É¥¦¥Õ¥é¥°", 15, 5);
2378 #else
2379                 prt("(1) Input Options", 2, 5);
2380                 prt("(2) Map Screen Options", 3, 5);
2381                 prt("(3) Text Display Options", 4, 5);
2382                 prt("(4) Game-Play Options", 5, 5);
2383                 prt("(5) Disturbance Options", 6, 5);
2384                 prt("(6) Easy Auto-Destroyer Options", 7, 5);
2385                 prt("(R) Play-record Options", 8, 5);
2386                 /* Special choices */
2387                 prt("(P) Auto-picker/destroyer editor", 10, 5);
2388                 prt("(D) Base Delay Factor", 11, 5);
2389                 prt("(H) Hitpoint Warning", 12, 5);
2390                 prt("(M) Mana Color Threshold", 13, 5);
2391                 prt("(A) Autosave Options", 14, 5);
2392                 /* Window flags */
2393                 prt("(W) Window Flags", 15, 5);
2394 #endif
2395
2396                 if (!p_ptr->wizard || !allow_debug_opts)
2397                 {
2398                         /* Birth */
2399 #ifdef JP
2400                         prt("(B)        ½é´ü          ¥ª¥×¥·¥ç¥ó (»²¾È¤Î¤ß)", 16, 5);
2401 #else
2402                         prt("(B) Birth Options (Browse Only)", 16, 5);
2403 #endif
2404                 }
2405                 else
2406                 {
2407                         /* Birth */
2408 #ifdef JP
2409                         prt("(B)        ½é´ü          ¥ª¥×¥·¥ç¥ó", 16, 5);
2410 #else
2411                         prt("(B) Birth Options", 16, 5);
2412 #endif
2413                 }
2414
2415
2416                 if (p_ptr->noscore || allow_debug_opts)
2417                 {
2418                         /* Cheating */
2419 #ifdef JP
2420                         prt("(C)        º¾µ½          ¥ª¥×¥·¥ç¥ó", 17, 5);
2421 #else
2422                         prt("(C) Cheating Options", 17, 5);
2423 #endif
2424                 }
2425
2426
2427                 /* Prompt */
2428 #ifdef JP
2429                 prt("¥³¥Þ¥ó¥É:", 19, 0);
2430 #else
2431                 prt("Command: ", 19, 0);
2432 #endif
2433
2434
2435                 /* Get command */
2436                 k = inkey();
2437
2438                 /* Exit */
2439                 if (k == ESCAPE) break;
2440
2441                 /* Analyze */
2442                 switch (k)
2443                 {
2444                         case '1':
2445                         {
2446                                 /* Process the general options */
2447 #ifdef JP
2448                                 do_cmd_options_aux(OPT_PAGE_INPUT, "¥­¡¼ÆþÎÏ¥ª¥×¥·¥ç¥ó");
2449 #else
2450                                 do_cmd_options_aux(OPT_PAGE_INPUT, "Input Options");
2451 #endif
2452
2453                                 break;
2454                         }
2455
2456                         case '2':
2457                         {
2458                                 /* Process the general options */
2459 #ifdef JP
2460                                 do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "¥Þ¥Ã¥×²èÌÌ¥ª¥×¥·¥ç¥ó");
2461 #else
2462                                 do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "Map Screen Options");
2463 #endif
2464
2465                                 break;
2466                         }
2467
2468                         case '3':
2469                         {
2470                                 /* Spawn */
2471 #ifdef JP
2472                                 do_cmd_options_aux(OPT_PAGE_TEXT, "¥Æ¥­¥¹¥Èɽ¼¨¥ª¥×¥·¥ç¥ó");
2473 #else
2474                                 do_cmd_options_aux(OPT_PAGE_TEXT, "Text Display Options");
2475 #endif
2476
2477                                 break;
2478                         }
2479
2480                         case '4':
2481                         {
2482                                 /* Spawn */
2483 #ifdef JP
2484                                 do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "¥²¡¼¥à¥×¥ì¥¤¡¦¥ª¥×¥·¥ç¥ó");
2485 #else
2486                                 do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "Game-Play Options");
2487 #endif
2488
2489                                 break;
2490                         }
2491
2492                         case '5':
2493                         {
2494                                 /* Spawn */
2495 #ifdef JP
2496                                 do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "¹ÔÆ°Ãæ»ß´Ø·¸¤Î¥ª¥×¥·¥ç¥ó");
2497 #else
2498                                 do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "Disturbance Options");
2499 #endif
2500
2501                                 break;
2502                         }
2503
2504                         case '6':
2505                         {
2506                                 /* Spawn */
2507 #ifdef JP
2508                                 do_cmd_options_aux(OPT_PAGE_AUTODESTROY, "´Ê°×¼«Æ°Ç˲õ¥ª¥×¥·¥ç¥ó");
2509 #else
2510                                 do_cmd_options_aux(OPT_PAGE_AUTODESTROY, "Easy Auto-Destroyer Options");
2511 #endif
2512                                 break;
2513                         }
2514
2515                         /* Play-record Options */
2516                         case 'R':
2517                         case 'r':
2518                         {
2519                                 /* Spawn */
2520 #ifdef JP
2521                                 do_cmd_options_aux(OPT_PAGE_PLAYRECORD, "¥×¥ì¥¤µ­Ï¿¥ª¥×¥·¥ç¥ó");
2522 #else
2523                                 do_cmd_options_aux(OPT_PAGE_PLAYRECORD, "Play-record Options");
2524 #endif
2525                                 break;
2526                         }
2527
2528                         /* Birth Options */
2529                         case 'B':
2530                         case 'b':
2531                         {
2532                                 /* Spawn */
2533 #ifdef JP
2534                                 do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "½é´ü¥ª¥×¥·¥ç¥ó(»²¾È¤Î¤ß)" : "½é´ü¥ª¥×¥·¥ç¥ó((*)¤Ï¥¹¥³¥¢¤Ë±Æ¶Á)");
2535 #else
2536                                 do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "Birth Options(browse only)" : "Birth Options((*)s effect score)");
2537 #endif
2538
2539                                 break;
2540                         }
2541
2542                         /* Cheating Options */
2543                         case 'C':
2544                         {
2545                                 if (!p_ptr->noscore && !allow_debug_opts)
2546                                 {
2547                                         /* Cheat options are not permitted */
2548                                         bell();
2549                                         break;
2550                                 }
2551
2552                                 /* Spawn */
2553 #ifdef JP
2554                                 do_cmd_options_cheat("º¾µ½»Õ¤Ï·è¤·¤Æ¾¡Íø¤Ç¤­¤Ê¤¤¡ª");
2555 #else
2556                                 do_cmd_options_cheat("Cheaters never win");
2557 #endif
2558
2559                                 break;
2560                         }
2561
2562                         case 'a':
2563                         case 'A':
2564                         {
2565 #ifdef JP
2566                                 do_cmd_options_autosave("¼«Æ°¥»¡¼¥Ö");
2567 #else
2568                                 do_cmd_options_autosave("Autosave");
2569 #endif
2570
2571                                 break;
2572                         }
2573
2574                         /* Window flags */
2575                         case 'W':
2576                         case 'w':
2577                         {
2578                                 /* Spawn */
2579                                 do_cmd_options_win();
2580                                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL |
2581                                                   PW_PLAYER | PW_MESSAGE | PW_OVERHEAD |
2582                                                   PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
2583                                                   PW_BORG_1 | PW_BORG_2 | PW_DUNGEON);
2584                                 break;
2585                         }
2586
2587                         /* Auto-picker/destroyer editor */
2588                         case 'P':
2589                         case 'p':
2590                         {
2591                                 do_cmd_edit_autopick();
2592                                 break;
2593                         }
2594
2595                         /* Hack -- Delay Speed */
2596                         case 'D':
2597                         case 'd':
2598                         {
2599                                 /* Prompt */
2600 #ifdef JP
2601                                 prt("¥³¥Þ¥ó¥É: ´ðËÜ¥¦¥§¥¤¥ÈÎÌ", 19, 0);
2602 #else
2603                                 prt("Command: Base Delay Factor", 19, 0);
2604 #endif
2605
2606
2607                                 /* Get a new value */
2608                                 while (1)
2609                                 {
2610                                         int msec = delay_factor * delay_factor * delay_factor;
2611 #ifdef JP
2612                                         prt(format("¸½ºß¤Î¥¦¥§¥¤¥È: %d (%d¥ß¥êÉÃ)",
2613                                                    delay_factor, msec), 22, 0);
2614 #else
2615                                         prt(format("Current base delay factor: %d (%d msec)",
2616                                                    delay_factor, msec), 22, 0);
2617 #endif
2618
2619 #ifdef JP
2620                                         prt("¥¦¥§¥¤¥È (0-9) ESC¤Ç·èÄê: ", 20, 0);
2621 #else
2622                                         prt("Delay Factor (0-9 or ESC to accept): ", 20, 0);
2623 #endif
2624
2625                                         k = inkey();
2626                                         if (k == ESCAPE) break;
2627                                         else if (k == '?')
2628                                         {
2629 #ifdef JP
2630                                                 (void)show_file(TRUE, "joption.txt#BaseDelay", NULL, 0, 0);
2631 #else
2632                                                 (void)show_file(TRUE, "option.txt#BaseDelay", NULL, 0, 0);
2633 #endif
2634                                                 Term_clear(); 
2635                                         }
2636                                         else if (isdigit(k)) delay_factor = D2I(k);
2637                                         else bell();
2638                                 }
2639
2640                                 break;
2641                         }
2642
2643                         /* Hack -- hitpoint warning factor */
2644                         case 'H':
2645                         case 'h':
2646                         {
2647                                 /* Prompt */
2648 #ifdef JP
2649                                 prt("¥³¥Þ¥ó¥É: Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð", 19, 0);
2650 #else
2651                                 prt("Command: Hitpoint Warning", 19, 0);
2652 #endif
2653
2654
2655                                 /* Get a new value */
2656                                 while (1)
2657                                 {
2658 #ifdef JP
2659                                         prt(format("¸½ºß¤ÎÄã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð: %d0%%",
2660                                                    hitpoint_warn), 22, 0);
2661 #else
2662                                         prt(format("Current hitpoint warning: %d0%%",
2663                                                    hitpoint_warn), 22, 0);
2664 #endif
2665
2666 #ifdef JP
2667                                         prt("Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð (0-9) ESC¤Ç·èÄê: ", 20, 0);
2668 #else
2669                                         prt("Hitpoint Warning (0-9 or ESC to accept): ", 20, 0);
2670 #endif
2671
2672                                         k = inkey();
2673                                         if (k == ESCAPE) break;
2674                                         else if (k == '?')
2675                                         {
2676 #ifdef JP
2677                                                 (void)show_file(TRUE, "joption.txt#Hitpoint", NULL, 0, 0);
2678 #else
2679                                                 (void)show_file(TRUE, "option.txt#Hitpoint", NULL, 0, 0);
2680 #endif
2681                                                 Term_clear(); 
2682                                         }
2683                                         else if (isdigit(k)) hitpoint_warn = D2I(k);
2684                                         else bell();
2685                                 }
2686
2687                                 break;
2688                         }
2689
2690                         /* Hack -- mana color factor */
2691                         case 'M':
2692                         case 'm':
2693                         {
2694                                 /* Prompt */
2695 #ifdef JP
2696                                 prt("¥³¥Þ¥ó¥É: ÄãËâÎÏ¿§ïçÃÍ", 19, 0);
2697 #else
2698                                 prt("Command: Mana Color Threshold", 19, 0);
2699 #endif
2700
2701
2702                                 /* Get a new value */
2703                                 while (1)
2704                                 {
2705 #ifdef JP
2706                                         prt(format("¸½ºß¤ÎÄãËâÎÏ¿§ïçÃÍ: %d0%%",
2707                                                    mana_warn), 22, 0);
2708 #else
2709                                         prt(format("Current mana color threshold: %d0%%",
2710                                                    mana_warn), 22, 0);
2711 #endif
2712
2713 #ifdef JP
2714                                         prt("ÄãËâÎÏïçÃÍ (0-9) ESC¤Ç·èÄê: ", 20, 0);
2715 #else
2716                                         prt("Mana color Threshold (0-9 or ESC to accept): ", 20, 0);
2717 #endif
2718
2719                                         k = inkey();
2720                                         if (k == ESCAPE) break;
2721                                         else if (k == '?')
2722                                         {
2723 #ifdef JP
2724                                                 (void)show_file(TRUE, "joption.txt#Manapoint", NULL, 0, 0);
2725 #else
2726                                                 (void)show_file(TRUE, "option.txt#Manapoint", NULL, 0, 0);
2727 #endif
2728                                                 Term_clear(); 
2729                                         }
2730                                         else if (isdigit(k)) mana_warn = D2I(k);
2731                                         else bell();
2732                                 }
2733
2734                                 break;
2735                         }
2736
2737                         case '?':
2738 #ifdef JP
2739                                 (void)show_file(TRUE, "joption.txt", NULL, 0, 0);
2740 #else
2741                                 (void)show_file(TRUE, "option.txt", NULL, 0, 0);
2742 #endif
2743                                 Term_clear(); 
2744                                 break;
2745
2746                         /* Unknown option */
2747                         default:
2748                         {
2749                                 /* Oops */
2750                                 bell();
2751                                 break;
2752                         }
2753                 }
2754
2755                 /* Flush messages */
2756                 msg_print(NULL);
2757         }
2758
2759
2760         /* Restore the screen */
2761         screen_load();
2762
2763         /* Hack - Redraw equippy chars */
2764         p_ptr->redraw |= (PR_EQUIPPY);
2765 }
2766
2767
2768
2769 /*
2770  * Ask for a "user pref line" and process it
2771  *
2772  * XXX XXX XXX Allow absolute file names?
2773  */
2774 void do_cmd_pref(void)
2775 {
2776         char buf[80];
2777
2778         /* Default */
2779         strcpy(buf, "");
2780
2781         /* Ask for a "user pref command" */
2782 #ifdef JP
2783         if (!get_string("ÀßÄêÊѹ¹¥³¥Þ¥ó¥É: ", buf, 80)) return;
2784 #else
2785         if (!get_string("Pref: ", buf, 80)) return;
2786 #endif
2787
2788
2789         /* Process that pref command */
2790         (void)process_pref_file_command(buf);
2791 }
2792
2793 void do_cmd_reload_autopick(void)
2794 {
2795 #ifdef JP
2796         if (!get_check("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return;
2797 #else
2798         if (!get_check("Reload auto-pick preference file? ")) return;
2799 #endif
2800
2801         /* Load the file with messages */
2802         autopick_load_pref(TRUE);
2803 }
2804
2805 #ifdef ALLOW_MACROS
2806
2807 /*
2808  * Hack -- append all current macros to the given file
2809  */
2810 static errr macro_dump(cptr fname)
2811 {
2812         static cptr mark = "Macro Dump";
2813
2814         int i;
2815
2816         char buf[1024];
2817
2818         /* Build the filename */
2819         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2820
2821         /* File type is "TEXT" */
2822         FILE_TYPE(FILE_TYPE_TEXT);
2823
2824         /* Append to the file */
2825         if (!open_auto_dump(buf, mark)) return (-1);
2826
2827         /* Start dumping */
2828 #ifdef JP
2829         auto_dump_printf("\n# ¼«Æ°¥Þ¥¯¥í¥»¡¼¥Ö\n\n");
2830 #else
2831         auto_dump_printf("\n# Automatic macro dump\n\n");
2832 #endif
2833
2834         /* Dump them */
2835         for (i = 0; i < macro__num; i++)
2836         {
2837                 /* Extract the action */
2838                 ascii_to_text(buf, macro__act[i]);
2839
2840                 /* Dump the macro */
2841                 auto_dump_printf("A:%s\n", buf);
2842
2843                 /* Extract the action */
2844                 ascii_to_text(buf, macro__pat[i]);
2845
2846                 /* Dump normal macros */
2847                 auto_dump_printf("P:%s\n", buf);
2848
2849                 /* End the macro */
2850                 auto_dump_printf("\n");
2851         }
2852
2853         /* Close */
2854         close_auto_dump();
2855
2856         /* Success */
2857         return (0);
2858 }
2859
2860
2861 /*
2862  * Hack -- ask for a "trigger" (see below)
2863  *
2864  * Note the complex use of the "inkey()" function from "util.c".
2865  *
2866  * Note that both "flush()" calls are extremely important.
2867  */
2868 static void do_cmd_macro_aux(char *buf)
2869 {
2870         int i, n = 0;
2871
2872         char tmp[1024];
2873
2874
2875         /* Flush */
2876         flush();
2877
2878         /* Do not process macros */
2879         inkey_base = TRUE;
2880
2881         /* First key */
2882         i = inkey();
2883
2884         /* Read the pattern */
2885         while (i)
2886         {
2887                 /* Save the key */
2888                 buf[n++] = i;
2889
2890                 /* Do not process macros */
2891                 inkey_base = TRUE;
2892
2893                 /* Do not wait for keys */
2894                 inkey_scan = TRUE;
2895
2896                 /* Attempt to read a key */
2897                 i = inkey();
2898         }
2899
2900         /* Terminate */
2901         buf[n] = '\0';
2902
2903         /* Flush */
2904         flush();
2905
2906
2907         /* Convert the trigger */
2908         ascii_to_text(tmp, buf);
2909
2910         /* Hack -- display the trigger */
2911         Term_addstr(-1, TERM_WHITE, tmp);
2912 }
2913
2914 #endif
2915
2916
2917 /*
2918  * Hack -- ask for a keymap "trigger" (see below)
2919  *
2920  * Note that both "flush()" calls are extremely important.  This may
2921  * no longer be true, since "util.c" is much simpler now.  XXX XXX XXX
2922  */
2923 static void do_cmd_macro_aux_keymap(char *buf)
2924 {
2925         char tmp[1024];
2926
2927
2928         /* Flush */
2929         flush();
2930
2931
2932         /* Get a key */
2933         buf[0] = inkey();
2934         buf[1] = '\0';
2935
2936
2937         /* Convert to ascii */
2938         ascii_to_text(tmp, buf);
2939
2940         /* Hack -- display the trigger */
2941         Term_addstr(-1, TERM_WHITE, tmp);
2942
2943
2944         /* Flush */
2945         flush();
2946 }
2947
2948
2949 /*
2950  * Hack -- append all keymaps to the given file
2951  */
2952 static errr keymap_dump(cptr fname)
2953 {
2954         static cptr mark = "Keymap Dump";
2955         int i;
2956
2957         char key[1024];
2958         char buf[1024];
2959
2960         int mode;
2961
2962         /* Roguelike */
2963         if (rogue_like_commands)
2964         {
2965                 mode = KEYMAP_MODE_ROGUE;
2966         }
2967
2968         /* Original */
2969         else
2970         {
2971                 mode = KEYMAP_MODE_ORIG;
2972         }
2973
2974
2975         /* Build the filename */
2976         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2977
2978         /* File type is "TEXT" */
2979         FILE_TYPE(FILE_TYPE_TEXT);
2980
2981         /* Append to the file */
2982         if (!open_auto_dump(buf, mark)) return -1;
2983
2984         /* Start dumping */
2985 #ifdef JP
2986         auto_dump_printf("\n# ¼«Æ°¥­¡¼ÇÛÃÖ¥»¡¼¥Ö\n\n");
2987 #else
2988         auto_dump_printf("\n# Automatic keymap dump\n\n");
2989 #endif
2990
2991         /* Dump them */
2992         for (i = 0; i < 256; i++)
2993         {
2994                 cptr act;
2995
2996                 /* Loop up the keymap */
2997                 act = keymap_act[mode][i];
2998
2999                 /* Skip empty keymaps */
3000                 if (!act) continue;
3001
3002                 /* Encode the key */
3003                 buf[0] = i;
3004                 buf[1] = '\0';
3005                 ascii_to_text(key, buf);
3006
3007                 /* Encode the action */
3008                 ascii_to_text(buf, act);
3009
3010                 /* Dump the macro */
3011                 auto_dump_printf("A:%s\n", buf);
3012                 auto_dump_printf("C:%d:%s\n", mode, key);
3013         }
3014
3015         /* Close */
3016         close_auto_dump();
3017
3018         /* Success */
3019         return (0);
3020 }
3021
3022
3023
3024 /*
3025  * Interact with "macros"
3026  *
3027  * Note that the macro "action" must be defined before the trigger.
3028  *
3029  * Could use some helpful instructions on this page.  XXX XXX XXX
3030  */
3031 void do_cmd_macros(void)
3032 {
3033         int i;
3034
3035         char tmp[1024];
3036
3037         char buf[1024];
3038
3039         int mode;
3040
3041
3042         /* Roguelike */
3043         if (rogue_like_commands)
3044         {
3045                 mode = KEYMAP_MODE_ROGUE;
3046         }
3047
3048         /* Original */
3049         else
3050         {
3051                 mode = KEYMAP_MODE_ORIG;
3052         }
3053
3054         /* File type is "TEXT" */
3055         FILE_TYPE(FILE_TYPE_TEXT);
3056
3057
3058         /* Save screen */
3059         screen_save();
3060
3061
3062         /* Process requests until done */
3063         while (1)
3064         {
3065                 /* Clear screen */
3066                 Term_clear();
3067
3068                 /* Describe */
3069 #ifdef JP
3070                 prt("[ ¥Þ¥¯¥í¤ÎÀßÄê ]", 2, 0);
3071 #else
3072                 prt("Interact with Macros", 2, 0);
3073 #endif
3074
3075
3076
3077                 /* Describe that action */
3078 #ifdef JP
3079                 prt("¥Þ¥¯¥í¹ÔÆ°¤¬(¤â¤·¤¢¤ì¤Ð)²¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹:", 20, 0);
3080 #else
3081                 prt("Current action (if any) shown below:", 20, 0);
3082 #endif
3083
3084
3085                 /* Analyze the current action */
3086                 ascii_to_text(buf, macro__buf);
3087
3088                 /* Display the current action */
3089                 prt(buf, 22, 0);
3090
3091
3092                 /* Selections */
3093 #ifdef JP
3094                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
3095 #else
3096                 prt("(1) Load a user pref file", 4, 5);
3097 #endif
3098
3099 #ifdef ALLOW_MACROS
3100 #ifdef JP
3101                 prt("(2) ¥Õ¥¡¥¤¥ë¤Ë¥Þ¥¯¥í¤òÄɲÃ", 5, 5);
3102                 prt("(3) ¥Þ¥¯¥í¤Î³Îǧ", 6, 5);
3103                 prt("(4) ¥Þ¥¯¥í¤ÎºîÀ®", 7, 5);
3104                 prt("(5) ¥Þ¥¯¥í¤Îºï½ü", 8, 5);
3105                 prt("(6) ¥Õ¥¡¥¤¥ë¤Ë¥­¡¼ÇÛÃÖ¤òÄɲÃ", 9, 5);
3106                 prt("(7) ¥­¡¼ÇÛÃ֤γÎǧ", 10, 5);
3107                 prt("(8) ¥­¡¼ÇÛÃ֤κîÀ®", 11, 5);
3108                 prt("(9) ¥­¡¼ÇÛÃ֤κï½ü", 12, 5);
3109                 prt("(0) ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 13, 5);
3110 #else
3111                 prt("(2) Append macros to a file", 5, 5);
3112                 prt("(3) Query a macro", 6, 5);
3113                 prt("(4) Create a macro", 7, 5);
3114                 prt("(5) Remove a macro", 8, 5);
3115                 prt("(6) Append keymaps to a file", 9, 5);
3116                 prt("(7) Query a keymap", 10, 5);
3117                 prt("(8) Create a keymap", 11, 5);
3118                 prt("(9) Remove a keymap", 12, 5);
3119                 prt("(0) Enter a new action", 13, 5);
3120 #endif
3121
3122 #endif /* ALLOW_MACROS */
3123
3124                 /* Prompt */
3125 #ifdef JP
3126                 prt("¥³¥Þ¥ó¥É: ", 16, 0);
3127 #else
3128                 prt("Command: ", 16, 0);
3129 #endif
3130
3131
3132                 /* Get a command */
3133                 i = inkey();
3134
3135                 /* Leave */
3136                 if (i == ESCAPE) break;
3137
3138                 /* Load a 'macro' file */
3139                 else if (i == '1')
3140                 {
3141                         errr err;
3142
3143                         /* Prompt */
3144 #ifdef JP
3145                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 16, 0);
3146 #else
3147                         prt("Command: Load a user pref file", 16, 0);
3148 #endif
3149
3150
3151                         /* Prompt */
3152 #ifdef JP
3153                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3154 #else
3155                         prt("File: ", 18, 0);
3156 #endif
3157
3158
3159                         /* Default filename */
3160                         sprintf(tmp, "%s.prf", player_base);
3161
3162                         /* Ask for a file */
3163                         if (!askfor(tmp, 80)) continue;
3164
3165                         /* Process the given filename */
3166                         err = process_pref_file(tmp);
3167                         if (-2 == err)
3168                         {
3169 #ifdef JP
3170                                 msg_format("ɸ½à¤ÎÀßÄê¥Õ¥¡¥¤¥ë'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
3171 #else
3172                                 msg_format("Loaded default '%s'.", tmp);
3173 #endif
3174                         }
3175                         else if (err)
3176                         {
3177                                 /* Prompt */
3178 #ifdef JP
3179                                 msg_format("'%s'¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", tmp);
3180 #else
3181                                 msg_format("Failed to load '%s'!");
3182 #endif
3183                         }
3184                         else
3185                         {
3186 #ifdef JP
3187                                 msg_format("'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
3188 #else
3189                                 msg_format("Loaded '%s'.", tmp);
3190 #endif
3191                         }
3192                 }
3193
3194 #ifdef ALLOW_MACROS
3195
3196                 /* Save macros */
3197                 else if (i == '2')
3198                 {
3199                         /* Prompt */
3200 #ifdef JP
3201                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤ò¥Õ¥¡¥¤¥ë¤ËÄɲ乤ë", 16, 0);
3202 #else
3203                         prt("Command: Append macros to a file", 16, 0);
3204 #endif
3205
3206
3207                         /* Prompt */
3208 #ifdef JP
3209                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3210 #else
3211                         prt("File: ", 18, 0);
3212 #endif
3213
3214
3215                         /* Default filename */
3216                         sprintf(tmp, "%s.prf", player_base);
3217
3218                         /* Ask for a file */
3219                         if (!askfor(tmp, 80)) continue;
3220
3221                         /* Dump the macros */
3222                         (void)macro_dump(tmp);
3223
3224                         /* Prompt */
3225 #ifdef JP
3226                         msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
3227 #else
3228                         msg_print("Appended macros.");
3229 #endif
3230
3231                 }
3232
3233                 /* Query a macro */
3234                 else if (i == '3')
3235                 {
3236                         int k;
3237
3238                         /* Prompt */
3239 #ifdef JP
3240                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤Î³Îǧ", 16, 0);
3241 #else
3242                         prt("Command: Query a macro", 16, 0);
3243 #endif
3244
3245
3246                         /* Prompt */
3247 #ifdef JP
3248                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3249 #else
3250                         prt("Trigger: ", 18, 0);
3251 #endif
3252
3253
3254                         /* Get a macro trigger */
3255                         do_cmd_macro_aux(buf);
3256
3257                         /* Acquire action */
3258                         k = macro_find_exact(buf);
3259
3260                         /* Nothing found */
3261                         if (k < 0)
3262                         {
3263                                 /* Prompt */
3264 #ifdef JP
3265                                 msg_print("¤½¤Î¥­¡¼¤Ë¤Ï¥Þ¥¯¥í¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
3266 #else
3267                                 msg_print("Found no macro.");
3268 #endif
3269
3270                         }
3271
3272                         /* Found one */
3273                         else
3274                         {
3275                                 /* Obtain the action */
3276                                 strcpy(macro__buf, macro__act[k]);
3277
3278                                 /* Analyze the current action */
3279                                 ascii_to_text(buf, macro__buf);
3280
3281                                 /* Display the current action */
3282                                 prt(buf, 22, 0);
3283
3284                                 /* Prompt */
3285 #ifdef JP
3286                                 msg_print("¥Þ¥¯¥í¤ò³Îǧ¤·¤Þ¤·¤¿¡£");
3287 #else
3288                                 msg_print("Found a macro.");
3289 #endif
3290
3291                         }
3292                 }
3293
3294                 /* Create a macro */
3295                 else if (i == '4')
3296                 {
3297                         /* Prompt */
3298 #ifdef JP
3299                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤ÎºîÀ®", 16, 0);
3300 #else
3301                         prt("Command: Create a macro", 16, 0);
3302 #endif
3303
3304
3305                         /* Prompt */
3306 #ifdef JP
3307                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3308 #else
3309                         prt("Trigger: ", 18, 0);
3310 #endif
3311
3312
3313                         /* Get a macro trigger */
3314                         do_cmd_macro_aux(buf);
3315
3316                         /* Clear */
3317                         clear_from(20);
3318
3319                         /* Help message */
3320 #ifdef JP
3321                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3322 #else
3323                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3324 #endif
3325
3326                         /* Prompt */
3327 #ifdef JP
3328                         prt("¥Þ¥¯¥í¹ÔÆ°: ", 20, 0);
3329 #else
3330                         prt("Action: ", 20, 0);
3331 #endif
3332
3333
3334                         /* Convert to text */
3335                         ascii_to_text(tmp, macro__buf);
3336
3337                         /* Get an encoded action */
3338                         if (askfor(tmp, 80))
3339                         {
3340                                 /* Convert to ascii */
3341                                 text_to_ascii(macro__buf, tmp);
3342
3343                                 /* Link the macro */
3344                                 macro_add(buf, macro__buf);
3345
3346                                 /* Prompt */
3347 #ifdef JP
3348                                 msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
3349 #else
3350                                 msg_print("Added a macro.");
3351 #endif
3352
3353                         }
3354                 }
3355
3356                 /* Remove a macro */
3357                 else if (i == '5')
3358                 {
3359                         /* Prompt */
3360 #ifdef JP
3361                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤Îºï½ü", 16, 0);
3362 #else
3363                         prt("Command: Remove a macro", 16, 0);
3364 #endif
3365
3366
3367                         /* Prompt */
3368 #ifdef JP
3369                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3370 #else
3371                         prt("Trigger: ", 18, 0);
3372 #endif
3373
3374
3375                         /* Get a macro trigger */
3376                         do_cmd_macro_aux(buf);
3377
3378                         /* Link the macro */
3379                         macro_add(buf, buf);
3380
3381                         /* Prompt */
3382 #ifdef JP
3383                         msg_print("¥Þ¥¯¥í¤òºï½ü¤·¤Þ¤·¤¿¡£");
3384 #else
3385                         msg_print("Removed a macro.");
3386 #endif
3387
3388                 }
3389
3390                 /* Save keymaps */
3391                 else if (i == '6')
3392                 {
3393                         /* Prompt */
3394 #ifdef JP
3395                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃÖ¤ò¥Õ¥¡¥¤¥ë¤ËÄɲ乤ë", 16, 0);
3396 #else
3397                         prt("Command: Append keymaps to a file", 16, 0);
3398 #endif
3399
3400
3401                         /* Prompt */
3402 #ifdef JP
3403                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3404 #else
3405                         prt("File: ", 18, 0);
3406 #endif
3407
3408
3409                         /* Default filename */
3410                         sprintf(tmp, "%s.prf", player_base);
3411
3412                         /* Ask for a file */
3413                         if (!askfor(tmp, 80)) continue;
3414
3415                         /* Dump the macros */
3416                         (void)keymap_dump(tmp);
3417
3418                         /* Prompt */
3419 #ifdef JP
3420                         msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
3421 #else
3422                         msg_print("Appended keymaps.");
3423 #endif
3424
3425                 }
3426
3427                 /* Query a keymap */
3428                 else if (i == '7')
3429                 {
3430                         cptr act;
3431
3432                         /* Prompt */
3433 #ifdef JP
3434                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤γÎǧ", 16, 0);
3435 #else
3436                         prt("Command: Query a keymap", 16, 0);
3437 #endif
3438
3439
3440                         /* Prompt */
3441 #ifdef JP
3442                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3443 #else
3444                         prt("Keypress: ", 18, 0);
3445 #endif
3446
3447
3448                         /* Get a keymap trigger */
3449                         do_cmd_macro_aux_keymap(buf);
3450
3451                         /* Look up the keymap */
3452                         act = keymap_act[mode][(byte)(buf[0])];
3453
3454                         /* Nothing found */
3455                         if (!act)
3456                         {
3457                                 /* Prompt */
3458 #ifdef JP
3459                                 msg_print("¥­¡¼ÇÛÃÖ¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
3460 #else
3461                                 msg_print("Found no keymap.");
3462 #endif
3463
3464                         }
3465
3466                         /* Found one */
3467                         else
3468                         {
3469                                 /* Obtain the action */
3470                                 strcpy(macro__buf, act);
3471
3472                                 /* Analyze the current action */
3473                                 ascii_to_text(buf, macro__buf);
3474
3475                                 /* Display the current action */
3476                                 prt(buf, 22, 0);
3477
3478                                 /* Prompt */
3479 #ifdef JP
3480                                 msg_print("¥­¡¼ÇÛÃÖ¤ò³Îǧ¤·¤Þ¤·¤¿¡£");
3481 #else
3482                                 msg_print("Found a keymap.");
3483 #endif
3484
3485                         }
3486                 }
3487
3488                 /* Create a keymap */
3489                 else if (i == '8')
3490                 {
3491                         /* Prompt */
3492 #ifdef JP
3493                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤κîÀ®", 16, 0);
3494 #else
3495                         prt("Command: Create a keymap", 16, 0);
3496 #endif
3497
3498
3499                         /* Prompt */
3500 #ifdef JP
3501                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3502 #else
3503                         prt("Keypress: ", 18, 0);
3504 #endif
3505
3506
3507                         /* Get a keymap trigger */
3508                         do_cmd_macro_aux_keymap(buf);
3509
3510                         /* Clear */
3511                         clear_from(20);
3512
3513                         /* Help message */
3514 #ifdef JP
3515                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3516 #else
3517                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3518 #endif
3519
3520                         /* Prompt */
3521 #ifdef JP
3522                         prt("¹ÔÆ°: ", 20, 0);
3523 #else
3524                         prt("Action: ", 20, 0);
3525 #endif
3526
3527
3528                         /* Convert to text */
3529                         ascii_to_text(tmp, macro__buf);
3530
3531                         /* Get an encoded action */
3532                         if (askfor(tmp, 80))
3533                         {
3534                                 /* Convert to ascii */
3535                                 text_to_ascii(macro__buf, tmp);
3536
3537                                 /* Free old keymap */
3538                                 string_free(keymap_act[mode][(byte)(buf[0])]);
3539
3540                                 /* Make new keymap */
3541                                 keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
3542
3543                                 /* Prompt */
3544 #ifdef JP
3545                                 msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
3546 #else
3547                                 msg_print("Added a keymap.");
3548 #endif
3549
3550                         }
3551                 }
3552
3553                 /* Remove a keymap */
3554                 else if (i == '9')
3555                 {
3556                         /* Prompt */
3557 #ifdef JP
3558                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤κï½ü", 16, 0);
3559 #else
3560                         prt("Command: Remove a keymap", 16, 0);
3561 #endif
3562
3563
3564                         /* Prompt */
3565 #ifdef JP
3566                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3567 #else
3568                         prt("Keypress: ", 18, 0);
3569 #endif
3570
3571
3572                         /* Get a keymap trigger */
3573                         do_cmd_macro_aux_keymap(buf);
3574
3575                         /* Free old keymap */
3576                         string_free(keymap_act[mode][(byte)(buf[0])]);
3577
3578                         /* Make new keymap */
3579                         keymap_act[mode][(byte)(buf[0])] = NULL;
3580
3581                         /* Prompt */
3582 #ifdef JP
3583                         msg_print("¥­¡¼ÇÛÃÖ¤òºï½ü¤·¤Þ¤·¤¿¡£");
3584 #else
3585                         msg_print("Removed a keymap.");
3586 #endif
3587
3588                 }
3589
3590                 /* Enter a new action */
3591                 else if (i == '0')
3592                 {
3593                         /* Prompt */
3594 #ifdef JP
3595                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 16, 0);
3596 #else
3597                         prt("Command: Enter a new action", 16, 0);
3598 #endif
3599
3600                         /* Clear */
3601                         clear_from(20);
3602
3603                         /* Help message */
3604 #ifdef JP
3605                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3606 #else
3607                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3608 #endif
3609
3610                         /* Prompt */
3611 #ifdef JP
3612                         prt("¥Þ¥¯¥í¹ÔÆ°: ", 20, 0);
3613 #else
3614                         prt("Action: ", 20, 0);
3615 #endif
3616
3617                         /* Hack -- limit the value */
3618                         tmp[80] = '\0';
3619
3620                         /* Get an encoded action */
3621                         if (!askfor(buf, 80)) continue;
3622
3623                         /* Extract an action */
3624                         text_to_ascii(macro__buf, buf);
3625                 }
3626
3627 #endif /* ALLOW_MACROS */
3628
3629                 /* Oops */
3630                 else
3631                 {
3632                         /* Oops */
3633                         bell();
3634                 }
3635
3636                 /* Flush messages */
3637                 msg_print(NULL);
3638         }
3639
3640         /* Load screen */
3641         screen_load();
3642 }
3643
3644
3645 static cptr lighting_level_str[F_LIT_MAX] =
3646 {
3647 #ifdef JP
3648         "ɸ½à¿§",
3649         "ÌÀ¿§",
3650         "°Å¿§",
3651 #else
3652         "standard",
3653         "brightly lit",
3654         "darkened",
3655 #endif
3656 };
3657
3658
3659 static bool cmd_visuals_aux(int i, int *num, int max)
3660 {
3661         if (iscntrl(i))
3662         {
3663                 char str[10] = "";
3664                 int tmp;
3665
3666                 sprintf(str, "%d", *num);
3667
3668                 if (!get_string(format("Input new number(0-%d): ", max-1), str, 4))
3669                         return FALSE;
3670
3671                 tmp = strtol(str, NULL, 0);
3672                 if (tmp >= 0 && tmp < max)
3673                         *num = tmp;
3674         }
3675         else if (isupper(i))
3676                 *num = (*num + max - 1) % max;
3677         else
3678                 *num = (*num + 1) % max;
3679
3680         return TRUE;
3681 }
3682
3683 static void print_visuals_menu(cptr choice_msg)
3684 {
3685 #ifdef JP
3686         prt("[ ²èÌÌɽ¼¨¤ÎÀßÄê ]", 1, 0);
3687 #else
3688         prt("Interact with Visuals", 1, 0);
3689 #endif
3690
3691         /* Give some choices */
3692 #ifdef JP
3693         prt("(0) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 3, 5);
3694 #else
3695         prt("(0) Load a user pref file", 3, 5);
3696 #endif
3697
3698 #ifdef ALLOW_VISUALS
3699 #ifdef JP
3700         prt("(1) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 4, 5);
3701         prt("(2) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
3702         prt("(3) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 6, 5);
3703         prt("(4) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 7, 5);
3704         prt("(5) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 8, 5);
3705         prt("(6) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 9, 5);
3706         prt("(7) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 10, 5);
3707         prt("(8) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 11, 5);
3708         prt("(9) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 12, 5);
3709 #else
3710         prt("(1) Dump monster attr/chars", 4, 5);
3711         prt("(2) Dump object attr/chars", 5, 5);
3712         prt("(3) Dump feature attr/chars", 6, 5);
3713         prt("(4) Change monster attr/chars (numeric operation)", 7, 5);
3714         prt("(5) Change object attr/chars (numeric operation)", 8, 5);
3715         prt("(6) Change feature attr/chars (numeric operation)", 9, 5);
3716         prt("(7) Change monster attr/chars (visual mode)", 10, 5);
3717         prt("(8) Change object attr/chars (visual mode)", 11, 5);
3718         prt("(9) Change feature attr/chars (visual mode)", 12, 5);
3719 #endif
3720
3721 #endif /* ALLOW_VISUALS */
3722
3723 #ifdef JP
3724         prt("(R) ²èÌÌɽ¼¨ÊýË¡¤Î½é´ü²½", 13, 5);
3725 #else
3726         prt("(R) Reset visuals", 13, 5);
3727 #endif
3728
3729         /* Prompt */
3730 #ifdef JP
3731         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg ? choice_msg : ""), 15, 0);
3732 #else
3733         prt(format("Command: %s", choice_msg ? choice_msg : ""), 15, 0);
3734 #endif
3735 }
3736
3737 static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int direct_r_idx);
3738 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int direct_k_idx);
3739 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int direct_f_idx, int *lighting_level);
3740
3741 /*
3742  * Interact with "visuals"
3743  */
3744 void do_cmd_visuals(void)
3745 {
3746         int i;
3747         char tmp[160];
3748         char buf[1024];
3749         bool need_redraw = FALSE;
3750         const char *empty_symbol = "<< ? >>";
3751
3752         if (use_bigtile) empty_symbol = "<< ?? >>";
3753
3754         /* File type is "TEXT" */
3755         FILE_TYPE(FILE_TYPE_TEXT);
3756
3757         /* Save the screen */
3758         screen_save();
3759
3760         /* Interact until done */
3761         while (1)
3762         {
3763                 /* Clear screen */
3764                 Term_clear();
3765
3766                 /* Ask for a choice */
3767                 print_visuals_menu(NULL);
3768
3769                 /* Prompt */
3770                 i = inkey();
3771
3772                 /* Done */
3773                 if (i == ESCAPE) break;
3774
3775                 switch (i)
3776                 {
3777                 /* Load a 'pref' file */
3778                 case '0':
3779                         /* Prompt */
3780 #ifdef JP
3781                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 15, 0);
3782 #else
3783                         prt("Command: Load a user pref file", 15, 0);
3784 #endif
3785
3786                         /* Prompt */
3787 #ifdef JP
3788                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3789 #else
3790                         prt("File: ", 17, 0);
3791 #endif
3792
3793                         /* Default filename */
3794                         sprintf(tmp, "%s.prf", player_base);
3795
3796                         /* Query */
3797                         if (!askfor(tmp, 70)) continue;
3798
3799                         /* Process the given filename */
3800                         (void)process_pref_file(tmp);
3801
3802                         need_redraw = TRUE;
3803                         break;
3804
3805 #ifdef ALLOW_VISUALS
3806
3807                 /* Dump monster attr/chars */
3808                 case '1':
3809                 {
3810                         static cptr mark = "Monster attr/chars";
3811
3812                         /* Prompt */
3813 #ifdef JP
3814                         prt("¥³¥Þ¥ó¥É: ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3815 #else
3816                         prt("Command: Dump monster attr/chars", 15, 0);
3817 #endif
3818
3819                         /* Prompt */
3820 #ifdef JP
3821                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3822 #else
3823                         prt("File: ", 17, 0);
3824 #endif
3825
3826                         /* Default filename */
3827                         sprintf(tmp, "%s.prf", player_base);
3828
3829                         /* Get a filename */
3830                         if (!askfor(tmp, 70)) continue;
3831
3832                         /* Build the filename */
3833                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3834
3835                         /* Append to the file */
3836                         if (!open_auto_dump(buf, mark)) continue;
3837
3838                         /* Start dumping */
3839 #ifdef JP
3840                         auto_dump_printf("\n# ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3841 #else
3842                         auto_dump_printf("\n# Monster attr/char definitions\n\n");
3843 #endif
3844
3845                         /* Dump monsters */
3846                         for (i = 0; i < max_r_idx; i++)
3847                         {
3848                                 monster_race *r_ptr = &r_info[i];
3849
3850                                 /* Skip non-entries */
3851                                 if (!r_ptr->name) continue;
3852
3853                                 /* Dump a comment */
3854                                 auto_dump_printf("# %s\n", (r_name + r_ptr->name));
3855
3856                                 /* Dump the monster attr/char info */
3857                                 auto_dump_printf("R:%d:0x%02X/0x%02X\n\n", i,
3858                                         (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char));
3859                         }
3860
3861                         /* Close */
3862                         close_auto_dump();
3863
3864                         /* Message */
3865 #ifdef JP
3866                         msg_print("¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3867 #else
3868                         msg_print("Dumped monster attr/chars.");
3869 #endif
3870
3871                         break;
3872                 }
3873
3874                 /* Dump object attr/chars */
3875                 case '2':
3876                 {
3877                         static cptr mark = "Object attr/chars";
3878
3879                         /* Prompt */
3880 #ifdef JP
3881                         prt("¥³¥Þ¥ó¥É: ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3882 #else
3883                         prt("Command: Dump object attr/chars", 15, 0);
3884 #endif
3885
3886                         /* Prompt */
3887 #ifdef JP
3888                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3889 #else
3890                         prt("File: ", 17, 0);
3891 #endif
3892
3893                         /* Default filename */
3894                         sprintf(tmp, "%s.prf", player_base);
3895
3896                         /* Get a filename */
3897                         if (!askfor(tmp, 70)) continue;
3898
3899                         /* Build the filename */
3900                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3901
3902                         /* Append to the file */
3903                         if (!open_auto_dump(buf, mark)) continue;
3904
3905                         /* Start dumping */
3906 #ifdef JP
3907                         auto_dump_printf("\n# ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3908 #else
3909                         auto_dump_printf("\n# Object attr/char definitions\n\n");
3910 #endif
3911
3912                         /* Dump objects */
3913                         for (i = 0; i < max_k_idx; i++)
3914                         {
3915                                 char o_name[80];
3916                                 object_kind *k_ptr = &k_info[i];
3917
3918                                 /* Skip non-entries */
3919                                 if (!k_ptr->name) continue;
3920
3921                                 if (!k_ptr->flavor)
3922                                 {
3923                                         /* Tidy name */
3924                                         strip_name(o_name, i);
3925                                 }
3926                                 else
3927                                 {
3928                                         object_type forge;
3929
3930                                         /* Prepare dummy object */
3931                                         object_prep(&forge, i);
3932
3933                                         /* Get un-shuffled flavor name */
3934                                         object_desc(o_name, &forge, OD_FORCE_FLAVOR);
3935                                 }
3936
3937                                 /* Dump a comment */
3938                                 auto_dump_printf("# %s\n", o_name);
3939
3940                                 /* Dump the object attr/char info */
3941                                 auto_dump_printf("K:%d:0x%02X/0x%02X\n\n", i,
3942                                         (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char));
3943                         }
3944
3945                         /* Close */
3946                         close_auto_dump();
3947
3948                         /* Message */
3949 #ifdef JP
3950                         msg_print("¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3951 #else
3952                         msg_print("Dumped object attr/chars.");
3953 #endif
3954
3955                         break;
3956                 }
3957
3958                 /* Dump feature attr/chars */
3959                 case '3':
3960                 {
3961                         static cptr mark = "Feature attr/chars";
3962
3963                         /* Prompt */
3964 #ifdef JP
3965                         prt("¥³¥Þ¥ó¥É: ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3966 #else
3967                         prt("Command: Dump feature attr/chars", 15, 0);
3968 #endif
3969
3970                         /* Prompt */
3971 #ifdef JP
3972                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3973 #else
3974                         prt("File: ", 17, 0);
3975 #endif
3976
3977                         /* Default filename */
3978                         sprintf(tmp, "%s.prf", player_base);
3979
3980                         /* Get a filename */
3981                         if (!askfor(tmp, 70)) continue;
3982
3983                         /* Build the filename */
3984                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3985
3986                         /* Append to the file */
3987                         if (!open_auto_dump(buf, mark)) continue;
3988
3989                         /* Start dumping */
3990 #ifdef JP
3991                         auto_dump_printf("\n# ÃÏ·Á¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3992 #else
3993                         auto_dump_printf("\n# Feature attr/char definitions\n\n");
3994 #endif
3995
3996                         /* Dump features */
3997                         for (i = 0; i < max_f_idx; i++)
3998                         {
3999                                 feature_type *f_ptr = &f_info[i];
4000
4001                                 /* Skip non-entries */
4002                                 if (!f_ptr->name) continue;
4003
4004                                 /* Skip mimiccing features */
4005                                 if (f_ptr->mimic != i) continue;
4006
4007                                 /* Dump a comment */
4008                                 auto_dump_printf("# %s\n", (f_name + f_ptr->name));
4009
4010                                 /* Dump the feature attr/char info */
4011                                 auto_dump_printf("F:%d:0x%02X/0x%02X:0x%02X/0x%02X:0x%02X/0x%02X\n\n", i,
4012                                         (byte)(f_ptr->x_attr[F_LIT_STANDARD]), (byte)(f_ptr->x_char[F_LIT_STANDARD]),
4013                                         (byte)(f_ptr->x_attr[F_LIT_LITE]), (byte)(f_ptr->x_char[F_LIT_LITE]),
4014                                         (byte)(f_ptr->x_attr[F_LIT_DARK]), (byte)(f_ptr->x_char[F_LIT_DARK]));
4015                         }
4016
4017                         /* Close */
4018                         close_auto_dump();
4019
4020                         /* Message */
4021 #ifdef JP
4022                         msg_print("ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4023 #else
4024                         msg_print("Dumped feature attr/chars.");
4025 #endif
4026
4027                         break;
4028                 }
4029
4030                 /* Modify monster attr/chars (numeric operation) */
4031                 case '4':
4032                 {
4033 #ifdef JP
4034                         static cptr choice_msg = "¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4035 #else
4036                         static cptr choice_msg = "Change monster attr/chars";
4037 #endif
4038                         static int r = 0;
4039
4040 #ifdef JP
4041                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4042 #else
4043                         prt(format("Command: %s", choice_msg), 15, 0);
4044 #endif
4045
4046                         /* Hack -- query until done */
4047                         while (1)
4048                         {
4049                                 monster_race *r_ptr = &r_info[r];
4050                                 char c;
4051                                 int t;
4052
4053                                 byte da = r_ptr->d_attr;
4054                                 byte dc = r_ptr->d_char;
4055                                 byte ca = r_ptr->x_attr;
4056                                 byte cc = r_ptr->x_char;
4057
4058                                 /* Label the object */
4059 #ifdef JP
4060                                 Term_putstr(5, 17, -1, TERM_WHITE,
4061                                             format("¥â¥ó¥¹¥¿¡¼ = %d, Ì¾Á° = %-40.40s",
4062                                                    r, (r_name + r_ptr->name)));
4063 #else
4064                                 Term_putstr(5, 17, -1, TERM_WHITE,
4065                                             format("Monster = %d, Name = %-40.40s",
4066                                                    r, (r_name + r_ptr->name)));
4067 #endif
4068
4069                                 /* Label the Default values */
4070 #ifdef JP
4071                                 Term_putstr(10, 19, -1, TERM_WHITE,
4072                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3u / %3u", da, dc));
4073 #else
4074                                 Term_putstr(10, 19, -1, TERM_WHITE,
4075                                             format("Default attr/char = %3u / %3u", da, dc));
4076 #endif
4077
4078                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4079                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4080
4081                                 /* Label the Current values */
4082 #ifdef JP
4083                                 Term_putstr(10, 20, -1, TERM_WHITE,
4084                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3u / %3u", ca, cc));
4085 #else
4086                                 Term_putstr(10, 20, -1, TERM_WHITE,
4087                                             format("Current attr/char = %3u / %3u", ca, cc));
4088 #endif
4089
4090                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4091                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4092
4093                                 /* Prompt */
4094 #ifdef JP
4095                                 Term_putstr(0, 22, -1, TERM_WHITE,
4096                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4097 #else
4098                                 Term_putstr(0, 22, -1, TERM_WHITE,
4099                                             "Command (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4100 #endif
4101
4102                                 /* Get a command */
4103                                 i = inkey();
4104
4105                                 /* All done */
4106                                 if (i == ESCAPE) break;
4107
4108                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4109                                 else if (isupper(i)) c = 'a' + i - 'A';
4110                                 else c = i;
4111
4112                                 switch (c)
4113                                 {
4114                                 case 'n':
4115                                         {
4116                                                 int prev_r = r;
4117                                                 do
4118                                                 {
4119                                                         if (!cmd_visuals_aux(i, &r, max_r_idx))
4120                                                         {
4121                                                                 r = prev_r;
4122                                                                 break;
4123                                                         }
4124                                                 }
4125                                                 while (!r_info[r].name);
4126                                         }
4127                                         break;
4128                                 case 'a':
4129                                         t = (int)r_ptr->x_attr;
4130                                         (void)cmd_visuals_aux(i, &t, 256);
4131                                         r_ptr->x_attr = (byte)t;
4132                                         need_redraw = TRUE;
4133                                         break;
4134                                 case 'c':
4135                                         t = (int)r_ptr->x_char;
4136                                         (void)cmd_visuals_aux(i, &t, 256);
4137                                         r_ptr->x_char = (byte)t;
4138                                         need_redraw = TRUE;
4139                                         break;
4140                                 case 'v':
4141                                         do_cmd_knowledge_monsters(&need_redraw, TRUE, r);
4142
4143                                         /* Clear screen */
4144                                         Term_clear();
4145                                         print_visuals_menu(choice_msg);
4146                                         break;
4147                                 }
4148                         }
4149
4150                         break;
4151                 }
4152
4153                 /* Modify object attr/chars (numeric operation) */
4154                 case '5':
4155                 {
4156 #ifdef JP
4157                         static cptr choice_msg = "¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4158 #else
4159                         static cptr choice_msg = "Change object attr/chars";
4160 #endif
4161                         static int k = 0;
4162
4163 #ifdef JP
4164                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4165 #else
4166                         prt(format("Command: %s", choice_msg), 15, 0);
4167 #endif
4168
4169                         /* Hack -- query until done */
4170                         while (1)
4171                         {
4172                                 object_kind *k_ptr = &k_info[k];
4173                                 char c;
4174                                 int t;
4175
4176                                 byte da = k_ptr->d_attr;
4177                                 byte dc = k_ptr->d_char;
4178                                 byte ca = k_ptr->x_attr;
4179                                 byte cc = k_ptr->x_char;
4180
4181                                 /* Label the object */
4182 #ifdef JP
4183                                 Term_putstr(5, 17, -1, TERM_WHITE,
4184                                             format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
4185                                                    k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
4186 #else
4187                                 Term_putstr(5, 17, -1, TERM_WHITE,
4188                                             format("Object = %d, Name = %-40.40s",
4189                                                    k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
4190 #endif
4191
4192                                 /* Label the Default values */
4193 #ifdef JP
4194                                 Term_putstr(10, 19, -1, TERM_WHITE,
4195                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4196 #else
4197                                 Term_putstr(10, 19, -1, TERM_WHITE,
4198                                             format("Default attr/char = %3d / %3d", da, dc));
4199 #endif
4200
4201                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4202                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4203
4204                                 /* Label the Current values */
4205 #ifdef JP
4206                                 Term_putstr(10, 20, -1, TERM_WHITE,
4207                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4208 #else
4209                                 Term_putstr(10, 20, -1, TERM_WHITE,
4210                                             format("Current attr/char = %3d / %3d", ca, cc));
4211 #endif
4212
4213                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4214                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4215
4216                                 /* Prompt */
4217 #ifdef JP
4218                                 Term_putstr(0, 22, -1, TERM_WHITE,
4219                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4220 #else
4221                                 Term_putstr(0, 22, -1, TERM_WHITE,
4222                                             "Command (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4223 #endif
4224
4225                                 /* Get a command */
4226                                 i = inkey();
4227
4228                                 /* All done */
4229                                 if (i == ESCAPE) break;
4230
4231                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4232                                 else if (isupper(i)) c = 'a' + i - 'A';
4233                                 else c = i;
4234
4235                                 switch (c)
4236                                 {
4237                                 case 'n':
4238                                         {
4239                                                 int prev_k = k;
4240                                                 do
4241                                                 {
4242                                                         if (!cmd_visuals_aux(i, &k, max_k_idx))
4243                                                         {
4244                                                                 k = prev_k;
4245                                                                 break;
4246                                                         }
4247                                                 }
4248                                                 while (!k_info[k].name);
4249                                         }
4250                                         break;
4251                                 case 'a':
4252                                         t = (int)k_ptr->x_attr;
4253                                         (void)cmd_visuals_aux(i, &t, 256);
4254                                         k_ptr->x_attr = (byte)t;
4255                                         need_redraw = TRUE;
4256                                         break;
4257                                 case 'c':
4258                                         t = (int)k_ptr->x_char;
4259                                         (void)cmd_visuals_aux(i, &t, 256);
4260                                         k_ptr->x_char = (byte)t;
4261                                         need_redraw = TRUE;
4262                                         break;
4263                                 case 'v':
4264                                         do_cmd_knowledge_objects(&need_redraw, TRUE, k);
4265
4266                                         /* Clear screen */
4267                                         Term_clear();
4268                                         print_visuals_menu(choice_msg);
4269                                         break;
4270                                 }
4271                         }
4272
4273                         break;
4274                 }
4275
4276                 /* Modify feature attr/chars (numeric operation) */
4277                 case '6':
4278                 {
4279 #ifdef JP
4280                         static cptr choice_msg = "ÃÏ·Á¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4281 #else
4282                         static cptr choice_msg = "Change feature attr/chars";
4283 #endif
4284                         static int f = 0;
4285                         static int lighting_level = F_LIT_STANDARD;
4286
4287 #ifdef JP
4288                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4289 #else
4290                         prt(format("Command: %s", choice_msg), 15, 0);
4291 #endif
4292
4293                         /* Hack -- query until done */
4294                         while (1)
4295                         {
4296                                 feature_type *f_ptr = &f_info[f];
4297                                 char c;
4298                                 int t;
4299
4300                                 byte da = f_ptr->d_attr[lighting_level];
4301                                 byte dc = f_ptr->d_char[lighting_level];
4302                                 byte ca = f_ptr->x_attr[lighting_level];
4303                                 byte cc = f_ptr->x_char[lighting_level];
4304
4305                                 /* Label the object */
4306                                 prt("", 17, 5);
4307 #ifdef JP
4308                                 Term_putstr(5, 17, -1, TERM_WHITE,
4309                                             format("ÃÏ·Á = %d, Ì¾Á° = %s, ÌÀÅÙ = %s",
4310                                                    f, (f_name + f_ptr->name), lighting_level_str[lighting_level]));
4311 #else
4312                                 Term_putstr(5, 17, -1, TERM_WHITE,
4313                                             format("Terrain = %d, Name = %s, Lighting = %s",
4314                                                    f, (f_name + f_ptr->name), lighting_level_str[lighting_level]));
4315 #endif
4316
4317                                 /* Label the Default values */
4318 #ifdef JP
4319                                 Term_putstr(10, 19, -1, TERM_WHITE,
4320                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4321 #else
4322                                 Term_putstr(10, 19, -1, TERM_WHITE,
4323                                             format("Default attr/char = %3d / %3d", da, dc));
4324 #endif
4325
4326                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4327
4328                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4329
4330                                 /* Label the Current values */
4331 #ifdef JP
4332                                 Term_putstr(10, 20, -1, TERM_WHITE,
4333                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4334 #else
4335                                 Term_putstr(10, 20, -1, TERM_WHITE,
4336                                             format("Current attr/char = %3d / %3d", ca, cc));
4337 #endif
4338
4339                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4340                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4341
4342                                 /* Prompt */
4343 #ifdef JP
4344                                 Term_putstr(0, 22, -1, TERM_WHITE,
4345                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/l/L/^L/d/D/^D/v/V/^V): ");
4346 #else
4347                                 Term_putstr(0, 22, -1, TERM_WHITE,
4348                                             "Command (n/N/^N/a/A/^A/c/C/^C/l/L/^L/d/D/^D/v/V/^V): ");
4349 #endif
4350
4351                                 /* Get a command */
4352                                 i = inkey();
4353
4354                                 /* All done */
4355                                 if (i == ESCAPE) break;
4356
4357                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4358                                 else if (isupper(i)) c = 'a' + i - 'A';
4359                                 else c = i;
4360
4361                                 switch (c)
4362                                 {
4363                                 case 'n':
4364                                         {
4365                                                 int prev_f = f;
4366                                                 do
4367                                                 {
4368                                                         if (!cmd_visuals_aux(i, &f, max_f_idx))
4369                                                         {
4370                                                                 f = prev_f;
4371                                                                 break;
4372                                                         }
4373                                                 }
4374                                                 while (!f_info[f].name || (f_info[f].mimic != f));
4375                                         }
4376                                         break;
4377                                 case 'a':
4378                                         t = (int)f_ptr->x_attr[lighting_level];
4379                                         (void)cmd_visuals_aux(i, &t, 256);
4380                                         f_ptr->x_attr[lighting_level] = (byte)t;
4381                                         need_redraw = TRUE;
4382                                         break;
4383                                 case 'c':
4384                                         t = (int)f_ptr->x_char[lighting_level];
4385                                         (void)cmd_visuals_aux(i, &t, 256);
4386                                         f_ptr->x_char[lighting_level] = (byte)t;
4387                                         need_redraw = TRUE;
4388                                         break;
4389                                 case 'l':
4390                                         (void)cmd_visuals_aux(i, &lighting_level, F_LIT_MAX);
4391                                         break;
4392                                 case 'd':
4393                                         apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
4394                                         need_redraw = TRUE;
4395                                         break;
4396                                 case 'v':
4397                                         do_cmd_knowledge_features(&need_redraw, TRUE, f, &lighting_level);
4398
4399                                         /* Clear screen */
4400                                         Term_clear();
4401                                         print_visuals_menu(choice_msg);
4402                                         break;
4403                                 }
4404                         }
4405
4406                         break;
4407                 }
4408
4409                 /* Modify monster attr/chars (visual mode) */
4410                 case '7':
4411                         do_cmd_knowledge_monsters(&need_redraw, TRUE, -1);
4412                         break;
4413
4414                 /* Modify object attr/chars (visual mode) */
4415                 case '8':
4416                         do_cmd_knowledge_objects(&need_redraw, TRUE, -1);
4417                         break;
4418
4419                 /* Modify feature attr/chars (visual mode) */
4420                 case '9':
4421                 {
4422                         int lighting_level = F_LIT_STANDARD;
4423                         do_cmd_knowledge_features(&need_redraw, TRUE, -1, &lighting_level);
4424                         break;
4425                 }
4426
4427 #endif /* ALLOW_VISUALS */
4428
4429                 /* Reset visuals */
4430                 case 'R':
4431                 case 'r':
4432                         /* Reset */
4433                         reset_visuals();
4434
4435                         /* Message */
4436 #ifdef JP
4437                         msg_print("²èÌ̾å¤Î[¿§/ʸ»ú]¤ò½é´üÃͤ˥ꥻ¥Ã¥È¤·¤Þ¤·¤¿¡£");
4438 #else
4439                         msg_print("Visual attr/char tables reset.");
4440 #endif
4441
4442                         need_redraw = TRUE;
4443                         break;
4444
4445                 /* Unknown option */
4446                 default:
4447                         bell();
4448                         break;
4449                 }
4450
4451                 /* Flush messages */
4452                 msg_print(NULL);
4453         }
4454
4455         /* Restore the screen */
4456         screen_load();
4457
4458         if (need_redraw) do_cmd_redraw();
4459 }
4460
4461
4462 /*
4463  * Interact with "colors"
4464  */
4465 void do_cmd_colors(void)
4466 {
4467         int i;
4468
4469         char tmp[160];
4470
4471         char buf[1024];
4472
4473
4474         /* File type is "TEXT" */
4475         FILE_TYPE(FILE_TYPE_TEXT);
4476
4477
4478         /* Save the screen */
4479         screen_save();
4480
4481
4482         /* Interact until done */
4483         while (1)
4484         {
4485                 /* Clear screen */
4486                 Term_clear();
4487
4488                 /* Ask for a choice */
4489 #ifdef JP
4490                 prt("[ ¥«¥é¡¼¤ÎÀßÄê ]", 2, 0);
4491 #else
4492                 prt("Interact with Colors", 2, 0);
4493 #endif
4494
4495
4496                 /* Give some choices */
4497 #ifdef JP
4498                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
4499 #else
4500                 prt("(1) Load a user pref file", 4, 5);
4501 #endif
4502
4503 #ifdef ALLOW_COLORS
4504 #ifdef JP
4505                 prt("(2) ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
4506                 prt("(3) ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤¹¤ë", 6, 5);
4507 #else
4508                 prt("(2) Dump colors", 5, 5);
4509                 prt("(3) Modify colors", 6, 5);
4510 #endif
4511
4512 #endif
4513
4514                 /* Prompt */
4515 #ifdef JP
4516                 prt("¥³¥Þ¥ó¥É: ", 8, 0);
4517 #else
4518                 prt("Command: ", 8, 0);
4519 #endif
4520
4521
4522                 /* Prompt */
4523                 i = inkey();
4524
4525                 /* Done */
4526                 if (i == ESCAPE) break;
4527
4528                 /* Load a 'pref' file */
4529                 if (i == '1')
4530                 {
4531                         /* Prompt */
4532 #ifdef JP
4533                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹", 8, 0);
4534 #else
4535                         prt("Command: Load a user pref file", 8, 0);
4536 #endif
4537
4538
4539                         /* Prompt */
4540 #ifdef JP
4541                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4542 #else
4543                         prt("File: ", 10, 0);
4544 #endif
4545
4546
4547                         /* Default file */
4548                         sprintf(tmp, "%s.prf", player_base);
4549
4550                         /* Query */
4551                         if (!askfor(tmp, 70)) continue;
4552
4553                         /* Process the given filename */
4554                         (void)process_pref_file(tmp);
4555
4556                         /* Mega-Hack -- react to changes */
4557                         Term_xtra(TERM_XTRA_REACT, 0);
4558
4559                         /* Mega-Hack -- redraw */
4560                         Term_redraw();
4561                 }
4562
4563 #ifdef ALLOW_COLORS
4564
4565                 /* Dump colors */
4566                 else if (i == '2')
4567                 {
4568                         static cptr mark = "Colors";
4569
4570                         /* Prompt */
4571 #ifdef JP
4572                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 8, 0);
4573 #else
4574                         prt("Command: Dump colors", 8, 0);
4575 #endif
4576
4577
4578                         /* Prompt */
4579 #ifdef JP
4580                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4581 #else
4582                         prt("File: ", 10, 0);
4583 #endif
4584
4585
4586                         /* Default filename */
4587                         sprintf(tmp, "%s.prf", player_base);
4588
4589                         /* Get a filename */
4590                         if (!askfor(tmp, 70)) continue;
4591
4592                         /* Build the filename */
4593                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4594
4595                         /* Append to the file */
4596                         if (!open_auto_dump(buf, mark)) continue;
4597
4598                         /* Start dumping */
4599 #ifdef JP
4600                         auto_dump_printf("\n# ¥«¥é¡¼¤ÎÀßÄê\n\n");
4601 #else
4602                         auto_dump_printf("\n# Color redefinitions\n\n");
4603 #endif
4604
4605                         /* Dump colors */
4606                         for (i = 0; i < 256; i++)
4607                         {
4608                                 int kv = angband_color_table[i][0];
4609                                 int rv = angband_color_table[i][1];
4610                                 int gv = angband_color_table[i][2];
4611                                 int bv = angband_color_table[i][3];
4612
4613 #ifdef JP
4614                                 cptr name = "̤ÃÎ";
4615 #else
4616                                 cptr name = "unknown";
4617 #endif
4618
4619
4620                                 /* Skip non-entries */
4621                                 if (!kv && !rv && !gv && !bv) continue;
4622
4623                                 /* Extract the color name */
4624                                 if (i < 16) name = color_names[i];
4625
4626                                 /* Dump a comment */
4627 #ifdef JP
4628                                 auto_dump_printf("# ¥«¥é¡¼ '%s'\n", name);
4629 #else
4630                                 auto_dump_printf("# Color '%s'\n", name);
4631 #endif
4632
4633                                 /* Dump the monster attr/char info */
4634                                 auto_dump_printf("V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
4635                                         i, kv, rv, gv, bv);
4636                         }
4637
4638                         /* Close */
4639                         close_auto_dump();
4640
4641                         /* Message */
4642 #ifdef JP
4643                         msg_print("¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4644 #else
4645                         msg_print("Dumped color redefinitions.");
4646 #endif
4647
4648                 }
4649
4650                 /* Edit colors */
4651                 else if (i == '3')
4652                 {
4653                         static byte a = 0;
4654
4655                         /* Prompt */
4656 #ifdef JP
4657                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤·¤Þ¤¹", 8, 0);
4658 #else
4659                         prt("Command: Modify colors", 8, 0);
4660 #endif
4661
4662
4663                         /* Hack -- query until done */
4664                         while (1)
4665                         {
4666                                 cptr name;
4667                                 byte j;
4668
4669                                 /* Clear */
4670                                 clear_from(10);
4671
4672                                 /* Exhibit the normal colors */
4673                                 for (j = 0; j < 16; j++)
4674                                 {
4675                                         /* Exhibit this color */
4676                                         Term_putstr(j*4, 20, -1, a, "###");
4677
4678                                         /* Exhibit all colors */
4679                                         Term_putstr(j*4, 22, -1, j, format("%3d", j));
4680                                 }
4681
4682                                 /* Describe the color */
4683 #ifdef JP
4684                                 name = ((a < 16) ? color_names[a] : "̤ÄêµÁ");
4685 #else
4686                                 name = ((a < 16) ? color_names[a] : "undefined");
4687 #endif
4688
4689
4690                                 /* Describe the color */
4691 #ifdef JP
4692                                 Term_putstr(5, 10, -1, TERM_WHITE,
4693                                             format("¥«¥é¡¼ = %d, Ì¾Á° = %s", a, name));
4694 #else
4695                                 Term_putstr(5, 10, -1, TERM_WHITE,
4696                                             format("Color = %d, Name = %s", a, name));
4697 #endif
4698
4699
4700                                 /* Label the Current values */
4701                                 Term_putstr(5, 12, -1, TERM_WHITE,
4702                                             format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
4703                                                    angband_color_table[a][0],
4704                                                    angband_color_table[a][1],
4705                                                    angband_color_table[a][2],
4706                                                    angband_color_table[a][3]));
4707
4708                                 /* Prompt */
4709 #ifdef JP
4710                                 Term_putstr(0, 14, -1, TERM_WHITE,
4711                                             "¥³¥Þ¥ó¥É (n/N/k/K/r/R/g/G/b/B): ");
4712 #else
4713                                 Term_putstr(0, 14, -1, TERM_WHITE,
4714                                             "Command (n/N/k/K/r/R/g/G/b/B): ");
4715 #endif
4716
4717
4718                                 /* Get a command */
4719                                 i = inkey();
4720
4721                                 /* All done */
4722                                 if (i == ESCAPE) break;
4723
4724                                 /* Analyze */
4725                                 if (i == 'n') a = (byte)(a + 1);
4726                                 if (i == 'N') a = (byte)(a - 1);
4727                                 if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1);
4728                                 if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1);
4729                                 if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1);
4730                                 if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1);
4731                                 if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1);
4732                                 if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1);
4733                                 if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1);
4734                                 if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1);
4735
4736                                 /* Hack -- react to changes */
4737                                 Term_xtra(TERM_XTRA_REACT, 0);
4738
4739                                 /* Hack -- redraw */
4740                                 Term_redraw();
4741                         }
4742                 }
4743
4744 #endif
4745
4746                 /* Unknown option */
4747                 else
4748                 {
4749                         bell();
4750                 }
4751
4752                 /* Flush messages */
4753                 msg_print(NULL);
4754         }
4755
4756
4757         /* Restore the screen */
4758         screen_load();
4759 }
4760
4761
4762 /*
4763  * Note something in the message recall
4764  */
4765 void do_cmd_note(void)
4766 {
4767         char buf[80];
4768
4769         /* Default */
4770         strcpy(buf, "");
4771
4772         /* Input */
4773 #ifdef JP
4774         if (!get_string("¥á¥â: ", buf, 60)) return;
4775 #else
4776         if (!get_string("Note: ", buf, 60)) return;
4777 #endif
4778
4779
4780         /* Ignore empty notes */
4781         if (!buf[0] || (buf[0] == ' ')) return;
4782
4783         /* Add the note to the message recall */
4784 #ifdef JP
4785         msg_format("¥á¥â: %s", buf);
4786 #else
4787         msg_format("Note: %s", buf);
4788 #endif
4789
4790 }
4791
4792
4793 /*
4794  * Mention the current version
4795  */
4796 void do_cmd_version(void)
4797 {
4798
4799         /* Silly message */
4800 #ifdef JP
4801         msg_format("ÊѶòÈÚÅÜ(Hengband) %d.%d.%d",
4802                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4803 #else
4804         msg_format("You are playing Hengband %d.%d.%d.",
4805                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4806 #endif
4807 }
4808
4809
4810
4811 /*
4812  * Array of feeling strings
4813  */
4814 static cptr do_cmd_feeling_text[11] =
4815 {
4816 #ifdef JP
4817         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4818 #else
4819         "Looks like any other level.",
4820 #endif
4821
4822 #ifdef JP
4823         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4824 #else
4825         "You feel there is something special about this level.",
4826 #endif
4827
4828 #ifdef JP
4829         "¶²¤í¤·¤¤»à¤Î¸¸¤¬ÌܤËÉ⤫¤Ó¡¢µ¤À䤷¤½¤¦¤Ë¤Ê¤Ã¤¿¡ª",
4830 #else
4831         "You nearly faint as horrible visions of death fill your mind!",
4832 #endif
4833
4834 #ifdef JP
4835         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4836 #else
4837         "This level looks very dangerous.",
4838 #endif
4839
4840 #ifdef JP
4841         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4842 #else
4843         "You have a very bad feeling...",
4844 #endif
4845
4846 #ifdef JP
4847         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4848 #else
4849         "You have a bad feeling...",
4850 #endif
4851
4852 #ifdef JP
4853         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4854 #else
4855         "You feel nervous.",
4856 #endif
4857
4858 #ifdef JP
4859         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4860 #else
4861         "You feel your luck is turning...",
4862 #endif
4863
4864 #ifdef JP
4865         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4866 #else
4867         "You don't like the look of this place.",
4868 #endif
4869
4870 #ifdef JP
4871         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4872 #else
4873         "This level looks reasonably safe.",
4874 #endif
4875
4876 #ifdef JP
4877         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4878 #else
4879         "What a boring place..."
4880 #endif
4881
4882 };
4883
4884 static cptr do_cmd_feeling_text_combat[11] =
4885 {
4886 #ifdef JP
4887         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4888 #else
4889         "Looks like any other level.",
4890 #endif
4891
4892 #ifdef JP
4893         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4894 #else
4895         "You feel there is something special about this level.",
4896 #endif
4897
4898 #ifdef JP
4899         "º£Ìë¤â¤Þ¤¿¡¢Ã¯¤«¤¬Ì¿¤òÍî¤È¤¹...",
4900 #else
4901         "You nearly faint as horrible visions of death fill your mind!",
4902 #endif
4903
4904 #ifdef JP
4905         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4906 #else
4907         "This level looks very dangerous.",
4908 #endif
4909
4910 #ifdef JP
4911         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4912 #else
4913         "You have a very bad feeling...",
4914 #endif
4915
4916 #ifdef JP
4917         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4918 #else
4919         "You have a bad feeling...",
4920 #endif
4921
4922 #ifdef JP
4923         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4924 #else
4925         "You feel nervous.",
4926 #endif
4927
4928 #ifdef JP
4929         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4930 #else
4931         "You feel your luck is turning...",
4932 #endif
4933
4934 #ifdef JP
4935         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4936 #else
4937         "You don't like the look of this place.",
4938 #endif
4939
4940 #ifdef JP
4941         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4942 #else
4943         "This level looks reasonably safe.",
4944 #endif
4945
4946 #ifdef JP
4947         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4948 #else
4949         "What a boring place..."
4950 #endif
4951
4952 };
4953
4954 static cptr do_cmd_feeling_text_lucky[11] =
4955 {
4956 #ifdef JP
4957         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4958         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4959         "¤³¤Î³¬¤Ï¤³¤Î¾å¤Ê¤¯ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë¡£",
4960         "ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë...",
4961         "¤È¤Æ¤âÎɤ¤´¶¤¸¤¬¤¹¤ë...",
4962         "Îɤ¤´¶¤¸¤¬¤¹¤ë...",
4963         "¤Á¤ç¤Ã¤È¹¬±¿¤Ê´¶¤¸¤¬¤¹¤ë...",
4964         "¿¾¯¤Ï±¿¤¬¸þ¤¤¤Æ¤­¤¿¤«...",
4965         "¸«¤¿´¶¤¸°­¤¯¤Ï¤Ê¤¤...",
4966         "Á´Á³ÂÌÌܤȤ¤¤¦¤³¤È¤Ï¤Ê¤¤¤¬...",
4967         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4968 #else
4969         "Looks like any other level.",
4970         "You feel there is something special about this level.",
4971         "You have a superb feeling about this level.",
4972         "You have an excellent feeling...",
4973         "You have a very good feeling...",
4974         "You have a good feeling...",
4975         "You feel strangely lucky...",
4976         "You feel your luck is turning...",
4977         "You like the look of this place...",
4978         "This level can't be all bad...",
4979         "What a boring place..."
4980 #endif
4981 };
4982
4983
4984 /*
4985  * Note that "feeling" is set to zero unless some time has passed.
4986  * Note that this is done when the level is GENERATED, not entered.
4987  */
4988 void do_cmd_feeling(void)
4989 {
4990         /* No useful feeling in quests */
4991         if (p_ptr->inside_quest && !random_quest_number(dun_level))
4992         {
4993 #ifdef JP
4994                 msg_print("ŵ·¿Åª¤Ê¥¯¥¨¥¹¥È¤Î¥À¥ó¥¸¥ç¥ó¤Î¤è¤¦¤À¡£");
4995 #else
4996                 msg_print("Looks like a typical quest level.");
4997 #endif
4998
4999                 return;
5000         }
5001
5002         /* No useful feeling in town */
5003         else if (p_ptr->town_num && !dun_level)
5004         {
5005 #ifdef JP
5006                 if (!strcmp(town[p_ptr->town_num].name, "¹ÓÌî"))
5007 #else
5008                 if (!strcmp(town[p_ptr->town_num].name, "wilderness"))
5009 #endif
5010                 {
5011 #ifdef JP
5012                         msg_print("²¿¤«¤¢¤ê¤½¤¦¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
5013 #else
5014                         msg_print("Looks like a strange wilderness.");
5015 #endif
5016
5017                         return;
5018                 }
5019                 else
5020                 {
5021 #ifdef JP
5022                         msg_print("ŵ·¿Åª¤ÊÄ®¤Î¤è¤¦¤À¡£");
5023 #else
5024                         msg_print("Looks like a typical town.");
5025 #endif
5026
5027                         return;
5028                 }
5029         }
5030
5031         /* No useful feeling in the wilderness */
5032         else if (!dun_level)
5033         {
5034 #ifdef JP
5035                 msg_print("ŵ·¿Åª¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
5036 #else
5037                 msg_print("Looks like a typical wilderness.");
5038 #endif
5039
5040                 return;
5041         }
5042
5043         /* Display the feeling */
5044         if (p_ptr->muta3 & MUT3_GOOD_LUCK)
5045                 msg_print(do_cmd_feeling_text_lucky[p_ptr->feeling]);
5046         else if (p_ptr->pseikaku == SEIKAKU_COMBAT ||
5047                  inventory[INVEN_BOW].name1 == ART_CRIMSON)
5048                 msg_print(do_cmd_feeling_text_combat[p_ptr->feeling]);
5049         else
5050                 msg_print(do_cmd_feeling_text[p_ptr->feeling]);
5051 }
5052
5053
5054
5055 /*
5056  * Description of each monster group.
5057  */
5058 static cptr monster_group_text[] = 
5059 {
5060 #ifdef JP
5061         "¥æ¥Ë¡¼¥¯",     /* "Uniques" */
5062         "¾èÇϲÄǽ¤Ê¥â¥ó¥¹¥¿¡¼", /* "Riding" */
5063         "¥¢¥ê",
5064         "¥³¥¦¥â¥ê",
5065         "¥à¥«¥Ç",
5066         "¥É¥é¥´¥ó",
5067         "ÌܶÌ",
5068         "¥Í¥³",
5069         "¥´¡¼¥ì¥à",
5070         "ɸ½à¿Í´Ö·¿À¸Êª",
5071         "¥Ù¥È¥Ù¥È",
5072         "¥¼¥ê¡¼",
5073         "¥³¥Ü¥ë¥É",
5074         "¿åÀ³À¸Êª",
5075         "¥â¥ë¥É",
5076         "¥Ê¡¼¥¬",
5077         "¥ª¡¼¥¯",
5078         "¿Í´Ö",
5079         "»Í­½Ã",
5080         "¥Í¥º¥ß",
5081         "¥¹¥±¥ë¥È¥ó",
5082         "¥Ç¡¼¥â¥ó",
5083         "¥Ü¥ë¥Æ¥Ã¥¯¥¹",
5084         "¥¤¥â¥à¥·/Âç·²",
5085         /* "unused", */
5086         "¥¤¡¼¥¯",
5087         "¥¾¥ó¥Ó/¥ß¥¤¥é",
5088         "Å·»È",
5089         "Ļ",
5090         "¸¤",
5091         /* "¸ÅÂå¥É¥é¥´¥ó/¥ï¥¤¥¢¡¼¥à", */
5092         "¥¨¥ì¥á¥ó¥¿¥ë",
5093         "¥È¥ó¥Ü",
5094         "¥´¡¼¥¹¥È",
5095         "»¨¼ï",
5096         "º«Ãî",
5097         "¥Ø¥Ó",
5098         "¥­¥é¡¼¡¦¥Ó¡¼¥È¥ë",
5099         "¥ê¥Ã¥Á",
5100         "¿¼ó¤Îà¨ÃîÎà",
5101         "Ææ¤ÎÀ¸Êª",
5102         "¥ª¡¼¥¬",
5103         "µðÂç¿Í´Ö·¿À¸Êª",
5104         "¥¯¥¤¥ë¥¹¥ë¥°",
5105         "à¨ÃîÎà/ξÀ¸Îà",
5106         "ÃØéá/¥µ¥½¥ê/¥À¥Ë",
5107         "¥È¥í¥ë",
5108         /* "¾åµé¥Ç¡¼¥â¥ó", */
5109         "¥Ð¥ó¥Ñ¥¤¥¢",
5110         "¥ï¥¤¥È/¥ì¥¤¥¹/Åù",
5111         "¥¾¡¼¥ó/¥¶¥ì¥ó/Åù",
5112         "¥¤¥¨¥Æ¥£",
5113         "¥Ï¥¦¥ó¥É",
5114         "¥ß¥ß¥Ã¥¯",
5115         "ÊÉ/¿¢Êª/µ¤ÂÎ",
5116         "¤ª¤Ð¤±¥­¥Î¥³",
5117         "µåÂÎ",
5118         "¥×¥ì¥¤¥ä¡¼",
5119 #else
5120         "Uniques",
5121         "Ridable monsters",
5122         "Ant",
5123         "Bat",
5124         "Centipede",
5125         "Dragon",
5126         "Floating Eye",
5127         "Feline",
5128         "Golem",
5129         "Hobbit/Elf/Dwarf",
5130         "Icky Thing",
5131         "Jelly",
5132         "Kobold",
5133         "Aquatic monster",
5134         "Mold",
5135         "Naga",
5136         "Orc",
5137         "Person/Human",
5138         "Quadruped",
5139         "Rodent",
5140         "Skeleton",
5141         "Demon",
5142         "Vortex",
5143         "Worm/Worm-Mass",
5144         /* "unused", */
5145         "Yeek",
5146         "Zombie/Mummy",
5147         "Angel",
5148         "Bird",
5149         "Canine",
5150         /* "Ancient Dragon/Wyrm", */
5151         "Elemental",
5152         "Dragon Fly",
5153         "Ghost",
5154         "Hybrid",
5155         "Insect",
5156         "Snake",
5157         "Killer Beetle",
5158         "Lich",
5159         "Multi-Headed Reptile",
5160         "Mystery Living",
5161         "Ogre",
5162         "Giant Humanoid",
5163         "Quylthulg",
5164         "Reptile/Amphibian",
5165         "Spider/Scorpion/Tick",
5166         "Troll",
5167         /* "Major Demon", */
5168         "Vampire",
5169         "Wight/Wraith/etc",
5170         "Xorn/Xaren/etc",
5171         "Yeti",
5172         "Zephyr Hound",
5173         "Mimic",
5174         "Wall/Plant/Gas",
5175         "Mushroom patch",
5176         "Ball",
5177         "Player",
5178 #endif
5179         NULL
5180 };
5181
5182
5183 /*
5184  * Symbols of monsters in each group. Note the "Uniques" group
5185  * is handled differently.
5186  */
5187 static cptr monster_group_char[] =
5188 {
5189         (char *) -1L,
5190         (char *) -2L,
5191         "a",
5192         "b",
5193         "c",
5194         "dD",
5195         "e",
5196         "f",
5197         "g",
5198         "h",
5199         "i",
5200         "j",
5201         "k",
5202         "l",
5203         "m",
5204         "n",
5205         "o",
5206         "pt",
5207         "q",
5208         "r",
5209         "s",
5210         "uU",
5211         "v",
5212         "w",
5213         /* "x", */
5214         "y",
5215         "z",
5216         "A",
5217         "B",
5218         "C",
5219         /* "D", */
5220         "E",
5221         "F",
5222         "G",
5223         "H",
5224         "I",
5225         "J",
5226         "K",
5227         "L",
5228         "M",
5229         "N",
5230         "O",
5231         "P",
5232         "Q",
5233         "R",
5234         "S",
5235         "T",
5236         /* "U", */
5237         "V",
5238         "W",
5239         "X",
5240         "Y",
5241         "Z",
5242         "!$&()+./=>?[\\]`{|~",
5243         "#%",
5244         ",",
5245         "*",
5246         "@",
5247         NULL
5248 };
5249
5250
5251 /*
5252  * hook function to sort monsters by level
5253  */
5254 static bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
5255 {
5256         u16b *who = (u16b*)(u);
5257
5258         int w1 = who[a];
5259         int w2 = who[b];
5260
5261         monster_race *r_ptr1 = &r_info[w1];
5262         monster_race *r_ptr2 = &r_info[w2];
5263
5264         /* Unused */
5265         (void)v;
5266
5267         if (r_ptr2->level > r_ptr1->level) return TRUE;
5268         if (r_ptr1->level > r_ptr2->level) return FALSE;
5269
5270         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return TRUE;
5271         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return FALSE;
5272         return w1 <= w2;
5273 }
5274
5275 /*
5276  * Build a list of monster indexes in the given group. Return the number
5277  * of monsters in the group.
5278  *
5279  * mode & 0x01 : check for non-empty group
5280  * mode & 0x02 : visual operation only
5281  */
5282 static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
5283 {
5284         int i, mon_cnt = 0;
5285         int dummy_why;
5286
5287         /* Get a list of x_char in this group */
5288         cptr group_char = monster_group_char[grp_cur];
5289
5290         /* XXX Hack -- Check if this is the "Uniques" group */
5291         bool grp_unique = (monster_group_char[grp_cur] == (char *) -1L);
5292
5293         /* XXX Hack -- Check if this is the "Riding" group */
5294         bool grp_riding = (monster_group_char[grp_cur] == (char *) -2L);
5295
5296         /* Check every race */
5297         for (i = 0; i < max_r_idx; i++)
5298         {
5299                 /* Access the race */
5300                 monster_race *r_ptr = &r_info[i];
5301
5302                 /* Skip empty race */
5303                 if (!r_ptr->name) continue ;
5304
5305                 /* Require known monsters */
5306                 if (!(mode & 0x02) && !cheat_know && !r_ptr->r_sights) continue;
5307
5308                 if (grp_unique)
5309                 {
5310                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5311                 }
5312
5313                 else if (grp_riding)
5314                 {
5315                         if (!(r_ptr->flags7 & RF7_RIDING)) continue;
5316                 }
5317
5318                 else
5319                 {
5320                         /* Check for race in the group */
5321                         if (!my_strchr(group_char, r_ptr->d_char)) continue;
5322                 }
5323
5324                 /* Add the race */
5325                 mon_idx[mon_cnt++] = i;
5326
5327                 /* XXX Hack -- Just checking for non-empty group */
5328                 if (mode & 0x01) break;
5329         }
5330
5331         /* Terminate the list */
5332         mon_idx[mon_cnt] = -1;
5333
5334         /* Select the sort method */
5335         ang_sort_comp = ang_sort_comp_monster_level;
5336         ang_sort_swap = ang_sort_swap_hook;
5337
5338         /* Sort by monster level */
5339         ang_sort(mon_idx, &dummy_why, mon_cnt);
5340
5341         /* Return the number of races */
5342         return mon_cnt;
5343 }
5344
5345
5346 /*
5347  * Description of each monster group.
5348  */
5349 static cptr object_group_text[] = 
5350 {
5351 #ifdef JP
5352         "¥­¥Î¥³",       /* "Mushrooms" */
5353         "Ìô",           /* "Potions" */
5354         "Ìý¤Ä¤Ü",       /* "Flasks" */
5355         "´¬Êª",         /* "Scrolls" */
5356         "»ØÎØ",         /* "Rings" */
5357         "¥¢¥ß¥å¥ì¥Ã¥È", /* "Amulets" */
5358         "ū",           /* "Whistle" */
5359         "¸÷¸»",         /* "Lanterns" */
5360         "ËâË¡ËÀ",       /* "Wands" */
5361         "¾ó",           /* "Staffs" */
5362         "¥í¥Ã¥É",       /* "Rods" */
5363         "¥«¡¼¥É",       /* "Cards" */
5364         "¥­¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë",
5365         "ÍÓÈé»æ",       
5366         "¤¯¤µ¤Ó",
5367         "Ȣ",
5368         "¿Í·Á",
5369         "Áü",
5370         "¥´¥ß",
5371         "¶õ¤Î¥Ó¥ó",
5372         "¹ü",
5373         "»àÂÎ",
5374         "Åá·õÎà",       /* "Swords" */
5375         "Æß´ï",         /* "Blunt Weapons" */
5376         "ĹÊÁÉð´ï",     /* "Polearms" */
5377         "ºÎ·¡Æ»¶ñ",     /* "Diggers" */
5378         "Èô¤ÓÆ»¶ñ",     /* "Bows" */
5379         "ÃÆ",
5380         "Ìð",
5381         "¥Ü¥ë¥È",
5382         "·ÚÁõ³»",       /* "Soft Armor" */
5383         "½ÅÁõ³»",       /* "Hard Armor" */
5384         "¥É¥é¥´¥ó³»",   /* "Dragon Armor" */
5385         "½â",   /* "Shields" */
5386         "¥¯¥í¡¼¥¯",     /* "Cloaks" */
5387         "äƼê", /* "Gloves" */
5388         "¥Ø¥ë¥á¥Ã¥È",   /* "Helms" */
5389         "´§",   /* "Crowns" */
5390         "¥Ö¡¼¥Ä",       /* "Boots" */
5391         "ËâË¡½ñ",
5392         "ºâÊõ",
5393         "²¿¤«",
5394 #else
5395         "Mushrooms",
5396         "Potions",
5397         "Flasks",
5398         "Scrolls",
5399         "Rings",
5400         "Amulets",
5401         "Whistle",
5402         "Lanterns",
5403         "Wands",
5404         "Staves",
5405         "Rods",
5406         "Cards",
5407         "Capture Balls",
5408         "Parchments",
5409         "Spikes",
5410         "Boxs",
5411         "Figurines",
5412         "Statues",
5413         "Junks",
5414         "Bottles",
5415         "Skeletons",
5416         "Corpses",
5417         "Swords",
5418         "Blunt Weapons",
5419         "Polearms",
5420         "Diggers",
5421         "Bows",
5422         "Shots",
5423         "Arrows",
5424         "Bolts",
5425         "Soft Armor",
5426         "Hard Armor",
5427         "Dragon Armor",
5428         "Shields",
5429         "Cloaks",
5430         "Gloves",
5431         "Helms",
5432         "Crowns",
5433         "Boots",
5434         "Spellbooks",
5435         "Treasure",
5436         "Something",
5437 #endif
5438         NULL
5439 };
5440
5441
5442 /*
5443  * TVALs of items in each group
5444  */
5445 static byte object_group_tval[] = 
5446 {
5447         TV_FOOD,
5448         TV_POTION,
5449         TV_FLASK,
5450         TV_SCROLL,
5451         TV_RING,
5452         TV_AMULET,
5453         TV_WHISTLE,
5454         TV_LITE,
5455         TV_WAND,
5456         TV_STAFF,
5457         TV_ROD,
5458         TV_CARD,
5459         TV_CAPTURE,
5460         TV_PARCHMENT,
5461         TV_SPIKE,
5462         TV_CHEST,
5463         TV_FIGURINE,
5464         TV_STATUE,
5465         TV_JUNK,
5466         TV_BOTTLE,
5467         TV_SKELETON,
5468         TV_CORPSE,
5469         TV_SWORD,
5470         TV_HAFTED,
5471         TV_POLEARM,
5472         TV_DIGGING,
5473         TV_BOW,
5474         TV_SHOT,
5475         TV_ARROW,
5476         TV_BOLT,
5477         TV_SOFT_ARMOR,
5478         TV_HARD_ARMOR,
5479         TV_DRAG_ARMOR,
5480         TV_SHIELD,
5481         TV_CLOAK,
5482         TV_GLOVES,
5483         TV_HELM,
5484         TV_CROWN,
5485         TV_BOOTS,
5486         TV_LIFE_BOOK, /* Hack -- all spellbooks */
5487         TV_GOLD,
5488         0,
5489         0,
5490 };
5491
5492
5493 /*
5494  * Build a list of object indexes in the given group. Return the number
5495  * of objects in the group.
5496  *
5497  * mode & 0x01 : check for non-empty group
5498  * mode & 0x02 : visual operation only
5499  */
5500 static int collect_objects(int grp_cur, int object_idx[], byte mode)
5501 {
5502         int i, j, k, object_cnt = 0;
5503
5504         /* Get a list of x_char in this group */
5505         byte group_tval = object_group_tval[grp_cur];
5506
5507         /* Check every object */
5508         for (i = 0; i < max_k_idx; i++)
5509         {
5510                 /* Access the object */
5511                 object_kind *k_ptr = &k_info[i];
5512
5513                 /* Skip empty objects */
5514                 if (!k_ptr->name) continue;
5515
5516                 if (mode & 0x02)
5517                 {
5518                         /* Any objects will be displayed */
5519                 }
5520                 else
5521                 {
5522                         if (!p_ptr->wizard)
5523                         {
5524                                 /* Skip non-flavoured objects */
5525                                 if (!k_ptr->flavor) continue;
5526
5527                                 /* Require objects ever seen */
5528                                 if (!k_ptr->aware) continue;
5529                         }
5530
5531                         /* Skip items with no distribution (special artifacts) */
5532                         for (j = 0, k = 0; j < 4; j++) k += k_ptr->chance[j];
5533                         if (!k) continue;
5534                 }
5535
5536                 /* Check for objects in the group */
5537                 if (TV_LIFE_BOOK == group_tval)
5538                 {
5539                         /* Hack -- All spell books */
5540                         if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HISSATSU_BOOK)
5541                         {
5542                                 /* Add the object */
5543                                 object_idx[object_cnt++] = i;
5544                         }
5545                         else continue;
5546                 }
5547                 else if (k_ptr->tval == group_tval)
5548                 {
5549                         /* Add the object */
5550                         object_idx[object_cnt++] = i;
5551                 }
5552                 else continue;
5553
5554                 /* XXX Hack -- Just checking for non-empty group */
5555                 if (mode & 0x01) break;
5556         }
5557
5558         /* Terminate the list */
5559         object_idx[object_cnt] = -1;
5560
5561         /* Return the number of objects */
5562         return object_cnt;
5563 }
5564
5565
5566 /*
5567  * Description of each feature group.
5568  */
5569 static cptr feature_group_text[] = 
5570 {
5571         "terrains",
5572         NULL
5573 };
5574
5575
5576 /*
5577  * Build a list of feature indexes in the given group. Return the number
5578  * of features in the group.
5579  *
5580  * mode & 0x01 : check for non-empty group
5581  */
5582 static int collect_features(int grp_cur, int *feat_idx, byte mode)
5583 {
5584         int i, feat_cnt = 0;
5585
5586         /* Unused;  There is a single group. */
5587         (void)grp_cur;
5588
5589         /* Check every feature */
5590         for (i = 0; i < max_f_idx; i++)
5591         {
5592                 /* Access the index */
5593                 feature_type *f_ptr = &f_info[i];
5594
5595                 /* Skip empty index */
5596                 if (!f_ptr->name) continue;
5597
5598                 /* Skip mimiccing features */
5599                 if (f_ptr->mimic != i) continue;
5600
5601                 /* Add the index */
5602                 feat_idx[feat_cnt++] = i;
5603
5604                 /* XXX Hack -- Just checking for non-empty group */
5605                 if (mode & 0x01) break;
5606         }
5607
5608         /* Terminate the list */
5609         feat_idx[feat_cnt] = -1;
5610
5611         /* Return the number of races */
5612         return feat_cnt;
5613 }
5614
5615
5616 #if 0
5617 /*
5618  * Build a list of monster indexes in the given group. Return the number
5619  * of monsters in the group.
5620  */
5621 static int collect_artifacts(int grp_cur, int object_idx[])
5622 {
5623         int i, object_cnt = 0;
5624
5625         /* Get a list of x_char in this group */
5626         byte group_tval = object_group_tval[grp_cur];
5627
5628         /* Check every object */
5629         for (i = 0; i < max_a_idx; i++)
5630         {
5631                 /* Access the artifact */
5632                 artifact_type *a_ptr = &a_info[i];
5633
5634                 /* Skip empty artifacts */
5635                 if (!a_ptr->name) continue;
5636
5637                 /* Skip "uncreated" artifacts */
5638                 if (!a_ptr->cur_num) continue;
5639
5640                 /* Check for race in the group */
5641                 if (a_ptr->tval == group_tval)
5642                 {
5643                         /* Add the race */
5644                         object_idx[object_cnt++] = i;
5645                 }
5646         }
5647
5648         /* Terminate the list */
5649         object_idx[object_cnt] = 0;
5650
5651         /* Return the number of races */
5652         return object_cnt;
5653 }
5654 #endif /* 0 */
5655
5656
5657 /*
5658  * Encode the screen colors
5659  */
5660 static char hack[17] = "dwsorgbuDWvyRGBU";
5661
5662
5663 /*
5664  * Hack -- load a screen dump from a file
5665  */
5666 void do_cmd_load_screen(void)
5667 {
5668         int i, y, x;
5669
5670         byte a = 0;
5671         char c = ' ';
5672
5673         bool okay = TRUE;
5674
5675         FILE *fff;
5676
5677         char buf[1024];
5678
5679         int wid, hgt;
5680
5681         Term_get_size(&wid, &hgt);
5682
5683         /* Build the filename */
5684         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
5685
5686         /* Append to the file */
5687         fff = my_fopen(buf, "r");
5688
5689         /* Oops */
5690         if (!fff) {
5691 #ifdef JP
5692                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
5693 #else
5694                 msg_format("Failed to open %s.", buf);
5695 #endif
5696                 msg_print(NULL);
5697                 return;
5698         }
5699
5700
5701         /* Save the screen */
5702         screen_save();
5703
5704         /* Clear the screen */
5705         Term_clear();
5706
5707
5708         /* Load the screen */
5709         for (y = 0; okay; y++)
5710         {
5711                 /* Get a line of data including control code */
5712                 if (!fgets(buf, 1024, fff)) okay = FALSE;
5713
5714                 /* Get the blank line */
5715                 if (buf[0] == '\n' || buf[0] == '\0') break;
5716
5717                 /* Ignore too large screen image */
5718                 if (y >= hgt) continue;
5719
5720                 /* Show each row */
5721                 for (x = 0; x < wid - 1; x++)
5722                 {
5723                         /* End of line */
5724                         if (buf[x] == '\n' || buf[x] == '\0') break;
5725
5726                         /* Put the attr/char */
5727                         Term_draw(x, y, TERM_WHITE, buf[x]);
5728                 }
5729         }
5730
5731         /* Dump the screen */
5732         for (y = 0; okay; y++)
5733         {
5734                 /* Get a line of data including control code */
5735                 if (!fgets(buf, 1024, fff)) okay = FALSE;
5736
5737                 /* Get the blank line */
5738                 if (buf[0] == '\n' || buf[0] == '\0') break;
5739
5740                 /* Ignore too large screen image */
5741                 if (y >= hgt) continue;
5742
5743                 /* Dump each row */
5744                 for (x = 0; x < wid - 1; x++)
5745                 {
5746                         /* End of line */
5747                         if (buf[x] == '\n' || buf[x] == '\0') break;
5748
5749                         /* Get the attr/char */
5750                         (void)(Term_what(x, y, &a, &c));
5751
5752                         /* Look up the attr */
5753                         for (i = 0; i < 16; i++)
5754                         {
5755                                 /* Use attr matches */
5756                                 if (hack[i] == buf[x]) a = i;
5757                         }
5758
5759                         /* Put the attr/char */
5760                         Term_draw(x, y, a, c);
5761                 }
5762         }
5763
5764
5765         /* Close it */
5766         my_fclose(fff);
5767
5768
5769         /* Message */
5770 #ifdef JP
5771         prt("¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤µ¤ì¤¿²èÌÌ(µ­Ç°»£±Æ)¤ò¥í¡¼¥É¤·¤Þ¤·¤¿¡£", 0, 0);
5772 #else
5773         msg_print("Screen dump loaded.");
5774 #endif
5775
5776         flush();
5777         inkey();
5778
5779
5780         /* Restore the screen */
5781         screen_load();
5782 }
5783
5784
5785
5786
5787 cptr inven_res_label = 
5788 #ifdef JP
5789  "                               »ÀÅŲÐÎäÆǸ÷°ÇÇ˹ì¹ö°øÆÙÎô ÌÕÉÝÍðáãÆ©Ì¿´¶¾ÃÉüÉâ";
5790 #else
5791  "                               AcElFiCoPoLiDkShSoNtNxCaDi BlFeCfFaSeHlEpSdRgLv";
5792 #endif
5793
5794
5795 #ifdef JP
5796 #define IM_FLAG_STR  "¡ö"
5797 #define HAS_FLAG_STR "¡Ü"
5798 #define NO_FLAG_STR  "¡¦"
5799 #else
5800 #define IM_FLAG_STR  "* "
5801 #define HAS_FLAG_STR "+ "
5802 #define NO_FLAG_STR  ". "
5803 #endif
5804
5805 #define print_im_or_res_flag(IM, RES) \
5806 { \
5807         fputs(have_flag(flgs, (IM)) ? IM_FLAG_STR : \
5808               (have_flag(flgs, (RES)) ? HAS_FLAG_STR : NO_FLAG_STR), fff); \
5809 }
5810
5811 #define print_flag(TR) \
5812 { \
5813         fputs(have_flag(flgs, (TR)) ? HAS_FLAG_STR : NO_FLAG_STR, fff); \
5814 }
5815
5816
5817 /* XTRA HACK RESLIST */
5818 static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr, int *j, byte tval, char *where)
5819 {
5820         char o_name[MAX_NLEN];
5821         u32b flgs[TR_FLAG_SIZE];
5822
5823         if (!o_ptr->k_idx) return;
5824         if (o_ptr->tval != tval) return;
5825
5826         /* Identified items only */
5827         if (!object_is_known(o_ptr)) return;
5828
5829         /*
5830          * HACK:Ring of Lordly protection and Dragon equipment
5831          * have random resistances.
5832          */
5833         if ((object_is_wearable(o_ptr) && object_is_ego(o_ptr))
5834             || ((tval == TV_AMULET) && (o_ptr->sval == SV_AMULET_RESISTANCE))
5835             || ((tval == TV_RING) && (o_ptr->sval == SV_RING_LORDLY))
5836             || ((tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD))
5837             || ((tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM))
5838             || ((tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES))
5839             || ((tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE))
5840             || object_is_artifact(o_ptr))
5841         {
5842                 int i = 0;
5843                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5844
5845                 while (o_name[i] && (i < 26))
5846                 {
5847 #ifdef JP
5848                         if (iskanji(o_name[i])) i++;
5849 #endif
5850                         i++;
5851                 }
5852
5853                 if (i < 28)
5854                 {
5855                         while (i < 28)
5856                         {
5857                                 o_name[i] = ' '; i++;
5858                         }
5859                 }
5860                 o_name[i] = '\0';
5861
5862                 fprintf(fff, "%s %s", where, o_name);
5863
5864                 if (!(o_ptr->ident & (IDENT_MENTAL)))
5865                 {
5866 #ifdef JP
5867                         fputs("-------ÉÔÌÀ--------------- -------ÉÔÌÀ---------\n", fff);
5868 #else
5869                         fputs("-------unknown------------ -------unknown------\n", fff);
5870 #endif
5871                 }
5872                 else
5873                 {
5874                         object_flags_known(o_ptr, flgs);
5875
5876                         print_im_or_res_flag(TR_IM_ACID, TR_RES_ACID);
5877                         print_im_or_res_flag(TR_IM_ELEC, TR_RES_ELEC);
5878                         print_im_or_res_flag(TR_IM_FIRE, TR_RES_FIRE);
5879                         print_im_or_res_flag(TR_IM_COLD, TR_RES_COLD);
5880                         print_flag(TR_RES_POIS);
5881                         print_flag(TR_RES_LITE);
5882                         print_flag(TR_RES_DARK);
5883                         print_flag(TR_RES_SHARDS);
5884                         print_flag(TR_RES_SOUND);
5885                         print_flag(TR_RES_NETHER);
5886                         print_flag(TR_RES_NEXUS);
5887                         print_flag(TR_RES_CHAOS);
5888                         print_flag(TR_RES_DISEN);
5889
5890                         fputs(" ", fff);
5891
5892                         print_flag(TR_RES_BLIND);
5893                         print_flag(TR_RES_FEAR);
5894                         print_flag(TR_RES_CONF);
5895                         print_flag(TR_FREE_ACT);
5896                         print_flag(TR_SEE_INVIS);
5897                         print_flag(TR_HOLD_LIFE);
5898                         print_flag(TR_TELEPATHY);
5899                         print_flag(TR_SLOW_DIGEST);
5900                         print_flag(TR_REGEN);
5901                         print_flag(TR_LEVITATION);
5902
5903                         fputc('\n', fff);
5904                 }
5905                 (*j)++;
5906                 if (*j == 9)
5907                 {
5908                         *j = 0;
5909                         fprintf(fff, "%s\n", inven_res_label);
5910                 }
5911         }
5912 }
5913
5914 /*
5915  * Display *ID* ed weapons/armors's resistances
5916  */
5917 static void do_cmd_knowledge_inven(void)
5918 {
5919         FILE *fff;
5920
5921         char file_name[1024];
5922
5923         store_type  *st_ptr;
5924
5925         byte tval;
5926         int i = 0;
5927         int j = 0;
5928
5929         char  where[32];
5930
5931         /* Open a new file */
5932         fff = my_fopen_temp(file_name, 1024);
5933         if (!fff)
5934         {
5935 #ifdef JP
5936             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
5937 #else
5938             msg_format("Failed to create temporary file %s.", file_name);
5939 #endif
5940             msg_print(NULL);
5941             return;
5942         }
5943         fprintf(fff, "%s\n", inven_res_label);
5944
5945         for (tval = TV_WEARABLE_BEGIN; tval <= TV_WEARABLE_END; tval++)
5946         {
5947                 if (j != 0)
5948                 {
5949                         for (; j < 9; j++) fputc('\n', fff);
5950                         j = 0;
5951                         fprintf(fff, "%s\n", inven_res_label);
5952                 }
5953
5954 #ifdef JP
5955                 strcpy(where, "Áõ");
5956 #else
5957                 strcpy(where, "E ");
5958 #endif
5959                 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
5960                 {
5961                         do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
5962                 }
5963
5964 #ifdef JP
5965                 strcpy(where, "»ý");
5966 #else
5967                 strcpy(where, "I ");
5968 #endif
5969                 for (i = 0; i < INVEN_PACK; i++)
5970                 {
5971                         do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
5972                 }
5973
5974                 st_ptr = &town[1].store[STORE_HOME];
5975 #ifdef JP
5976                 strcpy(where, "²È");
5977 #else
5978                 strcpy(where, "H ");
5979 #endif
5980
5981                 for (i = 0; i < st_ptr->stock_num; i++)
5982                 {
5983                         do_cmd_knowledge_inven_aux(fff, &st_ptr->stock[i], &j, tval, where);
5984                 }
5985         }
5986
5987         /* Close the file */
5988         my_fclose(fff);
5989
5990         /* Display the file contents */
5991 #ifdef JP
5992         show_file(TRUE, file_name, "*´ÕÄê*ºÑ¤ßÉð´ï/Ëɶñ¤ÎÂÑÀ­¥ê¥¹¥È", 0, 0);
5993 #else
5994         show_file(TRUE, file_name, "Resistances of *identified* equipment", 0, 0);
5995 #endif
5996
5997         /* Remove the file */
5998         fd_kill(file_name);
5999 }
6000
6001
6002 void do_cmd_save_screen_html_aux(char *filename, int message)
6003 {
6004         int y, x, i;
6005
6006         byte a = 0, old_a = 0;
6007         char c = ' ';
6008
6009         FILE *fff, *tmpfff;
6010         char buf[2048];
6011
6012         int yomikomu = 0;
6013         cptr tags[4] = {
6014                 "HEADER_START:",
6015                 "HEADER_END:",
6016                 "FOOTER_START:",
6017                 "FOOTER_END:",
6018         };
6019
6020         cptr html_head[] = {
6021                 "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
6022                 "<pre>",
6023                 0,
6024         };
6025         cptr html_foot[] = {
6026                 "</pre>\n",
6027                 "</body>\n</html>\n",
6028                 0,
6029         };
6030
6031         int wid, hgt;
6032
6033         Term_get_size(&wid, &hgt);
6034
6035         /* File type is "TEXT" */
6036         FILE_TYPE(FILE_TYPE_TEXT);
6037
6038         /* Append to the file */
6039         fff = my_fopen(filename, "w");
6040
6041         /* Oops */
6042         if (!fff) {
6043                 if (message) {
6044 #ifdef JP
6045                     msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", filename);
6046 #else
6047                     msg_format("Failed to open file %s.", filename);
6048 #endif
6049                     msg_print(NULL);
6050                 }
6051                 
6052                 return;
6053         }
6054
6055         /* Save the screen */
6056         if (message)
6057                 screen_save();
6058
6059         /* Build the filename */
6060         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
6061         tmpfff = my_fopen(buf, "r");
6062         if (!tmpfff) {
6063                 for (i = 0; html_head[i]; i++)
6064                         fprintf(fff, html_head[i]);
6065         }
6066         else {
6067                 yomikomu = 0;
6068                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
6069                         if (!yomikomu) {
6070                                 if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
6071                                         yomikomu = 1;
6072                         }
6073                         else {
6074                                 if (strncmp(buf, tags[1], strlen(tags[1])) == 0)
6075                                         break;
6076                                 fprintf(fff, "%s\n", buf);
6077                         }
6078                 }
6079         }
6080
6081         /* Dump the screen */
6082         for (y = 0; y < hgt; y++)
6083         {
6084                 /* Start the row */
6085                 if (y != 0)
6086                         fprintf(fff, "\n");
6087
6088                 /* Dump each row */
6089                 for (x = 0; x < wid - 1; x++)
6090                 {
6091                         int rv, gv, bv;
6092                         cptr cc = NULL;
6093                         /* Get the attr/char */
6094                         (void)(Term_what(x, y, &a, &c));
6095
6096                         switch (c)
6097                         {
6098                         case '&': cc = "&amp;"; break;
6099                         case '<': cc = "&lt;"; break;
6100                         case '>': cc = "&gt;"; break;
6101 #ifdef WINDOWS
6102                         case 0x1f: c = '.'; break;
6103                         case 0x7f: c = (a == 0x09) ? '%' : '#'; break;
6104 #endif
6105                         }
6106
6107                         a = a & 0x0F;
6108                         if ((y == 0 && x == 0) || a != old_a) {
6109                                 rv = angband_color_table[a][1];
6110                                 gv = angband_color_table[a][2];
6111                                 bv = angband_color_table[a][3];
6112                                 fprintf(fff, "%s<font color=\"#%02x%02x%02x\">", 
6113                                         ((y == 0 && x == 0) ? "" : "</font>"), rv, gv, bv);
6114                                 old_a = a;
6115                         }
6116                         if (cc)
6117                                 fprintf(fff, "%s", cc);
6118                         else
6119                                 fprintf(fff, "%c", c);
6120                 }
6121         }
6122         fprintf(fff, "</font>");
6123
6124         if (!tmpfff) {
6125                 for (i = 0; html_foot[i]; i++)
6126                         fprintf(fff, html_foot[i]);
6127         }
6128         else {
6129                 rewind(tmpfff);
6130                 yomikomu = 0;
6131                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
6132                         if (!yomikomu) {
6133                                 if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
6134                                         yomikomu = 1;
6135                         }
6136                         else {
6137                                 if (strncmp(buf, tags[3], strlen(tags[3])) == 0)
6138                                         break;
6139                                 fprintf(fff, "%s\n", buf);
6140                         }
6141                 }
6142                 my_fclose(tmpfff);
6143         }
6144
6145         /* Skip a line */
6146         fprintf(fff, "\n");
6147
6148         /* Close it */
6149         my_fclose(fff);
6150
6151         /* Message */
6152         if (message) {
6153 #ifdef JP
6154         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6155 #else
6156                 msg_print("Screen dump saved.");
6157 #endif
6158                 msg_print(NULL);
6159         }
6160
6161         /* Restore the screen */
6162         if (message)
6163                 screen_load();
6164 }
6165
6166 /*
6167  * Hack -- save a screen dump to a file
6168  */
6169 static void do_cmd_save_screen_html(void)
6170 {
6171         char buf[1024], tmp[256] = "screen.html";
6172
6173 #ifdef JP
6174         if (!get_string("¥Õ¥¡¥¤¥ë̾: ", tmp, 80))
6175 #else
6176         if (!get_string("File name: ", tmp, 80))
6177 #endif
6178                 return;
6179
6180         /* Build the filename */
6181         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
6182
6183         msg_print(NULL);
6184
6185         do_cmd_save_screen_html_aux(buf, 1);
6186 }
6187
6188
6189 /*
6190  * Redefinable "save_screen" action
6191  */
6192 void (*screendump_aux)(void) = NULL;
6193
6194
6195 /*
6196  * Hack -- save a screen dump to a file
6197  */
6198 void do_cmd_save_screen(void)
6199 {
6200         bool old_use_graphics = use_graphics;
6201         bool html_dump = FALSE;
6202
6203         int wid, hgt;
6204
6205 #ifdef JP
6206         prt("µ­Ç°»£±Æ¤·¤Þ¤¹¤«¡© [(y)es/(h)tml/(n)o] ", 0, 0);
6207 #else
6208         prt("Save screen dump? [(y)es/(h)tml/(n)o] ", 0, 0);
6209 #endif
6210         while(TRUE)
6211         {
6212                 char c = inkey();
6213                 if (c == 'Y' || c == 'y')
6214                         break;
6215                 else if (c == 'H' || c == 'h')
6216                 {
6217                         html_dump = TRUE;
6218                         break;
6219                 }
6220                 else
6221                 {
6222                         prt("", 0, 0);
6223                         return;
6224                 }
6225         }
6226
6227         Term_get_size(&wid, &hgt);
6228
6229         if (old_use_graphics)
6230         {
6231                 use_graphics = FALSE;
6232                 reset_visuals();
6233
6234                 /* Redraw everything */
6235                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6236
6237                 /* Hack -- update */
6238                 handle_stuff();
6239         }
6240
6241         if (html_dump)
6242         {
6243                 do_cmd_save_screen_html();
6244                 do_cmd_redraw();
6245         }
6246
6247         /* Do we use a special screendump function ? */
6248         else if (screendump_aux)
6249         {
6250                 /* Dump the screen to a graphics file */
6251                 (*screendump_aux)();
6252         }
6253         else /* Dump the screen as text */
6254         {
6255                 int y, x;
6256
6257                 byte a = 0;
6258                 char c = ' ';
6259
6260                 FILE *fff;
6261
6262                 char buf[1024];
6263
6264                 /* Build the filename */
6265                 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
6266
6267                 /* File type is "TEXT" */
6268                 FILE_TYPE(FILE_TYPE_TEXT);
6269
6270                 /* Append to the file */
6271                 fff = my_fopen(buf, "w");
6272
6273                 /* Oops */
6274                 if (!fff)
6275                 {
6276 #ifdef JP
6277                         msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
6278 #else
6279                         msg_format("Failed to open file %s.", buf);
6280 #endif
6281                         msg_print(NULL);
6282                         return;
6283                 }
6284
6285
6286                 /* Save the screen */
6287                 screen_save();
6288
6289
6290                 /* Dump the screen */
6291                 for (y = 0; y < hgt; y++)
6292                 {
6293                         /* Dump each row */
6294                         for (x = 0; x < wid - 1; x++)
6295                         {
6296                                 /* Get the attr/char */
6297                                 (void)(Term_what(x, y, &a, &c));
6298
6299                                 /* Dump it */
6300                                 buf[x] = c;
6301                         }
6302
6303                         /* Terminate */
6304                         buf[x] = '\0';
6305
6306                         /* End the row */
6307                         fprintf(fff, "%s\n", buf);
6308                 }
6309
6310                 /* Skip a line */
6311                 fprintf(fff, "\n");
6312
6313
6314                 /* Dump the screen */
6315                 for (y = 0; y < hgt; y++)
6316                 {
6317                         /* Dump each row */
6318                         for (x = 0; x < wid - 1; x++)
6319                         {
6320                                 /* Get the attr/char */
6321                                 (void)(Term_what(x, y, &a, &c));
6322
6323                                 /* Dump it */
6324                                 buf[x] = hack[a&0x0F];
6325                         }
6326
6327                         /* Terminate */
6328                         buf[x] = '\0';
6329
6330                         /* End the row */
6331                         fprintf(fff, "%s\n", buf);
6332                 }
6333
6334                 /* Skip a line */
6335                 fprintf(fff, "\n");
6336
6337
6338                 /* Close it */
6339                 my_fclose(fff);
6340
6341                 /* Message */
6342 #ifdef JP
6343         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6344 #else
6345                 msg_print("Screen dump saved.");
6346 #endif
6347
6348                 msg_print(NULL);
6349
6350
6351                 /* Restore the screen */
6352                 screen_load();
6353         }
6354
6355         if (old_use_graphics)
6356         {
6357                 use_graphics = TRUE;
6358                 reset_visuals();
6359
6360                 /* Redraw everything */
6361                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6362
6363                 /* Hack -- update */
6364                 handle_stuff();
6365         }
6366 }
6367
6368
6369 /*
6370  * Sorting hook -- Comp function -- see below
6371  *
6372  * We use "u" to point to array of monster indexes,
6373  * and "v" to select the type of sorting to perform on "u".
6374  */
6375 static bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
6376 {
6377         u16b *who = (u16b*)(u);
6378
6379         u16b *why = (u16b*)(v);
6380
6381         int w1 = who[a];
6382         int w2 = who[b];
6383
6384         int z1, z2;
6385
6386         /* Sort by total kills */
6387         if (*why >= 3)
6388         {
6389                 /* Extract total kills */
6390                 z1 = a_info[w1].tval;
6391                 z2 = a_info[w2].tval;
6392
6393                 /* Compare total kills */
6394                 if (z1 < z2) return (TRUE);
6395                 if (z1 > z2) return (FALSE);
6396         }
6397
6398
6399         /* Sort by monster level */
6400         if (*why >= 2)
6401         {
6402                 /* Extract levels */
6403                 z1 = a_info[w1].sval;
6404                 z2 = a_info[w2].sval;
6405
6406                 /* Compare levels */
6407                 if (z1 < z2) return (TRUE);
6408                 if (z1 > z2) return (FALSE);
6409         }
6410
6411
6412         /* Sort by monster experience */
6413         if (*why >= 1)
6414         {
6415                 /* Extract experience */
6416                 z1 = a_info[w1].level;
6417                 z2 = a_info[w2].level;
6418
6419                 /* Compare experience */
6420                 if (z1 < z2) return (TRUE);
6421                 if (z1 > z2) return (FALSE);
6422         }
6423
6424
6425         /* Compare indexes */
6426         return (w1 <= w2);
6427 }
6428
6429
6430 /*
6431  * Sorting hook -- Swap function -- see below
6432  *
6433  * We use "u" to point to array of monster indexes,
6434  * and "v" to select the type of sorting to perform.
6435  */
6436 static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
6437 {
6438         u16b *who = (u16b*)(u);
6439
6440         u16b holder;
6441
6442         /* Unused */
6443         (void)v;
6444
6445         /* Swap */
6446         holder = who[a];
6447         who[a] = who[b];
6448         who[b] = holder;
6449 }
6450
6451
6452 /*
6453  * Check the status of "artifacts"
6454  */
6455 static void do_cmd_knowledge_artifacts(void)
6456 {
6457         int i, k, z, x, y, n = 0;
6458         u16b why = 3;
6459         s16b *who;
6460
6461         FILE *fff;
6462
6463         char file_name[1024];
6464
6465         char base_name[MAX_NLEN];
6466
6467         bool *okay;
6468
6469         /* Open a new file */
6470         fff = my_fopen_temp(file_name, 1024);
6471
6472         if (!fff) {
6473 #ifdef JP
6474             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6475 #else
6476             msg_format("Failed to create temporary file %s.", file_name);
6477 #endif
6478             msg_print(NULL);
6479             return;
6480         }
6481
6482         /* Allocate the "who" array */
6483         C_MAKE(who, max_a_idx, s16b);
6484
6485         /* Allocate the "okay" array */
6486         C_MAKE(okay, max_a_idx, bool);
6487
6488         /* Scan the artifacts */
6489         for (k = 0; k < max_a_idx; k++)
6490         {
6491                 artifact_type *a_ptr = &a_info[k];
6492
6493                 /* Default */
6494                 okay[k] = FALSE;
6495
6496                 /* Skip "empty" artifacts */
6497                 if (!a_ptr->name) continue;
6498
6499                 /* Skip "uncreated" artifacts */
6500                 if (!a_ptr->cur_num) continue;
6501
6502                 /* Assume okay */
6503                 okay[k] = TRUE;
6504         }
6505
6506         /* Check the dungeon */
6507         for (y = 0; y < cur_hgt; y++)
6508         {
6509                 for (x = 0; x < cur_wid; x++)
6510                 {
6511                         cave_type *c_ptr = &cave[y][x];
6512
6513                         s16b this_o_idx, next_o_idx = 0;
6514
6515                         /* Scan all objects in the grid */
6516                         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
6517                         {
6518                                 object_type *o_ptr;
6519
6520                                 /* Acquire object */
6521                                 o_ptr = &o_list[this_o_idx];
6522
6523                                 /* Acquire next object */
6524                                 next_o_idx = o_ptr->next_o_idx;
6525
6526                                 /* Ignore non-artifacts */
6527                                 if (!object_is_fixed_artifact(o_ptr)) continue;
6528
6529                                 /* Ignore known items */
6530                                 if (object_is_known(o_ptr)) continue;
6531
6532                                 /* Note the artifact */
6533                                 okay[o_ptr->name1] = FALSE;
6534                         }
6535                 }
6536         }
6537
6538         /* Check the inventory and equipment */
6539         for (i = 0; i < INVEN_TOTAL; i++)
6540         {
6541                 object_type *o_ptr = &inventory[i];
6542
6543                 /* Ignore non-objects */
6544                 if (!o_ptr->k_idx) continue;
6545
6546                 /* Ignore non-artifacts */
6547                 if (!object_is_fixed_artifact(o_ptr)) continue;
6548
6549                 /* Ignore known items */
6550                 if (object_is_known(o_ptr)) continue;
6551
6552                 /* Note the artifact */
6553                 okay[o_ptr->name1] = FALSE;
6554         }
6555
6556         for (k = 0; k < max_a_idx; k++)
6557         {
6558                 if (okay[k]) who[n++] = k;
6559         }
6560
6561         /* Select the sort method */
6562         ang_sort_comp = ang_sort_art_comp;
6563         ang_sort_swap = ang_sort_art_swap;
6564
6565         /* Sort the array by dungeon depth of monsters */
6566         ang_sort(who, &why, n);
6567
6568         /* Scan the artifacts */
6569         for (k = 0; k < n; k++)
6570         {
6571                 artifact_type *a_ptr = &a_info[who[k]];
6572
6573                 /* Paranoia */
6574 #ifdef JP
6575                 strcpy(base_name, "̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à");
6576 #else
6577                 strcpy(base_name, "Unknown Artifact");
6578 #endif
6579
6580
6581                 /* Obtain the base object type */
6582                 z = lookup_kind(a_ptr->tval, a_ptr->sval);
6583
6584                 /* Real object */
6585                 if (z)
6586                 {
6587                         object_type forge;
6588                         object_type *q_ptr;
6589
6590                         /* Get local object */
6591                         q_ptr = &forge;
6592
6593                         /* Create fake object */
6594                         object_prep(q_ptr, z);
6595
6596                         /* Make it an artifact */
6597                         q_ptr->name1 = (byte)who[k];
6598
6599                         /* Display as if known */
6600                         q_ptr->ident |= IDENT_STORE;
6601
6602                         /* Describe the artifact */
6603                         object_desc(base_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6604                 }
6605
6606                 /* Hack -- Build the artifact name */
6607 #ifdef JP
6608                 fprintf(fff, "     %s\n", base_name);
6609 #else
6610                 fprintf(fff, "     The %s\n", base_name);
6611 #endif
6612
6613         }
6614
6615         /* Free the "who" array */
6616         C_KILL(who, max_a_idx, s16b);
6617
6618         /* Free the "okay" array */
6619         C_KILL(okay, max_a_idx, bool);
6620
6621         /* Close the file */
6622         my_fclose(fff);
6623
6624         /* Display the file contents */
6625 #ifdef JP
6626         show_file(TRUE, file_name, "´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à", 0, 0);
6627 #else
6628         show_file(TRUE, file_name, "Artifacts Seen", 0, 0);
6629 #endif
6630
6631
6632         /* Remove the file */
6633         fd_kill(file_name);
6634 }
6635
6636
6637 /*
6638  * Display known uniques
6639  * With "XTRA HACK UNIQHIST" (Originally from XAngband)
6640  */
6641 static void do_cmd_knowledge_uniques(void)
6642 {
6643         int i, k, n = 0;
6644         u16b why = 2;
6645         s16b *who;
6646
6647         FILE *fff;
6648
6649         char file_name[1024];
6650
6651         int n_alive[10];
6652         int n_alive_surface = 0;
6653         int n_alive_over100 = 0;
6654         int n_alive_total = 0;
6655         int max_lev = -1;
6656
6657         for (i = 0; i < 10; i++) n_alive[i] = 0;
6658
6659         /* Open a new file */
6660         fff = my_fopen_temp(file_name, 1024);
6661
6662         if (!fff)
6663         {
6664 #ifdef JP
6665             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6666 #else
6667             msg_format("Failed to create temporary file %s.", file_name);
6668 #endif
6669             msg_print(NULL);
6670             return;
6671         }
6672
6673         /* Allocate the "who" array */
6674         C_MAKE(who, max_r_idx, s16b);
6675
6676         /* Scan the monsters */
6677         for (i = 1; i < max_r_idx; i++)
6678         {
6679                 monster_race *r_ptr = &r_info[i];
6680                 int          lev;
6681
6682                 if (!r_ptr->name) continue;
6683
6684                 /* Require unique monsters */
6685                 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6686
6687                 /* Only display "known" uniques */
6688                 if (!cheat_know && !r_ptr->r_sights) continue;
6689
6690                 /* Only print rarity <= 100 uniques */
6691                 if (!r_ptr->rarity || ((r_ptr->rarity > 100) && !(r_ptr->flags1 & RF1_QUESTOR))) continue;
6692
6693                 /* Only "alive" uniques */
6694                 if (r_ptr->max_num == 0) continue;
6695
6696                 if (r_ptr->level)
6697                 {
6698                         lev = (r_ptr->level - 1) / 10;
6699                         if (lev < 10)
6700                         {
6701                                 n_alive[lev]++;
6702                                 if (max_lev < lev) max_lev = lev;
6703                         }
6704                         else n_alive_over100++;
6705                 }
6706                 else n_alive_surface++;
6707
6708                 /* Collect "appropriate" monsters */
6709                 who[n++] = i;
6710         }
6711
6712         /* Select the sort method */
6713         ang_sort_comp = ang_sort_comp_hook;
6714         ang_sort_swap = ang_sort_swap_hook;
6715
6716         /* Sort the array by dungeon depth of monsters */
6717         ang_sort(who, &why, n);
6718
6719         if (n_alive_surface)
6720         {
6721 #ifdef JP
6722                 fprintf(fff, "     ÃϾ堠À¸Â¸: %3dÂÎ\n", n_alive_surface);
6723 #else
6724                 fprintf(fff, "      Surface  alive: %3d\n", n_alive_surface);
6725 #endif
6726                 n_alive_total += n_alive_surface;
6727         }
6728         for (i = 0; i <= max_lev; i++)
6729         {
6730 #ifdef JP
6731                 fprintf(fff, "%3d-%3d³¬  À¸Â¸: %3dÂÎ\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
6732 #else
6733                 fprintf(fff, "Level %3d-%3d  alive: %3d\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
6734 #endif
6735                 n_alive_total += n_alive[i];
6736         }
6737         if (n_alive_over100)
6738         {
6739 #ifdef JP
6740                 fprintf(fff, "101-   ³¬  À¸Â¸: %3dÂÎ\n", n_alive_over100);
6741 #else
6742                 fprintf(fff, "Level 101-     alive: %3d\n", n_alive_over100);
6743 #endif
6744                 n_alive_total += n_alive_over100;
6745         }
6746
6747         if (n_alive_total)
6748         {
6749 #ifdef JP
6750                 fputs("---------  -----------\n", fff);
6751                 fprintf(fff, "     ¹ç·×  À¸Â¸: %3dÂÎ\n\n", n_alive_total);
6752 #else
6753                 fputs("-------------  ----------\n", fff);
6754                 fprintf(fff, "        Total  alive: %3d\n\n", n_alive_total);
6755 #endif
6756         }
6757         else
6758         {
6759 #ifdef JP
6760                 fputs("¸½ºß¤Ï´ûÃΤÎÀ¸Â¸¥æ¥Ë¡¼¥¯¤Ï¤¤¤Þ¤»¤ó¡£\n", fff);
6761 #else
6762                 fputs("No known uniques alive.\n", fff);
6763 #endif
6764         }
6765
6766         /* Scan the monster races */
6767         for (k = 0; k < n; k++)
6768         {
6769                 monster_race *r_ptr = &r_info[who[k]];
6770
6771                 /* Print a message */
6772 #ifdef JP
6773                 fprintf(fff, "     %s (¥ì¥Ù¥ë%d)\n", r_name + r_ptr->name, r_ptr->level);
6774 #else
6775                 fprintf(fff, "     %s (level %d)\n", r_name + r_ptr->name, r_ptr->level);
6776 #endif
6777         }
6778
6779         /* Free the "who" array */
6780         C_KILL(who, max_r_idx, s16b);
6781
6782         /* Close the file */
6783         my_fclose(fff);
6784
6785         /* Display the file contents */
6786 #ifdef JP
6787         show_file(TRUE, file_name, "¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼", 0, 0);
6788 #else
6789         show_file(TRUE, file_name, "Alive Uniques", 0, 0);
6790 #endif
6791
6792
6793         /* Remove the file */
6794         fd_kill(file_name);
6795 }
6796
6797
6798 /*
6799  * Display weapon-exp
6800  */
6801 static void do_cmd_knowledge_weapon_exp(void)
6802 {
6803         int i, j, num, weapon_exp;
6804
6805         FILE *fff;
6806
6807         char file_name[1024];
6808         char tmp[30];
6809
6810         /* Open a new file */
6811         fff = my_fopen_temp(file_name, 1024);
6812         if (!fff) {
6813 #ifdef JP
6814             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6815 #else
6816             msg_format("Failed to create temporary file %s.", file_name);
6817 #endif
6818             msg_print(NULL);
6819             return;
6820         }
6821
6822         for (i = 0; i < 5; i++)
6823         {
6824                 for (num = 0; num < 64; num++)
6825                 {
6826                         for (j = 0; j < max_k_idx; j++)
6827                         {
6828                                 object_kind *k_ptr = &k_info[j];
6829
6830                                 if ((k_ptr->tval == TV_SWORD - i) && (k_ptr->sval == num))
6831                                 {
6832                                         if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
6833
6834                                         weapon_exp = p_ptr->weapon_exp[4 - i][num];
6835                                         strip_name(tmp, j);
6836                                         fprintf(fff, "%-25s ", tmp);
6837                                         if (weapon_exp >= s_info[p_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
6838                                         else fprintf(fff, " ");
6839                                         fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
6840                                         if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
6841                                         fprintf(fff, "\n");
6842                                         break;
6843                                 }
6844                         }
6845                 }
6846         }
6847
6848         /* Close the file */
6849         my_fclose(fff);
6850
6851         /* Display the file contents */
6852 #ifdef JP
6853         show_file(TRUE, file_name, "Éð´ï¤Î·Ð¸³ÃÍ", 0, 0);
6854 #else
6855         show_file(TRUE, file_name, "Weapon Proficiency", 0, 0);
6856 #endif
6857
6858
6859         /* Remove the file */
6860         fd_kill(file_name);
6861 }
6862
6863
6864 /*
6865  * Display spell-exp
6866  */
6867 static void do_cmd_knowledge_spell_exp(void)
6868 {
6869         int i = 0, spell_exp, exp_level;
6870
6871         FILE *fff;
6872         magic_type *s_ptr;
6873
6874         char file_name[1024];
6875
6876         /* Open a new file */
6877         fff = my_fopen_temp(file_name, 1024);
6878         if (!fff) {
6879 #ifdef JP
6880             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6881 #else
6882             msg_format("Failed to create temporary file %s.", file_name);
6883 #endif
6884             msg_print(NULL);
6885             return;
6886         }
6887
6888         if (p_ptr->realm1 != REALM_NONE)
6889         {
6890 #ifdef JP
6891                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm1]);
6892 #else
6893                 fprintf(fff, "%s Spellbook\n", realm_names[p_ptr->realm1]);
6894 #endif
6895                 for (i = 0; i < 32; i++)
6896                 {
6897                         if (!is_magic(p_ptr->realm1))
6898                         {
6899                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
6900                         }
6901                         else
6902                         {
6903                                 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
6904                         }
6905                         if (s_ptr->slevel >= 99) continue;
6906                         spell_exp = p_ptr->spell_exp[i];
6907                         exp_level = spell_exp_level(spell_exp);
6908                         fprintf(fff, "%-25s ", do_spell(p_ptr->realm1, i, SPELL_NAME));
6909                         if (p_ptr->realm1 == REALM_HISSATSU)
6910                                 fprintf(fff, "[--]");
6911                         else
6912                         {
6913                                 if (exp_level >= EXP_LEVEL_MASTER) fprintf(fff, "!");
6914                                 else fprintf(fff, " ");
6915                                 fprintf(fff, "%s", exp_level_str[exp_level]);
6916                         }
6917                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
6918                         fprintf(fff, "\n");
6919                 }
6920         }
6921
6922         if (p_ptr->realm2 != REALM_NONE)
6923         {
6924 #ifdef JP
6925                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm2]);
6926 #else
6927                 fprintf(fff, "\n%s Spellbook\n", realm_names[p_ptr->realm2]);
6928 #endif
6929                 for (i = 0; i < 32; i++)
6930                 {
6931                         if (!is_magic(p_ptr->realm1))
6932                         {
6933                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
6934                         }
6935                         else
6936                         {
6937                                 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][i];
6938                         }
6939                         if (s_ptr->slevel >= 99) continue;
6940
6941                         spell_exp = p_ptr->spell_exp[i + 32];
6942                         exp_level = spell_exp_level(spell_exp);
6943                         fprintf(fff, "%-25s ", do_spell(p_ptr->realm2, i, SPELL_NAME));
6944                         if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
6945                         else fprintf(fff, " ");
6946                         fprintf(fff, "%s", exp_level_str[exp_level]);
6947                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
6948                         fprintf(fff, "\n");
6949                 }
6950         }
6951
6952         /* Close the file */
6953         my_fclose(fff);
6954
6955         /* Display the file contents */
6956 #ifdef JP
6957         show_file(TRUE, file_name, "ËâË¡¤Î·Ð¸³ÃÍ", 0, 0);
6958 #else
6959         show_file(TRUE, file_name, "Spell Proficiency", 0, 0);
6960 #endif
6961
6962
6963         /* Remove the file */
6964         fd_kill(file_name);
6965 }
6966
6967
6968 /*
6969  * Display skill-exp
6970  */
6971 static void do_cmd_knowledge_skill_exp(void)
6972 {
6973         int i = 0, skill_exp;
6974
6975         FILE *fff;
6976
6977         char file_name[1024];
6978 #ifdef JP
6979         char skill_name[3][17]={"¥Þ¡¼¥·¥ã¥ë¥¢¡¼¥Ä", "ÆóÅáή          ", "¾èÇÏ            "};
6980 #else
6981         char skill_name[3][20]={"Martial Arts    ", "Dual Wielding   ", "Riding          "};
6982 #endif
6983
6984         /* Open a new file */
6985         fff = my_fopen_temp(file_name, 1024);
6986         if (!fff) {
6987 #ifdef JP
6988             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6989 #else
6990             msg_format("Failed to create temporary file %s.", file_name);
6991 #endif
6992             msg_print(NULL);
6993             return;
6994         }
6995
6996         for (i = 0; i < 3; i++)
6997         {
6998                 skill_exp = p_ptr->skill_exp[i];
6999                 fprintf(fff, "%-20s ", skill_name[i]);
7000                 if (skill_exp >= s_info[p_ptr->pclass].s_max[i]) fprintf(fff, "!");
7001                 else fprintf(fff, " ");
7002                 fprintf(fff, "%s", exp_level_str[(i == GINOU_RIDING) ? riding_exp_level(skill_exp) : weapon_exp_level(skill_exp)]);
7003                 if (cheat_xtra) fprintf(fff, " %d", skill_exp);
7004                 fprintf(fff, "\n");
7005         }
7006
7007         /* Close the file */
7008         my_fclose(fff);
7009
7010         /* Display the file contents */
7011 #ifdef JP
7012         show_file(TRUE, file_name, "µ»Ç½¤Î·Ð¸³ÃÍ", 0, 0);
7013 #else
7014         show_file(TRUE, file_name, "Miscellaneous Proficiency", 0, 0);
7015 #endif
7016
7017
7018         /* Remove the file */
7019         fd_kill(file_name);
7020 }
7021
7022
7023 /*
7024  * Pluralize a monster name
7025  */
7026 void plural_aux(char *Name)
7027 {
7028         int NameLen = strlen(Name);
7029
7030         if (my_strstr(Name, "Disembodied hand"))
7031         {
7032                 strcpy(Name, "Disembodied hands that strangled people");
7033         }
7034         else if (my_strstr(Name, "Colour out of space"))
7035         {
7036                 strcpy(Name, "Colours out of space");
7037         }
7038         else if (my_strstr(Name, "stairway to hell"))
7039         {
7040                 strcpy(Name, "stairways to hell");
7041         }
7042         else if (my_strstr(Name, "Dweller on the threshold"))
7043         {
7044                 strcpy(Name, "Dwellers on the threshold");
7045         }
7046         else if (my_strstr(Name, " of "))
7047         {
7048                 cptr aider = my_strstr(Name, " of ");
7049                 char dummy[80];
7050                 int i = 0;
7051                 cptr ctr = Name;
7052
7053                 while (ctr < aider)
7054                 {
7055                         dummy[i] = *ctr;
7056                         ctr++; i++;
7057                 }
7058
7059                 if (dummy[i-1] == 's')
7060                 {
7061                         strcpy(&(dummy[i]), "es");
7062                         i++;
7063                 }
7064                 else
7065                 {
7066                         strcpy(&(dummy[i]), "s");
7067                 }
7068
7069                 strcpy(&(dummy[i+1]), aider);
7070                 strcpy(Name, dummy);
7071         }
7072         else if (my_strstr(Name, "coins"))
7073         {
7074                 char dummy[80];
7075                 strcpy(dummy, "piles of ");
7076                 strcat(dummy, Name);
7077                 strcpy(Name, dummy);
7078                 return;
7079         }
7080         else if (my_strstr(Name, "Manes"))
7081         {
7082                 return;
7083         }
7084         else if (streq(&(Name[NameLen - 2]), "ey"))
7085         {
7086                 strcpy(&(Name[NameLen - 2]), "eys");
7087         }
7088         else if (Name[NameLen - 1] == 'y')
7089         {
7090                 strcpy(&(Name[NameLen - 1]), "ies");
7091         }
7092         else if (streq(&(Name[NameLen - 4]), "ouse"))
7093         {
7094                 strcpy(&(Name[NameLen - 4]), "ice");
7095         }
7096         else if (streq(&(Name[NameLen - 2]), "us"))
7097         {
7098                 strcpy(&(Name[NameLen - 2]), "i");
7099         }
7100         else if (streq(&(Name[NameLen - 6]), "kelman"))
7101         {
7102                 strcpy(&(Name[NameLen - 6]), "kelmen");
7103         }
7104         else if (streq(&(Name[NameLen - 8]), "wordsman"))
7105         {
7106                 strcpy(&(Name[NameLen - 8]), "wordsmen");
7107         }
7108         else if (streq(&(Name[NameLen - 7]), "oodsman"))
7109         {
7110                 strcpy(&(Name[NameLen - 7]), "oodsmen");
7111         }
7112         else if (streq(&(Name[NameLen - 7]), "eastman"))
7113         {
7114                 strcpy(&(Name[NameLen - 7]), "eastmen");
7115         }
7116         else if (streq(&(Name[NameLen - 8]), "izardman"))
7117         {
7118                 strcpy(&(Name[NameLen - 8]), "izardmen");
7119         }
7120         else if (streq(&(Name[NameLen - 5]), "geist"))
7121         {
7122                 strcpy(&(Name[NameLen - 5]), "geister");
7123         }
7124         else if (streq(&(Name[NameLen - 2]), "ex"))
7125         {
7126                 strcpy(&(Name[NameLen - 2]), "ices");
7127         }
7128         else if (streq(&(Name[NameLen - 2]), "lf"))
7129         {
7130                 strcpy(&(Name[NameLen - 2]), "lves");
7131         }
7132         else if (suffix(Name, "ch") ||
7133                  suffix(Name, "sh") ||
7134                          suffix(Name, "nx") ||
7135                          suffix(Name, "s") ||
7136                          suffix(Name, "o"))
7137         {
7138                 strcpy(&(Name[NameLen]), "es");
7139         }
7140         else
7141         {
7142                 strcpy(&(Name[NameLen]), "s");
7143         }
7144 }
7145
7146 /*
7147  * Display current pets
7148  */
7149 static void do_cmd_knowledge_pets(void)
7150 {
7151         int             i;
7152         FILE            *fff;
7153         monster_type    *m_ptr;
7154         char            pet_name[80];
7155         int             t_friends = 0;
7156         int             show_upkeep = 0;
7157         char            file_name[1024];
7158
7159
7160         /* Open a new file */
7161         fff = my_fopen_temp(file_name, 1024);
7162         if (!fff) {
7163 #ifdef JP
7164             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7165 #else
7166             msg_format("Failed to create temporary file %s.", file_name);
7167 #endif
7168             msg_print(NULL);
7169             return;
7170         }
7171
7172         /* Process the monsters (backwards) */
7173         for (i = m_max - 1; i >= 1; i--)
7174         {
7175                 /* Access the monster */
7176                 m_ptr = &m_list[i];
7177
7178                 /* Ignore "dead" monsters */
7179                 if (!m_ptr->r_idx) continue;
7180
7181                 /* Calculate "upkeep" for pets */
7182                 if (is_pet(m_ptr))
7183                 {
7184                         t_friends++;
7185                         monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
7186                         fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
7187                 }
7188         }
7189
7190         show_upkeep = calculate_upkeep();
7191
7192         fprintf(fff, "----------------------------------------------\n");
7193 #ifdef JP
7194         fprintf(fff, "    ¹ç·×: %d ÂΤΥڥåÈ\n", t_friends);
7195         fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
7196 #else
7197         fprintf(fff, "   Total: %d pet%s.\n",
7198                 t_friends, (t_friends == 1 ? "" : "s"));
7199         fprintf(fff, "   Upkeep: %d%% mana.\n", show_upkeep);
7200 #endif
7201
7202
7203
7204         /* Close the file */
7205         my_fclose(fff);
7206
7207         /* Display the file contents */
7208 #ifdef JP
7209         show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
7210 #else
7211         show_file(TRUE, file_name, "Current Pets", 0, 0);
7212 #endif
7213
7214
7215         /* Remove the file */
7216         fd_kill(file_name);
7217 }
7218
7219
7220 /*
7221  * Total kill count
7222  *
7223  * Note that the player ghosts are ignored.  XXX XXX XXX
7224  */
7225 static void do_cmd_knowledge_kill_count(void)
7226 {
7227         int i, k, n = 0;
7228         u16b why = 2;
7229         s16b *who;
7230
7231         FILE *fff;
7232
7233         char file_name[1024];
7234
7235         s32b Total = 0;
7236
7237
7238         /* Open a new file */
7239         fff = my_fopen_temp(file_name, 1024);
7240
7241         if (!fff) {
7242 #ifdef JP
7243             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7244 #else
7245             msg_format("Failed to create temporary file %s.", file_name);
7246 #endif
7247             msg_print(NULL);
7248             return;
7249         }
7250
7251         /* Allocate the "who" array */
7252         C_MAKE(who, max_r_idx, s16b);
7253
7254         {
7255                 /* Monsters slain */
7256                 int kk;
7257
7258                 for (kk = 1; kk < max_r_idx; kk++)
7259                 {
7260                         monster_race *r_ptr = &r_info[kk];
7261
7262                         if (r_ptr->flags1 & (RF1_UNIQUE))
7263                         {
7264                                 bool dead = (r_ptr->max_num == 0);
7265
7266                                 if (dead)
7267                                 {
7268                                         Total++;
7269                                 }
7270                         }
7271                         else
7272                         {
7273                                 s16b This = r_ptr->r_pkills;
7274
7275                                 if (This > 0)
7276                                 {
7277                                         Total += This;
7278                                 }
7279                         }
7280                 }
7281
7282                 if (Total < 1)
7283 #ifdef JP
7284                         fprintf(fff,"¤¢¤Ê¤¿¤Ï¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Ê¤¤¡£\n\n");
7285 #else
7286                         fprintf(fff,"You have defeated no enemies yet.\n\n");
7287 #endif
7288                 else
7289 #ifdef JP
7290                         fprintf(fff,"¤¢¤Ê¤¿¤Ï%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", Total);
7291 #else
7292                         fprintf(fff,"You have defeated %ld %s.\n\n", Total, (Total == 1) ? "enemy" : "enemies");
7293 #endif
7294         }
7295
7296         Total = 0;
7297
7298         /* Scan the monsters */
7299         for (i = 1; i < max_r_idx; i++)
7300         {
7301                 monster_race *r_ptr = &r_info[i];
7302
7303                 /* Use that monster */
7304                 if (r_ptr->name) who[n++] = i;
7305         }
7306
7307         /* Select the sort method */
7308         ang_sort_comp = ang_sort_comp_hook;
7309         ang_sort_swap = ang_sort_swap_hook;
7310
7311         /* Sort the array by dungeon depth of monsters */
7312         ang_sort(who, &why, n);
7313
7314         /* Scan the monster races */
7315         for (k = 0; k < n; k++)
7316         {
7317                 monster_race *r_ptr = &r_info[who[k]];
7318
7319                 if (r_ptr->flags1 & (RF1_UNIQUE))
7320                 {
7321                         bool dead = (r_ptr->max_num == 0);
7322
7323                         if (dead)
7324                         {
7325                                 /* Print a message */
7326                                 fprintf(fff, "     %s\n",
7327                                     (r_name + r_ptr->name));
7328                                 Total++;
7329                         }
7330                 }
7331                 else
7332                 {
7333                         s16b This = r_ptr->r_pkills;
7334
7335                         if (This > 0)
7336                         {
7337 #ifdef JP
7338                                 /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita */
7339                                 if (my_strchr("pt", r_ptr->d_char))
7340                                         fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
7341                                 else
7342                                         fprintf(fff, "     %3d ÂΤΠ%s\n", This, r_name + r_ptr->name);
7343 #else
7344                                 if (This < 2)
7345                                 {
7346                                         if (my_strstr(r_name + r_ptr->name, "coins"))
7347                                         {
7348                                                 fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
7349                                         }
7350                                         else
7351                                         {
7352                                                 fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
7353                                         }
7354                                 }
7355                                 else
7356                                 {
7357                                         char ToPlural[80];
7358                                         strcpy(ToPlural, (r_name + r_ptr->name));
7359                                         plural_aux(ToPlural);
7360                                         fprintf(fff, "     %d %s\n", This, ToPlural);
7361                                 }
7362 #endif
7363
7364
7365                                 Total += This;
7366                         }
7367                 }
7368         }
7369
7370         fprintf(fff,"----------------------------------------------\n");
7371 #ifdef JP
7372         fprintf(fff,"    ¹ç·×: %lu ÂΤòÅݤ·¤¿¡£\n", Total);
7373 #else
7374         fprintf(fff,"   Total: %lu creature%s killed.\n",
7375                 Total, (Total == 1 ? "" : "s"));
7376 #endif
7377
7378
7379         /* Free the "who" array */
7380         C_KILL(who, max_r_idx, s16b);
7381
7382         /* Close the file */
7383         my_fclose(fff);
7384
7385         /* Display the file contents */
7386 #ifdef JP
7387         show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
7388 #else
7389         show_file(TRUE, file_name, "Kill Count", 0, 0);
7390 #endif
7391
7392
7393         /* Remove the file */
7394         fd_kill(file_name);
7395 }
7396
7397
7398 /*
7399  * Display the object groups.
7400  */
7401 static void display_group_list(int col, int row, int wid, int per_page,
7402         int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
7403 {
7404         int i;
7405
7406         /* Display lines until done */
7407         for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
7408         {
7409                 /* Get the group index */
7410                 int grp = grp_idx[grp_top + i];
7411
7412                 /* Choose a color */
7413                 byte attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
7414
7415                 /* Erase the entire line */
7416                 Term_erase(col, row + i, wid);
7417
7418                 /* Display the group label */
7419                 c_put_str(attr, group_text[grp], row + i, col);
7420         }
7421 }
7422
7423
7424 /* 
7425  * Move the cursor in a browser window 
7426  */
7427 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt, 
7428                                                    int *list_cur, int list_cnt)
7429 {
7430         int d;
7431         int col = *column;
7432         int grp = *grp_cur;
7433         int list = *list_cur;
7434
7435         /* Extract direction */
7436         if (ch == ' ')
7437         {
7438                 /* Hack -- scroll up full screen */
7439                 d = 3;
7440         }
7441         else if (ch == '-')
7442         {
7443                 /* Hack -- scroll down full screen */
7444                 d = 9;
7445         }
7446         else
7447         {
7448                 d = get_keymap_dir(ch);
7449         }
7450
7451         if (!d) return;
7452
7453         /* Diagonals - hack */
7454         if ((ddx[d] > 0) && ddy[d])
7455         {
7456                 int browser_rows;
7457                 int wid, hgt;
7458
7459                 /* Get size */
7460                 Term_get_size(&wid, &hgt);
7461
7462                 browser_rows = hgt - 8;
7463
7464                 /* Browse group list */
7465                 if (!col)
7466                 {
7467                         int old_grp = grp;
7468
7469                         /* Move up or down */
7470                         grp += ddy[d] * (browser_rows - 1);
7471
7472                         /* Verify */
7473                         if (grp >= grp_cnt)     grp = grp_cnt - 1;
7474                         if (grp < 0) grp = 0;
7475                         if (grp != old_grp)     list = 0;
7476                 }
7477
7478                 /* Browse sub-list list */
7479                 else
7480                 {
7481                         /* Move up or down */
7482                         list += ddy[d] * browser_rows;
7483
7484                         /* Verify */
7485                         if (list >= list_cnt) list = list_cnt - 1;
7486                         if (list < 0) list = 0;
7487                 }
7488
7489                 (*grp_cur) = grp;
7490                 (*list_cur) = list;
7491
7492                 return;
7493         }
7494
7495         if (ddx[d])
7496         {
7497                 col += ddx[d];
7498                 if (col < 0) col = 0;
7499                 if (col > 1) col = 1;
7500
7501                 (*column) = col;
7502
7503                 return;
7504         }
7505
7506         /* Browse group list */
7507         if (!col)
7508         {
7509                 int old_grp = grp;
7510
7511                 /* Move up or down */
7512                 grp += ddy[d];
7513
7514                 /* Verify */
7515                 if (grp >= grp_cnt)     grp = grp_cnt - 1;
7516                 if (grp < 0) grp = 0;
7517                 if (grp != old_grp)     list = 0;
7518         }
7519
7520         /* Browse sub-list list */
7521         else
7522         {
7523                 /* Move up or down */
7524                 list += ddy[d];
7525
7526                 /* Verify */
7527                 if (list >= list_cnt) list = list_cnt - 1;
7528                 if (list < 0) list = 0;
7529         }
7530
7531         (*grp_cur) = grp;
7532         (*list_cur) = list;
7533 }
7534
7535
7536 /*
7537  * Display visuals.
7538  */
7539 static void display_visual_list(int col, int row, int height, int width, byte attr_top, byte char_left)
7540 {
7541         int i, j;
7542
7543         /* Clear the display lines */
7544         for (i = 0; i < height; i++)
7545         {
7546                 Term_erase(col, row + i, width);
7547         }
7548
7549         /* Bigtile mode uses double width */
7550         if (use_bigtile) width /= 2;
7551
7552         /* Display lines until done */
7553         for (i = 0; i < height; i++)
7554         {
7555                 /* Display columns until done */
7556                 for (j = 0; j < width; j++)
7557                 {
7558                         byte a;
7559                         char c;
7560                         int x = col + j;
7561                         int y = row + i;
7562                         int ia, ic;
7563
7564                         /* Bigtile mode uses double width */
7565                         if (use_bigtile) x += j;
7566
7567                         ia = attr_top + i;
7568                         ic = char_left + j;
7569
7570                         /* Ignore illegal characters */
7571                         if (ia > 0x7f || ic > 0xff || ic < ' ' ||
7572                             (!use_graphics && ic > 0x7f))
7573                                 continue;
7574
7575                         a = (byte)ia;
7576                         c = (char)ic;
7577
7578                         /* Force correct code for both ASCII character and tile */
7579                         if (c & 0x80) a |= 0x80;
7580
7581                         /* Display symbol */
7582                         Term_queue_bigchar(x, y, a, c, 0, 0);
7583                 }
7584         }
7585 }
7586
7587
7588 /*
7589  * Place the cursor at the collect position for visual mode
7590  */
7591 static void place_visual_list_cursor(int col, int row, byte a, byte c, byte attr_top, byte char_left)
7592 {
7593         int i = (a & 0x7f) - attr_top;
7594         int j = c - char_left;
7595
7596         int x = col + j;
7597         int y = row + i;
7598
7599         /* Bigtile mode uses double width */
7600         if (use_bigtile) x += j;
7601
7602         /* Place the cursor */
7603         Term_gotoxy(x, y);
7604 }
7605
7606
7607 /*
7608  *  Clipboard variables for copy&paste in visual mode
7609  */
7610 static byte attr_idx = 0;
7611 static byte char_idx = 0;
7612
7613 /* Hack -- for feature lighting */
7614 static byte attr_idx_feat[F_LIT_MAX];
7615 static byte char_idx_feat[F_LIT_MAX];
7616
7617 /*
7618  *  Do visual mode command -- Change symbols
7619  */
7620 static bool visual_mode_command(char ch, bool *visual_list_ptr,
7621                                 int height, int width,
7622                                 byte *attr_top_ptr, byte *char_left_ptr,
7623                                 byte *cur_attr_ptr, byte *cur_char_ptr, bool *need_redraw)
7624 {
7625         static byte attr_old = 0, char_old = 0;
7626
7627         switch (ch)
7628         {
7629         case ESCAPE:
7630                 if (*visual_list_ptr)
7631                 {
7632                         /* Cancel change */
7633                         *cur_attr_ptr = attr_old;
7634                         *cur_char_ptr = char_old;
7635                         *visual_list_ptr = FALSE;
7636
7637                         return TRUE;
7638                 }
7639                 break;
7640
7641         case '\n':
7642         case '\r':
7643                 if (*visual_list_ptr)
7644                 {
7645                         /* Accept change */
7646                         *visual_list_ptr = FALSE;
7647                         *need_redraw = TRUE;
7648
7649                         return TRUE;
7650                 }
7651                 break;
7652
7653         case 'V':
7654         case 'v':
7655                 if (!*visual_list_ptr)
7656                 {
7657                         *visual_list_ptr = TRUE;
7658
7659                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7660                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7661
7662                         attr_old = *cur_attr_ptr;
7663                         char_old = *cur_char_ptr;
7664
7665                         return TRUE;
7666                 }
7667                 break;
7668
7669         case 'C':
7670         case 'c':
7671                 {
7672                         int i;
7673
7674                         /* Set the visual */
7675                         attr_idx = *cur_attr_ptr;
7676                         char_idx = *cur_char_ptr;
7677
7678                         /* Hack -- for feature lighting */
7679                         for (i = 0; i < F_LIT_MAX; i++)
7680                         {
7681                                 attr_idx_feat[i] = 0;
7682                                 char_idx_feat[i] = 0;
7683                         }
7684                 }
7685                 return TRUE;
7686
7687         case 'P':
7688         case 'p':
7689                 if (attr_idx || (!(char_idx & 0x80) && char_idx)) /* Allow TERM_DARK text */
7690                 {
7691                         /* Set the char */
7692                         *cur_attr_ptr = attr_idx;
7693                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7694                         if (!*visual_list_ptr) *need_redraw = TRUE;
7695                 }
7696
7697                 if (char_idx)
7698                 {
7699                         /* Set the char */
7700                         *cur_char_ptr = char_idx;
7701                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7702                         if (!*visual_list_ptr) *need_redraw = TRUE;
7703                 }
7704
7705                 return TRUE;
7706
7707         default:
7708                 if (*visual_list_ptr)
7709                 {
7710                         int eff_width;
7711                         int d = get_keymap_dir(ch);
7712                         byte a = (*cur_attr_ptr & 0x7f);
7713                         byte c = *cur_char_ptr;
7714
7715                         if (use_bigtile) eff_width = width / 2;
7716                         else eff_width = width;
7717
7718                         /* Restrict direction */
7719                         if ((a == 0) && (ddy[d] < 0)) d = 0;
7720                         if ((c == 0) && (ddx[d] < 0)) d = 0;
7721                         if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
7722                         if ((c == 0xff) && (ddx[d] > 0)) d = 0;
7723
7724                         a += ddy[d];
7725                         c += ddx[d];
7726
7727                         /* Force correct code for both ASCII character and tile */
7728                         if (c & 0x80) a |= 0x80;
7729
7730                         /* Set the visual */
7731                         *cur_attr_ptr = a;
7732                         *cur_char_ptr = c;
7733
7734
7735                         /* Move the frame */
7736                         if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
7737                         if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
7738                         if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
7739                         if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
7740                         return TRUE;
7741                 }
7742                 break;
7743         }
7744
7745         /* Visual mode command is not used */
7746         return FALSE;
7747 }
7748
7749
7750 /*
7751  * Display the monsters in a group.
7752  */
7753 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
7754         int mon_cur, int mon_top, bool visual_only)
7755 {
7756         int i;
7757
7758         /* Display lines until done */
7759         for (i = 0; i < per_page && (mon_idx[mon_top + i] >= 0); i++)
7760         {
7761                 byte attr;
7762
7763                 /* Get the race index */
7764                 int r_idx = mon_idx[mon_top + i] ;
7765
7766                 /* Access the race */
7767                 monster_race *r_ptr = &r_info[r_idx];
7768
7769                 /* Choose a color */
7770                 attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
7771
7772                 /* Display the name */
7773                 c_prt(attr, (r_name + r_ptr->name), row + i, col);
7774
7775                 /* Hack -- visual_list mode */
7776                 if (per_page == 1)
7777                 {
7778                         c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 56 : 61);
7779                 }
7780                 if (p_ptr->wizard || visual_only)
7781                 {
7782                         c_prt(attr, format("%d", r_idx), row + i, 62);
7783                 }
7784
7785                 /* Erase chars before overwritten by the race letter */
7786                 Term_erase(69, row + i, 255);
7787
7788                 /* Display symbol */
7789                 Term_queue_bigchar(use_bigtile ? 69 : 70, row + i, r_ptr->x_attr, r_ptr->x_char, 0, 0);
7790
7791                 if (!visual_only)
7792                 {
7793                         /* Display kills */
7794                         if (!(r_ptr->flags1 & RF1_UNIQUE)) put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
7795 #ifdef JP
7796                         else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "»àË´" : "À¸Â¸"), row + i, 74);
7797 #else
7798                         else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? " dead" : "alive"), row + i, 73);
7799 #endif
7800                 }
7801         }
7802
7803         /* Clear remaining lines */
7804         for (; i < per_page; i++)
7805         {
7806                 Term_erase(col, row + i, 255);
7807         }
7808 }
7809
7810
7811 /*
7812  * Display known monsters.
7813  */
7814 static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int direct_r_idx)
7815 {
7816         int i, len, max;
7817         int grp_cur, grp_top, old_grp_cur;
7818         int mon_cur, mon_top;
7819         int grp_cnt, grp_idx[100];
7820         int mon_cnt;
7821         s16b *mon_idx;
7822
7823         int column = 0;
7824         bool flag;
7825         bool redraw;
7826
7827         bool visual_list = FALSE;
7828         byte attr_top = 0, char_left = 0;
7829
7830         int browser_rows;
7831         int wid, hgt;
7832
7833         byte mode;
7834
7835         /* Get size */
7836         Term_get_size(&wid, &hgt);
7837
7838         browser_rows = hgt - 8;
7839
7840         /* Allocate the "mon_idx" array */
7841         C_MAKE(mon_idx, max_r_idx, s16b);
7842
7843         max = 0;
7844         grp_cnt = 0;
7845
7846         if (direct_r_idx < 0)
7847         {
7848                 mode = visual_only ? 0x03 : 0x01;
7849
7850                 /* Check every group */
7851                 for (i = 0; monster_group_text[i] != NULL; i++)
7852                 {
7853                         /* Measure the label */
7854                         len = strlen(monster_group_text[i]);
7855
7856                         /* Save the maximum length */
7857                         if (len > max) max = len;
7858
7859                         /* See if any monsters are known */
7860                         if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, mode))
7861                         {
7862                                 /* Build a list of groups with known monsters */
7863                                 grp_idx[grp_cnt++] = i;
7864                         }
7865                 }
7866
7867                 mon_cnt = 0;
7868         }
7869         else
7870         {
7871                 mon_idx[0] = direct_r_idx;
7872                 mon_cnt = 1;
7873
7874                 /* Terminate the list */
7875                 mon_idx[1] = -1;
7876
7877                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
7878                         &attr_top, &char_left, &r_info[direct_r_idx].x_attr, &r_info[direct_r_idx].x_char, need_redraw);
7879         }
7880
7881         /* Terminate the list */
7882         grp_idx[grp_cnt] = -1;
7883
7884         old_grp_cur = -1;
7885         grp_cur = grp_top = 0;
7886         mon_cur = mon_top = 0;
7887
7888         flag = FALSE;
7889         redraw = TRUE;
7890
7891         mode = visual_only ? 0x02 : 0x00;
7892
7893         while (!flag)
7894         {
7895                 char ch;
7896                 monster_race *r_ptr;
7897
7898                 if (redraw)
7899                 {
7900                         clear_from(0);
7901
7902 #ifdef JP
7903                         prt(format("%s - ¥â¥ó¥¹¥¿¡¼", !visual_only ? "Ãμ±" : "ɽ¼¨"), 2, 0);
7904                         if (direct_r_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
7905                         prt("̾Á°", 4, max + 3);
7906                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
7907                         prt("ʸ»ú", 4, 67);
7908                         if (!visual_only) prt("»¦³²¿ô", 4, 72);
7909 #else
7910                         prt(format("%s - monsters", !visual_only ? "Knowledge" : "Visuals"), 2, 0);
7911                         if (direct_r_idx < 0) prt("Group", 4, 0);
7912                         prt("Name", 4, max + 3);
7913                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
7914                         prt("Sym", 4, 68);
7915                         if (!visual_only) prt("Kills", 4, 73);
7916 #endif
7917
7918                         for (i = 0; i < 78; i++)
7919                         {
7920                                 Term_putch(i, 5, TERM_WHITE, '=');
7921                         }
7922
7923                         if (direct_r_idx < 0)
7924                         {
7925                                 for (i = 0; i < browser_rows; i++)
7926                                 {
7927                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
7928                                 }
7929                         }
7930
7931                         redraw = FALSE;
7932                 }
7933
7934                 if (direct_r_idx < 0)
7935                 {
7936                         /* Scroll group list */
7937                         if (grp_cur < grp_top) grp_top = grp_cur;
7938                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
7939
7940                         /* Display a list of monster groups */
7941                         display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
7942
7943                         if (old_grp_cur != grp_cur)
7944                         {
7945                                 old_grp_cur = grp_cur;
7946
7947                                 /* Get a list of monsters in the current group */
7948                                 mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, mode);
7949                         }
7950
7951                         /* Scroll monster list */
7952                         while (mon_cur < mon_top)
7953                                 mon_top = MAX(0, mon_top - browser_rows/2);
7954                         while (mon_cur >= mon_top + browser_rows)
7955                                 mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows/2);
7956                 }
7957
7958                 if (!visual_list)
7959                 {
7960                         /* Display a list of monsters in the current group */
7961                         display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top, visual_only);
7962                 }
7963                 else
7964                 {
7965                         mon_top = mon_cur;
7966
7967                         /* Display a monster name */
7968                         display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top, visual_only);
7969
7970                         /* Display visual list below first monster */
7971                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
7972                 }
7973
7974                 /* Prompt */
7975 #ifdef JP
7976                 prt(format("<Êý¸þ>%s%s%s, ESC",
7977                         (!visual_list && !visual_only) ? ", 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë" : "",
7978                         visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
7979                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
7980                         hgt - 1, 0);
7981 #else
7982                 prt(format("<dir>%s%s%s, ESC",
7983                         (!visual_list && !visual_only) ? ", 'r' to recall" : "",
7984                         visual_list ? ", ENTER to accept" : ", 'v' for visuals",
7985                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
7986                         hgt - 1, 0);
7987 #endif
7988
7989                 /* Get the current monster */
7990                 r_ptr = &r_info[mon_idx[mon_cur]];
7991
7992                 if (!visual_only)
7993                 {
7994                         /* Mega Hack -- track this monster race */
7995                         if (mon_cnt) monster_race_track(mon_idx[mon_cur]);
7996
7997                         /* Hack -- handle stuff */
7998                         handle_stuff();
7999                 }
8000
8001                 if (visual_list)
8002                 {
8003                         place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
8004                 }
8005                 else if (!column)
8006                 {
8007                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8008                 }
8009                 else
8010                 {
8011                         Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
8012                 }
8013
8014                 ch = inkey();
8015
8016                 /* Do visual mode command if needed */
8017                 if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &r_ptr->x_attr, &r_ptr->x_char, need_redraw))
8018                 {
8019                         if (direct_r_idx >= 0)
8020                         {
8021                                 switch (ch)
8022                                 {
8023                                 case '\n':
8024                                 case '\r':
8025                                 case ESCAPE:
8026                                         flag = TRUE;
8027                                         break;
8028                                 }
8029                         }
8030                         continue;
8031                 }
8032
8033                 switch (ch)
8034                 {
8035                         case ESCAPE:
8036                         {
8037                                 flag = TRUE;
8038                                 break;
8039                         }
8040
8041                         case 'R':
8042                         case 'r':
8043                         {
8044                                 /* Recall on screen */
8045                                 if (!visual_list && !visual_only && (mon_idx[mon_cur] > 0))
8046                                 {
8047                                         screen_roff(mon_idx[mon_cur], 0);
8048
8049                                         (void)inkey();
8050
8051                                         redraw = TRUE;
8052                                 }
8053                                 break;
8054                         }
8055
8056                         default:
8057                         {
8058                                 /* Move the cursor */
8059                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
8060
8061                                 break;
8062                         }
8063                 }
8064         }
8065
8066         /* Free the "mon_idx" array */
8067         C_KILL(mon_idx, max_r_idx, s16b);
8068 }
8069
8070
8071 /*
8072  * Display the objects in a group.
8073  */
8074 static void display_object_list(int col, int row, int per_page, int object_idx[],
8075         int object_cur, int object_top, bool visual_only)
8076 {
8077         int i;
8078
8079         /* Display lines until done */
8080         for (i = 0; i < per_page && (object_idx[object_top + i] >= 0); i++)
8081         {
8082                 char o_name[80];
8083                 byte a, c;
8084                 object_kind *flavor_k_ptr;
8085
8086                 /* Get the object index */
8087                 int k_idx = object_idx[object_top + i];
8088
8089                 /* Access the object */
8090                 object_kind *k_ptr = &k_info[k_idx];
8091
8092                 /* Choose a color */
8093                 byte attr = ((k_ptr->aware || visual_only) ? TERM_WHITE : TERM_SLATE);
8094                 byte cursor = ((k_ptr->aware || visual_only) ? TERM_L_BLUE : TERM_BLUE);
8095
8096
8097                 if (!visual_only && k_ptr->flavor)
8098                 {
8099                         /* Appearance of this object is shuffled */
8100                         flavor_k_ptr = &k_info[k_ptr->flavor];
8101                 }
8102                 else
8103                 {
8104                         /* Appearance of this object is very normal */
8105                         flavor_k_ptr = k_ptr;
8106                 }
8107
8108
8109
8110                 attr = ((i + object_top == object_cur) ? cursor : attr);
8111
8112                 if (!k_ptr->flavor || (!visual_only && k_ptr->aware))
8113                 {
8114                         /* Tidy name */
8115                         strip_name(o_name, k_idx);
8116                 }
8117                 else
8118                 {
8119                         /* Flavor name */
8120                         strcpy(o_name, k_name + flavor_k_ptr->flavor_name);
8121                 }
8122
8123                 /* Display the name */
8124                 c_prt(attr, o_name, row + i, col);
8125
8126                 /* Hack -- visual_list mode */
8127                 if (per_page == 1)
8128                 {
8129                         c_prt(attr, format("%02x/%02x", flavor_k_ptr->x_attr, flavor_k_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 64 : 68);
8130                 }
8131                 if (p_ptr->wizard || visual_only)
8132                 {
8133                         c_prt(attr, format("%d", k_idx), row + i, 70);
8134                 }
8135
8136                 a = flavor_k_ptr->x_attr;
8137                 c = flavor_k_ptr->x_char;
8138
8139                 /* Display symbol */
8140                 Term_queue_bigchar(use_bigtile ? 76 : 77, row + i, a, c, 0, 0);
8141         }
8142
8143         /* Clear remaining lines */
8144         for (; i < per_page; i++)
8145         {
8146                 Term_erase(col, row + i, 255);
8147         }
8148 }
8149
8150 /*
8151  * Describe fake object
8152  */
8153 static void desc_obj_fake(int k_idx)
8154 {
8155         object_type *o_ptr;
8156         object_type object_type_body;
8157
8158         /* Get local object */
8159         o_ptr = &object_type_body;
8160
8161         /* Wipe the object */
8162         object_wipe(o_ptr);
8163
8164         /* Create the artifact */
8165         object_prep(o_ptr, k_idx);
8166
8167         /* It's fully know */
8168         o_ptr->ident |= IDENT_KNOWN;
8169
8170         /* Track the object */
8171         /* object_actual_track(o_ptr); */
8172
8173         /* Hack - mark as fake */
8174         /* term_obj_real = FALSE; */
8175
8176         /* Hack -- Handle stuff */
8177         handle_stuff();
8178
8179         if (!screen_object(o_ptr, SCROBJ_FAKE_OBJECT | SCROBJ_FORCE_DETAIL))
8180         {
8181 #ifdef JP
8182                 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
8183 #else
8184                 msg_print("You see nothing special.");
8185 #endif
8186                 msg_print(NULL);
8187         }
8188 }
8189
8190
8191
8192 /*
8193  * Display known objects
8194  */
8195 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int direct_k_idx)
8196 {
8197         int i, len, max;
8198         int grp_cur, grp_top, old_grp_cur;
8199         int object_old, object_cur, object_top;
8200         int grp_cnt, grp_idx[100];
8201         int object_cnt;
8202         int *object_idx;
8203
8204         int column = 0;
8205         bool flag;
8206         bool redraw;
8207
8208         bool visual_list = FALSE;
8209         byte attr_top = 0, char_left = 0;
8210
8211         int browser_rows;
8212         int wid, hgt;
8213
8214         byte mode;
8215
8216         /* Get size */
8217         Term_get_size(&wid, &hgt);
8218
8219         browser_rows = hgt - 8;
8220
8221         /* Allocate the "object_idx" array */
8222         C_MAKE(object_idx, max_k_idx, int);
8223
8224         max = 0;
8225         grp_cnt = 0;
8226
8227         if (direct_k_idx < 0)
8228         {
8229                 mode = visual_only ? 0x03 : 0x01;
8230
8231                 /* Check every group */
8232                 for (i = 0; object_group_text[i] != NULL; i++)
8233                 {
8234                         /* Measure the label */
8235                         len = strlen(object_group_text[i]);
8236
8237                         /* Save the maximum length */
8238                         if (len > max) max = len;
8239
8240                         /* See if any monsters are known */
8241                         if (collect_objects(i, object_idx, mode))
8242                         {
8243                                 /* Build a list of groups with known monsters */
8244                                 grp_idx[grp_cnt++] = i;
8245                         }
8246                 }
8247
8248                 object_old = -1;
8249                 object_cnt = 0;
8250         }
8251         else
8252         {
8253                 object_kind *k_ptr = &k_info[direct_k_idx];
8254                 object_kind *flavor_k_ptr;
8255
8256                 if (!visual_only && k_ptr->flavor)
8257                 {
8258                         /* Appearance of this object is shuffled */
8259                         flavor_k_ptr = &k_info[k_ptr->flavor];
8260                 }
8261                 else
8262                 {
8263                         /* Appearance of this object is very normal */
8264                         flavor_k_ptr = k_ptr;
8265                 }
8266
8267                 object_idx[0] = direct_k_idx;
8268                 object_old = direct_k_idx;
8269                 object_cnt = 1;
8270
8271                 /* Terminate the list */
8272                 object_idx[1] = -1;
8273
8274                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8275                         &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw);
8276         }
8277
8278         /* Terminate the list */
8279         grp_idx[grp_cnt] = -1;
8280
8281         old_grp_cur = -1;
8282         grp_cur = grp_top = 0;
8283         object_cur = object_top = 0;
8284
8285         flag = FALSE;
8286         redraw = TRUE;
8287
8288         mode = visual_only ? 0x02 : 0x00;
8289
8290         while (!flag)
8291         {
8292                 char ch;
8293                 object_kind *k_ptr, *flavor_k_ptr;
8294
8295                 if (redraw)
8296                 {
8297                         clear_from(0);
8298
8299 #ifdef JP
8300                         prt(format("%s - ¥¢¥¤¥Æ¥à", !visual_only ? "Ãμ±" : "ɽ¼¨"), 2, 0);
8301                         if (direct_k_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8302                         prt("̾Á°", 4, max + 3);
8303                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 70);
8304                         prt("ʸ»ú", 4, 74);
8305 #else
8306                         prt(format("%s - objects", !visual_only ? "Knowledge" : "Visuals"), 2, 0);
8307                         if (direct_k_idx < 0) prt("Group", 4, 0);
8308                         prt("Name", 4, max + 3);
8309                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 70);
8310                         prt("Sym", 4, 75);
8311 #endif
8312
8313                         for (i = 0; i < 78; i++)
8314                         {
8315                                 Term_putch(i, 5, TERM_WHITE, '=');
8316                         }
8317
8318                         if (direct_k_idx < 0)
8319                         {
8320                                 for (i = 0; i < browser_rows; i++)
8321                                 {
8322                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8323                                 }
8324                         }
8325
8326                         redraw = FALSE;
8327                 }
8328
8329                 if (direct_k_idx < 0)
8330                 {
8331                         /* Scroll group list */
8332                         if (grp_cur < grp_top) grp_top = grp_cur;
8333                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8334
8335                         /* Display a list of object groups */
8336                         display_group_list(0, 6, max, browser_rows, grp_idx, object_group_text, grp_cur, grp_top);
8337
8338                         if (old_grp_cur != grp_cur)
8339                         {
8340                                 old_grp_cur = grp_cur;
8341
8342                                 /* Get a list of objects in the current group */
8343                                 object_cnt = collect_objects(grp_idx[grp_cur], object_idx, mode);
8344                         }
8345
8346                         /* Scroll object list */
8347                         while (object_cur < object_top)
8348                                 object_top = MAX(0, object_top - browser_rows/2);
8349                         while (object_cur >= object_top + browser_rows)
8350                                 object_top = MIN(object_cnt - browser_rows, object_top + browser_rows/2);
8351                 }
8352
8353                 if (!visual_list)
8354                 {
8355                         /* Display a list of objects in the current group */
8356                         display_object_list(max + 3, 6, browser_rows, object_idx, object_cur, object_top, visual_only);
8357                 }
8358                 else
8359                 {
8360                         object_top = object_cur;
8361
8362                         /* Display a list of objects in the current group */
8363                         display_object_list(max + 3, 6, 1, object_idx, object_cur, object_top, visual_only);
8364
8365                         /* Display visual list below first object */
8366                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8367                 }
8368
8369                 /* Get the current object */
8370                 k_ptr = &k_info[object_idx[object_cur]];
8371
8372                 if (!visual_only && k_ptr->flavor)
8373                 {
8374                         /* Appearance of this object is shuffled */
8375                         flavor_k_ptr = &k_info[k_ptr->flavor];
8376                 }
8377                 else
8378                 {
8379                         /* Appearance of this object is very normal */
8380                         flavor_k_ptr = k_ptr;
8381                 }
8382
8383                 /* Prompt */
8384 #ifdef JP
8385                 prt(format("<Êý¸þ>%s%s%s, ESC",
8386                         (!visual_list && !visual_only) ? ", 'r'¤Ç¾ÜºÙ¤ò¸«¤ë" : "",
8387                         visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8388                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8389                         hgt - 1, 0);
8390 #else
8391                 prt(format("<dir>%s%s%s, ESC",
8392                         (!visual_list && !visual_only) ? ", 'r' to recall" : "",
8393                         visual_list ? ", ENTER to accept" : ", 'v' for visuals",
8394                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8395                         hgt - 1, 0);
8396 #endif
8397
8398                 if (!visual_only)
8399                 {
8400                         /* Mega Hack -- track this object */
8401                         if (object_cnt) object_kind_track(object_idx[object_cur]);
8402
8403                         /* The "current" object changed */
8404                         if (object_old != object_idx[object_cur])
8405                         {
8406                                 /* Hack -- handle stuff */
8407                                 handle_stuff();
8408
8409                                 /* Remember the "current" object */
8410                                 object_old = object_idx[object_cur];
8411                         }
8412                 }
8413
8414                 if (visual_list)
8415                 {
8416                         place_visual_list_cursor(max + 3, 7, flavor_k_ptr->x_attr, flavor_k_ptr->x_char, attr_top, char_left);
8417                 }
8418                 else if (!column)
8419                 {
8420                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8421                 }
8422                 else
8423                 {
8424                         Term_gotoxy(max + 3, 6 + (object_cur - object_top));
8425                 }
8426
8427                 ch = inkey();
8428
8429                 /* Do visual mode command if needed */
8430                 if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw))
8431                 {
8432                         if (direct_k_idx >= 0)
8433                         {
8434                                 switch (ch)
8435                                 {
8436                                 case '\n':
8437                                 case '\r':
8438                                 case ESCAPE:
8439                                         flag = TRUE;
8440                                         break;
8441                                 }
8442                         }
8443                         continue;
8444                 }
8445
8446                 switch (ch)
8447                 {
8448                         case ESCAPE:
8449                         {
8450                                 flag = TRUE;
8451                                 break;
8452                         }
8453
8454                         case 'R':
8455                         case 'r':
8456                         {
8457                                 /* Recall on screen */
8458                                 if (!visual_list && !visual_only && (grp_cnt > 0))
8459                                 {
8460                                         desc_obj_fake(object_idx[object_cur]);
8461                                         redraw = TRUE;
8462                                 }
8463                                 break;
8464                         }
8465
8466                         default:
8467                         {
8468                                 /* Move the cursor */
8469                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &object_cur, object_cnt);
8470                                 break;
8471                         }
8472                 }
8473         }
8474
8475         /* Free the "object_idx" array */
8476         C_KILL(object_idx, max_k_idx, int);
8477 }
8478
8479
8480 /*
8481  * Display the features in a group.
8482  */
8483 static void display_feature_list(int col, int row, int per_page, int *feat_idx,
8484         int feat_cur, int feat_top, bool visual_only, int lighting_level)
8485 {
8486         int lit_col[F_LIT_MAX], i, j;
8487         int f_idx_col = use_bigtile ? 62 : 64;
8488
8489         /* Correct columns 1 and 4 */
8490         lit_col[F_LIT_STANDARD] = use_bigtile ? (71 - F_LIT_MAX) : 71;
8491         for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
8492                 lit_col[i] = lit_col[F_LIT_STANDARD] + 2 + (i - F_LIT_NS_BEGIN) * 2 + (use_bigtile ? i : 0);
8493
8494         /* Display lines until done */
8495         for (i = 0; i < per_page && (feat_idx[feat_top + i] >= 0); i++)
8496         {
8497                 byte attr;
8498
8499                 /* Get the index */
8500                 int f_idx = feat_idx[feat_top + i];
8501
8502                 /* Access the index */
8503                 feature_type *f_ptr = &f_info[f_idx];
8504
8505                 int row_i = row + i;
8506
8507                 /* Choose a color */
8508                 attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
8509
8510                 /* Display the name */
8511                 c_prt(attr, f_name + f_ptr->name, row_i, col);
8512
8513                 /* Hack -- visual_list mode */
8514                 if (per_page == 1)
8515                 {
8516                         /* Display lighting level */
8517                         c_prt(attr, format("(%s)", lighting_level_str[lighting_level]), row_i, col + 1 + strlen(f_name + f_ptr->name));
8518
8519                         c_prt(attr, format("%02x/%02x", f_ptr->x_attr[lighting_level], f_ptr->x_char[lighting_level]), row_i, f_idx_col - ((p_ptr->wizard || visual_only) ? 6 : 2));
8520                 }
8521                 if (p_ptr->wizard || visual_only)
8522                 {
8523                         c_prt(attr, format("%d", f_idx), row_i, f_idx_col);
8524                 }
8525
8526                 /* Display symbol */
8527                 Term_queue_bigchar(lit_col[F_LIT_STANDARD], row_i, f_ptr->x_attr[F_LIT_STANDARD], f_ptr->x_char[F_LIT_STANDARD], 0, 0);
8528
8529                 Term_putch(lit_col[F_LIT_NS_BEGIN], row_i, TERM_SLATE, '(');
8530                 for (j = F_LIT_NS_BEGIN + 1; j < F_LIT_MAX; j++)
8531                 {
8532                         Term_putch(lit_col[j], row_i, TERM_SLATE, '/');
8533                 }
8534                 Term_putch(lit_col[F_LIT_MAX - 1] + (use_bigtile ? 3 : 2), row_i, TERM_SLATE, ')');
8535
8536                 /* Mega-hack -- Use non-standard colour */
8537                 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
8538                 {
8539                         Term_queue_bigchar(lit_col[j] + 1, row_i, f_ptr->x_attr[j], f_ptr->x_char[j], 0, 0);
8540                 }
8541         }
8542
8543         /* Clear remaining lines */
8544         for (; i < per_page; i++)
8545         {
8546                 Term_erase(col, row + i, 255);
8547         }
8548 }
8549
8550
8551 /*
8552  * Interact with feature visuals.
8553  */
8554 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int direct_f_idx, int *lighting_level)
8555 {
8556         int i, len, max;
8557         int grp_cur, grp_top, old_grp_cur;
8558         int feat_cur, feat_top;
8559         int grp_cnt, grp_idx[100];
8560         int feat_cnt;
8561         int *feat_idx;
8562
8563         int column = 0;
8564         bool flag;
8565         bool redraw;
8566
8567         bool visual_list = FALSE;
8568         byte attr_top = 0, char_left = 0;
8569
8570         int browser_rows;
8571         int wid, hgt;
8572
8573         byte attr_old[F_LIT_MAX];
8574         byte char_old[F_LIT_MAX];
8575         byte *cur_attr_ptr, *cur_char_ptr;
8576
8577         C_WIPE(attr_old, F_LIT_MAX, byte);
8578         C_WIPE(char_old, F_LIT_MAX, byte);
8579
8580         /* Get size */
8581         Term_get_size(&wid, &hgt);
8582
8583         browser_rows = hgt - 8;
8584
8585         /* Allocate the "feat_idx" array */
8586         C_MAKE(feat_idx, max_f_idx, int);
8587
8588         max = 0;
8589         grp_cnt = 0;
8590
8591         if (direct_f_idx < 0)
8592         {
8593                 /* Check every group */
8594                 for (i = 0; feature_group_text[i] != NULL; i++)
8595                 {
8596                         /* Measure the label */
8597                         len = strlen(feature_group_text[i]);
8598
8599                         /* Save the maximum length */
8600                         if (len > max) max = len;
8601
8602                         /* See if any features are known */
8603                         if (collect_features(i, feat_idx, 0x01))
8604                         {
8605                                 /* Build a list of groups with known features */
8606                                 grp_idx[grp_cnt++] = i;
8607                         }
8608                 }
8609
8610                 feat_cnt = 0;
8611         }
8612         else
8613         {
8614                 feature_type *f_ptr = &f_info[direct_f_idx];
8615
8616                 feat_idx[0] = direct_f_idx;
8617                 feat_cnt = 1;
8618
8619                 /* Terminate the list */
8620                 feat_idx[1] = -1;
8621
8622                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8623                         &attr_top, &char_left, &f_ptr->x_attr[*lighting_level], &f_ptr->x_char[*lighting_level], need_redraw);
8624
8625                 for (i = 0; i < F_LIT_MAX; i++)
8626                 {
8627                         attr_old[i] = f_ptr->x_attr[i];
8628                         char_old[i] = f_ptr->x_char[i];
8629                 }
8630         }
8631
8632         /* Terminate the list */
8633         grp_idx[grp_cnt] = -1;
8634
8635         old_grp_cur = -1;
8636         grp_cur = grp_top = 0;
8637         feat_cur = feat_top = 0;
8638
8639         flag = FALSE;
8640         redraw = TRUE;
8641
8642         while (!flag)
8643         {
8644                 char ch;
8645                 feature_type *f_ptr;
8646
8647                 if (redraw)
8648                 {
8649                         clear_from(0);
8650
8651 #ifdef JP
8652                         prt("ɽ¼¨ - ÃÏ·Á", 2, 0);
8653                         if (direct_f_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8654                         prt("̾Á°", 4, max + 3);
8655                         if (use_bigtile)
8656                         {
8657                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8658                                 prt("ʸ»ú ( l/ d)", 4, 66);
8659                         }
8660                         else
8661                         {
8662                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 64);
8663                                 prt("ʸ»ú (l/d)", 4, 68);
8664                         }
8665 #else
8666                         prt("Visuals - features", 2, 0);
8667                         if (direct_f_idx < 0) prt("Group", 4, 0);
8668                         prt("Name", 4, max + 3);
8669                         if (use_bigtile)
8670                         {
8671                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8672                                 prt("Sym ( l/ d)", 4, 67);
8673                         }
8674                         else
8675                         {
8676                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 64);
8677                                 prt("Sym (l/d)", 4, 69);
8678                         }
8679 #endif
8680
8681                         for (i = 0; i < 78; i++)
8682                         {
8683                                 Term_putch(i, 5, TERM_WHITE, '=');
8684                         }
8685
8686                         if (direct_f_idx < 0)
8687                         {
8688                                 for (i = 0; i < browser_rows; i++)
8689                                 {
8690                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8691                                 }
8692                         }
8693
8694                         redraw = FALSE;
8695                 }
8696
8697                 if (direct_f_idx < 0)
8698                 {
8699                         /* Scroll group list */
8700                         if (grp_cur < grp_top) grp_top = grp_cur;
8701                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8702
8703                         /* Display a list of feature groups */
8704                         display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
8705
8706                         if (old_grp_cur != grp_cur)
8707                         {
8708                                 old_grp_cur = grp_cur;
8709
8710                                 /* Get a list of features in the current group */
8711                                 feat_cnt = collect_features(grp_idx[grp_cur], feat_idx, 0x00);
8712                         }
8713
8714                         /* Scroll feature list */
8715                         while (feat_cur < feat_top)
8716                                 feat_top = MAX(0, feat_top - browser_rows/2);
8717                         while (feat_cur >= feat_top + browser_rows)
8718                                 feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows/2);
8719                 }
8720
8721                 if (!visual_list)
8722                 {
8723                         /* Display a list of features in the current group */
8724                         display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top, visual_only, F_LIT_STANDARD);
8725                 }
8726                 else
8727                 {
8728                         feat_top = feat_cur;
8729
8730                         /* Display a list of features in the current group */
8731                         display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top, visual_only, *lighting_level);
8732
8733                         /* Display visual list below first object */
8734                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8735                 }
8736
8737                 /* Prompt */
8738 #ifdef JP
8739                 prt(format("<Êý¸þ>%s, 'd'¤Çɸ½à¸÷¸»¸ú²Ì%s, ESC",
8740                         visual_list ? ", ENTER¤Ç·èÄê, 'a'¤ÇÂоÝÌÀÅÙÊѹ¹" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8741                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8742                         hgt - 1, 0);
8743 #else
8744                 prt(format("<dir>%s, 'd' for default lighting%s, ESC",
8745                         visual_list ? ", ENTER to accept, 'a' for lighting level" : ", 'v' for visuals",
8746                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8747                         hgt - 1, 0);
8748 #endif
8749
8750                 /* Get the current feature */
8751                 f_ptr = &f_info[feat_idx[feat_cur]];
8752                 cur_attr_ptr = &f_ptr->x_attr[*lighting_level];
8753                 cur_char_ptr = &f_ptr->x_char[*lighting_level];
8754
8755                 if (visual_list)
8756                 {
8757                         place_visual_list_cursor(max + 3, 7, *cur_attr_ptr, *cur_char_ptr, attr_top, char_left);
8758                 }
8759                 else if (!column)
8760                 {
8761                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8762                 }
8763                 else
8764                 {
8765                         Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
8766                 }
8767
8768                 ch = inkey();
8769
8770                 if (visual_list && ((ch == 'A') || (ch == 'a')))
8771                 {
8772                         int prev_lighting_level = *lighting_level;
8773
8774                         if (ch == 'A')
8775                         {
8776                                 if (*lighting_level <= 0) *lighting_level = F_LIT_MAX - 1;
8777                                 else (*lighting_level)--;
8778                         }
8779                         else
8780                         {
8781                                 if (*lighting_level >= F_LIT_MAX - 1) *lighting_level = 0;
8782                                 else (*lighting_level)++;
8783                         }
8784
8785                         if (f_ptr->x_attr[prev_lighting_level] != f_ptr->x_attr[*lighting_level])
8786                                 attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
8787
8788                         if (f_ptr->x_char[prev_lighting_level] != f_ptr->x_char[*lighting_level])
8789                                 char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
8790
8791                         continue;
8792                 }
8793
8794                 else if ((ch == 'D') || (ch == 'd'))
8795                 {
8796                         byte prev_x_attr = f_ptr->x_attr[*lighting_level];
8797                         byte prev_x_char = f_ptr->x_char[*lighting_level];
8798
8799                         apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
8800
8801                         if (visual_list)
8802                         {
8803                                 if (prev_x_attr != f_ptr->x_attr[*lighting_level])
8804                                          attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
8805
8806                                 if (prev_x_char != f_ptr->x_char[*lighting_level])
8807                                         char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
8808                         }
8809                         else *need_redraw = TRUE;
8810
8811                         continue;
8812                 }
8813
8814                 /* Do visual mode command if needed */
8815                 else if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, cur_attr_ptr, cur_char_ptr, need_redraw))
8816                 {
8817                         switch (ch)
8818                         {
8819                         /* Restore previous visual settings */
8820                         case ESCAPE:
8821                                 for (i = 0; i < F_LIT_MAX; i++)
8822                                 {
8823                                         f_ptr->x_attr[i] = attr_old[i];
8824                                         f_ptr->x_char[i] = char_old[i];
8825                                 }
8826
8827                                 /* Fall through */
8828
8829                         case '\n':
8830                         case '\r':
8831                                 if (direct_f_idx >= 0) flag = TRUE;
8832                                 else *lighting_level = F_LIT_STANDARD;
8833                                 break;
8834
8835                         /* Preserve current visual settings */
8836                         case 'V':
8837                         case 'v':
8838                                 for (i = 0; i < F_LIT_MAX; i++)
8839                                 {
8840                                         attr_old[i] = f_ptr->x_attr[i];
8841                                         char_old[i] = f_ptr->x_char[i];
8842                                 }
8843                                 *lighting_level = F_LIT_STANDARD;
8844                                 break;
8845
8846                         case 'C':
8847                         case 'c':
8848                                 if (!visual_list)
8849                                 {
8850                                         for (i = 0; i < F_LIT_MAX; i++)
8851                                         {
8852                                                 attr_idx_feat[i] = f_ptr->x_attr[i];
8853                                                 char_idx_feat[i] = f_ptr->x_char[i];
8854                                         }
8855                                 }
8856                                 break;
8857
8858                         case 'P':
8859                         case 'p':
8860                                 if (!visual_list)
8861                                 {
8862                                         /* Allow TERM_DARK text */
8863                                         for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
8864                                         {
8865                                                 if (attr_idx_feat[i] || (!(char_idx_feat[i] & 0x80) && char_idx_feat[i])) f_ptr->x_attr[i] = attr_idx_feat[i];
8866                                                 if (char_idx_feat[i]) f_ptr->x_char[i] = char_idx_feat[i];
8867                                         }
8868                                 }
8869                                 break;
8870                         }
8871                         continue;
8872                 }
8873
8874                 switch (ch)
8875                 {
8876                         case ESCAPE:
8877                         {
8878                                 flag = TRUE;
8879                                 break;
8880                         }
8881
8882                         default:
8883                         {
8884                                 /* Move the cursor */
8885                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
8886                                 break;
8887                         }
8888                 }
8889         }
8890
8891         /* Free the "feat_idx" array */
8892         C_KILL(feat_idx, max_f_idx, int);
8893 }
8894
8895
8896 /*
8897  * List wanted monsters
8898  */
8899 static void do_cmd_knowledge_kubi(void)
8900 {
8901         int i;
8902         FILE *fff;
8903         
8904         char file_name[1024];
8905         
8906         
8907         /* Open a new file */
8908         fff = my_fopen_temp(file_name, 1024);
8909         if (!fff) {
8910 #ifdef JP
8911             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8912 #else
8913             msg_format("Failed to create temporary file %s.", file_name);
8914 #endif
8915             msg_print(NULL);
8916             return;
8917         }
8918         
8919         if (fff)
8920         {
8921                 bool listed = FALSE;
8922
8923 #ifdef JP
8924                 fprintf(fff, "º£Æü¤Î¥¿¡¼¥²¥Ã¥È : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "ÉÔÌÀ"));
8925                 fprintf(fff, "\n");
8926                 fprintf(fff, "¾Þ¶â¼ó¥ê¥¹¥È\n");
8927 #else
8928                 fprintf(fff, "Today target : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "unknown"));
8929                 fprintf(fff, "\n");
8930                 fprintf(fff, "List of wanted monsters\n");
8931 #endif
8932                 fprintf(fff, "----------------------------------------------\n");
8933
8934                 for (i = 0; i < MAX_KUBI; i++)
8935                 {
8936                         if (kubi_r_idx[i] <= 10000)
8937                         {
8938                                 fprintf(fff,"%s\n", r_name + r_info[kubi_r_idx[i]].name);
8939
8940                                 listed = TRUE;
8941                         }
8942                 }
8943
8944                 if (!listed)
8945                 {
8946 #ifdef JP
8947                         fprintf(fff,"\n%s\n", "¾Þ¶â¼ó¤Ï¤â¤¦»Ä¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
8948 #else
8949                         fprintf(fff,"\n%s\n", "There is no more wanted monster.");
8950 #endif
8951                 }
8952         }
8953         
8954         /* Close the file */
8955         my_fclose(fff);
8956         
8957         /* Display the file contents */
8958 #ifdef JP
8959         show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
8960 #else
8961         show_file(TRUE, file_name, "Wanted monsters", 0, 0);
8962 #endif
8963
8964         
8965         /* Remove the file */
8966         fd_kill(file_name);
8967 }
8968
8969 /*
8970  * List virtues & status
8971  */
8972 static void do_cmd_knowledge_virtues(void)
8973 {
8974         FILE *fff;
8975         
8976         char file_name[1024];
8977         
8978         
8979         /* Open a new file */
8980         fff = my_fopen_temp(file_name, 1024);
8981         if (!fff) {
8982 #ifdef JP
8983             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8984 #else
8985             msg_format("Failed to create temporary file %s.", file_name);
8986 #endif
8987             msg_print(NULL);
8988             return;
8989         }
8990         
8991         if (fff)
8992         {
8993 #ifdef JP
8994                 fprintf(fff, "¸½ºß¤Î°À­ : %s\n\n", your_alignment());
8995 #else
8996                 fprintf(fff, "Your alighnment : %s\n\n", your_alignment());
8997 #endif
8998                 dump_virtues(fff);
8999         }
9000         
9001         /* Close the file */
9002         my_fclose(fff);
9003         
9004         /* Display the file contents */
9005 #ifdef JP
9006         show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
9007 #else
9008         show_file(TRUE, file_name, "Virtues", 0, 0);
9009 #endif
9010
9011         
9012         /* Remove the file */
9013         fd_kill(file_name);
9014 }
9015
9016 /*
9017 * Dungeon
9018 *
9019 */
9020 static void do_cmd_knowledge_dungeon(void)
9021 {
9022         FILE *fff;
9023         
9024         char file_name[1024];
9025         int i;
9026         
9027         
9028         /* Open a new file */
9029         fff = my_fopen_temp(file_name, 1024);
9030         if (!fff) {
9031 #ifdef JP
9032             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9033 #else
9034             msg_format("Failed to create temporary file %s.", file_name);
9035 #endif
9036             msg_print(NULL);
9037             return;
9038         }
9039         
9040         if (fff)
9041         {
9042                 for (i = 1; i < max_d_idx; i++)
9043                 {
9044                         bool seiha = FALSE;
9045
9046                         if (!d_info[i].maxdepth) continue;
9047                         if (!max_dlv[i]) continue;
9048                         if (d_info[i].final_guardian)
9049                         {
9050                                 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
9051                         }
9052                         else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
9053 #ifdef JP
9054                         fprintf(fff,"%c%-12s :  %3d ³¬\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
9055 #else
9056                         fprintf(fff,"%c%-16s :  level %3d\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
9057 #endif
9058                 }
9059         }
9060         
9061         /* Close the file */
9062         my_fclose(fff);
9063         
9064         /* Display the file contents */
9065 #ifdef JP
9066         show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
9067 #else
9068         show_file(TRUE, file_name, "Dungeon", 0, 0);
9069 #endif
9070
9071         
9072         /* Remove the file */
9073         fd_kill(file_name);
9074 }
9075
9076 /*
9077 * List virtues & status
9078 *
9079 */
9080 static void do_cmd_knowledge_stat(void)
9081 {
9082         FILE *fff;
9083         
9084         char file_name[1024];
9085         int percent, v_nr;
9086         
9087         /* Open a new file */
9088         fff = my_fopen_temp(file_name, 1024);
9089         if (!fff) {
9090 #ifdef JP
9091             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9092 #else
9093             msg_format("Failed to create temporary file %s.", file_name);
9094 #endif
9095             msg_print(NULL);
9096             return;
9097         }
9098         
9099         if (fff)
9100         {
9101                 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
9102                         (2 * p_ptr->hitdie +
9103                         ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
9104
9105 #ifdef JP
9106                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
9107                 else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
9108                 fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
9109 #else
9110                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
9111                 else fprintf(fff, "Your current Life Rating is ???.\n\n");
9112                 fprintf(fff, "Limits of maximum stats\n\n");
9113 #endif
9114                 for (v_nr = 0; v_nr < 6; v_nr++)
9115                 {
9116                         if ((p_ptr->knowledge & KNOW_STAT) || p_ptr->stat_max[v_nr] == p_ptr->stat_max_max[v_nr]) fprintf(fff, "%s 18/%d\n", stat_names[v_nr], p_ptr->stat_max_max[v_nr]-18);
9117                         else fprintf(fff, "%s ???\n", stat_names[v_nr]);
9118                 }
9119         }
9120
9121         dump_yourself(fff);
9122
9123         /* Close the file */
9124         my_fclose(fff);
9125         
9126         /* Display the file contents */
9127 #ifdef JP
9128         show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
9129 #else
9130         show_file(TRUE, file_name, "HP-rate & Max stat", 0, 0);
9131 #endif
9132
9133         
9134         /* Remove the file */
9135         fd_kill(file_name);
9136 }
9137
9138
9139 /*
9140  * Print all active quests
9141  */
9142 static void do_cmd_knowledge_quests_current(FILE *fff)
9143 {
9144         char tmp_str[120];
9145         char rand_tmp_str[120] = "\0";
9146         char name[80];
9147         monster_race *r_ptr;
9148         int i;
9149         int rand_level = 100;
9150         int total = 0;
9151
9152 #ifdef JP
9153         fprintf(fff, "¡Ô¿ë¹ÔÃæ¤Î¥¯¥¨¥¹¥È¡Õ\n");
9154 #else
9155         fprintf(fff, "< Current Quest >\n");
9156 #endif
9157
9158         for (i = 1; i < max_quests; i++)
9159         {
9160                 if ((quest[i].status == QUEST_STATUS_TAKEN) || (quest[i].status == QUEST_STATUS_COMPLETED))
9161                 {
9162                         /* Set the quest number temporary */
9163                         int old_quest = p_ptr->inside_quest;
9164                         int j;
9165
9166                         /* Clear the text */
9167                         for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
9168                         quest_text_line = 0;
9169
9170                         p_ptr->inside_quest = i;
9171
9172                         /* Get the quest text */
9173                         init_flags = INIT_SHOW_TEXT;
9174
9175                         process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9176
9177                         /* Reset the old quest number */
9178                         p_ptr->inside_quest = old_quest;
9179
9180                         /* No info from "silent" quests */
9181                         if (quest[i].flags & QUEST_FLAG_SILENT) continue;
9182
9183                         total++;
9184
9185                         if (quest[i].type != QUEST_TYPE_RANDOM)
9186                         {
9187                                 char note[80] = "\0";
9188
9189                                 if (quest[i].status == QUEST_STATUS_TAKEN)
9190                                 {
9191                                         switch (quest[i].type)
9192                                         {
9193                                         case QUEST_TYPE_KILL_LEVEL:
9194                                         case QUEST_TYPE_KILL_ANY_LEVEL:
9195                                                 r_ptr = &r_info[quest[i].r_idx];
9196                                                 strcpy(name, r_name + r_ptr->name);
9197                                                 if (quest[i].max_num > 1)
9198                                                 {
9199 #ifdef JP
9200                                                         sprintf(note," - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
9201                                                                 quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
9202 #else
9203                                                         plural_aux(name);
9204                                                         sprintf(note," - kill %d %s, have killed %d.",
9205                                                                 quest[i].max_num, name, quest[i].cur_num);
9206 #endif
9207                                                 }
9208                                                 else
9209 #ifdef JP
9210                                                         sprintf(note," - %s¤òÅݤ¹¡£",name);
9211 #else
9212                                                         sprintf(note," - kill %s.",name);
9213 #endif
9214                                                 break;
9215
9216                                         case QUEST_TYPE_FIND_ARTIFACT:
9217                                                 strcpy(name, a_name + a_info[quest[i].k_idx].name);
9218 #ifdef JP
9219                                                 sprintf(note," - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
9220 #else
9221                                                 sprintf(note," - Find out %s.", name);
9222 #endif
9223                                                 break;
9224
9225                                         case QUEST_TYPE_FIND_EXIT:
9226 #ifdef JP
9227                                                 sprintf(note," - Ãµº÷¤¹¤ë¡£");
9228 #else
9229                                                 sprintf(note," - Search.");
9230 #endif
9231                                                 break;
9232
9233                                         case QUEST_TYPE_KILL_NUMBER:
9234 #ifdef JP
9235                                                 sprintf(note," - %d ÂΤΥâ¥ó¥¹¥¿¡¼¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
9236                                                         quest[i].max_num, quest[i].max_num - quest[i].cur_num);
9237 #else
9238                                                 sprintf(note," - Kill %d monsters, have killed %d.",
9239                                                         quest[i].max_num, quest[i].cur_num);
9240 #endif
9241                                                 break;
9242
9243                                         case QUEST_TYPE_KILL_ALL:
9244 #ifdef JP
9245                                                 sprintf(note," - Á´¤Æ¤Î¥â¥ó¥¹¥¿¡¼¤òÅݤ¹¡£");
9246 #else
9247                                                 sprintf(note," - Kill all monsters.");
9248 #endif
9249                                                 break;
9250                                         }
9251                                 }
9252
9253                                 /* Print the quest info */
9254 #ifdef JP
9255                                 sprintf(tmp_str, "  %s (´í¸±ÅÙ:%d³¬ÁêÅö)%s\n",
9256                                         quest[i].name, quest[i].level, note);
9257 #else
9258                                 sprintf(tmp_str, "  %s (Danger level: %d)%s\n",
9259                                         quest[i].name, quest[i].level, note);
9260 #endif
9261
9262                                 fprintf(fff, tmp_str);
9263
9264                                 if (quest[i].status == QUEST_STATUS_COMPLETED)
9265                                 {
9266 #ifdef JP
9267                                         sprintf(tmp_str, "    ¥¯¥¨¥¹¥ÈãÀ® - ¤Þ¤ÀÊó½·¤ò¼õ¤±¤È¤Ã¤Æ¤Ê¤¤¡£\n");
9268 #else
9269                                         sprintf(tmp_str, "    Quest Completed - Unrewarded\n");
9270 #endif
9271                                         fprintf(fff, tmp_str);
9272                                 }
9273                                 else
9274                                 {
9275                                         j = 0;
9276
9277                                         while (quest_text[j][0] && j < 10)
9278                                         {
9279                                                 fprintf(fff, "    %s\n", quest_text[j]);
9280                                                 j++;
9281                                         }
9282                                 }
9283                         }
9284                         else if (quest[i].level < rand_level) /* QUEST_TYPE_RANDOM */
9285                         {
9286                                 /* New random */
9287                                 rand_level = quest[i].level;
9288
9289                                 if (max_dlv[DUNGEON_ANGBAND] >= rand_level)
9290                                 {
9291                                         /* Print the quest info */
9292                                         r_ptr = &r_info[quest[i].r_idx];
9293                                         strcpy(name, r_name + r_ptr->name);
9294
9295                                         if (quest[i].max_num > 1)
9296                                         {
9297 #ifdef JP
9298                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
9299                                                         quest[i].name, quest[i].level,
9300                                                         quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
9301 #else
9302                                                 plural_aux(name);
9303
9304                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
9305                                                         quest[i].name, quest[i].level,
9306                                                         quest[i].max_num, name, quest[i].cur_num);
9307 #endif
9308                                         }
9309                                         else
9310                                         {
9311 #ifdef JP
9312                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %s¤òÅݤ¹¡£\n",
9313                                                         quest[i].name, quest[i].level, name);
9314 #else
9315                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %s.\n",
9316                                                         quest[i].name, quest[i].level, name);
9317 #endif
9318                                         }
9319                                 }
9320                         }
9321                 }
9322         }
9323
9324         /* Print the current random quest  */
9325         if (rand_tmp_str[0]) fprintf(fff, rand_tmp_str);
9326
9327 #ifdef JP
9328         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9329 #else
9330         if (!total) fprintf(fff, "  Nothing.\n");
9331 #endif
9332 }
9333
9334
9335 /*
9336  * Print all finished quests
9337  */
9338 void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
9339 {
9340         char tmp_str[120];
9341         int i;
9342         int total = 0;
9343
9344 #ifdef JP
9345         fprintf(fff, "¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
9346 #else
9347         fprintf(fff, "< Completed Quest >\n");
9348 #endif
9349         for (i = 1; i < max_quests; i++)
9350         {
9351                 int q_idx = quest_num[i];
9352
9353                 if (quest[q_idx].status == QUEST_STATUS_FINISHED)
9354                 {
9355                         if (is_fixed_quest_idx(q_idx))
9356                         {
9357                                 /* Set the quest number temporary */
9358                                 int old_quest = p_ptr->inside_quest;
9359
9360                                 p_ptr->inside_quest = q_idx;
9361
9362                                 /* Get the quest */
9363                                 init_flags = INIT_ASSIGN;
9364
9365                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9366
9367                                 /* Reset the old quest number */
9368                                 p_ptr->inside_quest = old_quest;
9369
9370                                 /* No info from "silent" quests */
9371                                 if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
9372                         }
9373
9374                         total++;
9375
9376                         if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
9377                         {
9378                                 /* Print the quest info */
9379
9380                                 if (quest[q_idx].complev == 0)
9381                                 {
9382                                         sprintf(tmp_str,
9383 #ifdef JP
9384                                                 "  %-40s (%3d³¬)            -   ÉÔÀᄀ\n",
9385 #else
9386                                                 "  %-40s (Dungeon level: %3d) - (Cancelled)\n",
9387 #endif
9388                                                 r_name+r_info[quest[q_idx].r_idx].name,
9389                                                 quest[q_idx].level);
9390                                 }
9391                                 else
9392                                 {
9393                                         sprintf(tmp_str,
9394 #ifdef JP
9395                                                 "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
9396 #else
9397                                                 "  %-40s (Dungeon level: %3d) - level %2d\n",
9398 #endif
9399                                                 r_name+r_info[quest[q_idx].r_idx].name,
9400                                                 quest[q_idx].level,
9401                                                 quest[q_idx].complev);
9402                                 }
9403                         }
9404                         else
9405                         {
9406                                 /* Print the quest info */
9407 #ifdef JP
9408                                 sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
9409                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9410 #else
9411                                 sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
9412                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9413 #endif
9414                         }
9415
9416                         fprintf(fff, tmp_str);
9417                 }
9418         }
9419 #ifdef JP
9420         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9421 #else
9422         if (!total) fprintf(fff, "  Nothing.\n");
9423 #endif
9424 }
9425
9426
9427 /*
9428  * Print all failed quests
9429  */
9430 void do_cmd_knowledge_quests_failed(FILE *fff, int quest_num[])
9431 {
9432         char tmp_str[120];
9433         int i;
9434         int total = 0;
9435
9436 #ifdef JP
9437         fprintf(fff, "¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
9438 #else
9439         fprintf(fff, "< Failed Quest >\n");
9440 #endif
9441         for (i = 1; i < max_quests; i++)
9442         {
9443                 int q_idx = quest_num[i];
9444
9445                 if ((quest[q_idx].status == QUEST_STATUS_FAILED_DONE) || (quest[q_idx].status == QUEST_STATUS_FAILED))
9446                 {
9447                         if (is_fixed_quest_idx(q_idx))
9448                         {
9449                                 /* Set the quest number temporary */
9450                                 int old_quest = p_ptr->inside_quest;
9451
9452                                 p_ptr->inside_quest = q_idx;
9453
9454                                 /* Get the quest text */
9455                                 init_flags = INIT_ASSIGN;
9456
9457                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9458
9459                                 /* Reset the old quest number */
9460                                 p_ptr->inside_quest = old_quest;
9461
9462                                 /* No info from "silent" quests */
9463                                 if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
9464                         }
9465
9466                         total++;
9467
9468                         if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
9469                         {
9470                                 /* Print the quest info */
9471 #ifdef JP
9472                                 sprintf(tmp_str, "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
9473                                         r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
9474 #else
9475                                 sprintf(tmp_str, "  %-40s (Dungeon level: %3d) - level %2d\n",
9476                                         r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
9477 #endif
9478                         }
9479                         else
9480                         {
9481                                 /* Print the quest info */
9482 #ifdef JP
9483                                 sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
9484                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9485 #else
9486                                 sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
9487                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9488 #endif
9489                         }
9490                         fprintf(fff, tmp_str);
9491                 }
9492         }
9493 #ifdef JP
9494         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9495 #else
9496         if (!total) fprintf(fff, "  Nothing.\n");
9497 #endif
9498 }
9499
9500
9501 /*
9502  * Print all random quests
9503  */
9504 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
9505 {
9506         char tmp_str[120];
9507         int i;
9508         int total = 0;
9509
9510 #ifdef JP
9511         fprintf(fff, "¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
9512 #else
9513         fprintf(fff, "< Remaining Random Quest >\n");
9514 #endif
9515         for (i = 1; i < max_quests; i++)
9516         {
9517                 /* No info from "silent" quests */
9518                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
9519
9520                 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
9521                 {
9522                         total++;
9523
9524                         /* Print the quest info */
9525 #ifdef JP
9526                         sprintf(tmp_str, "  %s (%d³¬, %s)\n",
9527                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
9528 #else
9529                         sprintf(tmp_str, "  %s (%d, %s)\n",
9530                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
9531 #endif
9532                         fprintf(fff, tmp_str);
9533                 }
9534         }
9535 #ifdef JP
9536         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9537 #else
9538         if (!total) fprintf(fff, "  Nothing.\n");
9539 #endif
9540 }
9541
9542
9543 bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
9544 {
9545         int *q_num = (int *)u;
9546         quest_type *qa = &quest[q_num[a]];
9547         quest_type *qb = &quest[q_num[b]];
9548
9549         /* Unused */
9550         (void)v;
9551
9552         if (qa->complev < qb->complev) return TRUE;
9553         if (qa->complev > qb->complev) return FALSE;
9554         if (qa->level <= qb->level) return TRUE;
9555         return FALSE;
9556 }
9557
9558 void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
9559 {
9560         int *q_num = (int *)u;
9561         int tmp;
9562
9563         /* Unused */
9564         (void)v;
9565
9566         tmp = q_num[a];
9567         q_num[a] = q_num[b];
9568         q_num[b] = tmp;
9569 }
9570
9571
9572 /*
9573  * Print quest status of all active quests
9574  */
9575 static void do_cmd_knowledge_quests(void)
9576 {
9577         FILE *fff;
9578         char file_name[1024];
9579         int *quest_num, dummy, i;
9580
9581         /* Open a new file */
9582         fff = my_fopen_temp(file_name, 1024);
9583         if (!fff)
9584         {
9585 #ifdef JP
9586             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9587 #else
9588             msg_format("Failed to create temporary file %s.", file_name);
9589 #endif
9590             msg_print(NULL);
9591             return;
9592         }
9593
9594         /* Allocate Memory */
9595         C_MAKE(quest_num, max_quests, int);
9596
9597         /* Sort by compete level */
9598         for (i = 1; i < max_quests; i++) quest_num[i] = i;
9599         ang_sort_comp = ang_sort_comp_quest_num;
9600         ang_sort_swap = ang_sort_swap_quest_num;
9601         ang_sort(quest_num, &dummy, max_quests);
9602
9603         /* Dump Quest Information */
9604         do_cmd_knowledge_quests_current(fff);
9605         fputc('\n', fff);
9606         do_cmd_knowledge_quests_completed(fff, quest_num);
9607         fputc('\n', fff);
9608         do_cmd_knowledge_quests_failed(fff, quest_num);
9609         if (p_ptr->wizard)
9610         {
9611                 fputc('\n', fff);
9612                 do_cmd_knowledge_quests_wiz_random(fff);
9613         }
9614
9615         /* Close the file */
9616         my_fclose(fff);
9617
9618         /* Display the file contents */
9619 #ifdef JP
9620         show_file(TRUE, file_name, "¥¯¥¨¥¹¥ÈãÀ®¾õ¶·", 0, 0);
9621 #else
9622         show_file(TRUE, file_name, "Quest status", 0, 0);
9623 #endif
9624
9625         /* Remove the file */
9626         fd_kill(file_name);
9627
9628         /* Free Memory */
9629         C_KILL(quest_num, max_quests, int);
9630 }
9631
9632
9633 /*
9634  * List my home
9635  */
9636 static void do_cmd_knowledge_home(void)
9637 {
9638         FILE *fff;
9639
9640         int i;
9641         char file_name[1024];
9642         store_type  *st_ptr;
9643         char o_name[MAX_NLEN];
9644         cptr            paren = ")";
9645
9646         process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
9647
9648         /* Open a new file */
9649         fff = my_fopen_temp(file_name, 1024);
9650         if (!fff) {
9651 #ifdef JP
9652                 msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9653 #else
9654                 msg_format("Failed to create temporary file %s.", file_name);
9655 #endif
9656                 msg_print(NULL);
9657                 return;
9658         }
9659
9660         if (fff)
9661         {
9662                 /* Print all homes in the different towns */
9663                 st_ptr = &town[1].store[STORE_HOME];
9664
9665                 /* Home -- if anything there */
9666                 if (st_ptr->stock_num)
9667                 {
9668 #ifdef JP
9669                         int x = 1;
9670 #endif
9671                         /* Header with name of the town */
9672 #ifdef JP
9673                         fprintf(fff, "  [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
9674 #else
9675                         fprintf(fff, "  [Home Inventory]\n");
9676 #endif
9677
9678                         /* Dump all available items */
9679                         for (i = 0; i < st_ptr->stock_num; i++)
9680                         {
9681 #ifdef JP
9682                                 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
9683                                 object_desc(o_name, &st_ptr->stock[i], 0);
9684                                 if (strlen(o_name) <= 80-3)
9685                                 {
9686                                         fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9687                                 }
9688                                 else
9689                                 {
9690                                         int n;
9691                                         char *t;
9692                                         for (n = 0, t = o_name; n < 80-3; n++, t++)
9693                                                 if(iskanji(*t)) {t++; n++;}
9694                                         if (n == 81-3) n = 79-3; /* ºÇ¸å¤¬´Á»úȾʬ */
9695
9696                                         fprintf(fff, "%c%s %.*s\n", I2A(i%12), paren, n, o_name);
9697                                         fprintf(fff, "   %.77s\n", o_name+n);
9698                                 }
9699 #else
9700                                 object_desc(o_name, &st_ptr->stock[i], 0);
9701                                 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9702 #endif
9703
9704                         }
9705
9706                         /* Add an empty line */
9707                         fprintf(fff, "\n\n");
9708                 }
9709         }
9710
9711         /* Close the file */
9712         my_fclose(fff);
9713
9714         /* Display the file contents */
9715 #ifdef JP
9716         show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
9717 #else
9718         show_file(TRUE, file_name, "Home Inventory", 0, 0);
9719 #endif
9720
9721
9722         /* Remove the file */
9723         fd_kill(file_name);
9724 }
9725
9726
9727 /*
9728  * Check the status of "autopick"
9729  */
9730 static void do_cmd_knowledge_autopick(void)
9731 {
9732         int k;
9733         FILE *fff;
9734         char file_name[1024];
9735
9736         /* Open a new file */
9737         fff = my_fopen_temp(file_name, 1024);
9738
9739         if (!fff)
9740         {
9741 #ifdef JP
9742             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9743 #else
9744             msg_format("Failed to create temporary file %s.", file_name);
9745 #endif
9746             msg_print(NULL);
9747             return;
9748         }
9749
9750         if (!max_autopick)
9751         {
9752 #ifdef JP
9753             fprintf(fff, "¼«Æ°Ç˲õ/½¦¤¤¤Ë¤Ï²¿¤âÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
9754 #else
9755             fprintf(fff, "No preference for auto picker/destroyer.");
9756 #endif
9757         }
9758         else
9759         {
9760 #ifdef JP
9761             fprintf(fff, "   ¼«Æ°½¦¤¤/Ç˲õ¤Ë¤Ï¸½ºß %d¹ÔÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n\n", max_autopick);
9762 #else
9763             fprintf(fff, "   There are %d registered lines for auto picker/destroyer.\n\n", max_autopick);
9764 #endif
9765         }
9766
9767         for (k = 0; k < max_autopick; k++)
9768         {
9769                 cptr tmp;
9770                 byte act = autopick_list[k].action;
9771                 if (act & DONT_AUTOPICK)
9772                 {
9773 #ifdef JP
9774                         tmp = "ÊüÃÖ";
9775 #else
9776                         tmp = "Leave";
9777 #endif
9778                 }
9779                 else if (act & DO_AUTODESTROY)
9780                 {
9781 #ifdef JP
9782                         tmp = "Ç˲õ";
9783 #else
9784                         tmp = "Destroy";
9785 #endif
9786                 }
9787                 else if (act & DO_AUTOPICK)
9788                 {
9789 #ifdef JP
9790                         tmp = "½¦¤¦";
9791 #else
9792                         tmp = "Pickup";
9793 #endif
9794                 }
9795                 else /* if (act & DO_QUERY_AUTOPICK) */ /* Obvious */
9796                 {
9797 #ifdef JP
9798                         tmp = "³Îǧ";
9799 #else
9800                         tmp = "Query";
9801 #endif
9802                 }
9803
9804                 if (act & DO_DISPLAY)
9805                         fprintf(fff, "%11s", format("[%s]", tmp));
9806                 else
9807                         fprintf(fff, "%11s", format("(%s)", tmp));
9808
9809                 tmp = autopick_line_from_entry(&autopick_list[k]);
9810                 fprintf(fff, " %s", tmp);
9811                 string_free(tmp);
9812                 fprintf(fff, "\n");
9813         }
9814         /* Close the file */
9815         my_fclose(fff);
9816         /* Display the file contents */
9817 #ifdef JP
9818         show_file(TRUE, file_name, "¼«Æ°½¦¤¤/Ç˲õ ÀßÄê¥ê¥¹¥È", 0, 0);
9819 #else
9820         show_file(TRUE, file_name, "Auto-picker/Destroyer", 0, 0);
9821 #endif
9822
9823         /* Remove the file */
9824         fd_kill(file_name);
9825 }
9826
9827
9828 /*
9829  * Interact with "knowledge"
9830  */
9831 void do_cmd_knowledge(void)
9832 {
9833         int i, p = 0;
9834         bool need_redraw = FALSE;
9835
9836         /* File type is "TEXT" */
9837         FILE_TYPE(FILE_TYPE_TEXT);
9838
9839         /* Save the screen */
9840         screen_save();
9841
9842         /* Interact until done */
9843         while (1)
9844         {
9845                 /* Clear screen */
9846                 Term_clear();
9847
9848                 /* Ask for a choice */
9849 #ifdef JP
9850                 prt(format("%d/2 ¥Ú¡¼¥¸", (p+1)), 2, 65);
9851                 prt("¸½ºß¤ÎÃ챤ò³Îǧ¤¹¤ë", 3, 0);
9852 #else
9853                 prt(format("page %d/2", (p+1)), 2, 65);
9854                 prt("Display current knowledge", 3, 0);
9855 #endif
9856
9857                 /* Give some choices */
9858 #ifdef JP
9859                 if (p == 0)
9860                 {
9861                         prt("(1) ´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à                 ¤Î°ìÍ÷", 6, 5);
9862                         prt("(2) ´ûÃΤΥ¢¥¤¥Æ¥à                       ¤Î°ìÍ÷", 7, 5);
9863                         prt("(3) ´ûÃΤÎÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ ¤Î°ìÍ÷", 8, 5);
9864                         prt("(4) ´ûÃΤΥâ¥ó¥¹¥¿¡¼                     ¤Î°ìÍ÷", 9, 5);
9865                         prt("(5) Åݤ·¤¿Å¨¤Î¿ô                         ¤Î°ìÍ÷", 10, 5);
9866                         if (!vanilla_town) prt("(6) ¾Þ¶â¼ó                               ¤Î°ìÍ÷", 11, 5);
9867                         prt("(7) ¸½ºß¤Î¥Ú¥Ã¥È                         ¤Î°ìÍ÷", 12, 5);
9868                         prt("(8) ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à                     ¤Î°ìÍ÷", 13, 5);
9869                         prt("(9) *´ÕÄê*ºÑ¤ßÁõÈ÷¤ÎÂÑÀ­                 ¤Î°ìÍ÷", 14, 5);
9870                         prt("(0) ÃÏ·Á¤Îɽ¼¨Ê¸»ú/¥¿¥¤¥ë                ¤Î°ìÍ÷", 15, 5);
9871                 }
9872                 else
9873                 {
9874                         prt("(a) ¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó                     ¤Î°ìÍ÷", 6, 5);
9875                         prt("(b) ÆÍÁ³ÊÑ°Û                             ¤Î°ìÍ÷", 7, 5);
9876                         prt("(c) Éð´ï¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 8, 5);
9877                         prt("(d) ËâË¡¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 9, 5);
9878                         prt("(e) µ»Ç½¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 10, 5);
9879                         prt("(f) ¥×¥ì¥¤¥ä¡¼¤ÎÆÁ                       ¤Î°ìÍ÷", 11, 5);
9880                         prt("(g) Æþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó                     ¤Î°ìÍ÷", 12, 5);
9881                         prt("(h) ¼Â¹ÔÃæ¤Î¥¯¥¨¥¹¥È                     ¤Î°ìÍ÷", 13, 5);
9882                         prt("(i) ¸½ºß¤Î¼«Æ°½¦¤¤/Ç˲õÀßÄê              ¤Î°ìÍ÷", 14, 5);
9883                 }
9884 #else
9885                 if (p == 0)
9886                 {
9887                         prt("(1) Display known artifacts", 6, 5);
9888                         prt("(2) Display known objects", 7, 5);
9889                         prt("(3) Display remaining uniques", 8, 5);
9890                         prt("(4) Display known monster", 9, 5);
9891                         prt("(5) Display kill count", 10, 5);
9892                         if (!vanilla_town) prt("(6) Display wanted monsters", 11, 5);
9893                         prt("(7) Display current pets", 12, 5);
9894                         prt("(8) Display home inventory", 13, 5);
9895                         prt("(9) Display *identified* equip.", 14, 5);
9896                         prt("(0) Display terrain symbols.", 15, 5);
9897                 }
9898                 else
9899                 {
9900                         prt("(a) Display about yourself", 6, 5);
9901                         prt("(b) Display mutations", 7, 5);
9902                         prt("(c) Display weapon proficiency", 8, 5);
9903                         prt("(d) Display spell proficiency", 9, 5);
9904                         prt("(e) Display misc. proficiency", 10, 5);
9905                         prt("(f) Display virtues", 11, 5);
9906                         prt("(g) Display dungeons", 12, 5);
9907                         prt("(h) Display current quests", 13, 5);
9908                         prt("(i) Display auto pick/destroy", 14, 5);
9909                 }
9910 #endif
9911                 /* Prompt */
9912 #ifdef JP
9913                 prt("-³¤¯-", 17, 8);
9914                 prt("ESC) È´¤±¤ë", 21, 1);
9915                 prt("SPACE) ¼¡¥Ú¡¼¥¸", 21, 30);
9916                 /*prt("-) Á°¥Ú¡¼¥¸", 21, 60);*/
9917                 prt("¥³¥Þ¥ó¥É:", 20, 0);
9918 #else
9919                 prt("-more-", 17, 8);
9920                 prt("ESC) Exit menu", 21, 1);
9921                 prt("SPACE) Next page", 21, 30);
9922                 /*prt("-) Previous page", 21, 60);*/
9923                 prt("Command: ", 20, 0);
9924 #endif
9925
9926                 /* Prompt */
9927                 i = inkey();
9928
9929                 /* Done */
9930                 if (i == ESCAPE) break;
9931                 switch (i)
9932                 {
9933                 case ' ': /* Page change */
9934                 case '-':
9935                         p = 1 - p;
9936                         break;
9937                 case '1': /* Artifacts */
9938                         do_cmd_knowledge_artifacts();
9939                         break;
9940                 case '2': /* Objects */
9941                         do_cmd_knowledge_objects(&need_redraw, FALSE, -1);
9942                         break;
9943                 case '3': /* Uniques */
9944                         do_cmd_knowledge_uniques();
9945                         break;
9946                 case '4': /* Monsters */
9947                         do_cmd_knowledge_monsters(&need_redraw, FALSE, -1);
9948                         break;
9949                 case '5': /* Kill count  */
9950                         do_cmd_knowledge_kill_count();
9951                         break;
9952                 case '6': /* wanted */
9953                         if (!vanilla_town) do_cmd_knowledge_kubi();
9954                         break;
9955                 case '7': /* Pets */
9956                         do_cmd_knowledge_pets();
9957                         break;
9958                 case '8': /* Home */
9959                         do_cmd_knowledge_home();
9960                         break;
9961                 case '9': /* Resist list */
9962                         do_cmd_knowledge_inven();
9963                         break;
9964                 case '0': /* Feature list */
9965                         {
9966                                 int lighting_level = F_LIT_STANDARD;
9967                                 do_cmd_knowledge_features(&need_redraw, FALSE, -1, &lighting_level);
9968                         }
9969                         break;
9970                 /* Next page */
9971                 case 'a': /* Max stat */
9972                         do_cmd_knowledge_stat();
9973                         break;
9974                 case 'b': /* Mutations */
9975                         do_cmd_knowledge_mutations();
9976                         break;
9977                 case 'c': /* weapon-exp */
9978                         do_cmd_knowledge_weapon_exp();
9979                         break;
9980                 case 'd': /* spell-exp */
9981                         do_cmd_knowledge_spell_exp();
9982                         break;
9983                 case 'e': /* skill-exp */
9984                         do_cmd_knowledge_skill_exp();
9985                         break;
9986                 case 'f': /* Virtues */
9987                         do_cmd_knowledge_virtues();
9988                         break;
9989                 case 'g': /* Dungeon */
9990                         do_cmd_knowledge_dungeon();
9991                         break;
9992                 case 'h': /* Quests */
9993                         do_cmd_knowledge_quests();
9994                         break;
9995                 case 'i': /* Autopick */
9996                         do_cmd_knowledge_autopick();
9997                         break;
9998                 default: /* Unknown option */
9999                         bell();
10000                 }
10001
10002                 /* Flush messages */
10003                 msg_print(NULL);
10004         }
10005
10006         /* Restore the screen */
10007         screen_load();
10008
10009         if (need_redraw) do_cmd_redraw();
10010 }
10011
10012
10013 /*
10014  * Check on the status of an active quest
10015  */
10016 void do_cmd_checkquest(void)
10017 {
10018         /* File type is "TEXT" */
10019         FILE_TYPE(FILE_TYPE_TEXT);
10020
10021         /* Save the screen */
10022         screen_save();
10023
10024         /* Quest info */
10025         do_cmd_knowledge_quests();
10026
10027         /* Restore the screen */
10028         screen_load();
10029 }
10030
10031
10032 /*
10033  * Display the time and date
10034  */
10035 void do_cmd_time(void)
10036 {
10037         int day, hour, min, full, start, end, num;
10038         char desc[1024];
10039
10040         char buf[1024];
10041         char day_buf[10];
10042
10043         FILE *fff;
10044
10045         extract_day_hour_min(&day, &hour, &min);
10046
10047         full = hour * 100 + min;
10048
10049         start = 9999;
10050         end = -9999;
10051
10052         num = 0;
10053
10054 #ifdef JP
10055         strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
10056 #else
10057         strcpy(desc, "It is a strange time.");
10058 #endif
10059
10060
10061         if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
10062         else strcpy(day_buf, "*****");
10063
10064         /* Message */
10065 #ifdef JP
10066         msg_format("%sÆüÌÜ, »þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
10067                    day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
10068                    min, (hour < 12) ? "AM" : "PM");
10069 #else
10070         msg_format("This is day %s. The time is %d:%02d %s.",
10071                    day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
10072                    min, (hour < 12) ? "AM" : "PM");
10073 #endif
10074
10075
10076         /* Find the path */
10077         if (!randint0(10) || p_ptr->image)
10078         {
10079 #ifdef JP
10080                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
10081 #else
10082                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
10083 #endif
10084
10085         }
10086         else
10087         {
10088 #ifdef JP
10089                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
10090 #else
10091                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
10092 #endif
10093
10094         }
10095
10096         /* Open this file */
10097         fff = my_fopen(buf, "rt");
10098
10099         /* Oops */
10100         if (!fff) return;
10101
10102         /* Find this time */
10103         while (!my_fgets(fff, buf, sizeof(buf)))
10104         {
10105                 /* Ignore comments */
10106                 if (!buf[0] || (buf[0] == '#')) continue;
10107
10108                 /* Ignore invalid lines */
10109                 if (buf[1] != ':') continue;
10110
10111                 /* Process 'Start' */
10112                 if (buf[0] == 'S')
10113                 {
10114                         /* Extract the starting time */
10115                         start = atoi(buf + 2);
10116
10117                         /* Assume valid for an hour */
10118                         end = start + 59;
10119
10120                         /* Next... */
10121                         continue;
10122                 }
10123
10124                 /* Process 'End' */
10125                 if (buf[0] == 'E')
10126                 {
10127                         /* Extract the ending time */
10128                         end = atoi(buf + 2);
10129
10130                         /* Next... */
10131                         continue;
10132                 }
10133
10134                 /* Ignore incorrect range */
10135                 if ((start > full) || (full > end)) continue;
10136
10137                 /* Process 'Description' */
10138                 if (buf[0] == 'D')
10139                 {
10140                         num++;
10141
10142                         /* Apply the randomizer */
10143                         if (!randint0(num)) strcpy(desc, buf + 2);
10144
10145                         /* Next... */
10146                         continue;
10147                 }
10148         }
10149
10150         /* Message */
10151         msg_print(desc);
10152
10153         /* Close the file */
10154         my_fclose(fff);
10155 }