gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 9aba0004b835fb994faa4f6d5900e3e3969f0519 parent e3ff4e8fbea388e39bbf2623cb0b859abc611dd4 Author: Toxa <untoxa@mail.ru> Date: Mon, 22 Jan 2024 18:32:59 +0300 EXAMPLES: put back graphical rand test for the game boy Diffstat:
| A | gbdk-lib/examples/gb/rand/Makefile | 17 | +++++++++++++++++ |
| A | gbdk-lib/examples/gb/rand/rand.c | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/gbdk-lib/examples/gb/rand/Makefile b/gbdk-lib/examples/gb/rand/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j + +BINS = rand.gb + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat + +# Compile and link single file in one pass +%.gb: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/gb/rand/rand.c b/gbdk-lib/examples/gb/rand/rand.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * * + * Module : rand.c * + * * + * Purpose : A test for the rand() function, for the GBDK * + * * + * Version : 1, Januari 6 1998 * + * * + * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) * + * * + **************************************************************************/ + +#include <gb/gb.h> +#include <rand.h> +#include <gb/drawing.h> +#include <stdio.h> +#include <string.h> + +UBYTE accu[80]; +UBYTE accua[80]; + +void main(void) +{ + UBYTE r, s, t = 0, u = 0; + UWORD seed; + + memset(accu, 0, sizeof(accu)); + memset(accua, 0, sizeof(accua)); + + /* We use the DIV register to get a random initial seed */ + puts("Getting seed"); + puts("Push any key (1)"); + waitpad(0xFF); + waitpadup(); + seed = DIV_REG; + puts("Push any key (2)"); + waitpad(0xFF); + waitpadup(); + seed |= (UWORD)DIV_REG << 8; + + /* initarand() calls initrand() */ + initarand(seed); + + do { + r = rand(); + s = arand(); + + if(r < 80) { + t = ++accu[r]; + plot(r, 144-t, LTGREY, SOLID); + } + if(s < 80) { + u = ++accua[s]; + plot(s+80, 144-u, DKGREY, SOLID); + } + } + while(t != 144 && u != 144); +}
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.