Compare commits

...

28 commits

Author SHA1 Message Date
Michael Hope 50a602383a Pull the version directly from git. 2015-01-10 21:49:00 +01:00
Michael Hope 51613ec605 Bump the version. 2015-01-10 21:36:06 +01:00
Michael Hope 1ec424f4e2 Added a travis-ci.org build config. 2015-01-10 21:32:20 +01:00
Michael Hope 0196eac7dc Added a Docker script to build in a clean VM. 2015-01-10 21:26:25 +01:00
Michael Hope 684a30b299 Added a build-dep rule for Debian machines. 2015-01-10 21:16:48 +01:00
Michael Hope ff61cf5601 Modernise the binary tarball command. 2015-01-10 20:54:56 +01:00
Michael Hope 637da8d677 Pulled maccer into the top level build. 2015-01-10 20:48:29 +01:00
Michael Hope 947e10906d Make the install prefix overridable. 2015-01-10 20:45:13 +01:00
Michael Hope bf945bdc26 Renamed getline() to getline_() so it doesn't collide with libc. 2015-01-10 20:21:18 +01:00
Michael Hope 584c3e5ef5 Fixed the build by moving -lm to the end of the ld command.
Don't generate the API documentation by default.
2015-01-10 20:06:03 +01:00
Michael Hope 2c782e0b62 Imported maccer 0.25. 2015-01-10 20:04:02 +01:00
Michael Hope 105215819f Removed an auto-generated file. 2015-01-10 19:28:17 +01:00
Michael Hope 105a361908 Ensure we have a bin/ directory. 2015-01-10 19:25:28 +01:00
Michael Hope af8c3fd0b7 Renamed getline() to getline_() to remove the conflict with the builtin getline(). 2015-01-10 18:59:29 +01:00
Michael Hope 87e88b6377 Rename getline() to getline_() so we don't conflict with the builtin getline(). 2015-01-10 18:57:12 +01:00
Michael Hope 83ff071c62 Fix the copy command by removing the explicit $MANUAL path. 2015-01-10 18:55:39 +01:00
Michael Hope f4ce5ce439 Removed generated files. 2015-01-10 18:01:58 +01:00
Michael Hope 01da2d884e Added a .gitignore. 2015-01-10 17:13:19 +01:00
Michael Hope 6a90b129b7 Update the YACC script to work with bison 3.0. 2015-01-10 17:09:22 +01:00
Michael Hope bf5cebfdd7 Update the lexer to match flex 2.5. 2015-01-10 17:08:13 +01:00
Michael Hope 64db604da9 Remove the generated lexer and yaccer from the tree. 2015-01-10 16:58:05 +01:00
Michael Hope f551cdb3c0 Pull the host architecture from the dpkg.
Default the build architecture to the host architecture.
2015-01-10 16:57:08 +01:00
Michael Hope 09a290dd78 Imported gbdk-2.96a. 2015-01-10 16:25:09 +01:00
Michael Hope 7ee938a8ae Imported gbdk-2.95-2. 2015-01-10 16:25:09 +01:00
Michael Hope 42b070e5e9 Imported gbdk-2.95. 2015-01-10 16:25:08 +01:00
Michael Hope 47985a4330 Imported gbdk-2.94. 2015-01-10 16:25:08 +01:00
Michael Hope 20c0ed8d9e Imported gbdk-2.93. 2015-01-10 16:25:07 +01:00
Michael Hope d07d2c2175 Imported gbdk-2.92. 2015-01-10 16:25:07 +01:00
1940 changed files with 202609 additions and 180720 deletions

5
.travis.yml Normal file
View file

@ -0,0 +1,5 @@
language: c
install:
- sudo apt-get update -qq
- sudo make build-dep
script: make

192
Makefile Normal file
View file

@ -0,0 +1,192 @@
# Top level Makefile for GBDK that combines the builds for sdcc,
# gbdk-lib, and gbdk-support
#
# 2001 Michael Hope <michaelh@juju.net.nz>
# $Id: Makefile,v 1.4 2001/11/04 18:43:51 michaelh Exp $
#
TOPDIR = $(shell pwd)
# Package name, used for tarballs and cvs
PKG = gbdk
# Version, used for tarballs
VER ?= $(shell git describe --tags --always | sed "s/^$(PKG)-//")
# Prefix to add to the standard tools. Usefull for a standard gcc
# cross-compile.
TOOLSPREFIX =
TARGETCC = $(TOOLSPREFIX)gcc
TARGETRANLIB = $(TOOLSPREFIX)ranlib
TARGETAR = $(TOOLSPREFIX)ar
TARGETCXX = $(TOOLSPREFIX)g++
TARGETSTRIP = $(TOOLSPREFIX)strip
# Add extra flags here. g++ 2.95.4 requires -fdollars-in-identifiers
TARGETCXXFLAGS =
# Directory containing the source to sdcc
SDCCDIR = $(TOPDIR)/sdcc
# Directory containing the source to gbdk-lib
GBDKLIBDIR = $(TOPDIR)/gbdk-lib
# Directory containing the source to gbdk-support
GBDKSUPPORTDIR = $(TOPDIR)/gbdk-support
# Directory containing the source to maccer
MACCERDIR = $(TOPDIR)/maccer
# Base setup
# Extension to add to executables
EXEEXTENSION =
# Host operating system identifier. The one below should work for
# most systems.
HOSTOS := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
# Target operating system identifier. Used in the output zip name.
TARGETOS = $(HOSTOS)
# Directory that gbdk should finally end up in
TARGETDIR = /opt/gbdk
# Directory that gbdk for this target is built into.
BUILDDIR = $(TOPDIR)/build/$(TARGETOS)/gbdk
# Intermediates directory
INTDIR = $(TOPDIR)/tmp
NOISELOG = $(TOPDIR)/noise.log
all: native-build
clean: sdcc-clean gbdk-support-clean gbdk-lib-clean maccer-clean
distclean: clean build-dir-clean
# Cross-compilation targets
FIXUPMASKS = *.c *.h .bat *.s ChangeLog README
build-dep:
sudo apt-get install -y build-essential bison flex
native-build: gbdk-build gbdk-install
cross-clean: sdcc-clean gbdk-support-clean
cross-build: gbdk-build gbdk-install cross-cleanup
cross-cleanup:
ifdef MSDOSLINEENDS
for i in $(FIXUPMASKS); do \
find $(BUILDDIR) -name $$i -exec unix2dos {} \; ; \
done
endif
cross-linux-mingw32-build:
$(MAKE) TARGETOS=i586-mingw32msvc \
TOOLSPREFIX=i586-mingw32msvc- \
EXEEXTENSION=.exe \
CROSSCOMPILING=1 \
MSDOSLINEENDS=1 \
TARGETDIR=/sdcc \
ARCHIVETYPE=zip \
cross-build gbdk-lib-examples-makefile binary
# Source code drop
src: clean
rm -rf gbdk
mkdir -p gbdk
cp -r Makefile sdcc gbdk-lib gbdk-support gbdk
rm -rf `find gbdk -name CVS`
tar czf gbdk-$(VER).tar.gz gbdk
# Base rules
gbdk-build: sdcc-build gbdk-support-build gbdk-lib-build
gbdk-install: sdcc-install gbdk-support-install gbdk-lib-install
# Directories
build-bin-dir:
mkdir -p $(BUILDDIR)/bin
build-dir-clean:
rm -r $(BUILDDIR)
# Rules for sdcc
SDCCCONFIGUREFLAGS = \
--disable-mcs51-port \
--disable-avr-port \
--disable-ds390-port \
--disable-pic-port \
--disable-i186-port \
--disable-tlcs900h-port \
--disable-ucsim \
--disable-device-lib-build \
--disable-packihx
SDCCCONFIGUREFLAGS += \
--prefix=$(TARGETDIR) \
--program-suffix=$(EXEEXTENSION)
sdcc-build: $(SDCCDIR)/sdccconf.h
$(MAKE) -C $(SDCCDIR) SDCC_SUB_VERSION=$(PKG)-$(VER)
$(SDCCDIR)/sdccconf.h:
cd $(SDCCDIR); CC=$(TARGETCC) CXX=$(TARGETCXX) STRIP=$(TARGETSTRIP) RANLIB=$(TARGETRANLIB) CXXFLAGS=$(TARGETCXXFLAGS) ./configure $(SDCCCONFIGUREFLAGS) --host=$(HOSTOS)
sdcc-install: sdcc-build build-bin-dir
rm -rf $(INTDIR)/sdcc
$(MAKE) -C $(SDCCDIR) install prefix=$(INTDIR)/sdcc
cp $(INTDIR)/sdcc/bin/sdcc* $(INTDIR)/sdcc/bin/sdcpp* $(INTDIR)/sdcc/bin/link-* $(INTDIR)/sdcc/bin/as-* $(BUILDDIR)/bin
# PENDING: Hack below
sdcc-clean:
-$(MAKE) -C $(SDCCDIR) distclean
touch $(SDCCDIR)/doc/holder.pdf
# Rules for gbdk-support
gbdk-support-build:
$(MAKE) -C $(GBDKSUPPORTDIR)/lcc TOOLSPREFIX=$(TOOLSPREFIX) TARGETDIR=$(TARGETDIR)/
gbdk-support-install: gbdk-support-build build-bin-dir
cp $(GBDKSUPPORTDIR)/lcc/lcc $(BUILDDIR)/bin/lcc$(EXEEXTENSION)
$(TARGETSTRIP) $(BUILDDIR)/bin/lcc*
cp $(GBDKSUPPORTDIR)/README $(GBDKSUPPORTDIR)/ChangeLog $(BUILDDIR)
gbdk-support-clean:
$(MAKE) -C $(GBDKSUPPORTDIR)/lcc clean
# Rules for gbdk-lib
gbdk-lib-build: maccer-build
ifndef CROSSCOMPILING
PATH=$(PATH):$(INTDIR)/host $(MAKE) -C $(GBDKLIBDIR)/libc PORTS=gbz80 PLATFORMS=gb SDCCLIB=$(SDCCDIR)
endif
gbdk-lib-install: gbdk-lib-build
cp -r $(GBDKLIBDIR)/libc $(GBDKLIBDIR)/include $(GBDKLIBDIR)/examples $(GBDKLIBDIR)/tools $(BUILDDIR)
rm -rf $(BUILDDIR)/lib
cp -r $(GBDKLIBDIR)/build $(BUILDDIR)/lib
gbdk-lib-clean:
$(MAKE) -C $(GBDKLIBDIR) clean
gbdk-lib-examples-makefile:
$(MAKE) -C $(BUILDDIR)/examples/gb make.bat
unix2dos $(BUILDDIR)/examples/gb/make.bat
maccer-build:
$(MAKE) -C $(MACCERDIR) install PREFIX=$(INTDIR)/host
maccer-clean:
$(MAKE) -C $(MACCERDIR) clean
# Final binary
binary: binary-tidyup
ifeq ($(ARCHIVETYPE),zip)
rm -f $(TOPDIR)/gbdk-$(VER)-$(TARGETOS).zip
cd $(BUILDDIR)/..; zip -9Xrq $(TOPDIR)/gbdk-$(VER)-$(TARGETOS).zip gbdk
else
rm -f gbdk-$(VER)-$(TARGETOS).tar.xz
tar caf gbdk-$(VER)-$(TARGETOS).tar.xz -C $(BUILDDIR)/.. gbdk
endif
binary-tidyup:
rm -rf `find $(BUILDDIR) -name CVS`
# Install
install: native-build
mkdir -p $(TARGETDIR)
cp -r $(BUILDDIR)/* $(TARGETDIR)

View file

@ -1,3 +0,0 @@
/Makefile/1.1/Mon Feb 21 02:04:36 2000//
/Makefile.common/1.6/Fri Feb 25 01:01:08 2000//
D

View file

@ -1,3 +0,0 @@
A D/examples////
A D/include////
A D/libc////

View file

@ -1 +0,0 @@
gbdk-lib

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

6
gbdk-lib/ChangeLog Normal file
View file

@ -0,0 +1,6 @@
2001-11-03 Michael Hope <michaelh@juju.net.nz>
* examples/gb/gb-dtmf/gb-dtmf.c (main): Changed printf to %u as the arg was a int.
* examples/gb/ram_fn.c (print_counter): Made ANSI compliant.

View file

@ -1,4 +1,11 @@
# Common settings
ifndef ASM
ASM = asxxxx
endif
ifndef MODEL
MODEL = small
endif
ifndef PORTS
PORTS = gbz80 z80
@ -11,14 +18,22 @@ ifndef SDCCLIB
SDCCLIB = /home/michaelh/projects/sdcc
endif
SCC = $(SDCCLIB)/bin/sdcc
GBCC = $(SDCCLIB)/bin/lcc
SCC = $(SDCCLIB)/bin/sdcc
GBCC = $(SDCCLIB)/bin/lcc
AS_Z80 = as-z80
AS_Z80 = $(SDCCLIB)/bin/as-z80
ifeq ($(RGBDS),1)
AS_GBZ80 = rgbasm
else
AS_GBZ80 = $(SDCCLIB)/bin/as-gbz80
endif
CLEANSPEC = *.o *.asm *.cdb *.sym *.lst *~
CLEANSPEC = *.o *.cdb *.sym *.lst *~ *.asm
# Maccer rule
%.s: %.ms
maccer -o $@ $<
CFLAGS = -I$(TOPDIR)/include --model-$(MODEL)
CFLAGS += -m$(PORT) -DGBDK=1
CC = $(SCC)
BUILD = $(TOPDIR)/build/$(MODEL)/$(ASM)/$(THIS)
LIB = $(BUILD)/$(THIS).lib
OBJ = $(CSRC:%.c=$(BUILD)/%.o) $(ASSRC:%.s=$(BUILD)/%.o)

View file

@ -1 +0,0 @@
D

View file

@ -1 +0,0 @@
A D/gb////

View file

@ -1 +0,0 @@
gbdk-lib/examples

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,20 +0,0 @@
/Makefile/1.5/Mon Feb 28 00:58:19 2000//
/bank_0.c/1.1/Wed Feb 23 02:49:17 2000//
/bank_1.c/1.1/Wed Feb 23 02:49:17 2000//
/bank_2.c/1.1/Wed Feb 23 02:49:17 2000//
/bank_3.c/1.1/Wed Feb 23 02:49:17 2000//
/banks.c/1.1/Wed Feb 23 02:49:17 2000//
/comm.c/1.1/Wed Feb 23 02:49:17 2000//
/filltest.c/1.1/Wed Feb 23 02:49:17 2000//
/fonts.c/1.1/Wed Feb 23 02:49:17 2000//
/fprpn.c/1.1/Wed Feb 23 02:49:17 2000//
/galaxy.c/1.3/Mon Feb 28 00:58:19 2000//
/irq.c/1.1/Wed Feb 23 02:49:17 2000//
/paint.c/1.3/Sun Feb 27 22:54:33 2000//
/ram_fn.c/1.1/Wed Feb 23 02:49:17 2000//
/rand.c/1.2/Fri Feb 25 02:52:56 2000//
/rpn.c/1.1/Wed Feb 23 02:49:17 2000//
/samptest.c/1.1/Wed Feb 23 02:49:17 2000//
/sound.c/1.1/Wed Feb 23 02:49:17 2000//
/space.s/1.1/Wed Feb 23 02:49:17 2000//
D

View file

@ -1,4 +0,0 @@
A D/colorbar////
A D/dscan////
A D/gb-dtmf////
A D/tests////

View file

@ -1 +0,0 @@
gbdk-lib/examples/gb

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,4 +1,4 @@
CC = ../../bin/lcc -Wa-l -Wl-m -DGBDK_2_COMPAT=1 -Wl-j
CC = ../../bin/lcc -Wa-l -Wl-m -Wl-j
BINS = galaxy.gb \
space.gb \
@ -10,18 +10,24 @@ BINS = galaxy.gb \
filltest.gb \
ram_fn.gb \
fonts.gb \
samptest.gb
samptest.gb \
banks.gb
# sound.gb: Cant do bitfields
# banks.gb: Doesnt support banks.
OTHER = sound.gb \
banks.gb \
all: $(BINS)
make.bat: Makefile
echo "REM Automatically generated from Makefile" > make.bat
make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat
%.o: %.c
$(CC) -c -o $@ $<
%.s: %.c
$(CC) -S -o $@ $<
%.o: %.s
$(CC) -c -o $@ $<
@ -29,7 +35,7 @@ all: $(BINS)
$(CC) -o $@ $<
clean:
rm -f *.o *.lst *.map *.gb
rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm
############################################################
# Multiple bank example

View file

@ -0,0 +1,92 @@
TOPDIR= ../..
CC= $(TOPDIR)/bin/sdcc -mgbz80 --asm=rgbds -I$(TOPDIR)/include -v
GBLIB = $(TOPDIR)/lib/rgbds
LIB = $(GBLIB)/gbz80/gbz80.lib $(GBLIB)/gb/gb.lib
CRT0 = $(GBLIB)/gb/crt0.o
BINS = \
galaxy.gb \
paint.gb \
rpn.gb \
rand.gb \
comm.gb \
irq.gb \
filltest.gb \
fonts.gb \
samptest.gb
# sound.gb: Cant do bitfields
OTHER = sound.gb \
banks.gb \
ram_fn.gb
all: $(BINS)
make.bat: Makefile
make -sn | sed y/\\//\\\\/ | grep -v make > make.bat
%.o: %.s
%.asm: %.s
astorgb.pl $< > $@
%.o: %.c
$(CC) -c $<
%.s: %.c
$(CC) -S $<
%.o: %.asm
rgbasm -o$@ $<
%.gb: %.o
$(CC) $(CRT0) $< $(LIB)
cp a.gb $@
rgbfix -p -v $@
clean:
rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm
############################################################
# Multiple bank example
# Compile bank 0 (no ROM)
# RAM bank 0 : -Wf-ba0
#
bank_0.o: bank_0.c
$(CC) -Wf-ba0 -c -o $@ $<
# Compile bank 1 (ROM+RAM)
# ROM bank 1 : -Wf-bo1
# RAM bank 1 : -Wf-ba1
#
bank_1.o: bank_1.c
$(CC) -Wf-bo1 -Wf-ba1 -c -o $@ $<
# Compile bank 2 (ROM+RAM)
# ROM bank 2 : -Wf-bo2
# RAM bank 2 : -Wf-ba2
#
bank_2.o: bank_2.c
$(CC) -Wf-bo2 -Wf-ba2 -c -o $@ $<
# Compile bank 3 (ROM+RAM)
# ROM bank 3 : -Wf-bo3
# RAM bank 3 : -Wf-ba3
#
bank_3.o: bank_3.c
$(CC) -Wf-bo3 -Wf-ba3 -c -o $@ $<
# Link banks
# ROM+MBC1+RAM : -Wl-yt2
# 4 ROM banks : -Wl-yo4
# 4 RAM banks : -Wl-ya4
#
banks.gb: banks.o bank_0.o bank_1.o bank_2.o bank_3.o
$(CC) -Wl-yt2 -Wl-yo4 -Wl-ya4 -o $@ banks.o bank_0.o bank_1.o bank_2.o bank_3.o
############################################################
# RAM function example
ram_fn.gb: ram_fn.o
$(CC) -Wl-g_inc_ram=0xD000 -Wl-g_inc_hiram=0xFFA0 -o $@ ram_fn.o

View file

@ -1,3 +1,3 @@
#include <gb/gb.h>
UBYTE var_0; /* In external RAM bank 0 */
int var_0; /* In external RAM bank 0 */

View file

@ -1,9 +1,9 @@
#include <gb/gb.h>
#include <stdio.h>
UBYTE var_1; /* In external RAM bank 1 */
int var_1; /* In external RAM bank 1 */
void bank_1() /* In ROM bank 1 */
void bank_1() NONBANKED /* In ROM bank 1 */
{
puts("I'm in ROM bank 1");
}

View file

@ -1,9 +1,9 @@
#include <gb/gb.h>
#include <stdio.h>
UBYTE var_2; /* In external RAM bank 2 */
int var_2; /* In external RAM bank 2 */
void bank_2() /* In ROM bank 2 */
void bank_2() NONBANKED /* In ROM bank 2 */
{
puts("I'm in ROM bank 2");
}

View file

@ -1,9 +1,9 @@
#include <gb/gb.h>
#include <stdio.h>
UBYTE var_3; /* In external RAM bank 3 */
int var_3; /* In external RAM bank 3 */
void bank_3() /* In ROM bank 3 */
void bank_3() NONBANKED /* In ROM bank 3 */
{
puts("I'm in ROM bank 3");
}

View file

@ -0,0 +1,38 @@
SRC = main.c bank2.c bank3.c
BIN = banked.gb
TOPDIR = ../../..
GBLIB = $(TOPDIR)/lib/medium/rgbds
LIB = $(GBLIB)/gbz80/gbz80.lib $(GBLIB)/gb/gb.lib
CRT0 = $(GBLIB)/gb/crt0.o
OBJ = $(SRC:.c=.o)
CC = $(TOPDIR)/bin/sdcc -mgbz80 --asm=rgbds -I $(TOPDIR)/include
all: $(BIN)
clean:
rm $(OBJ)
%.o: %.s
$(BIN): $(OBJ)
$(CC) -v $(CRT0) $(OBJ) $(LIB)
rgbfix -p -v a.gb
$(LIB): $(LIBOBJ)
xlib $@ a $(LIBOBJ)
%.o: %.c
$(CC) -c $<
%.asm: %.s
astorgb.pl $< > $@
%.o: %.asm
rgbasm -o$@ $<
%.s: %.ms
maccer -o $@ $<

View file

@ -0,0 +1,9 @@
#ifndef BANK_INCLUDE
#define BANK_INCLUDE
#include <stdio.h>
int bank2(int i) BANKED;
void bank3(void) BANKED;
#endif

View file

@ -0,0 +1,13 @@
#include "bank.h"
#pragma bank=2
int bank2(int i) BANKED
{
int j;
puts(" In bank 2");
for (j=0; j<i; j++) {
bank3();
}
return 2;
}

View file

@ -0,0 +1,8 @@
#include "bank.h"
#pragma bank=3
void bank3(void) BANKED
{
puts(" In bank 3!");
}

View file

@ -0,0 +1,10 @@
#include "bank.h"
int main(void)
{
puts("Testing 1,2,3...");
puts("Calling bank2()");
bank2(3);
puts("Back to main()");
return 0;
}

View file

@ -1,17 +1,20 @@
/** Note that this example is a bit old. Try BANKED and NONBANKED
as in banked/
*/
#include <gb/gb.h>
#include <stdio.h>
UBYTE var_internal; /* In internal RAM */
extern UBYTE var_0; /* In external RAM bank 0 */
extern UBYTE var_1; /* In external RAM bank 1 */
extern UBYTE var_2; /* In external RAM bank 2 */
extern UBYTE var_3; /* In external RAM bank 3 */
int var_internal; /* In internal RAM */
extern int var_0; /* In external RAM bank 0 */
extern int var_1; /* In external RAM bank 1 */
extern int var_2; /* In external RAM bank 2 */
extern int var_3; /* In external RAM bank 3 */
void bank_1();
void bank_2();
void bank_3();
void bank_1() NONBANKED;
void bank_2() NONBANKED;
void bank_3() NONBANKED;
void bank_fixed()
void bank_fixed(void) NONBANKED
{
puts("I'm in fixed ROM");
}
@ -22,11 +25,13 @@ void print_var(UBYTE bank)
printf("Var_%u is %u\n");
}
void main()
void main(void)
{
puts("Program Start...");
ENABLE_RAM_MBC1;
SWITCH_4_32_MODE_MBC1;
var_internal = 1;
SWITCH_RAM_MBC1(0);
var_0 = 2;

View file

@ -1,10 +0,0 @@
/Makefile/1.1/Wed Feb 23 02:50:14 2000//
/bar_c.c/1.1/Wed Feb 23 02:50:14 2000//
/bar_c.gbr/1.1/Wed Feb 23 02:50:14 2000//
/bar_c.h/1.1/Wed Feb 23 02:50:14 2000//
/bar_m.c/1.1/Wed Feb 23 02:50:14 2000//
/bar_m.gbm/1.1/Wed Feb 23 02:50:14 2000//
/bar_m.h/1.1/Wed Feb 23 02:50:14 2000//
/colorbar.c/1.1/Wed Feb 23 02:50:14 2000//
/make.bat/1.1/Wed Feb 23 02:50:14 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/examples/gb/colorbar

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,21 +1,26 @@
CC = ../../bin/lcc -Wa-l -Wl-m
CC = ../../../bin/lcc -Wa-l -Wl-m
CFLAGS = -DGBDK_2_COMPAT
BINS = colorbar.gb
all: $(BINS)
%.o: %.c
$(CC) -c -o $@ $<
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.s
$(CC) -c -o $@ $<
$(CC) $(CFLAGS) -c -o $@ $<
%.s: %.c
$(CC) $(CFLAGS) -S -o $@ $<
%.gb: %.o
$(CC) -o $@ $<
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f *.o *.lst *.map *.gb
# Link file, and write 0x80 at position 0x143 in header
colorbar.gb: colorbar.o
$(CC) -Wl-yp0x143=0x80 -o colorbar.gb colorbar.o
$(CC) $(CFLAGS) -Wl-yp0x143=0x80 -o colorbar.gb colorbar.o

View file

@ -23,7 +23,7 @@
*/
/* CGBpalette entries. */
unsigned char bar_cCGB[] =
const unsigned char bar_cCGB[] =
{
0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
@ -31,7 +31,7 @@ unsigned char bar_cCGB[] =
0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07
};
/* Start of tile array. */
unsigned char bar_c[] =
const unsigned char bar_c[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View file

@ -19,7 +19,7 @@
#define bar_mWidth 20
#define bar_mHeight 18
unsigned char bar_m[] =
const unsigned char bar_m[] =
{
0x1F,0x1F,0x12,0x12,0x12,0x1B,0x1B,0x1B,0x08,0x08,
0x08,0x16,0x16,0x16,0x07,0x07,0x07,0x0C,0x0C,0x0C,

View file

@ -1,10 +1,10 @@
#include <gb.h>
#include <gb/gb.h>
#include "bar_c.h"
#include "bar_c.c"
#include "bar_m.c"
UWORD bar_p[] =
const UWORD bar_p[] =
{
bar_cCGBPal0c0,bar_cCGBPal0c1,bar_cCGBPal0c2,bar_cCGBPal0c3,
bar_cCGBPal1c0,bar_cCGBPal1c1,bar_cCGBPal1c2,bar_cCGBPal1c3,
@ -16,7 +16,7 @@ UWORD bar_p[] =
bar_cCGBPal7c0,bar_cCGBPal7c1,bar_cCGBPal7c2,bar_cCGBPal7c3
};
unsigned char bar_a[] =
const unsigned char bar_a[] =
{
7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
@ -38,7 +38,7 @@ unsigned char bar_a[] =
3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0
};
int main()
int main(void)
{
/* Transfer color palettes */
set_bkg_palette( 7, 1, &bar_p[0] );
@ -67,9 +67,5 @@ int main()
enable_interrupts();
DISPLAY_ON;
/* Loop forever */
while(1)
;
return(0);
return 0;
}

View file

@ -1,12 +1,12 @@
#include <gb/gb.h>
#include <stdio.h>
char *str = "Hello World!";
const char * str = "Hello World!";
char buffer[32];
void main()
void main(void)
{
UBYTE i, j, n = 0;
UBYTE i, n = 0;
char *s;
puts("Byte");

View file

@ -1,14 +0,0 @@
/Makefile/1.1/Wed Feb 23 02:50:14 2000//
/bkg.c/1.1/Wed Feb 23 02:50:14 2000//
/bkg.gbr/1.1/Wed Feb 23 02:50:14 2000//
/bkg.h/1.1/Wed Feb 23 02:50:14 2000//
/bkg_c.c/1.1/Wed Feb 23 02:50:14 2000//
/bkg_c.gbm/1.1/Wed Feb 23 02:50:14 2000//
/bkg_m.c/1.1/Wed Feb 23 02:50:14 2000//
/bkg_m.gbm/1.1/Wed Feb 23 02:50:14 2000//
/dscan.c/1.1/Wed Feb 23 02:50:14 2000//
/fore.c/1.1/Wed Feb 23 02:50:14 2000//
/fore.gbr/1.1/Wed Feb 23 02:50:14 2000//
/fore.h/1.1/Wed Feb 23 02:50:14 2000//
/make.bat/1.1/Wed Feb 23 02:50:14 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/examples/gb/dscan

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,4 +1,4 @@
CC = ../../bin/lcc -Wa-l -Wl-m
CC = ../../../bin/lcc -Wa-l -Wl-m
BINS = dscan.gb
@ -7,6 +7,9 @@ all: $(BINS)
%.o: %.c
$(CC) -c -o $@ $<
%.s: %.c
$(CC) -S -o $@ $<
%.o: %.s
$(CC) -c -o $@ $<

View file

@ -23,7 +23,7 @@
*/
/* CGBpalette entries. */
unsigned char bkgCGB[] =
const unsigned char bkgCGB[] =
{
0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,
0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04,
@ -39,7 +39,7 @@ unsigned char bkgCGB[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/* Start of tile array. */
unsigned char bkg[] =
const unsigned char bkg[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View file

@ -19,7 +19,7 @@
#define bkg_cWidth 20
#define bkg_cHeight 18
unsigned char bkg_c[] =
const unsigned char bkg_c[] =
{
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,

View file

@ -19,7 +19,7 @@
#define bkg_mWidth 20
#define bkg_mHeight 18
unsigned char bkg_m[] =
const unsigned char bkg_m[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

View file

@ -4,7 +4,7 @@
* Mr. N.U. of TeamKNOx *
********************************************************************/
#include <gb.h>
#include <gb/gb.h>
#include <stdlib.h>
#include <rand.h>
@ -18,7 +18,7 @@
/* ************************************************************ */
UWORD bkg_p[] =
const UWORD bkg_p[] =
{
bkgCGBPal0c0,bkgCGBPal0c1,bkgCGBPal0c2,bkgCGBPal0c3,
bkgCGBPal1c0,bkgCGBPal1c1,bkgCGBPal1c2,bkgCGBPal1c3,
@ -30,7 +30,7 @@ UWORD bkg_p[] =
bkgCGBPal7c0,bkgCGBPal7c1,bkgCGBPal7c2,bkgCGBPal7c3
};
UWORD obj_p[] =
const UWORD obj_p[] =
{
foreCGBPal0c0,foreCGBPal0c1,foreCGBPal0c2,foreCGBPal0c3,
foreCGBPal1c0,foreCGBPal1c1,foreCGBPal1c2,foreCGBPal1c3,
@ -97,25 +97,23 @@ UWORD obj_p[] =
unsigned char msg_tile[64];
unsigned char msg_1up[] = "1UP";
unsigned char msg_lv[] = "LV";
const unsigned char * const msg_1up = "1UP";
const unsigned char * const msg_lv = "LV";
unsigned char msg_gover[] = "GAMEOVER";
unsigned char msg_pause[] = " PAUSE! ";
unsigned char msg_start[] = " ";
const unsigned char * const msg_gover = "GAMEOVER";
const unsigned char * const msg_pause = " PAUSE! ";
const unsigned char * const msg_start = " ";
UBYTE pf, px, pp, pl;
UWORD pw;
UWORD ps;
UBYTE tf[MAX_TT], tx[MAX_TT], ty[MAX_TT];
UBYTE tf[MAX_TT];
UBYTE tx[MAX_TT], ty[MAX_TT];
UBYTE ef[MAX_ET], ex[MAX_ET], ey[MAX_ET];
UBYTE kf[MAX_KT], kx[MAX_KT], ky[MAX_KT];
UBYTE rnd_enemy, rnd_kirai;
UBYTE k_right, k_left;
/* Seed for the random number generator */
fixed seed;
void set_sprite_attrb( UBYTE nb, UBYTE tile )
{
if( _cpu==CGB_TYPE ) {
@ -315,23 +313,24 @@ void player()
{
UBYTE key;
UBYTE i;
UINT16 seed;
key = joypad();
/* pause */
if( key & J_START ) {
if( pf == DEF_PF ) {
/* Initialize the random number generator */
seed.b.l = DIV_REG;
seed = DIV_REG;
waitpadup();
seed.b.h = DIV_REG;
initarand(seed.w);
seed |= ((UINT16)DIV_REG << 8);
initarand(seed);
hide_msg();
init_score();
init_player();
init_tama();
init_enemy();
init_kirai();
delay( 500UL );
delay( 500 );
} else {
show_pause();
waitpadup();
@ -353,7 +352,7 @@ void player()
if(pw > 0)
pw--;
show_score( pw );
delay( 250UL );
delay( 250 );
}
show_score( ps );
} else if( key & J_RIGHT ) {
@ -361,7 +360,7 @@ void player()
if(pw < 99)
pw++;
show_score( pw );
delay( 250UL );
delay( 250 );
}
show_score( ps );
} else if( key & J_SELECT ) {
@ -373,7 +372,7 @@ void player()
}
waitpadup();
hide_msg();
delay( 500UL );
delay( 500 );
}
return;
}
@ -431,9 +430,9 @@ void player()
/* bombs */
void bombs()
{
UBYTE i;
UBYTE i;
for( i=0; i<MAX_TT; i++ ) {
for( i=0; i<MAX_TT; i++ ) {
if( tf[i] != 0 ) {
ty[i]++;
if( ty[i] > MAX_TY ) {
@ -726,7 +725,6 @@ void main()
disable_interrupts();
DISPLAY_OFF;
initarand(seed.w);
init_screen();
init_score();
init_player();

View file

@ -23,7 +23,7 @@
*/
/* CGBpalette entries. */
unsigned char foreCGB[] =
const unsigned char foreCGB[] =
{
0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x05,
0x05,0x05,0x01,0x01,0x01,0x01,0x01,0x01,
@ -43,7 +43,7 @@ unsigned char foreCGB[] =
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04
};
/* Start of tile array. */
unsigned char fore[] =
const unsigned char fore[] =
{
0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,
0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x00,0x00,

View file

@ -4,7 +4,7 @@
#include <gb/gb.h>
#include <gb/drawing.h>
void main()
void main(void)
{
UBYTE a,b,c,d,e;
c=0;

View file

@ -322,7 +322,7 @@ const unsigned char door4_tiles[] = {
};
/* Should really be const, but sdcc doesnt yet support it. */
unsigned char *film[] = {
const unsigned char * const film[] = {
&door1_tiles[0x0C*0],
&door2_tiles[0x0C*0],
&door3_tiles[0x0C*0],
@ -366,10 +366,10 @@ unsigned char *film[] = {
#define OPENED 0x02
#define CLOSING 0x03
UBYTE time; /* Global "time" value (counter) */
static UBYTE time; /* Global "time" value (counter) */
UBYTE doorstate; /* State of the door (OPENED, CLOSED...) */
UBYTE doorpos; /* Current position in the door animation */
UBYTE color; /* Current color for fading effect */
static UBYTE color; /* Current color for fading effect */
UBYTE sframe; /* Current frame of the sprite */
fixed bposx, bposy; /* Background position (fixed point) */
fixed bspx, bspy; /* Background speed (fixed point) */
@ -536,8 +536,8 @@ void main()
SCX_REG = 0;
bposy.w = 0;
SCY_REG = 0;
bspx.w = 0xFF00UL;
bspy.w = 0x0080UL;
bspx.w = 0xFF00;
bspy.w = 0x0080;
/* Initialize the window */
set_win_data(0x80, 0x21, frame_data);
@ -561,18 +561,18 @@ void main()
wposy.b.h = MAXWNDPOSY;
wposy.b.l = 0;
WY_REG = MAXWNDPOSY;
wspx.w = 0xFF80UL;
wspy.w = 0xFFC0UL;
wspx.w = 0xFF80;
wspy.w = 0xFFC0;
/* Initialize the sprite */
set_sprite_data(0x00, 0x1C, earth_data);
set_sprite_prop(0, 0x00);
set_sprite_prop(1, 0x00);
sframe = 0;
sposx.w = 0x1000U;
sposy.w = 0x1000U;
sspx.w = 0x0040UL;
sspy.w = 0x0040UL;
sposx.w = 0x1000;
sposy.w = 0x1000;
sspx.w = 0x0040;
sspy.w = 0x0040;
tile_sprite();
place_sprite();
@ -591,22 +591,22 @@ void main()
i = joypad();
if(i & J_B) {
if(i & J_UP)
bspy.w -= 0x0010UL;
bspy.w -= 0x0010;
if(i & J_DOWN)
bspy.w += 0x0010UL;
bspy.w += 0x0010;
if(i & J_LEFT)
bspx.w -= 0x0010UL;
bspx.w -= 0x0010;
if(i & J_RIGHT)
bspx.w += 0x0010UL;
bspx.w += 0x0010;
} else if(i & J_A) {
if(i & J_UP)
wspy.w -= 0x0010UL;
wspy.w -= 0x0010;
if(i & J_DOWN)
wspy.w += 0x0010UL;
wspy.w += 0x0010;
if(i & J_LEFT)
wspx.w -= 0x0010UL;
wspx.w -= 0x0010;
if(i & J_RIGHT)
wspx.w += 0x0010UL;
wspx.w += 0x0010;
} else {
if(i & J_SELECT)
color = STARTFADE;
@ -619,13 +619,13 @@ void main()
doorpos = NBDFRAMES;
}
if(i & J_UP)
sspy.w -= 0x0010UL;
sspy.w -= 0x0010;
if(i & J_DOWN)
sspy.w += 0x0010UL;
sspy.w += 0x0010;
if(i & J_LEFT)
sspx.w -= 0x0010UL;
sspx.w -= 0x0010;
if(i & J_RIGHT)
sspx.w += 0x0010UL;
sspx.w += 0x0010;
}
}
}

View file

@ -1,16 +0,0 @@
/Makefile/1.1/Wed Feb 23 02:50:14 2000//
/brk_btn.c/1.1/Wed Feb 23 02:50:14 2000//
/brk_btn.gbr/1.1/Wed Feb 23 02:50:14 2000//
/cursor.c/1.1/Wed Feb 23 02:50:14 2000//
/cursor.gbr/1.1/Wed Feb 23 02:50:14 2000//
/dtmf_lcd.c/1.1/Wed Feb 23 02:50:15 2000//
/dtmf_lcd.gbr/1.1/Wed Feb 23 02:50:15 2000//
/frm_lcd.c/1.1/Wed Feb 23 02:50:15 2000//
/frm_lcd.gbr/1.1/Wed Feb 23 02:50:15 2000//
/gb-dtmf.c/1.1/Wed Feb 23 02:50:15 2000//
/key_num.c/1.1/Wed Feb 23 02:50:15 2000//
/key_num.gbr/1.1/Wed Feb 23 02:50:15 2000//
/make.bat/1.1/Wed Feb 23 02:50:15 2000//
/prs_btn.c/1.1/Wed Feb 23 02:50:15 2000//
/prs_btn.gbr/1.1/Wed Feb 23 02:50:15 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/examples/gb/gb-dtmf

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,9 +1,12 @@
CC = ../../bin/lcc -Wa-l -Wl-m
CC = ../../../bin/lcc -Wa-l -Wl-m -DGBDK_2_COMPAT=1
BINS = gb-dtmf.gb
all: $(BINS)
%.s: %.c
$(CC) -S -o $@ $<
%.o: %.c
$(CC) -c -o $@ $<

View file

@ -16,7 +16,7 @@
*/
/* Start of tile array. */
unsigned char break_btn[] =
const unsigned char break_btn[] =
{
0x00,0x00,0x00,0x00,0x3F,0x00,0x3F,0x00,
0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,

View file

@ -16,7 +16,7 @@
*/
/* Start of tile array. */
unsigned char cursor_data[] =
const unsigned char cursor_data[] =
{
0x06,0x06,0x09,0x09,0x09,0x09,0x09,0x0F,
0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F,

View file

@ -16,7 +16,7 @@
*/
/* Start of tile array. */
unsigned char dtmf_lcd[] =
const unsigned char dtmf_lcd[] =
{
0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
0x63,0x63,0x63,0x63,0x63,0x63,0x00,0x00,

View file

@ -16,7 +16,7 @@
*/
/* Start of tile array. */
unsigned char frame_lcd[] =
const unsigned char frame_lcd[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
0x00,0x1F,0x00,0x18,0x00,0x18,0x00,0x18,

View file

@ -4,9 +4,10 @@
/* Osamu Ohashi */
/* ---------------------------------------- */
#include <gb.h>
#include <gb/gb.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* BG data */
#include "frm_lcd.c" /* Back ground pattern */
@ -84,11 +85,11 @@
#define R3 0x66U /* 852Hz, 851Hz */
#define R4 0x75U /* 941Hz, 942Hz */
unsigned char row[4] = {R1,R2,R3,R4}; /* DTMF frequency strage of Row */
unsigned char col[4] = {C1,C2,C3,C4}; /* DTMF frequency strage of Col */
const unsigned char row[4] = {R1,R2,R3,R4}; /* DTMF frequency strage of Row */
const unsigned char col[4] = {C1,C2,C3,C4}; /* DTMF frequency strage of Col */
/* It is possible to set up initial screen by each BG data. */
unsigned char dtmf_tile[] = {
const unsigned char dtmf_tile[] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
@ -120,26 +121,26 @@ unsigned char dtmf_tile[] = {
Normal buttons are created by 3tiles x 3tiles(24pixels x 24pixels)
Dialing button is created by 6tiles x 3tiles(48pixels x 24pixels)
*/
unsigned char break_tile[] = {
const unsigned char break_tile[] = {
9,10,11,
12,13,14,
15,16,17
};
unsigned char dialing_break[] = {
const unsigned char dialing_break[] = {
9,10,10,10,10,11,
12,13,13,13,13,14,
15,16,16,16,16,17
};
unsigned char press_tile[] = {
const unsigned char press_tile[] = {
18,19,20,
21,22,23,
24,25,26
};
unsigned char dialing_press[] = {
const unsigned char dialing_press[] = {
18,19,19,19,19,20,
21,22,22,22,22,23,
24,25,25,25,25,26
@ -148,12 +149,12 @@ unsigned char dialing_press[] = {
/*
LCD image at initial & AC
*/
unsigned char init_disp[] = {
const unsigned char init_disp[] = {
59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,
60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60
};
char pad[4][6] = { /* DTMF Pad assign */
const char pad[4][6] = { /* DTMF Pad assign */
{'1','2','3','A','%','P'},
{'4','5','6','B','-','F'},
{'7','8','9','C',',','?'},
@ -373,7 +374,7 @@ void clr_disp()
/*
CAUTION: Don't display the NULL code
*/
void disp(char str[MAX_DTMF])
void disp(const char *str)
{
UBYTE no, left_pos;
UBYTE i, start_ch, end_ch;
@ -541,6 +542,9 @@ void main()
char str[MAX_DTMF];
char str_ms[10];
/* PENDING: sdcc is broken and needs this to be initalised. */
key2 = 0;
/* default dialling time setting */
on_time = DTMF_ON;
off_time = DTMF_OFF;
@ -568,7 +572,7 @@ void main()
i = j = 0;
ch_pos = 0;
while(1) {
wait_vbl_done();
key1 = joypad();
@ -603,7 +607,7 @@ void main()
/* decremental button */
/* appear the delay during press A button */
if(i == 5 && (j == 1 || j == 2) && !non_flick){
sprintf(str_ms, "%lu MS", on_time);
sprintf(str_ms, "%u MS", on_time);
disp(str_ms);
non_flick = ON;
}
@ -695,7 +699,6 @@ void main()
}
}
}
if(!(key1 & J_A)){
if((key1 & J_UP) && !(key2 & J_UP) && j > 0)
j--;

View file

@ -16,7 +16,7 @@
*/
/* Start of tile array. */
unsigned char key_num[] =
const unsigned char key_num[] =
{
0xFF,0x3C,0xFF,0x7E,0xFF,0x66,0xFF,0x66,
0xFF,0x66,0xFF,0x66,0xFF,0x7E,0xFF,0x3C,

View file

@ -16,7 +16,7 @@
*/
/* Start of tile array. */
unsigned char press_btn[] =
const unsigned char press_btn[] =
{
0x00,0xFF,0x00,0xFF,0x3F,0xC0,0x3F,0xC0,
0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,

View file

@ -26,7 +26,7 @@ void print_counter()
cnt = tim_cnt;
enable_interrupts();
printf(" TIM %u", cnt);
printf(" TIM %u", (unsigned int)cnt);
gotoxy(9, posy());
/* Ensure mutual exclusion (not really necessary in this example)... */
@ -34,7 +34,7 @@ void print_counter()
cnt = vbl_cnt;
enable_interrupts();
printf("- VBL %u\n", cnt);
printf("- VBL %u\n", (unsigned int)cnt);
}
void main()

View file

@ -4,25 +4,30 @@
UWORD counter;
void inc()
void inc(void)
{
counter++;
}
void print_counter()
void print_counter(void)
{
printf(" Counter is %u\n", counter);
printf(" Counter is %u\n", counter);
}
void main()
typedef void (*FUNPTR)(void);
void main(void)
{
extern UBYTE __inc_end, __inc_start;
/* Declare extern functions */
void inc_ram();
void inc_hiram();
void inc_ram() NONBANKED;
void inc_hiram() NONBANKED;
/* Declare pointer-to-function variables */
void (*inc_ram_var)(void) = 0xD000;
void (*inc_hiram_var)(void) = 0xFFA0;
/* With sdcc 2.3.1, you cannot cast a constant to a function pointer
without going through a typedef.
*/
FUNPTR inc_ram_var = (FUNPTR)0xD000;
FUNPTR inc_hiram_var = (FUNPTR)0xFFA0;
puts("Program Start...");
counter = 0;

View file

@ -18,29 +18,21 @@
UBYTE accu[80];
UBYTE accua[80];
UWORD seed;
volatile UBYTE div_reg;
void main(void)
{
UBYTE r, s, t, u;
for(r = 0; r != 80; r++) {
accu[r] = 0;
accua[r] = 0;
}
UBYTE r, s, t = 0, u = 0;
UWORD seed;
/* 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;
seed = DIV_REG;
puts("Push any key (2)");
waitpad(0xFF);
waitpadup();
seed |= (UWORD)div_reg << 8;
seed |= (UWORD)DIV_REG << 8;
/* initarand() calls initrand() */
initarand(seed);

View file

@ -20,7 +20,7 @@ void push(WORD l)
puts("Stack full");
}
WORD pop()
WORD pop(void)
{
if(sp > 0)
return stack[--sp];
@ -29,7 +29,7 @@ WORD pop()
return 0;
}
WORD top()
WORD top(void)
{
if(sp > 0)
return stack[sp-1];
@ -38,7 +38,7 @@ WORD top()
return 0;
}
BYTE read_op()
BYTE read_op(void)
{
if(pos == 0) {
gets(s);
@ -62,7 +62,7 @@ BYTE read_op()
return NUMBER;
}
void main()
void main(void)
{
BYTE type;
WORD op2;
@ -71,7 +71,7 @@ void main()
sp = 0;
pos = 0;
while((type = read_op(s)) != 0) {
while((type = read_op()) != 0) {
switch(type) {
case NUMBER:
push(n);

View file

@ -1,3 +0,0 @@
/stress.c/1.1/Wed Feb 23 02:50:15 2000//
/test-memset.c/1.1/Wed Feb 23 02:50:15 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/examples/gb/tests

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,9 +0,0 @@
/ctype.h/1.1/Wed Feb 23 02:45:17 2000//
/gbdk-lib.h/1.1/Mon Feb 21 02:04:36 2000//
/rand.h/1.1/Tue Feb 22 04:12:15 2000//
/stdarg.h/1.1/Mon Feb 21 02:04:36 2000//
/stdio.h/1.3/Wed Feb 23 02:45:17 2000//
/string.h/1.2/Mon Feb 21 02:01:59 2000//
/time.h/1.2/Tue Feb 22 04:05:50 2000//
/types.h/1.1/Mon Feb 21 02:04:36 2000//
D

View file

@ -1,3 +0,0 @@
A D/asm////
A D/consolez80////
A D/gb////

View file

@ -1 +0,0 @@
gbdk-lib/include

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

14
gbdk-lib/include/Makefile Normal file
View file

@ -0,0 +1,14 @@
VER = 2.94
doc:
mkdir -p ../doc
doxygen libc.dox
make -C ../doc/libc/latex pdf
dist:
mkdir -p ../build/doc
cd ../doc/libc; tar czf ../../build/doc/gbdk-doc-html-$(VER).tar.gz html
cp ../doc/libc/latex/refman.pdf ../build/doc/gbdk-doc-$(VER).pdf
gzip ../build/doc/gbdk-doc-$(VER).pdf
(cd ../doc/libc; tar cf - html) | (cd ../build/doc; tar xf -)

View file

@ -1,2 +0,0 @@
/types.h/1.2/Tue Feb 22 04:05:50 2000//
D

View file

@ -1,2 +0,0 @@
A D/gbz80////
A D/z80////

View file

@ -1 +0,0 @@
gbdk-lib/include/asm

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,4 +0,0 @@
/provides.h/1.1/Mon Feb 21 02:04:36 2000//
/stdarg.h/1.3/Wed Feb 23 02:45:18 2000//
/types.h/1.3/Mon Feb 21 19:12:00 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/include/asm/gbz80

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,3 +1,4 @@
#undef USE_C_MEMCPY
#undef USE_C_STRCPY
#undef USE_C_STRCMP
#define USE_C_MEMCPY 1
#define USE_C_STRCPY 1
#define USE_C_STRCMP 1

View file

@ -9,9 +9,9 @@
the correct order.
*/
typedef char * va_list;
#define va_start(list, last) list = (char *)&last + sizeof(last)
#define va_arg(list, type) *(type *)list; list + sizeof(type)
typedef unsigned char * va_list;
#define va_start(list, last) list = (unsigned char *)&last + sizeof(last)
#define va_arg(list, type) *((type *)((list += sizeof(type)) - sizeof(type)))
#define va_end(list)

View file

@ -1,3 +1,6 @@
/** @file asm/gbz80/types.h
Types definitions for the gb.
*/
#ifndef ASM_GBZ80_TYPES_INCLUDE
#define ASM_GBZ80_TYPES_INCLUDE
@ -5,14 +8,33 @@
#error gbz80 only.
#endif
#define NONBANKED nonbanked
#define BANKED banked
/** Signed eight bit.
*/
typedef char INT8;
/** Unsigned eight bit.
*/
typedef unsigned char UINT8;
/** Signed sixteen bit.
*/
typedef int INT16;
/** Unsigned sixteen bit.
*/
typedef unsigned int UINT16;
/** Signed 32 bit.
*/
typedef long INT32;
/** Unsigned 32 bit.
*/
typedef unsigned long UINT32;
typedef int size_t;
/** Returned from clock
@see clock
*/
typedef UINT16 clock_t;
#endif

View file

@ -1,28 +1,57 @@
/** @file asm/types.h
Shared types definitions.
*/
#ifndef ASM_TYPES_INCLUDE
#define ASM_TYPES_INCLUDE
#if SDCC_PORT==gbz80
#if SDCC_PORT == gbz80
#include <asm/gbz80/types.h>
#elif SDCC_PORT==z80
#elif SDCC_PORT == z80
#include <asm/z80/types.h>
#else
#error Unrecognised port
#endif
#if GBDK_2_COMPAT
#warning This code uses the depreciated GBDK 2.0/1.0 compatible WORD/BYTE defs.
#ifndef NONBANKED
#define NONBANKED
#endif
typedef INT8 BYTE;
typedef UINT8 UBYTE;
typedef INT16 WORD;
typedef UINT16 UWORD;
typedef INT32 LWORD;
typedef UINT32 ULWORD;
typedef INT32 DWORD;
typedef UINT32 UDWORD;
#ifndef BANKED
#define BANKED
#endif
/* Useful definition for fixed point values */
/** TRUE or FALSE.
*/
typedef INT8 BOOLEAN;
#if BYTE_IS_UNSIGNED
typedef UINT8 BYTE;
typedef UINT16 WORD;
typedef UINT32 DWORD;
#else
/** Signed 8 bit.
*/
typedef INT8 BYTE;
/** Unsigned 8 bit.
*/
typedef UINT8 UBYTE;
/** Signed 16 bit */
typedef INT16 WORD;
/** Unsigned 16 bit */
typedef UINT16 UWORD;
/** Signed 32 bit */
typedef INT32 LWORD;
/** Unsigned 32 bit */
typedef UINT32 ULWORD;
/** Signed 32 bit */
typedef INT32 DWORD;
/** Unsigned 32 bit */
typedef UINT32 UDWORD;
/** Useful definition for fixed point values */
typedef union _fixed {
struct {
UBYTE l;
@ -31,12 +60,6 @@ typedef union _fixed {
UWORD w;
} fixed;
#else
typedef UINT8 BYTE;
typedef UINT16 WORD;
typedef UINT32 DWORD;
#endif
#endif

View file

@ -1,4 +0,0 @@
/provides.h/1.1/Mon Feb 21 02:04:36 2000//
/stdarg.h/1.2/Wed Feb 23 02:45:18 2000//
/types.h/1.3/Mon Feb 21 19:12:00 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/include/asm/z80

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,2 +0,0 @@
/README/1.1.1.1/Mon Feb 21 00:46:01 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/include/consolez80

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,27 +1,30 @@
/** @file ctype.h
Character type functions.
*/
#ifndef _CTYPE_H
#define _CTYPE_H
#include <types.h>
BYTE
BOOLEAN
isalpha(char c);
BYTE
BOOLEAN
isupper(char c);
BYTE
BOOLEAN
islower(char c);
BYTE
BOOLEAN
isdigit(char c);
BYTE
BOOLEAN
isspace(char c);
BYTE
char
toupper(char c);
BYTE
char
tolower(char c);
#endif /* _CTYPE_H */

View file

@ -1,9 +0,0 @@
/cgb.h/1.1/Tue Feb 22 04:11:49 2000//
/console.h/1.1/Tue Feb 22 04:11:49 2000//
/drawing.h/1.1/Tue Feb 22 04:11:49 2000//
/font.h/1.1/Tue Feb 22 04:11:49 2000//
/gb.h/1.2/Tue Feb 22 04:05:50 2000//
/hardware.h/1.1/Tue Feb 22 04:11:49 2000//
/sample.h/1.1/Tue Feb 22 04:11:49 2000//
/sgb.h/1.1/Tue Feb 22 04:11:49 2000//
D

View file

@ -1 +0,0 @@
gbdk-lib/include/gb

View file

@ -1 +0,0 @@
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk

View file

@ -1,18 +1,16 @@
/*
* Support for Color GameBoy.
*/
/** @file gb/cgb.h
Support for Color GameBoy.
*/
#ifndef _CGB_H
#define _CGB_H
/*
* Macro to create a palette entry out of the color components.
/** Macro to create a palette entry out of the color components.
*/
#define RGB(r, g, b) \
((((UWORD)(b) & 0x1f) << 10) | (((UWORD)(g) & 0x1f) << 5) | (((UWORD)(r) & 0x1f) << 0))
((((UINT16)(b) & 0x1f) << 10) | (((UINT16)(g) & 0x1f) << 5) | (((UINT16)(r) & 0x1f) << 0))
/*
* Common colors based on the EGA default palette.
/** Common colors based on the EGA default palette.
*/
#define RGB_RED RGB(31, 0, 0)
#define RGB_DARKRED RGB(15, 0, 0)
@ -36,54 +34,49 @@
#define RGB_ORANGE RGB(30, 20, 0)
#define RGB_TEAL RGB(15, 15, 0)
/*
* Set bkg palette(s).
/** Set bkg palette(s).
*/
void
set_bkg_palette(UBYTE first_palette,
UBYTE nb_palettes,
UWORD *rgb_data);
set_bkg_palette(UINT8 first_palette,
UINT8 nb_palettes,
UINT16 *rgb_data) NONBANKED;
/*
* Set sprite palette(s).
/** Set sprite palette(s).
*/
void
set_sprite_palette(UBYTE first_palette,
UBYTE nb_palettes,
UWORD *rgb_data);
set_sprite_palette(UINT8 first_palette,
UINT8 nb_palettes,
UINT16 *rgb_data) NONBANKED;
/*
* Set a bkg palette entry.
/** Set a bkg palette entry.
*/
void
set_bkg_palette_entry(UBYTE palette,
UBYTE entry,
UWORD rgb_data);
set_bkg_palette_entry(UINT8 palette,
UINT8 entry,
UINT16 rgb_data);
/*
* Set a sprite palette entry.
/** Set a sprite palette entry.
*/
void
set_sprite_palette_entry(UBYTE palette,
UBYTE entry,
UWORD rgb_data);
set_sprite_palette_entry(UINT8 palette,
UINT8 entry,
UINT16 rgb_data);
/*
* Set CPU speed to slow operation.
* (Make sure interrupts are disabled before call!)
/** Set CPU speed to slow operation.
Make sure interrupts are disabled before call.
@see cpu_fast
*/
void cpu_slow(void);
/*
* Set CPU speed to fast operation.
* (Make sure interrupts are disabled before call!)
*/
/** Set CPU speed to fast operation.
Make sure interrupts are disabled before call.
@see cpu_slow
*/
void cpu_fast(void);
/*
* Set defaults compatible with normal GameBoy.
/** Set defaults compatible with normal GameBoy.
*/
void cgb_compatibility(void);

View file

@ -1,18 +1,32 @@
/** @file gb/console.h
Console functions that work like Turbo C's.
Note that the font is 8x8, making the screen 20x18 characters.
*/
#ifndef _CONSOLE_H
#define _CONSOLE_H
#include <types.h>
/** Move the cursor to an absolute position.
*/
void
gotoxy(UBYTE x,
UBYTE y);
gotoxy(UINT8 x,
UINT8 y);
UBYTE
/** Get the current X position of the cursor.
*/
UINT8
posx(void);
UBYTE
/** Get the current Y position of the cursor.
*/
UINT8
posy(void);
/** Writes out a single character at the current cursor
position.
Does not update the cursor or interpret the character.
*/
void
setchar(char c);

View file

@ -1,6 +1,4 @@
/*
drawing.h
/** @file gb/drawing.h
All Points Addressable (APA) mode drawing library.
Drawing routines originally by Pascal Felber
@ -13,11 +11,11 @@
#ifndef __DRAWING_H
#define __DRAWING_H
/* Size of the screen in pixels */
/** Size of the screen in pixels */
#define GRAPHICS_WIDTH 160
#define GRAPHICS_HEIGHT 144
/* Possible drawing modes */
/** Possible drawing modes */
#if ORIGINAL
#define SOLID 0x10 /* Overwrites the existing pixels */
#define OR 0x20 /* Performs a logical OR */
@ -30,86 +28,85 @@
#define AND 0x03 /* Performs a logical AND */
#endif
/* Possible drawing colours */
/** Possible drawing colours */
#define WHITE 0
#define LTGREY 1
#define DKGREY 2
#define BLACK 3
/* Possible fill styles for box() and circle() */
/** Possible fill styles for box() and circle() */
#define M_NOFILL 0
#define M_FILL 1
/* Possible values for signed_value in gprintln() and gprintn() */
/** Possible values for signed_value in gprintln() and gprintn() */
#define SIGNED 1
#define UNSIGNED 0
#include <types.h>
/* Note: all
/* Print the string 'str' with no interpretation */
/** Print the string 'str' with no interpretation */
void
gprint(char *str);
gprint(char *str) NONBANKED;
/* Print the long number 'number' in radix 'radix'. signed_value should
/** Print the long number 'number' in radix 'radix'. signed_value should
be set to SIGNED or UNSIGNED depending on whether the number is signed
or not */
void
gprintln(WORD number, BYTE radix, BYTE signed_value);
gprintln(INT16 number, INT8 radix, INT8 signed_value);
/* Print the number 'number' as in 'gprintln' */
/** Print the number 'number' as in 'gprintln' */
void
gprintn(BYTE number, BYTE radix, BYTE signed_value);
gprintn(INT8 number, INT8 radix, INT8 signed_value);
/* Print the formatted string 'fmt' with arguments '...' */
BYTE
gprintf(char *fmt,...);
/** Print the formatted string 'fmt' with arguments '...' */
INT8
gprintf(char *fmt,...) NONBANKED;
/* Old style plot - try plot_point() */
/** Old style plot - try plot_point() */
void
plot(UBYTE x, UBYTE y, UBYTE colour, UBYTE mode);
plot(UINT8 x, UINT8 y, UINT8 colour, UINT8 mode);
/* Plot a point in the current drawing mode and colour at (x,y) */
/** Plot a point in the current drawing mode and colour at (x,y) */
void
plot_point(UBYTE x, UBYTE y);
plot_point(UINT8 x, UINT8 y);
/* I (MLH) have no idea what switch_data does... */
/** I (MLH) have no idea what switch_data does... */
void
switch_data(UBYTE x, UBYTE y, unsigned char *src, unsigned char *dst);
switch_data(UINT8 x, UINT8 y, unsigned char *src, unsigned char *dst) NONBANKED;
/* Ditto */
/** Ditto */
void
draw_image(unsigned char *data);
draw_image(unsigned char *data) NONBANKED;
/* Draw a line in the current drawing mode and colour from (x1,y1) to (x2,y2) */
/** Draw a line in the current drawing mode and colour from (x1,y1) to (x2,y2) */
void
line(UBYTE x1, UBYTE y1, UBYTE x2, UBYTE y2);
line(UINT8 x1, UINT8 y1, UINT8 x2, UINT8 y2);
/* Draw a box (rectangle) with corners (x1,y1) and (x2,y2) using fill mode
/** Draw a box (rectangle) with corners (x1,y1) and (x2,y2) using fill mode
'style' (one of NOFILL or FILL */
void
box(UBYTE x1, UBYTE y1, UBYTE x2, UBYTE y2, UBYTE style);
box(UINT8 x1, UINT8 y1, UINT8 x2, UINT8 y2, UINT8 style);
/* Draw a circle with centre at (x,y) and radius 'radius'. 'style' sets
/** Draw a circle with centre at (x,y) and radius 'radius'. 'style' sets
the fill mode */
void
circle(UBYTE x, UBYTE y, UBYTE radius, UBYTE style);
circle(UINT8 x, UINT8 y, UINT8 radius, UINT8 style);
/* Returns the current colour of the pixel at (x,y) */
UBYTE
getpix(UBYTE x, UBYTE y);
/** Returns the current colour of the pixel at (x,y) */
UINT8
getpix(UINT8 x, UINT8 y);
/* Prints the character 'chr' in the default font at the current position */
/** Prints the character 'chr' in the default font at the current position */
void
wrtchr(char chr);
/* Sets the current text position to (x,y). Note that x and y have units
/** Sets the current text position to (x,y). Note that x and y have units
of cells (8 pixels) */
void
gotogxy(UBYTE x, UBYTE y);
gotogxy(UINT8 x, UINT8 y);
/* Set the current foreground colour (for pixels), background colour, and
/** Set the current foreground colour (for pixels), background colour, and
draw mode */
void color(UBYTE forecolor, UBYTE backcolor, UBYTE mode);
void color(UINT8 forecolor, UINT8 backcolor, UINT8 mode);
#endif /* __DRAWING_H */

View file

@ -1,14 +1,15 @@
/* font.h
Multiple font support for the GameBoy
Michael Hope, 1999
michaelh@earthling.net
Distrubuted under the Artistic License - see www.opensource.org
/** @file gb/font.h
Multiple font support for the GameBoy
Michael Hope, 1999
michaelh@earthling.net
*/
#ifndef __FONT_H
#define __FONT_H
#include <gb/gb.h>
/** Various flags in the font header.
*/
#define FONT_256ENCODING 0
#define FONT_128ENCODING 1
#define FONT_NOENCODING 2
@ -17,38 +18,41 @@
/* See gb.h/M_NO_SCROLL and gb.h/M_NO_INTERP */
/* font_t is a handle to a font loaded by font_load() */
typedef UWORD font_t;
/** font_t is a handle to a font loaded by font_load() */
typedef UINT16 font_t;
/* The default fonts */
extern UBYTE font_spect[], font_italic[], font_ibm[], font_min[];
/** The default fonts */
extern UINT8 font_spect[], font_italic[], font_ibm[], font_min[];
/* Backwards compatible font */
extern UBYTE fontibm_fixed[];
/** Backwards compatible font */
extern UINT8 font_ibm_fixed[];
/* Init the font system */
void font_init(void);
/** Init the font system.
Should be called first.
*/
void font_init(void) NONBANKED;
/* Load the font 'font' */
font_t font_load( void *font );
/** Load the font 'font'.
Sets the current font to the newly loaded font.
*/
font_t font_load( void *font ) NONBANKED;
/* Set the current font to 'font_handle', which was returned from an earlier
font_load(). Returns the previously used font handle.
/** Set the current font to 'font_handle', which was returned
from an earlier font_load().
@return The previously used font handle.
*/
font_t font_set( font_t font_handle );
/* Print the same character 'show' 'num' times */
void print_repeat(char show, UBYTE num);
font_t font_set( font_t font_handle ) NONBANKED;
/* Use mode() and color() to set the font modes and colours */
/* Internal representation of a font. What a font_t really is */
/** Internal representation of a font.
What a font_t really is */
typedef struct sfont_handle mfont_handle;
typedef struct sfont_handle *pmfont_handle;
struct sfont_handle {
UBYTE first_tile; /* First tile used */
UINT8 first_tile; /* First tile used */
void *font; /* Pointer to the base of the font */
};
#endif /* __FONT_H */

View file

@ -0,0 +1,4 @@
PROJECT_NAME = "gbdk"
OUTPUT_DIRECTORY = "html"
INPUT = gb.h cgb.h console.h drawing.h font.h hardware.h \
malloc.h sample.h sgb.h

View file

@ -1,3 +1,6 @@
/** @file gb/gb.h
Gameboy specific functions.
*/
#ifndef _GB_H
#define _GB_H
@ -6,8 +9,19 @@
#include <gb/sgb.h>
#include <gb/cgb.h>
/* Joypad bits */
/** Joypad bits.
A logical OR of these is used in the wait_pad and joypad
functions. For example, to see if the B button is pressed
try
UINT8 keys;
keys = joypad();
if (keys & J_B) {
...
}
@see joypad
*/
#define J_START 0x80U
#define J_SELECT 0x40U
#define J_B 0x20U
@ -17,35 +31,59 @@
#define J_LEFT 0x02U
#define J_RIGHT 0x01U
/* Modes */
/** Screen modes.
Normally used by internal functions only.
*/
#define M_DRAWING 0x01U
#define M_TEXT_OUT 0x02U
#define M_TEXT_INOUT 0x03U
/* Set this in addition to the others to disable scrolling
If scrolling is disabled, the cursor returns to (0,0) */
/** Set this in addition to the others to disable scrolling
If scrolling is disabled, the cursor returns to (0,0) */
#define M_NO_SCROLL 0x04U
/* Set this to disable \n interpretation */
/** Set this to disable \n interpretation */
#define M_NO_INTERP 0x08U
/* Sprite properties bits */
/** If this is set, sprite colours come from OBJ1PAL. Else
they come from OBJ0PAL.
*/
#define S_PALETTE 0x10U
/** If set the sprite will be flipped horizontally.
*/
#define S_FLIPX 0x20U
/** If set the sprite will be flipped vertically.
*/
#define S_FLIPY 0x40U
/** If this bit is clear, then the sprite will be displayed
ontop of the background and window.
*/
#define S_PRIORITY 0x80U
/* Interrupt flags */
/** Vertical blank interrupt.
Occurs at the start of the vertical blank. During this
period the video ram may be freely accessed.
*/
#define VBL_IFLAG 0x01U
/** Interrupt when triggered by the STAT register.
See the Pan doc.
*/
#define LCD_IFLAG 0x02U
/** Interrupt when the timer TIMA overflows.
*/
#define TIM_IFLAG 0x04U
/** Occurs when the serial transfer has completed.
*/
#define SIO_IFLAG 0x08U
/** Occurs on a transition of the keypad.
*/
#define JOY_IFLAG 0x10U
/* Limits */
/** Width of the visible screen in pixels.
*/
#define SCREENWIDTH 0xA0U
/** Height of the visible screen in pixels.
*/
#define SCREENHEIGHT 0x90U
#define MINWNDPOSX 0x07U
#define MINWNDPOSY 0x00U
@ -54,70 +92,160 @@
/* ************************************************************ */
/*
* Interrupt handlers
/** Interrupt handlers
*/
typedef void (*int_handler)(void);
typedef void (*int_handler)(void) NONBANKED;
/** The remove functions will remove any interrupt
handler. A handler of NULL will cause bad things
to happen.
*/
void
remove_VBL(int_handler h) NONBANKED;
void
add_VBL(int_handler h);
remove_LCD(int_handler h) NONBANKED;
void
add_LCD(int_handler h);
remove_TIM(int_handler h) NONBANKED;
void
add_TIM(int_handler h);
remove_SIO(int_handler h) NONBANKED;
void
add_SIO(int_handler h);
remove_JOY(int_handler h) NONBANKED;
/** Adds a V-blank interrupt handler.
The handler 'h' will be called whenever a V-blank
interrupt occurs. Up to 4 handlers may be added,
with the last added being called last. If the remove_VBL
function is to be called, only three may be added.
@see remove_VBL
*/
void
add_JOY(int_handler h);
add_VBL(int_handler h) NONBANKED;
/** Adds a LCD interrupt handler.
Called when the LCD interrupt occurs, which is normally
when LY_REG == LYC_REG.
From pan/k0Pa:
There are various reasons for this interrupt to occur
as described by the STAT register ($FF40). One very
popular reason is to indicate to the user when the
video hardware is about to redraw a given LCD line.
This can be useful for dynamically controlling the SCX/
SCY registers ($FF43/$FF42) to perform special video
effects.
@see add_VBL
*/
void
add_LCD(int_handler h) NONBANKED;
/** Adds a timer interrupt handler.
From pan/k0Pa:
This interrupt occurs when the TIMA register ($FF05)
changes from $FF to $00.
@see add_VBL
*/
void
add_TIM(int_handler h) NONBANKED;
/** Adds a serial transmit complete interrupt handler.
From pan/k0Pa:
This interrupt occurs when a serial transfer has
completed on the game link port.
@see send_byte, receive_byte, add_VBL
*/
void
add_SIO(int_handler h) NONBANKED;
/** Adds a pad tranisition interrupt handler.
From pan/k0Pa:
This interrupt occurs on a transition of any of the
keypad input lines from high to low. Due to the fact
that keypad "bounce" is virtually always present,
software should expect this interrupt to occur one
or more times for every button press and one or more
times for every button release.
@see joypad
*/
void
add_JOY(int_handler h) NONBANKED;
/* ************************************************************ */
/* Set the current mode - one of M_* defined above */
/** Set the current mode - one of M_* defined above */
void
mode(UBYTE m);
mode(UINT8 m) NONBANKED;
/* Returns the current mode */
UBYTE
get_mode(void);
/** Returns the current mode */
UINT8
get_mode(void) NONBANKED;
/* GB type (GB, PGB, CGB) */
extern UBYTE _cpu;
/** GB type (GB, PGB, CGB) */
extern UINT8 _cpu;
#define DMG_TYPE 0x01 /* Original GB or Super GB */
#define MGB_TYPE 0xFF /* Pocket GB or Super GB 2 */
#define CGB_TYPE 0x11 /* Color GB */
/** Original GB or Super GB */
#define DMG_TYPE 0x01
/** Pocket GB or Super GB 2 */
#define MGB_TYPE 0xFF
/** Color GB */
#define CGB_TYPE 0x11
extern UWORD sys_time; /* Time in VBL periods (60Hz) */
/** Time in VBL periods (60Hz) */
extern UINT16 sys_time;
/* ************************************************************ */
/** Send byte in _io_out to the serial port */
void
send_byte(void);
/* Send byte in _io_out to the serial port */
/** Receive byte from the serial port in _io_in */
void
receive_byte(void);
/* Receive byte from the serial port in _io_in */
extern UBYTE _io_status;
extern UBYTE _io_in;
extern UBYTE _io_out;
/** An OR of IO_* */
extern UINT8 _io_status;
/** Byte just read. */
extern UINT8 _io_in;
/** Write the byte to send here before calling send_byte()
@see send_byte
*/
extern UINT8 _io_out;
/* Status codes */
#define IO_IDLE 0x00U /* IO is completed */
#define IO_SENDING 0x01U /* Sending data */
#define IO_RECEIVING 0x02U /* Receiving data */
#define IO_ERROR 0x04U /* Error */
/** IO is completed */
#define IO_IDLE 0x00U
/** Sending data */
#define IO_SENDING 0x01U
/** Receiving data */
#define IO_RECEIVING 0x02U
/** Error */
#define IO_ERROR 0x04U
/* ************************************************************ */
/* Multiple banks */
/* MBC1 */
/** Switches the upper 16k bank of the 32k rom to bank rombank
using the MBC1 controller.
By default the upper 16k bank is 1. Make sure the rom you compile
has more than just bank 0 and bank 1, a 32k rom. This is done by
feeding lcc.exe the following switches:
-Wl-yt# where # is the type of cartridge. 1 for ROM+MBC1.
-Wl-yo# where # is the number of rom banks. 2,4,8,16,32.
*/
#define SWITCH_ROM_MBC1(b) \
*(unsigned char *)0x2000 = (b)
@ -130,13 +258,19 @@ extern UBYTE _io_out;
#define DISABLE_RAM_MBC1 \
*(unsigned char *)0x0000 = 0x00
#define SWITCH_16_8_MODE_MBC1 \
*(unsigned char *)0x6000 = 0x00
#define SWITCH_4_32_MODE_MBC1 \
*(unsigned char *)0x6000 = 0x01
/* Note the order used here. Writing the other way around
* on a MBC1 always selects bank 0 (d'oh)
*/
/* MBC5 */
/** MBC5 */
#define SWITCH_ROM_MBC5(b) \
*(unsigned char *)0x3000 = (b)>>8; \
*(unsigned char *)0x2000 = (b)&0xFF
*(unsigned char *)0x3000 = (UINT16)(b)>>8; \
*(unsigned char *)0x2000 = (UINT8)(b)
#define SWITCH_RAM_MBC5(b) \
*(unsigned char *)0x4000 = (b)
@ -149,199 +283,401 @@ extern UBYTE _io_out;
/* ************************************************************ */
/** Delays the given number of milliseconds.
Uses no timers or interrupts, and can be called with
interrupts disabled (why nobody knows :)
*/
void
delay(UWORD d);
delay(UINT16 d) NONBANKED;
/* ************************************************************ */
UBYTE
joypad(void);
/** Reads and returns the current state of the joypad.
Follows Nintendo's guidelines for reading the pad.
Return value is an OR of J_*
@see J_START
*/
UINT8
joypad(void) NONBANKED;
UBYTE
waitpad(UBYTE mask);
/** Waits until all the keys given in mask are pressed.
Normally only used for checking one key, but it will
support many, even J_LEFT at the same time as J_RIGHT :)
@see joypad, J_START
*/
UINT8
waitpad(UINT8 mask) NONBANKED;
/** Waits for the pad and all buttons to be released.
*/
void
waitpadup(void);
waitpadup(void) NONBANKED;
/* ************************************************************ */
/** Enables unmasked interrupts
@see disable_interrupts
*/
void
enable_interrupts(void);
enable_interrupts(void) NONBANKED;
/** Disables interrupts.
This function may be called as many times as you like;
however the first call to enable_interrupts will re-enable
them.
@see enable_interrupts
*/
void
disable_interrupts(void);
disable_interrupts(void) NONBANKED;
/** Clears any pending interrupts and sets the interrupt mask
register IO to flags.
@see VBL_IFLAG
@param flags A logical OR of *_IFLAGS
*/
void
set_interrupts(UBYTE flags);
set_interrupts(UINT8 flags) NONBANKED;
/** Performs a warm reset by reloading the CPU value
then jumping to the start of crt0 (0x0150)
*/
void
reset(void);
reset(void) NONBANKED;
/** Waits for the vertical blank interrupt (VBL) to finish.
This can be used to sync animation with the screen
re-draw. If VBL interrupt is disabled, this function will
never return. If the screen is off this function returns
immediatly.
*/
void
wait_vbl_done(void);
wait_vbl_done(void) NONBANKED;
/** Turns the display off.
Waits until the VBL interrupt before turning the display
off.
@see DISPLAY_ON
*/
void
display_off(void);
display_off(void) NONBANKED;
/* ************************************************************ */
/** Copies data from somewhere in the lower address space
to part of hi-ram.
@param dst Offset in high ram (0xFF00 and above)
to copy to.
@param src Area to copy from
@param n Number of bytes to copy.
*/
void
hiramcpy(UBYTE dst,
hiramcpy(UINT8 dst,
const void *src,
UBYTE n);
UINT8 n) NONBANKED;
/* ************************************************************ */
/** Turns the display back on.
@see display_off, DISPLAY_OFF
*/
#define DISPLAY_ON \
LCDC_REG|=0x80U
/** Turns the display off immediatly.
@see display_off, DISPLAY_ON
*/
#define DISPLAY_OFF \
display_off();
/** Turns on the background layer.
Sets bit 0 of the LCDC register to 1.
*/
#define SHOW_BKG \
LCDC_REG|=0x01U
/** Turns off the background layer.
Sets bit 0 of the LCDC register to 0.
*/
#define HIDE_BKG \
LCDC_REG&=0xFEU
/** Turns on the window layer
Sets bit 5 of the LCDC register to 1.
*/
#define SHOW_WIN \
LCDC_REG|=0x20U
/** Turns off the window layer.
Clears bit 5 of the LCDC register to 0.
*/
#define HIDE_WIN \
LCDC_REG&=0xDFU
/** Turns on the sprites layer.
Sets bit 1 of the LCDC register to 1.
*/
#define SHOW_SPRITES \
LCDC_REG|=0x02U
/** Turns off the sprites layer.
Clears bit 1 of the LCDC register to 0.
*/
#define HIDE_SPRITES \
LCDC_REG&=0xFDU
/** Sets sprite size to 8x16 pixels, two tiles one above the other.
Sets bit 2 of the LCDC register to 1.
*/
#define SPRITES_8x16 \
LCDC_REG|=0x04U
/** Sets sprite size to 8x8 pixels, one tile.
Clears bit 2 of the LCDC register to 0.
*/
#define SPRITES_8x8 \
LCDC_REG&=0xFBU
/* ************************************************************ */
/** Sets the tile patterns in the Background Tile Pattern table.
Starting with the tile pattern x and carrying on for n number of
tile patterns.Taking the values starting from the pointer
data. Note that patterns 128-255 overlap with patterns 128-255
of the sprite Tile Pattern table.
GBC: Depending on the VBK_REG this determines which bank of
Background tile patterns are written to. VBK_REG=0 indicates the
first bank, and VBK_REG=1 indicates the second.
@param first_tile Range 0 - 255
@param nb_tiles Range 0 - 255
*/
void
set_bkg_data(UBYTE first_tile,
UBYTE nb_tiles,
unsigned char *data);
set_bkg_data(UINT8 first_tile,
UINT8 nb_tiles,
unsigned char *data) NONBANKED;
/** Sets the tiles in the background tile table.
Starting at position x,y in tiles and writing across for w tiles
and down for h tiles. Taking the values starting from the pointer
data.
For the GBC, also see the pan/k00Pa section on VBK_REG.
@param x Range 0 - 31
@param y Range 0 - 31
@param w Range 0 - 31
@param h Range 0 - 31
@param data Pointer to an unsigned char. Usually the
first element in an array.
*/
void
set_bkg_tiles(UINT8 x,
UINT8 y,
UINT8 w,
UINT8 h,
unsigned char *tiles) NONBANKED;
void
set_bkg_tiles(UBYTE x,
UBYTE y,
UBYTE w,
UBYTE h,
unsigned char *tiles);
get_bkg_tiles(UINT8 x,
UINT8 y,
UINT8 w,
UINT8 h,
unsigned char *tiles) NONBANKED;
/** Moves the background layer to the position specified in x and y in pixels.
Where 0,0 is the top left corner of the GB screen. You'll notice the screen
wraps around in all 4 directions, and is always under the window layer.
*/
void
get_bkg_tiles(UBYTE x,
UBYTE y,
UBYTE w,
UBYTE h,
unsigned char *tiles);
move_bkg(UINT8 x,
UINT8 y) NONBANKED;
void
move_bkg(UBYTE x,
UBYTE y);
/** Moves the background relative to it's current position.
@see move_bkg
*/
void
scroll_bkg(BYTE x,
BYTE y);
scroll_bkg(INT8 x,
INT8 y) NONBANKED;
/* ************************************************************ */
/** Sets the window tile data.
This is the same as set_bkg_data, as both the window layer and background
layer share the same Tile Patterns.
@see set_bkg_data
*/
void
set_win_data(UBYTE first_tile,
UBYTE nb_tiles,
unsigned char *data);
set_win_data(UINT8 first_tile,
UINT8 nb_tiles,
unsigned char *data) NONBANKED;
/** Sets the tiles in the win tile table.
Starting at position x,y in
tiles and writing across for w tiles and down for h tiles. Taking the
values starting from the pointer data. Note that patterns 128-255 overlap
with patterns 128-255 of the sprite Tile Pattern table.
GBC only.
Depending on the VBK_REG this determines if you're setting the tile numbers
VBK_REG=0; or the attributes for those tiles VBK_REG=1;. The bits in the
attributes are defined as:
Bit 7 - Priority flag. When this is set, it puts the tile above the sprites
with colour 0 being transparent. 0: below sprites, 1: above sprites
Note SHOW_BKG needs to be set for these priorities to take place.
Bit 6 - Vertical flip. Dictates which way up the tile is drawn vertically.
0: normal, 1: upside down.
Bit 5 - Horizontal flip. Dictates which way up the tile is drawn
horizontally. 0: normal, 1:back to front.
Bit 4 - Not used.
Bit 3 - Character Bank specification. Dictates from which bank of
Background Tile Patterns the tile is taken. 0: Bank 0, 1: Bank 1
Bit 2 - See bit 0.
Bit 1 - See bit 0.
Bit 0 - Bits 0-2 indicate which of the 7 BKG colour palettes the tile is
assigned.
@param x Range 0 - 31
@param y Range 0 - 31
@param w Range 0 - 31
@param h Range 0 - 31
*/
void
set_win_tiles(UINT8 x,
UINT8 y,
UINT8 w,
UINT8 h,
unsigned char *tiles) NONBANKED;
void
set_win_tiles(UBYTE x,
UBYTE y,
UBYTE w,
UBYTE h,
unsigned char *tiles);
get_win_tiles(UINT8 x,
UINT8 y,
UINT8 w,
UINT8 h,
unsigned char *tiles) NONBANKED;
/** Moves the window layer to the position specified in x and y in pixels.
Where 7,0 is the top left corner of the GB screen. The window is locked to
the bottom right corner, and is always over the background layer.
@see SHOW_WIN, HIDE_WIN
*/
void
get_win_tiles(UBYTE x,
UBYTE y,
UBYTE w,
UBYTE h,
unsigned char *tiles);
move_win(UINT8 x,
UINT8 y) NONBANKED;
/** Move the window relative to its current position.
@see move_win
*/
void
move_win(UBYTE x,
UBYTE y);
void
scroll_win(BYTE x,
BYTE y);
scroll_win(INT8 x,
INT8 y) NONBANKED;
/* ************************************************************ */
/** Sets the tile patterns in the Sprite Tile Pattern table.
Starting with the tile pattern x and carrying on for n number of
tile patterns.Taking the values starting from the pointer
data. Note that patterns 128-255 overlap with patterns 128-255 of
the Background Tile Pattern table.
GBC only.
Depending on the VBK_REG this determines which bank of Background tile
patterns are written to. VBK_REG=0 indicates the first bank, and VBK_REG=1
indicates the second.
*/
void
set_sprite_data(UBYTE first_tile,
UBYTE nb_tiles,
unsigned char *data);
set_sprite_data(UINT8 first_tile,
UINT8 nb_tiles,
unsigned char *data) NONBANKED;
void
get_sprite_data(UBYTE first_tile,
UBYTE nb_tiles,
unsigned char *data);
get_sprite_data(UINT8 first_tile,
UINT8 nb_tiles,
unsigned char *data) NONBANKED;
/** Sets sprite n to display tile number t, from the sprite tile data.
If the GB is in 8x16 sprite mode then it will display the next
tile, t+1, below the first tile.
@param nb Sprite number, range 0 - 39
*/
void
set_sprite_tile(UBYTE nb,
UBYTE tile);
set_sprite_tile(UINT8 nb,
UINT8 tile) NONBANKED;
UBYTE
get_sprite_tile(UBYTE nb);
UINT8
get_sprite_tile(UINT8 nb) NONBANKED;
/** Sets the property of sprite n to those defined in p.
Where the bits in p represent:
Bit 7 - Priority flag. When this is set the sprites appear behind the
background and window layer. 0: infront, 1: behind.
Bit 6 - GBC only. Vertical flip. Dictates which way up the sprite is drawn
vertically. 0: normal, 1:upside down.
Bit 5 - GBC only. Horizontal flip. Dictates which way up the sprite is
drawn horizontally. 0: normal, 1:back to front.
Bit 4 - DMG only. Assigns either one of the two b/w palettes to the sprite.
0: OBJ palette 0, 1: OBJ palette 1.
Bit 3 - GBC only. Dictates from which bank of Sprite Tile Patterns the tile
is taken. 0: Bank 0, 1: Bank 1
Bit 2 - See bit 0.
Bit 1 - See bit 0.
Bit 0 - GBC only. Bits 0-2 indicate which of the 7 OBJ colour palettes the
sprite is assigned.
@param nb Sprite number, range 0 - 39
*/
void
set_sprite_prop(UBYTE nb,
UBYTE prop);
set_sprite_prop(UINT8 nb,
UINT8 prop) NONBANKED;
UBYTE
get_sprite_prop(UBYTE nb);
UINT8
get_sprite_prop(UINT8 nb) NONBANKED;
/** Moves the given sprite to the given position on the
screen.
Dont forget that the top left visible pixel on the screen
is at (8,16). To put sprite 0 at the top left, use
move_sprite(0, 8, 16);
*/
void
move_sprite(UBYTE nb,
UBYTE x,
UBYTE y);
move_sprite(UINT8 nb,
UINT8 x,
UINT8 y) NONBANKED;
/** Moves the given sprite relative to its current position.
*/
void
scroll_sprite(BYTE nb,
BYTE x,
BYTE y);
scroll_sprite(INT8 nb,
INT8 x,
INT8 y) NONBANKED;
/* ************************************************************ */
void
set_data(unsigned char *vram_addr,
unsigned char *data,
UWORD len);
UINT16 len) NONBANKED;
void
get_data(unsigned char *data,
unsigned char *vram_addr,
UWORD len);
UINT16 len) NONBANKED;
void
set_tiles(UBYTE x,
UBYTE y,
UBYTE w,
UBYTE h,
set_tiles(UINT8 x,
UINT8 y,
UINT8 w,
UINT8 h,
unsigned char *vram_addr,
unsigned char *tiles);
unsigned char *tiles) NONBANKED;
void
get_tiles(UBYTE x,
UBYTE y,
UBYTE w,
UBYTE h,
get_tiles(UINT8 x,
UINT8 y,
UINT8 w,
UINT8 h,
unsigned char *tiles,
unsigned char *vram_addr);
unsigned char *vram_addr) NONBANKED;
#endif /* _GB_H */

View file

@ -1,62 +1,133 @@
/** @file gb/hardware.h
Defines that let the GB's hardware registers be accessed
from C. See the Pan doc for what to set them to.
*/
#ifndef _HARDWARE_H
#define _HARDWARE_H
#include <types.h>
#define P1_REG (*(UBYTE *)0xFF00) /* Joystick: 1.1.P15.P14.P13.P12.P11.P10 */
#define SB_REG (*(UBYTE *)0xFF01) /* Serial IO data buffer */
#define SC_REG (*(UBYTE *)0xFF02) /* Serial IO control register */
#define DIV_REG (*(UBYTE *)0xFF04) /* Divider register */
#define TIMA_REG (*(UBYTE *)0xFF05) /* Timer counter */
#define TMA_REG (*(UBYTE *)0xFF06) /* Timer modulo */
#define TAC_REG (*(UBYTE *)0xFF07) /* Timer control */
#define IF_REG (*(UBYTE *)0xFF0F) /* Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL */
#define NR10_REG (*(UBYTE *)0xFF10) /* Sound register */
#define NR11_REG (*(UBYTE *)0xFF11) /* Sound register */
#define NR12_REG (*(UBYTE *)0xFF12) /* Sound register */
#define NR13_REG (*(UBYTE *)0xFF13) /* Sound register */
#define NR14_REG (*(UBYTE *)0xFF14) /* Sound register */
#define NR21_REG (*(UBYTE *)0xFF16) /* Sound register */
#define NR22_REG (*(UBYTE *)0xFF17) /* Sound register */
#define NR23_REG (*(UBYTE *)0xFF18) /* Sound register */
#define NR24_REG (*(UBYTE *)0xFF19) /* Sound register */
#define NR30_REG (*(UBYTE *)0xFF1A) /* Sound register */
#define NR31_REG (*(UBYTE *)0xFF1B) /* Sound register */
#define NR32_REG (*(UBYTE *)0xFF1C) /* Sound register */
#define NR33_REG (*(UBYTE *)0xFF1D) /* Sound register */
#define NR34_REG (*(UBYTE *)0xFF1E) /* Sound register */
#define NR41_REG (*(UBYTE *)0xFF20) /* Sound register */
#define NR42_REG (*(UBYTE *)0xFF21) /* Sound register */
#define NR43_REG (*(UBYTE *)0xFF22) /* Sound register */
#define NR44_REG (*(UBYTE *)0xFF23) /* Sound register */
#define NR50_REG (*(UBYTE *)0xFF24) /* Sound register */
#define NR51_REG (*(UBYTE *)0xFF25) /* Sound register */
#define NR52_REG (*(UBYTE *)0xFF26) /* Sound register */
#define LCDC_REG (*(UBYTE *)0xFF40) /* LCD control */
#define STAT_REG (*(UBYTE *)0xFF41) /* LCD status */
#define SCY_REG (*(UBYTE *)0xFF42) /* Scroll Y */
#define SCX_REG (*(UBYTE *)0xFF43) /* Scroll X */
#define LY_REG (*(UBYTE *)0xFF44) /* LCDC Y-coordinate */
#define LYC_REG (*(UBYTE *)0xFF45) /* LY compare */
#define DMA_REG (*(UBYTE *)0xFF46) /* DMA transfer */
#define BGP_REG (*(UBYTE *)0xFF47) /* BG palette data */
#define OBP0_REG (*(UBYTE *)0xFF48) /* OBJ palette 0 data */
#define OBP1_REG (*(UBYTE *)0xFF49) /* OBJ palette 1 data */
#define WY_REG (*(UBYTE *)0xFF4A) /* Window Y coordinate */
#define WX_REG (*(UBYTE *)0xFF4B) /* Window X coordinate */
#define KEY1_REG (*(UBYTE *)0xFF4D) /* CPU speed */
#define VBK_REG (*(UBYTE *)0xFF4F) /* VRAM bank */
#define HDMA1_REG (*(UBYTE *)0xFF51) /* DMA control 1 */
#define HDMA2_REG (*(UBYTE *)0xFF52) /* DMA control 2 */
#define HDMA3_REG (*(UBYTE *)0xFF53) /* DMA control 3 */
#define HDMA4_REG (*(UBYTE *)0xFF54) /* DMA control 4 */
#define HDMA5_REG (*(UBYTE *)0xFF55) /* DMA control 5 */
#define RP_REG (*(UBYTE *)0xFF56) /* IR port */
#define BCPS_REG (*(UBYTE *)0xFF68) /* BG color palette specification */
#define BCPD_REG (*(UBYTE *)0xFF69) /* BG color palette data */
#define OCPS_REG (*(UBYTE *)0xFF6A) /* OBJ color palette specification */
#define OCPD_REG (*(UBYTE *)0xFF6B) /* OBJ color palette data */
#define SVBK_REG (*(UBYTE *)0xFF70) /* WRAM bank */
#define IE_REG (*(UBYTE *)0xFFFF) /* Interrupt enable */
#if USE_SFR_FOR_REG
#error SFR is unteseted and disabled in 2.96
#define __REG extern volatile sfr UINT8
__REG P1_REG ; /* Joystick: 1.1.P15.P14.P13.P12.P11.P10 */
__REG SB_REG ; /* Serial IO data buffer */
__REG SC_REG ; /* Serial IO control register */
__REG DIV_REG ; /* Divider register */
__REG TIMA_REG ; /* Timer counter */
__REG TMA_REG ; /* Timer modulo */
__REG TAC_REG ; /* Timer control */
__REG IF_REG ; /* Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL */
__REG NR10_REG ; /* Sound register */
__REG NR11_REG ; /* Sound register */
__REG NR12_REG ; /* Sound register */
__REG NR13_REG ; /* Sound register */
__REG NR14_REG ; /* Sound register */
__REG NR21_REG ; /* Sound register */
__REG NR22_REG ; /* Sound register */
__REG NR23_REG ; /* Sound register */
__REG NR24_REG ; /* Sound register */
__REG NR30_REG ; /* Sound register */
__REG NR31_REG ; /* Sound register */
__REG NR32_REG ; /* Sound register */
__REG NR33_REG ; /* Sound register */
__REG NR34_REG ; /* Sound register */
__REG NR41_REG ; /* Sound register */
__REG NR42_REG ; /* Sound register */
__REG NR43_REG ; /* Sound register */
__REG NR44_REG ; /* Sound register */
__REG NR50_REG ; /* Sound register */
__REG NR51_REG ; /* Sound register */
__REG NR52_REG ; /* Sound register */
__REG LCDC_REG ; /* LCD control */
__REG STAT_REG ; /* LCD status */
__REG SCY_REG ; /* Scroll Y */
__REG SCX_REG ; /* Scroll X */
__REG LY_REG ; /* LCDC Y-coordinate */
__REG LYC_REG ; /* LY compare */
__REG DMA_REG ; /* DMA transfer */
__REG BGP_REG ; /* BG palette data */
__REG OBP0_REG ; /* OBJ palette 0 data */
__REG OBP1_REG ; /* OBJ palette 1 data */
__REG WY_REG ; /* Window Y coordinate */
__REG WX_REG ; /* Window X coordinate */
__REG KEY1_REG ; /* CPU speed */
__REG VBK_REG ; /* VRAM bank */
__REG HDMA1_REG ; /* DMA control 1 */
__REG HDMA2_REG ; /* DMA control 2 */
__REG HDMA3_REG ; /* DMA control 3 */
__REG HDMA4_REG ; /* DMA control 4 */
__REG HDMA5_REG ; /* DMA control 5 */
__REG RP_REG ; /* IR port */
__REG BCPS_REG ; /* BG color palette specification */
__REG BCPD_REG ; /* BG color palette data */
__REG OCPS_REG ; /* OBJ color palette specification */
__REG OCPD_REG ; /* OBJ color palette data */
__REG SVBK_REG ; /* WRAM bank */
__REG IE_REG ; /* Interrupt enable */
#else
#define __REG volatile UINT8 *
#define P1_REG (*(__REG)0xFF00) /* Joystick: 1.1.P15.P14.P13.P12.P11.P10 */
#define SB_REG (*(__REG)0xFF01) /* Serial IO data buffer */
#define SC_REG (*(__REG)0xFF02) /* Serial IO control register */
#define DIV_REG (*(__REG)0xFF04) /* Divider register */
#define TIMA_REG (*(__REG)0xFF05) /* Timer counter */
#define TMA_REG (*(__REG)0xFF06) /* Timer modulo */
#define TAC_REG (*(__REG)0xFF07) /* Timer control */
#define IF_REG (*(__REG)0xFF0F) /* Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL */
#define NR10_REG (*(__REG)0xFF10) /* Sound register */
#define NR11_REG (*(__REG)0xFF11) /* Sound register */
#define NR12_REG (*(__REG)0xFF12) /* Sound register */
#define NR13_REG (*(__REG)0xFF13) /* Sound register */
#define NR14_REG (*(__REG)0xFF14) /* Sound register */
#define NR21_REG (*(__REG)0xFF16) /* Sound register */
#define NR22_REG (*(__REG)0xFF17) /* Sound register */
#define NR23_REG (*(__REG)0xFF18) /* Sound register */
#define NR24_REG (*(__REG)0xFF19) /* Sound register */
#define NR30_REG (*(__REG)0xFF1A) /* Sound register */
#define NR31_REG (*(__REG)0xFF1B) /* Sound register */
#define NR32_REG (*(__REG)0xFF1C) /* Sound register */
#define NR33_REG (*(__REG)0xFF1D) /* Sound register */
#define NR34_REG (*(__REG)0xFF1E) /* Sound register */
#define NR41_REG (*(__REG)0xFF20) /* Sound register */
#define NR42_REG (*(__REG)0xFF21) /* Sound register */
#define NR43_REG (*(__REG)0xFF22) /* Sound register */
#define NR44_REG (*(__REG)0xFF23) /* Sound register */
#define NR50_REG (*(__REG)0xFF24) /* Sound register */
#define NR51_REG (*(__REG)0xFF25) /* Sound register */
#define NR52_REG (*(__REG)0xFF26) /* Sound register */
#define LCDC_REG (*(__REG)0xFF40) /* LCD control */
#define STAT_REG (*(__REG)0xFF41) /* LCD status */
#define SCY_REG (*(__REG)0xFF42) /* Scroll Y */
#define SCX_REG (*(__REG)0xFF43) /* Scroll X */
#define LY_REG (*(__REG)0xFF44) /* LCDC Y-coordinate */
#define LYC_REG (*(__REG)0xFF45) /* LY compare */
#define DMA_REG (*(__REG)0xFF46) /* DMA transfer */
#define BGP_REG (*(__REG)0xFF47) /* BG palette data */
#define OBP0_REG (*(__REG)0xFF48) /* OBJ palette 0 data */
#define OBP1_REG (*(__REG)0xFF49) /* OBJ palette 1 data */
#define WY_REG (*(__REG)0xFF4A) /* Window Y coordinate */
#define WX_REG (*(__REG)0xFF4B) /* Window X coordinate */
#define KEY1_REG (*(__REG)0xFF4D) /* CPU speed */
#define VBK_REG (*(__REG)0xFF4F) /* VRAM bank */
#define HDMA1_REG (*(__REG)0xFF51) /* DMA control 1 */
#define HDMA2_REG (*(__REG)0xFF52) /* DMA control 2 */
#define HDMA3_REG (*(__REG)0xFF53) /* DMA control 3 */
#define HDMA4_REG (*(__REG)0xFF54) /* DMA control 4 */
#define HDMA5_REG (*(__REG)0xFF55) /* DMA control 5 */
#define RP_REG (*(__REG)0xFF56) /* IR port */
#define BCPS_REG (*(__REG)0xFF68) /* BG color palette specification */
#define BCPD_REG (*(__REG)0xFF69) /* BG color palette data */
#define OCPS_REG (*(__REG)0xFF6A) /* OBJ color palette specification */
#define OCPD_REG (*(__REG)0xFF6B) /* OBJ color palette data */
#define SVBK_REG (*(__REG)0xFF70) /* WRAM bank */
#define IE_REG (*(__REG)0xFFFF) /* Interrupt enable */
#endif
#endif /* _HARDWARE_H */

44
gbdk-lib/include/gb/malloc.h Executable file
View file

@ -0,0 +1,44 @@
/** @file gb/malloc.h
Header for a simple implementation of malloc(). This library
may currently be broken.
*/
#ifndef __SYS_MALLOC_H
#define __SYS_MALLOC_H
#include <types.h>
/* The various constants */
/** The malloc hunk flags
Note: Cound have used a negative size a'la TI
*/
#define MALLOC_FREE 1
#define MALLOC_USED 2
/** Magic number of a header. Gives us some chance of
surviving if the list is corrupted*/
#define MALLOC_MAGIC 123
/* malloc hunk header definition */
typedef struct smalloc_hunk mmalloc_hunk;
typedef struct smalloc_hunk * pmmalloc_hunk;
struct smalloc_hunk {
UBYTE magic; /* Magic number - indicates valid hunk header */
pmmalloc_hunk next; /* Pointer to the next hunk */
UWORD size; /* Size in bytes of this region */
int status; /* One of MALLOC_FREE or MALLOC_USED */
};
/** Start of free memory, as defined by the linker */
extern UBYTE malloc_heap_start;
/** First hunk */
extern pmmalloc_hunk malloc_first;
/** Garbage collect (join free hunks) */
void malloc_gc(void) NONBANKED;
/** debug message logger */
void debug( char *routine, char *msg ) NONBANKED;
#endif /* __SYS_MALLOC_H */

View file

@ -1,16 +1,18 @@
/*
* Playback raw sound sample with length len from start at 8192Hz rate.
* len defines the length of the sample in samples/32 or bytes/16.
* The format of the data is unsigned 4-bit samples,
* 2 samples per byte, upper 4-bits played before lower 4 bits.
*
* Adaption for GBDK by Lars Malmborg.
* Original code by Jeff Frohwein.
*/
/** @file gb/sample.h
Playback raw sound sample with length len from start at 8192Hz rate.
len defines the length of the sample in samples/32 or bytes/16.
The format of the data is unsigned 4-bit samples,
2 samples per byte, upper 4-bits played before lower 4 bits.
Adaption for GBDK by Lars Malmborg.
Original code by Jeff Frohwein.
*/
#ifndef _SAMPLE_H
#define _SAMPLE_H
/** Play the given, appropriatly formatted sample.
*/
void
play_sample(UBYTE *start, UWORD len);
play_sample(UINT8 *start, UINT16 len) NONBANKED;
#endif /* _SAMPLE_H */

Some files were not shown because too many files have changed in this diff Show more