diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-07 10:18:48 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-07 10:18:48 +0200 |
commit | c1ac9aa30fa1c33ac09963bdb2f6a42ffadaa6c8 (patch) | |
tree | c6146f163dda564cd638179b92f9db5609e0c1c6 | |
parent | ce5976eed899a7214629302b7994acc48415ef81 (diff) | |
download | gba-experiments-c1ac9aa30fa1c33ac09963bdb2f6a42ffadaa6c8.tar.gz gba-experiments-c1ac9aa30fa1c33ac09963bdb2f6a42ffadaa6c8.zip |
Add a small 3x5 font
-rw-r--r-- | src/main.c | 14 | ||||
-rw-r--r-- | src/small-font.c | 45 |
2 files changed, 54 insertions, 5 deletions
@@ -6,22 +6,26 @@ | |||
6 | #include "sprites.h" | 6 | #include "sprites.h" |
7 | #include "text.h" | 7 | #include "text.h" |
8 | #include "sequencer.c" | 8 | #include "sequencer.c" |
9 | #include "bd-font.c" | 9 | #include "small-font.c" |
10 | 10 | ||
11 | // | 11 | // |
12 | // Main functions. | 12 | // Main functions. |
13 | // | 13 | // |
14 | 14 | ||
15 | // TODO: Cleanup OBJ/OAM memory copying and access. | ||
16 | // | ||
17 | |||
18 | int main(void) { | 15 | int main(void) { |
19 | // Configure the display in mode 0 to show OBJs, where tile memory is | 16 | // Configure the display in mode 0 to show OBJs, where tile memory is |
20 | // sequential. | 17 | // sequential. |
21 | DISP_CTRL = DISP_ENABLE_SPRITES | DISP_MODE_3 | DISP_BG_2; | 18 | DISP_CTRL = DISP_ENABLE_SPRITES | DISP_MODE_3 | DISP_BG_2; |
22 | 19 | ||
23 | // Initialize text engine. | 20 | // Initialize text engine. |
24 | txt_init_bitmap(TXT_MODE_MODE3, (Font){.data = bd_font, .char_width = 6}); | 21 | txt_init_bitmap( |
22 | TXT_MODE_MODE3, | ||
23 | (Font){ | ||
24 | .data = small_font, | ||
25 | .char_width = 4, | ||
26 | .char_height = 8, | ||
27 | .char_map = small_font_map, | ||
28 | }); | ||
25 | 29 | ||
26 | // Register interrupts. | 30 | // Register interrupts. |
27 | irq_init(); | 31 | irq_init(); |
diff --git a/src/small-font.c b/src/small-font.c new file mode 100644 index 0000000..2f232dd --- /dev/null +++ b/src/small-font.c | |||
@@ -0,0 +1,45 @@ | |||
1 | u32 small_font[] = { | ||
2 | 0x00000000, 0x00000000, 0x00020202, 0x00020000, | ||
3 | 0x000a0a00, 0x00000000, 0x000a1f0a, 0x1f0a0000, | ||
4 | 0x02070107, 0x04070200, 0x00010402, 0x01040000, | ||
5 | 0x0007050f, 0x050d0000, 0x00020200, 0x00000000, | ||
6 | 0x00020101, 0x01020000, 0x00020404, 0x04020000, | ||
7 | 0x00050207, 0x02050000, 0x00000207, 0x02000000, | ||
8 | 0x00000000, 0x00020100, 0x00000007, 0x00000000, | ||
9 | 0x00000000, 0x00020000, 0x00040602, 0x03010000, | ||
10 | 0x00070505, 0x05070000, 0x00020302, 0x02070000, | ||
11 | 0x00070407, 0x01070000, 0x00070406, 0x04070000, | ||
12 | 0x00040605, 0x07040000, 0x00070107, 0x04070000, | ||
13 | 0x00070107, 0x05070000, 0x00070402, 0x01010000, | ||
14 | 0x00070507, 0x05070000, 0x00070507, 0x04040000, | ||
15 | 0x00000200, 0x00020000, 0x00000200, 0x00020100, | ||
16 | 0x00040201, 0x02040000, 0x00000700, 0x07000000, | ||
17 | 0x00010204, 0x02010000, 0x00070402, 0x00020000, | ||
18 | 0x00070505, 0x01070000, 0x00070505, 0x07050000, | ||
19 | 0x00070503, 0x05070000, 0x00070101, 0x01070000, | ||
20 | 0x00030505, 0x05030000, 0x00070103, 0x01070000, | ||
21 | 0x00070103, 0x01010000, 0x00070105, 0x05070000, | ||
22 | 0x00050507, 0x05050000, 0x00070202, 0x02070000, | ||
23 | 0x00040404, 0x05070000, 0x00050503, 0x05050000, | ||
24 | 0x00010101, 0x01070000, 0x00050705, 0x05050000, | ||
25 | 0x00030505, 0x05050000, 0x00030505, 0x05070000, | ||
26 | 0x00070507, 0x01010000, 0x00070505, 0x07040000, | ||
27 | 0x00070503, 0x05050000, 0x00060107, 0x04030000, | ||
28 | 0x00070202, 0x02020000, 0x00050505, 0x05070000, | ||
29 | 0x00050505, 0x05060000, 0x00050505, 0x07050000, | ||
30 | 0x00050502, 0x05050000, 0x00050507, 0x02020000, | ||
31 | 0x00070402, 0x01070000, 0x00070101, 0x01070000, | ||
32 | 0x00010302, 0x06040000, 0x00070404, 0x04070000, | ||
33 | 0x00020500, 0x00000000, 0x00000000, 0x00070000, | ||
34 | }; | ||
35 | |||
36 | u8 small_font_map[256] = { | ||
37 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , | ||
38 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , | ||
39 | 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, | ||
40 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | ||
41 | 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, | ||
42 | 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, | ||
43 | 0 , 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, | ||
44 | 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 0 , 0 , 0 , 0 , 0 , | ||
45 | }; | ||