diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-19 16:29:20 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-19 16:29:20 +0200 |
commit | 9911609e8fff312c406e3407a519b39db79bdb97 (patch) | |
tree | bbef38c5eaac06e6658ec93c2e07c571166a836d /src/text.h | |
parent | 60684bb15f5c68eb8248673da48cc4469537ffc9 (diff) | |
download | uxngba-9911609e8fff312c406e3407a519b39db79bdb97.tar.gz uxngba-9911609e8fff312c406e3407a519b39db79bdb97.zip |
Implement double buffering drawing
Diffstat (limited to 'src/text.h')
-rw-r--r-- | src/text.h | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -131,9 +131,9 @@ txt_putc_hybrid(char c) { | |||
131 | unpack_tiles(packed_char, &tile, 1); | 131 | unpack_tiles(packed_char, &tile, 1); |
132 | int x = text_engine.cursor_x; | 132 | int x = text_engine.cursor_x; |
133 | int y = text_engine.cursor_y; | 133 | int y = text_engine.cursor_y; |
134 | // DEBUG: should be on the text struct. | 134 | Tile *buf = text_engine.memory; |
135 | Tile *buf = &TILE_MEM[0]; | ||
136 | buf[x + y * 30] = tile; | 135 | buf[x + y * 30] = tile; |
136 | dirty_tiles[y][x] = 1; | ||
137 | text_engine.cursor_x += 1; | 137 | text_engine.cursor_x += 1; |
138 | if (text_engine.cursor_x >= 30) { | 138 | if (text_engine.cursor_x >= 30) { |
139 | text_engine.cursor_x = 0; | 139 | text_engine.cursor_x = 0; |
@@ -222,6 +222,33 @@ txt_init_bitmap(TextMode mode, Font font) { | |||
222 | text_engine.mode = mode; | 222 | text_engine.mode = mode; |
223 | } | 223 | } |
224 | 224 | ||
225 | void | ||
226 | txt_init_hybrid(TextMode mode, Font font, u32 *buf) { | ||
227 | // If font_map is NULL, initialize the standard 0-255 character map. | ||
228 | if (font.char_map == NULL) { | ||
229 | for (size_t i = 0; i < 256; ++i) { | ||
230 | default_char_map[i] = i; | ||
231 | } | ||
232 | font.char_map = &default_char_map; | ||
233 | } | ||
234 | |||
235 | // Initialize default values if set to zero. | ||
236 | if (font.char_width == 0) { | ||
237 | font.char_width = 8; | ||
238 | } | ||
239 | if (font.char_height == 0) { | ||
240 | font.char_height = 8; | ||
241 | } | ||
242 | if (font.color == 0) { | ||
243 | font.color = COLOR_WHITE; | ||
244 | } | ||
245 | |||
246 | // Prepare text engine. | ||
247 | text_engine.font = font; | ||
248 | text_engine.mode = mode; | ||
249 | text_engine.memory = *buf; | ||
250 | } | ||
251 | |||
225 | // Print text to the screen with formatting. | 252 | // Print text to the screen with formatting. |
226 | void | 253 | void |
227 | txt_printf(char *msg, ...) { | 254 | txt_printf(char *msg, ...) { |