OSDN Git Service

オプションメニューでカーソルを使用して項目を選択できるようにした。
[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 #define OPT_NUM 15
2332
2333 static struct opts
2334 {
2335         char key;
2336         cptr name;
2337         int row;
2338 }
2339 option_fields[OPT_NUM] =
2340 {
2341 #ifdef JP
2342         { '1', "    ¥­¡¼ÆþÎÏ     ¥ª¥×¥·¥ç¥ó", 3 },
2343         { '2', "   ¥Þ¥Ã¥×²èÌÌ    ¥ª¥×¥·¥ç¥ó", 4 },
2344         { '3', "  ¥Æ¥­¥¹¥Èɽ¼¨   ¥ª¥×¥·¥ç¥ó", 5 },
2345         { '4', "  ¥²¡¼¥à¥×¥ì¥¤   ¥ª¥×¥·¥ç¥ó", 6 },
2346         { '5', "  ¹ÔÆ°Ãæ»ß´Ø·¸   ¥ª¥×¥·¥ç¥ó", 7 },
2347         { '6', "  ´Ê°×¼«Æ°Ç˲õ   ¥ª¥×¥·¥ç¥ó", 8 },
2348         { 'r', "   ¥×¥ì¥¤µ­Ï¿    ¥ª¥×¥·¥ç¥ó", 9 },
2349
2350         { 'p', "¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿", 11 },
2351         { 'd', " ´ðËÜ¥¦¥§¥¤¥ÈÎÌ ", 12 },
2352         { 'h', "Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È", 13 },
2353         { 'm', "  ÄãËâÎÏ¿§ïçÃÍ  ", 14 },
2354         { 'a', "   ¼«Æ°¥»¡¼¥Ö    ¥ª¥×¥·¥ç¥ó", 15 },
2355         { 'w', "¥¦¥¤¥ó¥É¥¦¥Õ¥é¥°", 16 },
2356
2357         { 'b', "      ½é´ü       ¥ª¥×¥·¥ç¥ó (»²¾È¤Î¤ß)", 18 },
2358         { 'c', "      º¾µ½       ¥ª¥×¥·¥ç¥ó", 19 },
2359 #else
2360         { '1', "Input Options", 3 },
2361         { '2', "Map Screen Options", 4 },
2362         { '3', "Text Display Options", 5 },
2363         { '4', "Game-Play Options", 6 },
2364         { '5', "Disturbance Options", 7 },
2365         { '6', "Easy Auto-Destroyer Options", 8 },
2366         { 'r', "Play record Options", 9 },
2367
2368         { 'p', "Auto-picker/destroyer editor", 11 },
2369         { 'd', "Base Delay Factor", 12 },
2370         { 'h', "Hitpoint Warning", 13 },
2371         { 'm', "Mana Color Threshold", 14 },
2372         { 'a', "Autosave Options", 15 },
2373         { 'w', "Window Flags", 16 },
2374
2375         { 'b', "Birth Options (Browse Only)", 18 },
2376         { 'c', "Cheat Options", 19 },
2377 #endif
2378 };
2379
2380
2381 /*
2382  * Set or unset various options.
2383  *
2384  * The user must use the "Ctrl-R" command to "adapt" to changes
2385  * in any options which control "visual" aspects of the game.
2386  */
2387 void do_cmd_options(void)
2388 {
2389         char k;
2390         int i, d, skey;
2391         int y = 0;
2392
2393         /* Save the screen */
2394         screen_save();
2395
2396         /* Interact */
2397         while (1)
2398         {
2399                 int n = OPT_NUM;
2400
2401                 /* Does not list cheat option when cheat option is off */
2402                 if (!p_ptr->noscore && !allow_debug_opts) n--;
2403
2404                 /* Clear screen */
2405                 Term_clear();
2406
2407                 /* Why are we here */
2408 #ifdef JP
2409                 prt("[ ¥ª¥×¥·¥ç¥ó¤ÎÀßÄê ]", 1, 0);
2410 #else
2411                 prt("TinyAngband options", 1, 0);
2412 #endif
2413
2414                 while(1)
2415                 {
2416                         /* Give some choices */
2417                         for (i = 0; i < n; i++)
2418                         {
2419                                 byte a = TERM_WHITE;
2420                                 if (i == y) a = TERM_L_BLUE;
2421                                 Term_putstr(5, option_fields[i].row, -1, a, 
2422                                         format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
2423                         }
2424
2425 #ifdef JP
2426                         prt("<Êý¸þ>¤Ç°ÜÆ°, Enter¤Ç·èÄê, ESC¤Ç¥­¥ã¥ó¥»¥ë, ?¤Ç¥Ø¥ë¥×: ", 21, 0);
2427 #else
2428                         prt("Move to <dir>, Select to Enter, Cancel to ESC, ? to help: ", 21, 0);
2429 #endif
2430
2431                         /* Get command */
2432                         skey = inkey_special(TRUE);
2433                         if (!(skey & SKEY_MASK)) k = (char)skey;
2434                         else k = 0;
2435
2436                         /* Exit */
2437                         if (k == ESCAPE) break;
2438
2439                         if (my_strchr("\n\r ", k))
2440                         {
2441                                 k = option_fields[y].key;
2442                                 break;
2443                         }
2444
2445                         for (i = 0; i < n; i++)
2446                         {
2447                                 if (tolower(k) == option_fields[i].key) break;
2448                         }
2449
2450                         /* Command is found */
2451                         if (i < n) break;
2452
2453                         /* Hack -- browse help */
2454                         if (k == '?') break;
2455
2456                         /* Move cursor */
2457                         d = 0;
2458                         if (skey == SKEY_UP) d = 8;
2459                         if (skey == SKEY_DOWN) d = 2;
2460                         y = (y + ddy[d] + n) % n;
2461                         if (!d) bell();
2462                 }
2463
2464                 /* Exit */
2465                 if (k == ESCAPE) break;
2466
2467                 /* Analyze */
2468                 switch (k)
2469                 {
2470                         case '1':
2471                         {
2472                                 /* Process the general options */
2473 #ifdef JP
2474                                 do_cmd_options_aux(OPT_PAGE_INPUT, "¥­¡¼ÆþÎÏ¥ª¥×¥·¥ç¥ó");
2475 #else
2476                                 do_cmd_options_aux(OPT_PAGE_INPUT, "Input Options");
2477 #endif
2478                                 break;
2479                         }
2480
2481                         case '2':
2482                         {
2483                                 /* Process the general options */
2484 #ifdef JP
2485                                 do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "¥Þ¥Ã¥×²èÌÌ¥ª¥×¥·¥ç¥ó");
2486 #else
2487                                 do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "Map Screen Options");
2488 #endif
2489                                 break;
2490                         }
2491
2492                         case '3':
2493                         {
2494                                 /* Spawn */
2495 #ifdef JP
2496                                 do_cmd_options_aux(OPT_PAGE_TEXT, "¥Æ¥­¥¹¥Èɽ¼¨¥ª¥×¥·¥ç¥ó");
2497 #else
2498                                 do_cmd_options_aux(OPT_PAGE_TEXT, "Text Display Options");
2499 #endif
2500                                 break;
2501                         }
2502
2503                         case '4':
2504                         {
2505                                 /* Spawn */
2506 #ifdef JP
2507                                 do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "¥²¡¼¥à¥×¥ì¥¤¡¦¥ª¥×¥·¥ç¥ó");
2508 #else
2509                                 do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "Game-Play Options");
2510 #endif
2511                                 break;
2512                         }
2513
2514                         case '5':
2515                         {
2516                                 /* Spawn */
2517 #ifdef JP
2518                                 do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "¹ÔÆ°Ãæ»ß´Ø·¸¤Î¥ª¥×¥·¥ç¥ó");
2519 #else
2520                                 do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "Disturbance Options");
2521 #endif
2522                                 break;
2523                         }
2524
2525                         case '6':
2526                         {
2527                                 /* Spawn */
2528 #ifdef JP
2529                                 do_cmd_options_aux(OPT_PAGE_AUTODESTROY, "´Ê°×¼«Æ°Ç˲õ¥ª¥×¥·¥ç¥ó");
2530 #else
2531                                 do_cmd_options_aux(OPT_PAGE_AUTODESTROY, "Easy Auto-Destroyer Options");
2532 #endif
2533                                 break;
2534                         }
2535
2536                         /* Play-record Options */
2537                         case 'R':
2538                         case 'r':
2539                         {
2540                                 /* Spawn */
2541 #ifdef JP
2542                                 do_cmd_options_aux(OPT_PAGE_PLAYRECORD, "¥×¥ì¥¤µ­Ï¿¥ª¥×¥·¥ç¥ó");
2543 #else
2544                                 do_cmd_options_aux(OPT_PAGE_PLAYRECORD, "Play-record Options");
2545 #endif
2546                                 break;
2547                         }
2548
2549                         /* Birth Options */
2550                         case 'B':
2551                         case 'b':
2552                         {
2553                                 /* Spawn */
2554 #ifdef JP
2555                                 do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "½é´ü¥ª¥×¥·¥ç¥ó(»²¾È¤Î¤ß)" : "½é´ü¥ª¥×¥·¥ç¥ó((*)¤Ï¥¹¥³¥¢¤Ë±Æ¶Á)");
2556 #else
2557                                 do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "Birth Options(browse only)" : "Birth Options((*)s effect score)");
2558 #endif
2559                                 break;
2560                         }
2561
2562                         /* Cheating Options */
2563                         case 'C':
2564                         {
2565                                 if (!p_ptr->noscore && !allow_debug_opts)
2566                                 {
2567                                         /* Cheat options are not permitted */
2568                                         bell();
2569                                         break;
2570                                 }
2571
2572                                 /* Spawn */
2573 #ifdef JP
2574                                 do_cmd_options_cheat("º¾µ½»Õ¤Ï·è¤·¤Æ¾¡Íø¤Ç¤­¤Ê¤¤¡ª");
2575 #else
2576                                 do_cmd_options_cheat("Cheaters never win");
2577 #endif
2578                                 break;
2579                         }
2580
2581                         case 'a':
2582                         case 'A':
2583                         {
2584 #ifdef JP
2585                                 do_cmd_options_autosave("¼«Æ°¥»¡¼¥Ö");
2586 #else
2587                                 do_cmd_options_autosave("Autosave");
2588 #endif
2589                                 break;
2590                         }
2591
2592                         /* Window flags */
2593                         case 'W':
2594                         case 'w':
2595                         {
2596                                 /* Spawn */
2597                                 do_cmd_options_win();
2598                                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL |
2599                                                   PW_PLAYER | PW_MESSAGE | PW_OVERHEAD |
2600                                                   PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
2601                                                   PW_BORG_1 | PW_BORG_2 | PW_DUNGEON);
2602                                 break;
2603                         }
2604
2605                         /* Auto-picker/destroyer editor */
2606                         case 'P':
2607                         case 'p':
2608                         {
2609                                 do_cmd_edit_autopick();
2610                                 break;
2611                         }
2612
2613                         /* Hack -- Delay Speed */
2614                         case 'D':
2615                         case 'd':
2616                         {
2617                                 /* Prompt */
2618                                 clear_from(18);
2619 #ifdef JP
2620                                 prt("¥³¥Þ¥ó¥É: ´ðËÜ¥¦¥§¥¤¥ÈÎÌ", 19, 0);
2621 #else
2622                                 prt("Command: Base Delay Factor", 19, 0);
2623 #endif
2624
2625                                 /* Get a new value */
2626                                 while (1)
2627                                 {
2628                                         int msec = delay_factor * delay_factor * delay_factor;
2629 #ifdef JP
2630                                         prt(format("¸½ºß¤Î¥¦¥§¥¤¥È: %d (%d¥ß¥êÉÃ)",
2631                                                    delay_factor, msec), 22, 0);
2632 #else
2633                                         prt(format("Current base delay factor: %d (%d msec)",
2634                                                    delay_factor, msec), 22, 0);
2635 #endif
2636
2637 #ifdef JP
2638                                         prt("¥¦¥§¥¤¥È (0-9) ESC¤Ç·èÄê: ", 20, 0);
2639 #else
2640                                         prt("Delay Factor (0-9 or ESC to accept): ", 20, 0);
2641 #endif
2642
2643                                         k = inkey();
2644                                         if (k == ESCAPE) break;
2645                                         else if (k == '?')
2646                                         {
2647 #ifdef JP
2648                                                 (void)show_file(TRUE, "joption.txt#BaseDelay", NULL, 0, 0);
2649 #else
2650                                                 (void)show_file(TRUE, "option.txt#BaseDelay", NULL, 0, 0);
2651 #endif
2652                                                 Term_clear(); 
2653                                         }
2654                                         else if (isdigit(k)) delay_factor = D2I(k);
2655                                         else bell();
2656                                 }
2657
2658                                 break;
2659                         }
2660
2661                         /* Hack -- hitpoint warning factor */
2662                         case 'H':
2663                         case 'h':
2664                         {
2665                                 /* Prompt */
2666                                 clear_from(18);
2667 #ifdef JP
2668                                 prt("¥³¥Þ¥ó¥É: Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð", 19, 0);
2669 #else
2670                                 prt("Command: Hitpoint Warning", 19, 0);
2671 #endif
2672
2673                                 /* Get a new value */
2674                                 while (1)
2675                                 {
2676 #ifdef JP
2677                                         prt(format("¸½ºß¤ÎÄã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð: %d0%%",
2678                                                    hitpoint_warn), 22, 0);
2679 #else
2680                                         prt(format("Current hitpoint warning: %d0%%",
2681                                                    hitpoint_warn), 22, 0);
2682 #endif
2683
2684 #ifdef JP
2685                                         prt("Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð (0-9) ESC¤Ç·èÄê: ", 20, 0);
2686 #else
2687                                         prt("Hitpoint Warning (0-9 or ESC to accept): ", 20, 0);
2688 #endif
2689
2690                                         k = inkey();
2691                                         if (k == ESCAPE) break;
2692                                         else if (k == '?')
2693                                         {
2694 #ifdef JP
2695                                                 (void)show_file(TRUE, "joption.txt#Hitpoint", NULL, 0, 0);
2696 #else
2697                                                 (void)show_file(TRUE, "option.txt#Hitpoint", NULL, 0, 0);
2698 #endif
2699                                                 Term_clear(); 
2700                                         }
2701                                         else if (isdigit(k)) hitpoint_warn = D2I(k);
2702                                         else bell();
2703                                 }
2704
2705                                 break;
2706                         }
2707
2708                         /* Hack -- mana color factor */
2709                         case 'M':
2710                         case 'm':
2711                         {
2712                                 /* Prompt */
2713                                 clear_from(18);
2714 #ifdef JP
2715                                 prt("¥³¥Þ¥ó¥É: ÄãËâÎÏ¿§ïçÃÍ", 19, 0);
2716 #else
2717                                 prt("Command: Mana Color Threshold", 19, 0);
2718 #endif
2719
2720                                 /* Get a new value */
2721                                 while (1)
2722                                 {
2723 #ifdef JP
2724                                         prt(format("¸½ºß¤ÎÄãËâÎÏ¿§ïçÃÍ: %d0%%",
2725                                                    mana_warn), 22, 0);
2726 #else
2727                                         prt(format("Current mana color threshold: %d0%%",
2728                                                    mana_warn), 22, 0);
2729 #endif
2730
2731 #ifdef JP
2732                                         prt("ÄãËâÎÏïçÃÍ (0-9) ESC¤Ç·èÄê: ", 20, 0);
2733 #else
2734                                         prt("Mana color Threshold (0-9 or ESC to accept): ", 20, 0);
2735 #endif
2736
2737                                         k = inkey();
2738                                         if (k == ESCAPE) break;
2739                                         else if (k == '?')
2740                                         {
2741 #ifdef JP
2742                                                 (void)show_file(TRUE, "joption.txt#Manapoint", NULL, 0, 0);
2743 #else
2744                                                 (void)show_file(TRUE, "option.txt#Manapoint", NULL, 0, 0);
2745 #endif
2746                                                 Term_clear(); 
2747                                         }
2748                                         else if (isdigit(k)) mana_warn = D2I(k);
2749                                         else bell();
2750                                 }
2751
2752                                 break;
2753                         }
2754
2755                         case '?':
2756 #ifdef JP
2757                                 (void)show_file(TRUE, "joption.txt", NULL, 0, 0);
2758 #else
2759                                 (void)show_file(TRUE, "option.txt", NULL, 0, 0);
2760 #endif
2761                                 Term_clear(); 
2762                                 break;
2763
2764                         /* Unknown option */
2765                         default:
2766                         {
2767                                 /* Oops */
2768                                 bell();
2769                                 break;
2770                         }
2771                 }
2772
2773                 /* Flush messages */
2774                 msg_print(NULL);
2775         }
2776
2777
2778         /* Restore the screen */
2779         screen_load();
2780
2781         /* Hack - Redraw equippy chars */
2782         p_ptr->redraw |= (PR_EQUIPPY);
2783 }
2784
2785
2786
2787 /*
2788  * Ask for a "user pref line" and process it
2789  *
2790  * XXX XXX XXX Allow absolute file names?
2791  */
2792 void do_cmd_pref(void)
2793 {
2794         char buf[80];
2795
2796         /* Default */
2797         strcpy(buf, "");
2798
2799         /* Ask for a "user pref command" */
2800 #ifdef JP
2801         if (!get_string("ÀßÄêÊѹ¹¥³¥Þ¥ó¥É: ", buf, 80)) return;
2802 #else
2803         if (!get_string("Pref: ", buf, 80)) return;
2804 #endif
2805
2806
2807         /* Process that pref command */
2808         (void)process_pref_file_command(buf);
2809 }
2810
2811 void do_cmd_reload_autopick(void)
2812 {
2813 #ifdef JP
2814         if (!get_check("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return;
2815 #else
2816         if (!get_check("Reload auto-pick preference file? ")) return;
2817 #endif
2818
2819         /* Load the file with messages */
2820         autopick_load_pref(TRUE);
2821 }
2822
2823 #ifdef ALLOW_MACROS
2824
2825 /*
2826  * Hack -- append all current macros to the given file
2827  */
2828 static errr macro_dump(cptr fname)
2829 {
2830         static cptr mark = "Macro Dump";
2831
2832         int i;
2833
2834         char buf[1024];
2835
2836         /* Build the filename */
2837         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2838
2839         /* File type is "TEXT" */
2840         FILE_TYPE(FILE_TYPE_TEXT);
2841
2842         /* Append to the file */
2843         if (!open_auto_dump(buf, mark)) return (-1);
2844
2845         /* Start dumping */
2846 #ifdef JP
2847         auto_dump_printf("\n# ¼«Æ°¥Þ¥¯¥í¥»¡¼¥Ö\n\n");
2848 #else
2849         auto_dump_printf("\n# Automatic macro dump\n\n");
2850 #endif
2851
2852         /* Dump them */
2853         for (i = 0; i < macro__num; i++)
2854         {
2855                 /* Extract the action */
2856                 ascii_to_text(buf, macro__act[i]);
2857
2858                 /* Dump the macro */
2859                 auto_dump_printf("A:%s\n", buf);
2860
2861                 /* Extract the action */
2862                 ascii_to_text(buf, macro__pat[i]);
2863
2864                 /* Dump normal macros */
2865                 auto_dump_printf("P:%s\n", buf);
2866
2867                 /* End the macro */
2868                 auto_dump_printf("\n");
2869         }
2870
2871         /* Close */
2872         close_auto_dump();
2873
2874         /* Success */
2875         return (0);
2876 }
2877
2878
2879 /*
2880  * Hack -- ask for a "trigger" (see below)
2881  *
2882  * Note the complex use of the "inkey()" function from "util.c".
2883  *
2884  * Note that both "flush()" calls are extremely important.
2885  */
2886 static void do_cmd_macro_aux(char *buf)
2887 {
2888         int i, n = 0;
2889
2890         char tmp[1024];
2891
2892
2893         /* Flush */
2894         flush();
2895
2896         /* Do not process macros */
2897         inkey_base = TRUE;
2898
2899         /* First key */
2900         i = inkey();
2901
2902         /* Read the pattern */
2903         while (i)
2904         {
2905                 /* Save the key */
2906                 buf[n++] = i;
2907
2908                 /* Do not process macros */
2909                 inkey_base = TRUE;
2910
2911                 /* Do not wait for keys */
2912                 inkey_scan = TRUE;
2913
2914                 /* Attempt to read a key */
2915                 i = inkey();
2916         }
2917
2918         /* Terminate */
2919         buf[n] = '\0';
2920
2921         /* Flush */
2922         flush();
2923
2924
2925         /* Convert the trigger */
2926         ascii_to_text(tmp, buf);
2927
2928         /* Hack -- display the trigger */
2929         Term_addstr(-1, TERM_WHITE, tmp);
2930 }
2931
2932 #endif
2933
2934
2935 /*
2936  * Hack -- ask for a keymap "trigger" (see below)
2937  *
2938  * Note that both "flush()" calls are extremely important.  This may
2939  * no longer be true, since "util.c" is much simpler now.  XXX XXX XXX
2940  */
2941 static void do_cmd_macro_aux_keymap(char *buf)
2942 {
2943         char tmp[1024];
2944
2945
2946         /* Flush */
2947         flush();
2948
2949
2950         /* Get a key */
2951         buf[0] = inkey();
2952         buf[1] = '\0';
2953
2954
2955         /* Convert to ascii */
2956         ascii_to_text(tmp, buf);
2957
2958         /* Hack -- display the trigger */
2959         Term_addstr(-1, TERM_WHITE, tmp);
2960
2961
2962         /* Flush */
2963         flush();
2964 }
2965
2966
2967 /*
2968  * Hack -- append all keymaps to the given file
2969  */
2970 static errr keymap_dump(cptr fname)
2971 {
2972         static cptr mark = "Keymap Dump";
2973         int i;
2974
2975         char key[1024];
2976         char buf[1024];
2977
2978         int mode;
2979
2980         /* Roguelike */
2981         if (rogue_like_commands)
2982         {
2983                 mode = KEYMAP_MODE_ROGUE;
2984         }
2985
2986         /* Original */
2987         else
2988         {
2989                 mode = KEYMAP_MODE_ORIG;
2990         }
2991
2992
2993         /* Build the filename */
2994         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2995
2996         /* File type is "TEXT" */
2997         FILE_TYPE(FILE_TYPE_TEXT);
2998
2999         /* Append to the file */
3000         if (!open_auto_dump(buf, mark)) return -1;
3001
3002         /* Start dumping */
3003 #ifdef JP
3004         auto_dump_printf("\n# ¼«Æ°¥­¡¼ÇÛÃÖ¥»¡¼¥Ö\n\n");
3005 #else
3006         auto_dump_printf("\n# Automatic keymap dump\n\n");
3007 #endif
3008
3009         /* Dump them */
3010         for (i = 0; i < 256; i++)
3011         {
3012                 cptr act;
3013
3014                 /* Loop up the keymap */
3015                 act = keymap_act[mode][i];
3016
3017                 /* Skip empty keymaps */
3018                 if (!act) continue;
3019
3020                 /* Encode the key */
3021                 buf[0] = i;
3022                 buf[1] = '\0';
3023                 ascii_to_text(key, buf);
3024
3025                 /* Encode the action */
3026                 ascii_to_text(buf, act);
3027
3028                 /* Dump the macro */
3029                 auto_dump_printf("A:%s\n", buf);
3030                 auto_dump_printf("C:%d:%s\n", mode, key);
3031         }
3032
3033         /* Close */
3034         close_auto_dump();
3035
3036         /* Success */
3037         return (0);
3038 }
3039
3040
3041
3042 /*
3043  * Interact with "macros"
3044  *
3045  * Note that the macro "action" must be defined before the trigger.
3046  *
3047  * Could use some helpful instructions on this page.  XXX XXX XXX
3048  */
3049 void do_cmd_macros(void)
3050 {
3051         int i;
3052
3053         char tmp[1024];
3054
3055         char buf[1024];
3056
3057         int mode;
3058
3059
3060         /* Roguelike */
3061         if (rogue_like_commands)
3062         {
3063                 mode = KEYMAP_MODE_ROGUE;
3064         }
3065
3066         /* Original */
3067         else
3068         {
3069                 mode = KEYMAP_MODE_ORIG;
3070         }
3071
3072         /* File type is "TEXT" */
3073         FILE_TYPE(FILE_TYPE_TEXT);
3074
3075
3076         /* Save screen */
3077         screen_save();
3078
3079
3080         /* Process requests until done */
3081         while (1)
3082         {
3083                 /* Clear screen */
3084                 Term_clear();
3085
3086                 /* Describe */
3087 #ifdef JP
3088                 prt("[ ¥Þ¥¯¥í¤ÎÀßÄê ]", 2, 0);
3089 #else
3090                 prt("Interact with Macros", 2, 0);
3091 #endif
3092
3093
3094
3095                 /* Describe that action */
3096 #ifdef JP
3097                 prt("¥Þ¥¯¥í¹ÔÆ°¤¬(¤â¤·¤¢¤ì¤Ð)²¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹:", 20, 0);
3098 #else
3099                 prt("Current action (if any) shown below:", 20, 0);
3100 #endif
3101
3102
3103                 /* Analyze the current action */
3104                 ascii_to_text(buf, macro__buf);
3105
3106                 /* Display the current action */
3107                 prt(buf, 22, 0);
3108
3109
3110                 /* Selections */
3111 #ifdef JP
3112                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
3113 #else
3114                 prt("(1) Load a user pref file", 4, 5);
3115 #endif
3116
3117 #ifdef ALLOW_MACROS
3118 #ifdef JP
3119                 prt("(2) ¥Õ¥¡¥¤¥ë¤Ë¥Þ¥¯¥í¤òÄɲÃ", 5, 5);
3120                 prt("(3) ¥Þ¥¯¥í¤Î³Îǧ", 6, 5);
3121                 prt("(4) ¥Þ¥¯¥í¤ÎºîÀ®", 7, 5);
3122                 prt("(5) ¥Þ¥¯¥í¤Îºï½ü", 8, 5);
3123                 prt("(6) ¥Õ¥¡¥¤¥ë¤Ë¥­¡¼ÇÛÃÖ¤òÄɲÃ", 9, 5);
3124                 prt("(7) ¥­¡¼ÇÛÃ֤γÎǧ", 10, 5);
3125                 prt("(8) ¥­¡¼ÇÛÃ֤κîÀ®", 11, 5);
3126                 prt("(9) ¥­¡¼ÇÛÃ֤κï½ü", 12, 5);
3127                 prt("(0) ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 13, 5);
3128 #else
3129                 prt("(2) Append macros to a file", 5, 5);
3130                 prt("(3) Query a macro", 6, 5);
3131                 prt("(4) Create a macro", 7, 5);
3132                 prt("(5) Remove a macro", 8, 5);
3133                 prt("(6) Append keymaps to a file", 9, 5);
3134                 prt("(7) Query a keymap", 10, 5);
3135                 prt("(8) Create a keymap", 11, 5);
3136                 prt("(9) Remove a keymap", 12, 5);
3137                 prt("(0) Enter a new action", 13, 5);
3138 #endif
3139
3140 #endif /* ALLOW_MACROS */
3141
3142                 /* Prompt */
3143 #ifdef JP
3144                 prt("¥³¥Þ¥ó¥É: ", 16, 0);
3145 #else
3146                 prt("Command: ", 16, 0);
3147 #endif
3148
3149
3150                 /* Get a command */
3151                 i = inkey();
3152
3153                 /* Leave */
3154                 if (i == ESCAPE) break;
3155
3156                 /* Load a 'macro' file */
3157                 else if (i == '1')
3158                 {
3159                         errr err;
3160
3161                         /* Prompt */
3162 #ifdef JP
3163                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 16, 0);
3164 #else
3165                         prt("Command: Load a user pref file", 16, 0);
3166 #endif
3167
3168
3169                         /* Prompt */
3170 #ifdef JP
3171                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3172 #else
3173                         prt("File: ", 18, 0);
3174 #endif
3175
3176
3177                         /* Default filename */
3178                         sprintf(tmp, "%s.prf", player_base);
3179
3180                         /* Ask for a file */
3181                         if (!askfor(tmp, 80)) continue;
3182
3183                         /* Process the given filename */
3184                         err = process_pref_file(tmp);
3185                         if (-2 == err)
3186                         {
3187 #ifdef JP
3188                                 msg_format("ɸ½à¤ÎÀßÄê¥Õ¥¡¥¤¥ë'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
3189 #else
3190                                 msg_format("Loaded default '%s'.", tmp);
3191 #endif
3192                         }
3193                         else if (err)
3194                         {
3195                                 /* Prompt */
3196 #ifdef JP
3197                                 msg_format("'%s'¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", tmp);
3198 #else
3199                                 msg_format("Failed to load '%s'!");
3200 #endif
3201                         }
3202                         else
3203                         {
3204 #ifdef JP
3205                                 msg_format("'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
3206 #else
3207                                 msg_format("Loaded '%s'.", tmp);
3208 #endif
3209                         }
3210                 }
3211
3212 #ifdef ALLOW_MACROS
3213
3214                 /* Save macros */
3215                 else if (i == '2')
3216                 {
3217                         /* Prompt */
3218 #ifdef JP
3219                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤ò¥Õ¥¡¥¤¥ë¤ËÄɲ乤ë", 16, 0);
3220 #else
3221                         prt("Command: Append macros to a file", 16, 0);
3222 #endif
3223
3224
3225                         /* Prompt */
3226 #ifdef JP
3227                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3228 #else
3229                         prt("File: ", 18, 0);
3230 #endif
3231
3232
3233                         /* Default filename */
3234                         sprintf(tmp, "%s.prf", player_base);
3235
3236                         /* Ask for a file */
3237                         if (!askfor(tmp, 80)) continue;
3238
3239                         /* Dump the macros */
3240                         (void)macro_dump(tmp);
3241
3242                         /* Prompt */
3243 #ifdef JP
3244                         msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
3245 #else
3246                         msg_print("Appended macros.");
3247 #endif
3248
3249                 }
3250
3251                 /* Query a macro */
3252                 else if (i == '3')
3253                 {
3254                         int k;
3255
3256                         /* Prompt */
3257 #ifdef JP
3258                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤Î³Îǧ", 16, 0);
3259 #else
3260                         prt("Command: Query a macro", 16, 0);
3261 #endif
3262
3263
3264                         /* Prompt */
3265 #ifdef JP
3266                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3267 #else
3268                         prt("Trigger: ", 18, 0);
3269 #endif
3270
3271
3272                         /* Get a macro trigger */
3273                         do_cmd_macro_aux(buf);
3274
3275                         /* Acquire action */
3276                         k = macro_find_exact(buf);
3277
3278                         /* Nothing found */
3279                         if (k < 0)
3280                         {
3281                                 /* Prompt */
3282 #ifdef JP
3283                                 msg_print("¤½¤Î¥­¡¼¤Ë¤Ï¥Þ¥¯¥í¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
3284 #else
3285                                 msg_print("Found no macro.");
3286 #endif
3287
3288                         }
3289
3290                         /* Found one */
3291                         else
3292                         {
3293                                 /* Obtain the action */
3294                                 strcpy(macro__buf, macro__act[k]);
3295
3296                                 /* Analyze the current action */
3297                                 ascii_to_text(buf, macro__buf);
3298
3299                                 /* Display the current action */
3300                                 prt(buf, 22, 0);
3301
3302                                 /* Prompt */
3303 #ifdef JP
3304                                 msg_print("¥Þ¥¯¥í¤ò³Îǧ¤·¤Þ¤·¤¿¡£");
3305 #else
3306                                 msg_print("Found a macro.");
3307 #endif
3308
3309                         }
3310                 }
3311
3312                 /* Create a macro */
3313                 else if (i == '4')
3314                 {
3315                         /* Prompt */
3316 #ifdef JP
3317                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤ÎºîÀ®", 16, 0);
3318 #else
3319                         prt("Command: Create a macro", 16, 0);
3320 #endif
3321
3322
3323                         /* Prompt */
3324 #ifdef JP
3325                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3326 #else
3327                         prt("Trigger: ", 18, 0);
3328 #endif
3329
3330
3331                         /* Get a macro trigger */
3332                         do_cmd_macro_aux(buf);
3333
3334                         /* Clear */
3335                         clear_from(20);
3336
3337                         /* Help message */
3338 #ifdef JP
3339                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3340 #else
3341                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3342 #endif
3343
3344                         /* Prompt */
3345 #ifdef JP
3346                         prt("¥Þ¥¯¥í¹ÔÆ°: ", 20, 0);
3347 #else
3348                         prt("Action: ", 20, 0);
3349 #endif
3350
3351
3352                         /* Convert to text */
3353                         ascii_to_text(tmp, macro__buf);
3354
3355                         /* Get an encoded action */
3356                         if (askfor(tmp, 80))
3357                         {
3358                                 /* Convert to ascii */
3359                                 text_to_ascii(macro__buf, tmp);
3360
3361                                 /* Link the macro */
3362                                 macro_add(buf, macro__buf);
3363
3364                                 /* Prompt */
3365 #ifdef JP
3366                                 msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
3367 #else
3368                                 msg_print("Added a macro.");
3369 #endif
3370
3371                         }
3372                 }
3373
3374                 /* Remove a macro */
3375                 else if (i == '5')
3376                 {
3377                         /* Prompt */
3378 #ifdef JP
3379                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤Îºï½ü", 16, 0);
3380 #else
3381                         prt("Command: Remove a macro", 16, 0);
3382 #endif
3383
3384
3385                         /* Prompt */
3386 #ifdef JP
3387                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3388 #else
3389                         prt("Trigger: ", 18, 0);
3390 #endif
3391
3392
3393                         /* Get a macro trigger */
3394                         do_cmd_macro_aux(buf);
3395
3396                         /* Link the macro */
3397                         macro_add(buf, buf);
3398
3399                         /* Prompt */
3400 #ifdef JP
3401                         msg_print("¥Þ¥¯¥í¤òºï½ü¤·¤Þ¤·¤¿¡£");
3402 #else
3403                         msg_print("Removed a macro.");
3404 #endif
3405
3406                 }
3407
3408                 /* Save keymaps */
3409                 else if (i == '6')
3410                 {
3411                         /* Prompt */
3412 #ifdef JP
3413                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃÖ¤ò¥Õ¥¡¥¤¥ë¤ËÄɲ乤ë", 16, 0);
3414 #else
3415                         prt("Command: Append keymaps to a file", 16, 0);
3416 #endif
3417
3418
3419                         /* Prompt */
3420 #ifdef JP
3421                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3422 #else
3423                         prt("File: ", 18, 0);
3424 #endif
3425
3426
3427                         /* Default filename */
3428                         sprintf(tmp, "%s.prf", player_base);
3429
3430                         /* Ask for a file */
3431                         if (!askfor(tmp, 80)) continue;
3432
3433                         /* Dump the macros */
3434                         (void)keymap_dump(tmp);
3435
3436                         /* Prompt */
3437 #ifdef JP
3438                         msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
3439 #else
3440                         msg_print("Appended keymaps.");
3441 #endif
3442
3443                 }
3444
3445                 /* Query a keymap */
3446                 else if (i == '7')
3447                 {
3448                         cptr act;
3449
3450                         /* Prompt */
3451 #ifdef JP
3452                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤γÎǧ", 16, 0);
3453 #else
3454                         prt("Command: Query a keymap", 16, 0);
3455 #endif
3456
3457
3458                         /* Prompt */
3459 #ifdef JP
3460                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3461 #else
3462                         prt("Keypress: ", 18, 0);
3463 #endif
3464
3465
3466                         /* Get a keymap trigger */
3467                         do_cmd_macro_aux_keymap(buf);
3468
3469                         /* Look up the keymap */
3470                         act = keymap_act[mode][(byte)(buf[0])];
3471
3472                         /* Nothing found */
3473                         if (!act)
3474                         {
3475                                 /* Prompt */
3476 #ifdef JP
3477                                 msg_print("¥­¡¼ÇÛÃÖ¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
3478 #else
3479                                 msg_print("Found no keymap.");
3480 #endif
3481
3482                         }
3483
3484                         /* Found one */
3485                         else
3486                         {
3487                                 /* Obtain the action */
3488                                 strcpy(macro__buf, act);
3489
3490                                 /* Analyze the current action */
3491                                 ascii_to_text(buf, macro__buf);
3492
3493                                 /* Display the current action */
3494                                 prt(buf, 22, 0);
3495
3496                                 /* Prompt */
3497 #ifdef JP
3498                                 msg_print("¥­¡¼ÇÛÃÖ¤ò³Îǧ¤·¤Þ¤·¤¿¡£");
3499 #else
3500                                 msg_print("Found a keymap.");
3501 #endif
3502
3503                         }
3504                 }
3505
3506                 /* Create a keymap */
3507                 else if (i == '8')
3508                 {
3509                         /* Prompt */
3510 #ifdef JP
3511                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤κîÀ®", 16, 0);
3512 #else
3513                         prt("Command: Create a keymap", 16, 0);
3514 #endif
3515
3516
3517                         /* Prompt */
3518 #ifdef JP
3519                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3520 #else
3521                         prt("Keypress: ", 18, 0);
3522 #endif
3523
3524
3525                         /* Get a keymap trigger */
3526                         do_cmd_macro_aux_keymap(buf);
3527
3528                         /* Clear */
3529                         clear_from(20);
3530
3531                         /* Help message */
3532 #ifdef JP
3533                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3534 #else
3535                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3536 #endif
3537
3538                         /* Prompt */
3539 #ifdef JP
3540                         prt("¹ÔÆ°: ", 20, 0);
3541 #else
3542                         prt("Action: ", 20, 0);
3543 #endif
3544
3545
3546                         /* Convert to text */
3547                         ascii_to_text(tmp, macro__buf);
3548
3549                         /* Get an encoded action */
3550                         if (askfor(tmp, 80))
3551                         {
3552                                 /* Convert to ascii */
3553                                 text_to_ascii(macro__buf, tmp);
3554
3555                                 /* Free old keymap */
3556                                 string_free(keymap_act[mode][(byte)(buf[0])]);
3557
3558                                 /* Make new keymap */
3559                                 keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
3560
3561                                 /* Prompt */
3562 #ifdef JP
3563                                 msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
3564 #else
3565                                 msg_print("Added a keymap.");
3566 #endif
3567
3568                         }
3569                 }
3570
3571                 /* Remove a keymap */
3572                 else if (i == '9')
3573                 {
3574                         /* Prompt */
3575 #ifdef JP
3576                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤κï½ü", 16, 0);
3577 #else
3578                         prt("Command: Remove a keymap", 16, 0);
3579 #endif
3580
3581
3582                         /* Prompt */
3583 #ifdef JP
3584                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3585 #else
3586                         prt("Keypress: ", 18, 0);
3587 #endif
3588
3589
3590                         /* Get a keymap trigger */
3591                         do_cmd_macro_aux_keymap(buf);
3592
3593                         /* Free old keymap */
3594                         string_free(keymap_act[mode][(byte)(buf[0])]);
3595
3596                         /* Make new keymap */
3597                         keymap_act[mode][(byte)(buf[0])] = NULL;
3598
3599                         /* Prompt */
3600 #ifdef JP
3601                         msg_print("¥­¡¼ÇÛÃÖ¤òºï½ü¤·¤Þ¤·¤¿¡£");
3602 #else
3603                         msg_print("Removed a keymap.");
3604 #endif
3605
3606                 }
3607
3608                 /* Enter a new action */
3609                 else if (i == '0')
3610                 {
3611                         /* Prompt */
3612 #ifdef JP
3613                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 16, 0);
3614 #else
3615                         prt("Command: Enter a new action", 16, 0);
3616 #endif
3617
3618                         /* Clear */
3619                         clear_from(20);
3620
3621                         /* Help message */
3622 #ifdef JP
3623                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3624 #else
3625                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3626 #endif
3627
3628                         /* Prompt */
3629 #ifdef JP
3630                         prt("¥Þ¥¯¥í¹ÔÆ°: ", 20, 0);
3631 #else
3632                         prt("Action: ", 20, 0);
3633 #endif
3634
3635                         /* Hack -- limit the value */
3636                         tmp[80] = '\0';
3637
3638                         /* Get an encoded action */
3639                         if (!askfor(buf, 80)) continue;
3640
3641                         /* Extract an action */
3642                         text_to_ascii(macro__buf, buf);
3643                 }
3644
3645 #endif /* ALLOW_MACROS */
3646
3647                 /* Oops */
3648                 else
3649                 {
3650                         /* Oops */
3651                         bell();
3652                 }
3653
3654                 /* Flush messages */
3655                 msg_print(NULL);
3656         }
3657
3658         /* Load screen */
3659         screen_load();
3660 }
3661
3662
3663 static cptr lighting_level_str[F_LIT_MAX] =
3664 {
3665 #ifdef JP
3666         "ɸ½à¿§",
3667         "ÌÀ¿§",
3668         "°Å¿§",
3669 #else
3670         "standard",
3671         "brightly lit",
3672         "darkened",
3673 #endif
3674 };
3675
3676
3677 static bool cmd_visuals_aux(int i, int *num, int max)
3678 {
3679         if (iscntrl(i))
3680         {
3681                 char str[10] = "";
3682                 int tmp;
3683
3684                 sprintf(str, "%d", *num);
3685
3686                 if (!get_string(format("Input new number(0-%d): ", max-1), str, 4))
3687                         return FALSE;
3688
3689                 tmp = strtol(str, NULL, 0);
3690                 if (tmp >= 0 && tmp < max)
3691                         *num = tmp;
3692         }
3693         else if (isupper(i))
3694                 *num = (*num + max - 1) % max;
3695         else
3696                 *num = (*num + 1) % max;
3697
3698         return TRUE;
3699 }
3700
3701 static void print_visuals_menu(cptr choice_msg)
3702 {
3703 #ifdef JP
3704         prt("[ ²èÌÌɽ¼¨¤ÎÀßÄê ]", 1, 0);
3705 #else
3706         prt("Interact with Visuals", 1, 0);
3707 #endif
3708
3709         /* Give some choices */
3710 #ifdef JP
3711         prt("(0) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 3, 5);
3712 #else
3713         prt("(0) Load a user pref file", 3, 5);
3714 #endif
3715
3716 #ifdef ALLOW_VISUALS
3717 #ifdef JP
3718         prt("(1) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 4, 5);
3719         prt("(2) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
3720         prt("(3) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 6, 5);
3721         prt("(4) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 7, 5);
3722         prt("(5) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 8, 5);
3723         prt("(6) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 9, 5);
3724         prt("(7) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 10, 5);
3725         prt("(8) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 11, 5);
3726         prt("(9) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 12, 5);
3727 #else
3728         prt("(1) Dump monster attr/chars", 4, 5);
3729         prt("(2) Dump object attr/chars", 5, 5);
3730         prt("(3) Dump feature attr/chars", 6, 5);
3731         prt("(4) Change monster attr/chars (numeric operation)", 7, 5);
3732         prt("(5) Change object attr/chars (numeric operation)", 8, 5);
3733         prt("(6) Change feature attr/chars (numeric operation)", 9, 5);
3734         prt("(7) Change monster attr/chars (visual mode)", 10, 5);
3735         prt("(8) Change object attr/chars (visual mode)", 11, 5);
3736         prt("(9) Change feature attr/chars (visual mode)", 12, 5);
3737 #endif
3738
3739 #endif /* ALLOW_VISUALS */
3740
3741 #ifdef JP
3742         prt("(R) ²èÌÌɽ¼¨ÊýË¡¤Î½é´ü²½", 13, 5);
3743 #else
3744         prt("(R) Reset visuals", 13, 5);
3745 #endif
3746
3747         /* Prompt */
3748 #ifdef JP
3749         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg ? choice_msg : ""), 15, 0);
3750 #else
3751         prt(format("Command: %s", choice_msg ? choice_msg : ""), 15, 0);
3752 #endif
3753 }
3754
3755 static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int direct_r_idx);
3756 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int direct_k_idx);
3757 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int direct_f_idx, int *lighting_level);
3758
3759 /*
3760  * Interact with "visuals"
3761  */
3762 void do_cmd_visuals(void)
3763 {
3764         int i;
3765         char tmp[160];
3766         char buf[1024];
3767         bool need_redraw = FALSE;
3768         const char *empty_symbol = "<< ? >>";
3769
3770         if (use_bigtile) empty_symbol = "<< ?? >>";
3771
3772         /* File type is "TEXT" */
3773         FILE_TYPE(FILE_TYPE_TEXT);
3774
3775         /* Save the screen */
3776         screen_save();
3777
3778         /* Interact until done */
3779         while (1)
3780         {
3781                 /* Clear screen */
3782                 Term_clear();
3783
3784                 /* Ask for a choice */
3785                 print_visuals_menu(NULL);
3786
3787                 /* Prompt */
3788                 i = inkey();
3789
3790                 /* Done */
3791                 if (i == ESCAPE) break;
3792
3793                 switch (i)
3794                 {
3795                 /* Load a 'pref' file */
3796                 case '0':
3797                         /* Prompt */
3798 #ifdef JP
3799                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 15, 0);
3800 #else
3801                         prt("Command: Load a user pref file", 15, 0);
3802 #endif
3803
3804                         /* Prompt */
3805 #ifdef JP
3806                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3807 #else
3808                         prt("File: ", 17, 0);
3809 #endif
3810
3811                         /* Default filename */
3812                         sprintf(tmp, "%s.prf", player_base);
3813
3814                         /* Query */
3815                         if (!askfor(tmp, 70)) continue;
3816
3817                         /* Process the given filename */
3818                         (void)process_pref_file(tmp);
3819
3820                         need_redraw = TRUE;
3821                         break;
3822
3823 #ifdef ALLOW_VISUALS
3824
3825                 /* Dump monster attr/chars */
3826                 case '1':
3827                 {
3828                         static cptr mark = "Monster attr/chars";
3829
3830                         /* Prompt */
3831 #ifdef JP
3832                         prt("¥³¥Þ¥ó¥É: ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3833 #else
3834                         prt("Command: Dump monster attr/chars", 15, 0);
3835 #endif
3836
3837                         /* Prompt */
3838 #ifdef JP
3839                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3840 #else
3841                         prt("File: ", 17, 0);
3842 #endif
3843
3844                         /* Default filename */
3845                         sprintf(tmp, "%s.prf", player_base);
3846
3847                         /* Get a filename */
3848                         if (!askfor(tmp, 70)) continue;
3849
3850                         /* Build the filename */
3851                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3852
3853                         /* Append to the file */
3854                         if (!open_auto_dump(buf, mark)) continue;
3855
3856                         /* Start dumping */
3857 #ifdef JP
3858                         auto_dump_printf("\n# ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3859 #else
3860                         auto_dump_printf("\n# Monster attr/char definitions\n\n");
3861 #endif
3862
3863                         /* Dump monsters */
3864                         for (i = 0; i < max_r_idx; i++)
3865                         {
3866                                 monster_race *r_ptr = &r_info[i];
3867
3868                                 /* Skip non-entries */
3869                                 if (!r_ptr->name) continue;
3870
3871                                 /* Dump a comment */
3872                                 auto_dump_printf("# %s\n", (r_name + r_ptr->name));
3873
3874                                 /* Dump the monster attr/char info */
3875                                 auto_dump_printf("R:%d:0x%02X/0x%02X\n\n", i,
3876                                         (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char));
3877                         }
3878
3879                         /* Close */
3880                         close_auto_dump();
3881
3882                         /* Message */
3883 #ifdef JP
3884                         msg_print("¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3885 #else
3886                         msg_print("Dumped monster attr/chars.");
3887 #endif
3888
3889                         break;
3890                 }
3891
3892                 /* Dump object attr/chars */
3893                 case '2':
3894                 {
3895                         static cptr mark = "Object attr/chars";
3896
3897                         /* Prompt */
3898 #ifdef JP
3899                         prt("¥³¥Þ¥ó¥É: ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3900 #else
3901                         prt("Command: Dump object attr/chars", 15, 0);
3902 #endif
3903
3904                         /* Prompt */
3905 #ifdef JP
3906                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3907 #else
3908                         prt("File: ", 17, 0);
3909 #endif
3910
3911                         /* Default filename */
3912                         sprintf(tmp, "%s.prf", player_base);
3913
3914                         /* Get a filename */
3915                         if (!askfor(tmp, 70)) continue;
3916
3917                         /* Build the filename */
3918                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3919
3920                         /* Append to the file */
3921                         if (!open_auto_dump(buf, mark)) continue;
3922
3923                         /* Start dumping */
3924 #ifdef JP
3925                         auto_dump_printf("\n# ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3926 #else
3927                         auto_dump_printf("\n# Object attr/char definitions\n\n");
3928 #endif
3929
3930                         /* Dump objects */
3931                         for (i = 0; i < max_k_idx; i++)
3932                         {
3933                                 char o_name[80];
3934                                 object_kind *k_ptr = &k_info[i];
3935
3936                                 /* Skip non-entries */
3937                                 if (!k_ptr->name) continue;
3938
3939                                 if (!k_ptr->flavor)
3940                                 {
3941                                         /* Tidy name */
3942                                         strip_name(o_name, i);
3943                                 }
3944                                 else
3945                                 {
3946                                         object_type forge;
3947
3948                                         /* Prepare dummy object */
3949                                         object_prep(&forge, i);
3950
3951                                         /* Get un-shuffled flavor name */
3952                                         object_desc(o_name, &forge, OD_FORCE_FLAVOR);
3953                                 }
3954
3955                                 /* Dump a comment */
3956                                 auto_dump_printf("# %s\n", o_name);
3957
3958                                 /* Dump the object attr/char info */
3959                                 auto_dump_printf("K:%d:0x%02X/0x%02X\n\n", i,
3960                                         (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char));
3961                         }
3962
3963                         /* Close */
3964                         close_auto_dump();
3965
3966                         /* Message */
3967 #ifdef JP
3968                         msg_print("¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3969 #else
3970                         msg_print("Dumped object attr/chars.");
3971 #endif
3972
3973                         break;
3974                 }
3975
3976                 /* Dump feature attr/chars */
3977                 case '3':
3978                 {
3979                         static cptr mark = "Feature attr/chars";
3980
3981                         /* Prompt */
3982 #ifdef JP
3983                         prt("¥³¥Þ¥ó¥É: ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3984 #else
3985                         prt("Command: Dump feature attr/chars", 15, 0);
3986 #endif
3987
3988                         /* Prompt */
3989 #ifdef JP
3990                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3991 #else
3992                         prt("File: ", 17, 0);
3993 #endif
3994
3995                         /* Default filename */
3996                         sprintf(tmp, "%s.prf", player_base);
3997
3998                         /* Get a filename */
3999                         if (!askfor(tmp, 70)) continue;
4000
4001                         /* Build the filename */
4002                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4003
4004                         /* Append to the file */
4005                         if (!open_auto_dump(buf, mark)) continue;
4006
4007                         /* Start dumping */
4008 #ifdef JP
4009                         auto_dump_printf("\n# ÃÏ·Á¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
4010 #else
4011                         auto_dump_printf("\n# Feature attr/char definitions\n\n");
4012 #endif
4013
4014                         /* Dump features */
4015                         for (i = 0; i < max_f_idx; i++)
4016                         {
4017                                 feature_type *f_ptr = &f_info[i];
4018
4019                                 /* Skip non-entries */
4020                                 if (!f_ptr->name) continue;
4021
4022                                 /* Skip mimiccing features */
4023                                 if (f_ptr->mimic != i) continue;
4024
4025                                 /* Dump a comment */
4026                                 auto_dump_printf("# %s\n", (f_name + f_ptr->name));
4027
4028                                 /* Dump the feature attr/char info */
4029                                 auto_dump_printf("F:%d:0x%02X/0x%02X:0x%02X/0x%02X:0x%02X/0x%02X\n\n", i,
4030                                         (byte)(f_ptr->x_attr[F_LIT_STANDARD]), (byte)(f_ptr->x_char[F_LIT_STANDARD]),
4031                                         (byte)(f_ptr->x_attr[F_LIT_LITE]), (byte)(f_ptr->x_char[F_LIT_LITE]),
4032                                         (byte)(f_ptr->x_attr[F_LIT_DARK]), (byte)(f_ptr->x_char[F_LIT_DARK]));
4033                         }
4034
4035                         /* Close */
4036                         close_auto_dump();
4037
4038                         /* Message */
4039 #ifdef JP
4040                         msg_print("ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4041 #else
4042                         msg_print("Dumped feature attr/chars.");
4043 #endif
4044
4045                         break;
4046                 }
4047
4048                 /* Modify monster attr/chars (numeric operation) */
4049                 case '4':
4050                 {
4051 #ifdef JP
4052                         static cptr choice_msg = "¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4053 #else
4054                         static cptr choice_msg = "Change monster attr/chars";
4055 #endif
4056                         static int r = 0;
4057
4058 #ifdef JP
4059                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4060 #else
4061                         prt(format("Command: %s", choice_msg), 15, 0);
4062 #endif
4063
4064                         /* Hack -- query until done */
4065                         while (1)
4066                         {
4067                                 monster_race *r_ptr = &r_info[r];
4068                                 char c;
4069                                 int t;
4070
4071                                 byte da = r_ptr->d_attr;
4072                                 byte dc = r_ptr->d_char;
4073                                 byte ca = r_ptr->x_attr;
4074                                 byte cc = r_ptr->x_char;
4075
4076                                 /* Label the object */
4077 #ifdef JP
4078                                 Term_putstr(5, 17, -1, TERM_WHITE,
4079                                             format("¥â¥ó¥¹¥¿¡¼ = %d, Ì¾Á° = %-40.40s",
4080                                                    r, (r_name + r_ptr->name)));
4081 #else
4082                                 Term_putstr(5, 17, -1, TERM_WHITE,
4083                                             format("Monster = %d, Name = %-40.40s",
4084                                                    r, (r_name + r_ptr->name)));
4085 #endif
4086
4087                                 /* Label the Default values */
4088 #ifdef JP
4089                                 Term_putstr(10, 19, -1, TERM_WHITE,
4090                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3u / %3u", da, dc));
4091 #else
4092                                 Term_putstr(10, 19, -1, TERM_WHITE,
4093                                             format("Default attr/char = %3u / %3u", da, dc));
4094 #endif
4095
4096                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4097                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4098
4099                                 /* Label the Current values */
4100 #ifdef JP
4101                                 Term_putstr(10, 20, -1, TERM_WHITE,
4102                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3u / %3u", ca, cc));
4103 #else
4104                                 Term_putstr(10, 20, -1, TERM_WHITE,
4105                                             format("Current attr/char = %3u / %3u", ca, cc));
4106 #endif
4107
4108                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4109                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4110
4111                                 /* Prompt */
4112 #ifdef JP
4113                                 Term_putstr(0, 22, -1, TERM_WHITE,
4114                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4115 #else
4116                                 Term_putstr(0, 22, -1, TERM_WHITE,
4117                                             "Command (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4118 #endif
4119
4120                                 /* Get a command */
4121                                 i = inkey();
4122
4123                                 /* All done */
4124                                 if (i == ESCAPE) break;
4125
4126                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4127                                 else if (isupper(i)) c = 'a' + i - 'A';
4128                                 else c = i;
4129
4130                                 switch (c)
4131                                 {
4132                                 case 'n':
4133                                         {
4134                                                 int prev_r = r;
4135                                                 do
4136                                                 {
4137                                                         if (!cmd_visuals_aux(i, &r, max_r_idx))
4138                                                         {
4139                                                                 r = prev_r;
4140                                                                 break;
4141                                                         }
4142                                                 }
4143                                                 while (!r_info[r].name);
4144                                         }
4145                                         break;
4146                                 case 'a':
4147                                         t = (int)r_ptr->x_attr;
4148                                         (void)cmd_visuals_aux(i, &t, 256);
4149                                         r_ptr->x_attr = (byte)t;
4150                                         need_redraw = TRUE;
4151                                         break;
4152                                 case 'c':
4153                                         t = (int)r_ptr->x_char;
4154                                         (void)cmd_visuals_aux(i, &t, 256);
4155                                         r_ptr->x_char = (byte)t;
4156                                         need_redraw = TRUE;
4157                                         break;
4158                                 case 'v':
4159                                         do_cmd_knowledge_monsters(&need_redraw, TRUE, r);
4160
4161                                         /* Clear screen */
4162                                         Term_clear();
4163                                         print_visuals_menu(choice_msg);
4164                                         break;
4165                                 }
4166                         }
4167
4168                         break;
4169                 }
4170
4171                 /* Modify object attr/chars (numeric operation) */
4172                 case '5':
4173                 {
4174 #ifdef JP
4175                         static cptr choice_msg = "¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4176 #else
4177                         static cptr choice_msg = "Change object attr/chars";
4178 #endif
4179                         static int k = 0;
4180
4181 #ifdef JP
4182                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4183 #else
4184                         prt(format("Command: %s", choice_msg), 15, 0);
4185 #endif
4186
4187                         /* Hack -- query until done */
4188                         while (1)
4189                         {
4190                                 object_kind *k_ptr = &k_info[k];
4191                                 char c;
4192                                 int t;
4193
4194                                 byte da = k_ptr->d_attr;
4195                                 byte dc = k_ptr->d_char;
4196                                 byte ca = k_ptr->x_attr;
4197                                 byte cc = k_ptr->x_char;
4198
4199                                 /* Label the object */
4200 #ifdef JP
4201                                 Term_putstr(5, 17, -1, TERM_WHITE,
4202                                             format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
4203                                                    k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
4204 #else
4205                                 Term_putstr(5, 17, -1, TERM_WHITE,
4206                                             format("Object = %d, Name = %-40.40s",
4207                                                    k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
4208 #endif
4209
4210                                 /* Label the Default values */
4211 #ifdef JP
4212                                 Term_putstr(10, 19, -1, TERM_WHITE,
4213                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4214 #else
4215                                 Term_putstr(10, 19, -1, TERM_WHITE,
4216                                             format("Default attr/char = %3d / %3d", da, dc));
4217 #endif
4218
4219                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4220                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4221
4222                                 /* Label the Current values */
4223 #ifdef JP
4224                                 Term_putstr(10, 20, -1, TERM_WHITE,
4225                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4226 #else
4227                                 Term_putstr(10, 20, -1, TERM_WHITE,
4228                                             format("Current attr/char = %3d / %3d", ca, cc));
4229 #endif
4230
4231                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4232                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4233
4234                                 /* Prompt */
4235 #ifdef JP
4236                                 Term_putstr(0, 22, -1, TERM_WHITE,
4237                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4238 #else
4239                                 Term_putstr(0, 22, -1, TERM_WHITE,
4240                                             "Command (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4241 #endif
4242
4243                                 /* Get a command */
4244                                 i = inkey();
4245
4246                                 /* All done */
4247                                 if (i == ESCAPE) break;
4248
4249                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4250                                 else if (isupper(i)) c = 'a' + i - 'A';
4251                                 else c = i;
4252
4253                                 switch (c)
4254                                 {
4255                                 case 'n':
4256                                         {
4257                                                 int prev_k = k;
4258                                                 do
4259                                                 {
4260                                                         if (!cmd_visuals_aux(i, &k, max_k_idx))
4261                                                         {
4262                                                                 k = prev_k;
4263                                                                 break;
4264                                                         }
4265                                                 }
4266                                                 while (!k_info[k].name);
4267                                         }
4268                                         break;
4269                                 case 'a':
4270                                         t = (int)k_ptr->x_attr;
4271                                         (void)cmd_visuals_aux(i, &t, 256);
4272                                         k_ptr->x_attr = (byte)t;
4273                                         need_redraw = TRUE;
4274                                         break;
4275                                 case 'c':
4276                                         t = (int)k_ptr->x_char;
4277                                         (void)cmd_visuals_aux(i, &t, 256);
4278                                         k_ptr->x_char = (byte)t;
4279                                         need_redraw = TRUE;
4280                                         break;
4281                                 case 'v':
4282                                         do_cmd_knowledge_objects(&need_redraw, TRUE, k);
4283
4284                                         /* Clear screen */
4285                                         Term_clear();
4286                                         print_visuals_menu(choice_msg);
4287                                         break;
4288                                 }
4289                         }
4290
4291                         break;
4292                 }
4293
4294                 /* Modify feature attr/chars (numeric operation) */
4295                 case '6':
4296                 {
4297 #ifdef JP
4298                         static cptr choice_msg = "ÃÏ·Á¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4299 #else
4300                         static cptr choice_msg = "Change feature attr/chars";
4301 #endif
4302                         static int f = 0;
4303                         static int lighting_level = F_LIT_STANDARD;
4304
4305 #ifdef JP
4306                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4307 #else
4308                         prt(format("Command: %s", choice_msg), 15, 0);
4309 #endif
4310
4311                         /* Hack -- query until done */
4312                         while (1)
4313                         {
4314                                 feature_type *f_ptr = &f_info[f];
4315                                 char c;
4316                                 int t;
4317
4318                                 byte da = f_ptr->d_attr[lighting_level];
4319                                 byte dc = f_ptr->d_char[lighting_level];
4320                                 byte ca = f_ptr->x_attr[lighting_level];
4321                                 byte cc = f_ptr->x_char[lighting_level];
4322
4323                                 /* Label the object */
4324                                 prt("", 17, 5);
4325 #ifdef JP
4326                                 Term_putstr(5, 17, -1, TERM_WHITE,
4327                                             format("ÃÏ·Á = %d, Ì¾Á° = %s, ÌÀÅÙ = %s",
4328                                                    f, (f_name + f_ptr->name), lighting_level_str[lighting_level]));
4329 #else
4330                                 Term_putstr(5, 17, -1, TERM_WHITE,
4331                                             format("Terrain = %d, Name = %s, Lighting = %s",
4332                                                    f, (f_name + f_ptr->name), lighting_level_str[lighting_level]));
4333 #endif
4334
4335                                 /* Label the Default values */
4336 #ifdef JP
4337                                 Term_putstr(10, 19, -1, TERM_WHITE,
4338                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4339 #else
4340                                 Term_putstr(10, 19, -1, TERM_WHITE,
4341                                             format("Default attr/char = %3d / %3d", da, dc));
4342 #endif
4343
4344                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4345
4346                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4347
4348                                 /* Label the Current values */
4349 #ifdef JP
4350                                 Term_putstr(10, 20, -1, TERM_WHITE,
4351                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4352 #else
4353                                 Term_putstr(10, 20, -1, TERM_WHITE,
4354                                             format("Current attr/char = %3d / %3d", ca, cc));
4355 #endif
4356
4357                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4358                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4359
4360                                 /* Prompt */
4361 #ifdef JP
4362                                 Term_putstr(0, 22, -1, TERM_WHITE,
4363                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/l/L/^L/d/D/^D/v/V/^V): ");
4364 #else
4365                                 Term_putstr(0, 22, -1, TERM_WHITE,
4366                                             "Command (n/N/^N/a/A/^A/c/C/^C/l/L/^L/d/D/^D/v/V/^V): ");
4367 #endif
4368
4369                                 /* Get a command */
4370                                 i = inkey();
4371
4372                                 /* All done */
4373                                 if (i == ESCAPE) break;
4374
4375                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4376                                 else if (isupper(i)) c = 'a' + i - 'A';
4377                                 else c = i;
4378
4379                                 switch (c)
4380                                 {
4381                                 case 'n':
4382                                         {
4383                                                 int prev_f = f;
4384                                                 do
4385                                                 {
4386                                                         if (!cmd_visuals_aux(i, &f, max_f_idx))
4387                                                         {
4388                                                                 f = prev_f;
4389                                                                 break;
4390                                                         }
4391                                                 }
4392                                                 while (!f_info[f].name || (f_info[f].mimic != f));
4393                                         }
4394                                         break;
4395                                 case 'a':
4396                                         t = (int)f_ptr->x_attr[lighting_level];
4397                                         (void)cmd_visuals_aux(i, &t, 256);
4398                                         f_ptr->x_attr[lighting_level] = (byte)t;
4399                                         need_redraw = TRUE;
4400                                         break;
4401                                 case 'c':
4402                                         t = (int)f_ptr->x_char[lighting_level];
4403                                         (void)cmd_visuals_aux(i, &t, 256);
4404                                         f_ptr->x_char[lighting_level] = (byte)t;
4405                                         need_redraw = TRUE;
4406                                         break;
4407                                 case 'l':
4408                                         (void)cmd_visuals_aux(i, &lighting_level, F_LIT_MAX);
4409                                         break;
4410                                 case 'd':
4411                                         apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
4412                                         need_redraw = TRUE;
4413                                         break;
4414                                 case 'v':
4415                                         do_cmd_knowledge_features(&need_redraw, TRUE, f, &lighting_level);
4416
4417                                         /* Clear screen */
4418                                         Term_clear();
4419                                         print_visuals_menu(choice_msg);
4420                                         break;
4421                                 }
4422                         }
4423
4424                         break;
4425                 }
4426
4427                 /* Modify monster attr/chars (visual mode) */
4428                 case '7':
4429                         do_cmd_knowledge_monsters(&need_redraw, TRUE, -1);
4430                         break;
4431
4432                 /* Modify object attr/chars (visual mode) */
4433                 case '8':
4434                         do_cmd_knowledge_objects(&need_redraw, TRUE, -1);
4435                         break;
4436
4437                 /* Modify feature attr/chars (visual mode) */
4438                 case '9':
4439                 {
4440                         int lighting_level = F_LIT_STANDARD;
4441                         do_cmd_knowledge_features(&need_redraw, TRUE, -1, &lighting_level);
4442                         break;
4443                 }
4444
4445 #endif /* ALLOW_VISUALS */
4446
4447                 /* Reset visuals */
4448                 case 'R':
4449                 case 'r':
4450                         /* Reset */
4451                         reset_visuals();
4452
4453                         /* Message */
4454 #ifdef JP
4455                         msg_print("²èÌ̾å¤Î[¿§/ʸ»ú]¤ò½é´üÃͤ˥ꥻ¥Ã¥È¤·¤Þ¤·¤¿¡£");
4456 #else
4457                         msg_print("Visual attr/char tables reset.");
4458 #endif
4459
4460                         need_redraw = TRUE;
4461                         break;
4462
4463                 /* Unknown option */
4464                 default:
4465                         bell();
4466                         break;
4467                 }
4468
4469                 /* Flush messages */
4470                 msg_print(NULL);
4471         }
4472
4473         /* Restore the screen */
4474         screen_load();
4475
4476         if (need_redraw) do_cmd_redraw();
4477 }
4478
4479
4480 /*
4481  * Interact with "colors"
4482  */
4483 void do_cmd_colors(void)
4484 {
4485         int i;
4486
4487         char tmp[160];
4488
4489         char buf[1024];
4490
4491
4492         /* File type is "TEXT" */
4493         FILE_TYPE(FILE_TYPE_TEXT);
4494
4495
4496         /* Save the screen */
4497         screen_save();
4498
4499
4500         /* Interact until done */
4501         while (1)
4502         {
4503                 /* Clear screen */
4504                 Term_clear();
4505
4506                 /* Ask for a choice */
4507 #ifdef JP
4508                 prt("[ ¥«¥é¡¼¤ÎÀßÄê ]", 2, 0);
4509 #else
4510                 prt("Interact with Colors", 2, 0);
4511 #endif
4512
4513
4514                 /* Give some choices */
4515 #ifdef JP
4516                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
4517 #else
4518                 prt("(1) Load a user pref file", 4, 5);
4519 #endif
4520
4521 #ifdef ALLOW_COLORS
4522 #ifdef JP
4523                 prt("(2) ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
4524                 prt("(3) ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤¹¤ë", 6, 5);
4525 #else
4526                 prt("(2) Dump colors", 5, 5);
4527                 prt("(3) Modify colors", 6, 5);
4528 #endif
4529
4530 #endif
4531
4532                 /* Prompt */
4533 #ifdef JP
4534                 prt("¥³¥Þ¥ó¥É: ", 8, 0);
4535 #else
4536                 prt("Command: ", 8, 0);
4537 #endif
4538
4539
4540                 /* Prompt */
4541                 i = inkey();
4542
4543                 /* Done */
4544                 if (i == ESCAPE) break;
4545
4546                 /* Load a 'pref' file */
4547                 if (i == '1')
4548                 {
4549                         /* Prompt */
4550 #ifdef JP
4551                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹", 8, 0);
4552 #else
4553                         prt("Command: Load a user pref file", 8, 0);
4554 #endif
4555
4556
4557                         /* Prompt */
4558 #ifdef JP
4559                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4560 #else
4561                         prt("File: ", 10, 0);
4562 #endif
4563
4564
4565                         /* Default file */
4566                         sprintf(tmp, "%s.prf", player_base);
4567
4568                         /* Query */
4569                         if (!askfor(tmp, 70)) continue;
4570
4571                         /* Process the given filename */
4572                         (void)process_pref_file(tmp);
4573
4574                         /* Mega-Hack -- react to changes */
4575                         Term_xtra(TERM_XTRA_REACT, 0);
4576
4577                         /* Mega-Hack -- redraw */
4578                         Term_redraw();
4579                 }
4580
4581 #ifdef ALLOW_COLORS
4582
4583                 /* Dump colors */
4584                 else if (i == '2')
4585                 {
4586                         static cptr mark = "Colors";
4587
4588                         /* Prompt */
4589 #ifdef JP
4590                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 8, 0);
4591 #else
4592                         prt("Command: Dump colors", 8, 0);
4593 #endif
4594
4595
4596                         /* Prompt */
4597 #ifdef JP
4598                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4599 #else
4600                         prt("File: ", 10, 0);
4601 #endif
4602
4603
4604                         /* Default filename */
4605                         sprintf(tmp, "%s.prf", player_base);
4606
4607                         /* Get a filename */
4608                         if (!askfor(tmp, 70)) continue;
4609
4610                         /* Build the filename */
4611                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4612
4613                         /* Append to the file */
4614                         if (!open_auto_dump(buf, mark)) continue;
4615
4616                         /* Start dumping */
4617 #ifdef JP
4618                         auto_dump_printf("\n# ¥«¥é¡¼¤ÎÀßÄê\n\n");
4619 #else
4620                         auto_dump_printf("\n# Color redefinitions\n\n");
4621 #endif
4622
4623                         /* Dump colors */
4624                         for (i = 0; i < 256; i++)
4625                         {
4626                                 int kv = angband_color_table[i][0];
4627                                 int rv = angband_color_table[i][1];
4628                                 int gv = angband_color_table[i][2];
4629                                 int bv = angband_color_table[i][3];
4630
4631 #ifdef JP
4632                                 cptr name = "̤ÃÎ";
4633 #else
4634                                 cptr name = "unknown";
4635 #endif
4636
4637
4638                                 /* Skip non-entries */
4639                                 if (!kv && !rv && !gv && !bv) continue;
4640
4641                                 /* Extract the color name */
4642                                 if (i < 16) name = color_names[i];
4643
4644                                 /* Dump a comment */
4645 #ifdef JP
4646                                 auto_dump_printf("# ¥«¥é¡¼ '%s'\n", name);
4647 #else
4648                                 auto_dump_printf("# Color '%s'\n", name);
4649 #endif
4650
4651                                 /* Dump the monster attr/char info */
4652                                 auto_dump_printf("V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
4653                                         i, kv, rv, gv, bv);
4654                         }
4655
4656                         /* Close */
4657                         close_auto_dump();
4658
4659                         /* Message */
4660 #ifdef JP
4661                         msg_print("¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4662 #else
4663                         msg_print("Dumped color redefinitions.");
4664 #endif
4665
4666                 }
4667
4668                 /* Edit colors */
4669                 else if (i == '3')
4670                 {
4671                         static byte a = 0;
4672
4673                         /* Prompt */
4674 #ifdef JP
4675                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤·¤Þ¤¹", 8, 0);
4676 #else
4677                         prt("Command: Modify colors", 8, 0);
4678 #endif
4679
4680
4681                         /* Hack -- query until done */
4682                         while (1)
4683                         {
4684                                 cptr name;
4685                                 byte j;
4686
4687                                 /* Clear */
4688                                 clear_from(10);
4689
4690                                 /* Exhibit the normal colors */
4691                                 for (j = 0; j < 16; j++)
4692                                 {
4693                                         /* Exhibit this color */
4694                                         Term_putstr(j*4, 20, -1, a, "###");
4695
4696                                         /* Exhibit all colors */
4697                                         Term_putstr(j*4, 22, -1, j, format("%3d", j));
4698                                 }
4699
4700                                 /* Describe the color */
4701 #ifdef JP
4702                                 name = ((a < 16) ? color_names[a] : "̤ÄêµÁ");
4703 #else
4704                                 name = ((a < 16) ? color_names[a] : "undefined");
4705 #endif
4706
4707
4708                                 /* Describe the color */
4709 #ifdef JP
4710                                 Term_putstr(5, 10, -1, TERM_WHITE,
4711                                             format("¥«¥é¡¼ = %d, Ì¾Á° = %s", a, name));
4712 #else
4713                                 Term_putstr(5, 10, -1, TERM_WHITE,
4714                                             format("Color = %d, Name = %s", a, name));
4715 #endif
4716
4717
4718                                 /* Label the Current values */
4719                                 Term_putstr(5, 12, -1, TERM_WHITE,
4720                                             format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
4721                                                    angband_color_table[a][0],
4722                                                    angband_color_table[a][1],
4723                                                    angband_color_table[a][2],
4724                                                    angband_color_table[a][3]));
4725
4726                                 /* Prompt */
4727 #ifdef JP
4728                                 Term_putstr(0, 14, -1, TERM_WHITE,
4729                                             "¥³¥Þ¥ó¥É (n/N/k/K/r/R/g/G/b/B): ");
4730 #else
4731                                 Term_putstr(0, 14, -1, TERM_WHITE,
4732                                             "Command (n/N/k/K/r/R/g/G/b/B): ");
4733 #endif
4734
4735
4736                                 /* Get a command */
4737                                 i = inkey();
4738
4739                                 /* All done */
4740                                 if (i == ESCAPE) break;
4741
4742                                 /* Analyze */
4743                                 if (i == 'n') a = (byte)(a + 1);
4744                                 if (i == 'N') a = (byte)(a - 1);
4745                                 if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1);
4746                                 if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1);
4747                                 if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1);
4748                                 if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1);
4749                                 if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1);
4750                                 if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1);
4751                                 if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1);
4752                                 if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1);
4753
4754                                 /* Hack -- react to changes */
4755                                 Term_xtra(TERM_XTRA_REACT, 0);
4756
4757                                 /* Hack -- redraw */
4758                                 Term_redraw();
4759                         }
4760                 }
4761
4762 #endif
4763
4764                 /* Unknown option */
4765                 else
4766                 {
4767                         bell();
4768                 }
4769
4770                 /* Flush messages */
4771                 msg_print(NULL);
4772         }
4773
4774
4775         /* Restore the screen */
4776         screen_load();
4777 }
4778
4779
4780 /*
4781  * Note something in the message recall
4782  */
4783 void do_cmd_note(void)
4784 {
4785         char buf[80];
4786
4787         /* Default */
4788         strcpy(buf, "");
4789
4790         /* Input */
4791 #ifdef JP
4792         if (!get_string("¥á¥â: ", buf, 60)) return;
4793 #else
4794         if (!get_string("Note: ", buf, 60)) return;
4795 #endif
4796
4797
4798         /* Ignore empty notes */
4799         if (!buf[0] || (buf[0] == ' ')) return;
4800
4801         /* Add the note to the message recall */
4802 #ifdef JP
4803         msg_format("¥á¥â: %s", buf);
4804 #else
4805         msg_format("Note: %s", buf);
4806 #endif
4807
4808 }
4809
4810
4811 /*
4812  * Mention the current version
4813  */
4814 void do_cmd_version(void)
4815 {
4816
4817         /* Silly message */
4818 #ifdef JP
4819         msg_format("ÊѶòÈÚÅÜ(Hengband) %d.%d.%d",
4820                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4821 #else
4822         msg_format("You are playing Hengband %d.%d.%d.",
4823                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4824 #endif
4825 }
4826
4827
4828
4829 /*
4830  * Array of feeling strings
4831  */
4832 static cptr do_cmd_feeling_text[11] =
4833 {
4834 #ifdef JP
4835         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4836 #else
4837         "Looks like any other level.",
4838 #endif
4839
4840 #ifdef JP
4841         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4842 #else
4843         "You feel there is something special about this level.",
4844 #endif
4845
4846 #ifdef JP
4847         "¶²¤í¤·¤¤»à¤Î¸¸¤¬ÌܤËÉ⤫¤Ó¡¢µ¤À䤷¤½¤¦¤Ë¤Ê¤Ã¤¿¡ª",
4848 #else
4849         "You nearly faint as horrible visions of death fill your mind!",
4850 #endif
4851
4852 #ifdef JP
4853         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4854 #else
4855         "This level looks very dangerous.",
4856 #endif
4857
4858 #ifdef JP
4859         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4860 #else
4861         "You have a very bad feeling...",
4862 #endif
4863
4864 #ifdef JP
4865         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4866 #else
4867         "You have a bad feeling...",
4868 #endif
4869
4870 #ifdef JP
4871         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4872 #else
4873         "You feel nervous.",
4874 #endif
4875
4876 #ifdef JP
4877         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4878 #else
4879         "You feel your luck is turning...",
4880 #endif
4881
4882 #ifdef JP
4883         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4884 #else
4885         "You don't like the look of this place.",
4886 #endif
4887
4888 #ifdef JP
4889         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4890 #else
4891         "This level looks reasonably safe.",
4892 #endif
4893
4894 #ifdef JP
4895         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4896 #else
4897         "What a boring place..."
4898 #endif
4899
4900 };
4901
4902 static cptr do_cmd_feeling_text_combat[11] =
4903 {
4904 #ifdef JP
4905         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4906 #else
4907         "Looks like any other level.",
4908 #endif
4909
4910 #ifdef JP
4911         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4912 #else
4913         "You feel there is something special about this level.",
4914 #endif
4915
4916 #ifdef JP
4917         "º£Ìë¤â¤Þ¤¿¡¢Ã¯¤«¤¬Ì¿¤òÍî¤È¤¹...",
4918 #else
4919         "You nearly faint as horrible visions of death fill your mind!",
4920 #endif
4921
4922 #ifdef JP
4923         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4924 #else
4925         "This level looks very dangerous.",
4926 #endif
4927
4928 #ifdef JP
4929         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4930 #else
4931         "You have a very bad feeling...",
4932 #endif
4933
4934 #ifdef JP
4935         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4936 #else
4937         "You have a bad feeling...",
4938 #endif
4939
4940 #ifdef JP
4941         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4942 #else
4943         "You feel nervous.",
4944 #endif
4945
4946 #ifdef JP
4947         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4948 #else
4949         "You feel your luck is turning...",
4950 #endif
4951
4952 #ifdef JP
4953         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4954 #else
4955         "You don't like the look of this place.",
4956 #endif
4957
4958 #ifdef JP
4959         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4960 #else
4961         "This level looks reasonably safe.",
4962 #endif
4963
4964 #ifdef JP
4965         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4966 #else
4967         "What a boring place..."
4968 #endif
4969
4970 };
4971
4972 static cptr do_cmd_feeling_text_lucky[11] =
4973 {
4974 #ifdef JP
4975         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4976         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4977         "¤³¤Î³¬¤Ï¤³¤Î¾å¤Ê¤¯ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë¡£",
4978         "ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë...",
4979         "¤È¤Æ¤âÎɤ¤´¶¤¸¤¬¤¹¤ë...",
4980         "Îɤ¤´¶¤¸¤¬¤¹¤ë...",
4981         "¤Á¤ç¤Ã¤È¹¬±¿¤Ê´¶¤¸¤¬¤¹¤ë...",
4982         "¿¾¯¤Ï±¿¤¬¸þ¤¤¤Æ¤­¤¿¤«...",
4983         "¸«¤¿´¶¤¸°­¤¯¤Ï¤Ê¤¤...",
4984         "Á´Á³ÂÌÌܤȤ¤¤¦¤³¤È¤Ï¤Ê¤¤¤¬...",
4985         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4986 #else
4987         "Looks like any other level.",
4988         "You feel there is something special about this level.",
4989         "You have a superb feeling about this level.",
4990         "You have an excellent feeling...",
4991         "You have a very good feeling...",
4992         "You have a good feeling...",
4993         "You feel strangely lucky...",
4994         "You feel your luck is turning...",
4995         "You like the look of this place...",
4996         "This level can't be all bad...",
4997         "What a boring place..."
4998 #endif
4999 };
5000
5001
5002 /*
5003  * Note that "feeling" is set to zero unless some time has passed.
5004  * Note that this is done when the level is GENERATED, not entered.
5005  */
5006 void do_cmd_feeling(void)
5007 {
5008         /* No useful feeling in quests */
5009         if (p_ptr->inside_quest && !random_quest_number(dun_level))
5010         {
5011 #ifdef JP
5012                 msg_print("ŵ·¿Åª¤Ê¥¯¥¨¥¹¥È¤Î¥À¥ó¥¸¥ç¥ó¤Î¤è¤¦¤À¡£");
5013 #else
5014                 msg_print("Looks like a typical quest level.");
5015 #endif
5016
5017                 return;
5018         }
5019
5020         /* No useful feeling in town */
5021         else if (p_ptr->town_num && !dun_level)
5022         {
5023 #ifdef JP
5024                 if (!strcmp(town[p_ptr->town_num].name, "¹ÓÌî"))
5025 #else
5026                 if (!strcmp(town[p_ptr->town_num].name, "wilderness"))
5027 #endif
5028                 {
5029 #ifdef JP
5030                         msg_print("²¿¤«¤¢¤ê¤½¤¦¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
5031 #else
5032                         msg_print("Looks like a strange wilderness.");
5033 #endif
5034
5035                         return;
5036                 }
5037                 else
5038                 {
5039 #ifdef JP
5040                         msg_print("ŵ·¿Åª¤ÊÄ®¤Î¤è¤¦¤À¡£");
5041 #else
5042                         msg_print("Looks like a typical town.");
5043 #endif
5044
5045                         return;
5046                 }
5047         }
5048
5049         /* No useful feeling in the wilderness */
5050         else if (!dun_level)
5051         {
5052 #ifdef JP
5053                 msg_print("ŵ·¿Åª¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
5054 #else
5055                 msg_print("Looks like a typical wilderness.");
5056 #endif
5057
5058                 return;
5059         }
5060
5061         /* Display the feeling */
5062         if (p_ptr->muta3 & MUT3_GOOD_LUCK)
5063                 msg_print(do_cmd_feeling_text_lucky[p_ptr->feeling]);
5064         else if (p_ptr->pseikaku == SEIKAKU_COMBAT ||
5065                  inventory[INVEN_BOW].name1 == ART_CRIMSON)
5066                 msg_print(do_cmd_feeling_text_combat[p_ptr->feeling]);
5067         else
5068                 msg_print(do_cmd_feeling_text[p_ptr->feeling]);
5069 }
5070
5071
5072
5073 /*
5074  * Description of each monster group.
5075  */
5076 static cptr monster_group_text[] = 
5077 {
5078 #ifdef JP
5079         "¥æ¥Ë¡¼¥¯",     /* "Uniques" */
5080         "¾èÇϲÄǽ¤Ê¥â¥ó¥¹¥¿¡¼", /* "Riding" */
5081         "¾Þ¶â¼ó", /* "Wanted */
5082         "¥¢¥ó¥Ð¡¼¤Î²¦Â²", /* "Ambertite" */
5083         "¥¢¥ê",
5084         "¥³¥¦¥â¥ê",
5085         "¥à¥«¥Ç",
5086         "¥É¥é¥´¥ó",
5087         "ÌܶÌ",
5088         "¥Í¥³",
5089         "¥´¡¼¥ì¥à",
5090         "ɸ½à¿Í´Ö·¿À¸Êª",
5091         "¥Ù¥È¥Ù¥È",
5092         "¥¼¥ê¡¼",
5093         "¥³¥Ü¥ë¥É",
5094         "¿åÀ³À¸Êª",
5095         "¥â¥ë¥É",
5096         "¥Ê¡¼¥¬",
5097         "¥ª¡¼¥¯",
5098         "¿Í´Ö",
5099         "»Í­½Ã",
5100         "¥Í¥º¥ß",
5101         "¥¹¥±¥ë¥È¥ó",
5102         "¥Ç¡¼¥â¥ó",
5103         "¥Ü¥ë¥Æ¥Ã¥¯¥¹",
5104         "¥¤¥â¥à¥·/Âç·²",
5105         /* "unused", */
5106         "¥¤¡¼¥¯",
5107         "¥¾¥ó¥Ó/¥ß¥¤¥é",
5108         "Å·»È",
5109         "Ļ",
5110         "¸¤",
5111         /* "¸ÅÂå¥É¥é¥´¥ó/¥ï¥¤¥¢¡¼¥à", */
5112         "¥¨¥ì¥á¥ó¥¿¥ë",
5113         "¥È¥ó¥Ü",
5114         "¥´¡¼¥¹¥È",
5115         "»¨¼ï",
5116         "º«Ãî",
5117         "¥Ø¥Ó",
5118         "¥­¥é¡¼¡¦¥Ó¡¼¥È¥ë",
5119         "¥ê¥Ã¥Á",
5120         "¿¼ó¤Îà¨ÃîÎà",
5121         "Ææ¤ÎÀ¸Êª",
5122         "¥ª¡¼¥¬",
5123         "µðÂç¿Í´Ö·¿À¸Êª",
5124         "¥¯¥¤¥ë¥¹¥ë¥°",
5125         "à¨ÃîÎà/ξÀ¸Îà",
5126         "ÃØéá/¥µ¥½¥ê/¥À¥Ë",
5127         "¥È¥í¥ë",
5128         /* "¾åµé¥Ç¡¼¥â¥ó", */
5129         "¥Ð¥ó¥Ñ¥¤¥¢",
5130         "¥ï¥¤¥È/¥ì¥¤¥¹/Åù",
5131         "¥¾¡¼¥ó/¥¶¥ì¥ó/Åù",
5132         "¥¤¥¨¥Æ¥£",
5133         "¥Ï¥¦¥ó¥É",
5134         "¥ß¥ß¥Ã¥¯",
5135         "ÊÉ/¿¢Êª/µ¤ÂÎ",
5136         "¤ª¤Ð¤±¥­¥Î¥³",
5137         "µåÂÎ",
5138         "¥×¥ì¥¤¥ä¡¼",
5139 #else
5140         "Uniques",
5141         "Ridable monsters",
5142         "Wanted monsters",
5143         "Ambertite",
5144         "Ant",
5145         "Bat",
5146         "Centipede",
5147         "Dragon",
5148         "Floating Eye",
5149         "Feline",
5150         "Golem",
5151         "Hobbit/Elf/Dwarf",
5152         "Icky Thing",
5153         "Jelly",
5154         "Kobold",
5155         "Aquatic monster",
5156         "Mold",
5157         "Naga",
5158         "Orc",
5159         "Person/Human",
5160         "Quadruped",
5161         "Rodent",
5162         "Skeleton",
5163         "Demon",
5164         "Vortex",
5165         "Worm/Worm-Mass",
5166         /* "unused", */
5167         "Yeek",
5168         "Zombie/Mummy",
5169         "Angel",
5170         "Bird",
5171         "Canine",
5172         /* "Ancient Dragon/Wyrm", */
5173         "Elemental",
5174         "Dragon Fly",
5175         "Ghost",
5176         "Hybrid",
5177         "Insect",
5178         "Snake",
5179         "Killer Beetle",
5180         "Lich",
5181         "Multi-Headed Reptile",
5182         "Mystery Living",
5183         "Ogre",
5184         "Giant Humanoid",
5185         "Quylthulg",
5186         "Reptile/Amphibian",
5187         "Spider/Scorpion/Tick",
5188         "Troll",
5189         /* "Major Demon", */
5190         "Vampire",
5191         "Wight/Wraith/etc",
5192         "Xorn/Xaren/etc",
5193         "Yeti",
5194         "Zephyr Hound",
5195         "Mimic",
5196         "Wall/Plant/Gas",
5197         "Mushroom patch",
5198         "Ball",
5199         "Player",
5200 #endif
5201         NULL
5202 };
5203
5204
5205 /*
5206  * Symbols of monsters in each group. Note the "Uniques" group
5207  * is handled differently.
5208  */
5209 static cptr monster_group_char[] =
5210 {
5211         (char *) -1L,
5212         (char *) -2L,
5213         (char *) -3L,
5214         (char *) -4L,
5215         "a",
5216         "b",
5217         "c",
5218         "dD",
5219         "e",
5220         "f",
5221         "g",
5222         "h",
5223         "i",
5224         "j",
5225         "k",
5226         "l",
5227         "m",
5228         "n",
5229         "o",
5230         "pt",
5231         "q",
5232         "r",
5233         "s",
5234         "uU",
5235         "v",
5236         "w",
5237         /* "x", */
5238         "y",
5239         "z",
5240         "A",
5241         "B",
5242         "C",
5243         /* "D", */
5244         "E",
5245         "F",
5246         "G",
5247         "H",
5248         "I",
5249         "J",
5250         "K",
5251         "L",
5252         "M",
5253         "N",
5254         "O",
5255         "P",
5256         "Q",
5257         "R",
5258         "S",
5259         "T",
5260         /* "U", */
5261         "V",
5262         "W",
5263         "X",
5264         "Y",
5265         "Z",
5266         "!$&()+./=>?[\\]`{|~",
5267         "#%",
5268         ",",
5269         "*",
5270         "@",
5271         NULL
5272 };
5273
5274
5275 /*
5276  * hook function to sort monsters by level
5277  */
5278 static bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
5279 {
5280         u16b *who = (u16b*)(u);
5281
5282         int w1 = who[a];
5283         int w2 = who[b];
5284
5285         monster_race *r_ptr1 = &r_info[w1];
5286         monster_race *r_ptr2 = &r_info[w2];
5287
5288         /* Unused */
5289         (void)v;
5290
5291         if (r_ptr2->level > r_ptr1->level) return TRUE;
5292         if (r_ptr1->level > r_ptr2->level) return FALSE;
5293
5294         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return TRUE;
5295         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return FALSE;
5296         return w1 <= w2;
5297 }
5298
5299 /*
5300  * Build a list of monster indexes in the given group. Return the number
5301  * of monsters in the group.
5302  *
5303  * mode & 0x01 : check for non-empty group
5304  * mode & 0x02 : visual operation only
5305  */
5306 static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
5307 {
5308         int i, mon_cnt = 0;
5309         int dummy_why;
5310
5311         /* Get a list of x_char in this group */
5312         cptr group_char = monster_group_char[grp_cur];
5313
5314         /* XXX Hack -- Check if this is the "Uniques" group */
5315         bool grp_unique = (monster_group_char[grp_cur] == (char *) -1L);
5316
5317         /* XXX Hack -- Check if this is the "Riding" group */
5318         bool grp_riding = (monster_group_char[grp_cur] == (char *) -2L);
5319
5320         /* XXX Hack -- Check if this is the "Wanted" group */
5321         bool grp_wanted = (monster_group_char[grp_cur] == (char *) -3L);
5322
5323         /* XXX Hack -- Check if this is the "Amberite" group */
5324         bool grp_amberite = (monster_group_char[grp_cur] == (char *) -4L);
5325
5326
5327         /* Check every race */
5328         for (i = 0; i < max_r_idx; i++)
5329         {
5330                 /* Access the race */
5331                 monster_race *r_ptr = &r_info[i];
5332
5333                 /* Skip empty race */
5334                 if (!r_ptr->name) continue ;
5335
5336                 /* Require known monsters */
5337                 if (!(mode & 0x02) && !cheat_know && !r_ptr->r_sights) continue;
5338
5339                 if (grp_unique)
5340                 {
5341                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5342                 }
5343
5344                 else if (grp_riding)
5345                 {
5346                         if (!(r_ptr->flags7 & RF7_RIDING)) continue;
5347                 }
5348
5349                 else if (grp_wanted)
5350                 {
5351                         bool wanted = FALSE;
5352                         int j;
5353                         for (j = 0; j < MAX_KUBI; j++)
5354                         {
5355                                 if (kubi_r_idx[j] == i || kubi_r_idx[j] - 10000 == i ||
5356                                         (p_ptr->today_mon && p_ptr->today_mon == i))
5357                                 {
5358                                         wanted = TRUE;
5359                                         break;
5360                                 }
5361                         }
5362                         if (!wanted) continue;
5363                 }
5364
5365                 else if (grp_amberite)
5366                 {
5367                         if (!(r_ptr->flags3 & RF3_AMBERITE)) continue;
5368                 }
5369
5370                 else
5371                 {
5372                         /* Check for race in the group */
5373                         if (!my_strchr(group_char, r_ptr->d_char)) continue;
5374                 }
5375
5376                 /* Add the race */
5377                 mon_idx[mon_cnt++] = i;
5378
5379                 /* XXX Hack -- Just checking for non-empty group */
5380                 if (mode & 0x01) break;
5381         }
5382
5383         /* Terminate the list */
5384         mon_idx[mon_cnt] = -1;
5385
5386         /* Select the sort method */
5387         ang_sort_comp = ang_sort_comp_monster_level;
5388         ang_sort_swap = ang_sort_swap_hook;
5389
5390         /* Sort by monster level */
5391         ang_sort(mon_idx, &dummy_why, mon_cnt);
5392
5393         /* Return the number of races */
5394         return mon_cnt;
5395 }
5396
5397
5398 /*
5399  * Description of each monster group.
5400  */
5401 static cptr object_group_text[] = 
5402 {
5403 #ifdef JP
5404         "¥­¥Î¥³",       /* "Mushrooms" */
5405         "Ìô",           /* "Potions" */
5406         "Ìý¤Ä¤Ü",       /* "Flasks" */
5407         "´¬Êª",         /* "Scrolls" */
5408         "»ØÎØ",         /* "Rings" */
5409         "¥¢¥ß¥å¥ì¥Ã¥È", /* "Amulets" */
5410         "ū",           /* "Whistle" */
5411         "¸÷¸»",         /* "Lanterns" */
5412         "ËâË¡ËÀ",       /* "Wands" */
5413         "¾ó",           /* "Staffs" */
5414         "¥í¥Ã¥É",       /* "Rods" */
5415         "¥«¡¼¥É",       /* "Cards" */
5416         "¥­¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë",
5417         "ÍÓÈé»æ",       
5418         "¤¯¤µ¤Ó",
5419         "Ȣ",
5420         "¿Í·Á",
5421         "Áü",
5422         "¥´¥ß",
5423         "¶õ¤Î¥Ó¥ó",
5424         "¹ü",
5425         "»àÂÎ",
5426         "Åá·õÎà",       /* "Swords" */
5427         "Æß´ï",         /* "Blunt Weapons" */
5428         "ĹÊÁÉð´ï",     /* "Polearms" */
5429         "ºÎ·¡Æ»¶ñ",     /* "Diggers" */
5430         "Èô¤ÓÆ»¶ñ",     /* "Bows" */
5431         "ÃÆ",
5432         "Ìð",
5433         "¥Ü¥ë¥È",
5434         "·ÚÁõ³»",       /* "Soft Armor" */
5435         "½ÅÁõ³»",       /* "Hard Armor" */
5436         "¥É¥é¥´¥ó³»",   /* "Dragon Armor" */
5437         "½â",   /* "Shields" */
5438         "¥¯¥í¡¼¥¯",     /* "Cloaks" */
5439         "äƼê", /* "Gloves" */
5440         "¥Ø¥ë¥á¥Ã¥È",   /* "Helms" */
5441         "´§",   /* "Crowns" */
5442         "¥Ö¡¼¥Ä",       /* "Boots" */
5443         "ËâË¡½ñ",
5444         "ºâÊõ",
5445         "²¿¤«",
5446 #else
5447         "Mushrooms",
5448         "Potions",
5449         "Flasks",
5450         "Scrolls",
5451         "Rings",
5452         "Amulets",
5453         "Whistle",
5454         "Lanterns",
5455         "Wands",
5456         "Staves",
5457         "Rods",
5458         "Cards",
5459         "Capture Balls",
5460         "Parchments",
5461         "Spikes",
5462         "Boxs",
5463         "Figurines",
5464         "Statues",
5465         "Junks",
5466         "Bottles",
5467         "Skeletons",
5468         "Corpses",
5469         "Swords",
5470         "Blunt Weapons",
5471         "Polearms",
5472         "Diggers",
5473         "Bows",
5474         "Shots",
5475         "Arrows",
5476         "Bolts",
5477         "Soft Armor",
5478         "Hard Armor",
5479         "Dragon Armor",
5480         "Shields",
5481         "Cloaks",
5482         "Gloves",
5483         "Helms",
5484         "Crowns",
5485         "Boots",
5486         "Spellbooks",
5487         "Treasure",
5488         "Something",
5489 #endif
5490         NULL
5491 };
5492
5493
5494 /*
5495  * TVALs of items in each group
5496  */
5497 static byte object_group_tval[] = 
5498 {
5499         TV_FOOD,
5500         TV_POTION,
5501         TV_FLASK,
5502         TV_SCROLL,
5503         TV_RING,
5504         TV_AMULET,
5505         TV_WHISTLE,
5506         TV_LITE,
5507         TV_WAND,
5508         TV_STAFF,
5509         TV_ROD,
5510         TV_CARD,
5511         TV_CAPTURE,
5512         TV_PARCHMENT,
5513         TV_SPIKE,
5514         TV_CHEST,
5515         TV_FIGURINE,
5516         TV_STATUE,
5517         TV_JUNK,
5518         TV_BOTTLE,
5519         TV_SKELETON,
5520         TV_CORPSE,
5521         TV_SWORD,
5522         TV_HAFTED,
5523         TV_POLEARM,
5524         TV_DIGGING,
5525         TV_BOW,
5526         TV_SHOT,
5527         TV_ARROW,
5528         TV_BOLT,
5529         TV_SOFT_ARMOR,
5530         TV_HARD_ARMOR,
5531         TV_DRAG_ARMOR,
5532         TV_SHIELD,
5533         TV_CLOAK,
5534         TV_GLOVES,
5535         TV_HELM,
5536         TV_CROWN,
5537         TV_BOOTS,
5538         TV_LIFE_BOOK, /* Hack -- all spellbooks */
5539         TV_GOLD,
5540         0,
5541         0,
5542 };
5543
5544
5545 /*
5546  * Build a list of object indexes in the given group. Return the number
5547  * of objects in the group.
5548  *
5549  * mode & 0x01 : check for non-empty group
5550  * mode & 0x02 : visual operation only
5551  */
5552 static int collect_objects(int grp_cur, int object_idx[], byte mode)
5553 {
5554         int i, j, k, object_cnt = 0;
5555
5556         /* Get a list of x_char in this group */
5557         byte group_tval = object_group_tval[grp_cur];
5558
5559         /* Check every object */
5560         for (i = 0; i < max_k_idx; i++)
5561         {
5562                 /* Access the object */
5563                 object_kind *k_ptr = &k_info[i];
5564
5565                 /* Skip empty objects */
5566                 if (!k_ptr->name) continue;
5567
5568                 if (mode & 0x02)
5569                 {
5570                         /* Any objects will be displayed */
5571                 }
5572                 else
5573                 {
5574                         if (!p_ptr->wizard)
5575                         {
5576                                 /* Skip non-flavoured objects */
5577                                 if (!k_ptr->flavor) continue;
5578
5579                                 /* Require objects ever seen */
5580                                 if (!k_ptr->aware) continue;
5581                         }
5582
5583                         /* Skip items with no distribution (special artifacts) */
5584                         for (j = 0, k = 0; j < 4; j++) k += k_ptr->chance[j];
5585                         if (!k) continue;
5586                 }
5587
5588                 /* Check for objects in the group */
5589                 if (TV_LIFE_BOOK == group_tval)
5590                 {
5591                         /* Hack -- All spell books */
5592                         if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HISSATSU_BOOK)
5593                         {
5594                                 /* Add the object */
5595                                 object_idx[object_cnt++] = i;
5596                         }
5597                         else continue;
5598                 }
5599                 else if (k_ptr->tval == group_tval)
5600                 {
5601                         /* Add the object */
5602                         object_idx[object_cnt++] = i;
5603                 }
5604                 else continue;
5605
5606                 /* XXX Hack -- Just checking for non-empty group */
5607                 if (mode & 0x01) break;
5608         }
5609
5610         /* Terminate the list */
5611         object_idx[object_cnt] = -1;
5612
5613         /* Return the number of objects */
5614         return object_cnt;
5615 }
5616
5617
5618 /*
5619  * Description of each feature group.
5620  */
5621 static cptr feature_group_text[] = 
5622 {
5623         "terrains",
5624         NULL
5625 };
5626
5627
5628 /*
5629  * Build a list of feature indexes in the given group. Return the number
5630  * of features in the group.
5631  *
5632  * mode & 0x01 : check for non-empty group
5633  */
5634 static int collect_features(int grp_cur, int *feat_idx, byte mode)
5635 {
5636         int i, feat_cnt = 0;
5637
5638         /* Unused;  There is a single group. */
5639         (void)grp_cur;
5640
5641         /* Check every feature */
5642         for (i = 0; i < max_f_idx; i++)
5643         {
5644                 /* Access the index */
5645                 feature_type *f_ptr = &f_info[i];
5646
5647                 /* Skip empty index */
5648                 if (!f_ptr->name) continue;
5649
5650                 /* Skip mimiccing features */
5651                 if (f_ptr->mimic != i) continue;
5652
5653                 /* Add the index */
5654                 feat_idx[feat_cnt++] = i;
5655
5656                 /* XXX Hack -- Just checking for non-empty group */
5657                 if (mode & 0x01) break;
5658         }
5659
5660         /* Terminate the list */
5661         feat_idx[feat_cnt] = -1;
5662
5663         /* Return the number of races */
5664         return feat_cnt;
5665 }
5666
5667
5668 #if 0
5669 /*
5670  * Build a list of monster indexes in the given group. Return the number
5671  * of monsters in the group.
5672  */
5673 static int collect_artifacts(int grp_cur, int object_idx[])
5674 {
5675         int i, object_cnt = 0;
5676
5677         /* Get a list of x_char in this group */
5678         byte group_tval = object_group_tval[grp_cur];
5679
5680         /* Check every object */
5681         for (i = 0; i < max_a_idx; i++)
5682         {
5683                 /* Access the artifact */
5684                 artifact_type *a_ptr = &a_info[i];
5685
5686                 /* Skip empty artifacts */
5687                 if (!a_ptr->name) continue;
5688
5689                 /* Skip "uncreated" artifacts */
5690                 if (!a_ptr->cur_num) continue;
5691
5692                 /* Check for race in the group */
5693                 if (a_ptr->tval == group_tval)
5694                 {
5695                         /* Add the race */
5696                         object_idx[object_cnt++] = i;
5697                 }
5698         }
5699
5700         /* Terminate the list */
5701         object_idx[object_cnt] = 0;
5702
5703         /* Return the number of races */
5704         return object_cnt;
5705 }
5706 #endif /* 0 */
5707
5708
5709 /*
5710  * Encode the screen colors
5711  */
5712 static char hack[17] = "dwsorgbuDWvyRGBU";
5713
5714
5715 /*
5716  * Hack -- load a screen dump from a file
5717  */
5718 void do_cmd_load_screen(void)
5719 {
5720         int i, y, x;
5721
5722         byte a = 0;
5723         char c = ' ';
5724
5725         bool okay = TRUE;
5726
5727         FILE *fff;
5728
5729         char buf[1024];
5730
5731         int wid, hgt;
5732
5733         Term_get_size(&wid, &hgt);
5734
5735         /* Build the filename */
5736         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
5737
5738         /* Append to the file */
5739         fff = my_fopen(buf, "r");
5740
5741         /* Oops */
5742         if (!fff) {
5743 #ifdef JP
5744                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
5745 #else
5746                 msg_format("Failed to open %s.", buf);
5747 #endif
5748                 msg_print(NULL);
5749                 return;
5750         }
5751
5752
5753         /* Save the screen */
5754         screen_save();
5755
5756         /* Clear the screen */
5757         Term_clear();
5758
5759
5760         /* Load the screen */
5761         for (y = 0; okay; y++)
5762         {
5763                 /* Get a line of data including control code */
5764                 if (!fgets(buf, 1024, fff)) okay = FALSE;
5765
5766                 /* Get the blank line */
5767                 if (buf[0] == '\n' || buf[0] == '\0') break;
5768
5769                 /* Ignore too large screen image */
5770                 if (y >= hgt) continue;
5771
5772                 /* Show each row */
5773                 for (x = 0; x < wid - 1; x++)
5774                 {
5775                         /* End of line */
5776                         if (buf[x] == '\n' || buf[x] == '\0') break;
5777
5778                         /* Put the attr/char */
5779                         Term_draw(x, y, TERM_WHITE, buf[x]);
5780                 }
5781         }
5782
5783         /* Dump the screen */
5784         for (y = 0; okay; y++)
5785         {
5786                 /* Get a line of data including control code */
5787                 if (!fgets(buf, 1024, fff)) okay = FALSE;
5788
5789                 /* Get the blank line */
5790                 if (buf[0] == '\n' || buf[0] == '\0') break;
5791
5792                 /* Ignore too large screen image */
5793                 if (y >= hgt) continue;
5794
5795                 /* Dump each row */
5796                 for (x = 0; x < wid - 1; x++)
5797                 {
5798                         /* End of line */
5799                         if (buf[x] == '\n' || buf[x] == '\0') break;
5800
5801                         /* Get the attr/char */
5802                         (void)(Term_what(x, y, &a, &c));
5803
5804                         /* Look up the attr */
5805                         for (i = 0; i < 16; i++)
5806                         {
5807                                 /* Use attr matches */
5808                                 if (hack[i] == buf[x]) a = i;
5809                         }
5810
5811                         /* Put the attr/char */
5812                         Term_draw(x, y, a, c);
5813                 }
5814         }
5815
5816
5817         /* Close it */
5818         my_fclose(fff);
5819
5820
5821         /* Message */
5822 #ifdef JP
5823         prt("¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤µ¤ì¤¿²èÌÌ(µ­Ç°»£±Æ)¤ò¥í¡¼¥É¤·¤Þ¤·¤¿¡£", 0, 0);
5824 #else
5825         msg_print("Screen dump loaded.");
5826 #endif
5827
5828         flush();
5829         inkey();
5830
5831
5832         /* Restore the screen */
5833         screen_load();
5834 }
5835
5836
5837
5838
5839 cptr inven_res_label = 
5840 #ifdef JP
5841  "                               »ÀÅŲÐÎäÆǸ÷°ÇÇ˹ì¹ö°øÆÙÎô ÌÕÉÝÍðáãÆ©Ì¿´¶¾ÃÉüÉâ";
5842 #else
5843  "                               AcElFiCoPoLiDkShSoNtNxCaDi BlFeCfFaSeHlEpSdRgLv";
5844 #endif
5845
5846
5847 #ifdef JP
5848 #define IM_FLAG_STR  "¡ö"
5849 #define HAS_FLAG_STR "¡Ü"
5850 #define NO_FLAG_STR  "¡¦"
5851 #else
5852 #define IM_FLAG_STR  "* "
5853 #define HAS_FLAG_STR "+ "
5854 #define NO_FLAG_STR  ". "
5855 #endif
5856
5857 #define print_im_or_res_flag(IM, RES) \
5858 { \
5859         fputs(have_flag(flgs, (IM)) ? IM_FLAG_STR : \
5860               (have_flag(flgs, (RES)) ? HAS_FLAG_STR : NO_FLAG_STR), fff); \
5861 }
5862
5863 #define print_flag(TR) \
5864 { \
5865         fputs(have_flag(flgs, (TR)) ? HAS_FLAG_STR : NO_FLAG_STR, fff); \
5866 }
5867
5868
5869 /* XTRA HACK RESLIST */
5870 static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr, int *j, byte tval, char *where)
5871 {
5872         char o_name[MAX_NLEN];
5873         u32b flgs[TR_FLAG_SIZE];
5874
5875         if (!o_ptr->k_idx) return;
5876         if (o_ptr->tval != tval) return;
5877
5878         /* Identified items only */
5879         if (!object_is_known(o_ptr)) return;
5880
5881         /*
5882          * HACK:Ring of Lordly protection and Dragon equipment
5883          * have random resistances.
5884          */
5885         if ((object_is_wearable(o_ptr) && object_is_ego(o_ptr))
5886             || ((tval == TV_AMULET) && (o_ptr->sval == SV_AMULET_RESISTANCE))
5887             || ((tval == TV_RING) && (o_ptr->sval == SV_RING_LORDLY))
5888             || ((tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD))
5889             || ((tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM))
5890             || ((tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES))
5891             || ((tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE))
5892             || object_is_artifact(o_ptr))
5893         {
5894                 int i = 0;
5895                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5896
5897                 while (o_name[i] && (i < 26))
5898                 {
5899 #ifdef JP
5900                         if (iskanji(o_name[i])) i++;
5901 #endif
5902                         i++;
5903                 }
5904
5905                 if (i < 28)
5906                 {
5907                         while (i < 28)
5908                         {
5909                                 o_name[i] = ' '; i++;
5910                         }
5911                 }
5912                 o_name[i] = '\0';
5913
5914                 fprintf(fff, "%s %s", where, o_name);
5915
5916                 if (!(o_ptr->ident & (IDENT_MENTAL)))
5917                 {
5918 #ifdef JP
5919                         fputs("-------ÉÔÌÀ--------------- -------ÉÔÌÀ---------\n", fff);
5920 #else
5921                         fputs("-------unknown------------ -------unknown------\n", fff);
5922 #endif
5923                 }
5924                 else
5925                 {
5926                         object_flags_known(o_ptr, flgs);
5927
5928                         print_im_or_res_flag(TR_IM_ACID, TR_RES_ACID);
5929                         print_im_or_res_flag(TR_IM_ELEC, TR_RES_ELEC);
5930                         print_im_or_res_flag(TR_IM_FIRE, TR_RES_FIRE);
5931                         print_im_or_res_flag(TR_IM_COLD, TR_RES_COLD);
5932                         print_flag(TR_RES_POIS);
5933                         print_flag(TR_RES_LITE);
5934                         print_flag(TR_RES_DARK);
5935                         print_flag(TR_RES_SHARDS);
5936                         print_flag(TR_RES_SOUND);
5937                         print_flag(TR_RES_NETHER);
5938                         print_flag(TR_RES_NEXUS);
5939                         print_flag(TR_RES_CHAOS);
5940                         print_flag(TR_RES_DISEN);
5941
5942                         fputs(" ", fff);
5943
5944                         print_flag(TR_RES_BLIND);
5945                         print_flag(TR_RES_FEAR);
5946                         print_flag(TR_RES_CONF);
5947                         print_flag(TR_FREE_ACT);
5948                         print_flag(TR_SEE_INVIS);
5949                         print_flag(TR_HOLD_LIFE);
5950                         print_flag(TR_TELEPATHY);
5951                         print_flag(TR_SLOW_DIGEST);
5952                         print_flag(TR_REGEN);
5953                         print_flag(TR_LEVITATION);
5954
5955                         fputc('\n', fff);
5956                 }
5957                 (*j)++;
5958                 if (*j == 9)
5959                 {
5960                         *j = 0;
5961                         fprintf(fff, "%s\n", inven_res_label);
5962                 }
5963         }
5964 }
5965
5966 /*
5967  * Display *ID* ed weapons/armors's resistances
5968  */
5969 static void do_cmd_knowledge_inven(void)
5970 {
5971         FILE *fff;
5972
5973         char file_name[1024];
5974
5975         store_type  *st_ptr;
5976
5977         byte tval;
5978         int i = 0;
5979         int j = 0;
5980
5981         char  where[32];
5982
5983         /* Open a new file */
5984         fff = my_fopen_temp(file_name, 1024);
5985         if (!fff)
5986         {
5987 #ifdef JP
5988             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
5989 #else
5990             msg_format("Failed to create temporary file %s.", file_name);
5991 #endif
5992             msg_print(NULL);
5993             return;
5994         }
5995         fprintf(fff, "%s\n", inven_res_label);
5996
5997         for (tval = TV_WEARABLE_BEGIN; tval <= TV_WEARABLE_END; tval++)
5998         {
5999                 if (j != 0)
6000                 {
6001                         for (; j < 9; j++) fputc('\n', fff);
6002                         j = 0;
6003                         fprintf(fff, "%s\n", inven_res_label);
6004                 }
6005
6006 #ifdef JP
6007                 strcpy(where, "Áõ");
6008 #else
6009                 strcpy(where, "E ");
6010 #endif
6011                 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6012                 {
6013                         do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
6014                 }
6015
6016 #ifdef JP
6017                 strcpy(where, "»ý");
6018 #else
6019                 strcpy(where, "I ");
6020 #endif
6021                 for (i = 0; i < INVEN_PACK; i++)
6022                 {
6023                         do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
6024                 }
6025
6026                 st_ptr = &town[1].store[STORE_HOME];
6027 #ifdef JP
6028                 strcpy(where, "²È");
6029 #else
6030                 strcpy(where, "H ");
6031 #endif
6032
6033                 for (i = 0; i < st_ptr->stock_num; i++)
6034                 {
6035                         do_cmd_knowledge_inven_aux(fff, &st_ptr->stock[i], &j, tval, where);
6036                 }
6037         }
6038
6039         /* Close the file */
6040         my_fclose(fff);
6041
6042         /* Display the file contents */
6043 #ifdef JP
6044         show_file(TRUE, file_name, "*´ÕÄê*ºÑ¤ßÉð´ï/Ëɶñ¤ÎÂÑÀ­¥ê¥¹¥È", 0, 0);
6045 #else
6046         show_file(TRUE, file_name, "Resistances of *identified* equipment", 0, 0);
6047 #endif
6048
6049         /* Remove the file */
6050         fd_kill(file_name);
6051 }
6052
6053
6054 void do_cmd_save_screen_html_aux(char *filename, int message)
6055 {
6056         int y, x, i;
6057
6058         byte a = 0, old_a = 0;
6059         char c = ' ';
6060
6061         FILE *fff, *tmpfff;
6062         char buf[2048];
6063
6064         int yomikomu = 0;
6065         cptr tags[4] = {
6066                 "HEADER_START:",
6067                 "HEADER_END:",
6068                 "FOOTER_START:",
6069                 "FOOTER_END:",
6070         };
6071
6072         cptr html_head[] = {
6073                 "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
6074                 "<pre>",
6075                 0,
6076         };
6077         cptr html_foot[] = {
6078                 "</pre>\n",
6079                 "</body>\n</html>\n",
6080                 0,
6081         };
6082
6083         int wid, hgt;
6084
6085         Term_get_size(&wid, &hgt);
6086
6087         /* File type is "TEXT" */
6088         FILE_TYPE(FILE_TYPE_TEXT);
6089
6090         /* Append to the file */
6091         fff = my_fopen(filename, "w");
6092
6093         /* Oops */
6094         if (!fff) {
6095                 if (message) {
6096 #ifdef JP
6097                     msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", filename);
6098 #else
6099                     msg_format("Failed to open file %s.", filename);
6100 #endif
6101                     msg_print(NULL);
6102                 }
6103                 
6104                 return;
6105         }
6106
6107         /* Save the screen */
6108         if (message)
6109                 screen_save();
6110
6111         /* Build the filename */
6112         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
6113         tmpfff = my_fopen(buf, "r");
6114         if (!tmpfff) {
6115                 for (i = 0; html_head[i]; i++)
6116                         fprintf(fff, html_head[i]);
6117         }
6118         else {
6119                 yomikomu = 0;
6120                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
6121                         if (!yomikomu) {
6122                                 if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
6123                                         yomikomu = 1;
6124                         }
6125                         else {
6126                                 if (strncmp(buf, tags[1], strlen(tags[1])) == 0)
6127                                         break;
6128                                 fprintf(fff, "%s\n", buf);
6129                         }
6130                 }
6131         }
6132
6133         /* Dump the screen */
6134         for (y = 0; y < hgt; y++)
6135         {
6136                 /* Start the row */
6137                 if (y != 0)
6138                         fprintf(fff, "\n");
6139
6140                 /* Dump each row */
6141                 for (x = 0; x < wid - 1; x++)
6142                 {
6143                         int rv, gv, bv;
6144                         cptr cc = NULL;
6145                         /* Get the attr/char */
6146                         (void)(Term_what(x, y, &a, &c));
6147
6148                         switch (c)
6149                         {
6150                         case '&': cc = "&amp;"; break;
6151                         case '<': cc = "&lt;"; break;
6152                         case '>': cc = "&gt;"; break;
6153 #ifdef WINDOWS
6154                         case 0x1f: c = '.'; break;
6155                         case 0x7f: c = (a == 0x09) ? '%' : '#'; break;
6156 #endif
6157                         }
6158
6159                         a = a & 0x0F;
6160                         if ((y == 0 && x == 0) || a != old_a) {
6161                                 rv = angband_color_table[a][1];
6162                                 gv = angband_color_table[a][2];
6163                                 bv = angband_color_table[a][3];
6164                                 fprintf(fff, "%s<font color=\"#%02x%02x%02x\">", 
6165                                         ((y == 0 && x == 0) ? "" : "</font>"), rv, gv, bv);
6166                                 old_a = a;
6167                         }
6168                         if (cc)
6169                                 fprintf(fff, "%s", cc);
6170                         else
6171                                 fprintf(fff, "%c", c);
6172                 }
6173         }
6174         fprintf(fff, "</font>");
6175
6176         if (!tmpfff) {
6177                 for (i = 0; html_foot[i]; i++)
6178                         fprintf(fff, html_foot[i]);
6179         }
6180         else {
6181                 rewind(tmpfff);
6182                 yomikomu = 0;
6183                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
6184                         if (!yomikomu) {
6185                                 if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
6186                                         yomikomu = 1;
6187                         }
6188                         else {
6189                                 if (strncmp(buf, tags[3], strlen(tags[3])) == 0)
6190                                         break;
6191                                 fprintf(fff, "%s\n", buf);
6192                         }
6193                 }
6194                 my_fclose(tmpfff);
6195         }
6196
6197         /* Skip a line */
6198         fprintf(fff, "\n");
6199
6200         /* Close it */
6201         my_fclose(fff);
6202
6203         /* Message */
6204         if (message) {
6205 #ifdef JP
6206         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6207 #else
6208                 msg_print("Screen dump saved.");
6209 #endif
6210                 msg_print(NULL);
6211         }
6212
6213         /* Restore the screen */
6214         if (message)
6215                 screen_load();
6216 }
6217
6218 /*
6219  * Hack -- save a screen dump to a file
6220  */
6221 static void do_cmd_save_screen_html(void)
6222 {
6223         char buf[1024], tmp[256] = "screen.html";
6224
6225 #ifdef JP
6226         if (!get_string("¥Õ¥¡¥¤¥ë̾: ", tmp, 80))
6227 #else
6228         if (!get_string("File name: ", tmp, 80))
6229 #endif
6230                 return;
6231
6232         /* Build the filename */
6233         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
6234
6235         msg_print(NULL);
6236
6237         do_cmd_save_screen_html_aux(buf, 1);
6238 }
6239
6240
6241 /*
6242  * Redefinable "save_screen" action
6243  */
6244 void (*screendump_aux)(void) = NULL;
6245
6246
6247 /*
6248  * Hack -- save a screen dump to a file
6249  */
6250 void do_cmd_save_screen(void)
6251 {
6252         bool old_use_graphics = use_graphics;
6253         bool html_dump = FALSE;
6254
6255         int wid, hgt;
6256
6257 #ifdef JP
6258         prt("µ­Ç°»£±Æ¤·¤Þ¤¹¤«¡© [(y)es/(h)tml/(n)o] ", 0, 0);
6259 #else
6260         prt("Save screen dump? [(y)es/(h)tml/(n)o] ", 0, 0);
6261 #endif
6262         while(TRUE)
6263         {
6264                 char c = inkey();
6265                 if (c == 'Y' || c == 'y')
6266                         break;
6267                 else if (c == 'H' || c == 'h')
6268                 {
6269                         html_dump = TRUE;
6270                         break;
6271                 }
6272                 else
6273                 {
6274                         prt("", 0, 0);
6275                         return;
6276                 }
6277         }
6278
6279         Term_get_size(&wid, &hgt);
6280
6281         if (old_use_graphics)
6282         {
6283                 use_graphics = FALSE;
6284                 reset_visuals();
6285
6286                 /* Redraw everything */
6287                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6288
6289                 /* Hack -- update */
6290                 handle_stuff();
6291         }
6292
6293         if (html_dump)
6294         {
6295                 do_cmd_save_screen_html();
6296                 do_cmd_redraw();
6297         }
6298
6299         /* Do we use a special screendump function ? */
6300         else if (screendump_aux)
6301         {
6302                 /* Dump the screen to a graphics file */
6303                 (*screendump_aux)();
6304         }
6305         else /* Dump the screen as text */
6306         {
6307                 int y, x;
6308
6309                 byte a = 0;
6310                 char c = ' ';
6311
6312                 FILE *fff;
6313
6314                 char buf[1024];
6315
6316                 /* Build the filename */
6317                 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
6318
6319                 /* File type is "TEXT" */
6320                 FILE_TYPE(FILE_TYPE_TEXT);
6321
6322                 /* Append to the file */
6323                 fff = my_fopen(buf, "w");
6324
6325                 /* Oops */
6326                 if (!fff)
6327                 {
6328 #ifdef JP
6329                         msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
6330 #else
6331                         msg_format("Failed to open file %s.", buf);
6332 #endif
6333                         msg_print(NULL);
6334                         return;
6335                 }
6336
6337
6338                 /* Save the screen */
6339                 screen_save();
6340
6341
6342                 /* Dump the screen */
6343                 for (y = 0; y < hgt; y++)
6344                 {
6345                         /* Dump each row */
6346                         for (x = 0; x < wid - 1; x++)
6347                         {
6348                                 /* Get the attr/char */
6349                                 (void)(Term_what(x, y, &a, &c));
6350
6351                                 /* Dump it */
6352                                 buf[x] = c;
6353                         }
6354
6355                         /* Terminate */
6356                         buf[x] = '\0';
6357
6358                         /* End the row */
6359                         fprintf(fff, "%s\n", buf);
6360                 }
6361
6362                 /* Skip a line */
6363                 fprintf(fff, "\n");
6364
6365
6366                 /* Dump the screen */
6367                 for (y = 0; y < hgt; y++)
6368                 {
6369                         /* Dump each row */
6370                         for (x = 0; x < wid - 1; x++)
6371                         {
6372                                 /* Get the attr/char */
6373                                 (void)(Term_what(x, y, &a, &c));
6374
6375                                 /* Dump it */
6376                                 buf[x] = hack[a&0x0F];
6377                         }
6378
6379                         /* Terminate */
6380                         buf[x] = '\0';
6381
6382                         /* End the row */
6383                         fprintf(fff, "%s\n", buf);
6384                 }
6385
6386                 /* Skip a line */
6387                 fprintf(fff, "\n");
6388
6389
6390                 /* Close it */
6391                 my_fclose(fff);
6392
6393                 /* Message */
6394 #ifdef JP
6395         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6396 #else
6397                 msg_print("Screen dump saved.");
6398 #endif
6399
6400                 msg_print(NULL);
6401
6402
6403                 /* Restore the screen */
6404                 screen_load();
6405         }
6406
6407         if (old_use_graphics)
6408         {
6409                 use_graphics = TRUE;
6410                 reset_visuals();
6411
6412                 /* Redraw everything */
6413                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6414
6415                 /* Hack -- update */
6416                 handle_stuff();
6417         }
6418 }
6419
6420
6421 /*
6422  * Sorting hook -- Comp function -- see below
6423  *
6424  * We use "u" to point to array of monster indexes,
6425  * and "v" to select the type of sorting to perform on "u".
6426  */
6427 static bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
6428 {
6429         u16b *who = (u16b*)(u);
6430
6431         u16b *why = (u16b*)(v);
6432
6433         int w1 = who[a];
6434         int w2 = who[b];
6435
6436         int z1, z2;
6437
6438         /* Sort by total kills */
6439         if (*why >= 3)
6440         {
6441                 /* Extract total kills */
6442                 z1 = a_info[w1].tval;
6443                 z2 = a_info[w2].tval;
6444
6445                 /* Compare total kills */
6446                 if (z1 < z2) return (TRUE);
6447                 if (z1 > z2) return (FALSE);
6448         }
6449
6450
6451         /* Sort by monster level */
6452         if (*why >= 2)
6453         {
6454                 /* Extract levels */
6455                 z1 = a_info[w1].sval;
6456                 z2 = a_info[w2].sval;
6457
6458                 /* Compare levels */
6459                 if (z1 < z2) return (TRUE);
6460                 if (z1 > z2) return (FALSE);
6461         }
6462
6463
6464         /* Sort by monster experience */
6465         if (*why >= 1)
6466         {
6467                 /* Extract experience */
6468                 z1 = a_info[w1].level;
6469                 z2 = a_info[w2].level;
6470
6471                 /* Compare experience */
6472                 if (z1 < z2) return (TRUE);
6473                 if (z1 > z2) return (FALSE);
6474         }
6475
6476
6477         /* Compare indexes */
6478         return (w1 <= w2);
6479 }
6480
6481
6482 /*
6483  * Sorting hook -- Swap function -- see below
6484  *
6485  * We use "u" to point to array of monster indexes,
6486  * and "v" to select the type of sorting to perform.
6487  */
6488 static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
6489 {
6490         u16b *who = (u16b*)(u);
6491
6492         u16b holder;
6493
6494         /* Unused */
6495         (void)v;
6496
6497         /* Swap */
6498         holder = who[a];
6499         who[a] = who[b];
6500         who[b] = holder;
6501 }
6502
6503
6504 /*
6505  * Check the status of "artifacts"
6506  */
6507 static void do_cmd_knowledge_artifacts(void)
6508 {
6509         int i, k, z, x, y, n = 0;
6510         u16b why = 3;
6511         s16b *who;
6512
6513         FILE *fff;
6514
6515         char file_name[1024];
6516
6517         char base_name[MAX_NLEN];
6518
6519         bool *okay;
6520
6521         /* Open a new file */
6522         fff = my_fopen_temp(file_name, 1024);
6523
6524         if (!fff) {
6525 #ifdef JP
6526             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6527 #else
6528             msg_format("Failed to create temporary file %s.", file_name);
6529 #endif
6530             msg_print(NULL);
6531             return;
6532         }
6533
6534         /* Allocate the "who" array */
6535         C_MAKE(who, max_a_idx, s16b);
6536
6537         /* Allocate the "okay" array */
6538         C_MAKE(okay, max_a_idx, bool);
6539
6540         /* Scan the artifacts */
6541         for (k = 0; k < max_a_idx; k++)
6542         {
6543                 artifact_type *a_ptr = &a_info[k];
6544
6545                 /* Default */
6546                 okay[k] = FALSE;
6547
6548                 /* Skip "empty" artifacts */
6549                 if (!a_ptr->name) continue;
6550
6551                 /* Skip "uncreated" artifacts */
6552                 if (!a_ptr->cur_num) continue;
6553
6554                 /* Assume okay */
6555                 okay[k] = TRUE;
6556         }
6557
6558         /* Check the dungeon */
6559         for (y = 0; y < cur_hgt; y++)
6560         {
6561                 for (x = 0; x < cur_wid; x++)
6562                 {
6563                         cave_type *c_ptr = &cave[y][x];
6564
6565                         s16b this_o_idx, next_o_idx = 0;
6566
6567                         /* Scan all objects in the grid */
6568                         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
6569                         {
6570                                 object_type *o_ptr;
6571
6572                                 /* Acquire object */
6573                                 o_ptr = &o_list[this_o_idx];
6574
6575                                 /* Acquire next object */
6576                                 next_o_idx = o_ptr->next_o_idx;
6577
6578                                 /* Ignore non-artifacts */
6579                                 if (!object_is_fixed_artifact(o_ptr)) continue;
6580
6581                                 /* Ignore known items */
6582                                 if (object_is_known(o_ptr)) continue;
6583
6584                                 /* Note the artifact */
6585                                 okay[o_ptr->name1] = FALSE;
6586                         }
6587                 }
6588         }
6589
6590         /* Check the inventory and equipment */
6591         for (i = 0; i < INVEN_TOTAL; i++)
6592         {
6593                 object_type *o_ptr = &inventory[i];
6594
6595                 /* Ignore non-objects */
6596                 if (!o_ptr->k_idx) continue;
6597
6598                 /* Ignore non-artifacts */
6599                 if (!object_is_fixed_artifact(o_ptr)) continue;
6600
6601                 /* Ignore known items */
6602                 if (object_is_known(o_ptr)) continue;
6603
6604                 /* Note the artifact */
6605                 okay[o_ptr->name1] = FALSE;
6606         }
6607
6608         for (k = 0; k < max_a_idx; k++)
6609         {
6610                 if (okay[k]) who[n++] = k;
6611         }
6612
6613         /* Select the sort method */
6614         ang_sort_comp = ang_sort_art_comp;
6615         ang_sort_swap = ang_sort_art_swap;
6616
6617         /* Sort the array by dungeon depth of monsters */
6618         ang_sort(who, &why, n);
6619
6620         /* Scan the artifacts */
6621         for (k = 0; k < n; k++)
6622         {
6623                 artifact_type *a_ptr = &a_info[who[k]];
6624
6625                 /* Paranoia */
6626 #ifdef JP
6627                 strcpy(base_name, "̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à");
6628 #else
6629                 strcpy(base_name, "Unknown Artifact");
6630 #endif
6631
6632
6633                 /* Obtain the base object type */
6634                 z = lookup_kind(a_ptr->tval, a_ptr->sval);
6635
6636                 /* Real object */
6637                 if (z)
6638                 {
6639                         object_type forge;
6640                         object_type *q_ptr;
6641
6642                         /* Get local object */
6643                         q_ptr = &forge;
6644
6645                         /* Create fake object */
6646                         object_prep(q_ptr, z);
6647
6648                         /* Make it an artifact */
6649                         q_ptr->name1 = (byte)who[k];
6650
6651                         /* Display as if known */
6652                         q_ptr->ident |= IDENT_STORE;
6653
6654                         /* Describe the artifact */
6655                         object_desc(base_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6656                 }
6657
6658                 /* Hack -- Build the artifact name */
6659 #ifdef JP
6660                 fprintf(fff, "     %s\n", base_name);
6661 #else
6662                 fprintf(fff, "     The %s\n", base_name);
6663 #endif
6664
6665         }
6666
6667         /* Free the "who" array */
6668         C_KILL(who, max_a_idx, s16b);
6669
6670         /* Free the "okay" array */
6671         C_KILL(okay, max_a_idx, bool);
6672
6673         /* Close the file */
6674         my_fclose(fff);
6675
6676         /* Display the file contents */
6677 #ifdef JP
6678         show_file(TRUE, file_name, "´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à", 0, 0);
6679 #else
6680         show_file(TRUE, file_name, "Artifacts Seen", 0, 0);
6681 #endif
6682
6683
6684         /* Remove the file */
6685         fd_kill(file_name);
6686 }
6687
6688
6689 /*
6690  * Display known uniques
6691  * With "XTRA HACK UNIQHIST" (Originally from XAngband)
6692  */
6693 static void do_cmd_knowledge_uniques(void)
6694 {
6695         int i, k, n = 0;
6696         u16b why = 2;
6697         s16b *who;
6698
6699         FILE *fff;
6700
6701         char file_name[1024];
6702
6703         int n_alive[10];
6704         int n_alive_surface = 0;
6705         int n_alive_over100 = 0;
6706         int n_alive_total = 0;
6707         int max_lev = -1;
6708
6709         for (i = 0; i < 10; i++) n_alive[i] = 0;
6710
6711         /* Open a new file */
6712         fff = my_fopen_temp(file_name, 1024);
6713
6714         if (!fff)
6715         {
6716 #ifdef JP
6717             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6718 #else
6719             msg_format("Failed to create temporary file %s.", file_name);
6720 #endif
6721             msg_print(NULL);
6722             return;
6723         }
6724
6725         /* Allocate the "who" array */
6726         C_MAKE(who, max_r_idx, s16b);
6727
6728         /* Scan the monsters */
6729         for (i = 1; i < max_r_idx; i++)
6730         {
6731                 monster_race *r_ptr = &r_info[i];
6732                 int          lev;
6733
6734                 if (!r_ptr->name) continue;
6735
6736                 /* Require unique monsters */
6737                 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6738
6739                 /* Only display "known" uniques */
6740                 if (!cheat_know && !r_ptr->r_sights) continue;
6741
6742                 /* Only print rarity <= 100 uniques */
6743                 if (!r_ptr->rarity || ((r_ptr->rarity > 100) && !(r_ptr->flags1 & RF1_QUESTOR))) continue;
6744
6745                 /* Only "alive" uniques */
6746                 if (r_ptr->max_num == 0) continue;
6747
6748                 if (r_ptr->level)
6749                 {
6750                         lev = (r_ptr->level - 1) / 10;
6751                         if (lev < 10)
6752                         {
6753                                 n_alive[lev]++;
6754                                 if (max_lev < lev) max_lev = lev;
6755                         }
6756                         else n_alive_over100++;
6757                 }
6758                 else n_alive_surface++;
6759
6760                 /* Collect "appropriate" monsters */
6761                 who[n++] = i;
6762         }
6763
6764         /* Select the sort method */
6765         ang_sort_comp = ang_sort_comp_hook;
6766         ang_sort_swap = ang_sort_swap_hook;
6767
6768         /* Sort the array by dungeon depth of monsters */
6769         ang_sort(who, &why, n);
6770
6771         if (n_alive_surface)
6772         {
6773 #ifdef JP
6774                 fprintf(fff, "     ÃϾ堠À¸Â¸: %3dÂÎ\n", n_alive_surface);
6775 #else
6776                 fprintf(fff, "      Surface  alive: %3d\n", n_alive_surface);
6777 #endif
6778                 n_alive_total += n_alive_surface;
6779         }
6780         for (i = 0; i <= max_lev; i++)
6781         {
6782 #ifdef JP
6783                 fprintf(fff, "%3d-%3d³¬  À¸Â¸: %3dÂÎ\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
6784 #else
6785                 fprintf(fff, "Level %3d-%3d  alive: %3d\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
6786 #endif
6787                 n_alive_total += n_alive[i];
6788         }
6789         if (n_alive_over100)
6790         {
6791 #ifdef JP
6792                 fprintf(fff, "101-   ³¬  À¸Â¸: %3dÂÎ\n", n_alive_over100);
6793 #else
6794                 fprintf(fff, "Level 101-     alive: %3d\n", n_alive_over100);
6795 #endif
6796                 n_alive_total += n_alive_over100;
6797         }
6798
6799         if (n_alive_total)
6800         {
6801 #ifdef JP
6802                 fputs("---------  -----------\n", fff);
6803                 fprintf(fff, "     ¹ç·×  À¸Â¸: %3dÂÎ\n\n", n_alive_total);
6804 #else
6805                 fputs("-------------  ----------\n", fff);
6806                 fprintf(fff, "        Total  alive: %3d\n\n", n_alive_total);
6807 #endif
6808         }
6809         else
6810         {
6811 #ifdef JP
6812                 fputs("¸½ºß¤Ï´ûÃΤÎÀ¸Â¸¥æ¥Ë¡¼¥¯¤Ï¤¤¤Þ¤»¤ó¡£\n", fff);
6813 #else
6814                 fputs("No known uniques alive.\n", fff);
6815 #endif
6816         }
6817
6818         /* Scan the monster races */
6819         for (k = 0; k < n; k++)
6820         {
6821                 monster_race *r_ptr = &r_info[who[k]];
6822
6823                 /* Print a message */
6824 #ifdef JP
6825                 fprintf(fff, "     %s (¥ì¥Ù¥ë%d)\n", r_name + r_ptr->name, r_ptr->level);
6826 #else
6827                 fprintf(fff, "     %s (level %d)\n", r_name + r_ptr->name, r_ptr->level);
6828 #endif
6829         }
6830
6831         /* Free the "who" array */
6832         C_KILL(who, max_r_idx, s16b);
6833
6834         /* Close the file */
6835         my_fclose(fff);
6836
6837         /* Display the file contents */
6838 #ifdef JP
6839         show_file(TRUE, file_name, "¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼", 0, 0);
6840 #else
6841         show_file(TRUE, file_name, "Alive Uniques", 0, 0);
6842 #endif
6843
6844
6845         /* Remove the file */
6846         fd_kill(file_name);
6847 }
6848
6849
6850 /*
6851  * Display weapon-exp
6852  */
6853 static void do_cmd_knowledge_weapon_exp(void)
6854 {
6855         int i, j, num, weapon_exp;
6856
6857         FILE *fff;
6858
6859         char file_name[1024];
6860         char tmp[30];
6861
6862         /* Open a new file */
6863         fff = my_fopen_temp(file_name, 1024);
6864         if (!fff) {
6865 #ifdef JP
6866             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6867 #else
6868             msg_format("Failed to create temporary file %s.", file_name);
6869 #endif
6870             msg_print(NULL);
6871             return;
6872         }
6873
6874         for (i = 0; i < 5; i++)
6875         {
6876                 for (num = 0; num < 64; num++)
6877                 {
6878                         for (j = 0; j < max_k_idx; j++)
6879                         {
6880                                 object_kind *k_ptr = &k_info[j];
6881
6882                                 if ((k_ptr->tval == TV_SWORD - i) && (k_ptr->sval == num))
6883                                 {
6884                                         if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
6885
6886                                         weapon_exp = p_ptr->weapon_exp[4 - i][num];
6887                                         strip_name(tmp, j);
6888                                         fprintf(fff, "%-25s ", tmp);
6889                                         if (weapon_exp >= s_info[p_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
6890                                         else fprintf(fff, " ");
6891                                         fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
6892                                         if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
6893                                         fprintf(fff, "\n");
6894                                         break;
6895                                 }
6896                         }
6897                 }
6898         }
6899
6900         /* Close the file */
6901         my_fclose(fff);
6902
6903         /* Display the file contents */
6904 #ifdef JP
6905         show_file(TRUE, file_name, "Éð´ï¤Î·Ð¸³ÃÍ", 0, 0);
6906 #else
6907         show_file(TRUE, file_name, "Weapon Proficiency", 0, 0);
6908 #endif
6909
6910
6911         /* Remove the file */
6912         fd_kill(file_name);
6913 }
6914
6915
6916 /*
6917  * Display spell-exp
6918  */
6919 static void do_cmd_knowledge_spell_exp(void)
6920 {
6921         int i = 0, spell_exp, exp_level;
6922
6923         FILE *fff;
6924         magic_type *s_ptr;
6925
6926         char file_name[1024];
6927
6928         /* Open a new file */
6929         fff = my_fopen_temp(file_name, 1024);
6930         if (!fff) {
6931 #ifdef JP
6932             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6933 #else
6934             msg_format("Failed to create temporary file %s.", file_name);
6935 #endif
6936             msg_print(NULL);
6937             return;
6938         }
6939
6940         if (p_ptr->realm1 != REALM_NONE)
6941         {
6942 #ifdef JP
6943                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm1]);
6944 #else
6945                 fprintf(fff, "%s Spellbook\n", realm_names[p_ptr->realm1]);
6946 #endif
6947                 for (i = 0; i < 32; i++)
6948                 {
6949                         if (!is_magic(p_ptr->realm1))
6950                         {
6951                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
6952                         }
6953                         else
6954                         {
6955                                 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
6956                         }
6957                         if (s_ptr->slevel >= 99) continue;
6958                         spell_exp = p_ptr->spell_exp[i];
6959                         exp_level = spell_exp_level(spell_exp);
6960                         fprintf(fff, "%-25s ", do_spell(p_ptr->realm1, i, SPELL_NAME));
6961                         if (p_ptr->realm1 == REALM_HISSATSU)
6962                                 fprintf(fff, "[--]");
6963                         else
6964                         {
6965                                 if (exp_level >= EXP_LEVEL_MASTER) fprintf(fff, "!");
6966                                 else fprintf(fff, " ");
6967                                 fprintf(fff, "%s", exp_level_str[exp_level]);
6968                         }
6969                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
6970                         fprintf(fff, "\n");
6971                 }
6972         }
6973
6974         if (p_ptr->realm2 != REALM_NONE)
6975         {
6976 #ifdef JP
6977                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm2]);
6978 #else
6979                 fprintf(fff, "\n%s Spellbook\n", realm_names[p_ptr->realm2]);
6980 #endif
6981                 for (i = 0; i < 32; i++)
6982                 {
6983                         if (!is_magic(p_ptr->realm1))
6984                         {
6985                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
6986                         }
6987                         else
6988                         {
6989                                 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][i];
6990                         }
6991                         if (s_ptr->slevel >= 99) continue;
6992
6993                         spell_exp = p_ptr->spell_exp[i + 32];
6994                         exp_level = spell_exp_level(spell_exp);
6995                         fprintf(fff, "%-25s ", do_spell(p_ptr->realm2, i, SPELL_NAME));
6996                         if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
6997                         else fprintf(fff, " ");
6998                         fprintf(fff, "%s", exp_level_str[exp_level]);
6999                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
7000                         fprintf(fff, "\n");
7001                 }
7002         }
7003
7004         /* Close the file */
7005         my_fclose(fff);
7006
7007         /* Display the file contents */
7008 #ifdef JP
7009         show_file(TRUE, file_name, "ËâË¡¤Î·Ð¸³ÃÍ", 0, 0);
7010 #else
7011         show_file(TRUE, file_name, "Spell Proficiency", 0, 0);
7012 #endif
7013
7014
7015         /* Remove the file */
7016         fd_kill(file_name);
7017 }
7018
7019
7020 /*
7021  * Display skill-exp
7022  */
7023 static void do_cmd_knowledge_skill_exp(void)
7024 {
7025         int i = 0, skill_exp;
7026
7027         FILE *fff;
7028
7029         char file_name[1024];
7030 #ifdef JP
7031         char skill_name[3][17]={"¥Þ¡¼¥·¥ã¥ë¥¢¡¼¥Ä", "ÆóÅáή          ", "¾èÇÏ            "};
7032 #else
7033         char skill_name[3][20]={"Martial Arts    ", "Dual Wielding   ", "Riding          "};
7034 #endif
7035
7036         /* Open a new file */
7037         fff = my_fopen_temp(file_name, 1024);
7038         if (!fff) {
7039 #ifdef JP
7040             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7041 #else
7042             msg_format("Failed to create temporary file %s.", file_name);
7043 #endif
7044             msg_print(NULL);
7045             return;
7046         }
7047
7048         for (i = 0; i < 3; i++)
7049         {
7050                 skill_exp = p_ptr->skill_exp[i];
7051                 fprintf(fff, "%-20s ", skill_name[i]);
7052                 if (skill_exp >= s_info[p_ptr->pclass].s_max[i]) fprintf(fff, "!");
7053                 else fprintf(fff, " ");
7054                 fprintf(fff, "%s", exp_level_str[(i == GINOU_RIDING) ? riding_exp_level(skill_exp) : weapon_exp_level(skill_exp)]);
7055                 if (cheat_xtra) fprintf(fff, " %d", skill_exp);
7056                 fprintf(fff, "\n");
7057         }
7058
7059         /* Close the file */
7060         my_fclose(fff);
7061
7062         /* Display the file contents */
7063 #ifdef JP
7064         show_file(TRUE, file_name, "µ»Ç½¤Î·Ð¸³ÃÍ", 0, 0);
7065 #else
7066         show_file(TRUE, file_name, "Miscellaneous Proficiency", 0, 0);
7067 #endif
7068
7069
7070         /* Remove the file */
7071         fd_kill(file_name);
7072 }
7073
7074
7075 /*
7076  * Pluralize a monster name
7077  */
7078 void plural_aux(char *Name)
7079 {
7080         int NameLen = strlen(Name);
7081
7082         if (my_strstr(Name, "Disembodied hand"))
7083         {
7084                 strcpy(Name, "Disembodied hands that strangled people");
7085         }
7086         else if (my_strstr(Name, "Colour out of space"))
7087         {
7088                 strcpy(Name, "Colours out of space");
7089         }
7090         else if (my_strstr(Name, "stairway to hell"))
7091         {
7092                 strcpy(Name, "stairways to hell");
7093         }
7094         else if (my_strstr(Name, "Dweller on the threshold"))
7095         {
7096                 strcpy(Name, "Dwellers on the threshold");
7097         }
7098         else if (my_strstr(Name, " of "))
7099         {
7100                 cptr aider = my_strstr(Name, " of ");
7101                 char dummy[80];
7102                 int i = 0;
7103                 cptr ctr = Name;
7104
7105                 while (ctr < aider)
7106                 {
7107                         dummy[i] = *ctr;
7108                         ctr++; i++;
7109                 }
7110
7111                 if (dummy[i-1] == 's')
7112                 {
7113                         strcpy(&(dummy[i]), "es");
7114                         i++;
7115                 }
7116                 else
7117                 {
7118                         strcpy(&(dummy[i]), "s");
7119                 }
7120
7121                 strcpy(&(dummy[i+1]), aider);
7122                 strcpy(Name, dummy);
7123         }
7124         else if (my_strstr(Name, "coins"))
7125         {
7126                 char dummy[80];
7127                 strcpy(dummy, "piles of ");
7128                 strcat(dummy, Name);
7129                 strcpy(Name, dummy);
7130                 return;
7131         }
7132         else if (my_strstr(Name, "Manes"))
7133         {
7134                 return;
7135         }
7136         else if (streq(&(Name[NameLen - 2]), "ey"))
7137         {
7138                 strcpy(&(Name[NameLen - 2]), "eys");
7139         }
7140         else if (Name[NameLen - 1] == 'y')
7141         {
7142                 strcpy(&(Name[NameLen - 1]), "ies");
7143         }
7144         else if (streq(&(Name[NameLen - 4]), "ouse"))
7145         {
7146                 strcpy(&(Name[NameLen - 4]), "ice");
7147         }
7148         else if (streq(&(Name[NameLen - 2]), "us"))
7149         {
7150                 strcpy(&(Name[NameLen - 2]), "i");
7151         }
7152         else if (streq(&(Name[NameLen - 6]), "kelman"))
7153         {
7154                 strcpy(&(Name[NameLen - 6]), "kelmen");
7155         }
7156         else if (streq(&(Name[NameLen - 8]), "wordsman"))
7157         {
7158                 strcpy(&(Name[NameLen - 8]), "wordsmen");
7159         }
7160         else if (streq(&(Name[NameLen - 7]), "oodsman"))
7161         {
7162                 strcpy(&(Name[NameLen - 7]), "oodsmen");
7163         }
7164         else if (streq(&(Name[NameLen - 7]), "eastman"))
7165         {
7166                 strcpy(&(Name[NameLen - 7]), "eastmen");
7167         }
7168         else if (streq(&(Name[NameLen - 8]), "izardman"))
7169         {
7170                 strcpy(&(Name[NameLen - 8]), "izardmen");
7171         }
7172         else if (streq(&(Name[NameLen - 5]), "geist"))
7173         {
7174                 strcpy(&(Name[NameLen - 5]), "geister");
7175         }
7176         else if (streq(&(Name[NameLen - 2]), "ex"))
7177         {
7178                 strcpy(&(Name[NameLen - 2]), "ices");
7179         }
7180         else if (streq(&(Name[NameLen - 2]), "lf"))
7181         {
7182                 strcpy(&(Name[NameLen - 2]), "lves");
7183         }
7184         else if (suffix(Name, "ch") ||
7185                  suffix(Name, "sh") ||
7186                          suffix(Name, "nx") ||
7187                          suffix(Name, "s") ||
7188                          suffix(Name, "o"))
7189         {
7190                 strcpy(&(Name[NameLen]), "es");
7191         }
7192         else
7193         {
7194                 strcpy(&(Name[NameLen]), "s");
7195         }
7196 }
7197
7198 /*
7199  * Display current pets
7200  */
7201 static void do_cmd_knowledge_pets(void)
7202 {
7203         int             i;
7204         FILE            *fff;
7205         monster_type    *m_ptr;
7206         char            pet_name[80];
7207         int             t_friends = 0;
7208         int             show_upkeep = 0;
7209         char            file_name[1024];
7210
7211
7212         /* Open a new file */
7213         fff = my_fopen_temp(file_name, 1024);
7214         if (!fff) {
7215 #ifdef JP
7216             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7217 #else
7218             msg_format("Failed to create temporary file %s.", file_name);
7219 #endif
7220             msg_print(NULL);
7221             return;
7222         }
7223
7224         /* Process the monsters (backwards) */
7225         for (i = m_max - 1; i >= 1; i--)
7226         {
7227                 /* Access the monster */
7228                 m_ptr = &m_list[i];
7229
7230                 /* Ignore "dead" monsters */
7231                 if (!m_ptr->r_idx) continue;
7232
7233                 /* Calculate "upkeep" for pets */
7234                 if (is_pet(m_ptr))
7235                 {
7236                         t_friends++;
7237                         monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
7238                         fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
7239                 }
7240         }
7241
7242         show_upkeep = calculate_upkeep();
7243
7244         fprintf(fff, "----------------------------------------------\n");
7245 #ifdef JP
7246         fprintf(fff, "    ¹ç·×: %d ÂΤΥڥåÈ\n", t_friends);
7247         fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
7248 #else
7249         fprintf(fff, "   Total: %d pet%s.\n",
7250                 t_friends, (t_friends == 1 ? "" : "s"));
7251         fprintf(fff, "   Upkeep: %d%% mana.\n", show_upkeep);
7252 #endif
7253
7254
7255
7256         /* Close the file */
7257         my_fclose(fff);
7258
7259         /* Display the file contents */
7260 #ifdef JP
7261         show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
7262 #else
7263         show_file(TRUE, file_name, "Current Pets", 0, 0);
7264 #endif
7265
7266
7267         /* Remove the file */
7268         fd_kill(file_name);
7269 }
7270
7271
7272 /*
7273  * Total kill count
7274  *
7275  * Note that the player ghosts are ignored.  XXX XXX XXX
7276  */
7277 static void do_cmd_knowledge_kill_count(void)
7278 {
7279         int i, k, n = 0;
7280         u16b why = 2;
7281         s16b *who;
7282
7283         FILE *fff;
7284
7285         char file_name[1024];
7286
7287         s32b Total = 0;
7288
7289
7290         /* Open a new file */
7291         fff = my_fopen_temp(file_name, 1024);
7292
7293         if (!fff) {
7294 #ifdef JP
7295             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7296 #else
7297             msg_format("Failed to create temporary file %s.", file_name);
7298 #endif
7299             msg_print(NULL);
7300             return;
7301         }
7302
7303         /* Allocate the "who" array */
7304         C_MAKE(who, max_r_idx, s16b);
7305
7306         {
7307                 /* Monsters slain */
7308                 int kk;
7309
7310                 for (kk = 1; kk < max_r_idx; kk++)
7311                 {
7312                         monster_race *r_ptr = &r_info[kk];
7313
7314                         if (r_ptr->flags1 & (RF1_UNIQUE))
7315                         {
7316                                 bool dead = (r_ptr->max_num == 0);
7317
7318                                 if (dead)
7319                                 {
7320                                         Total++;
7321                                 }
7322                         }
7323                         else
7324                         {
7325                                 s16b This = r_ptr->r_pkills;
7326
7327                                 if (This > 0)
7328                                 {
7329                                         Total += This;
7330                                 }
7331                         }
7332                 }
7333
7334                 if (Total < 1)
7335 #ifdef JP
7336                         fprintf(fff,"¤¢¤Ê¤¿¤Ï¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Ê¤¤¡£\n\n");
7337 #else
7338                         fprintf(fff,"You have defeated no enemies yet.\n\n");
7339 #endif
7340                 else
7341 #ifdef JP
7342                         fprintf(fff,"¤¢¤Ê¤¿¤Ï%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", Total);
7343 #else
7344                         fprintf(fff,"You have defeated %ld %s.\n\n", Total, (Total == 1) ? "enemy" : "enemies");
7345 #endif
7346         }
7347
7348         Total = 0;
7349
7350         /* Scan the monsters */
7351         for (i = 1; i < max_r_idx; i++)
7352         {
7353                 monster_race *r_ptr = &r_info[i];
7354
7355                 /* Use that monster */
7356                 if (r_ptr->name) who[n++] = i;
7357         }
7358
7359         /* Select the sort method */
7360         ang_sort_comp = ang_sort_comp_hook;
7361         ang_sort_swap = ang_sort_swap_hook;
7362
7363         /* Sort the array by dungeon depth of monsters */
7364         ang_sort(who, &why, n);
7365
7366         /* Scan the monster races */
7367         for (k = 0; k < n; k++)
7368         {
7369                 monster_race *r_ptr = &r_info[who[k]];
7370
7371                 if (r_ptr->flags1 & (RF1_UNIQUE))
7372                 {
7373                         bool dead = (r_ptr->max_num == 0);
7374
7375                         if (dead)
7376                         {
7377                                 /* Print a message */
7378                                 fprintf(fff, "     %s\n",
7379                                     (r_name + r_ptr->name));
7380                                 Total++;
7381                         }
7382                 }
7383                 else
7384                 {
7385                         s16b This = r_ptr->r_pkills;
7386
7387                         if (This > 0)
7388                         {
7389 #ifdef JP
7390                                 /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita */
7391                                 if (my_strchr("pt", r_ptr->d_char))
7392                                         fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
7393                                 else
7394                                         fprintf(fff, "     %3d ÂΤΠ%s\n", This, r_name + r_ptr->name);
7395 #else
7396                                 if (This < 2)
7397                                 {
7398                                         if (my_strstr(r_name + r_ptr->name, "coins"))
7399                                         {
7400                                                 fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
7401                                         }
7402                                         else
7403                                         {
7404                                                 fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
7405                                         }
7406                                 }
7407                                 else
7408                                 {
7409                                         char ToPlural[80];
7410                                         strcpy(ToPlural, (r_name + r_ptr->name));
7411                                         plural_aux(ToPlural);
7412                                         fprintf(fff, "     %d %s\n", This, ToPlural);
7413                                 }
7414 #endif
7415
7416
7417                                 Total += This;
7418                         }
7419                 }
7420         }
7421
7422         fprintf(fff,"----------------------------------------------\n");
7423 #ifdef JP
7424         fprintf(fff,"    ¹ç·×: %lu ÂΤòÅݤ·¤¿¡£\n", Total);
7425 #else
7426         fprintf(fff,"   Total: %lu creature%s killed.\n",
7427                 Total, (Total == 1 ? "" : "s"));
7428 #endif
7429
7430
7431         /* Free the "who" array */
7432         C_KILL(who, max_r_idx, s16b);
7433
7434         /* Close the file */
7435         my_fclose(fff);
7436
7437         /* Display the file contents */
7438 #ifdef JP
7439         show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
7440 #else
7441         show_file(TRUE, file_name, "Kill Count", 0, 0);
7442 #endif
7443
7444
7445         /* Remove the file */
7446         fd_kill(file_name);
7447 }
7448
7449
7450 /*
7451  * Display the object groups.
7452  */
7453 static void display_group_list(int col, int row, int wid, int per_page,
7454         int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
7455 {
7456         int i;
7457
7458         /* Display lines until done */
7459         for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
7460         {
7461                 /* Get the group index */
7462                 int grp = grp_idx[grp_top + i];
7463
7464                 /* Choose a color */
7465                 byte attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
7466
7467                 /* Erase the entire line */
7468                 Term_erase(col, row + i, wid);
7469
7470                 /* Display the group label */
7471                 c_put_str(attr, group_text[grp], row + i, col);
7472         }
7473 }
7474
7475
7476 /* 
7477  * Move the cursor in a browser window 
7478  */
7479 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt, 
7480                                                    int *list_cur, int list_cnt)
7481 {
7482         int d;
7483         int col = *column;
7484         int grp = *grp_cur;
7485         int list = *list_cur;
7486
7487         /* Extract direction */
7488         if (ch == ' ')
7489         {
7490                 /* Hack -- scroll up full screen */
7491                 d = 3;
7492         }
7493         else if (ch == '-')
7494         {
7495                 /* Hack -- scroll down full screen */
7496                 d = 9;
7497         }
7498         else
7499         {
7500                 d = get_keymap_dir(ch);
7501         }
7502
7503         if (!d) return;
7504
7505         /* Diagonals - hack */
7506         if ((ddx[d] > 0) && ddy[d])
7507         {
7508                 int browser_rows;
7509                 int wid, hgt;
7510
7511                 /* Get size */
7512                 Term_get_size(&wid, &hgt);
7513
7514                 browser_rows = hgt - 8;
7515
7516                 /* Browse group list */
7517                 if (!col)
7518                 {
7519                         int old_grp = grp;
7520
7521                         /* Move up or down */
7522                         grp += ddy[d] * (browser_rows - 1);
7523
7524                         /* Verify */
7525                         if (grp >= grp_cnt)     grp = grp_cnt - 1;
7526                         if (grp < 0) grp = 0;
7527                         if (grp != old_grp)     list = 0;
7528                 }
7529
7530                 /* Browse sub-list list */
7531                 else
7532                 {
7533                         /* Move up or down */
7534                         list += ddy[d] * browser_rows;
7535
7536                         /* Verify */
7537                         if (list >= list_cnt) list = list_cnt - 1;
7538                         if (list < 0) list = 0;
7539                 }
7540
7541                 (*grp_cur) = grp;
7542                 (*list_cur) = list;
7543
7544                 return;
7545         }
7546
7547         if (ddx[d])
7548         {
7549                 col += ddx[d];
7550                 if (col < 0) col = 0;
7551                 if (col > 1) col = 1;
7552
7553                 (*column) = col;
7554
7555                 return;
7556         }
7557
7558         /* Browse group list */
7559         if (!col)
7560         {
7561                 int old_grp = grp;
7562
7563                 /* Move up or down */
7564                 grp += ddy[d];
7565
7566                 /* Verify */
7567                 if (grp >= grp_cnt)     grp = grp_cnt - 1;
7568                 if (grp < 0) grp = 0;
7569                 if (grp != old_grp)     list = 0;
7570         }
7571
7572         /* Browse sub-list list */
7573         else
7574         {
7575                 /* Move up or down */
7576                 list += ddy[d];
7577
7578                 /* Verify */
7579                 if (list >= list_cnt) list = list_cnt - 1;
7580                 if (list < 0) list = 0;
7581         }
7582
7583         (*grp_cur) = grp;
7584         (*list_cur) = list;
7585 }
7586
7587
7588 /*
7589  * Display visuals.
7590  */
7591 static void display_visual_list(int col, int row, int height, int width, byte attr_top, byte char_left)
7592 {
7593         int i, j;
7594
7595         /* Clear the display lines */
7596         for (i = 0; i < height; i++)
7597         {
7598                 Term_erase(col, row + i, width);
7599         }
7600
7601         /* Bigtile mode uses double width */
7602         if (use_bigtile) width /= 2;
7603
7604         /* Display lines until done */
7605         for (i = 0; i < height; i++)
7606         {
7607                 /* Display columns until done */
7608                 for (j = 0; j < width; j++)
7609                 {
7610                         byte a;
7611                         char c;
7612                         int x = col + j;
7613                         int y = row + i;
7614                         int ia, ic;
7615
7616                         /* Bigtile mode uses double width */
7617                         if (use_bigtile) x += j;
7618
7619                         ia = attr_top + i;
7620                         ic = char_left + j;
7621
7622                         /* Ignore illegal characters */
7623                         if (ia > 0x7f || ic > 0xff || ic < ' ' ||
7624                             (!use_graphics && ic > 0x7f))
7625                                 continue;
7626
7627                         a = (byte)ia;
7628                         c = (char)ic;
7629
7630                         /* Force correct code for both ASCII character and tile */
7631                         if (c & 0x80) a |= 0x80;
7632
7633                         /* Display symbol */
7634                         Term_queue_bigchar(x, y, a, c, 0, 0);
7635                 }
7636         }
7637 }
7638
7639
7640 /*
7641  * Place the cursor at the collect position for visual mode
7642  */
7643 static void place_visual_list_cursor(int col, int row, byte a, byte c, byte attr_top, byte char_left)
7644 {
7645         int i = (a & 0x7f) - attr_top;
7646         int j = c - char_left;
7647
7648         int x = col + j;
7649         int y = row + i;
7650
7651         /* Bigtile mode uses double width */
7652         if (use_bigtile) x += j;
7653
7654         /* Place the cursor */
7655         Term_gotoxy(x, y);
7656 }
7657
7658
7659 /*
7660  *  Clipboard variables for copy&paste in visual mode
7661  */
7662 static byte attr_idx = 0;
7663 static byte char_idx = 0;
7664
7665 /* Hack -- for feature lighting */
7666 static byte attr_idx_feat[F_LIT_MAX];
7667 static byte char_idx_feat[F_LIT_MAX];
7668
7669 /*
7670  *  Do visual mode command -- Change symbols
7671  */
7672 static bool visual_mode_command(char ch, bool *visual_list_ptr,
7673                                 int height, int width,
7674                                 byte *attr_top_ptr, byte *char_left_ptr,
7675                                 byte *cur_attr_ptr, byte *cur_char_ptr, bool *need_redraw)
7676 {
7677         static byte attr_old = 0, char_old = 0;
7678
7679         switch (ch)
7680         {
7681         case ESCAPE:
7682                 if (*visual_list_ptr)
7683                 {
7684                         /* Cancel change */
7685                         *cur_attr_ptr = attr_old;
7686                         *cur_char_ptr = char_old;
7687                         *visual_list_ptr = FALSE;
7688
7689                         return TRUE;
7690                 }
7691                 break;
7692
7693         case '\n':
7694         case '\r':
7695                 if (*visual_list_ptr)
7696                 {
7697                         /* Accept change */
7698                         *visual_list_ptr = FALSE;
7699                         *need_redraw = TRUE;
7700
7701                         return TRUE;
7702                 }
7703                 break;
7704
7705         case 'V':
7706         case 'v':
7707                 if (!*visual_list_ptr)
7708                 {
7709                         *visual_list_ptr = TRUE;
7710
7711                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7712                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7713
7714                         attr_old = *cur_attr_ptr;
7715                         char_old = *cur_char_ptr;
7716
7717                         return TRUE;
7718                 }
7719                 break;
7720
7721         case 'C':
7722         case 'c':
7723                 {
7724                         int i;
7725
7726                         /* Set the visual */
7727                         attr_idx = *cur_attr_ptr;
7728                         char_idx = *cur_char_ptr;
7729
7730                         /* Hack -- for feature lighting */
7731                         for (i = 0; i < F_LIT_MAX; i++)
7732                         {
7733                                 attr_idx_feat[i] = 0;
7734                                 char_idx_feat[i] = 0;
7735                         }
7736                 }
7737                 return TRUE;
7738
7739         case 'P':
7740         case 'p':
7741                 if (attr_idx || (!(char_idx & 0x80) && char_idx)) /* Allow TERM_DARK text */
7742                 {
7743                         /* Set the char */
7744                         *cur_attr_ptr = attr_idx;
7745                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7746                         if (!*visual_list_ptr) *need_redraw = TRUE;
7747                 }
7748
7749                 if (char_idx)
7750                 {
7751                         /* Set the char */
7752                         *cur_char_ptr = char_idx;
7753                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7754                         if (!*visual_list_ptr) *need_redraw = TRUE;
7755                 }
7756
7757                 return TRUE;
7758
7759         default:
7760                 if (*visual_list_ptr)
7761                 {
7762                         int eff_width;
7763                         int d = get_keymap_dir(ch);
7764                         byte a = (*cur_attr_ptr & 0x7f);
7765                         byte c = *cur_char_ptr;
7766
7767                         if (use_bigtile) eff_width = width / 2;
7768                         else eff_width = width;
7769
7770                         /* Restrict direction */
7771                         if ((a == 0) && (ddy[d] < 0)) d = 0;
7772                         if ((c == 0) && (ddx[d] < 0)) d = 0;
7773                         if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
7774                         if ((c == 0xff) && (ddx[d] > 0)) d = 0;
7775
7776                         a += ddy[d];
7777                         c += ddx[d];
7778
7779                         /* Force correct code for both ASCII character and tile */
7780                         if (c & 0x80) a |= 0x80;
7781
7782                         /* Set the visual */
7783                         *cur_attr_ptr = a;
7784                         *cur_char_ptr = c;
7785
7786
7787                         /* Move the frame */
7788                         if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
7789                         if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
7790                         if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
7791                         if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
7792                         return TRUE;
7793                 }
7794                 break;
7795         }
7796
7797         /* Visual mode command is not used */
7798         return FALSE;
7799 }
7800
7801
7802 /*
7803  * Display the monsters in a group.
7804  */
7805 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
7806         int mon_cur, int mon_top, bool visual_only)
7807 {
7808         int i;
7809
7810         /* Display lines until done */
7811         for (i = 0; i < per_page && (mon_idx[mon_top + i] >= 0); i++)
7812         {
7813                 byte attr;
7814
7815                 /* Get the race index */
7816                 int r_idx = mon_idx[mon_top + i] ;
7817
7818                 /* Access the race */
7819                 monster_race *r_ptr = &r_info[r_idx];
7820
7821                 /* Choose a color */
7822                 attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
7823
7824                 /* Display the name */
7825                 c_prt(attr, (r_name + r_ptr->name), row + i, col);
7826
7827                 /* Hack -- visual_list mode */
7828                 if (per_page == 1)
7829                 {
7830                         c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 56 : 61);
7831                 }
7832                 if (p_ptr->wizard || visual_only)
7833                 {
7834                         c_prt(attr, format("%d", r_idx), row + i, 62);
7835                 }
7836
7837                 /* Erase chars before overwritten by the race letter */
7838                 Term_erase(69, row + i, 255);
7839
7840                 /* Display symbol */
7841                 Term_queue_bigchar(use_bigtile ? 69 : 70, row + i, r_ptr->x_attr, r_ptr->x_char, 0, 0);
7842
7843                 if (!visual_only)
7844                 {
7845                         /* Display kills */
7846                         if (!(r_ptr->flags1 & RF1_UNIQUE)) put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
7847 #ifdef JP
7848                         else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "»àË´" : "À¸Â¸"), row + i, 74);
7849 #else
7850                         else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? " dead" : "alive"), row + i, 73);
7851 #endif
7852                 }
7853         }
7854
7855         /* Clear remaining lines */
7856         for (; i < per_page; i++)
7857         {
7858                 Term_erase(col, row + i, 255);
7859         }
7860 }
7861
7862
7863 /*
7864  * Display known monsters.
7865  */
7866 static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int direct_r_idx)
7867 {
7868         int i, len, max;
7869         int grp_cur, grp_top, old_grp_cur;
7870         int mon_cur, mon_top;
7871         int grp_cnt, grp_idx[100];
7872         int mon_cnt;
7873         s16b *mon_idx;
7874
7875         int column = 0;
7876         bool flag;
7877         bool redraw;
7878
7879         bool visual_list = FALSE;
7880         byte attr_top = 0, char_left = 0;
7881
7882         int browser_rows;
7883         int wid, hgt;
7884
7885         byte mode;
7886
7887         /* Get size */
7888         Term_get_size(&wid, &hgt);
7889
7890         browser_rows = hgt - 8;
7891
7892         /* Allocate the "mon_idx" array */
7893         C_MAKE(mon_idx, max_r_idx, s16b);
7894
7895         max = 0;
7896         grp_cnt = 0;
7897
7898         if (direct_r_idx < 0)
7899         {
7900                 mode = visual_only ? 0x03 : 0x01;
7901
7902                 /* Check every group */
7903                 for (i = 0; monster_group_text[i] != NULL; i++)
7904                 {
7905                         /* Measure the label */
7906                         len = strlen(monster_group_text[i]);
7907
7908                         /* Save the maximum length */
7909                         if (len > max) max = len;
7910
7911                         /* See if any monsters are known */
7912                         if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, mode))
7913                         {
7914                                 /* Build a list of groups with known monsters */
7915                                 grp_idx[grp_cnt++] = i;
7916                         }
7917                 }
7918
7919                 mon_cnt = 0;
7920         }
7921         else
7922         {
7923                 mon_idx[0] = direct_r_idx;
7924                 mon_cnt = 1;
7925
7926                 /* Terminate the list */
7927                 mon_idx[1] = -1;
7928
7929                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
7930                         &attr_top, &char_left, &r_info[direct_r_idx].x_attr, &r_info[direct_r_idx].x_char, need_redraw);
7931         }
7932
7933         /* Terminate the list */
7934         grp_idx[grp_cnt] = -1;
7935
7936         old_grp_cur = -1;
7937         grp_cur = grp_top = 0;
7938         mon_cur = mon_top = 0;
7939
7940         flag = FALSE;
7941         redraw = TRUE;
7942
7943         mode = visual_only ? 0x02 : 0x00;
7944
7945         while (!flag)
7946         {
7947                 char ch;
7948                 monster_race *r_ptr;
7949
7950                 if (redraw)
7951                 {
7952                         clear_from(0);
7953
7954 #ifdef JP
7955                         prt(format("%s - ¥â¥ó¥¹¥¿¡¼", !visual_only ? "Ãμ±" : "ɽ¼¨"), 2, 0);
7956                         if (direct_r_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
7957                         prt("̾Á°", 4, max + 3);
7958                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
7959                         prt("ʸ»ú", 4, 67);
7960                         if (!visual_only) prt("»¦³²¿ô", 4, 72);
7961 #else
7962                         prt(format("%s - monsters", !visual_only ? "Knowledge" : "Visuals"), 2, 0);
7963                         if (direct_r_idx < 0) prt("Group", 4, 0);
7964                         prt("Name", 4, max + 3);
7965                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
7966                         prt("Sym", 4, 68);
7967                         if (!visual_only) prt("Kills", 4, 73);
7968 #endif
7969
7970                         for (i = 0; i < 78; i++)
7971                         {
7972                                 Term_putch(i, 5, TERM_WHITE, '=');
7973                         }
7974
7975                         if (direct_r_idx < 0)
7976                         {
7977                                 for (i = 0; i < browser_rows; i++)
7978                                 {
7979                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
7980                                 }
7981                         }
7982
7983                         redraw = FALSE;
7984                 }
7985
7986                 if (direct_r_idx < 0)
7987                 {
7988                         /* Scroll group list */
7989                         if (grp_cur < grp_top) grp_top = grp_cur;
7990                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
7991
7992                         /* Display a list of monster groups */
7993                         display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
7994
7995                         if (old_grp_cur != grp_cur)
7996                         {
7997                                 old_grp_cur = grp_cur;
7998
7999                                 /* Get a list of monsters in the current group */
8000                                 mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, mode);
8001                         }
8002
8003                         /* Scroll monster list */
8004                         while (mon_cur < mon_top)
8005                                 mon_top = MAX(0, mon_top - browser_rows/2);
8006                         while (mon_cur >= mon_top + browser_rows)
8007                                 mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows/2);
8008                 }
8009
8010                 if (!visual_list)
8011                 {
8012                         /* Display a list of monsters in the current group */
8013                         display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top, visual_only);
8014                 }
8015                 else
8016                 {
8017                         mon_top = mon_cur;
8018
8019                         /* Display a monster name */
8020                         display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top, visual_only);
8021
8022                         /* Display visual list below first monster */
8023                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8024                 }
8025
8026                 /* Prompt */
8027 #ifdef JP
8028                 prt(format("<Êý¸þ>%s%s%s, ESC",
8029                         (!visual_list && !visual_only) ? ", 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë" : "",
8030                         visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8031                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8032                         hgt - 1, 0);
8033 #else
8034                 prt(format("<dir>%s%s%s, ESC",
8035                         (!visual_list && !visual_only) ? ", 'r' to recall" : "",
8036                         visual_list ? ", ENTER to accept" : ", 'v' for visuals",
8037                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8038                         hgt - 1, 0);
8039 #endif
8040
8041                 /* Get the current monster */
8042                 r_ptr = &r_info[mon_idx[mon_cur]];
8043
8044                 if (!visual_only)
8045                 {
8046                         /* Mega Hack -- track this monster race */
8047                         if (mon_cnt) monster_race_track(mon_idx[mon_cur]);
8048
8049                         /* Hack -- handle stuff */
8050                         handle_stuff();
8051                 }
8052
8053                 if (visual_list)
8054                 {
8055                         place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
8056                 }
8057                 else if (!column)
8058                 {
8059                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8060                 }
8061                 else
8062                 {
8063                         Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
8064                 }
8065
8066                 ch = inkey();
8067
8068                 /* Do visual mode command if needed */
8069                 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))
8070                 {
8071                         if (direct_r_idx >= 0)
8072                         {
8073                                 switch (ch)
8074                                 {
8075                                 case '\n':
8076                                 case '\r':
8077                                 case ESCAPE:
8078                                         flag = TRUE;
8079                                         break;
8080                                 }
8081                         }
8082                         continue;
8083                 }
8084
8085                 switch (ch)
8086                 {
8087                         case ESCAPE:
8088                         {
8089                                 flag = TRUE;
8090                                 break;
8091                         }
8092
8093                         case 'R':
8094                         case 'r':
8095                         {
8096                                 /* Recall on screen */
8097                                 if (!visual_list && !visual_only && (mon_idx[mon_cur] > 0))
8098                                 {
8099                                         screen_roff(mon_idx[mon_cur], 0);
8100
8101                                         (void)inkey();
8102
8103                                         redraw = TRUE;
8104                                 }
8105                                 break;
8106                         }
8107
8108                         default:
8109                         {
8110                                 /* Move the cursor */
8111                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
8112
8113                                 break;
8114                         }
8115                 }
8116         }
8117
8118         /* Free the "mon_idx" array */
8119         C_KILL(mon_idx, max_r_idx, s16b);
8120 }
8121
8122
8123 /*
8124  * Display the objects in a group.
8125  */
8126 static void display_object_list(int col, int row, int per_page, int object_idx[],
8127         int object_cur, int object_top, bool visual_only)
8128 {
8129         int i;
8130
8131         /* Display lines until done */
8132         for (i = 0; i < per_page && (object_idx[object_top + i] >= 0); i++)
8133         {
8134                 char o_name[80];
8135                 byte a, c;
8136                 object_kind *flavor_k_ptr;
8137
8138                 /* Get the object index */
8139                 int k_idx = object_idx[object_top + i];
8140
8141                 /* Access the object */
8142                 object_kind *k_ptr = &k_info[k_idx];
8143
8144                 /* Choose a color */
8145                 byte attr = ((k_ptr->aware || visual_only) ? TERM_WHITE : TERM_SLATE);
8146                 byte cursor = ((k_ptr->aware || visual_only) ? TERM_L_BLUE : TERM_BLUE);
8147
8148
8149                 if (!visual_only && k_ptr->flavor)
8150                 {
8151                         /* Appearance of this object is shuffled */
8152                         flavor_k_ptr = &k_info[k_ptr->flavor];
8153                 }
8154                 else
8155                 {
8156                         /* Appearance of this object is very normal */
8157                         flavor_k_ptr = k_ptr;
8158                 }
8159
8160
8161
8162                 attr = ((i + object_top == object_cur) ? cursor : attr);
8163
8164                 if (!k_ptr->flavor || (!visual_only && k_ptr->aware))
8165                 {
8166                         /* Tidy name */
8167                         strip_name(o_name, k_idx);
8168                 }
8169                 else
8170                 {
8171                         /* Flavor name */
8172                         strcpy(o_name, k_name + flavor_k_ptr->flavor_name);
8173                 }
8174
8175                 /* Display the name */
8176                 c_prt(attr, o_name, row + i, col);
8177
8178                 /* Hack -- visual_list mode */
8179                 if (per_page == 1)
8180                 {
8181                         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);
8182                 }
8183                 if (p_ptr->wizard || visual_only)
8184                 {
8185                         c_prt(attr, format("%d", k_idx), row + i, 70);
8186                 }
8187
8188                 a = flavor_k_ptr->x_attr;
8189                 c = flavor_k_ptr->x_char;
8190
8191                 /* Display symbol */
8192                 Term_queue_bigchar(use_bigtile ? 76 : 77, row + i, a, c, 0, 0);
8193         }
8194
8195         /* Clear remaining lines */
8196         for (; i < per_page; i++)
8197         {
8198                 Term_erase(col, row + i, 255);
8199         }
8200 }
8201
8202 /*
8203  * Describe fake object
8204  */
8205 static void desc_obj_fake(int k_idx)
8206 {
8207         object_type *o_ptr;
8208         object_type object_type_body;
8209
8210         /* Get local object */
8211         o_ptr = &object_type_body;
8212
8213         /* Wipe the object */
8214         object_wipe(o_ptr);
8215
8216         /* Create the artifact */
8217         object_prep(o_ptr, k_idx);
8218
8219         /* It's fully know */
8220         o_ptr->ident |= IDENT_KNOWN;
8221
8222         /* Track the object */
8223         /* object_actual_track(o_ptr); */
8224
8225         /* Hack - mark as fake */
8226         /* term_obj_real = FALSE; */
8227
8228         /* Hack -- Handle stuff */
8229         handle_stuff();
8230
8231         if (!screen_object(o_ptr, SCROBJ_FAKE_OBJECT | SCROBJ_FORCE_DETAIL))
8232         {
8233 #ifdef JP
8234                 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
8235 #else
8236                 msg_print("You see nothing special.");
8237 #endif
8238                 msg_print(NULL);
8239         }
8240 }
8241
8242
8243
8244 /*
8245  * Display known objects
8246  */
8247 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int direct_k_idx)
8248 {
8249         int i, len, max;
8250         int grp_cur, grp_top, old_grp_cur;
8251         int object_old, object_cur, object_top;
8252         int grp_cnt, grp_idx[100];
8253         int object_cnt;
8254         int *object_idx;
8255
8256         int column = 0;
8257         bool flag;
8258         bool redraw;
8259
8260         bool visual_list = FALSE;
8261         byte attr_top = 0, char_left = 0;
8262
8263         int browser_rows;
8264         int wid, hgt;
8265
8266         byte mode;
8267
8268         /* Get size */
8269         Term_get_size(&wid, &hgt);
8270
8271         browser_rows = hgt - 8;
8272
8273         /* Allocate the "object_idx" array */
8274         C_MAKE(object_idx, max_k_idx, int);
8275
8276         max = 0;
8277         grp_cnt = 0;
8278
8279         if (direct_k_idx < 0)
8280         {
8281                 mode = visual_only ? 0x03 : 0x01;
8282
8283                 /* Check every group */
8284                 for (i = 0; object_group_text[i] != NULL; i++)
8285                 {
8286                         /* Measure the label */
8287                         len = strlen(object_group_text[i]);
8288
8289                         /* Save the maximum length */
8290                         if (len > max) max = len;
8291
8292                         /* See if any monsters are known */
8293                         if (collect_objects(i, object_idx, mode))
8294                         {
8295                                 /* Build a list of groups with known monsters */
8296                                 grp_idx[grp_cnt++] = i;
8297                         }
8298                 }
8299
8300                 object_old = -1;
8301                 object_cnt = 0;
8302         }
8303         else
8304         {
8305                 object_kind *k_ptr = &k_info[direct_k_idx];
8306                 object_kind *flavor_k_ptr;
8307
8308                 if (!visual_only && k_ptr->flavor)
8309                 {
8310                         /* Appearance of this object is shuffled */
8311                         flavor_k_ptr = &k_info[k_ptr->flavor];
8312                 }
8313                 else
8314                 {
8315                         /* Appearance of this object is very normal */
8316                         flavor_k_ptr = k_ptr;
8317                 }
8318
8319                 object_idx[0] = direct_k_idx;
8320                 object_old = direct_k_idx;
8321                 object_cnt = 1;
8322
8323                 /* Terminate the list */
8324                 object_idx[1] = -1;
8325
8326                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8327                         &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw);
8328         }
8329
8330         /* Terminate the list */
8331         grp_idx[grp_cnt] = -1;
8332
8333         old_grp_cur = -1;
8334         grp_cur = grp_top = 0;
8335         object_cur = object_top = 0;
8336
8337         flag = FALSE;
8338         redraw = TRUE;
8339
8340         mode = visual_only ? 0x02 : 0x00;
8341
8342         while (!flag)
8343         {
8344                 char ch;
8345                 object_kind *k_ptr, *flavor_k_ptr;
8346
8347                 if (redraw)
8348                 {
8349                         clear_from(0);
8350
8351 #ifdef JP
8352                         prt(format("%s - ¥¢¥¤¥Æ¥à", !visual_only ? "Ãμ±" : "ɽ¼¨"), 2, 0);
8353                         if (direct_k_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8354                         prt("̾Á°", 4, max + 3);
8355                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 70);
8356                         prt("ʸ»ú", 4, 74);
8357 #else
8358                         prt(format("%s - objects", !visual_only ? "Knowledge" : "Visuals"), 2, 0);
8359                         if (direct_k_idx < 0) prt("Group", 4, 0);
8360                         prt("Name", 4, max + 3);
8361                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 70);
8362                         prt("Sym", 4, 75);
8363 #endif
8364
8365                         for (i = 0; i < 78; i++)
8366                         {
8367                                 Term_putch(i, 5, TERM_WHITE, '=');
8368                         }
8369
8370                         if (direct_k_idx < 0)
8371                         {
8372                                 for (i = 0; i < browser_rows; i++)
8373                                 {
8374                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8375                                 }
8376                         }
8377
8378                         redraw = FALSE;
8379                 }
8380
8381                 if (direct_k_idx < 0)
8382                 {
8383                         /* Scroll group list */
8384                         if (grp_cur < grp_top) grp_top = grp_cur;
8385                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8386
8387                         /* Display a list of object groups */
8388                         display_group_list(0, 6, max, browser_rows, grp_idx, object_group_text, grp_cur, grp_top);
8389
8390                         if (old_grp_cur != grp_cur)
8391                         {
8392                                 old_grp_cur = grp_cur;
8393
8394                                 /* Get a list of objects in the current group */
8395                                 object_cnt = collect_objects(grp_idx[grp_cur], object_idx, mode);
8396                         }
8397
8398                         /* Scroll object list */
8399                         while (object_cur < object_top)
8400                                 object_top = MAX(0, object_top - browser_rows/2);
8401                         while (object_cur >= object_top + browser_rows)
8402                                 object_top = MIN(object_cnt - browser_rows, object_top + browser_rows/2);
8403                 }
8404
8405                 if (!visual_list)
8406                 {
8407                         /* Display a list of objects in the current group */
8408                         display_object_list(max + 3, 6, browser_rows, object_idx, object_cur, object_top, visual_only);
8409                 }
8410                 else
8411                 {
8412                         object_top = object_cur;
8413
8414                         /* Display a list of objects in the current group */
8415                         display_object_list(max + 3, 6, 1, object_idx, object_cur, object_top, visual_only);
8416
8417                         /* Display visual list below first object */
8418                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8419                 }
8420
8421                 /* Get the current object */
8422                 k_ptr = &k_info[object_idx[object_cur]];
8423
8424                 if (!visual_only && k_ptr->flavor)
8425                 {
8426                         /* Appearance of this object is shuffled */
8427                         flavor_k_ptr = &k_info[k_ptr->flavor];
8428                 }
8429                 else
8430                 {
8431                         /* Appearance of this object is very normal */
8432                         flavor_k_ptr = k_ptr;
8433                 }
8434
8435                 /* Prompt */
8436 #ifdef JP
8437                 prt(format("<Êý¸þ>%s%s%s, ESC",
8438                         (!visual_list && !visual_only) ? ", 'r'¤Ç¾ÜºÙ¤ò¸«¤ë" : "",
8439                         visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8440                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8441                         hgt - 1, 0);
8442 #else
8443                 prt(format("<dir>%s%s%s, ESC",
8444                         (!visual_list && !visual_only) ? ", 'r' to recall" : "",
8445                         visual_list ? ", ENTER to accept" : ", 'v' for visuals",
8446                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8447                         hgt - 1, 0);
8448 #endif
8449
8450                 if (!visual_only)
8451                 {
8452                         /* Mega Hack -- track this object */
8453                         if (object_cnt) object_kind_track(object_idx[object_cur]);
8454
8455                         /* The "current" object changed */
8456                         if (object_old != object_idx[object_cur])
8457                         {
8458                                 /* Hack -- handle stuff */
8459                                 handle_stuff();
8460
8461                                 /* Remember the "current" object */
8462                                 object_old = object_idx[object_cur];
8463                         }
8464                 }
8465
8466                 if (visual_list)
8467                 {
8468                         place_visual_list_cursor(max + 3, 7, flavor_k_ptr->x_attr, flavor_k_ptr->x_char, attr_top, char_left);
8469                 }
8470                 else if (!column)
8471                 {
8472                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8473                 }
8474                 else
8475                 {
8476                         Term_gotoxy(max + 3, 6 + (object_cur - object_top));
8477                 }
8478
8479                 ch = inkey();
8480
8481                 /* Do visual mode command if needed */
8482                 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))
8483                 {
8484                         if (direct_k_idx >= 0)
8485                         {
8486                                 switch (ch)
8487                                 {
8488                                 case '\n':
8489                                 case '\r':
8490                                 case ESCAPE:
8491                                         flag = TRUE;
8492                                         break;
8493                                 }
8494                         }
8495                         continue;
8496                 }
8497
8498                 switch (ch)
8499                 {
8500                         case ESCAPE:
8501                         {
8502                                 flag = TRUE;
8503                                 break;
8504                         }
8505
8506                         case 'R':
8507                         case 'r':
8508                         {
8509                                 /* Recall on screen */
8510                                 if (!visual_list && !visual_only && (grp_cnt > 0))
8511                                 {
8512                                         desc_obj_fake(object_idx[object_cur]);
8513                                         redraw = TRUE;
8514                                 }
8515                                 break;
8516                         }
8517
8518                         default:
8519                         {
8520                                 /* Move the cursor */
8521                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &object_cur, object_cnt);
8522                                 break;
8523                         }
8524                 }
8525         }
8526
8527         /* Free the "object_idx" array */
8528         C_KILL(object_idx, max_k_idx, int);
8529 }
8530
8531
8532 /*
8533  * Display the features in a group.
8534  */
8535 static void display_feature_list(int col, int row, int per_page, int *feat_idx,
8536         int feat_cur, int feat_top, bool visual_only, int lighting_level)
8537 {
8538         int lit_col[F_LIT_MAX], i, j;
8539         int f_idx_col = use_bigtile ? 62 : 64;
8540
8541         /* Correct columns 1 and 4 */
8542         lit_col[F_LIT_STANDARD] = use_bigtile ? (71 - F_LIT_MAX) : 71;
8543         for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
8544                 lit_col[i] = lit_col[F_LIT_STANDARD] + 2 + (i - F_LIT_NS_BEGIN) * 2 + (use_bigtile ? i : 0);
8545
8546         /* Display lines until done */
8547         for (i = 0; i < per_page && (feat_idx[feat_top + i] >= 0); i++)
8548         {
8549                 byte attr;
8550
8551                 /* Get the index */
8552                 int f_idx = feat_idx[feat_top + i];
8553
8554                 /* Access the index */
8555                 feature_type *f_ptr = &f_info[f_idx];
8556
8557                 int row_i = row + i;
8558
8559                 /* Choose a color */
8560                 attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
8561
8562                 /* Display the name */
8563                 c_prt(attr, f_name + f_ptr->name, row_i, col);
8564
8565                 /* Hack -- visual_list mode */
8566                 if (per_page == 1)
8567                 {
8568                         /* Display lighting level */
8569                         c_prt(attr, format("(%s)", lighting_level_str[lighting_level]), row_i, col + 1 + strlen(f_name + f_ptr->name));
8570
8571                         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));
8572                 }
8573                 if (p_ptr->wizard || visual_only)
8574                 {
8575                         c_prt(attr, format("%d", f_idx), row_i, f_idx_col);
8576                 }
8577
8578                 /* Display symbol */
8579                 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);
8580
8581                 Term_putch(lit_col[F_LIT_NS_BEGIN], row_i, TERM_SLATE, '(');
8582                 for (j = F_LIT_NS_BEGIN + 1; j < F_LIT_MAX; j++)
8583                 {
8584                         Term_putch(lit_col[j], row_i, TERM_SLATE, '/');
8585                 }
8586                 Term_putch(lit_col[F_LIT_MAX - 1] + (use_bigtile ? 3 : 2), row_i, TERM_SLATE, ')');
8587
8588                 /* Mega-hack -- Use non-standard colour */
8589                 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
8590                 {
8591                         Term_queue_bigchar(lit_col[j] + 1, row_i, f_ptr->x_attr[j], f_ptr->x_char[j], 0, 0);
8592                 }
8593         }
8594
8595         /* Clear remaining lines */
8596         for (; i < per_page; i++)
8597         {
8598                 Term_erase(col, row + i, 255);
8599         }
8600 }
8601
8602
8603 /*
8604  * Interact with feature visuals.
8605  */
8606 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int direct_f_idx, int *lighting_level)
8607 {
8608         int i, len, max;
8609         int grp_cur, grp_top, old_grp_cur;
8610         int feat_cur, feat_top;
8611         int grp_cnt, grp_idx[100];
8612         int feat_cnt;
8613         int *feat_idx;
8614
8615         int column = 0;
8616         bool flag;
8617         bool redraw;
8618
8619         bool visual_list = FALSE;
8620         byte attr_top = 0, char_left = 0;
8621
8622         int browser_rows;
8623         int wid, hgt;
8624
8625         byte attr_old[F_LIT_MAX];
8626         byte char_old[F_LIT_MAX];
8627         byte *cur_attr_ptr, *cur_char_ptr;
8628
8629         C_WIPE(attr_old, F_LIT_MAX, byte);
8630         C_WIPE(char_old, F_LIT_MAX, byte);
8631
8632         /* Get size */
8633         Term_get_size(&wid, &hgt);
8634
8635         browser_rows = hgt - 8;
8636
8637         /* Allocate the "feat_idx" array */
8638         C_MAKE(feat_idx, max_f_idx, int);
8639
8640         max = 0;
8641         grp_cnt = 0;
8642
8643         if (direct_f_idx < 0)
8644         {
8645                 /* Check every group */
8646                 for (i = 0; feature_group_text[i] != NULL; i++)
8647                 {
8648                         /* Measure the label */
8649                         len = strlen(feature_group_text[i]);
8650
8651                         /* Save the maximum length */
8652                         if (len > max) max = len;
8653
8654                         /* See if any features are known */
8655                         if (collect_features(i, feat_idx, 0x01))
8656                         {
8657                                 /* Build a list of groups with known features */
8658                                 grp_idx[grp_cnt++] = i;
8659                         }
8660                 }
8661
8662                 feat_cnt = 0;
8663         }
8664         else
8665         {
8666                 feature_type *f_ptr = &f_info[direct_f_idx];
8667
8668                 feat_idx[0] = direct_f_idx;
8669                 feat_cnt = 1;
8670
8671                 /* Terminate the list */
8672                 feat_idx[1] = -1;
8673
8674                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8675                         &attr_top, &char_left, &f_ptr->x_attr[*lighting_level], &f_ptr->x_char[*lighting_level], need_redraw);
8676
8677                 for (i = 0; i < F_LIT_MAX; i++)
8678                 {
8679                         attr_old[i] = f_ptr->x_attr[i];
8680                         char_old[i] = f_ptr->x_char[i];
8681                 }
8682         }
8683
8684         /* Terminate the list */
8685         grp_idx[grp_cnt] = -1;
8686
8687         old_grp_cur = -1;
8688         grp_cur = grp_top = 0;
8689         feat_cur = feat_top = 0;
8690
8691         flag = FALSE;
8692         redraw = TRUE;
8693
8694         while (!flag)
8695         {
8696                 char ch;
8697                 feature_type *f_ptr;
8698
8699                 if (redraw)
8700                 {
8701                         clear_from(0);
8702
8703 #ifdef JP
8704                         prt("ɽ¼¨ - ÃÏ·Á", 2, 0);
8705                         if (direct_f_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8706                         prt("̾Á°", 4, max + 3);
8707                         if (use_bigtile)
8708                         {
8709                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8710                                 prt("ʸ»ú ( l/ d)", 4, 66);
8711                         }
8712                         else
8713                         {
8714                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 64);
8715                                 prt("ʸ»ú (l/d)", 4, 68);
8716                         }
8717 #else
8718                         prt("Visuals - features", 2, 0);
8719                         if (direct_f_idx < 0) prt("Group", 4, 0);
8720                         prt("Name", 4, max + 3);
8721                         if (use_bigtile)
8722                         {
8723                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8724                                 prt("Sym ( l/ d)", 4, 67);
8725                         }
8726                         else
8727                         {
8728                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 64);
8729                                 prt("Sym (l/d)", 4, 69);
8730                         }
8731 #endif
8732
8733                         for (i = 0; i < 78; i++)
8734                         {
8735                                 Term_putch(i, 5, TERM_WHITE, '=');
8736                         }
8737
8738                         if (direct_f_idx < 0)
8739                         {
8740                                 for (i = 0; i < browser_rows; i++)
8741                                 {
8742                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8743                                 }
8744                         }
8745
8746                         redraw = FALSE;
8747                 }
8748
8749                 if (direct_f_idx < 0)
8750                 {
8751                         /* Scroll group list */
8752                         if (grp_cur < grp_top) grp_top = grp_cur;
8753                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8754
8755                         /* Display a list of feature groups */
8756                         display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
8757
8758                         if (old_grp_cur != grp_cur)
8759                         {
8760                                 old_grp_cur = grp_cur;
8761
8762                                 /* Get a list of features in the current group */
8763                                 feat_cnt = collect_features(grp_idx[grp_cur], feat_idx, 0x00);
8764                         }
8765
8766                         /* Scroll feature list */
8767                         while (feat_cur < feat_top)
8768                                 feat_top = MAX(0, feat_top - browser_rows/2);
8769                         while (feat_cur >= feat_top + browser_rows)
8770                                 feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows/2);
8771                 }
8772
8773                 if (!visual_list)
8774                 {
8775                         /* Display a list of features in the current group */
8776                         display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top, visual_only, F_LIT_STANDARD);
8777                 }
8778                 else
8779                 {
8780                         feat_top = feat_cur;
8781
8782                         /* Display a list of features in the current group */
8783                         display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top, visual_only, *lighting_level);
8784
8785                         /* Display visual list below first object */
8786                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8787                 }
8788
8789                 /* Prompt */
8790 #ifdef JP
8791                 prt(format("<Êý¸þ>%s, 'd'¤Çɸ½à¸÷¸»¸ú²Ì%s, ESC",
8792                         visual_list ? ", ENTER¤Ç·èÄê, 'a'¤ÇÂоÝÌÀÅÙÊѹ¹" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8793                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8794                         hgt - 1, 0);
8795 #else
8796                 prt(format("<dir>%s, 'd' for default lighting%s, ESC",
8797                         visual_list ? ", ENTER to accept, 'a' for lighting level" : ", 'v' for visuals",
8798                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8799                         hgt - 1, 0);
8800 #endif
8801
8802                 /* Get the current feature */
8803                 f_ptr = &f_info[feat_idx[feat_cur]];
8804                 cur_attr_ptr = &f_ptr->x_attr[*lighting_level];
8805                 cur_char_ptr = &f_ptr->x_char[*lighting_level];
8806
8807                 if (visual_list)
8808                 {
8809                         place_visual_list_cursor(max + 3, 7, *cur_attr_ptr, *cur_char_ptr, attr_top, char_left);
8810                 }
8811                 else if (!column)
8812                 {
8813                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8814                 }
8815                 else
8816                 {
8817                         Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
8818                 }
8819
8820                 ch = inkey();
8821
8822                 if (visual_list && ((ch == 'A') || (ch == 'a')))
8823                 {
8824                         int prev_lighting_level = *lighting_level;
8825
8826                         if (ch == 'A')
8827                         {
8828                                 if (*lighting_level <= 0) *lighting_level = F_LIT_MAX - 1;
8829                                 else (*lighting_level)--;
8830                         }
8831                         else
8832                         {
8833                                 if (*lighting_level >= F_LIT_MAX - 1) *lighting_level = 0;
8834                                 else (*lighting_level)++;
8835                         }
8836
8837                         if (f_ptr->x_attr[prev_lighting_level] != f_ptr->x_attr[*lighting_level])
8838                                 attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
8839
8840                         if (f_ptr->x_char[prev_lighting_level] != f_ptr->x_char[*lighting_level])
8841                                 char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
8842
8843                         continue;
8844                 }
8845
8846                 else if ((ch == 'D') || (ch == 'd'))
8847                 {
8848                         byte prev_x_attr = f_ptr->x_attr[*lighting_level];
8849                         byte prev_x_char = f_ptr->x_char[*lighting_level];
8850
8851                         apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
8852
8853                         if (visual_list)
8854                         {
8855                                 if (prev_x_attr != f_ptr->x_attr[*lighting_level])
8856                                          attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
8857
8858                                 if (prev_x_char != f_ptr->x_char[*lighting_level])
8859                                         char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
8860                         }
8861                         else *need_redraw = TRUE;
8862
8863                         continue;
8864                 }
8865
8866                 /* Do visual mode command if needed */
8867                 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))
8868                 {
8869                         switch (ch)
8870                         {
8871                         /* Restore previous visual settings */
8872                         case ESCAPE:
8873                                 for (i = 0; i < F_LIT_MAX; i++)
8874                                 {
8875                                         f_ptr->x_attr[i] = attr_old[i];
8876                                         f_ptr->x_char[i] = char_old[i];
8877                                 }
8878
8879                                 /* Fall through */
8880
8881                         case '\n':
8882                         case '\r':
8883                                 if (direct_f_idx >= 0) flag = TRUE;
8884                                 else *lighting_level = F_LIT_STANDARD;
8885                                 break;
8886
8887                         /* Preserve current visual settings */
8888                         case 'V':
8889                         case 'v':
8890                                 for (i = 0; i < F_LIT_MAX; i++)
8891                                 {
8892                                         attr_old[i] = f_ptr->x_attr[i];
8893                                         char_old[i] = f_ptr->x_char[i];
8894                                 }
8895                                 *lighting_level = F_LIT_STANDARD;
8896                                 break;
8897
8898                         case 'C':
8899                         case 'c':
8900                                 if (!visual_list)
8901                                 {
8902                                         for (i = 0; i < F_LIT_MAX; i++)
8903                                         {
8904                                                 attr_idx_feat[i] = f_ptr->x_attr[i];
8905                                                 char_idx_feat[i] = f_ptr->x_char[i];
8906                                         }
8907                                 }
8908                                 break;
8909
8910                         case 'P':
8911                         case 'p':
8912                                 if (!visual_list)
8913                                 {
8914                                         /* Allow TERM_DARK text */
8915                                         for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
8916                                         {
8917                                                 if (attr_idx_feat[i] || (!(char_idx_feat[i] & 0x80) && char_idx_feat[i])) f_ptr->x_attr[i] = attr_idx_feat[i];
8918                                                 if (char_idx_feat[i]) f_ptr->x_char[i] = char_idx_feat[i];
8919                                         }
8920                                 }
8921                                 break;
8922                         }
8923                         continue;
8924                 }
8925
8926                 switch (ch)
8927                 {
8928                         case ESCAPE:
8929                         {
8930                                 flag = TRUE;
8931                                 break;
8932                         }
8933
8934                         default:
8935                         {
8936                                 /* Move the cursor */
8937                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
8938                                 break;
8939                         }
8940                 }
8941         }
8942
8943         /* Free the "feat_idx" array */
8944         C_KILL(feat_idx, max_f_idx, int);
8945 }
8946
8947
8948 /*
8949  * List wanted monsters
8950  */
8951 static void do_cmd_knowledge_kubi(void)
8952 {
8953         int i;
8954         FILE *fff;
8955         
8956         char file_name[1024];
8957         
8958         
8959         /* Open a new file */
8960         fff = my_fopen_temp(file_name, 1024);
8961         if (!fff) {
8962 #ifdef JP
8963             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8964 #else
8965             msg_format("Failed to create temporary file %s.", file_name);
8966 #endif
8967             msg_print(NULL);
8968             return;
8969         }
8970         
8971         if (fff)
8972         {
8973                 bool listed = FALSE;
8974
8975 #ifdef JP
8976                 fprintf(fff, "º£Æü¤Î¥¿¡¼¥²¥Ã¥È : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "ÉÔÌÀ"));
8977                 fprintf(fff, "\n");
8978                 fprintf(fff, "¾Þ¶â¼ó¥ê¥¹¥È\n");
8979 #else
8980                 fprintf(fff, "Today target : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "unknown"));
8981                 fprintf(fff, "\n");
8982                 fprintf(fff, "List of wanted monsters\n");
8983 #endif
8984                 fprintf(fff, "----------------------------------------------\n");
8985
8986                 for (i = 0; i < MAX_KUBI; i++)
8987                 {
8988                         if (kubi_r_idx[i] <= 10000)
8989                         {
8990                                 fprintf(fff,"%s\n", r_name + r_info[kubi_r_idx[i]].name);
8991
8992                                 listed = TRUE;
8993                         }
8994                 }
8995
8996                 if (!listed)
8997                 {
8998 #ifdef JP
8999                         fprintf(fff,"\n%s\n", "¾Þ¶â¼ó¤Ï¤â¤¦»Ä¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
9000 #else
9001                         fprintf(fff,"\n%s\n", "There is no more wanted monster.");
9002 #endif
9003                 }
9004         }
9005         
9006         /* Close the file */
9007         my_fclose(fff);
9008         
9009         /* Display the file contents */
9010 #ifdef JP
9011         show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
9012 #else
9013         show_file(TRUE, file_name, "Wanted monsters", 0, 0);
9014 #endif
9015
9016         
9017         /* Remove the file */
9018         fd_kill(file_name);
9019 }
9020
9021 /*
9022  * List virtues & status
9023  */
9024 static void do_cmd_knowledge_virtues(void)
9025 {
9026         FILE *fff;
9027         
9028         char file_name[1024];
9029         
9030         
9031         /* Open a new file */
9032         fff = my_fopen_temp(file_name, 1024);
9033         if (!fff) {
9034 #ifdef JP
9035             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9036 #else
9037             msg_format("Failed to create temporary file %s.", file_name);
9038 #endif
9039             msg_print(NULL);
9040             return;
9041         }
9042         
9043         if (fff)
9044         {
9045 #ifdef JP
9046                 fprintf(fff, "¸½ºß¤Î°À­ : %s\n\n", your_alignment());
9047 #else
9048                 fprintf(fff, "Your alighnment : %s\n\n", your_alignment());
9049 #endif
9050                 dump_virtues(fff);
9051         }
9052         
9053         /* Close the file */
9054         my_fclose(fff);
9055         
9056         /* Display the file contents */
9057 #ifdef JP
9058         show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
9059 #else
9060         show_file(TRUE, file_name, "Virtues", 0, 0);
9061 #endif
9062
9063         
9064         /* Remove the file */
9065         fd_kill(file_name);
9066 }
9067
9068 /*
9069 * Dungeon
9070 *
9071 */
9072 static void do_cmd_knowledge_dungeon(void)
9073 {
9074         FILE *fff;
9075         
9076         char file_name[1024];
9077         int i;
9078         
9079         
9080         /* Open a new file */
9081         fff = my_fopen_temp(file_name, 1024);
9082         if (!fff) {
9083 #ifdef JP
9084             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9085 #else
9086             msg_format("Failed to create temporary file %s.", file_name);
9087 #endif
9088             msg_print(NULL);
9089             return;
9090         }
9091         
9092         if (fff)
9093         {
9094                 for (i = 1; i < max_d_idx; i++)
9095                 {
9096                         bool seiha = FALSE;
9097
9098                         if (!d_info[i].maxdepth) continue;
9099                         if (!max_dlv[i]) continue;
9100                         if (d_info[i].final_guardian)
9101                         {
9102                                 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
9103                         }
9104                         else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
9105 #ifdef JP
9106                         fprintf(fff,"%c%-12s :  %3d ³¬\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
9107 #else
9108                         fprintf(fff,"%c%-16s :  level %3d\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
9109 #endif
9110                 }
9111         }
9112         
9113         /* Close the file */
9114         my_fclose(fff);
9115         
9116         /* Display the file contents */
9117 #ifdef JP
9118         show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
9119 #else
9120         show_file(TRUE, file_name, "Dungeon", 0, 0);
9121 #endif
9122
9123         
9124         /* Remove the file */
9125         fd_kill(file_name);
9126 }
9127
9128 /*
9129 * List virtues & status
9130 *
9131 */
9132 static void do_cmd_knowledge_stat(void)
9133 {
9134         FILE *fff;
9135         
9136         char file_name[1024];
9137         int percent, v_nr;
9138         
9139         /* Open a new file */
9140         fff = my_fopen_temp(file_name, 1024);
9141         if (!fff) {
9142 #ifdef JP
9143             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9144 #else
9145             msg_format("Failed to create temporary file %s.", file_name);
9146 #endif
9147             msg_print(NULL);
9148             return;
9149         }
9150         
9151         if (fff)
9152         {
9153                 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
9154                         (2 * p_ptr->hitdie +
9155                         ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
9156
9157 #ifdef JP
9158                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
9159                 else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
9160                 fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
9161 #else
9162                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
9163                 else fprintf(fff, "Your current Life Rating is ???.\n\n");
9164                 fprintf(fff, "Limits of maximum stats\n\n");
9165 #endif
9166                 for (v_nr = 0; v_nr < 6; v_nr++)
9167                 {
9168                         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);
9169                         else fprintf(fff, "%s ???\n", stat_names[v_nr]);
9170                 }
9171         }
9172
9173         dump_yourself(fff);
9174
9175         /* Close the file */
9176         my_fclose(fff);
9177         
9178         /* Display the file contents */
9179 #ifdef JP
9180         show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
9181 #else
9182         show_file(TRUE, file_name, "HP-rate & Max stat", 0, 0);
9183 #endif
9184
9185         
9186         /* Remove the file */
9187         fd_kill(file_name);
9188 }
9189
9190
9191 /*
9192  * Print all active quests
9193  */
9194 static void do_cmd_knowledge_quests_current(FILE *fff)
9195 {
9196         char tmp_str[120];
9197         char rand_tmp_str[120] = "\0";
9198         char name[80];
9199         monster_race *r_ptr;
9200         int i;
9201         int rand_level = 100;
9202         int total = 0;
9203
9204 #ifdef JP
9205         fprintf(fff, "¡Ô¿ë¹ÔÃæ¤Î¥¯¥¨¥¹¥È¡Õ\n");
9206 #else
9207         fprintf(fff, "< Current Quest >\n");
9208 #endif
9209
9210         for (i = 1; i < max_quests; i++)
9211         {
9212                 if ((quest[i].status == QUEST_STATUS_TAKEN) || (quest[i].status == QUEST_STATUS_COMPLETED))
9213                 {
9214                         /* Set the quest number temporary */
9215                         int old_quest = p_ptr->inside_quest;
9216                         int j;
9217
9218                         /* Clear the text */
9219                         for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
9220                         quest_text_line = 0;
9221
9222                         p_ptr->inside_quest = i;
9223
9224                         /* Get the quest text */
9225                         init_flags = INIT_SHOW_TEXT;
9226
9227                         process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9228
9229                         /* Reset the old quest number */
9230                         p_ptr->inside_quest = old_quest;
9231
9232                         /* No info from "silent" quests */
9233                         if (quest[i].flags & QUEST_FLAG_SILENT) continue;
9234
9235                         total++;
9236
9237                         if (quest[i].type != QUEST_TYPE_RANDOM)
9238                         {
9239                                 char note[80] = "\0";
9240
9241                                 if (quest[i].status == QUEST_STATUS_TAKEN)
9242                                 {
9243                                         switch (quest[i].type)
9244                                         {
9245                                         case QUEST_TYPE_KILL_LEVEL:
9246                                         case QUEST_TYPE_KILL_ANY_LEVEL:
9247                                                 r_ptr = &r_info[quest[i].r_idx];
9248                                                 strcpy(name, r_name + r_ptr->name);
9249                                                 if (quest[i].max_num > 1)
9250                                                 {
9251 #ifdef JP
9252                                                         sprintf(note," - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
9253                                                                 quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
9254 #else
9255                                                         plural_aux(name);
9256                                                         sprintf(note," - kill %d %s, have killed %d.",
9257                                                                 quest[i].max_num, name, quest[i].cur_num);
9258 #endif
9259                                                 }
9260                                                 else
9261 #ifdef JP
9262                                                         sprintf(note," - %s¤òÅݤ¹¡£",name);
9263 #else
9264                                                         sprintf(note," - kill %s.",name);
9265 #endif
9266                                                 break;
9267
9268                                         case QUEST_TYPE_FIND_ARTIFACT:
9269                                                 strcpy(name, a_name + a_info[quest[i].k_idx].name);
9270 #ifdef JP
9271                                                 sprintf(note," - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
9272 #else
9273                                                 sprintf(note," - Find out %s.", name);
9274 #endif
9275                                                 break;
9276
9277                                         case QUEST_TYPE_FIND_EXIT:
9278 #ifdef JP
9279                                                 sprintf(note," - Ãµº÷¤¹¤ë¡£");
9280 #else
9281                                                 sprintf(note," - Search.");
9282 #endif
9283                                                 break;
9284
9285                                         case QUEST_TYPE_KILL_NUMBER:
9286 #ifdef JP
9287                                                 sprintf(note," - %d ÂΤΥâ¥ó¥¹¥¿¡¼¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
9288                                                         quest[i].max_num, quest[i].max_num - quest[i].cur_num);
9289 #else
9290                                                 sprintf(note," - Kill %d monsters, have killed %d.",
9291                                                         quest[i].max_num, quest[i].cur_num);
9292 #endif
9293                                                 break;
9294
9295                                         case QUEST_TYPE_KILL_ALL:
9296 #ifdef JP
9297                                                 sprintf(note," - Á´¤Æ¤Î¥â¥ó¥¹¥¿¡¼¤òÅݤ¹¡£");
9298 #else
9299                                                 sprintf(note," - Kill all monsters.");
9300 #endif
9301                                                 break;
9302                                         }
9303                                 }
9304
9305                                 /* Print the quest info */
9306 #ifdef JP
9307                                 sprintf(tmp_str, "  %s (´í¸±ÅÙ:%d³¬ÁêÅö)%s\n",
9308                                         quest[i].name, quest[i].level, note);
9309 #else
9310                                 sprintf(tmp_str, "  %s (Danger level: %d)%s\n",
9311                                         quest[i].name, quest[i].level, note);
9312 #endif
9313
9314                                 fprintf(fff, tmp_str);
9315
9316                                 if (quest[i].status == QUEST_STATUS_COMPLETED)
9317                                 {
9318 #ifdef JP
9319                                         sprintf(tmp_str, "    ¥¯¥¨¥¹¥ÈãÀ® - ¤Þ¤ÀÊó½·¤ò¼õ¤±¤È¤Ã¤Æ¤Ê¤¤¡£\n");
9320 #else
9321                                         sprintf(tmp_str, "    Quest Completed - Unrewarded\n");
9322 #endif
9323                                         fprintf(fff, tmp_str);
9324                                 }
9325                                 else
9326                                 {
9327                                         j = 0;
9328
9329                                         while (quest_text[j][0] && j < 10)
9330                                         {
9331                                                 fprintf(fff, "    %s\n", quest_text[j]);
9332                                                 j++;
9333                                         }
9334                                 }
9335                         }
9336                         else if (quest[i].level < rand_level) /* QUEST_TYPE_RANDOM */
9337                         {
9338                                 /* New random */
9339                                 rand_level = quest[i].level;
9340
9341                                 if (max_dlv[DUNGEON_ANGBAND] >= rand_level)
9342                                 {
9343                                         /* Print the quest info */
9344                                         r_ptr = &r_info[quest[i].r_idx];
9345                                         strcpy(name, r_name + r_ptr->name);
9346
9347                                         if (quest[i].max_num > 1)
9348                                         {
9349 #ifdef JP
9350                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
9351                                                         quest[i].name, quest[i].level,
9352                                                         quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
9353 #else
9354                                                 plural_aux(name);
9355
9356                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
9357                                                         quest[i].name, quest[i].level,
9358                                                         quest[i].max_num, name, quest[i].cur_num);
9359 #endif
9360                                         }
9361                                         else
9362                                         {
9363 #ifdef JP
9364                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %s¤òÅݤ¹¡£\n",
9365                                                         quest[i].name, quest[i].level, name);
9366 #else
9367                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %s.\n",
9368                                                         quest[i].name, quest[i].level, name);
9369 #endif
9370                                         }
9371                                 }
9372                         }
9373                 }
9374         }
9375
9376         /* Print the current random quest  */
9377         if (rand_tmp_str[0]) fprintf(fff, rand_tmp_str);
9378
9379 #ifdef JP
9380         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9381 #else
9382         if (!total) fprintf(fff, "  Nothing.\n");
9383 #endif
9384 }
9385
9386
9387 /*
9388  * Print all finished quests
9389  */
9390 void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
9391 {
9392         char tmp_str[120];
9393         int i;
9394         int total = 0;
9395
9396 #ifdef JP
9397         fprintf(fff, "¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
9398 #else
9399         fprintf(fff, "< Completed Quest >\n");
9400 #endif
9401         for (i = 1; i < max_quests; i++)
9402         {
9403                 int q_idx = quest_num[i];
9404
9405                 if (quest[q_idx].status == QUEST_STATUS_FINISHED)
9406                 {
9407                         if (is_fixed_quest_idx(q_idx))
9408                         {
9409                                 /* Set the quest number temporary */
9410                                 int old_quest = p_ptr->inside_quest;
9411
9412                                 p_ptr->inside_quest = q_idx;
9413
9414                                 /* Get the quest */
9415                                 init_flags = INIT_ASSIGN;
9416
9417                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9418
9419                                 /* Reset the old quest number */
9420                                 p_ptr->inside_quest = old_quest;
9421
9422                                 /* No info from "silent" quests */
9423                                 if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
9424                         }
9425
9426                         total++;
9427
9428                         if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
9429                         {
9430                                 /* Print the quest info */
9431
9432                                 if (quest[q_idx].complev == 0)
9433                                 {
9434                                         sprintf(tmp_str,
9435 #ifdef JP
9436                                                 "  %-40s (%3d³¬)            -   ÉÔÀᄀ\n",
9437 #else
9438                                                 "  %-40s (Dungeon level: %3d) - (Cancelled)\n",
9439 #endif
9440                                                 r_name+r_info[quest[q_idx].r_idx].name,
9441                                                 quest[q_idx].level);
9442                                 }
9443                                 else
9444                                 {
9445                                         sprintf(tmp_str,
9446 #ifdef JP
9447                                                 "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
9448 #else
9449                                                 "  %-40s (Dungeon level: %3d) - level %2d\n",
9450 #endif
9451                                                 r_name+r_info[quest[q_idx].r_idx].name,
9452                                                 quest[q_idx].level,
9453                                                 quest[q_idx].complev);
9454                                 }
9455                         }
9456                         else
9457                         {
9458                                 /* Print the quest info */
9459 #ifdef JP
9460                                 sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
9461                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9462 #else
9463                                 sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
9464                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9465 #endif
9466                         }
9467
9468                         fprintf(fff, tmp_str);
9469                 }
9470         }
9471 #ifdef JP
9472         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9473 #else
9474         if (!total) fprintf(fff, "  Nothing.\n");
9475 #endif
9476 }
9477
9478
9479 /*
9480  * Print all failed quests
9481  */
9482 void do_cmd_knowledge_quests_failed(FILE *fff, int quest_num[])
9483 {
9484         char tmp_str[120];
9485         int i;
9486         int total = 0;
9487
9488 #ifdef JP
9489         fprintf(fff, "¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
9490 #else
9491         fprintf(fff, "< Failed Quest >\n");
9492 #endif
9493         for (i = 1; i < max_quests; i++)
9494         {
9495                 int q_idx = quest_num[i];
9496
9497                 if ((quest[q_idx].status == QUEST_STATUS_FAILED_DONE) || (quest[q_idx].status == QUEST_STATUS_FAILED))
9498                 {
9499                         if (is_fixed_quest_idx(q_idx))
9500                         {
9501                                 /* Set the quest number temporary */
9502                                 int old_quest = p_ptr->inside_quest;
9503
9504                                 p_ptr->inside_quest = q_idx;
9505
9506                                 /* Get the quest text */
9507                                 init_flags = INIT_ASSIGN;
9508
9509                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9510
9511                                 /* Reset the old quest number */
9512                                 p_ptr->inside_quest = old_quest;
9513
9514                                 /* No info from "silent" quests */
9515                                 if (quest[q_idx].flags & QUEST_FLAG_SILENT) continue;
9516                         }
9517
9518                         total++;
9519
9520                         if (!is_fixed_quest_idx(q_idx) && quest[q_idx].r_idx)
9521                         {
9522                                 /* Print the quest info */
9523 #ifdef JP
9524                                 sprintf(tmp_str, "  %-40s (%3d³¬)            - ¥ì¥Ù¥ë%2d\n",
9525                                         r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
9526 #else
9527                                 sprintf(tmp_str, "  %-40s (Dungeon level: %3d) - level %2d\n",
9528                                         r_name+r_info[quest[q_idx].r_idx].name, quest[q_idx].level, quest[q_idx].complev);
9529 #endif
9530                         }
9531                         else
9532                         {
9533                                 /* Print the quest info */
9534 #ifdef JP
9535                                 sprintf(tmp_str, "  %-40s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d\n",
9536                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9537 #else
9538                                 sprintf(tmp_str, "  %-40s (Danger  level: %3d) - level %2d\n",
9539                                         quest[q_idx].name, quest[q_idx].level, quest[q_idx].complev);
9540 #endif
9541                         }
9542                         fprintf(fff, tmp_str);
9543                 }
9544         }
9545 #ifdef JP
9546         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9547 #else
9548         if (!total) fprintf(fff, "  Nothing.\n");
9549 #endif
9550 }
9551
9552
9553 /*
9554  * Print all random quests
9555  */
9556 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
9557 {
9558         char tmp_str[120];
9559         int i;
9560         int total = 0;
9561
9562 #ifdef JP
9563         fprintf(fff, "¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
9564 #else
9565         fprintf(fff, "< Remaining Random Quest >\n");
9566 #endif
9567         for (i = 1; i < max_quests; i++)
9568         {
9569                 /* No info from "silent" quests */
9570                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
9571
9572                 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
9573                 {
9574                         total++;
9575
9576                         /* Print the quest info */
9577 #ifdef JP
9578                         sprintf(tmp_str, "  %s (%d³¬, %s)\n",
9579                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
9580 #else
9581                         sprintf(tmp_str, "  %s (%d, %s)\n",
9582                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
9583 #endif
9584                         fprintf(fff, tmp_str);
9585                 }
9586         }
9587 #ifdef JP
9588         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9589 #else
9590         if (!total) fprintf(fff, "  Nothing.\n");
9591 #endif
9592 }
9593
9594
9595 bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
9596 {
9597         int *q_num = (int *)u;
9598         quest_type *qa = &quest[q_num[a]];
9599         quest_type *qb = &quest[q_num[b]];
9600
9601         /* Unused */
9602         (void)v;
9603
9604         if (qa->complev < qb->complev) return TRUE;
9605         if (qa->complev > qb->complev) return FALSE;
9606         if (qa->level <= qb->level) return TRUE;
9607         return FALSE;
9608 }
9609
9610 void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
9611 {
9612         int *q_num = (int *)u;
9613         int tmp;
9614
9615         /* Unused */
9616         (void)v;
9617
9618         tmp = q_num[a];
9619         q_num[a] = q_num[b];
9620         q_num[b] = tmp;
9621 }
9622
9623
9624 /*
9625  * Print quest status of all active quests
9626  */
9627 static void do_cmd_knowledge_quests(void)
9628 {
9629         FILE *fff;
9630         char file_name[1024];
9631         int *quest_num, dummy, i;
9632
9633         /* Open a new file */
9634         fff = my_fopen_temp(file_name, 1024);
9635         if (!fff)
9636         {
9637 #ifdef JP
9638             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9639 #else
9640             msg_format("Failed to create temporary file %s.", file_name);
9641 #endif
9642             msg_print(NULL);
9643             return;
9644         }
9645
9646         /* Allocate Memory */
9647         C_MAKE(quest_num, max_quests, int);
9648
9649         /* Sort by compete level */
9650         for (i = 1; i < max_quests; i++) quest_num[i] = i;
9651         ang_sort_comp = ang_sort_comp_quest_num;
9652         ang_sort_swap = ang_sort_swap_quest_num;
9653         ang_sort(quest_num, &dummy, max_quests);
9654
9655         /* Dump Quest Information */
9656         do_cmd_knowledge_quests_current(fff);
9657         fputc('\n', fff);
9658         do_cmd_knowledge_quests_completed(fff, quest_num);
9659         fputc('\n', fff);
9660         do_cmd_knowledge_quests_failed(fff, quest_num);
9661         if (p_ptr->wizard)
9662         {
9663                 fputc('\n', fff);
9664                 do_cmd_knowledge_quests_wiz_random(fff);
9665         }
9666
9667         /* Close the file */
9668         my_fclose(fff);
9669
9670         /* Display the file contents */
9671 #ifdef JP
9672         show_file(TRUE, file_name, "¥¯¥¨¥¹¥ÈãÀ®¾õ¶·", 0, 0);
9673 #else
9674         show_file(TRUE, file_name, "Quest status", 0, 0);
9675 #endif
9676
9677         /* Remove the file */
9678         fd_kill(file_name);
9679
9680         /* Free Memory */
9681         C_KILL(quest_num, max_quests, int);
9682 }
9683
9684
9685 /*
9686  * List my home
9687  */
9688 static void do_cmd_knowledge_home(void)
9689 {
9690         FILE *fff;
9691
9692         int i;
9693         char file_name[1024];
9694         store_type  *st_ptr;
9695         char o_name[MAX_NLEN];
9696         cptr            paren = ")";
9697
9698         process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
9699
9700         /* Open a new file */
9701         fff = my_fopen_temp(file_name, 1024);
9702         if (!fff) {
9703 #ifdef JP
9704                 msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9705 #else
9706                 msg_format("Failed to create temporary file %s.", file_name);
9707 #endif
9708                 msg_print(NULL);
9709                 return;
9710         }
9711
9712         if (fff)
9713         {
9714                 /* Print all homes in the different towns */
9715                 st_ptr = &town[1].store[STORE_HOME];
9716
9717                 /* Home -- if anything there */
9718                 if (st_ptr->stock_num)
9719                 {
9720 #ifdef JP
9721                         int x = 1;
9722 #endif
9723                         /* Header with name of the town */
9724 #ifdef JP
9725                         fprintf(fff, "  [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
9726 #else
9727                         fprintf(fff, "  [Home Inventory]\n");
9728 #endif
9729
9730                         /* Dump all available items */
9731                         for (i = 0; i < st_ptr->stock_num; i++)
9732                         {
9733 #ifdef JP
9734                                 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
9735                                 object_desc(o_name, &st_ptr->stock[i], 0);
9736                                 if (strlen(o_name) <= 80-3)
9737                                 {
9738                                         fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9739                                 }
9740                                 else
9741                                 {
9742                                         int n;
9743                                         char *t;
9744                                         for (n = 0, t = o_name; n < 80-3; n++, t++)
9745                                                 if(iskanji(*t)) {t++; n++;}
9746                                         if (n == 81-3) n = 79-3; /* ºÇ¸å¤¬´Á»úȾʬ */
9747
9748                                         fprintf(fff, "%c%s %.*s\n", I2A(i%12), paren, n, o_name);
9749                                         fprintf(fff, "   %.77s\n", o_name+n);
9750                                 }
9751 #else
9752                                 object_desc(o_name, &st_ptr->stock[i], 0);
9753                                 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9754 #endif
9755
9756                         }
9757
9758                         /* Add an empty line */
9759                         fprintf(fff, "\n\n");
9760                 }
9761         }
9762
9763         /* Close the file */
9764         my_fclose(fff);
9765
9766         /* Display the file contents */
9767 #ifdef JP
9768         show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
9769 #else
9770         show_file(TRUE, file_name, "Home Inventory", 0, 0);
9771 #endif
9772
9773
9774         /* Remove the file */
9775         fd_kill(file_name);
9776 }
9777
9778
9779 /*
9780  * Check the status of "autopick"
9781  */
9782 static void do_cmd_knowledge_autopick(void)
9783 {
9784         int k;
9785         FILE *fff;
9786         char file_name[1024];
9787
9788         /* Open a new file */
9789         fff = my_fopen_temp(file_name, 1024);
9790
9791         if (!fff)
9792         {
9793 #ifdef JP
9794             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9795 #else
9796             msg_format("Failed to create temporary file %s.", file_name);
9797 #endif
9798             msg_print(NULL);
9799             return;
9800         }
9801
9802         if (!max_autopick)
9803         {
9804 #ifdef JP
9805             fprintf(fff, "¼«Æ°Ç˲õ/½¦¤¤¤Ë¤Ï²¿¤âÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
9806 #else
9807             fprintf(fff, "No preference for auto picker/destroyer.");
9808 #endif
9809         }
9810         else
9811         {
9812 #ifdef JP
9813             fprintf(fff, "   ¼«Æ°½¦¤¤/Ç˲õ¤Ë¤Ï¸½ºß %d¹ÔÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n\n", max_autopick);
9814 #else
9815             fprintf(fff, "   There are %d registered lines for auto picker/destroyer.\n\n", max_autopick);
9816 #endif
9817         }
9818
9819         for (k = 0; k < max_autopick; k++)
9820         {
9821                 cptr tmp;
9822                 byte act = autopick_list[k].action;
9823                 if (act & DONT_AUTOPICK)
9824                 {
9825 #ifdef JP
9826                         tmp = "ÊüÃÖ";
9827 #else
9828                         tmp = "Leave";
9829 #endif
9830                 }
9831                 else if (act & DO_AUTODESTROY)
9832                 {
9833 #ifdef JP
9834                         tmp = "Ç˲õ";
9835 #else
9836                         tmp = "Destroy";
9837 #endif
9838                 }
9839                 else if (act & DO_AUTOPICK)
9840                 {
9841 #ifdef JP
9842                         tmp = "½¦¤¦";
9843 #else
9844                         tmp = "Pickup";
9845 #endif
9846                 }
9847                 else /* if (act & DO_QUERY_AUTOPICK) */ /* Obvious */
9848                 {
9849 #ifdef JP
9850                         tmp = "³Îǧ";
9851 #else
9852                         tmp = "Query";
9853 #endif
9854                 }
9855
9856                 if (act & DO_DISPLAY)
9857                         fprintf(fff, "%11s", format("[%s]", tmp));
9858                 else
9859                         fprintf(fff, "%11s", format("(%s)", tmp));
9860
9861                 tmp = autopick_line_from_entry(&autopick_list[k]);
9862                 fprintf(fff, " %s", tmp);
9863                 string_free(tmp);
9864                 fprintf(fff, "\n");
9865         }
9866         /* Close the file */
9867         my_fclose(fff);
9868         /* Display the file contents */
9869 #ifdef JP
9870         show_file(TRUE, file_name, "¼«Æ°½¦¤¤/Ç˲õ ÀßÄê¥ê¥¹¥È", 0, 0);
9871 #else
9872         show_file(TRUE, file_name, "Auto-picker/Destroyer", 0, 0);
9873 #endif
9874
9875         /* Remove the file */
9876         fd_kill(file_name);
9877 }
9878
9879
9880 /*
9881  * Interact with "knowledge"
9882  */
9883 void do_cmd_knowledge(void)
9884 {
9885         int i, p = 0;
9886         bool need_redraw = FALSE;
9887
9888         /* File type is "TEXT" */
9889         FILE_TYPE(FILE_TYPE_TEXT);
9890
9891         /* Save the screen */
9892         screen_save();
9893
9894         /* Interact until done */
9895         while (1)
9896         {
9897                 /* Clear screen */
9898                 Term_clear();
9899
9900                 /* Ask for a choice */
9901 #ifdef JP
9902                 prt(format("%d/2 ¥Ú¡¼¥¸", (p+1)), 2, 65);
9903                 prt("¸½ºß¤ÎÃ챤ò³Îǧ¤¹¤ë", 3, 0);
9904 #else
9905                 prt(format("page %d/2", (p+1)), 2, 65);
9906                 prt("Display current knowledge", 3, 0);
9907 #endif
9908
9909                 /* Give some choices */
9910 #ifdef JP
9911                 if (p == 0)
9912                 {
9913                         prt("(1) ´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à                 ¤Î°ìÍ÷", 6, 5);
9914                         prt("(2) ´ûÃΤΥ¢¥¤¥Æ¥à                       ¤Î°ìÍ÷", 7, 5);
9915                         prt("(3) ´ûÃΤÎÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ ¤Î°ìÍ÷", 8, 5);
9916                         prt("(4) ´ûÃΤΥâ¥ó¥¹¥¿¡¼                     ¤Î°ìÍ÷", 9, 5);
9917                         prt("(5) Åݤ·¤¿Å¨¤Î¿ô                         ¤Î°ìÍ÷", 10, 5);
9918                         if (!vanilla_town) prt("(6) ¾Þ¶â¼ó                               ¤Î°ìÍ÷", 11, 5);
9919                         prt("(7) ¸½ºß¤Î¥Ú¥Ã¥È                         ¤Î°ìÍ÷", 12, 5);
9920                         prt("(8) ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à                     ¤Î°ìÍ÷", 13, 5);
9921                         prt("(9) *´ÕÄê*ºÑ¤ßÁõÈ÷¤ÎÂÑÀ­                 ¤Î°ìÍ÷", 14, 5);
9922                         prt("(0) ÃÏ·Á¤Îɽ¼¨Ê¸»ú/¥¿¥¤¥ë                ¤Î°ìÍ÷", 15, 5);
9923                 }
9924                 else
9925                 {
9926                         prt("(a) ¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó                     ¤Î°ìÍ÷", 6, 5);
9927                         prt("(b) ÆÍÁ³ÊÑ°Û                             ¤Î°ìÍ÷", 7, 5);
9928                         prt("(c) Éð´ï¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 8, 5);
9929                         prt("(d) ËâË¡¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 9, 5);
9930                         prt("(e) µ»Ç½¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 10, 5);
9931                         prt("(f) ¥×¥ì¥¤¥ä¡¼¤ÎÆÁ                       ¤Î°ìÍ÷", 11, 5);
9932                         prt("(g) Æþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó                     ¤Î°ìÍ÷", 12, 5);
9933                         prt("(h) ¼Â¹ÔÃæ¤Î¥¯¥¨¥¹¥È                     ¤Î°ìÍ÷", 13, 5);
9934                         prt("(i) ¸½ºß¤Î¼«Æ°½¦¤¤/Ç˲õÀßÄê              ¤Î°ìÍ÷", 14, 5);
9935                 }
9936 #else
9937                 if (p == 0)
9938                 {
9939                         prt("(1) Display known artifacts", 6, 5);
9940                         prt("(2) Display known objects", 7, 5);
9941                         prt("(3) Display remaining uniques", 8, 5);
9942                         prt("(4) Display known monster", 9, 5);
9943                         prt("(5) Display kill count", 10, 5);
9944                         if (!vanilla_town) prt("(6) Display wanted monsters", 11, 5);
9945                         prt("(7) Display current pets", 12, 5);
9946                         prt("(8) Display home inventory", 13, 5);
9947                         prt("(9) Display *identified* equip.", 14, 5);
9948                         prt("(0) Display terrain symbols.", 15, 5);
9949                 }
9950                 else
9951                 {
9952                         prt("(a) Display about yourself", 6, 5);
9953                         prt("(b) Display mutations", 7, 5);
9954                         prt("(c) Display weapon proficiency", 8, 5);
9955                         prt("(d) Display spell proficiency", 9, 5);
9956                         prt("(e) Display misc. proficiency", 10, 5);
9957                         prt("(f) Display virtues", 11, 5);
9958                         prt("(g) Display dungeons", 12, 5);
9959                         prt("(h) Display current quests", 13, 5);
9960                         prt("(i) Display auto pick/destroy", 14, 5);
9961                 }
9962 #endif
9963                 /* Prompt */
9964 #ifdef JP
9965                 prt("-³¤¯-", 17, 8);
9966                 prt("ESC) È´¤±¤ë", 21, 1);
9967                 prt("SPACE) ¼¡¥Ú¡¼¥¸", 21, 30);
9968                 /*prt("-) Á°¥Ú¡¼¥¸", 21, 60);*/
9969                 prt("¥³¥Þ¥ó¥É:", 20, 0);
9970 #else
9971                 prt("-more-", 17, 8);
9972                 prt("ESC) Exit menu", 21, 1);
9973                 prt("SPACE) Next page", 21, 30);
9974                 /*prt("-) Previous page", 21, 60);*/
9975                 prt("Command: ", 20, 0);
9976 #endif
9977
9978                 /* Prompt */
9979                 i = inkey();
9980
9981                 /* Done */
9982                 if (i == ESCAPE) break;
9983                 switch (i)
9984                 {
9985                 case ' ': /* Page change */
9986                 case '-':
9987                         p = 1 - p;
9988                         break;
9989                 case '1': /* Artifacts */
9990                         do_cmd_knowledge_artifacts();
9991                         break;
9992                 case '2': /* Objects */
9993                         do_cmd_knowledge_objects(&need_redraw, FALSE, -1);
9994                         break;
9995                 case '3': /* Uniques */
9996                         do_cmd_knowledge_uniques();
9997                         break;
9998                 case '4': /* Monsters */
9999                         do_cmd_knowledge_monsters(&need_redraw, FALSE, -1);
10000                         break;
10001                 case '5': /* Kill count  */
10002                         do_cmd_knowledge_kill_count();
10003                         break;
10004                 case '6': /* wanted */
10005                         if (!vanilla_town) do_cmd_knowledge_kubi();
10006                         break;
10007                 case '7': /* Pets */
10008                         do_cmd_knowledge_pets();
10009                         break;
10010                 case '8': /* Home */
10011                         do_cmd_knowledge_home();
10012                         break;
10013                 case '9': /* Resist list */
10014                         do_cmd_knowledge_inven();
10015                         break;
10016                 case '0': /* Feature list */
10017                         {
10018                                 int lighting_level = F_LIT_STANDARD;
10019                                 do_cmd_knowledge_features(&need_redraw, FALSE, -1, &lighting_level);
10020                         }
10021                         break;
10022                 /* Next page */
10023                 case 'a': /* Max stat */
10024                         do_cmd_knowledge_stat();
10025                         break;
10026                 case 'b': /* Mutations */
10027                         do_cmd_knowledge_mutations();
10028                         break;
10029                 case 'c': /* weapon-exp */
10030                         do_cmd_knowledge_weapon_exp();
10031                         break;
10032                 case 'd': /* spell-exp */
10033                         do_cmd_knowledge_spell_exp();
10034                         break;
10035                 case 'e': /* skill-exp */
10036                         do_cmd_knowledge_skill_exp();
10037                         break;
10038                 case 'f': /* Virtues */
10039                         do_cmd_knowledge_virtues();
10040                         break;
10041                 case 'g': /* Dungeon */
10042                         do_cmd_knowledge_dungeon();
10043                         break;
10044                 case 'h': /* Quests */
10045                         do_cmd_knowledge_quests();
10046                         break;
10047                 case 'i': /* Autopick */
10048                         do_cmd_knowledge_autopick();
10049                         break;
10050                 default: /* Unknown option */
10051                         bell();
10052                 }
10053
10054                 /* Flush messages */
10055                 msg_print(NULL);
10056         }
10057
10058         /* Restore the screen */
10059         screen_load();
10060
10061         if (need_redraw) do_cmd_redraw();
10062 }
10063
10064
10065 /*
10066  * Check on the status of an active quest
10067  */
10068 void do_cmd_checkquest(void)
10069 {
10070         /* File type is "TEXT" */
10071         FILE_TYPE(FILE_TYPE_TEXT);
10072
10073         /* Save the screen */
10074         screen_save();
10075
10076         /* Quest info */
10077         do_cmd_knowledge_quests();
10078
10079         /* Restore the screen */
10080         screen_load();
10081 }
10082
10083
10084 /*
10085  * Display the time and date
10086  */
10087 void do_cmd_time(void)
10088 {
10089         int day, hour, min, full, start, end, num;
10090         char desc[1024];
10091
10092         char buf[1024];
10093         char day_buf[10];
10094
10095         FILE *fff;
10096
10097         extract_day_hour_min(&day, &hour, &min);
10098
10099         full = hour * 100 + min;
10100
10101         start = 9999;
10102         end = -9999;
10103
10104         num = 0;
10105
10106 #ifdef JP
10107         strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
10108 #else
10109         strcpy(desc, "It is a strange time.");
10110 #endif
10111
10112
10113         if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
10114         else strcpy(day_buf, "*****");
10115
10116         /* Message */
10117 #ifdef JP
10118         msg_format("%sÆüÌÜ, »þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
10119                    day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
10120                    min, (hour < 12) ? "AM" : "PM");
10121 #else
10122         msg_format("This is day %s. The time is %d:%02d %s.",
10123                    day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
10124                    min, (hour < 12) ? "AM" : "PM");
10125 #endif
10126
10127
10128         /* Find the path */
10129         if (!randint0(10) || p_ptr->image)
10130         {
10131 #ifdef JP
10132                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
10133 #else
10134                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
10135 #endif
10136
10137         }
10138         else
10139         {
10140 #ifdef JP
10141                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
10142 #else
10143                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
10144 #endif
10145
10146         }
10147
10148         /* Open this file */
10149         fff = my_fopen(buf, "rt");
10150
10151         /* Oops */
10152         if (!fff) return;
10153
10154         /* Find this time */
10155         while (!my_fgets(fff, buf, sizeof(buf)))
10156         {
10157                 /* Ignore comments */
10158                 if (!buf[0] || (buf[0] == '#')) continue;
10159
10160                 /* Ignore invalid lines */
10161                 if (buf[1] != ':') continue;
10162
10163                 /* Process 'Start' */
10164                 if (buf[0] == 'S')
10165                 {
10166                         /* Extract the starting time */
10167                         start = atoi(buf + 2);
10168
10169                         /* Assume valid for an hour */
10170                         end = start + 59;
10171
10172                         /* Next... */
10173                         continue;
10174                 }
10175
10176                 /* Process 'End' */
10177                 if (buf[0] == 'E')
10178                 {
10179                         /* Extract the ending time */
10180                         end = atoi(buf + 2);
10181
10182                         /* Next... */
10183                         continue;
10184                 }
10185
10186                 /* Ignore incorrect range */
10187                 if ((start > full) || (full > end)) continue;
10188
10189                 /* Process 'Description' */
10190                 if (buf[0] == 'D')
10191                 {
10192                         num++;
10193
10194                         /* Apply the randomizer */
10195                         if (!randint0(num)) strcpy(desc, buf + 2);
10196
10197                         /* Next... */
10198                         continue;
10199                 }
10200         }
10201
10202         /* Message */
10203         msg_print(desc);
10204
10205         /* Close the file */
10206         my_fclose(fff);
10207 }