gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/cross-platform/display_system/src/display_system.c
1 /*
2 display_system.c
3
4 Displays the system gbdk is running on.
5
6 This will report one of these three:
7 * 60 Hz
8 * 50 Hz
9 * 50 Hz, Dendy-like (only applicable gbdk-nes port)
10
11 */
12
13 #include <stdio.h>
14 #include <gbdk/platform.h>
15 #include <gbdk/font.h>
16 #include <gbdk/console.h>
17
18 const char* get_system_name(uint8_t system)
19 {
20 switch(system)
21 {
22 case SYSTEM_60HZ:
23 return "60 Hz";
24 case SYSTEM_50HZ:
25 #if defined(NINTENDO_NES)
26 // For gbdk-nes, we can also inspect the bits in _SYSTEM to more specifically
27 // report the console as a Dendy-like Famiclone instead of an official PAL NES.
28 // This distinction is rarely useful as both run on 50Hz, but can be a
29 // useful feature for running this detection program on unknown hardware.
30 if((_SYSTEM & 0xC0) == SYSTEM_BITS_DENDY)
31 return "50 Hz (Dendy-like)";
32 else
33 return "50 Hz";
34 #else
35 return "50 Hz";
36 #endif
37 default:
38 return "Unknown";
39 }
40 }
41
42 void main(void)
43 {
44 font_t ibm_font;
45 uint8_t system = get_system();
46 // Init font system and load font
47 font_init();
48 ibm_font = font_load(font_ibm);
49 DISPLAY_ON;
50 gotoxy(4, 4);
51 printf("System: %s", get_system_name(system));
52 vsync();
53 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.