4 * Copyright (c) 1997 Ben Harrison
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.
11 #ifndef INCLUDED_Z_TERM_H
12 #define INCLUDED_Z_TERM_H
18 * A term_win is a "window" for a Term
20 * - Cursor Useless/Visible codes
21 * - Cursor Location (see "Useless")
23 * - Array[h] -- Access to the attribute array
24 * - Array[h] -- Access to the character array
26 * - Array[h*w] -- Attribute array
27 * - Array[h*w] -- Character array
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]
33 typedef struct term_win term_win;
56 * @brief term実装構造体 / An actual "term" structure
58 typedef struct term term;
61 vptr user; //!< Extra "user" info (used by application)
62 vptr data; //!< Extra "data" info (used by implementation)
64 bool user_flag; //!< Flag "user_flag" An extra "user" flag (used by application)
65 bool data_flag; //!< Flag "data_flag" An extra "data" flag(used by implementation)
67 bool active_flag; //!< Flag "active_flag" This "term" is "active"
68 bool mapped_flag; //!< Flag "mapped_flag" This "term" is "mapped"
69 bool total_erase; //!< Flag "total_erase" This "term" should be fully erased
70 bool fixed_shape; //!< Flag "fixed_shape" This "term" is not allowed to resize
71 bool icky_corner; //!< Flag "icky_corner" This "term" has an "icky" corner grid
72 bool soft_cursor; //!< Flag "soft_cursor" This "term" uses a "software" cursor
73 bool always_pict; //!< Flag "always_pict" Use the "Term_pict()" routine for all text
74 bool higher_pict; //!< Flag "higher_pict" Use the "Term_pict()" routine for special text
75 bool always_text; //!< Flag "always_text" Use the "Term_text()" routine for invisible text
76 bool unused_flag; //!< Flag "unused_flag" Reserved for future use
77 bool never_bored; //!< Flag "never_bored" Never call the "TERM_XTRA_BORED" action
78 bool never_frosh; //!< Flag "never_frosh" Never call the "TERM_XTRA_FROSH" action
80 byte attr_blank; //!< Value "attr_blank" Use this "attr" value for "blank" grids
81 char char_blank; //!< Value "char_blank" Use this "char" value for "blank" grids
83 char *key_queue; //!< Keypress Queue -- various data / Keypress Queue -- pending keys
89 TERM_POSITION wid; //!< Window Width(max 255)
90 TERM_POSITION hgt; //!< Window Height(max 255)
92 byte y1; //!< Minimum modified row
93 byte y2; //!< Maximum modified row
95 byte *x1; //!< Minimum modified column(per row)
96 byte *x2; //!< Maximum modified column(per row)
98 term_win *old; //!< Displayed screen image
99 term_win *scr; //!< Requested screen image
101 term_win *tmp; //!< Temporary screen image
102 term_win *mem; //!< Memorized screen image
104 void (*init_hook)(term *t); //!< Hook for init - ing the term
105 void (*nuke_hook)(term *t); //!< Hook for nuke - ing the term
107 errr (*user_hook)(int n); //!< ユーザ設定項目実装部 / Hook for user actions
108 errr (*xtra_hook)(int n, int v); //!< Hook for extra actions
109 errr (*curs_hook)(TERM_POSITION x, TERM_POSITION y); //!< Hook for placing the cursor
110 errr (*bigcurs_hook)(TERM_POSITION x, TERM_POSITION y);
111 errr (*wipe_hook)(TERM_POSITION x, TERM_POSITION y, int n); //!< Hook for drawing some blank spaces
112 errr (*text_hook)(TERM_POSITION x, TERM_POSITION y, int n, byte a, cptr s); //!< Hook for drawing a string of chars using an attr
113 void (*resize_hook)(void);
114 errr (*pict_hook)(TERM_POSITION x, TERM_POSITION y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp); //!< Hook for drawing a sequence of special attr / char pairs
123 /**** Available Constants ****/
127 * Definitions for the "actions" of "Term_xtra()"
129 * These values may be used as the first parameter of "Term_xtra()",
130 * with the second parameter depending on the "action" itself. Many
131 * of the actions shown below are optional on at least one platform.
133 * The "TERM_XTRA_EVENT" action uses "v" to "wait" for an event
134 * The "TERM_XTRA_SHAPE" action uses "v" to "show" the cursor
135 * The "TERM_XTRA_FROSH" action uses "v" for the index of the row
136 * The "TERM_XTRA_SOUND" action uses "v" for the index of a sound
137 * The "TERM_XTRA_ALIVE" action uses "v" to "activate" (or "close")
138 * The "TERM_XTRA_LEVEL" action uses "v" to "resume" (or "suspend")
139 * The "TERM_XTRA_DELAY" action uses "v" as a "millisecond" value
141 * The other actions do not need a "v" code, so "zero" is used.
143 #define TERM_XTRA_EVENT 1 /* Process some pending events */
144 #define TERM_XTRA_FLUSH 2 /* Flush all pending events */
145 #define TERM_XTRA_CLEAR 3 /* Clear the entire window */
146 #define TERM_XTRA_SHAPE 4 /* Set cursor shape (optional) */
147 #define TERM_XTRA_FROSH 5 /* Flush one row (optional) */
148 #define TERM_XTRA_FRESH 6 /* Flush all rows (optional) */
149 #define TERM_XTRA_NOISE 7 /* Make a noise (optional) */
150 #define TERM_XTRA_SOUND 8 /* Make a sound (optional) */
151 #define TERM_XTRA_BORED 9 /* Handle stuff when bored (optional) */
152 #define TERM_XTRA_REACT 10 /* React to global changes (optional) */
153 #define TERM_XTRA_ALIVE 11 /* Change the "hard" level (optional) */
154 #define TERM_XTRA_LEVEL 12 /* Change the "soft" level (optional) */
155 #define TERM_XTRA_DELAY 13 /* Delay some milliseconds (optional) */
156 #define TERM_XTRA_MUSIC_BASIC 14 /* Play a music(basic) (optional) */
157 #define TERM_XTRA_MUSIC_DUNGEON 15 /* Play a music(dungeon) (optional) */
158 #define TERM_XTRA_MUSIC_QUEST 16 /* Play a music(quest) (optional) */
159 #define TERM_XTRA_MUSIC_TOWN 17 /* Play a music(floor) (optional) */
162 /**** Available Variables ****/
167 /**** Available Functions ****/
169 extern errr Term_user(int n);
170 extern errr Term_xtra(int n, int v);
172 extern void Term_queue_char(TERM_POSITION x, TERM_POSITION y, byte a, char c, byte ta, char tc);
173 extern void Term_queue_bigchar(TERM_POSITION x, TERM_POSITION y, byte a, char c, byte ta, char tc);
175 extern void Term_queue_line(TERM_POSITION x, TERM_POSITION y, int n, byte *a, char *c, byte *ta, char *tc);
177 extern void Term_queue_chars(TERM_POSITION x, TERM_POSITION y, int n, byte a, cptr s);
179 extern errr Term_fresh(void);
180 extern errr Term_set_cursor(int v);
181 extern errr Term_gotoxy(TERM_POSITION x, TERM_POSITION y);
182 extern errr Term_draw(TERM_POSITION x, TERM_POSITION y, byte a, char c);
183 extern errr Term_addch(byte a, char c);
184 extern errr Term_add_bigch(byte a, char c);
185 extern errr Term_addstr(int n, byte a, cptr s);
186 extern errr Term_putch(TERM_POSITION x, TERM_POSITION y, byte a, char c);
187 extern errr Term_putstr(TERM_POSITION x, TERM_POSITION y, int n, byte a, cptr s);
189 extern errr Term_putstr_v(TERM_POSITION x, TERM_POSITION y, int n, byte a, cptr s);
191 extern errr Term_erase(TERM_POSITION x, TERM_POSITION y, int n);
192 extern errr Term_clear(void);
193 extern errr Term_redraw(void);
194 extern errr Term_redraw_section(int x1, int y1, int x2, int y2);
196 extern errr Term_get_cursor(int *v);
197 extern errr Term_get_size(int *w, int *h);
198 extern errr Term_locate(int *x, int *y);
199 extern errr Term_what(TERM_POSITION x, TERM_POSITION y, byte *a, char *c);
201 extern errr Term_flush(void);
202 extern errr Term_keypress(int k);
203 extern errr Term_key_push(int k);
204 extern errr Term_inkey(char *ch, bool wait, bool take);
206 extern errr Term_save(void);
207 extern errr Term_load(void);
209 extern errr Term_exchange(void);
211 extern errr Term_resize(int w, int h);
213 extern errr Term_activate(term *t);
215 extern errr term_nuke(term *t);
216 extern errr term_init(term *t, int w, int h, int k);