summaryrefslogtreecommitdiffstats
path: root/src/bitmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bitmap.h')
-rw-r--r--src/bitmap.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/bitmap.h b/src/bitmap.h
index 0befe5d..bae9b40 100644
--- a/src/bitmap.h
+++ b/src/bitmap.h
@@ -1,29 +1,29 @@
1#ifndef GBAEXP_BITMAP_H 1#ifndef GBAEXP_BITMAP_H
2#define GBAEXP_BITMAP_H 2#define GBAEXP_BITMAP_H
3 3
4#include "bd-font.c" 4// #include "bd-font.c"
5#include "common.c" 5#include "common.h"
6 6
7// Using bd-font, an 8x8 bitmap font. 7// Using bd-font, an 8x8 bitmap font.
8static void 8// static void
9put_char(int x, int y, Color clr, u8 chr) { 9// put_char(int x, int y, Color clr, u8 chr) {
10 for (size_t i = 0; i < 8; ++i) { 10// for (size_t i = 0; i < 8; ++i) {
11 for (size_t j = 0; j < 8; ++j) { 11// for (size_t j = 0; j < 8; ++j) {
12 if ((font[chr][i] >> (7 - j)) & 0x1) { 12// if ((font[chr][i] >> (7 - j)) & 0x1) {
13 FRAMEBUFFER[y + i][x + j] = clr; 13// FRAMEBUFFER[y + i][x + j] = clr;
14 } 14// }
15 } 15// }
16 } 16// }
17} 17// }
18 18
19static void 19// static void
20put_text(int x, int y, Color clr, char *msg) { 20// put_text(int x, int y, Color clr, char *msg) {
21 int count = 0; 21// int count = 0;
22 while (*msg) { 22// while (*msg) {
23 put_char(x + count, y, clr, *msg++); 23// put_char(x + count, y, clr, *msg++);
24 count += 8; 24// count += 8;
25 } 25// }
26} 26// }
27 27
28// Draws a line with the given color between (x0,y0) and (x1,y1) using the 28// Draws a line with the given color between (x0,y0) and (x1,y1) using the
29// Bresenham's line drawing algorithm using exclusively integer arithmetic. 29// Bresenham's line drawing algorithm using exclusively integer arithmetic.
@@ -205,24 +205,24 @@ draw_logo(void) {
205 draw_line(x + height, y + 1, x + height + line, y + 1, COLOR_WHITE); 205 draw_line(x + height, y + 1, x + height + line, y + 1, COLOR_WHITE);
206} 206}
207 207
208void 208// void
209copy_font_to_tile_memory(Tile *tile) { 209// copy_font_to_tile_memory(Tile *tile) {
210 // Hex to bits translation table. 210// // Hex to bits translation table.
211 const u32 conversion_u32[16] = { 211// const u32 conversion_u32[16] = {
212 0x00000000, 0x00001000, 0x00000100, 0x00001100, 212// 0x00000000, 0x00001000, 0x00000100, 0x00001100,
213 0x00000010, 0x00001010, 0x00000110, 0x00001110, 213// 0x00000010, 0x00001010, 0x00000110, 0x00001110,
214 0x00000001, 0x00001001, 0x00000101, 0x00001101, 214// 0x00000001, 0x00001001, 0x00000101, 0x00001101,
215 0x00000011, 0x00001011, 0x00000111, 0x00001111, 215// 0x00000011, 0x00001011, 0x00000111, 0x00001111,
216 }; 216// };
217 for (size_t i = 0; i < 250; ++i) { 217// for (size_t i = 0; i < 250; ++i) {
218 for (size_t j = 0; j < 8; ++j) { 218// for (size_t j = 0; j < 8; ++j) {
219 u8 row = font[i][j]; 219// u8 row = font[i][j];
220 u32 tile_idx = 0x00000000; 220// u32 tile_idx = 0x00000000;
221 tile_idx = conversion_u32[row & 0xF] << 16; 221// tile_idx = conversion_u32[row & 0xF] << 16;
222 tile_idx |= conversion_u32[(row >> 4) & 0xF]; 222// tile_idx |= conversion_u32[(row >> 4) & 0xF];
223 (tile + i)->data[j] = tile_idx; 223// (tile + i)->data[j] = tile_idx;
224 } 224// }
225 } 225// }
226} 226// }
227 227
228#endif // GBAEXP_BITMAP_H 228#endif // GBAEXP_BITMAP_H