OSDN Git Service

[Change] 変愚蛮怒名義を馬鹿馬鹿蛮怒名義に変更. / Change naming from Hengband to Bakabakaband.
[hengband/hengband.git] / src / term / gameterm.c
1 #include "term/gameterm.h"
2 #include "system/system-variables.h"
3 #include "term/term-color-types.h"
4 #include "util/quarks.h"
5 #include "util/string-processor.h"
6
7  /*
8  * Convert an "attr"/"char" pair into a "pict" (P)
9  */
10 #define PICT(A, C) ((((u16b)(A)) << 8) | ((byte)(C)))
11
12 /*
13  * Standard window names
14  */
15 const char angband_term_name[8][16] =
16 {
17         "Bakabakaband",
18         "Term-1",
19         "Term-2",
20         "Term-3",
21         "Term-4",
22         "Term-5",
23         "Term-6",
24         "Term-7"
25 };
26
27 /*
28  * Global table of color definitions
29  */
30 byte angband_color_table[256][4] =
31 {
32         {0x00, 0x00, 0x00, 0x00},       /* TERM_DARK */
33         {0x00, 0xFF, 0xFF, 0xFF},       /* TERM_WHITE */
34         {0x00, 0x80, 0x80, 0x80},       /* TERM_SLATE */
35         {0x00, 0xFF, 0x80, 0x00},       /* TERM_ORANGE */
36         {0x00, 0xC0, 0x00, 0x00},       /* TERM_RED */
37         {0x00, 0x00, 0x80, 0x40},       /* TERM_GREEN */
38         {0x00, 0x00, 0x00, 0xFF},       /* TERM_BLUE */
39         {0x00, 0x80, 0x40, 0x00},       /* TERM_UMBER */
40         {0x00, 0x40, 0x40, 0x40},       /* TERM_L_DARK */
41         {0x00, 0xC0, 0xC0, 0xC0},       /* TERM_L_WHITE */
42         {0x00, 0xFF, 0x00, 0xFF},       /* TERM_VIOLET */
43         {0x00, 0xFF, 0xFF, 0x00},       /* TERM_YELLOW */
44         {0x00, 0xFF, 0x00, 0x00},       /* TERM_L_RED */
45         {0x00, 0x00, 0xFF, 0x00},       /* TERM_L_GREEN */
46         {0x00, 0x00, 0xFF, 0xFF},       /* TERM_L_BLUE */
47         {0x00, 0xC0, 0x80, 0x40}        /* TERM_L_UMBER */
48 };
49
50 /*!
51  * @brief 色名称テーブル / Hack -- the "basic" color names (see "TERM_xxx")
52  */
53 const concptr color_names[16] =
54 {
55 #ifdef JP
56         "黒",
57         "白",
58         "青灰色",
59         "オレンジ",
60         "赤",
61         "緑",
62         "青",
63         "琥珀色",
64         "灰色",
65         "明青灰色",
66         "紫",
67         "黄",
68         "明るい赤",
69         "明るい緑",
70         "明るい青",
71         "明琥珀色",
72 #else
73         "Dark",
74         "White",
75         "Slate",
76         "Orange",
77         "Red",
78         "Green",
79         "Blue",
80         "Umber",
81         "Light Dark",
82         "Light Slate",
83         "Violet",
84         "Yellow",
85         "Light Red",
86         "Light Green",
87         "Light Blue",
88         "Light Umber",
89 #endif
90
91 };
92
93
94 /*!
95  * @brief サブウィンドウ名称テーブル
96  * @details
97  * <pre>
98  * Certain "screens" always use the main screen, including News, Birth,
99  * Dungeon, Tomb-stone, High-scores, Macros, Colors, Visuals, Options.
100  *
101  * Later, special flags may allow sub-windows to "steal" stuff from the
102  * main window, including File dump (help), File dump (artifacts, uniques),
103  * Character screen, Small scale map, Previous Messages, Store screen, etc.
104  *
105  * The "ctrl-i" (tab) command flips the "Display inven/equip" and "Display
106  * equip/inven" flags for all windows.
107  *
108  * The "ctrl-g" command (or pseudo-command) should perhaps grab a snapshot
109  * of the main screen into any interested windows.
110  * </pre>
111  */
112 const concptr window_flag_desc[32] =
113 {
114         _("持ち物/装備一覧", "Display inven/equip"),
115         _("装備/持ち物一覧", "Display equip/inven"),
116         _("呪文一覧", "Display spell list"),
117         _("キャラクタ情報", "Display character"),
118         _("視界内のモンスター表示", "Display monsters in sight"),
119         NULL,
120         _("メッセージ", "Display messages"),
121         _("ダンジョン全体図", "Display overhead view"),
122         _("モンスターの思い出", "Display monster recall"),
123         _("アイテムの詳細", "Display object recall"),
124         _("自分の周囲を表示", "Display dungeon view"),
125         _("記念撮影", "Display snap-shot"),
126         NULL,
127         NULL,
128         NULL,
129         NULL,
130         NULL,
131         NULL,
132         NULL,
133         NULL,
134         NULL,
135         NULL,
136         NULL,
137         NULL,
138         NULL,
139         NULL,
140         NULL,
141         NULL,
142         NULL,
143         NULL,
144         NULL,
145         NULL
146 };
147
148
149 /*!
150  * @brief シンボル解説テーブル /
151  * The table of "symbol info" -- each entry is a string of the form "X:desc" where "X" is the trigger, and "desc" is the "info".
152  */
153 const concptr ident_info[] =
154 {
155 #ifdef JP
156         " :暗闇",
157         "!:薬, オイル",
158         "\":アミュレット, 頸飾り",
159         "#:壁(隠しドア)/植物/気体",
160         "$:財宝(金か宝石)",
161         "%:鉱脈(溶岩か石英)",
162         "&:箱",
163         "':開いたドア",
164         "(:軟らかい防具",
165         "):盾",
166         "*:財宝を含んだ鉱脈または球形の怪物",
167         "+:閉じたドア",
168         ",:食べ物, おばけキノコ",
169         "-:魔法棒, ロッド",
170         ".:床",
171         "/:竿状武器(アックス/パイク/等)",
172         "0:博物館の入口",
173         "1:雑貨屋の入口",
174         "2:防具屋の入口",
175         "3:武器専門店の入口",
176         "4:寺院の入口",
177         "5:錬金術の店の入口",
178         "6:魔法の店の入口",
179         "7:ブラックマーケットの入口",
180         "8:我が家の入口",
181         "9:書店の入口",
182         "::岩石",
183         ";:回避の彫像/爆発のルーン",
184         "<:上り階段",
185         "=:指輪",
186         ">:下り階段",
187         "?:巻物",
188         "@:プレイヤー",
189         "A:天使",
190         "B:鳥",
191         "C:犬",
192         "D:古代ドラゴン/ワイアーム",
193         "E:エレメンタル",
194         "F:トンボ",
195         "G:ゴースト",
196         "H:雑種",
197         "I:昆虫",
198         "J:ヘビ",
199         "K:キラー・ビートル",
200         "L:リッチ",
201         "M:多首の爬虫類",
202         "N:謎の生物",
203         "O:オーガ",
204         "P:巨大人間型生物",
205         "Q:クイルスルグ(脈打つ肉塊)",
206         "R:爬虫類/両生類",
207         "S:蜘蛛/サソリ/ダニ",
208         "T:トロル",
209         "U:上級デーモン",
210         "V:バンパイア",
211         "W:ワイト/レイス/等",
212         "X:ゾーン/ザレン/等",
213         "Y:イエティ",
214         "Z:ハウンド",
215         "[:堅いアーマー",
216         "\\:鈍器(メイス/ムチ/等)",
217         "]:種々の防具",
218         "^:トラップ",
219         "_:杖",
220         "`:人形,彫像",
221         "a:アリ",
222         "b:コウモリ",
223         "c:ムカデ",
224         "d:ドラゴン",
225         "e:目玉",
226         "f:ネコ",
227         "g:ゴーレム",
228         "h:ホビット/エルフ/ドワーフ",
229         "i:ベトベト",
230         "j:ゼリー",
231         "k:コボルド",
232         "l:水棲生物",
233         "m:モルド",
234         "n:ナーガ",
235         "o:オーク",
236         "p:人間",
237         "q:四足獣",
238         "r:ネズミ",
239         "s:スケルトン",
240         "t:町の人",
241         "u:下級デーモン",
242         "v:ボルテックス",
243         "w:イモムシ/大群",
244         /* "x:unused", */
245         "y:イーク",
246         "z:ゾンビ/ミイラ",
247         "{:飛び道具の弾(矢/弾)",
248         "|:刀剣類(ソード/ダガー/等)",
249         "}:飛び道具(弓/クロスボウ/スリング)",
250         "~:水/溶岩流(種々のアイテム)",
251 #else
252         " :A dark grid",
253         "!:A potion (or oil)",
254         "\":An amulet (or necklace)",
255         "#:A wall (or secret door) / a plant / a gas",
256         "$:Treasure (gold or gems)",
257         "%:A vein (magma or quartz)",
258         "&:A chest",
259         "':An open door",
260         "(:Soft armor",
261         "):A shield",
262         "*:A vein with treasure or a ball monster",
263         "+:A closed door",
264         ",:Food (or mushroom patch)",
265         "-:A wand (or rod)",
266         ".:Floor",
267         "/:A polearm (Axe/Pike/etc)",
268         "0:Entrance to Museum",
269         "1:Entrance to General Store",
270         "2:Entrance to Armory",
271         "3:Entrance to Weaponsmith",
272         "4:Entrance to Temple",
273         "5:Entrance to Alchemy shop",
274         "6:Entrance to Magic store",
275         "7:Entrance to Black Market",
276         "8:Entrance to your home",
277         "9:Entrance to the bookstore",
278         "::Rubble",
279         ";:A glyph of warding / an explosive rune",
280         "<:An up staircase",
281         "=:A ring",
282         ">:A down staircase",
283         "?:A scroll",
284         "@:You",
285         "A:Angel",
286         "B:Bird",
287         "C:Canine",
288         "D:Ancient Dragon/Wyrm",
289         "E:Elemental",
290         "F:Dragon Fly",
291         "G:Ghost",
292         "H:Hybrid",
293         "I:Insect",
294         "J:Snake",
295         "K:Killer Beetle",
296         "L:Lich",
297         "M:Multi-Headed Reptile",
298         "N:Mystery Living",
299         "O:Ogre",
300         "P:Giant Humanoid",
301         "Q:Quylthulg (Pulsing Flesh Mound)",
302         "R:Reptile/Amphibian",
303         "S:Spider/Scorpion/Tick",
304         "T:Troll",
305         "U:Major Demon",
306         "V:Vampire",
307         "W:Wight/Wraith/etc",
308         "X:Xorn/Xaren/etc",
309         "Y:Yeti",
310         "Z:Zephyr Hound",
311         "[:Hard armor",
312         "\\:A hafted weapon (mace/whip/etc)",
313         "]:Misc. armor",
314         "^:A trap",
315         "_:A staff",
316         "`:A figurine or statue",
317         "a:Ant",
318         "b:Bat",
319         "c:Centipede",
320         "d:Dragon",
321         "e:Floating Eye",
322         "f:Feline",
323         "g:Golem",
324         "h:Hobbit/Elf/Dwarf",
325         "i:Icky Thing",
326         "j:Jelly",
327         "k:Kobold",
328         "l:Aquatic monster",
329         "m:Mold",
330         "n:Naga",
331         "o:Orc",
332         "p:Person/Human",
333         "q:Quadruped",
334         "r:Rodent",
335         "s:Skeleton",
336         "t:Townsperson",
337         "u:Minor Demon",
338         "v:Vortex",
339         "w:Worm/Worm-Mass",
340         /* "x:unused", */
341         "y:Yeek",
342         "z:Zombie/Mummy",
343         "{:A missile (arrow/bolt/shot)",
344         "|:An edged weapon (sword/dagger/etc)",
345         "}:A launcher (bow/crossbow/sling)",
346         "~:Fluid terrain (or miscellaneous item)",
347 #endif
348
349         NULL
350 };
351
352 /*
353  * The array of window pointers
354  */
355 term_type *angband_term[8];
356
357 /*!
358  * スクリーン表示色キャラクタ /
359  * Encode the screen colors
360  */
361 static const concptr color_char = "dwsorgbuDWvyRGBU";
362
363 /*
364  * Specify attr/char pairs for visual special effects
365  * Be sure to use "index & 0x7F" to avoid illegal access
366  */
367 TERM_COLOR misc_to_attr[256];
368 SYMBOL_CODE misc_to_char[256];
369
370 /*
371  * Specify attr/char pairs for inventory items (by tval)
372  * Be sure to use "index & 0x7F" to avoid illegal access
373  */
374 TERM_COLOR tval_to_attr[128];
375
376 /*
377  * Default spell color table (quark index)
378  */
379 TERM_COLOR gf_color[MAX_GF];
380
381 /*!
382  * @brief 万色表現用にランダムな色を選択する関数 /
383  * Get a legal "multi-hued" color for drawing "spells"
384  * @param max 色IDの最大値
385  * @return 選択した色ID
386  */
387 static TERM_COLOR mh_attr(int max)
388 {
389         switch (randint1(max))
390         {
391         case  1: return (TERM_RED);
392         case  2: return (TERM_GREEN);
393         case  3: return (TERM_BLUE);
394         case  4: return (TERM_YELLOW);
395         case  5: return (TERM_ORANGE);
396         case  6: return (TERM_VIOLET);
397         case  7: return (TERM_L_RED);
398         case  8: return (TERM_L_GREEN);
399         case  9: return (TERM_L_BLUE);
400         case 10: return (TERM_UMBER);
401         case 11: return (TERM_L_UMBER);
402         case 12: return (TERM_SLATE);
403         case 13: return (TERM_WHITE);
404         case 14: return (TERM_L_WHITE);
405         case 15: return (TERM_L_DARK);
406         }
407
408         return (TERM_WHITE);
409 }
410
411
412 /*!
413  * @brief 魔法属性に応じたエフェクトの色を返す /
414  * Return a color to use for the bolt/ball spells
415  * @param type 魔法属性
416  * @return 対応する色ID
417  */
418 static TERM_COLOR spell_color(EFFECT_ID type)
419 {
420         /* Check if A.B.'s new graphics should be used (rr9) */
421         if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2"))
422         {
423                 /* Analyze */
424                 switch (type)
425                 {
426                 case GF_PSY_SPEAR:              return (0x06);
427                 case GF_MISSILE:                return (0x0F);
428                 case GF_ACID:                   return (0x04);
429                 case GF_ELEC:                   return (0x02);
430                 case GF_FIRE:                   return (0x00);
431                 case GF_COLD:                   return (0x01);
432                 case GF_POIS:                   return (0x03);
433                 case GF_HOLY_FIRE:              return (0x00);
434                 case GF_HELL_FIRE:              return (0x00);
435                 case GF_MANA:                   return (0x0E);
436                         /* by henkma */
437                 case GF_SEEKER:                 return (0x0E);
438                 case GF_SUPER_RAY:              return (0x0E);
439
440                 case GF_ARROW:                  return (0x0F);
441                 case GF_WATER:                  return (0x04);
442                 case GF_NETHER:                 return (0x07);
443                 case GF_CHAOS:                  return (mh_attr(15));
444                 case GF_DISENCHANT:             return (0x05);
445                 case GF_NEXUS:                  return (0x0C);
446                 case GF_CONFUSION:              return (mh_attr(4));
447                 case GF_SOUND:                  return (0x09);
448                 case GF_SHARDS:                 return (0x08);
449                 case GF_FORCE:                  return (0x09);
450                 case GF_INERTIAL:               return (0x09);
451                 case GF_GRAVITY:                return (0x09);
452                 case GF_TIME:                   return (0x09);
453                 case GF_LITE_WEAK:              return (0x06);
454                 case GF_LITE:                   return (0x06);
455                 case GF_DARK_WEAK:              return (0x07);
456                 case GF_DARK:                   return (0x07);
457                 case GF_PLASMA:                 return (0x0B);
458                 case GF_METEOR:                 return (0x00);
459                 case GF_ICE:                    return (0x01);
460                 case GF_ROCKET:                 return (0x0F);
461                 case GF_DEATH_RAY:              return (0x07);
462                 case GF_NUKE:                   return (mh_attr(2));
463                 case GF_DISINTEGRATE:   return (0x05);
464                 case GF_PSI:
465                 case GF_PSI_DRAIN:
466                 case GF_TELEKINESIS:
467                 case GF_DOMINATION:
468                 case GF_DRAIN_MANA:
469                 case GF_MIND_BLAST:
470                 case GF_BRAIN_SMASH:
471                         return (0x09);
472                 case GF_CAUSE_1:
473                 case GF_CAUSE_2:
474                 case GF_CAUSE_3:
475                 case GF_CAUSE_4:                return (0x0E);
476                 case GF_HAND_DOOM:              return (0x07);
477                 case GF_CAPTURE:                return (0x0E);
478                 case GF_IDENTIFY:               return (0x01);
479                 case GF_ATTACK:                 return (0x0F);
480                 case GF_PHOTO:          return (0x06);
481                 }
482         }
483         /* Normal tiles or ASCII */
484         else
485         {
486                 TERM_COLOR a;
487                 SYMBOL_CODE c;
488
489                 /* Lookup the default colors for this type */
490                 concptr s = quark_str(gf_color[type]);
491
492                 if (!s) return (TERM_WHITE);
493
494                 /* Pick a random color */
495                 c = s[randint0(strlen(s))];
496
497                 /* Lookup this color */
498                 a = angband_strchr(color_char, c) - color_char;
499
500                 /* Invalid color (note check for < 0 removed, gave a silly
501                  * warning because bytes are always >= 0 -- RG) */
502                 if (a > 15) return (TERM_WHITE);
503
504                 /* Use this color */
505                 return (a);
506         }
507
508         /* Standard "color" */
509         return (TERM_WHITE);
510 }
511
512
513 /*!
514  * @brief 始点から終点にかけた方向毎にボルトのキャラクタを返す /
515  * Find the attr/char pair to use for a spell effect
516  * @param y 始点Y座標
517  * @param x 始点X座標
518  * @param ny 終点Y座標
519  * @param nx 終点X座標
520  * @param typ 魔法の効果属性
521  * @return 方向キャラID
522  * @details
523  * <pre>
524  * It is moving (or has moved) from (x,y) to (nx,ny).
525  * If the distance is not "one", we (may) return "*".
526  * </pre>
527  */
528 u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
529 {
530         int base;
531
532         byte k;
533
534         TERM_COLOR a;
535         SYMBOL_CODE c;
536
537         /* No motion (*) */
538         if ((ny == y) && (nx == x)) base = 0x30;
539
540         /* Vertical (|) */
541         else if (nx == x) base = 0x40;
542
543         /* Horizontal (-) */
544         else if (ny == y) base = 0x50;
545
546         /* Diagonal (/) */
547         else if ((ny - y) == (x - nx)) base = 0x60;
548
549         /* Diagonal (\) */
550         else if ((ny - y) == (nx - x)) base = 0x70;
551
552         /* Weird (*) */
553         else base = 0x30;
554
555         /* Basic spell color */
556         k = spell_color(typ);
557
558         /* Obtain attr/char */
559         a = misc_to_attr[base + k];
560         c = misc_to_char[base + k];
561
562         /* Create pict */
563         return (PICT(a, c));
564 }
565
566
567
568
569 /*!
570  * @brief シンボル1文字をカラーIDに変更する /
571  * Convert a "color letter" into an "actual" color
572  * The colors are: dwsorgbuDWvyRGBU, as shown below
573  * @param c シンボル文字
574  * @return カラーID
575  */
576 TERM_COLOR color_char_to_attr(SYMBOL_CODE c)
577 {
578         switch (c)
579         {
580         case 'd': return (TERM_DARK);
581         case 'w': return (TERM_WHITE);
582         case 's': return (TERM_SLATE);
583         case 'o': return (TERM_ORANGE);
584         case 'r': return (TERM_RED);
585         case 'g': return (TERM_GREEN);
586         case 'b': return (TERM_BLUE);
587         case 'u': return (TERM_UMBER);
588
589         case 'D': return (TERM_L_DARK);
590         case 'W': return (TERM_L_WHITE);
591         case 'v': return (TERM_VIOLET);
592         case 'y': return (TERM_YELLOW);
593         case 'R': return (TERM_L_RED);
594         case 'G': return (TERM_L_GREEN);
595         case 'B': return (TERM_L_BLUE);
596         case 'U': return (TERM_L_UMBER);
597         }
598
599         return (255);
600 }
601
602