Compare commits
27 commits
Author | SHA1 | Date | |
---|---|---|---|
50a602383a | |||
51613ec605 | |||
1ec424f4e2 | |||
0196eac7dc | |||
684a30b299 | |||
ff61cf5601 | |||
637da8d677 | |||
947e10906d | |||
bf945bdc26 | |||
584c3e5ef5 | |||
2c782e0b62 | |||
105215819f | |||
105a361908 | |||
af8c3fd0b7 | |||
87e88b6377 | |||
83ff071c62 | |||
f4ce5ce439 | |||
01da2d884e | |||
6a90b129b7 | |||
bf5cebfdd7 | |||
64db604da9 | |||
f551cdb3c0 | |||
09a290dd78 | |||
7ee938a8ae | |||
42b070e5e9 | |||
47985a4330 | |||
20c0ed8d9e |
5
.travis.yml
Normal file
5
.travis.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
language: c
|
||||
install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo make build-dep
|
||||
script: make
|
192
Makefile
Normal file
192
Makefile
Normal 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)
|
|
@ -1,3 +0,0 @@
|
|||
/Makefile/1.1/Mon Feb 21 02:04:36 2000//
|
||||
/Makefile.common/1.7/Sun Mar 5 22:11:32 2000//
|
||||
D
|
|
@ -1,3 +0,0 @@
|
|||
A D/examples////
|
||||
A D/include////
|
||||
A D/libc////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
6
gbdk-lib/ChangeLog
Normal file
6
gbdk-lib/ChangeLog
Normal 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.
|
||||
|
|
@ -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 = $(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)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
D
|
|
@ -1 +0,0 @@
|
|||
A D/gb////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1,20 +0,0 @@
|
|||
/Makefile/1.6/Sun Mar 5 22:11:32 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.4/Sun Mar 5 22:11:32 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.2/Sun Mar 5 22:11:32 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
|
|
@ -1,4 +0,0 @@
|
|||
A D/colorbar////
|
||||
A D/dscan////
|
||||
A D/gb-dtmf////
|
||||
A D/tests////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1,4 +1,4 @@
|
|||
CC = ../../bin/lcc -Wa-l -Wl-m -DGBDK_2_COMPAT=1 -Wl-j -v
|
||||
CC = ../../bin/lcc -Wa-l -Wl-m -Wl-j
|
||||
|
||||
BINS = galaxy.gb \
|
||||
space.gb \
|
||||
|
@ -10,21 +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 $@ $<
|
||||
|
||||
|
|
92
gbdk-lib/examples/gb/Makefile.rgbds
Normal file
92
gbdk-lib/examples/gb/Makefile.rgbds
Normal 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
|
|
@ -1,3 +1,3 @@
|
|||
#include <gb/gb.h>
|
||||
|
||||
UBYTE var_0; /* In external RAM bank 0 */
|
||||
int var_0; /* In external RAM bank 0 */
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
38
gbdk-lib/examples/gb/banked/Makefile
Normal file
38
gbdk-lib/examples/gb/banked/Makefile
Normal 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 $@ $<
|
9
gbdk-lib/examples/gb/banked/bank.h
Normal file
9
gbdk-lib/examples/gb/banked/bank.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef BANK_INCLUDE
|
||||
#define BANK_INCLUDE
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int bank2(int i) BANKED;
|
||||
void bank3(void) BANKED;
|
||||
|
||||
#endif
|
13
gbdk-lib/examples/gb/banked/bank2.c
Normal file
13
gbdk-lib/examples/gb/banked/bank2.c
Normal 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;
|
||||
}
|
8
gbdk-lib/examples/gb/banked/bank3.c
Normal file
8
gbdk-lib/examples/gb/banked/bank3.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include "bank.h"
|
||||
#pragma bank=3
|
||||
|
||||
void bank3(void) BANKED
|
||||
{
|
||||
puts(" In bank 3!");
|
||||
}
|
||||
|
10
gbdk-lib/examples/gb/banked/main.c
Normal file
10
gbdk-lib/examples/gb/banked/main.c
Normal 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;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
/Makefile/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/bar_c.c/1.2/Sun Mar 5 22:11:32 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.2/Sun Mar 5 22:11:32 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.2/Sun Mar 5 22:11:32 2000//
|
||||
/make.bat/1.1/Wed Feb 23 02:50:14 2000//
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/colorbar
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1,4 +1,4 @@
|
|||
CC = ../../../bin/lcc -Wa-l -Wl-m -v
|
||||
CC = ../../../bin/lcc -Wa-l -Wl-m
|
||||
|
||||
CFLAGS = -DGBDK_2_COMPAT
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
/Makefile/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/bkg.c/1.2/Sun Mar 5 22:11:32 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.2/Sun Mar 5 22:11:32 2000//
|
||||
/bkg_c.gbm/1.1/Wed Feb 23 02:50:14 2000//
|
||||
/bkg_m.c/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/bkg_m.gbm/1.1/Wed Feb 23 02:50:14 2000//
|
||||
/dscan.c/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/fore.c/1.2/Sun Mar 5 22:11:32 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
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/dscan
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1,4 +1,4 @@
|
|||
CC = ../../../bin/lcc -Wa-l -Wl-m -DGBDK_2_COMPAT=1 -v
|
||||
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 $@ $<
|
||||
|
||||
|
|
|
@ -97,17 +97,18 @@ const UWORD obj_p[] =
|
|||
|
||||
unsigned char msg_tile[64];
|
||||
|
||||
const unsigned char *msg_1up = "1UP";
|
||||
const unsigned char *msg_lv = "LV";
|
||||
const unsigned char * const msg_1up = "1UP";
|
||||
const unsigned char * const msg_lv = "LV";
|
||||
|
||||
const unsigned char *msg_gover = "GAMEOVER";
|
||||
const unsigned char *msg_pause = " PAUSE! ";
|
||||
const 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;
|
||||
|
@ -429,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 ) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -322,7 +322,7 @@ const unsigned char door4_tiles[] = {
|
|||
};
|
||||
|
||||
/* Should really be const, but sdcc doesnt yet support it. */
|
||||
const unsigned char *film[] = {
|
||||
const unsigned char * const film[] = {
|
||||
&door1_tiles[0x0C*0],
|
||||
&door2_tiles[0x0C*0],
|
||||
&door3_tiles[0x0C*0],
|
||||
|
@ -366,10 +366,10 @@ const 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/Makefile/1.3/Thu Mar 9 04:49:04 2000//
|
||||
/brk_btn.c/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/brk_btn.gbr/1.1/Wed Feb 23 02:50:14 2000//
|
||||
/cursor.c/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/cursor.gbr/1.1/Wed Feb 23 02:50:14 2000//
|
||||
/dtmf_lcd.c/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/dtmf_lcd.gbr/1.1/Wed Feb 23 02:50:15 2000//
|
||||
/frm_lcd.c/1.2/Sun Mar 5 22:11:32 2000//
|
||||
/frm_lcd.gbr/1.1/Wed Feb 23 02:50:15 2000//
|
||||
/gb-dtmf.c/1.3/Thu Mar 9 04:49:04 2000//
|
||||
/key_num.c/1.2/Sun Mar 5 22:11:32 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.2/Sun Mar 5 22:11:32 2000//
|
||||
/prs_btn.gbr/1.1/Wed Feb 23 02:50:15 2000//
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/gb-dtmf
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -374,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;
|
||||
|
@ -543,7 +543,7 @@ void main()
|
|||
char str_ms[10];
|
||||
|
||||
/* PENDING: sdcc is broken and needs this to be initalised. */
|
||||
key2 = 1;
|
||||
key2 = 0;
|
||||
|
||||
/* default dialling time setting */
|
||||
on_time = DTMF_ON;
|
||||
|
@ -607,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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/examples/gb/tests
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -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.3/Mon Mar 6 04:54:10 2000//
|
||||
/types.h/1.1/Mon Feb 21 02:04:36 2000//
|
||||
D
|
|
@ -1,3 +0,0 @@
|
|||
A D/asm////
|
||||
A D/consolez80////
|
||||
A D/gb////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
14
gbdk-lib/include/Makefile
Normal file
14
gbdk-lib/include/Makefile
Normal 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 -)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
/types.h/1.3/Sun Mar 5 22:11:32 2000//
|
||||
D
|
|
@ -1,2 +0,0 @@
|
|||
A D/gbz80////
|
||||
A D/z80////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/asm
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/asm/gbz80
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/** @file asm/types.h
|
||||
Shared types definitions.
|
||||
*/
|
||||
#ifndef ASM_TYPES_INCLUDE
|
||||
#define ASM_TYPES_INCLUDE
|
||||
|
||||
|
@ -9,20 +12,46 @@
|
|||
#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
|
||||
|
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/asm/z80
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1,2 +0,0 @@
|
|||
/README/1.1.1.1/Mon Feb 21 00:46:01 2000//
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/consolez80
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -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 */
|
||||
|
|
|
@ -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.2/Sun Mar 5 22:11:32 2000//
|
||||
/sample.h/1.1/Tue Feb 22 04:11:49 2000//
|
||||
/sgb.h/1.1/Tue Feb 22 04:11:49 2000//
|
||||
D
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/include/gb
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
4
gbdk-lib/include/gb/gb.dox
Normal file
4
gbdk-lib/include/gb/gb.dox
Normal 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
|
|
@ -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 */
|
||||
|
|
|
@ -1,8 +1,75 @@
|
|||
/** @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>
|
||||
|
||||
#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 */
|
||||
|
@ -61,4 +128,6 @@
|
|||
#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
44
gbdk-lib/include/gb/malloc.h
Executable 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 */
|
|
@ -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 */
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
/** @file gb/sgb.h
|
||||
Super Gameboy definitions.
|
||||
*/
|
||||
#ifndef _SGB_H
|
||||
#define _SGB_H
|
||||
|
||||
UBYTE
|
||||
/** Return a non-null value if running on Super GameBoy */
|
||||
UINT8
|
||||
sgb_check(void);
|
||||
/* Return a non-null value if running on Super GameBoy */
|
||||
|
||||
#endif /* _SGB_H */
|
||||
|
|
|
@ -1,3 +1,25 @@
|
|||
/** @file gbdk-lib.h
|
||||
Settings for the greater library system.
|
||||
*/
|
||||
/** @mainpage Gameboy Development Kit Library (gbdk-lib) documentation.
|
||||
|
||||
The following pages document a good size chunk of the libraries
|
||||
that go along with gbdk. They were automatically generated from
|
||||
the header files using <tt>doxygen libc.dox</tt>
|
||||
|
||||
Thanks to quang for many of the comments to the gb functions. Some
|
||||
of the comments are ripped directly from the Linux Programmers
|
||||
manual, and some directly from the pan/k00Pa document.
|
||||
|
||||
Links:
|
||||
|
||||
<a href="http://quangdx.com/">quangDX.com</a>
|
||||
|
||||
<a href="http://www.devrs.com/gb/">Jeff Frohwein's GB development page.</a>
|
||||
A good source of all information gb related, including GeeBee's GB faq and the pan/k00Pa document.
|
||||
|
||||
<a href="http://gbdk.sourceforge.net/">The gbdk homepage.</a>
|
||||
*/
|
||||
#ifndef GBDK_LIB_INCLUDE
|
||||
#define GBDK_LIB_INCLUDE
|
||||
|
||||
|
|
5
gbdk-lib/include/libc.dox
Normal file
5
gbdk-lib/include/libc.dox
Normal file
|
@ -0,0 +1,5 @@
|
|||
PROJECT_NAME = "gbdk-lib"
|
||||
OUTPUT_DIRECTORY = "../doc/libc"
|
||||
RECURSIVE = yes
|
||||
INPUT = .
|
||||
PREDEFINED = "NONBANKED= BANKED="
|
|
@ -1,37 +1,42 @@
|
|||
/** @file rand.h
|
||||
Random generator using the linear congruential method
|
||||
|
||||
@author Luc Van den Borre
|
||||
*/
|
||||
#ifndef RAND_INCLUDE
|
||||
#define RAND_INCLUDE
|
||||
|
||||
#include <types.h>
|
||||
|
||||
|
||||
/*
|
||||
* Random generator using the linear congruential method
|
||||
*
|
||||
* Author: Luc Van den Borre
|
||||
*/
|
||||
|
||||
/** Initalise the random number generator.
|
||||
seed needs to be different each time, else the same sequence will be
|
||||
generated. A good source is the DIV register.
|
||||
*/
|
||||
void
|
||||
initrand(UWORD seed);
|
||||
initrand(UINT16 seed) NONBANKED; /* Non-banked as called from asm in arand.s */
|
||||
|
||||
BYTE
|
||||
/** Returns a random value.
|
||||
*/
|
||||
INT8
|
||||
rand(void);
|
||||
|
||||
WORD
|
||||
/** Returns a random word.
|
||||
*/
|
||||
UINT16
|
||||
randw(void);
|
||||
|
||||
/*
|
||||
* Random generator using the linear lagged additive method
|
||||
*
|
||||
* Author: Luc Van den Borre
|
||||
*
|
||||
* Note that 'initarand()' calls 'initrand()' with the same seed value, and
|
||||
* uses 'rand()' to initialize the random generator.
|
||||
*/
|
||||
/** Random generator using the linear lagged additive method
|
||||
Note that 'initarand()' calls 'initrand()' with the same seed value, and
|
||||
uses 'rand()' to initialize the random generator.
|
||||
|
||||
@author Luc Van den Borre
|
||||
*/
|
||||
void
|
||||
initarand(WORD seed);
|
||||
initarand(UINT16 seed);
|
||||
|
||||
BYTE
|
||||
/** Generates a random number using the linear lagged additive method.
|
||||
*/
|
||||
INT8
|
||||
arand(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,7 @@ void putchar(char c);
|
|||
\%d (signed int), \%x (unsigned int as hex), and \%s (string).
|
||||
Does not return the number of characters printed.
|
||||
*/
|
||||
void printf(const char *format, ...);
|
||||
void printf(const char *format, ...) NONBANKED;
|
||||
|
||||
/** Print the string and arguments given by format to a buffer.
|
||||
Currently supported: \%c (character), \%u (unsigned int),
|
||||
|
@ -28,12 +28,12 @@ void printf(const char *format, ...);
|
|||
@param str The buffer to print into.
|
||||
@param format The format string as per printf.
|
||||
*/
|
||||
void sprintf(char *str, const char *format, ...);
|
||||
void sprintf(char *str, const char *format, ...) NONBANKED;
|
||||
|
||||
/** puts() writes the string s and a trailing newline to std
|
||||
out.
|
||||
*/
|
||||
void puts(const char *s);
|
||||
void puts(const char *s) NONBANKED;
|
||||
|
||||
/** gets() reads a line from stdin into the buffer pointed to by s until
|
||||
either a terminating newline or EOF, which it replaces with '\0'. No
|
||||
|
@ -41,4 +41,8 @@ void puts(const char *s);
|
|||
*/
|
||||
char *gets(char *s);
|
||||
|
||||
/** getchar() gets a single character from stdin.
|
||||
*/
|
||||
char getchar(void);
|
||||
|
||||
#endif
|
||||
|
|
44
gbdk-lib/include/stdlib.h
Normal file
44
gbdk-lib/include/stdlib.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/** file stdlib.h
|
||||
'Standard library' functions, for whatever that means.
|
||||
*/
|
||||
#ifndef STDLIB_INCLUDE
|
||||
#define STDLIB_INCLUDE
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/** Causes normal program termination and the value of status is
|
||||
returned to the parent.
|
||||
All open streams are flushed and closed.
|
||||
*/
|
||||
void exit(int status) NONBANKED;
|
||||
|
||||
#if 0
|
||||
/** Compatibility function. Not implemented.
|
||||
*/
|
||||
int getkey(void);
|
||||
#endif
|
||||
|
||||
/** Returns the absolute value of a int.
|
||||
If i is negative, returns -i; else returns i.
|
||||
*/
|
||||
int abs(int i);
|
||||
/** Returns the absolute value of a long.
|
||||
*/
|
||||
long labs(long num);
|
||||
/** Converts an ASCII string to an int.
|
||||
The string may be of the format [\s]*[+-][\d]+[\D]* i.e. any number
|
||||
of spaces, an optional + or -, then an arbitrary number of digits.
|
||||
The result is undefined if the number doesnt fit in an int.
|
||||
*/
|
||||
int atoi(const char *s);
|
||||
/** Converts an ASCII string to a long.
|
||||
*/
|
||||
long atol(const char *s);
|
||||
/** Converts an int into a base 10 ASCII string.
|
||||
*/
|
||||
char *itoa(int n, char *s);
|
||||
/** Converts a long into a base 10 ASCII string.
|
||||
*/
|
||||
char *ltoa(long n, char *s);
|
||||
|
||||
#endif
|
|
@ -15,14 +15,14 @@
|
|||
@param src Array to copy from.
|
||||
@return A pointer to dest.
|
||||
*/
|
||||
char *strcpy(char *dest, const char *src);
|
||||
char *strcpy(char *dest, const char *src) NONBANKED;
|
||||
|
||||
/** Compares the two strings s1 and s2.
|
||||
It returns an integer less than, equal to, or greater than zero if
|
||||
s1 is found, respectively, to be less than, to match, or be
|
||||
greater than s2.
|
||||
*/
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
int strcmp(const char *s1, const char *s2) NONBANKED;
|
||||
|
||||
/** Copies n bytes from memory area src to memory area dest.
|
||||
The memory areas may not overlap.
|
||||
|
@ -32,6 +32,37 @@ int strcmp(const char *s1, const char *s2);
|
|||
@param len The length in bytes of src.
|
||||
@return A pointer to dest.
|
||||
*/
|
||||
void *memcpy(void *dest, const void *src, size_t len);
|
||||
void *memcpy(void *dest, const void *src, size_t len) NONBANKED;
|
||||
|
||||
/** Reverses the characters in the string.
|
||||
For example 'abcdefg' will become 'gfedcba'. Banked as the string
|
||||
must be modifiable.
|
||||
*/
|
||||
char *reverse(char *s);
|
||||
|
||||
char *strcat(char *s1, const char *s2) NONBANKED;
|
||||
|
||||
/** Calculates the length of the string, not including the terminating
|
||||
`\0' character.
|
||||
*/
|
||||
int strlen(const char *s) NONBANKED;
|
||||
|
||||
/**Concatenate s2 on the end of s1.
|
||||
s1 must be large enough. At most n characters are moved.
|
||||
*/
|
||||
char *strncat(char *s1, const char *s2, int n) NONBANKED;
|
||||
|
||||
/** Compare strings (at most n bytes):
|
||||
s1>s2: >0
|
||||
s1==s2: 0
|
||||
s1<s2: <0
|
||||
*/
|
||||
int strncmp(const char *s1, const char *s2, int n) NONBANKED;
|
||||
|
||||
/** Copy s2 to s1, truncating or null-padding to always copy n bytes.
|
||||
If there is no \0 in the first n bytes of s2 then s1 will not be
|
||||
null terminated.
|
||||
*/
|
||||
char *strncpy(char *s1, const char *s2, int n) NONBANKED;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,11 +14,15 @@
|
|||
#define CLOCKS_PER_SEC 50
|
||||
#endif
|
||||
|
||||
typedef UINT16 time_t;
|
||||
|
||||
/** The clock() function returns an approximation of processor time
|
||||
used by the program. The value returned is the CPU time used so far
|
||||
as a clock_t; to get the number of seconds used, divide by
|
||||
CLOCKS_PER_SEC.
|
||||
*/
|
||||
clock_t clock(void);
|
||||
clock_t clock(void) NONBANKED;
|
||||
|
||||
time_t time(time_t *t);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,15 +1,25 @@
|
|||
/** @file types.h
|
||||
Basic types.
|
||||
Directly include the port specific file.
|
||||
*/
|
||||
#ifndef TYPES_INCLUDE
|
||||
#define TYPES_INCLUDE
|
||||
|
||||
#include <asm/types.h>
|
||||
|
||||
/** Good 'ol NULL.
|
||||
*/
|
||||
#define NULL 0
|
||||
|
||||
enum {
|
||||
FALSE,
|
||||
TRUE
|
||||
};
|
||||
/** A 'false' value.
|
||||
*/
|
||||
#define FALSE 0
|
||||
/** A 'true' value.
|
||||
*/
|
||||
#define TRUE 1
|
||||
|
||||
typedef void * POINTER;
|
||||
/** No longer used.
|
||||
*/
|
||||
typedef void * POINTER;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/Makefile/1.4/Wed Feb 23 02:45:18 2000//
|
||||
/Makefile.platform/1.2/Tue Feb 22 04:05:50 2000//
|
||||
/isalpha.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
/isdigit.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
/islower.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
/isspace.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
/isupper.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
/printf.c/1.2/Wed Feb 23 02:45:18 2000//
|
||||
/puts.c/1.1/Tue Feb 22 04:12:15 2000//
|
||||
/string.c/1.1.1.1/Mon Feb 21 00:46:01 2000//
|
||||
/tolower.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
/toupper.c/1.1/Wed Feb 23 02:46:23 2000//
|
||||
D
|
|
@ -1,4 +0,0 @@
|
|||
A D/asm////
|
||||
A D/consolez80////
|
||||
A D/gb////
|
||||
A D/rrgb////
|
|
@ -1 +0,0 @@
|
|||
gbdk-lib/libc
|
|
@ -1 +0,0 @@
|
|||
:pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
|
|
@ -1,41 +1,43 @@
|
|||
# Makefile for libc
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
TOPDIR = ..
|
||||
|
||||
CSRC = abs.c atoi.c atol.c isalpha.c isdigit.c \
|
||||
islower.c isspace.c isupper.c itoa.c labs.c \
|
||||
printf.c puts.c reverse.c scanf.c strcat.c string.c \
|
||||
strlen.c strncat.c strncmp.c strncpy.c time.c \
|
||||
tolower.c toupper.c \
|
||||
_modulong.c _modslong.c _divulong.c _divslong.c _mullong.c
|
||||
# free.c malloc.c realloc.c calloc.c ltoa.c
|
||||
|
||||
include $(TOPDIR)/Makefile.common
|
||||
|
||||
LIBC_OBJ = string.o printf.o puts.o \
|
||||
isalpha.o isdigit.o islower.o isspace.o isupper.o \
|
||||
toupper.o tolower.o
|
||||
|
||||
CFLAGS = -I$(TOPDIR)/include
|
||||
CFLAGS += -m$(PORT) -v
|
||||
CC = $(SCC)
|
||||
|
||||
all: ports platforms
|
||||
|
||||
clean: port-clean ports-clean platform-clean
|
||||
|
||||
ports:
|
||||
for i in $(PORTS); do make port PORT=$$i; done
|
||||
for i in $(PORTS); do make port THIS=$$i PORT=$$i; done
|
||||
|
||||
platforms:
|
||||
for i in $(PLATFORMS); do make -C $$i platform PLAT=$$i; done
|
||||
for i in $(PLATFORMS); do make -C $$i platform THIS=$$i; done
|
||||
|
||||
# Make all the std libs
|
||||
# Make all the port specific libs
|
||||
port: port-clean $(LIBC_OBJ)
|
||||
mkdir -p $(TOPDIR)/build/$(PORT)
|
||||
cp $(LIBC_OBJ) $(TOPDIR)/build/$(PORT)
|
||||
cd $(TOPDIR)/build/$(PORT); ls $(LIBC_OBJ) > $(PORT).lib
|
||||
|
||||
# Uses the LIB <- OBJ rule from Makefile.rules
|
||||
port: port-clean $(LIB)
|
||||
make -C asm/$(PORT) port
|
||||
|
||||
port-clean:
|
||||
rm -f $(LIBC_OBJ) $(CLEANSPEC)
|
||||
|
||||
ports-clean:
|
||||
for i in $(PORTS); do make -C asm/$$i clean PORT=$$i; done
|
||||
for i in $(PORTS); do make -C asm/$$i clean THIS=$$i; done
|
||||
|
||||
platform-clean:
|
||||
for i in $(PLATFORMS); do make -C $$i clean PLAT=$$i; done
|
||||
|
||||
include Makefile.rules
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue