gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit a31370b9bd3e5c8f4e9691384228292e72c4a7d5 parent 8cae7937ab88c22f1d6657fa188e0389477db9ce Author: Toxa <untoxa@mail.ru> Date: Fri, 3 Sep 2021 00:37:35 +0300 cross-platform banks example (requires patched sdcc with -boN and -baN command line option support for z80 target) Diffstat:
| D | gbdk-lib/examples/ap/banks/Makefile | 63 | --------------------------------------------------------------- |
| A | gbdk-lib/examples/cross-platform/banks/Makefile | 81 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | gbdk-lib/examples/cross-platform/banks/Makefile.targets | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
| R | gbdk-lib/examples/ap/banks/bank_0.c -> gbdk-lib/examples/cross-platform/banks/src/bank.d0.c0.c | 0 | |
| R | gbdk-lib/examples/ap/banks/bank_1.c -> gbdk-lib/examples/cross-platform/banks/src/bank.d1.c1.c | 0 | |
| R | gbdk-lib/examples/ap/banks/bank_2.c -> gbdk-lib/examples/cross-platform/banks/src/bank.d2.c2.c | 0 | |
| R | gbdk-lib/examples/ap/banks/bank_3.c -> gbdk-lib/examples/cross-platform/banks/src/bank.d3.c3.c | 0 | |
| R | gbdk-lib/examples/ap/banks/banks.c -> gbdk-lib/examples/cross-platform/banks/src/banks.c | 0 | |
| M | gbdk-lib/include/gb/bgb_emu.h | 2 | +- |
9 files changed, 126 insertions(+), 64 deletions(-)
diff --git a/gbdk-lib/examples/ap/banks/Makefile b/gbdk-lib/examples/ap/banks/Makefile @@ -1,63 +0,0 @@ -CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS - -BINS = banks.pocket \ - -all: $(BINS) - -compile.bat: Makefile - @echo "REM Automatically generated from Makefile" > compile.bat - @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat - -%.o: %.c - $(CC) -c -o $@ $< - -%.s: %.c - $(CC) -S -o $@ $< - -%.o: %.s - $(CC) -c -o $@ $< - -%.pocket: %.o - $(CC) -o $@ $< - -clean: - rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi - -############################################################ -# 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 -# MBC5+ROM+RAM : -Wl-yt0x19 -# 4 ROM banks : -Wl-yo4 -# 4 RAM banks : -Wl-ya4 -# -banks.pocket: banks.o bank_0.o bank_1.o bank_2.o bank_3.o - $(CC) -Wl-yt0x1A -Wl-yo4 -Wl-ya4 -o $@ banks.o bank_0.o bank_1.o bank_2.o bank_3.o - diff --git a/gbdk-lib/examples/cross-platform/banks/Makefile b/gbdk-lib/examples/cross-platform/banks/Makefile @@ -0,0 +1,81 @@ +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = ../../../ +LCC = $(GBDK_HOME)bin/lcc + +# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets) +# They can also be built/cleaned individually: "make gg" and "make gg-clean" +# Possible are: gb gbc pocket sms gg +TARGETS=gb pocket sms gg + +# Configure platform specific LCC flags here: +LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT) +LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb +LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive) +LCCFLAGS_sms = +LCCFLAGS_gg = + +LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags + +LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags +# LCCFLAGS += -debug # Uncomment to enable debug output +# LCCFLAGS += -v # Uncomment for lcc verbose output + +# You can set the name of the ROM file here +PROJECTNAME = banks_farptr + +# EXT?=gb # Only sets extension to default (game boy .gb) if not populated +SRCDIR = src +OBJDIR = obj/$(EXT) +RESDIR = res +BINDIR = build/$(EXT) +MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation + +BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT) +CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c))) +ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) +OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) + +# Builds all targets sequentially +all: $(TARGETS) + +# Compile .c files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(eval BOFLAG = $(shell if [[ $< =~ ".c([0-9]+)". ]]; then echo $${BASH_REMATCH[1]}; fi)) + $(eval BOFLAG = $(if $(BOFLAG),-Wf-bo$(BOFLAG),)) + $(eval BAFLAG = $(shell if [[ $< =~ ".d([0-9]+)". ]]; then echo $${BASH_REMATCH[1]}; fi)) + $(eval BAFLAG = $(if $(BAFLAG),-Wf-ba$(BAFLAG),)) + $(LCC) $(CFLAGS) $(BOFLAG) $(BAFLAG) -c -o $@ $< + +# Compile .c files in "res/" to .o object files +$(OBJDIR)/%.o: $(RESDIR)/%.c + $(LCC) $(CFLAGS) -c -o $@ $< + +# Compile .s assembly files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.s + $(LCC) $(CFLAGS) -c -o $@ $< + +# If needed, compile .c files i n"src/" to .s assembly files +# (not required if .c is compiled directly to .o) +$(OBJDIR)/%.s: $(SRCDIR)/%.c + $(LCC) $(CFLAGS) -S -o $@ $< + +# Link the compiled object files into a .gb ROM file +$(BINS): $(OBJS) + $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS) + +clean: + @echo Cleaning + @for target in $(TARGETS); do \ + $(MAKE) $$target-clean; \ + done + +# Include available build targets +include Makefile.targets + + +# create necessary directories after Makefile is parsed but before build +# info prevents the command from being pasted into the makefile +ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target +$(info $(shell mkdir -p $(MKDIRS))) +endif diff --git a/gbdk-lib/examples/cross-platform/banks/Makefile.targets b/gbdk-lib/examples/cross-platform/banks/Makefile.targets @@ -0,0 +1,44 @@ + +# Platform specific flags for compiling (only populate if they're both present) +ifneq ($(strip $(PORT)),) +ifneq ($(strip $(PLAT)),) +CFLAGS += -m$(PORT):$(PLAT) -D_PLAT_$(PLAT) +endif +endif + +# Called by the individual targets below to build a ROM +build-target: $(BINS) + +clean-target: + rm -rf $(OBJDIR) + rm -rf $(BINDIR) + +gb-clean: + ${MAKE} clean-target EXT=gb +gb: + ${MAKE} build-target PORT=gbz80 PLAT=gb EXT=gb + + +gbc-clean: + ${MAKE} clean-target EXT=gbc +gbc: + ${MAKE} build-target PORT=gbz80 PLAT=gb EXT=gbc + + +pocket-clean: + ${MAKE} clean-target EXT=pocket +pocket: + ${MAKE} build-target PORT=gbz80 PLAT=ap EXT=pocket + + +sms-clean: + ${MAKE} clean-target EXT=sms +sms: + ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms + + +gg-clean: + ${MAKE} clean-target EXT=gg +gg: + ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg + diff --git a/gbdk-lib/examples/ap/banks/bank_0.c b/gbdk-lib/examples/cross-platform/banks/src/bank.d0.c0.c diff --git a/gbdk-lib/examples/ap/banks/bank_1.c b/gbdk-lib/examples/cross-platform/banks/src/bank.d1.c1.c diff --git a/gbdk-lib/examples/ap/banks/bank_2.c b/gbdk-lib/examples/cross-platform/banks/src/bank.d2.c2.c diff --git a/gbdk-lib/examples/ap/banks/bank_3.c b/gbdk-lib/examples/cross-platform/banks/src/bank.d3.c3.c diff --git a/gbdk-lib/examples/ap/banks/banks.c b/gbdk-lib/examples/cross-platform/banks/src/banks.c diff --git a/gbdk-lib/include/gb/bgb_emu.h b/gbdk-lib/include/gb/bgb_emu.h @@ -42,7 +42,7 @@ #define BGB_MESSAGE1(name, message_text) \ __asm \ -.MACRO name msg_t, msg_s, ?llbl\ +.MACRO name msg_t, ?llbl\ ld d, d \ jr llbl \ .dw 0x6464 \
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.