gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/cross-platform/fonts/src/fonts.c
1 /*
2 fonts.c
3 Simple example of how to use multiple fonts on the GB
4 Michael Hope, 1999.
5 */
6
7 #include <stdio.h>
8
9 #include <gbdk/platform.h>
10 #include <gbdk/font.h>
11
12 #include <gbdk/console.h>
13
14 #define WHITE 3
15 #define DKGREY 1
16
17 void main(void)
18 {
19 #ifdef SEGA
20 __WRITE_VDP_REG(VDP_R2, R2_MAP_0x3800);
21 __WRITE_VDP_REG(VDP_R5, R5_SAT_0x3F00);
22 #endif
23
24 font_t ibm_font, italic_font, min_font;
25 int i;
26
27 /* First, init the font system */
28 font_init();
29
30 /* Load all the fonts that we can */
31 ibm_font = font_load(font_ibm); /* 96 tiles */
32 italic_font = font_load(font_italic); /* 93 tiles */
33
34 /* Load this one with dk grey background and white foreground */
35 font_color(WHITE, DKGREY);
36
37 min_font = font_load(font_min);
38
39 /* Turn scrolling off (why not?) */
40 mode(get_mode() | M_NO_SCROLL);
41
42 /* Print some text! */
43
44 /* IBM font */
45 font_set(ibm_font);
46 printf("Font demo.\n\n");
47
48 printf("IBM Font #!?123\n");
49
50 /* In italic */
51 font_set(italic_font);
52 for (i=1; i!=5; i++) {
53 printf("In italics, line %u\n", i);
54 }
55
56 /* With a minimal, colour changed font */
57 font_set(min_font);
58 printf("Minimal 36 tile font\n");
59
60 /* Done */
61 font_set(ibm_font);
62 printf("\nDone!");
63 }
64
65
66
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.