OSDN Git Service

b3cd84e367005af4de0bacb1196ee67a3b1668ce
[hengband/hengband.git] / src / term / z-term.h
1 /* File: z-term.h */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison
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.
9  */
10
11 #ifndef INCLUDED_Z_TERM_H
12 #define INCLUDED_Z_TERM_H
13
14 #include "system/angband.h"
15 #include "system/h-basic.h"
16
17 typedef struct term_win term_win;
18  /*!
19  * @brief A term_win is a "window" for a Term
20  */
21  struct term_win
22 {
23         bool cu, cv; //!< Cursor Useless / Visible codes
24         TERM_LEN cx, cy; //!< Cursor Location (see "Useless")
25
26         TERM_COLOR **a; //!< Array[h*w] -- Attribute array 
27         char **c; //!< Array[h*w] -- Character array
28
29         TERM_COLOR *va; //!< Array[h] -- Access to the attribute array
30         char *vc; //!< Array[h] -- Access to the character array
31
32         TERM_COLOR **ta; //!< Note that the attr pair at(x, y) is a[y][x]
33         char **tc; //!< Note that the char pair at(x, y) is c[y][x]
34
35         TERM_COLOR *vta; //!< Note that the row of attr at(0, y) is a[y]
36         char *vtc;  //!< Note that the row of chars at(0, y) is c[y]
37 };
38
39
40
41 /*!
42  * @brief term実装構造体 / An actual "term" structure
43  */
44 typedef struct term term;
45 struct term
46 {
47         vptr user; //!< Extra "user" info (used by application)
48         vptr data; //!< Extra "data" info (used by implementation)
49
50         bool user_flag; //!< Flag "user_flag" An extra "user" flag (used by application)
51         bool data_flag; //!< Flag "data_flag" An extra "data" flag (used by implementation)
52
53         bool active_flag; //!< Flag "active_flag" This "term" is "active"
54         bool mapped_flag; //!< Flag "mapped_flag" This "term" is "mapped"
55         bool total_erase; //!< Flag "total_erase" This "term" should be fully erased
56         bool fixed_shape; //!< Flag "fixed_shape" This "term" is not allowed to resize
57         bool icky_corner; //!< Flag "icky_corner" This "term" has an "icky" corner grid
58         bool soft_cursor; //!< Flag "soft_cursor" This "term" uses a "software" cursor
59         bool always_pict; //!< Flag "always_pict" Use the "Term_pict()" routine for all text
60         bool higher_pict; //!< Flag "higher_pict" Use the "Term_pict()" routine for special text
61         bool always_text; //!< Flag "always_text" Use the "Term_text()" routine for invisible text
62         bool unused_flag; //!< Flag "unused_flag" Reserved for future use
63         bool never_bored; //!< Flag "never_bored" Never call the "TERM_XTRA_BORED" action
64         bool never_frosh; //!< Flag "never_frosh" Never call the "TERM_XTRA_FROSH" action
65
66         byte attr_blank; //!< Value "attr_blank" Use this "attr" value for "blank" grids
67         char char_blank; //!< Value "char_blank" Use this "char" value for "blank" grids
68
69         char *key_queue; //!< Keypress Queue -- various data / Keypress Queue -- pending keys
70         u16b key_head;
71         u16b key_tail;
72         u16b key_xtra;
73         u16b key_size;
74
75         TERM_LEN wid; //!< Window Width(max 255)
76         TERM_LEN hgt; //!< Window Height(max 255)
77
78         TERM_LEN y1; //!< Minimum modified row
79         TERM_LEN y2; //!< Maximum modified row
80
81         TERM_LEN *x1; //!< Minimum modified column(per row)
82         TERM_LEN *x2; //!< Maximum modified column(per row)
83
84         term_win *old; //!< Displayed screen image
85         term_win *scr; //!< Requested screen image
86
87         term_win *tmp; //!< Temporary screen image
88         term_win *mem; //!< Memorized screen image
89
90         void (*init_hook)(term *t); //!< Hook for init - ing the term
91         void (*nuke_hook)(term *t); //!< Hook for nuke - ing the term
92
93         errr (*user_hook)(int n); //!< ユーザ設定項目実装部 / Hook for user actions
94         errr (*xtra_hook)(int n, int v); //!< 拡張機能実装部 / Hook for extra actions
95         errr (*curs_hook)(TERM_LEN x, TERM_LEN y); //!< カーソル描画実装部 / Hook for placing the cursor
96         errr (*bigcurs_hook)(TERM_LEN x, TERM_LEN y); //!< 大型タイル時カーソル描画実装部 / Hook for placing the cursor on bigtile mode
97         errr (*wipe_hook)(TERM_LEN x, TERM_LEN y, int n); //!< 指定座標テキスト消去実装部 / Hook for drawing some blank spaces
98         errr (*text_hook)(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s); //!< テキスト描画実装部 / Hook for drawing a string of chars using an attr
99         void (*resize_hook)(void); //!< 画面リサイズ実装部
100         errr (*pict_hook)(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap, concptr tcp); //!< タイル描画実装部 / Hook for drawing a sequence of special attr / char pairs
101 };
102
103
104
105
106
107
108
109 /**** Available Constants ****/
110
111
112 /*
113  * Definitions for the "actions" of "Term_xtra()"
114  *
115  * These values may be used as the first parameter of "Term_xtra()",
116  * with the second parameter depending on the "action" itself.  Many
117  * of the actions shown below are optional on at least one platform.
118  *
119  * The "TERM_XTRA_EVENT" action uses "v" to "wait" for an event
120  * The "TERM_XTRA_SHAPE" action uses "v" to "show" the cursor
121  * The "TERM_XTRA_FROSH" action uses "v" for the index of the row
122  * The "TERM_XTRA_SOUND" action uses "v" for the index of a sound
123  * The "TERM_XTRA_ALIVE" action uses "v" to "activate" (or "close")
124  * The "TERM_XTRA_LEVEL" action uses "v" to "resume" (or "suspend")
125  * The "TERM_XTRA_DELAY" action uses "v" as a "millisecond" value
126  *
127  * The other actions do not need a "v" code, so "zero" is used.
128  */
129 #define TERM_XTRA_EVENT 1       /* Process some pending events */
130 #define TERM_XTRA_FLUSH 2       /* Flush all pending events */
131 #define TERM_XTRA_CLEAR 3       /* Clear the entire window */
132 #define TERM_XTRA_SHAPE 4       /* Set cursor shape (optional) */
133 #define TERM_XTRA_FROSH 5       /* Flush one row (optional) */
134 #define TERM_XTRA_FRESH 6       /* Flush all rows (optional) */
135 #define TERM_XTRA_NOISE 7       /* Make a noise (optional) */
136 #define TERM_XTRA_SOUND 8       /* Make a sound (optional) */
137 #define TERM_XTRA_BORED 9       /* Handle stuff when bored (optional) */
138 #define TERM_XTRA_REACT 10      /* React to global changes (optional) */
139 #define TERM_XTRA_ALIVE 11      /* Change the "hard" level (optional) */
140 #define TERM_XTRA_LEVEL 12      /* Change the "soft" level (optional) */
141 #define TERM_XTRA_DELAY 13      /* Delay some milliseconds (optional) */
142 #define TERM_XTRA_MUSIC_BASIC 14   /* Play a music(basic)   (optional) */
143 #define TERM_XTRA_MUSIC_DUNGEON 15 /* Play a music(dungeon) (optional) */
144 #define TERM_XTRA_MUSIC_QUEST 16   /* Play a music(quest)   (optional) */
145 #define TERM_XTRA_MUSIC_TOWN 17    /* Play a music(floor)   (optional) */
146 #define TERM_XTRA_MUSIC_MUTE 18
147
148 /**** Available Variables ****/
149
150 extern term *Term;
151
152
153 /**** Available Functions ****/
154
155 extern errr Term_user(int n);
156 extern errr Term_xtra(int n, int v);
157
158 extern void Term_queue_char(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc);
159 extern void Term_queue_bigchar(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc);
160
161 extern void Term_queue_line(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR *a, char *c, TERM_COLOR *ta, char *tc);
162
163 extern void Term_queue_chars(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s);
164
165 extern errr Term_fresh(void);
166 extern errr Term_set_cursor(int v);
167 extern errr Term_gotoxy(TERM_LEN x, TERM_LEN y);
168 extern errr Term_draw(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
169 extern errr Term_addch(TERM_COLOR a, char c);
170 extern errr Term_add_bigch(TERM_COLOR a, char c);
171 extern errr Term_addstr(int n, TERM_COLOR a, concptr s);
172 extern errr Term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
173 extern errr Term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s);
174 #ifdef JP
175 extern errr Term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s);
176 #endif
177 extern errr Term_erase(TERM_LEN x, TERM_LEN y, int n);
178 extern errr Term_clear(void);
179 extern errr Term_redraw(void);
180 extern errr Term_redraw_section(TERM_LEN x1, TERM_LEN y1, TERM_LEN x2, TERM_LEN y2);
181
182 extern errr Term_get_cursor(int *v);
183 extern errr Term_get_size(TERM_LEN *w, TERM_LEN *h);
184 extern errr Term_locate(TERM_LEN *x, TERM_LEN *y);
185 extern errr Term_what(TERM_LEN x, TERM_LEN y, TERM_COLOR *a, char *c);
186
187 extern errr Term_flush(void);
188 extern errr Term_keypress(int k);
189 extern errr Term_key_push(int k);
190 extern errr Term_inkey(char *ch, bool wait, bool take);
191
192 extern errr Term_save(void);
193 extern errr Term_load(void);
194
195 extern errr Term_exchange(void);
196
197 extern errr Term_resize(TERM_LEN w, TERM_LEN h);
198
199 extern errr Term_activate(term *t);
200
201 extern errr term_nuke(term *t);
202 extern errr term_init(term *t, TERM_LEN w, TERM_LEN h, int k);
203
204
205 #endif
206
207