OSDN Git Service

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