OSDN Git Service

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