OSDN Git Service

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