OSDN Git Service

object_desc()のコードを書き直し。u32b modeでビットフラグ OD_*
[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, OD_NAME_ONLY);
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                         /* Display as if known */
6359                         q_ptr->ident |= IDENT_STORE;
6360
6361                         /* Describe the artifact */
6362                         object_desc(base_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6363                 }
6364
6365                 /* Hack -- Build the artifact name */
6366 #ifdef JP
6367                 fprintf(fff, "     %s\n", base_name);
6368 #else
6369                 fprintf(fff, "     The %s\n", base_name);
6370 #endif
6371
6372         }
6373
6374         /* Free the "who" array */
6375         C_KILL(who, max_a_idx, s16b);
6376
6377         /* Free the "okay" array */
6378         C_KILL(okay, max_a_idx, bool);
6379
6380         /* Close the file */
6381         my_fclose(fff);
6382
6383         /* Display the file contents */
6384 #ifdef JP
6385         show_file(TRUE, file_name, "´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à", 0, 0);
6386 #else
6387         show_file(TRUE, file_name, "Artifacts Seen", 0, 0);
6388 #endif
6389
6390
6391         /* Remove the file */
6392         fd_kill(file_name);
6393 }
6394
6395
6396 /*
6397  * Display known uniques
6398  */
6399 static void do_cmd_knowledge_uniques(void)
6400 {
6401         int i, k, n = 0;
6402         u16b why = 2;
6403         s16b *who;
6404
6405         FILE *fff;
6406
6407         char file_name[1024];
6408
6409         /* Open a new file */
6410         fff = my_fopen_temp(file_name, 1024);
6411
6412         if (!fff) {
6413 #ifdef JP
6414             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6415 #else
6416             msg_format("Failed to create temporary file %s.", file_name);
6417 #endif
6418             msg_print(NULL);
6419             return;
6420         }
6421
6422         /* Allocate the "who" array */
6423         C_MAKE(who, max_r_idx, s16b);
6424
6425         /* Scan the monsters */
6426         for (i = 1; i < max_r_idx; i++)
6427         {
6428                 monster_race *r_ptr = &r_info[i];
6429
6430                 /* Use that monster */
6431                 if (r_ptr->name) who[n++] = i;
6432         }
6433
6434         /* Select the sort method */
6435         ang_sort_comp = ang_sort_comp_hook;
6436         ang_sort_swap = ang_sort_swap_hook;
6437
6438         /* Sort the array by dungeon depth of monsters */
6439         ang_sort(who, &why, n);
6440
6441         /* Scan the monster races */
6442         for (k = 0; k < n; k++)
6443         {
6444                 monster_race *r_ptr = &r_info[who[k]];
6445
6446                 /* Only print Uniques */
6447                 if (r_ptr->flags1 & (RF1_UNIQUE))
6448                 {
6449                         bool dead = (r_ptr->max_num == 0);
6450
6451                         if (dead) continue;
6452
6453                         /* Only display "known" uniques */
6454                         if (dead || cheat_know || r_ptr->r_sights)
6455                         {
6456                                 /* Print a message */
6457 #ifdef JP
6458                                 fprintf(fff, "     %s¤Ï¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¡£\n",
6459                                         (r_name + r_ptr->name));
6460 #else
6461                                 fprintf(fff, "     %s is alive\n",
6462                                         (r_name + r_ptr->name));
6463 #endif
6464
6465                         }
6466                 }
6467         }
6468
6469         /* Free the "who" array */
6470         C_KILL(who, max_r_idx, s16b);
6471
6472         /* Close the file */
6473         my_fclose(fff);
6474
6475         /* Display the file contents */
6476 #ifdef JP
6477         show_file(TRUE, file_name, "¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼", 0, 0);
6478 #else
6479         show_file(TRUE, file_name, "Alive Uniques", 0, 0);
6480 #endif
6481
6482
6483         /* Remove the file */
6484         fd_kill(file_name);
6485 }
6486
6487
6488 /*
6489  * Display weapon-exp
6490  */
6491 static void do_cmd_knowledge_weapon_exp(void)
6492 {
6493         int i, j, num, weapon_exp;
6494
6495         FILE *fff;
6496
6497         char file_name[1024];
6498         char tmp[30];
6499
6500         /* Open a new file */
6501         fff = my_fopen_temp(file_name, 1024);
6502         if (!fff) {
6503 #ifdef JP
6504             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6505 #else
6506             msg_format("Failed to create temporary file %s.", file_name);
6507 #endif
6508             msg_print(NULL);
6509             return;
6510         }
6511
6512         for (i = 0; i < 5; i++)
6513         {
6514                 for (num = 0; num < 64; num++)
6515                 {
6516                         for (j = 0; j < max_k_idx; j++)
6517                         {
6518                                 object_kind *k_ptr = &k_info[j];
6519
6520                                 if ((k_ptr->tval == TV_SWORD - i) && (k_ptr->sval == num))
6521                                 {
6522                                         if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
6523
6524                                         weapon_exp = p_ptr->weapon_exp[4 - i][num];
6525                                         strip_name(tmp, j);
6526                                         fprintf(fff, "%-25s ", tmp);
6527                                         if (weapon_exp >= s_info[p_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
6528                                         else fprintf(fff, " ");
6529                                         fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
6530                                         if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
6531                                         fprintf(fff, "\n");
6532                                         break;
6533                                 }
6534                         }
6535                 }
6536         }
6537
6538         /* Close the file */
6539         my_fclose(fff);
6540
6541         /* Display the file contents */
6542 #ifdef JP
6543         show_file(TRUE, file_name, "Éð´ï¤Î·Ð¸³ÃÍ", 0, 0);
6544 #else
6545         show_file(TRUE, file_name, "Weapon Proficiency", 0, 0);
6546 #endif
6547
6548
6549         /* Remove the file */
6550         fd_kill(file_name);
6551 }
6552
6553
6554 /*
6555  * Display spell-exp
6556  */
6557 static void do_cmd_knowledge_spell_exp(void)
6558 {
6559         int i = 0, spell_exp, exp_level;
6560
6561         FILE *fff;
6562         magic_type *s_ptr;
6563
6564         char file_name[1024];
6565
6566         /* Open a new file */
6567         fff = my_fopen_temp(file_name, 1024);
6568         if (!fff) {
6569 #ifdef JP
6570             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6571 #else
6572             msg_format("Failed to create temporary file %s.", file_name);
6573 #endif
6574             msg_print(NULL);
6575             return;
6576         }
6577
6578         if (p_ptr->realm1 != REALM_NONE)
6579         {
6580 #ifdef JP
6581                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm1]);
6582 #else
6583                 fprintf(fff, "%s Spellbook\n", realm_names[p_ptr->realm1]);
6584 #endif
6585                 for (i = 0; i < 32; i++)
6586                 {
6587                         if (!is_magic(p_ptr->realm1))
6588                         {
6589                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
6590                         }
6591                         else
6592                         {
6593                                 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
6594                         }
6595                         if (s_ptr->slevel >= 99) continue;
6596                         spell_exp = p_ptr->spell_exp[i];
6597                         exp_level = spell_exp_level(spell_exp);
6598                         fprintf(fff, "%-25s ", spell_names[technic2magic(p_ptr->realm1) - 1][i]);
6599                         if (p_ptr->realm1 == REALM_HISSATSU)
6600                                 fprintf(fff, "[--]");
6601                         else
6602                         {
6603                                 if (exp_level >= EXP_LEVEL_MASTER) fprintf(fff, "!");
6604                                 else fprintf(fff, " ");
6605                                 fprintf(fff, "%s", exp_level_str[exp_level]);
6606                         }
6607                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
6608                         fprintf(fff, "\n");
6609                 }
6610         }
6611
6612         if (p_ptr->realm2 != REALM_NONE)
6613         {
6614 #ifdef JP
6615                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm2]);
6616 #else
6617                 fprintf(fff, "\n%s Spellbook\n", realm_names[p_ptr->realm2]);
6618 #endif
6619                 for (i = 0; i < 32; i++)
6620                 {
6621                         if (!is_magic(p_ptr->realm1))
6622                         {
6623                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
6624                         }
6625                         else
6626                         {
6627                                 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][i];
6628                         }
6629                         if (s_ptr->slevel >= 99) continue;
6630
6631                         spell_exp = p_ptr->spell_exp[i + 32];
6632                         exp_level = spell_exp_level(spell_exp);
6633                         fprintf(fff, "%-25s ", spell_names[technic2magic(p_ptr->realm2) - 1][i]);
6634                         if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
6635                         else fprintf(fff, " ");
6636                         fprintf(fff, "%s", exp_level_str[exp_level]);
6637                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
6638                         fprintf(fff, "\n");
6639                 }
6640         }
6641
6642         /* Close the file */
6643         my_fclose(fff);
6644
6645         /* Display the file contents */
6646 #ifdef JP
6647         show_file(TRUE, file_name, "ËâË¡¤Î·Ð¸³ÃÍ", 0, 0);
6648 #else
6649         show_file(TRUE, file_name, "Spell Proficiency", 0, 0);
6650 #endif
6651
6652
6653         /* Remove the file */
6654         fd_kill(file_name);
6655 }
6656
6657
6658 /*
6659  * Display skill-exp
6660  */
6661 static void do_cmd_knowledge_skill_exp(void)
6662 {
6663         int i = 0, skill_exp;
6664
6665         FILE *fff;
6666
6667         char file_name[1024];
6668 #ifdef JP
6669         char skill_name[3][17]={"¥Þ¡¼¥·¥ã¥ë¥¢¡¼¥Ä", "ÆóÅáή          ", "¾èÇÏ            "};
6670 #else
6671         char skill_name[3][20]={"Martial Arts    ", "Dual Wielding   ", "Riding          "};
6672 #endif
6673
6674         /* Open a new file */
6675         fff = my_fopen_temp(file_name, 1024);
6676         if (!fff) {
6677 #ifdef JP
6678             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6679 #else
6680             msg_format("Failed to create temporary file %s.", file_name);
6681 #endif
6682             msg_print(NULL);
6683             return;
6684         }
6685
6686         for (i = 0; i < 3; i++)
6687         {
6688                 skill_exp = p_ptr->skill_exp[i];
6689                 fprintf(fff, "%-20s ", skill_name[i]);
6690                 if (skill_exp >= s_info[p_ptr->pclass].s_max[i]) fprintf(fff, "!");
6691                 else fprintf(fff, " ");
6692                 fprintf(fff, "%s", exp_level_str[(i == GINOU_RIDING) ? riding_exp_level(skill_exp) : weapon_exp_level(skill_exp)]);
6693                 if (cheat_xtra) fprintf(fff, " %d", skill_exp);
6694                 fprintf(fff, "\n");
6695         }
6696
6697         /* Close the file */
6698         my_fclose(fff);
6699
6700         /* Display the file contents */
6701 #ifdef JP
6702         show_file(TRUE, file_name, "µ»Ç½¤Î·Ð¸³ÃÍ", 0, 0);
6703 #else
6704         show_file(TRUE, file_name, "Miscellaneous Proficiency", 0, 0);
6705 #endif
6706
6707
6708         /* Remove the file */
6709         fd_kill(file_name);
6710 }
6711
6712
6713 /*
6714  * Pluralize a monster name
6715  */
6716 void plural_aux(char *Name)
6717 {
6718         int NameLen = strlen(Name);
6719
6720         if (my_strstr(Name, "Disembodied hand"))
6721         {
6722                 strcpy(Name, "Disembodied hands that strangled people");
6723         }
6724         else if (my_strstr(Name, "Colour out of space"))
6725         {
6726                 strcpy(Name, "Colours out of space");
6727         }
6728         else if (my_strstr(Name, "stairway to hell"))
6729         {
6730                 strcpy(Name, "stairways to hell");
6731         }
6732         else if (my_strstr(Name, "Dweller on the threshold"))
6733         {
6734                 strcpy(Name, "Dwellers on the threshold");
6735         }
6736         else if (my_strstr(Name, " of "))
6737         {
6738                 cptr aider = my_strstr(Name, " of ");
6739                 char dummy[80];
6740                 int i = 0;
6741                 cptr ctr = Name;
6742
6743                 while (ctr < aider)
6744                 {
6745                         dummy[i] = *ctr;
6746                         ctr++; i++;
6747                 }
6748
6749                 if (dummy[i-1] == 's')
6750                 {
6751                         strcpy(&(dummy[i]), "es");
6752                         i++;
6753                 }
6754                 else
6755                 {
6756                         strcpy(&(dummy[i]), "s");
6757                 }
6758
6759                 strcpy(&(dummy[i+1]), aider);
6760                 strcpy(Name, dummy);
6761         }
6762         else if (my_strstr(Name, "coins"))
6763         {
6764                 char dummy[80];
6765                 strcpy(dummy, "piles of ");
6766                 strcat(dummy, Name);
6767                 strcpy(Name, dummy);
6768                 return;
6769         }
6770         else if (my_strstr(Name, "Manes"))
6771         {
6772                 return;
6773         }
6774         else if (streq(&(Name[NameLen - 2]), "ey"))
6775         {
6776                 strcpy(&(Name[NameLen - 2]), "eys");
6777         }
6778         else if (Name[NameLen - 1] == 'y')
6779         {
6780                 strcpy(&(Name[NameLen - 1]), "ies");
6781         }
6782         else if (streq(&(Name[NameLen - 4]), "ouse"))
6783         {
6784                 strcpy(&(Name[NameLen - 4]), "ice");
6785         }
6786         else if (streq(&(Name[NameLen - 2]), "us"))
6787         {
6788                 strcpy(&(Name[NameLen - 2]), "i");
6789         }
6790         else if (streq(&(Name[NameLen - 6]), "kelman"))
6791         {
6792                 strcpy(&(Name[NameLen - 6]), "kelmen");
6793         }
6794         else if (streq(&(Name[NameLen - 8]), "wordsman"))
6795         {
6796                 strcpy(&(Name[NameLen - 8]), "wordsmen");
6797         }
6798         else if (streq(&(Name[NameLen - 7]), "oodsman"))
6799         {
6800                 strcpy(&(Name[NameLen - 7]), "oodsmen");
6801         }
6802         else if (streq(&(Name[NameLen - 7]), "eastman"))
6803         {
6804                 strcpy(&(Name[NameLen - 7]), "eastmen");
6805         }
6806         else if (streq(&(Name[NameLen - 8]), "izardman"))
6807         {
6808                 strcpy(&(Name[NameLen - 8]), "izardmen");
6809         }
6810         else if (streq(&(Name[NameLen - 5]), "geist"))
6811         {
6812                 strcpy(&(Name[NameLen - 5]), "geister");
6813         }
6814         else if (streq(&(Name[NameLen - 2]), "ex"))
6815         {
6816                 strcpy(&(Name[NameLen - 2]), "ices");
6817         }
6818         else if (streq(&(Name[NameLen - 2]), "lf"))
6819         {
6820                 strcpy(&(Name[NameLen - 2]), "lves");
6821         }
6822         else if (suffix(Name, "ch") ||
6823                  suffix(Name, "sh") ||
6824                          suffix(Name, "nx") ||
6825                          suffix(Name, "s") ||
6826                          suffix(Name, "o"))
6827         {
6828                 strcpy(&(Name[NameLen]), "es");
6829         }
6830         else
6831         {
6832                 strcpy(&(Name[NameLen]), "s");
6833         }
6834 }
6835
6836 /*
6837  * Display current pets
6838  */
6839 static void do_cmd_knowledge_pets(void)
6840 {
6841         int             i;
6842         FILE            *fff;
6843         monster_type    *m_ptr;
6844         char            pet_name[80];
6845         int             t_friends = 0;
6846         int             show_upkeep = 0;
6847         char            file_name[1024];
6848
6849
6850         /* Open a new file */
6851         fff = my_fopen_temp(file_name, 1024);
6852         if (!fff) {
6853 #ifdef JP
6854             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6855 #else
6856             msg_format("Failed to create temporary file %s.", file_name);
6857 #endif
6858             msg_print(NULL);
6859             return;
6860         }
6861
6862         /* Process the monsters (backwards) */
6863         for (i = m_max - 1; i >= 1; i--)
6864         {
6865                 /* Access the monster */
6866                 m_ptr = &m_list[i];
6867
6868                 /* Ignore "dead" monsters */
6869                 if (!m_ptr->r_idx) continue;
6870
6871                 /* Calculate "upkeep" for pets */
6872                 if (is_pet(m_ptr))
6873                 {
6874                         t_friends++;
6875                         monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
6876                         fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
6877                 }
6878         }
6879
6880         show_upkeep = calculate_upkeep();
6881
6882         fprintf(fff, "----------------------------------------------\n");
6883 #ifdef JP
6884         fprintf(fff, "    ¹ç·×: %d É¤¤Î¥Ú¥Ã¥È\n", t_friends);
6885         fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
6886 #else
6887         fprintf(fff, "   Total: %d pet%s.\n",
6888                 t_friends, (t_friends == 1 ? "" : "s"));
6889         fprintf(fff, "   Upkeep: %d%% mana.\n", show_upkeep);
6890 #endif
6891
6892
6893
6894         /* Close the file */
6895         my_fclose(fff);
6896
6897         /* Display the file contents */
6898 #ifdef JP
6899         show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
6900 #else
6901         show_file(TRUE, file_name, "Current Pets", 0, 0);
6902 #endif
6903
6904
6905         /* Remove the file */
6906         fd_kill(file_name);
6907 }
6908
6909
6910 /*
6911  * Total kill count
6912  *
6913  * Note that the player ghosts are ignored.  XXX XXX XXX
6914  */
6915 static void do_cmd_knowledge_kill_count(void)
6916 {
6917         int i, k, n = 0;
6918         u16b why = 2;
6919         s16b *who;
6920
6921         FILE *fff;
6922
6923         char file_name[1024];
6924
6925         s32b Total = 0;
6926
6927
6928         /* Open a new file */
6929         fff = my_fopen_temp(file_name, 1024);
6930
6931         if (!fff) {
6932 #ifdef JP
6933             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6934 #else
6935             msg_format("Failed to create temporary file %s.", file_name);
6936 #endif
6937             msg_print(NULL);
6938             return;
6939         }
6940
6941         /* Allocate the "who" array */
6942         C_MAKE(who, max_r_idx, s16b);
6943
6944         {
6945                 /* Monsters slain */
6946                 int kk;
6947
6948                 for (kk = 1; kk < max_r_idx; kk++)
6949                 {
6950                         monster_race *r_ptr = &r_info[kk];
6951
6952                         if (r_ptr->flags1 & (RF1_UNIQUE))
6953                         {
6954                                 bool dead = (r_ptr->max_num == 0);
6955
6956                                 if (dead)
6957                                 {
6958                                         Total++;
6959                                 }
6960                         }
6961                         else
6962                         {
6963                                 s16b This = r_ptr->r_pkills;
6964
6965                                 if (This > 0)
6966                                 {
6967                                         Total += This;
6968                                 }
6969                         }
6970                 }
6971
6972                 if (Total < 1)
6973 #ifdef JP
6974                         fprintf(fff,"¤¢¤Ê¤¿¤Ï¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Ê¤¤¡£\n\n");
6975 #else
6976                         fprintf(fff,"You have defeated no enemies yet.\n\n");
6977 #endif
6978
6979                 else if (Total == 1)
6980 #ifdef JP
6981                         fprintf(fff,"¤¢¤Ê¤¿¤Ï°ìɤ¤ÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n");
6982 #else
6983                         fprintf(fff,"You have defeated one enemy.\n\n");
6984 #endif
6985
6986                 else
6987 #ifdef JP
6988                         fprintf(fff,"¤¢¤Ê¤¿¤Ï %lu É¤¤ÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", Total);
6989 #else
6990                         fprintf(fff,"You have defeated %lu enemies.\n\n", Total);
6991 #endif
6992
6993         }
6994
6995         Total = 0;
6996
6997         /* Scan the monsters */
6998         for (i = 1; i < max_r_idx; i++)
6999         {
7000                 monster_race *r_ptr = &r_info[i];
7001
7002                 /* Use that monster */
7003                 if (r_ptr->name) who[n++] = i;
7004         }
7005
7006         /* Select the sort method */
7007         ang_sort_comp = ang_sort_comp_hook;
7008         ang_sort_swap = ang_sort_swap_hook;
7009
7010         /* Sort the array by dungeon depth of monsters */
7011         ang_sort(who, &why, n);
7012
7013         /* Scan the monster races */
7014         for (k = 0; k < n; k++)
7015         {
7016                 monster_race *r_ptr = &r_info[who[k]];
7017
7018                 if (r_ptr->flags1 & (RF1_UNIQUE))
7019                 {
7020                         bool dead = (r_ptr->max_num == 0);
7021
7022                         if (dead)
7023                         {
7024                                 /* Print a message */
7025                                 fprintf(fff, "     %s\n",
7026                                     (r_name + r_ptr->name));
7027                                 Total++;
7028                         }
7029                 }
7030                 else
7031                 {
7032                         s16b This = r_ptr->r_pkills;
7033
7034                         if (This > 0)
7035                         {
7036 #ifdef JP
7037                                 /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita*/
7038                                 if(my_strchr("pt",r_ptr->d_char))
7039                                         fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
7040                                 else
7041                                         fprintf(fff, "     %3d É¤¤Î %s\n", This, r_name + r_ptr->name);
7042 #else
7043                                 if (This < 2)
7044                                 {
7045                                         if (my_strstr(r_name + r_ptr->name, "coins"))
7046                                         {
7047                                                 fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
7048                                         }
7049                                         else
7050                                         {
7051                                                 fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
7052                                         }
7053                                 }
7054                                 else
7055                                 {
7056                                         char ToPlural[80];
7057                                         strcpy(ToPlural, (r_name + r_ptr->name));
7058                                         plural_aux(ToPlural);
7059                                         fprintf(fff, "     %d %s\n", This, ToPlural);
7060                                 }
7061 #endif
7062
7063
7064                                 Total += This;
7065                         }
7066                 }
7067         }
7068
7069         fprintf(fff,"----------------------------------------------\n");
7070 #ifdef JP
7071         fprintf(fff,"    ¹ç·×: %lu É¤¤òÅݤ·¤¿¡£\n", Total);
7072 #else
7073         fprintf(fff,"   Total: %lu creature%s killed.\n",
7074                 Total, (Total == 1 ? "" : "s"));
7075 #endif
7076
7077
7078         /* Free the "who" array */
7079         C_KILL(who, max_r_idx, s16b);
7080
7081         /* Close the file */
7082         my_fclose(fff);
7083
7084         /* Display the file contents */
7085 #ifdef JP
7086         show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
7087 #else
7088         show_file(TRUE, file_name, "Kill Count", 0, 0);
7089 #endif
7090
7091
7092         /* Remove the file */
7093         fd_kill(file_name);
7094 }
7095
7096
7097 /*
7098  * Display the object groups.
7099  */
7100 static void display_group_list(int col, int row, int wid, int per_page,
7101         int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
7102 {
7103         int i;
7104
7105         /* Display lines until done */
7106         for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
7107         {
7108                 /* Get the group index */
7109                 int grp = grp_idx[grp_top + i];
7110
7111                 /* Choose a color */
7112                 byte attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
7113
7114                 /* Erase the entire line */
7115                 Term_erase(col, row + i, wid);
7116
7117                 /* Display the group label */
7118                 c_put_str(attr, group_text[grp], row + i, col);
7119         }
7120 }
7121
7122
7123 /* 
7124  * Move the cursor in a browser window 
7125  */
7126 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt, 
7127                                                    int *list_cur, int list_cnt)
7128 {
7129         int d;
7130         int col = *column;
7131         int grp = *grp_cur;
7132         int list = *list_cur;
7133
7134         /* Extract direction */
7135         if (ch == ' ')
7136         {
7137                 /* Hack -- scroll up full screen */
7138                 d = 3;
7139         }
7140         else if (ch == '-')
7141         {
7142                 /* Hack -- scroll down full screen */
7143                 d = 9;
7144         }
7145         else
7146         {
7147                 d = get_keymap_dir(ch);
7148         }
7149
7150         if (!d) return;
7151
7152         /* Diagonals - hack */
7153         if ((ddx[d] > 0) && ddy[d])
7154         {
7155                 int browser_rows;
7156                 int wid, hgt;
7157
7158                 /* Get size */
7159                 Term_get_size(&wid, &hgt);
7160
7161                 browser_rows = hgt - 8;
7162
7163                 /* Browse group list */
7164                 if (!col)
7165                 {
7166                         int old_grp = grp;
7167
7168                         /* Move up or down */
7169                         grp += ddy[d] * (browser_rows - 1);
7170
7171                         /* Verify */
7172                         if (grp >= grp_cnt)     grp = grp_cnt - 1;
7173                         if (grp < 0) grp = 0;
7174                         if (grp != old_grp)     list = 0;
7175                 }
7176
7177                 /* Browse sub-list list */
7178                 else
7179                 {
7180                         /* Move up or down */
7181                         list += ddy[d] * browser_rows;
7182
7183                         /* Verify */
7184                         if (list >= list_cnt) list = list_cnt - 1;
7185                         if (list < 0) list = 0;
7186                 }
7187
7188                 (*grp_cur) = grp;
7189                 (*list_cur) = list;
7190
7191                 return;
7192         }
7193
7194         if (ddx[d])
7195         {
7196                 col += ddx[d];
7197                 if (col < 0) col = 0;
7198                 if (col > 1) col = 1;
7199
7200                 (*column) = col;
7201
7202                 return;
7203         }
7204
7205         /* Browse group list */
7206         if (!col)
7207         {
7208                 int old_grp = grp;
7209
7210                 /* Move up or down */
7211                 grp += ddy[d];
7212
7213                 /* Verify */
7214                 if (grp >= grp_cnt)     grp = grp_cnt - 1;
7215                 if (grp < 0) grp = 0;
7216                 if (grp != old_grp)     list = 0;
7217         }
7218
7219         /* Browse sub-list list */
7220         else
7221         {
7222                 /* Move up or down */
7223                 list += ddy[d];
7224
7225                 /* Verify */
7226                 if (list >= list_cnt) list = list_cnt - 1;
7227                 if (list < 0) list = 0;
7228         }
7229
7230         (*grp_cur) = grp;
7231         (*list_cur) = list;
7232 }
7233
7234
7235 /*
7236  * Display visuals.
7237  */
7238 static void display_visual_list(int col, int row, int height, int width, byte attr_top, byte char_left)
7239 {
7240         int i, j;
7241
7242         /* Clear the display lines */
7243         for (i = 0; i < height; i++)
7244         {
7245                 Term_erase(col, row + i, width);
7246         }
7247
7248         /* Bigtile mode uses double width */
7249         if (use_bigtile) width /= 2;
7250
7251         /* Display lines until done */
7252         for (i = 0; i < height; i++)
7253         {
7254                 /* Display columns until done */
7255                 for (j = 0; j < width; j++)
7256                 {
7257                         byte a;
7258                         char c;
7259                         int x = col + j;
7260                         int y = row + i;
7261                         int ia, ic;
7262
7263                         /* Bigtile mode uses double width */
7264                         if (use_bigtile) x += j;
7265
7266                         ia = attr_top + i;
7267                         ic = char_left + j;
7268
7269                         /* Ignore illegal characters */
7270                         if (ia > 0x7f || ic > 0xff || ic < ' ' ||
7271                             (!use_graphics && ic > 0x7f))
7272                                 continue;
7273
7274                         a = (byte)ia;
7275                         c = (char)ic;
7276
7277                         /* Force correct code for both ASCII character and tile */
7278                         if (c & 0x80) a |= 0x80;
7279
7280                         /* Display symbol */
7281                         Term_queue_bigchar(x, y, a, c, 0, 0);
7282                 }
7283         }
7284 }
7285
7286
7287 /*
7288  * Place the cursor at the collect position for visual mode
7289  */
7290 static void place_visual_list_cursor(int col, int row, byte a, byte c, byte attr_top, byte char_left)
7291 {
7292         int i = (a & 0x7f) - attr_top;
7293         int j = c - char_left;
7294
7295         int x = col + j;
7296         int y = row + i;
7297
7298         /* Bigtile mode uses double width */
7299         if (use_bigtile) x += j;
7300
7301         /* Place the cursor */
7302         Term_gotoxy(x, y);
7303 }
7304
7305
7306 /*
7307  *  Clipboard variables for copy&paste in visual mode
7308  */
7309 static byte attr_idx = 0;
7310 static byte char_idx = 0;
7311
7312 /*
7313  *  Do visual mode command -- Change symbols
7314  */
7315 static bool visual_mode_command(char ch, bool *visual_list_ptr, 
7316                                 int height, int width, 
7317                                 byte *attr_top_ptr, byte *char_left_ptr, 
7318                                 byte *cur_attr_ptr, byte *cur_char_ptr)
7319 {
7320         static byte attr_old = 0, char_old = 0;
7321
7322         switch (ch)
7323         {
7324         case ESCAPE:
7325                 if (*visual_list_ptr)
7326                 {
7327                         /* Cancel change */
7328                         *cur_attr_ptr = attr_old;
7329                         *cur_char_ptr = char_old;
7330                         *visual_list_ptr = FALSE;
7331
7332                         return TRUE;
7333                 }
7334
7335                 break;
7336
7337         case '\n':
7338         case '\r':
7339                 if (*visual_list_ptr)
7340                 {
7341                         /* Accept change */
7342                         *visual_list_ptr = FALSE;
7343
7344                         return TRUE;
7345                 }
7346                 break;
7347
7348         case 'V':
7349         case 'v':
7350                 if (!*visual_list_ptr)
7351                 {
7352                         *visual_list_ptr = TRUE;
7353
7354                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7355                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7356
7357                         attr_old = *cur_attr_ptr;
7358                         char_old = *cur_char_ptr;
7359
7360                         return TRUE;
7361                 }
7362                 break;
7363
7364         case 'C':
7365         case 'c':
7366                 /* Set the visual */
7367                 attr_idx = *cur_attr_ptr;
7368                 char_idx = *cur_char_ptr;
7369
7370                 return TRUE;
7371
7372         case 'P':
7373         case 'p':
7374                 if (attr_idx)
7375                 {
7376                         /* Set the char */
7377                         *cur_attr_ptr = attr_idx;
7378                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7379                 }
7380
7381                 if (char_idx)
7382                 {
7383                         /* Set the char */
7384                         *cur_char_ptr = char_idx;
7385                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7386                 }
7387
7388                 return TRUE;
7389
7390         default:
7391                 if (*visual_list_ptr)
7392                 {
7393                         int eff_width;
7394                         int d = get_keymap_dir(ch);
7395                         byte a = (*cur_attr_ptr & 0x7f);
7396                         byte c = *cur_char_ptr;
7397
7398                         if (use_bigtile) eff_width = width / 2;
7399                         else eff_width = width;
7400                                         
7401                         /* Restrict direction */
7402                         if ((a == 0) && (ddy[d] < 0)) d = 0;
7403                         if ((c == 0) && (ddx[d] < 0)) d = 0;
7404                         if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
7405                         if ((c == 0xff) && (ddx[d] > 0)) d = 0;
7406
7407                         a += ddy[d];
7408                         c += ddx[d];
7409
7410                         /* Force correct code for both ASCII character and tile */
7411                         if (c & 0x80) a |= 0x80;
7412
7413                         /* Set the visual */
7414                         *cur_attr_ptr = a;
7415                         *cur_char_ptr = c;
7416
7417
7418                         /* Move the frame */
7419                         if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
7420                         if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
7421                         if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
7422                         if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
7423                         return TRUE;
7424                 }
7425                                 
7426                 break;
7427         }
7428
7429         /* Visual mode command is not used */
7430         return FALSE;
7431 }
7432
7433
7434 /*
7435  * Display the monsters in a group.
7436  */
7437 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
7438         int mon_cur, int mon_top)
7439 {
7440         int i;
7441
7442         /* Display lines until done */
7443         for (i = 0; i < per_page && mon_idx[mon_top + i]; i++)
7444         {
7445                 byte attr;
7446
7447                 /* Get the race index */
7448                 int r_idx = mon_idx[mon_top + i] ;
7449
7450                 /* Access the race */
7451                 monster_race *r_ptr = &r_info[r_idx];
7452
7453
7454                 /* Choose a color */
7455                 attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
7456
7457                 /* Display the name */
7458                 c_prt(attr, (r_name + r_ptr->name), row + i, col);
7459
7460                 /* Hack -- visual_list mode */
7461                 if (per_page == 1)
7462                 {
7463                         c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, 60);
7464                 }
7465                 else if (p_ptr->wizard) 
7466                 {
7467                         c_prt(attr, format("%d", r_idx), row + i, 60);
7468                 }
7469
7470                 /* Display symbol */
7471                 Term_queue_bigchar(70, row + i, r_ptr->x_attr, r_ptr->x_char, 0, 0);
7472
7473
7474                 /* Display kills */
7475                 if (!(r_ptr->flags1 & RF1_UNIQUE)) put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
7476 #ifdef JP
7477                 else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "»àË´" : "À¸Â¸"), row + i, 73);
7478 #else
7479                 else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "dead" : "alive"), row + i, 73);
7480 #endif
7481         
7482         }
7483
7484         /* Clear remaining lines */
7485         for (; i < per_page; i++)
7486         {
7487                 Term_erase(col, row + i, 255);
7488         }
7489 }
7490
7491
7492 /*
7493  * Display known monsters.
7494  */
7495 static void do_cmd_knowledge_monsters(void)
7496 {
7497         int i, len, max;
7498         int grp_cur, grp_top, old_grp_cur;
7499         int mon_cur, mon_top;
7500         int grp_cnt, grp_idx[100];
7501         int mon_cnt;
7502         s16b *mon_idx;
7503         
7504         int column = 0;
7505         bool flag;
7506         bool redraw;
7507
7508         bool visual_list = FALSE;
7509         byte attr_top = 0, char_left = 0;
7510
7511         int browser_rows;
7512         int wid, hgt;
7513
7514         /* Get size */
7515         Term_get_size(&wid, &hgt);
7516
7517         browser_rows = hgt - 8;
7518
7519         /* Allocate the "mon_idx" array */
7520         C_MAKE(mon_idx, max_r_idx, s16b);
7521
7522         max = 0;
7523         grp_cnt = 0;
7524
7525         /* Check every group */
7526         for (i = 0; monster_group_text[i] != NULL; i++)
7527         {
7528                 /* Measure the label */
7529                 len = strlen(monster_group_text[i]);
7530
7531                 /* Save the maximum length */
7532                 if (len > max) max = len;
7533
7534                 /* See if any monsters are known */
7535                 if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, 0x01))
7536                 {
7537                         /* Build a list of groups with known monsters */
7538                         grp_idx[grp_cnt++] = i;
7539                 }
7540         }
7541
7542         /* Terminate the list */
7543         grp_idx[grp_cnt] = -1;
7544
7545         old_grp_cur = -1;
7546         grp_cur = grp_top = 0;
7547         mon_cur = mon_top = 0;
7548         mon_cnt = 0;
7549
7550         flag = FALSE;
7551         redraw = TRUE;
7552
7553         while (!flag)
7554         {
7555                 char ch;
7556                 monster_race *r_ptr;
7557
7558                 if (redraw)
7559                 {
7560                         clear_from(0);
7561                 
7562 #ifdef JP
7563                         prt("Ãμ± - ¥â¥ó¥¹¥¿¡¼", 2, 0);
7564                         prt("¥°¥ë¡¼¥×", 4, 0);
7565                         prt("̾Á°", 4, max + 3);
7566                         if (p_ptr->wizard) prt("Idx", 4, 60);
7567                         prt("ʸ»ú »¦³²¿ô", 4, 67);
7568 #else
7569                         prt("Knowledge - Monsters", 2, 0);
7570                         prt("Group", 4, 0);
7571                         prt("Name", 4, max + 3);
7572                         if (p_ptr->wizard) prt("Idx", 4, 60);
7573                         prt("Sym   Kills", 4, 67);
7574 #endif
7575
7576                         for (i = 0; i < 78; i++)
7577                         {
7578                                 Term_putch(i, 5, TERM_WHITE, '=');
7579                         }
7580
7581                         for (i = 0; i < browser_rows; i++)
7582                         {
7583                                 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
7584                         }
7585
7586                         redraw = FALSE;
7587                 }
7588
7589                 /* Scroll group list */
7590                 if (grp_cur < grp_top) grp_top = grp_cur;
7591                 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
7592
7593                 /* Display a list of monster groups */
7594                 display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
7595
7596                 if (old_grp_cur != grp_cur)
7597                 {
7598                         old_grp_cur = grp_cur;
7599
7600                         /* Get a list of monsters in the current group */
7601                         mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, 0x00);
7602                 }
7603
7604                 /* Scroll monster list */
7605                 while (mon_cur < mon_top)
7606                         mon_top = MAX(0, mon_top - browser_rows/2);
7607                 while (mon_cur >= mon_top + browser_rows)
7608                         mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows/2);
7609
7610                 if (!visual_list)
7611                 {
7612                         /* Display a list of monsters in the current group */
7613                         display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top);
7614                 }
7615                 else
7616                 {
7617                         mon_top = mon_cur;
7618
7619                         /* Display a monster name */
7620                         display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top);
7621
7622                         /* Display visual list below first monster */
7623                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
7624                 }
7625
7626                 /* Prompt */
7627 #ifdef JP
7628                 prt(format("<Êý¸þ>, 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë%s%s, ESC", visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
7629 #else
7630                 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);
7631 #endif
7632
7633                 /* Get the current monster */
7634                 r_ptr = &r_info[mon_idx[mon_cur]];
7635
7636                 /* Mega Hack -- track this monster race */
7637                 if (mon_cnt) monster_race_track(mon_idx[mon_cur]);
7638
7639                 /* Hack -- handle stuff */
7640                 handle_stuff();
7641
7642                 if (visual_list)
7643                 {
7644                         place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
7645                 }
7646                 else if (!column)
7647                 {
7648                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
7649                 }
7650                 else
7651                 {
7652                         Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
7653                 }
7654         
7655                 ch = inkey();
7656
7657                 /* Do visual mode command if needed */
7658                 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;
7659
7660                 switch (ch)
7661                 {
7662                         case ESCAPE:
7663                         {
7664                                 flag = TRUE;
7665                                 break;
7666                         }
7667
7668                         case 'R':
7669                         case 'r':
7670                         {
7671                                 /* Recall on screen */
7672                                 if (mon_idx[mon_cur])
7673                                 {
7674                                         screen_roff(mon_idx[mon_cur], 0);
7675
7676                                         (void)inkey();
7677         
7678                                         redraw = TRUE;
7679                                 }
7680                                 break;
7681                         }
7682
7683                         default:
7684                         {
7685                                 /* Move the cursor */
7686                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
7687
7688                                 break;
7689                         }
7690                 }
7691         }
7692
7693         /* Free the "mon_idx" array */
7694         C_KILL(mon_idx, max_r_idx, s16b);
7695 }
7696
7697
7698 /*
7699  * Display the objects in a group.
7700  */
7701 static void display_object_list(int col, int row, int per_page, int object_idx[],
7702         int object_cur, int object_top)
7703 {
7704         int i;
7705
7706         /* Display lines until done */
7707         for (i = 0; i < per_page && object_idx[object_top + i]; i++)
7708         {
7709                 char o_name[80];
7710                 byte a, c;
7711
7712                 /* Get the object index */
7713                 int k_idx = object_idx[object_top + i];
7714
7715                 /* Access the object */
7716                 object_kind *k_ptr = &k_info[k_idx];
7717
7718                 /* Choose a color */
7719                 byte attr = (k_ptr->aware ? TERM_WHITE : TERM_SLATE);
7720                 byte cursor = (k_ptr->aware ? TERM_L_BLUE : TERM_BLUE);
7721
7722                 attr = ((i + object_top == object_cur) ? cursor : attr);
7723                 
7724                 /* Tidy name */
7725                 strip_name(o_name, k_idx);
7726
7727                 /* Display the name */
7728                 c_prt(attr, o_name, row + i, col);
7729
7730                 /* Hack -- visual_list mode */
7731                 if (per_page == 1)
7732                 {
7733                         c_prt(attr, format("%02x/%02x", k_ptr->x_attr, k_ptr->x_char), row + i, 60);
7734                 }
7735                 else if (p_ptr->wizard)
7736                 {
7737                         c_prt(attr, format ("%d", k_idx), row + i, 70);
7738                 }
7739
7740                 a = k_ptr->flavor ? misc_to_attr[k_ptr->flavor] : k_ptr->x_attr;
7741                 c = k_ptr->flavor ? misc_to_char[k_ptr->flavor] : k_ptr->x_char;
7742
7743                 /* Symbol is unknown */ 
7744                 if (!k_ptr->aware && !p_ptr->wizard)
7745                 {
7746                         c = ' ';
7747                         a = TERM_DARK;
7748                 }
7749
7750                 /* Display symbol */
7751                 Term_queue_bigchar(76, row + i, a, c, 0, 0);
7752         }
7753
7754         /* Clear remaining lines */
7755         for (; i < per_page; i++)
7756         {
7757                 Term_erase(col, row + i, 255);
7758         }
7759 }
7760
7761 /*
7762  * Describe fake object
7763  */
7764 static void desc_obj_fake(int k_idx)
7765 {
7766         object_type *o_ptr;
7767         object_type object_type_body;
7768
7769         /* Get local object */
7770         o_ptr = &object_type_body;
7771
7772         /* Wipe the object */
7773         object_wipe(o_ptr);
7774
7775         /* Create the artifact */
7776         object_prep(o_ptr, k_idx);
7777
7778         /* It's fully know */
7779         o_ptr->ident |= IDENT_KNOWN;
7780
7781         /* Track the object */
7782         /* object_actual_track(o_ptr); */
7783
7784         /* Hack - mark as fake */
7785         /* term_obj_real = FALSE; */
7786
7787         /* Hack -- Handle stuff */
7788         handle_stuff();
7789
7790         if (!screen_object(o_ptr, FALSE))
7791         {
7792 #ifdef JP
7793                 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
7794 #else
7795                 msg_print("You see nothing special.");
7796 #endif
7797                 msg_print(NULL);
7798         }
7799 }
7800
7801
7802
7803 /*
7804  * Display known objects
7805  */
7806 static void do_cmd_knowledge_objects(void)
7807 {
7808         int i, len, max;
7809         int grp_cur, grp_top, old_grp_cur;
7810         int object_old, object_cur, object_top;
7811         int grp_cnt, grp_idx[100];
7812         int object_cnt;
7813         int *object_idx;
7814
7815         int column = 0;
7816         bool flag;
7817         bool redraw;
7818
7819         bool visual_list = FALSE;
7820         byte attr_top = 0, char_left = 0;
7821
7822         int browser_rows;
7823         int wid, hgt;
7824
7825         /* Get size */
7826         Term_get_size(&wid, &hgt);
7827
7828         browser_rows = hgt - 8;
7829
7830         /* Allocate the "object_idx" array */
7831         C_MAKE(object_idx, max_k_idx, int);
7832
7833         max = 0;
7834         grp_cnt = 0;
7835
7836         /* Check every group */
7837         for (i = 0; object_group_text[i] != NULL; i++)
7838         {
7839                 /* Measure the label */
7840                 len = strlen(object_group_text[i]);
7841
7842                 /* Save the maximum length */
7843                 if (len > max) max = len;
7844
7845                 /* See if any monsters are known */
7846                 if (collect_objects(i, object_idx))
7847                 {
7848                         /* Build a list of groups with known monsters */
7849                         grp_idx[grp_cnt++] = i;
7850                 }
7851         }
7852
7853         /* Terminate the list */
7854         grp_idx[grp_cnt] = -1;
7855
7856         old_grp_cur = -1;
7857         grp_cur = grp_top = 0;
7858         object_cur = object_top = 0;
7859         object_old = -1;
7860         object_cnt = 0;
7861
7862         flag = FALSE;
7863         redraw = TRUE;
7864
7865         while (!flag)
7866         {
7867                 char ch;
7868                 object_kind *k_ptr;
7869
7870                 if (redraw)
7871                 {
7872                         clear_from(0);
7873                 
7874 #ifdef JP
7875                         prt("Ãμ± - ¥¢¥¤¥Æ¥à", 2, 0);
7876                         prt("¥°¥ë¡¼¥×", 4, 0);
7877                         prt("̾Á°", 4, max + 3);
7878                         if (p_ptr->wizard) prt("Idx", 4, 70);
7879                         prt("ʸ»ú", 4, 75);
7880 #else
7881                         prt("Knowledge - objects", 2, 0);
7882                         prt("Group", 4, 0);
7883                         prt("Name", 4, max + 3);
7884                         if (p_ptr->wizard) prt("Idx", 4, 70);
7885                         prt("Sym", 4, 75);
7886 #endif
7887
7888                         for (i = 0; i < 78; i++)
7889                         {
7890                                 Term_putch(i, 5, TERM_WHITE, '=');
7891                         }
7892
7893                         for (i = 0; i < browser_rows; i++)
7894                         {
7895                                 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
7896                         }
7897
7898                         redraw = FALSE;
7899                 }
7900
7901                 /* Scroll group list */
7902                 if (grp_cur < grp_top) grp_top = grp_cur;
7903                 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
7904
7905                 /* Display a list of object groups */
7906                 display_group_list(0, 6, max, browser_rows, grp_idx, object_group_text, grp_cur, grp_top);
7907
7908                 if (old_grp_cur != grp_cur)
7909                 {
7910                         old_grp_cur = grp_cur;
7911
7912                         /* Get a list of objects in the current group */
7913                         object_cnt = collect_objects(grp_idx[grp_cur], object_idx);
7914                 }
7915
7916                 /* Scroll object list */
7917                 while (object_cur < object_top)
7918                         object_top = MAX(0, object_top - browser_rows/2);
7919                 while (object_cur >= object_top + browser_rows)
7920                         object_top = MIN(object_cnt - browser_rows, object_top + browser_rows/2);
7921
7922                 if (!visual_list)
7923                 {
7924                         /* Display a list of objects in the current group */
7925                         display_object_list(max + 3, 6, browser_rows, object_idx, object_cur, object_top);
7926                 }
7927                 else
7928                 {
7929                         object_top = object_cur;
7930
7931                         /* Display a list of objects in the current group */
7932                         display_object_list(max + 3, 6, 1, object_idx, object_cur, object_top);
7933
7934                         /* Display visual list below first object */
7935                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
7936                 }
7937
7938                 /* Get the current object */
7939                 k_ptr = &k_info[object_idx[object_cur]];
7940
7941                 /* Mega Hack -- track this object */
7942                 if (object_cnt) object_kind_track(object_idx[object_cur]);
7943
7944                 /* Prompt */
7945 #ifdef JP
7946                 prt(format("<Êý¸þ>, 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë%s%s, ESC", k_ptr->flavor ? "" : visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
7947 #else
7948                 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);
7949 #endif
7950
7951                 /* The "current" object changed */
7952                 if (object_old != object_idx[object_cur])
7953                 {
7954                         /* Hack -- handle stuff */
7955                         handle_stuff();
7956
7957                         /* Remember the "current" object */
7958                         object_old = object_idx[object_cur];
7959                 }
7960
7961                 if (visual_list)
7962                 {
7963                         place_visual_list_cursor(max + 3, 7, k_ptr->x_attr, k_ptr->x_char, attr_top, char_left);
7964                 }
7965                 else if (!column)
7966                 {
7967                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
7968                 }
7969                 else
7970                 {
7971                         Term_gotoxy(max + 3, 6 + (object_cur - object_top));
7972                 }
7973         
7974                 ch = inkey();
7975
7976                 /* Do visual mode command if needed */
7977                 /* Symbol of objects with flavor cannot be changed */
7978                 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;
7979
7980                 switch (ch)
7981                 {
7982                         case ESCAPE:
7983                         {
7984                                 flag = TRUE;
7985                                 break;
7986                         }
7987
7988                         case 'R':
7989                         case 'r':
7990                         {
7991                                 /* Recall on screen */
7992                                 if (grp_cnt > 0)
7993                                         desc_obj_fake(object_idx[object_cur]);
7994
7995                                 redraw = TRUE;
7996                                 break;
7997                         }
7998
7999                         default:
8000                         {
8001                                 /* Move the cursor */
8002                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &object_cur, object_cnt);
8003                                 break;
8004                         }
8005                 }
8006         }
8007
8008         /* Free the "object_idx" array */
8009         C_KILL(object_idx, max_k_idx, int);
8010 }
8011
8012
8013
8014 /*
8015  * Display the features in a group.
8016  */
8017 static void display_feature_list(int col, int row, int per_page, int *feat_idx,
8018         int feat_cur, int feat_top)
8019 {
8020         int i;
8021
8022         /* Display lines until done */
8023         for (i = 0; i < per_page && feat_idx[feat_top + i]; i++)
8024         {
8025                 byte attr;
8026
8027                 /* Get the index */
8028                 int f_idx = feat_idx[feat_top + i];
8029
8030                 /* Access the index */
8031                 feature_type *f_ptr = &f_info[f_idx];
8032
8033                 /* Choose a color */
8034                 attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
8035
8036                 /* Display the name */
8037                 c_prt(attr, f_name + f_ptr->name, row + i, col);
8038
8039                 /* Hack -- visual_list mode */
8040                 if (per_page == 1)
8041                 {
8042                         c_prt(attr, format("%02x/%02x", f_ptr->x_attr, f_ptr->x_char), row + i, 60);
8043                 }
8044
8045                 /* Display symbol */
8046                 Term_queue_bigchar(68, row + i, f_ptr->x_attr, f_ptr->x_char, 0, 0);
8047         }
8048
8049         /* Clear remaining lines */
8050         for (; i < per_page; i++)
8051         {
8052                 Term_erase(col, row + i, 255);
8053         }
8054 }
8055
8056
8057 /*
8058  * Interact with feature visuals.
8059  */
8060 static void do_cmd_knowledge_features(void)
8061 {
8062         int i, len, max;
8063         int grp_cur, grp_top, old_grp_cur;
8064         int feat_cur, feat_top;
8065         int grp_cnt, grp_idx[100];
8066         int feat_cnt;
8067         int *feat_idx;
8068         
8069         int column = 0;
8070         bool flag;
8071         bool redraw;
8072
8073         bool visual_list = FALSE;
8074         byte attr_top = 0, char_left = 0;
8075
8076         int browser_rows;
8077         int wid, hgt;
8078
8079         /* Get size */
8080         Term_get_size(&wid, &hgt);
8081
8082         browser_rows = hgt - 8;
8083
8084         /* Allocate the "feat_idx" array */
8085         C_MAKE(feat_idx, max_f_idx, int);
8086
8087         max = 0;
8088         grp_cnt = 0;
8089
8090         /* Check every group */
8091         for (i = 0; feature_group_text[i] != NULL; i++)
8092         {
8093                 /* Measure the label */
8094                 len = strlen(feature_group_text[i]);
8095
8096                 /* Save the maximum length */
8097                 if (len > max) max = len;
8098
8099                 /* See if any features are known */
8100                 if (collect_features(i, feat_idx))
8101                 {
8102                         /* Build a list of groups with known features */
8103                         grp_idx[grp_cnt++] = i;
8104                 }
8105         }
8106
8107         /* Terminate the list */
8108         grp_idx[grp_cnt] = -1;
8109
8110         old_grp_cur = -1;
8111         grp_cur = grp_top = 0;
8112         feat_cur = feat_top = 0;
8113         feat_cnt = 0;
8114
8115         flag = FALSE;
8116         redraw = TRUE;
8117
8118         while ((!flag) && (grp_cnt))
8119         {
8120                 char ch;
8121                 feature_type *f_ptr;
8122
8123                 if (redraw)
8124                 {
8125                         clear_from(0);
8126                 
8127                         prt("Visuals - features", 2, 0);
8128                         prt("Group", 4, 0);
8129                         prt("Name", 4, max + 3);
8130                         prt("Sym", 4, 67);
8131
8132                         for (i = 0; i < 78; i++)
8133                         {
8134                                 Term_putch(i, 5, TERM_WHITE, '=');
8135                         }
8136
8137                         for (i = 0; i < browser_rows; i++)
8138                         {
8139                                 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8140                         }
8141
8142                         redraw = FALSE;
8143                 }
8144
8145                 /* Scroll group list */
8146                 if (grp_cur < grp_top) grp_top = grp_cur;
8147                 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8148
8149                 /* Display a list of feature groups */
8150                 display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
8151
8152                 if (old_grp_cur != grp_cur)
8153                 {
8154                         old_grp_cur = grp_cur;
8155
8156                         /* Get a list of features in the current group */
8157                         feat_cnt = collect_features(grp_idx[grp_cur], feat_idx);
8158                 }
8159
8160                 /* Scroll feature list */
8161                 while (feat_cur < feat_top)
8162                         feat_top = MAX(0, feat_top - browser_rows/2);
8163                 while (feat_cur >= feat_top + browser_rows)
8164                         feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows/2);
8165
8166                 if (!visual_list)
8167                 {
8168                         /* Display a list of features in the current group */
8169                         display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top);
8170                 }
8171                 else
8172                 {
8173                         feat_top = feat_cur;
8174
8175                         /* Display a list of features in the current group */
8176                         display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top);
8177
8178                         /* Display visual list below first object */
8179                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8180                 }
8181
8182                 /* Prompt */
8183 #ifdef JP
8184                 prt(format("<Êý¸þ>%s%s, ESC", visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
8185 #else
8186                 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);
8187 #endif
8188
8189                 /* Get the current feature */
8190                 f_ptr = &f_info[feat_idx[feat_cur]];
8191
8192                 if (visual_list)
8193                 {
8194                         place_visual_list_cursor(max + 3, 7, f_ptr->x_attr, f_ptr->x_char, attr_top, char_left);
8195                 }
8196                 else if (!column)
8197                 {
8198                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8199                 }
8200                 else
8201                 {
8202                         Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
8203                 }
8204         
8205                 ch = inkey();
8206
8207                 /* Do visual mode command if needed */
8208                 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;
8209
8210                 switch (ch)
8211                 {
8212                         case ESCAPE:
8213                         {
8214                                 flag = TRUE;
8215                                 break;
8216                         }
8217
8218                         default:
8219                         {
8220                                 /* Move the cursor */
8221                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
8222                                 break;
8223                         }
8224                 }
8225         }
8226
8227         /* Prompt */
8228         if (!grp_cnt) msg_print("No features known.");
8229
8230         /* Free the "feat_idx" array */
8231         C_KILL(feat_idx, max_f_idx, int);
8232 }
8233
8234
8235 /*
8236  * List wanted monsters
8237  */
8238 static void do_cmd_knowledge_kubi(void)
8239 {
8240         int i;
8241         FILE *fff;
8242         
8243         char file_name[1024];
8244         
8245         
8246         /* Open a new file */
8247         fff = my_fopen_temp(file_name, 1024);
8248         if (!fff) {
8249 #ifdef JP
8250             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8251 #else
8252             msg_format("Failed to create temporary file %s.", file_name);
8253 #endif
8254             msg_print(NULL);
8255             return;
8256         }
8257         
8258         if (fff)
8259         {
8260                 bool listed = FALSE;
8261
8262 #ifdef JP
8263                 fprintf(fff, "º£Æü¤Î¥¿¡¼¥²¥Ã¥È : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "ÉÔÌÀ"));
8264                 fprintf(fff, "\n");
8265                 fprintf(fff, "¾Þ¶â¼ó¥ê¥¹¥È\n");
8266 #else
8267                 fprintf(fff, "Today target : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "unknown"));
8268                 fprintf(fff, "\n");
8269                 fprintf(fff, "List of wanted monsters\n");
8270 #endif
8271                 fprintf(fff, "----------------------------------------------\n");
8272
8273                 for (i = 0; i < MAX_KUBI; i++)
8274                 {
8275                         if (kubi_r_idx[i] <= 10000)
8276                         {
8277                                 fprintf(fff,"%s\n", r_name + r_info[kubi_r_idx[i]].name);
8278
8279                                 listed = TRUE;
8280                         }
8281                 }
8282
8283                 if (!listed)
8284                 {
8285 #ifdef JP
8286                         fprintf(fff,"\n%s\n", "¾Þ¶â¼ó¤Ï¤â¤¦»Ä¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
8287 #else
8288                         fprintf(fff,"\n%s\n", "There is no more wanted monster.");
8289 #endif
8290                 }
8291         }
8292         
8293         /* Close the file */
8294         my_fclose(fff);
8295         
8296         /* Display the file contents */
8297 #ifdef JP
8298         show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
8299 #else
8300         show_file(TRUE, file_name, "Wanted monsters", 0, 0);
8301 #endif
8302
8303         
8304         /* Remove the file */
8305         fd_kill(file_name);
8306 }
8307
8308 /*
8309  * List virtues & status
8310  */
8311 static void do_cmd_knowledge_virtues(void)
8312 {
8313         FILE *fff;
8314         
8315         char file_name[1024];
8316         
8317         
8318         /* Open a new file */
8319         fff = my_fopen_temp(file_name, 1024);
8320         if (!fff) {
8321 #ifdef JP
8322             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8323 #else
8324             msg_format("Failed to create temporary file %s.", file_name);
8325 #endif
8326             msg_print(NULL);
8327             return;
8328         }
8329         
8330         if (fff)
8331         {
8332 #ifdef JP
8333                 fprintf(fff, "¸½ºß¤Î°À­ : %s\n\n", your_alignment());
8334 #else
8335                 fprintf(fff, "Your alighnment : %s\n\n", your_alignment());
8336 #endif
8337                 dump_virtues(fff);
8338         }
8339         
8340         /* Close the file */
8341         my_fclose(fff);
8342         
8343         /* Display the file contents */
8344 #ifdef JP
8345         show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
8346 #else
8347         show_file(TRUE, file_name, "Virtues", 0, 0);
8348 #endif
8349
8350         
8351         /* Remove the file */
8352         fd_kill(file_name);
8353 }
8354
8355 /*
8356 * Dungeon
8357 *
8358 */
8359 static void do_cmd_knowledge_dungeon(void)
8360 {
8361         FILE *fff;
8362         
8363         char file_name[1024];
8364         int i;
8365         
8366         
8367         /* Open a new file */
8368         fff = my_fopen_temp(file_name, 1024);
8369         if (!fff) {
8370 #ifdef JP
8371             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8372 #else
8373             msg_format("Failed to create temporary file %s.", file_name);
8374 #endif
8375             msg_print(NULL);
8376             return;
8377         }
8378         
8379         if (fff)
8380         {
8381                 for (i = 1; i < max_d_idx; i++)
8382                 {
8383                         bool seiha = FALSE;
8384
8385                         if (!d_info[i].maxdepth) continue;
8386                         if (!max_dlv[i]) continue;
8387                         if (d_info[i].final_guardian)
8388                         {
8389                                 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
8390                         }
8391                         else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
8392 #ifdef JP
8393                         fprintf(fff,"%c%-12s :  %3d ³¬\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
8394 #else
8395                         fprintf(fff,"%c%-16s :  level %3d\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
8396 #endif
8397                 }
8398         }
8399         
8400         /* Close the file */
8401         my_fclose(fff);
8402         
8403         /* Display the file contents */
8404 #ifdef JP
8405         show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
8406 #else
8407         show_file(TRUE, file_name, "Dungeon", 0, 0);
8408 #endif
8409
8410         
8411         /* Remove the file */
8412         fd_kill(file_name);
8413 }
8414
8415 /*
8416 * List virtues & status
8417 *
8418 */
8419 static void do_cmd_knowledge_stat(void)
8420 {
8421         FILE *fff;
8422         
8423         char file_name[1024];
8424         int percent, v_nr;
8425         
8426         /* Open a new file */
8427         fff = my_fopen_temp(file_name, 1024);
8428         if (!fff) {
8429 #ifdef JP
8430             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8431 #else
8432             msg_format("Failed to create temporary file %s.", file_name);
8433 #endif
8434             msg_print(NULL);
8435             return;
8436         }
8437         
8438         if (fff)
8439         {
8440                 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
8441                         (2 * p_ptr->hitdie +
8442                         ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
8443
8444 #ifdef JP
8445                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
8446                 else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
8447                 fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
8448 #else
8449                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
8450                 else fprintf(fff, "Your current Life Rating is ???.\n\n");
8451                 fprintf(fff, "Limits of maximum stats\n\n");
8452 #endif
8453                 for (v_nr = 0; v_nr < 6; v_nr++)
8454                 {
8455                         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);
8456                         else fprintf(fff, "%s ???\n", stat_names[v_nr]);
8457                 }
8458         }
8459
8460         dump_yourself(fff);
8461
8462         /* Close the file */
8463         my_fclose(fff);
8464         
8465         /* Display the file contents */
8466 #ifdef JP
8467         show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
8468 #else
8469         show_file(TRUE, file_name, "HP-rate & Max stat", 0, 0);
8470 #endif
8471
8472         
8473         /* Remove the file */
8474         fd_kill(file_name);
8475 }
8476
8477
8478 /*
8479  * Print all active quests
8480  */
8481 static void do_cmd_knowledge_quests_current(FILE *fff)
8482 {
8483         char tmp_str[120];
8484         char rand_tmp_str[120] = "\0";
8485         char name[80];
8486         monster_race *r_ptr;
8487         int i;
8488         int rand_level = 100;
8489         int total = 0;
8490
8491 #ifdef JP
8492         fprintf(fff, "¡Ô¿ë¹ÔÃæ¤Î¥¯¥¨¥¹¥È¡Õ\n");
8493 #else
8494         fprintf(fff, "< Current Quest >\n");
8495 #endif
8496
8497         for (i = 1; i < max_quests; i++)
8498         {
8499                 if ((quest[i].status == QUEST_STATUS_TAKEN) || (quest[i].status == QUEST_STATUS_COMPLETED))
8500                 {
8501                         /* Set the quest number temporary */
8502                         int old_quest = p_ptr->inside_quest;
8503                         int j;
8504
8505                         /* Clear the text */
8506                         for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
8507                         quest_text_line = 0;
8508
8509                         p_ptr->inside_quest = i;
8510
8511                         /* Get the quest text */
8512                         init_flags = INIT_SHOW_TEXT;
8513
8514                         process_dungeon_file("q_info.txt", 0, 0, 0, 0);
8515
8516                         /* Reset the old quest number */
8517                         p_ptr->inside_quest = old_quest;
8518
8519                         /* No info from "silent" quests */
8520                         if (quest[i].flags & QUEST_FLAG_SILENT) continue;
8521
8522                         total++;
8523
8524                         if (quest[i].type != QUEST_TYPE_RANDOM)
8525                         {
8526                                 char note[80] = "\0";
8527
8528                                 if (quest[i].status == QUEST_STATUS_TAKEN)
8529                                 {
8530                                         switch (quest[i].type)
8531                                         {
8532                                         case QUEST_TYPE_KILL_LEVEL:
8533                                         case QUEST_TYPE_KILL_ANY_LEVEL:
8534                                                 r_ptr = &r_info[quest[i].r_idx];
8535                                                 strcpy(name, r_name + r_ptr->name);
8536                                                 if (quest[i].max_num > 1)
8537                                                 {
8538 #ifdef JP
8539                                                         sprintf(note," - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
8540                                                                 quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
8541 #else
8542                                                         plural_aux(name);
8543                                                         sprintf(note," - kill %d %s, have killed %d.",
8544                                                                 quest[i].max_num, name, quest[i].cur_num);
8545 #endif
8546                                                 }
8547                                                 else
8548 #ifdef JP
8549                                                         sprintf(note," - %s¤òÅݤ¹¡£",name);
8550 #else
8551                                                         sprintf(note," - kill %s.",name);
8552 #endif
8553                                                 break;
8554
8555                                         case QUEST_TYPE_FIND_ARTIFACT:
8556                                                 strcpy(name, a_name + a_info[quest[i].k_idx].name);
8557 #ifdef JP
8558                                                 sprintf(note," - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
8559 #else
8560                                                 sprintf(note," - Find out %s.", name);
8561 #endif
8562                                                 break;
8563
8564                                         case QUEST_TYPE_FIND_EXIT:
8565 #ifdef JP
8566                                                 sprintf(note," - Ãµº÷¤¹¤ë¡£");
8567 #else
8568                                                 sprintf(note," - Search.");
8569 #endif
8570                                                 break;
8571
8572                                         case QUEST_TYPE_KILL_NUMBER:
8573 #ifdef JP
8574                                                 sprintf(note," - %d ÂΤΥâ¥ó¥¹¥¿¡¼¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
8575                                                         quest[i].max_num, quest[i].max_num - quest[i].cur_num);
8576 #else
8577                                                 sprintf(note," - Kill %d monsters, have killed %d.",
8578                                                         quest[i].max_num, quest[i].cur_num);
8579 #endif
8580                                                 break;
8581
8582                                         case QUEST_TYPE_KILL_ALL:
8583 #ifdef JP
8584                                                 sprintf(note," - Á´¤Æ¤Î¥â¥ó¥¹¥¿¡¼¤òÅݤ¹¡£");
8585 #else
8586                                                 sprintf(note," - Kill all monsters.");
8587 #endif
8588                                                 break;
8589                                         }
8590                                 }
8591
8592                                 /* Print the quest info */
8593 #ifdef JP
8594                                 sprintf(tmp_str, "  %s (´í¸±ÅÙ:%d³¬ÁêÅö)%s\n",
8595                                         quest[i].name, quest[i].level, note);
8596 #else
8597                                 sprintf(tmp_str, "  %s (Danger level: %d)%s\n",
8598                                         quest[i].name, quest[i].level, note);
8599 #endif
8600
8601                                 fprintf(fff, tmp_str);
8602
8603                                 if (quest[i].status == QUEST_STATUS_COMPLETED)
8604                                 {
8605 #ifdef JP
8606                                         sprintf(tmp_str, "    ¥¯¥¨¥¹¥ÈãÀ® - ¤Þ¤ÀÊó½·¤ò¼õ¤±¤È¤Ã¤Æ¤Ê¤¤¡£\n");
8607 #else
8608                                         sprintf(tmp_str, "    Quest Completed - Unrewarded\n");
8609 #endif
8610                                         fprintf(fff, tmp_str);
8611                                 }
8612                                 else
8613                                 {
8614                                         j = 0;
8615
8616                                         while (quest_text[j][0] && j < 10)
8617                                         {
8618                                                 fprintf(fff, "    %s\n", quest_text[j]);
8619                                                 j++;
8620                                         }
8621                                 }
8622                         }
8623                         else if (quest[i].level < rand_level) /* QUEST_TYPE_RANDOM */
8624                         {
8625                                 /* New random */
8626                                 rand_level = quest[i].level;
8627
8628                                 if (max_dlv[DUNGEON_ANGBAND] >= rand_level)
8629                                 {
8630                                         /* Print the quest info */
8631                                         r_ptr = &r_info[quest[i].r_idx];
8632                                         strcpy(name, r_name + r_ptr->name);
8633
8634                                         if (quest[i].max_num > 1)
8635                                         {
8636 #ifdef JP
8637                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
8638                                                         quest[i].name, quest[i].level,
8639                                                         quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
8640 #else
8641                                                 plural_aux(name);
8642
8643                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
8644                                                         quest[i].name, quest[i].level,
8645                                                         quest[i].max_num, name, quest[i].cur_num);
8646 #endif
8647                                         }
8648                                         else
8649                                         {
8650 #ifdef JP
8651                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %s¤òÅݤ¹¡£\n",
8652                                                         quest[i].name, quest[i].level, name);
8653 #else
8654                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %s.\n",
8655                                                         quest[i].name, quest[i].level, name);
8656 #endif
8657                                         }
8658                                 }
8659                         }
8660                 }
8661         }
8662
8663         /* Print the current random quest  */
8664         if (rand_tmp_str[0]) fprintf(fff, rand_tmp_str);
8665
8666 #ifdef JP
8667         if (!total) fprintf(fff, "  ¤Ê¤·\n");
8668 #else
8669         if (!total) fprintf(fff, "  Nothing.\n");
8670 #endif
8671 }
8672
8673
8674 /*
8675  * Print all finished quests
8676  */
8677 void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
8678 {
8679         char tmp_str[120];
8680         int i;
8681         int total = 0;
8682
8683 #ifdef JP
8684         fprintf(fff, "¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
8685 #else
8686         fprintf(fff, "< Completed Quest >\n");
8687 #endif
8688         for (i = 1; i < max_quests; i++)
8689         {
8690                 int q_idx = quest_num[i];
8691
8692                 if (quest[q_idx].status == QUEST_STATUS_FINISHED)
8693                 {
8694                         if (is_fixed_quest_idx(q_idx))
8695                         {
8696                                 /* Set the quest number temporary */
8697                                 int old_quest = p_ptr->inside_quest;
8698
8699                                 p_ptr->inside_quest = q_idx;
8700
8701                                 /* Get the quest */
8702                                 init_flags = INIT_ASSIGN;
8703
8704                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
8705
8706                                 /* Reset the old quest number */
8707                                 p_ptr->inside_quest = old_quest;
8708
8709                                 /* No info from "silent" quests */
8710                                 if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
8711                         }
8712
8713                         total++;
8714
8715                         if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
8716                         {
8717                                 /* Print the quest info */
8718
8719                                 if (quest[q_idx].complev == 0)
8720                                 {
8721                                         sprintf(tmp_str,
8722 #ifdef JP
8723                                                 "  %-40s (%3d³¬)            -   ÉÔÀᄀ\n",
8724 #else
8725                                                 "  %-40s (Dungeon level: %3d) - (Cancelled)\n",
8726 #endif
8727                                                 r_name+r_info[quest[q_idx].r_idx].name,
8728                                                 quest[q_idx].level);
8729                                 }
8730                                 else
8731                                 {
8732                                         sprintf(tmp_str,
8733 #ifdef JP
8734                                                 "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
8735 #else
8736                                                 "  %-40s (Dungeon level: %3d) - level %2d\n",
8737 #endif
8738                                                 r_name+r_info[quest[q_idx].r_idx].name,
8739                                                 quest[q_idx].level,
8740                                                 quest[q_idx].complev);
8741                                 }
8742                         }
8743                         else
8744                         {
8745                                 /* Print the quest info */
8746 #ifdef JP
8747                                 sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
8748                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
8749 #else
8750                                 sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
8751                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
8752 #endif
8753                         }
8754
8755                         fprintf(fff, tmp_str);
8756                 }
8757         }
8758 #ifdef JP
8759         if (!total) fprintf(fff, "  ¤Ê¤·\n");
8760 #else
8761         if (!total) fprintf(fff, "  Nothing.\n");
8762 #endif
8763 }
8764
8765
8766 /*
8767  * Print all failed quests
8768  */
8769 void do_cmd_knowledge_quests_failed(FILE *fff, int quest_num[])
8770 {
8771         char tmp_str[120];
8772         int i;
8773         int total = 0;
8774
8775 #ifdef JP
8776         fprintf(fff, "¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
8777 #else
8778         fprintf(fff, "< Failed Quest >\n");
8779 #endif
8780         for (i = 1; i < max_quests; i++)
8781         {
8782                 int q_idx = quest_num[i];
8783
8784                 if ((quest[q_idx].status == QUEST_STATUS_FAILED_DONE) || (quest[q_idx].status == QUEST_STATUS_FAILED))
8785                 {
8786                         if (is_fixed_quest_idx(q_idx))
8787                         {
8788                                 /* Set the quest number temporary */
8789                                 int old_quest = p_ptr->inside_quest;
8790
8791                                 p_ptr->inside_quest = q_idx;
8792
8793                                 /* Get the quest text */
8794                                 init_flags = INIT_ASSIGN;
8795
8796                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
8797
8798                                 /* Reset the old quest number */
8799                                 p_ptr->inside_quest = old_quest;
8800
8801                                 /* No info from "silent" quests */
8802                                 if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
8803                         }
8804
8805                         total++;
8806
8807                         if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
8808                         {
8809                                 /* Print the quest info */
8810 #ifdef JP
8811                                 sprintf(tmp_str, "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
8812                                         r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
8813 #else
8814                                 sprintf(tmp_str, "  %-40s (Dungeon level: %3d) - level %2d\n",
8815                                         r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
8816 #endif
8817                         }
8818                         else
8819                         {
8820                                 /* Print the quest info */
8821 #ifdef JP
8822                                 sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
8823                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
8824 #else
8825                                 sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
8826                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
8827 #endif
8828                         }
8829                         fprintf(fff, tmp_str);
8830                 }
8831         }
8832 #ifdef JP
8833         if (!total) fprintf(fff, "  ¤Ê¤·\n");
8834 #else
8835         if (!total) fprintf(fff, "  Nothing.\n");
8836 #endif
8837 }
8838
8839
8840 /*
8841  * Print all random quests
8842  */
8843 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
8844 {
8845         char tmp_str[120];
8846         int i;
8847         int total = 0;
8848
8849 #ifdef JP
8850         fprintf(fff, "¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
8851 #else
8852         fprintf(fff, "< Remaining Random Quest >\n");
8853 #endif
8854         for (i = 1; i < max_quests; i++)
8855         {
8856                 /* No info from "silent" quests */
8857                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
8858
8859                 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
8860                 {
8861                         total++;
8862
8863                         /* Print the quest info */
8864 #ifdef JP
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 #else
8868                         sprintf(tmp_str, "  %s (%d, %s)\n",
8869                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
8870 #endif
8871                         fprintf(fff, tmp_str);
8872                 }
8873         }
8874 #ifdef JP
8875         if (!total) fprintf(fff, "  ¤Ê¤·\n");
8876 #else
8877         if (!total) fprintf(fff, "  Nothing.\n");
8878 #endif
8879 }
8880
8881
8882 bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
8883 {
8884         int *q_num = (int *)u;
8885         quest_type *qa = &quest[q_num[a]];
8886         quest_type *qb = &quest[q_num[b]];
8887
8888         /* Unused */
8889         (void)v;
8890
8891         if (qa->complev < qb->complev) return TRUE;
8892         if (qa->complev > qb->complev) return FALSE;
8893         if (qa->level <= qb->level) return TRUE;
8894         return FALSE;
8895 }
8896
8897 void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
8898 {
8899         int *q_num = (int *)u;
8900         int tmp;
8901
8902         /* Unused */
8903         (void)v;
8904
8905         tmp = q_num[a];
8906         q_num[a] = q_num[b];
8907         q_num[b] = tmp;
8908 }
8909
8910
8911 /*
8912  * Print quest status of all active quests
8913  */
8914 static void do_cmd_knowledge_quests(void)
8915 {
8916         FILE *fff;
8917         char file_name[1024];
8918         int *quest_num, dummy, i;
8919
8920         /* Open a new file */
8921         fff = my_fopen_temp(file_name, 1024);
8922         if (!fff)
8923         {
8924 #ifdef JP
8925             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8926 #else
8927             msg_format("Failed to create temporary file %s.", file_name);
8928 #endif
8929             msg_print(NULL);
8930             return;
8931         }
8932
8933         /* Allocate Memory */
8934         C_MAKE(quest_num, max_quests, int);
8935
8936         /* Sort by compete level */
8937         for (i = 1; i < max_quests; i++) quest_num[i] = i;
8938         ang_sort_comp = ang_sort_comp_quest_num;
8939         ang_sort_swap = ang_sort_swap_quest_num;
8940         ang_sort(quest_num, &dummy, max_quests);
8941
8942         /* Dump Quest Information */
8943         do_cmd_knowledge_quests_current(fff);
8944         fputc('\n', fff);
8945         do_cmd_knowledge_quests_completed(fff, quest_num);
8946         fputc('\n', fff);
8947         do_cmd_knowledge_quests_failed(fff, quest_num);
8948         if (p_ptr->wizard)
8949         {
8950                 fputc('\n', fff);
8951                 do_cmd_knowledge_quests_wiz_random(fff);
8952         }
8953
8954         /* Close the file */
8955         my_fclose(fff);
8956
8957         /* Display the file contents */
8958 #ifdef JP
8959         show_file(TRUE, file_name, "¥¯¥¨¥¹¥ÈãÀ®¾õ¶·", 0, 0);
8960 #else
8961         show_file(TRUE, file_name, "Quest status", 0, 0);
8962 #endif
8963
8964         /* Remove the file */
8965         fd_kill(file_name);
8966
8967         /* Free Memory */
8968         C_KILL(quest_num, max_quests, int);
8969 }
8970
8971
8972 /*
8973  * List my home
8974  */
8975 static void do_cmd_knowledge_home(void)
8976 {
8977         FILE *fff;
8978
8979         int i;
8980         char file_name[1024];
8981         store_type  *st_ptr;
8982         char o_name[MAX_NLEN];
8983         cptr            paren = ")";
8984
8985         process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
8986
8987         /* Open a new file */
8988         fff = my_fopen_temp(file_name, 1024);
8989         if (!fff) {
8990 #ifdef JP
8991                 msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8992 #else
8993                 msg_format("Failed to create temporary file %s.", file_name);
8994 #endif
8995                 msg_print(NULL);
8996                 return;
8997         }
8998
8999         if (fff)
9000         {
9001                 /* Print all homes in the different towns */
9002                 st_ptr = &town[1].store[STORE_HOME];
9003
9004                 /* Home -- if anything there */
9005                 if (st_ptr->stock_num)
9006                 {
9007 #ifdef JP
9008                         int x = 1;
9009 #endif
9010                         /* Header with name of the town */
9011 #ifdef JP
9012                         fprintf(fff, "  [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
9013 #else
9014                         fprintf(fff, "  [Home Inventory]\n");
9015 #endif
9016
9017                         /* Dump all available items */
9018                         for (i = 0; i < st_ptr->stock_num; i++)
9019                         {
9020 #ifdef JP
9021                                 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
9022                                 object_desc(o_name, &st_ptr->stock[i], 0);
9023                                 if (strlen(o_name) <= 80-3)
9024                                 {
9025                                         fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9026                                 }
9027                                 else
9028                                 {
9029                                         int n;
9030                                         char *t;
9031                                         for (n = 0, t = o_name; n < 80-3; n++, t++)
9032                                                 if(iskanji(*t)) {t++; n++;}
9033                                         if (n == 81-3) n = 79-3; /* ºÇ¸å¤¬´Á»úȾʬ */
9034
9035                                         fprintf(fff, "%c%s %.*s\n", I2A(i%12), paren, n, o_name);
9036                                         fprintf(fff, "   %.77s\n", o_name+n);
9037                                 }
9038 #else
9039                                 object_desc(o_name, &st_ptr->stock[i], 0);
9040                                 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9041 #endif
9042
9043                         }
9044
9045                         /* Add an empty line */
9046                         fprintf(fff, "\n\n");
9047                 }
9048         }
9049
9050         /* Close the file */
9051         my_fclose(fff);
9052
9053         /* Display the file contents */
9054 #ifdef JP
9055         show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
9056 #else
9057         show_file(TRUE, file_name, "Home Inventory", 0, 0);
9058 #endif
9059
9060
9061         /* Remove the file */
9062         fd_kill(file_name);
9063 }
9064
9065
9066 /*
9067  * Check the status of "autopick"
9068  */
9069 static void do_cmd_knowledge_autopick(void)
9070 {
9071         int k;
9072         FILE *fff;
9073         char file_name[1024];
9074
9075         /* Open a new file */
9076         fff = my_fopen_temp(file_name, 1024);
9077
9078         if (!fff)
9079         {
9080 #ifdef JP
9081             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9082 #else
9083             msg_format("Failed to create temporary file %s.", file_name);
9084 #endif
9085             msg_print(NULL);
9086             return;
9087         }
9088
9089         if (!max_autopick)
9090         {
9091 #ifdef JP
9092             fprintf(fff, "¼«Æ°Ç˲õ/½¦¤¤¤Ë¤Ï²¿¤âÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
9093 #else
9094             fprintf(fff, "No preference for auto picker/destroyer.");
9095 #endif
9096         }
9097         else
9098         {
9099 #ifdef JP
9100             fprintf(fff, "   ¼«Æ°½¦¤¤/Ç˲õ¤Ë¤Ï¸½ºß %d¹ÔÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n\n", max_autopick);
9101 #else
9102             fprintf(fff, "   There are %d registered lines for auto picker/destroyer.\n\n", max_autopick);
9103 #endif
9104         }
9105
9106         for (k = 0; k < max_autopick; k++)
9107         {
9108                 cptr tmp;
9109                 byte act = autopick_list[k].action;
9110                 if (act & DONT_AUTOPICK)
9111                 {
9112 #ifdef JP
9113                         tmp = "ÊüÃÖ";
9114 #else
9115                         tmp = "Leave";
9116 #endif
9117                 }
9118                 else if (act & DO_AUTODESTROY)
9119                 {
9120 #ifdef JP
9121                         tmp = "Ç˲õ";
9122 #else
9123                         tmp = "Destroy";
9124 #endif
9125                 }
9126                 else if (act & DO_AUTOPICK)
9127                 {
9128 #ifdef JP
9129                         tmp = "½¦¤¦";
9130 #else
9131                         tmp = "Pickup";
9132 #endif
9133                 }
9134                 else /* if (act & DO_QUERY_AUTOPICK) */ /* Obvious */
9135                 {
9136 #ifdef JP
9137                         tmp = "³Îǧ";
9138 #else
9139                         tmp = "Query";
9140 #endif
9141                 }
9142
9143                 if (act & DO_DISPLAY)
9144                         fprintf(fff, "%11s", format("[%s]", tmp));
9145                 else
9146                         fprintf(fff, "%11s", format("(%s)", tmp));
9147
9148                 tmp = autopick_line_from_entry(&autopick_list[k]);
9149                 fprintf(fff, " %s", tmp);
9150                 string_free(tmp);
9151                 fprintf(fff, "\n");
9152         }
9153         /* Close the file */
9154         my_fclose(fff);
9155         /* Display the file contents */
9156 #ifdef JP
9157         show_file(TRUE, file_name, "¼«Æ°½¦¤¤/Ç˲õ ÀßÄê¥ê¥¹¥È", 0, 0);
9158 #else
9159         show_file(TRUE, file_name, "Auto-picker/Destroyer", 0, 0);
9160 #endif
9161
9162         /* Remove the file */
9163         fd_kill(file_name);
9164 }
9165
9166
9167 /*
9168  * Interact with "knowledge"
9169  */
9170 void do_cmd_knowledge(void)
9171 {
9172         int i,p=0;
9173         /* File type is "TEXT" */
9174         FILE_TYPE(FILE_TYPE_TEXT);
9175         /* Save the screen */
9176         screen_save();
9177         /* Interact until done */
9178         while (1)
9179         {
9180                 /* Clear screen */
9181                 Term_clear();
9182                 /* Ask for a choice */
9183 #ifdef JP
9184                 prt(format("%d/2 ¥Ú¡¼¥¸", (p+1)), 2, 65);
9185                 prt("¸½ºß¤ÎÃ챤ò³Îǧ¤¹¤ë", 3, 0);
9186 #else
9187                 prt(format("page %d/2", (p+1)), 2, 65);
9188                 prt("Display current knowledge", 3, 0);
9189 #endif
9190
9191                 /* Give some choices */
9192 #ifdef JP
9193                 if (p == 0) {
9194                         prt("(1) ´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à                 ¤Î°ìÍ÷", 6, 5);
9195                         prt("(2) ´ûÃΤΥ¢¥¤¥Æ¥à                       ¤Î°ìÍ÷", 7, 5);
9196                         prt("(3) ´ûÃΤÎÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ ¤Î°ìÍ÷", 8, 5);
9197                         prt("(4) ´ûÃΤΥâ¥ó¥¹¥¿¡¼                     ¤Î°ìÍ÷", 9, 5);
9198                         prt("(5) Åݤ·¤¿Å¨¤Î¿ô                         ¤Î°ìÍ÷", 10, 5);
9199                         if (!vanilla_town) prt("(6) ¾Þ¶â¼ó                               ¤Î°ìÍ÷", 11, 5);
9200                         prt("(7) ¸½ºß¤Î¥Ú¥Ã¥È                         ¤Î°ìÍ÷", 12, 5);
9201                         prt("(8) ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à                     ¤Î°ìÍ÷", 13, 5);
9202                         prt("(9) *´ÕÄê*ºÑ¤ßÁõÈ÷¤ÎÂÑÀ­                 ¤Î°ìÍ÷", 14, 5);
9203                         prt("(0) ÃÏ·Á¤Îɽ¼¨Ê¸»ú/¥¿¥¤¥ë                ¤Î°ìÍ÷", 15, 5);
9204                 } else {
9205                         prt("(a) ¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó                     ¤Î°ìÍ÷", 6, 5);
9206                         prt("(b) ÆÍÁ³ÊÑ°Û                             ¤Î°ìÍ÷", 7, 5);
9207                         prt("(c) Éð´ï¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 8, 5);
9208                         prt("(d) ËâË¡¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 9, 5);
9209                         prt("(e) µ»Ç½¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 10, 5);
9210                         prt("(f) ¥×¥ì¥¤¥ä¡¼¤ÎÆÁ                       ¤Î°ìÍ÷", 11, 5);
9211                         prt("(g) Æþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó                     ¤Î°ìÍ÷", 12, 5);
9212                         prt("(h) ¼Â¹ÔÃæ¤Î¥¯¥¨¥¹¥È                     ¤Î°ìÍ÷", 13, 5);
9213                         prt("(i) ¸½ºß¤Î¼«Æ°½¦¤¤/Ç˲õÀßÄê              ¤Î°ìÍ÷", 14, 5);
9214                 }
9215 #else
9216                 if (p == 0) {
9217                         prt("(1) Display known artifacts", 6, 5);
9218                         prt("(2) Display known objects", 7, 5);
9219                         prt("(3) Display remaining uniques", 8, 5);
9220                         prt("(4) Display known monster", 9, 5);
9221                         prt("(5) Display kill count", 10, 5);
9222                         if (!vanilla_town) prt("(6) Display wanted monsters", 11, 5);
9223                         prt("(7) Display current pets", 12, 5);
9224                         prt("(8) Display home inventory", 13, 5);
9225                         prt("(9) Display *identified* equip.", 14, 5);
9226                         prt("(0) Display terrain symbols.", 15, 5);
9227                 } else {
9228                         prt("(a) Display about yourself", 6, 5);
9229                         prt("(b) Display mutations", 7, 5);
9230                         prt("(c) Display weapon proficiency", 8, 5);
9231                         prt("(d) Display spell proficiency", 9, 5);
9232                         prt("(e) Display misc. proficiency", 10, 5);
9233                         prt("(f) Display virtues", 11, 5);
9234                         prt("(g) Display dungeons", 12, 5);
9235                         prt("(h) Display current quests", 13, 5);
9236                         prt("(i) Display auto pick/destroy", 14, 5);
9237                 }
9238 #endif
9239                 /* Prompt */
9240 #ifdef JP
9241                 prt("-³¤¯-", 17, 8);
9242                 prt("ESC) È´¤±¤ë", 21, 1);
9243                 prt("SPACE) ¼¡¥Ú¡¼¥¸", 21, 30);
9244                 /*prt("-) Á°¥Ú¡¼¥¸", 21, 60);*/
9245                 prt("¥³¥Þ¥ó¥É:", 20, 0);
9246 #else
9247                 prt("-more-", 17, 8);
9248                 prt("ESC) Exit menu", 21, 1);
9249                 prt("SPACE) Next page", 21, 30);
9250                 /*prt("-) Previous page", 21, 60);*/
9251                 prt("Command: ", 20, 0);
9252 #endif
9253
9254                 /* Prompt */
9255                 i = inkey();
9256                 /* Done */
9257                 if (i == ESCAPE) break;
9258                 switch (i)
9259                 {
9260                 case ' ': /* Page change */
9261                 case '-':
9262                         p = 1 - p;
9263                         break;
9264                 case '1': /* Artifacts */
9265                         do_cmd_knowledge_artifacts();
9266                         break;
9267                 case '2': /* Objects */
9268                         do_cmd_knowledge_objects();
9269                         break;
9270                 case '3': /* Uniques */
9271                         do_cmd_knowledge_uniques();
9272                         break;
9273                 case '4': /* Monsters */
9274                         do_cmd_knowledge_monsters();
9275                         break;
9276                 case '5': /* Kill count  */
9277                         do_cmd_knowledge_kill_count();
9278                         break;
9279                 case '6': /* wanted */
9280                         if (!vanilla_town) do_cmd_knowledge_kubi();
9281                         break;
9282                 case '7': /* Pets */
9283                         do_cmd_knowledge_pets();
9284                         break;
9285                 case '8': /* Home */
9286                         do_cmd_knowledge_home();
9287                         break;
9288                 case '9': /* Resist list */
9289                         do_cmd_knowledge_inven();
9290                         break;
9291                 case '0': /* Feature list */
9292                         do_cmd_knowledge_features();
9293                         break;
9294                 /* Next page */
9295                 case 'a': /* Max stat */
9296                         do_cmd_knowledge_stat();
9297                         break;
9298                 case 'b': /* Mutations */
9299                         do_cmd_knowledge_mutations();
9300                         break;
9301                 case 'c': /* weapon-exp */
9302                         do_cmd_knowledge_weapon_exp();
9303                         break;
9304                 case 'd': /* spell-exp */
9305                         do_cmd_knowledge_spell_exp();
9306                         break;
9307                 case 'e': /* skill-exp */
9308                         do_cmd_knowledge_skill_exp();
9309                         break;
9310                 case 'f': /* Virtues */
9311                         do_cmd_knowledge_virtues();
9312                         break;
9313                 case 'g': /* Dungeon */
9314                         do_cmd_knowledge_dungeon();
9315                         break;
9316                 case 'h': /* Quests */
9317                         do_cmd_knowledge_quests();
9318                         break;
9319                 case 'i': /* Autopick */
9320                         do_cmd_knowledge_autopick();
9321                         break;
9322                 default: /* Unknown option */
9323                         bell();
9324                 }
9325                 /* Flush messages */
9326                 msg_print(NULL);
9327         }
9328         /* Restore the screen */
9329         screen_load();
9330 }
9331
9332
9333 /*
9334  * Check on the status of an active quest
9335  */
9336 void do_cmd_checkquest(void)
9337 {
9338         /* File type is "TEXT" */
9339         FILE_TYPE(FILE_TYPE_TEXT);
9340
9341         /* Save the screen */
9342         screen_save();
9343
9344         /* Quest info */
9345         do_cmd_knowledge_quests();
9346
9347         /* Restore the screen */
9348         screen_load();
9349 }
9350
9351
9352 /*
9353  * Display the time and date
9354  */
9355 void do_cmd_time(void)
9356 {
9357         int day, hour, min, full, start, end, num;
9358         char desc[1024];
9359
9360         char buf[1024];
9361
9362         FILE *fff;
9363
9364         extract_day_hour_min(&day, &hour, &min);
9365
9366         full = hour * 100 + min;
9367
9368         start = 9999;
9369         end = -9999;
9370
9371         num = 0;
9372
9373 #ifdef JP
9374         strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
9375 #else
9376         strcpy(desc, "It is a strange time.");
9377 #endif
9378
9379
9380         /* Message */
9381 #ifdef JP
9382         msg_format("%d ÆüÌÜ,»þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
9383                    day, (hour % 12 == 0) ? 12 : (hour % 12),
9384                    min, (hour < 12) ? "AM" : "PM");
9385 #else
9386         msg_format("This is day %d. The time is %d:%02d %s.",
9387                    day, (hour % 12 == 0) ? 12 : (hour % 12),
9388                    min, (hour < 12) ? "AM" : "PM");
9389 #endif
9390
9391
9392         /* Find the path */
9393         if (!randint0(10) || p_ptr->image)
9394         {
9395 #ifdef JP
9396                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
9397 #else
9398                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
9399 #endif
9400
9401         }
9402         else
9403         {
9404 #ifdef JP
9405                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
9406 #else
9407                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
9408 #endif
9409
9410         }
9411
9412         /* Open this file */
9413         fff = my_fopen(buf, "rt");
9414
9415         /* Oops */
9416         if (!fff) return;
9417
9418         /* Find this time */
9419         while (!my_fgets(fff, buf, sizeof(buf)))
9420         {
9421                 /* Ignore comments */
9422                 if (!buf[0] || (buf[0] == '#')) continue;
9423
9424                 /* Ignore invalid lines */
9425                 if (buf[1] != ':') continue;
9426
9427                 /* Process 'Start' */
9428                 if (buf[0] == 'S')
9429                 {
9430                         /* Extract the starting time */
9431                         start = atoi(buf + 2);
9432
9433                         /* Assume valid for an hour */
9434                         end = start + 59;
9435
9436                         /* Next... */
9437                         continue;
9438                 }
9439
9440                 /* Process 'End' */
9441                 if (buf[0] == 'E')
9442                 {
9443                         /* Extract the ending time */
9444                         end = atoi(buf + 2);
9445
9446                         /* Next... */
9447                         continue;
9448                 }
9449
9450                 /* Ignore incorrect range */
9451                 if ((start > full) || (full > end)) continue;
9452
9453                 /* Process 'Description' */
9454                 if (buf[0] == 'D')
9455                 {
9456                         num++;
9457
9458                         /* Apply the randomizer */
9459                         if (!randint0(num)) strcpy(desc, buf + 2);
9460
9461                         /* Next... */
9462                         continue;
9463                 }
9464         }
9465
9466         /* Message */
9467         msg_print(desc);
9468
9469         /* Close the file */
9470         my_fclose(fff);
9471 }