OSDN Git Service

★聖騎士強化, その他新★のレアリティ調整.
[hengband/hengband.git] / src / 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 "h-basic.h"
15
16
17 /*
18  * A term_win is a "window" for a Term
19  *
20  *      - Cursor Useless/Visible codes
21  *      - Cursor Location (see "Useless")
22  *
23  *      - Array[h] -- Access to the attribute array
24  *      - Array[h] -- Access to the character array
25  *
26  *      - Array[h*w] -- Attribute array
27  *      - Array[h*w] -- Character array
28  *
29  * Note that the attr/char pair at (x,y) is a[y][x]/c[y][x]
30  * and that the row of attr/chars at (0,y) is a[y]/c[y]
31  */
32
33 typedef struct term_win term_win;
34
35 struct term_win
36 {
37         bool cu, cv;
38         byte cx, cy;
39
40         byte **a;
41         char **c;
42
43         byte *va;
44         char *vc;
45
46 #ifdef USE_TRANSPARENCY
47         byte **ta;
48         char **tc;
49
50         byte *vta;
51         char *vtc;
52 #endif /* USE_TRANSPARENCY */
53
54 };
55
56
57
58 /*
59  * An actual "term" structure
60  *
61  *      - Extra "user" info (used by application)
62  *
63  *      - Extra "data" info (used by implementation)
64  *
65  *
66  *      - Flag "user_flag"
67  *        An extra "user" flag (used by application)
68  *
69  *
70  *      - Flag "data_flag"
71  *        An extra "data" flag (used by implementation)
72  *
73  *
74  *      - Flag "active_flag"
75  *        This "term" is "active"
76  *
77  *      - Flag "mapped_flag"
78  *        This "term" is "mapped"
79  *
80  *      - Flag "total_erase"
81  *        This "term" should be fully erased
82  *
83  *      - Flag "fixed_shape"
84  *        This "term" is not allowed to resize
85  *
86  *      - Flag "icky_corner"
87  *        This "term" has an "icky" corner grid
88  *
89  *      - Flag "soft_cursor"
90  *        This "term" uses a "software" cursor
91  *
92  *      - Flag "always_pict"
93  *        Use the "Term_pict()" routine for all text
94  *
95  *      - Flag "higher_pict"
96  *        Use the "Term_pict()" routine for special text
97  *
98  *      - Flag "always_text"
99  *        Use the "Term_text()" routine for invisible text
100  *
101  *      - Flag "unused_flag"
102  *        Reserved for future use
103  *
104  *      - Flag "never_bored"
105  *        Never call the "TERM_XTRA_BORED" action
106  *
107  *      - Flag "never_frosh"
108  *        Never call the "TERM_XTRA_FROSH" action
109  *
110  *
111  *      - Value "attr_blank"
112  *        Use this "attr" value for "blank" grids
113  *
114  *      - Value "char_blank"
115  *        Use this "char" value for "blank" grids
116  *
117  *
118  *      - Ignore this pointer
119  *
120  *      - Keypress Queue -- various data
121  *
122  *      - Keypress Queue -- pending keys
123  *
124  *
125  *      - Window Width (max 255)
126  *      - Window Height (max 255)
127  *
128  *      - Minimum modified row
129  *      - Maximum modified row
130  *
131  *      - Minimum modified column (per row)
132  *      - Maximum modified column (per row)
133  *
134  *
135  *      - Displayed screen image
136  *      - Requested screen image
137  *
138  *      - Temporary screen image
139  *      - Memorized screen image
140  *
141  *
142  *      - Hook for init-ing the term
143  *      - Hook for nuke-ing the term
144  *
145  *      - Hook for user actions
146  *
147  *      - Hook for extra actions
148  *
149  *      - Hook for placing the cursor
150  *
151  *      - Hook for drawing some blank spaces
152  *
153  *      - Hook for drawing a string of chars using an attr
154  *
155  *      - Hook for drawing a sequence of special attr/char pairs
156  */
157
158 typedef struct term term;
159
160 struct term
161 {
162         vptr user;
163
164         vptr data;
165
166         bool user_flag;
167
168         bool data_flag;
169
170         bool active_flag;
171         bool mapped_flag;
172         bool total_erase;
173         bool fixed_shape;
174         bool icky_corner;
175         bool soft_cursor;
176         bool always_pict;
177         bool higher_pict;
178         bool always_text;
179         bool unused_flag;
180         bool never_bored;
181         bool never_frosh;
182
183         byte attr_blank;
184         char char_blank;
185
186         char *key_queue;
187
188         u16b key_head;
189         u16b key_tail;
190         u16b key_xtra;
191         u16b key_size;
192
193         byte wid;
194         byte hgt;
195
196         byte y1;
197         byte y2;
198
199         byte *x1;
200         byte *x2;
201
202         term_win *old;
203         term_win *scr;
204
205         term_win *tmp;
206         term_win *mem;
207
208         void (*init_hook)(term *t);
209         void (*nuke_hook)(term *t);
210
211         errr (*user_hook)(int n);
212
213         errr (*xtra_hook)(int n, int v);
214
215         errr (*curs_hook)(int x, int y);
216
217         errr (*bigcurs_hook)(int x, int y);
218
219         errr (*wipe_hook)(int x, int y, int n);
220
221         errr (*text_hook)(int x, int y, int n, byte a, cptr s);
222
223         void (*resize_hook)(void);
224
225 #ifdef USE_TRANSPARENCY
226         errr (*pict_hook)(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp);
227 #else /* USE_TRANSPARENCY */
228         errr (*pict_hook)(int x, int y, int n, const byte *ap, const char *cp);
229 #endif /* USE_TRANSPARENCY */
230
231 };
232
233
234
235
236
237
238
239 /**** Available Constants ****/
240
241
242 /*
243  * Definitions for the "actions" of "Term_xtra()"
244  *
245  * These values may be used as the first parameter of "Term_xtra()",
246  * with the second parameter depending on the "action" itself.  Many
247  * of the actions shown below are optional on at least one platform.
248  *
249  * The "TERM_XTRA_EVENT" action uses "v" to "wait" for an event
250  * The "TERM_XTRA_SHAPE" action uses "v" to "show" the cursor
251  * The "TERM_XTRA_FROSH" action uses "v" for the index of the row
252  * The "TERM_XTRA_SOUND" action uses "v" for the index of a sound
253  * The "TERM_XTRA_ALIVE" action uses "v" to "activate" (or "close")
254  * The "TERM_XTRA_LEVEL" action uses "v" to "resume" (or "suspend")
255  * The "TERM_XTRA_DELAY" action uses "v" as a "millisecond" value
256  *
257  * The other actions do not need a "v" code, so "zero" is used.
258  */
259 #define TERM_XTRA_EVENT 1       /* Process some pending events */
260 #define TERM_XTRA_FLUSH 2       /* Flush all pending events */
261 #define TERM_XTRA_CLEAR 3       /* Clear the entire window */
262 #define TERM_XTRA_SHAPE 4       /* Set cursor shape (optional) */
263 #define TERM_XTRA_FROSH 5       /* Flush one row (optional) */
264 #define TERM_XTRA_FRESH 6       /* Flush all rows (optional) */
265 #define TERM_XTRA_NOISE 7       /* Make a noise (optional) */
266 #define TERM_XTRA_SOUND 8       /* Make a sound (optional) */
267 #define TERM_XTRA_BORED 9       /* Handle stuff when bored (optional) */
268 #define TERM_XTRA_REACT 10      /* React to global changes (optional) */
269 #define TERM_XTRA_ALIVE 11      /* Change the "hard" level (optional) */
270 #define TERM_XTRA_LEVEL 12      /* Change the "soft" level (optional) */
271 #define TERM_XTRA_DELAY 13      /* Delay some milliseconds (optional) */
272
273
274 /**** Available Variables ****/
275
276 extern term *Term;
277
278
279 /**** Available Functions ****/
280
281 extern errr Term_user(int n);
282 extern errr Term_xtra(int n, int v);
283
284 #ifdef USE_TRANSPARENCY
285 extern void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc);
286
287 extern void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc);
288 #else /* USE_TRANSPARENCY */
289 extern void Term_queue_char(int x, int y, byte a, char c);
290
291 extern void Term_queue_line(int x, int y, int n, byte *a, char *c);
292 #endif /* USE_TRANSPARENCY */
293
294 extern void Term_queue_chars(int x, int y, int n, byte a, cptr s);
295
296 extern errr Term_fresh(void);
297 extern errr Term_set_cursor(int v);
298 extern errr Term_gotoxy(int x, int y);
299 extern errr Term_draw(int x, int y, byte a, char c);
300 extern errr Term_addch(byte a, char c);
301 extern errr Term_addstr(int n, byte a, cptr s);
302 extern errr Term_putch(int x, int y, byte a, char c);
303 extern errr Term_putstr(int x, int y, int n, byte a, cptr s);
304 #ifdef JP
305 extern errr Term_putstr_v(int x, int y, int n, byte a, cptr s);
306 #endif
307 extern errr Term_erase(int x, int y, int n);
308 extern errr Term_clear(void);
309 extern errr Term_redraw(void);
310 extern errr Term_redraw_section(int x1, int y1, int x2, int y2);
311
312 extern errr Term_get_cursor(int *v);
313 extern errr Term_get_size(int *w, int *h);
314 extern errr Term_locate(int *x, int *y);
315 extern errr Term_what(int x, int y, byte *a, char *c);
316
317 extern errr Term_flush(void);
318 extern errr Term_keypress(int k);
319 extern errr Term_key_push(int k);
320 extern errr Term_inkey(char *ch, bool wait, bool take);
321
322 extern errr Term_save(void);
323 extern errr Term_load(void);
324
325 extern errr Term_exchange(void);
326
327 extern errr Term_resize(int w, int h);
328
329 extern errr Term_activate(term *t);
330
331 extern errr term_nuke(term *t);
332 extern errr term_init(term *t, int w, int h, int k);
333
334
335 #endif
336
337