OSDN Git Service

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