git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit fd4e12732c4d2fd38e08ded5037524d6033602ad
parent 3e5e99404692563c60d04b1a673b20d44bc585ec
Author: bbbbbr <bbbbbr@users.noreply.github.com>
Date:   Tue, 27 Jun 2023 20:07:44 -0700

Merge pull request #529 from veganlies2me/develop

Example program idea: Program that detects which Game Boy the ROM is being run on
Diffstat:
Agbdk-lib/examples/gb/gbcheck/Makefile12++++++++++++
Agbdk-lib/examples/gb/gbcheck/gbcheck.c24++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/gbdk-lib/examples/gb/gbcheck/Makefile b/gbdk-lib/examples/gb/gbcheck/Makefile @@ -0,0 +1,12 @@ +CC = ../../../bin/lcc + +all: + $(CC) -Wm-ys -o gbcheck.gb gbcheck.c + +compile.bat: Makefile + @echo "REM Automatically generated from Makefile" > compile.bat + @make -sn | sed y/\\//\\\\/ | sed s/mkdir\ \-p/mkdir/ | grep -v make >> compile.bat + +clean: + rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm + diff --git a/gbdk-lib/examples/gb/gbcheck/gbcheck.c b/gbdk-lib/examples/gb/gbcheck/gbcheck.c @@ -0,0 +1,23 @@ +#include <gbdk/platform.h> +#include <stdio.h> +void main(void) +{ + // Wait 4 frames + // For PAL SNES(SGB) this delay is required on startup + for (uint8_t i = 4; i != 0; i--) + vsync(); + uint8_t issgb = sgb_check();//sgb_check() is slow, so it's better to call it once and save the result to test with + if ((_cpu == DMG_TYPE) && (!issgb))printf("This is a DMG! (OG Game Boy)"); + else if ((_cpu == MGB_TYPE) && (!issgb))printf("This is a MGB! (Game Boy Pocket / Light)"); + //Super Game Boys below + else if ((_cpu == DMG_TYPE) && (issgb))printf("This is a SGB1!"); + else if ((_cpu == MGB_TYPE) && (issgb))printf("This is a SGB2!"); + //Game Boy Color + else if ((_cpu == CGB_TYPE) && (!_is_GBA))printf("This is a CGB! (Game Boy Color)"); + //The GBA acts like a Game Boy Color. Adding !_is_GBA will make sure this only shows on a GBC + else if(_is_GBA)printf("This is a GBA in CGB mode!"); + while(1) + { + vsync(); + } +} +

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.