mirror of
https://github.com/AntonioND/nitro-engine.git
synced 2025-06-18 16:45:33 -04:00
build: docs: Support BlocksDS
This commit is contained in:
parent
d044d8c19f
commit
d659bc8915
181
Makefile.blocksds
Normal file
181
Makefile.blocksds
Normal file
@ -0,0 +1,181 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
BLOCKSDS ?= /opt/blocksds/core
|
||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
||||
|
||||
# Source code paths
|
||||
# -----------------
|
||||
|
||||
SOURCEDIRS := source
|
||||
INCLUDEDIRS := include
|
||||
GFXDIRS :=
|
||||
BINDIRS :=
|
||||
|
||||
# Defines passed to all files
|
||||
# ---------------------------
|
||||
|
||||
DEFINES :=
|
||||
|
||||
# Libraries
|
||||
# ---------
|
||||
|
||||
LIBDIRS := $(BLOCKSDS)/libs/libnds
|
||||
|
||||
# Build artifacts
|
||||
# ---------------
|
||||
|
||||
ifeq ($(NE_DEBUG),1)
|
||||
NAME := NE_debug
|
||||
BUILDDIR := build_debug
|
||||
else
|
||||
NAME := NE
|
||||
BUILDDIR := build_release
|
||||
endif
|
||||
INSTALLNAME := nitro-engine
|
||||
ARCHIVE := lib/lib$(NAME).a
|
||||
|
||||
# Tools
|
||||
# -----
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
AR := ar
|
||||
MKDIR := mkdir
|
||||
RM := rm -rf
|
||||
CP := cp
|
||||
INSTALL := install
|
||||
|
||||
# Verbose flag
|
||||
# ------------
|
||||
|
||||
ifeq ($(VERBOSE),1)
|
||||
V :=
|
||||
else
|
||||
V := @
|
||||
endif
|
||||
|
||||
# Source files
|
||||
# ------------
|
||||
|
||||
ifneq ($(BINDIRS),)
|
||||
SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS))
|
||||
endif
|
||||
ifneq ($(GFXDIRS),)
|
||||
SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS))
|
||||
endif
|
||||
|
||||
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
|
||||
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
|
||||
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
||||
|
||||
# Compiler and linker flags
|
||||
# -------------------------
|
||||
|
||||
DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall -Wno-address-of-packed-member
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||
-ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fomit-frame-pointer
|
||||
|
||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fno-exceptions -fno-rtti \
|
||||
-fomit-frame-pointer
|
||||
|
||||
# Intermediate build files
|
||||
# ------------------------
|
||||
|
||||
OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
||||
|
||||
OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES)
|
||||
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Targets
|
||||
# -------
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
all: $(ARCHIVE)
|
||||
|
||||
$(ARCHIVE): $(OBJS)
|
||||
@echo " AR $@"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(AR) rcs $@ $(OBJS)
|
||||
|
||||
install: all
|
||||
@echo " INSTALL $(BLOCKSDSEXT)/$(INSTALLNAME)/"
|
||||
$(V)$(RM) $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
||||
$(V)$(INSTALL) -d $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
||||
$(V)$(CP) -r include lib $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
||||
|
||||
clean:
|
||||
@echo " CLEAN"
|
||||
$(V)$(RM) $(ARCHIVE) build_debug build_release
|
||||
|
||||
# Rules
|
||||
# -----
|
||||
|
||||
$(BUILDDIR)/%.s.o : %.s
|
||||
@echo " AS $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.c.o : %.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.cpp.o : %.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin
|
||||
@echo " BIN2C $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c
|
||||
|
||||
$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
||||
@echo " GRIT $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||
$(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h
|
||||
|
||||
# All assets must be built before the source code
|
||||
# -----------------------------------------------
|
||||
|
||||
$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS)
|
||||
|
||||
# Include dependency files if they exist
|
||||
# --------------------------------------
|
||||
|
||||
-include $(DEPS)
|
25
examples/2d_system/Makefile.blocksds
Normal file
25
examples/2d_system/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
3
examples/2d_system/gui/Makefile.blocksds
Normal file
3
examples/2d_system/gui/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/2d_system/quad_texture_sizes/Makefile.blocksds
Normal file
3
examples/2d_system/quad_texture_sizes/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
1
examples/2d_system/quads/Makefile.blocksds
Normal file
1
examples/2d_system/quads/Makefile.blocksds
Normal file
@ -0,0 +1 @@
|
||||
include ../../Makefile.example.blocksds
|
3
examples/2d_system/sprites/Makefile.blocksds
Normal file
3
examples/2d_system/sprites/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/2d_system/text/Makefile.blocksds
Normal file
3
examples/2d_system/text/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
25
examples/Makefile.blocksds
Normal file
25
examples/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
$(MAKE) -C $$i -f Makefile.blocksds --no-print-directory || { exit 1;} \
|
||||
fi; \
|
||||
done;
|
||||
@rm -fr build-all
|
||||
@mkdir -p build-all
|
||||
@find . -name "*.nds" -not -path build-all -exec cp -fv {} build-all \;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
$(MAKE) -C $$i -f Makefile.blocksds clean --no-print-directory || { exit 1;} \
|
||||
fi; \
|
||||
done;
|
||||
@rm -fr build-all
|
263
examples/Makefile.example.blocksds
Normal file
263
examples/Makefile.example.blocksds
Normal file
@ -0,0 +1,263 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
BLOCKSDS ?= /opt/blocksds/core
|
||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
||||
|
||||
# User config
|
||||
# ===========
|
||||
|
||||
NAME := $(shell basename $(CURDIR))
|
||||
GAME_TITLE := $(shell basename $(CURDIR)).nds
|
||||
GAME_SUBTITLE := Nitro Engine example
|
||||
GAME_AUTHOR := github.com/AntonioND/nitro-engine
|
||||
GAME_ICON := $(BLOCKSDS)/sys/icon.bmp
|
||||
|
||||
# Source code paths
|
||||
# -----------------
|
||||
|
||||
SOURCEDIRS ?= source
|
||||
|
||||
# DLDI and internal SD slot of DSi
|
||||
# --------------------------------
|
||||
|
||||
# Root folder of the SD image
|
||||
SDROOT := sdroot
|
||||
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
||||
SDIMAGE := image.bin
|
||||
|
||||
# Libraries
|
||||
# ---------
|
||||
|
||||
LIBS += -lNE -lnds9 -lc
|
||||
LIBDIRS += $(BLOCKSDSEXT)/nitro-engine \
|
||||
$(BLOCKSDS)/libs/libnds
|
||||
|
||||
# Build artifacts
|
||||
# ---------------
|
||||
|
||||
BUILDDIR := build
|
||||
ELF := build/$(NAME).elf
|
||||
DUMP := build/$(NAME).dump
|
||||
NITROFAT_IMG := build/nitrofat.bin
|
||||
MAP := build/$(NAME).map
|
||||
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
||||
ROM := $(NAME).nds
|
||||
|
||||
# Tools
|
||||
# -----
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
MKDIR := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
# Verbose flag
|
||||
# ------------
|
||||
|
||||
ifeq ($(VERBOSE),1)
|
||||
V :=
|
||||
else
|
||||
V := @
|
||||
endif
|
||||
|
||||
# Source files
|
||||
# ------------
|
||||
|
||||
ifneq ($(BINDIRS),)
|
||||
SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS))
|
||||
endif
|
||||
ifneq ($(GFXDIRS),)
|
||||
SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS))
|
||||
endif
|
||||
ifneq ($(AUDIODIRS),)
|
||||
SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)')
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
INCLUDEDIRS += $(SOUNDBANKDIR)
|
||||
endif
|
||||
endif
|
||||
|
||||
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
|
||||
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
|
||||
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
||||
|
||||
# Compiler and linker flags
|
||||
# -------------------------
|
||||
|
||||
DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall
|
||||
|
||||
ifeq ($(SOURCES_CPP),)
|
||||
LD := $(CC)
|
||||
else
|
||||
LD := $(CXX)
|
||||
endif
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
||||
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||
-ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fomit-frame-pointer
|
||||
|
||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fno-exceptions -fno-rtti \
|
||||
-fomit-frame-pointer
|
||||
|
||||
LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \
|
||||
-Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.mem \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.ld \
|
||||
-Wl,--no-warn-rwx-segments \
|
||||
-Wl,--start-group $(LIBS) -lgcc -Wl,--end-group
|
||||
|
||||
# Intermediate build files
|
||||
# ------------------------
|
||||
|
||||
OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o
|
||||
HEADERS_ASSETS += $(SOUNDBANKDIR)/soundbank.h
|
||||
endif
|
||||
|
||||
OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
||||
|
||||
OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES)
|
||||
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Targets
|
||||
# -------
|
||||
|
||||
.PHONY: all clean dump dldipatch sdimage
|
||||
|
||||
all: $(ROM)
|
||||
|
||||
ifneq ($(strip $(NITROFATDIR)),)
|
||||
# Additional arguments for ndstool
|
||||
NDSTOOL_FAT := -F $(NITROFAT_IMG)
|
||||
|
||||
$(NITROFAT_IMG): $(NITROFATDIR)
|
||||
@echo " MKFATIMG $@ $(NITROFATDIR)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg $(NITROFATDIR) $@ 0
|
||||
#$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(NITROFATDIR) $@ 0
|
||||
|
||||
# Make the NDS ROM depend on the filesystem image only if it is needed
|
||||
$(ROM): $(NITROFAT_IMG)
|
||||
endif
|
||||
|
||||
# Combine the title strings
|
||||
ifeq ($(strip $(GAME_SUBTITLE)),)
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR)
|
||||
else
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR)
|
||||
endif
|
||||
|
||||
$(ROM): $(ELF)
|
||||
@echo " NDSTOOL $@"
|
||||
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
|
||||
-7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \
|
||||
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
|
||||
$(NDSTOOL_FAT)
|
||||
|
||||
$(ELF): $(OBJS)
|
||||
@echo " LD $@"
|
||||
$(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS)
|
||||
|
||||
$(DUMP): $(ELF)
|
||||
@echo " OBJDUMP $@"
|
||||
$(V)$(OBJDUMP) -h -C -S $< > $@
|
||||
|
||||
dump: $(DUMP)
|
||||
|
||||
clean:
|
||||
@echo " CLEAN"
|
||||
$(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE)
|
||||
|
||||
sdimage:
|
||||
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) 0
|
||||
|
||||
dldipatch: $(ROM)
|
||||
@echo " DLDITOOL $(ROM)"
|
||||
$(V)$(BLOCKSDS)/tools/dlditool/dlditool \
|
||||
$(BLOCKSDS)/tools/dldi/r4tfv2.dldi $(ROM)
|
||||
|
||||
# Rules
|
||||
# -----
|
||||
|
||||
$(BUILDDIR)/%.s.o : %.s
|
||||
@echo " AS $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.c.o : %.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.cpp.o : %.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin
|
||||
@echo " BIN2C $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c
|
||||
|
||||
$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
||||
@echo " GRIT $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.h: $(SOURCES_AUDIO)
|
||||
@echo " MMUTIL $^"
|
||||
@$(MKDIR) -p $(@D)
|
||||
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
||||
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKDIR)/soundbank.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKDIR)/soundbank.h
|
||||
@echo " BIN2C soundbank.bin"
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \
|
||||
$(SOUNDBANKDIR)
|
||||
@echo " CC.9 soundbank_bin.c"
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \
|
||||
$(SOUNDBANKDIR)/soundbank_bin.c
|
||||
|
||||
# All assets must be built before the source code
|
||||
# -----------------------------------------------
|
||||
|
||||
$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS)
|
||||
|
||||
# Include dependency files if they exist
|
||||
# --------------------------------------
|
||||
|
||||
-include $(DEPS)
|
||||
|
25
examples/effects/Makefile.blocksds
Normal file
25
examples/effects/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
3
examples/effects/fog/Makefile.blocksds
Normal file
3
examples/effects/fog/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/effects/screen_effects/Makefile.blocksds
Normal file
3
examples/effects/screen_effects/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/effects/specular_material/Makefile.blocksds
Normal file
3
examples/effects/specular_material/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
25
examples/loading/Makefile.blocksds
Normal file
25
examples/loading/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
3
examples/loading/animated_model/Makefile.blocksds
Normal file
3
examples/loading/animated_model/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/loading/clone_models/Makefile.blocksds
Normal file
3
examples/loading/clone_models/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/loading/compressed_texture/Makefile.blocksds
Normal file
3
examples/loading/compressed_texture/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
@ -0,0 +1,3 @@
|
||||
NITROFATDIR := nitrofiles
|
||||
|
||||
include ../../Makefile.example.blocksds
|
@ -0,0 +1,3 @@
|
||||
NITROFATDIR := nitrofiles
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/loading/incomplete_texture/Makefile.blocksds
Normal file
3
examples/loading/incomplete_texture/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/loading/multiple_models/Makefile.blocksds
Normal file
3
examples/loading/multiple_models/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/loading/paletted_texture/Makefile.blocksds
Normal file
3
examples/loading/paletted_texture/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/loading/simple_model/Makefile.blocksds
Normal file
3
examples/loading/simple_model/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
25
examples/other/Makefile.blocksds
Normal file
25
examples/other/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
3
examples/other/blended_animations/Makefile.blocksds
Normal file
3
examples/other/blended_animations/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/clear_bmp/Makefile.blocksds
Normal file
3
examples/other/clear_bmp/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
1
examples/other/error_handling/Makefile.blocksds
Normal file
1
examples/other/error_handling/Makefile.blocksds
Normal file
@ -0,0 +1 @@
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/fps_counter/Makefile.blocksds
Normal file
3
examples/other/fps_counter/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/free_camera/Makefile.blocksds
Normal file
3
examples/other/free_camera/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
1
examples/other/polygon_colored/Makefile.blocksds
Normal file
1
examples/other/polygon_colored/Makefile.blocksds
Normal file
@ -0,0 +1 @@
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/polygon_textured/Makefile.blocksds
Normal file
3
examples/other/polygon_textured/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/swap_3d_dual_screen/Makefile.blocksds
Normal file
3
examples/other/swap_3d_dual_screen/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/swap_3d_single_screen/Makefile.blocksds
Normal file
3
examples/other/swap_3d_single_screen/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/other/touch_test/Makefile.blocksds
Normal file
3
examples/other/touch_test/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
25
examples/physics/Makefile.blocksds
Normal file
25
examples/physics/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
3
examples/physics/basic/Makefile.blocksds
Normal file
3
examples/physics/basic/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/physics/box_tower/Makefile.blocksds
Normal file
3
examples/physics/box_tower/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
3
examples/physics/collision_actions/Makefile.blocksds
Normal file
3
examples/physics/collision_actions/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../Makefile.example.blocksds
|
272
examples/templates/3d_dual_screen/Makefile.blocksds
Normal file
272
examples/templates/3d_dual_screen/Makefile.blocksds
Normal file
@ -0,0 +1,272 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
BLOCKSDS ?= /opt/blocksds/core
|
||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
||||
|
||||
# User config
|
||||
# ===========
|
||||
|
||||
NAME := $(shell basename $(CURDIR))
|
||||
GAME_TITLE := 3D dual screen template
|
||||
GAME_SUBTITLE := Nitro Engine example
|
||||
GAME_AUTHOR := github.com/AntonioND/nitro-engine
|
||||
GAME_ICON := $(BLOCKSDS)/sys/icon.bmp
|
||||
|
||||
# DLDI and internal SD slot of DSi
|
||||
# --------------------------------
|
||||
|
||||
# Root folder of the SD image
|
||||
SDROOT := sdroot
|
||||
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
||||
SDIMAGE := image.bin
|
||||
|
||||
# Source code paths
|
||||
# -----------------
|
||||
|
||||
SOURCEDIRS := source
|
||||
INCLUDEDIRS :=
|
||||
GFXDIRS :=
|
||||
BINDIRS :=
|
||||
AUDIODIRS :=
|
||||
NITROFATDIR :=
|
||||
|
||||
# Defines passed to all files
|
||||
# ---------------------------
|
||||
|
||||
DEFINES :=
|
||||
|
||||
# Libraries
|
||||
# ---------
|
||||
|
||||
LIBS := -lNE -lnds9 -lc
|
||||
LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \
|
||||
$(BLOCKSDS)/libs/libnds
|
||||
|
||||
# Build artifacts
|
||||
# ---------------
|
||||
|
||||
BUILDDIR := build
|
||||
ELF := build/$(NAME).elf
|
||||
DUMP := build/$(NAME).dump
|
||||
NITROFAT_IMG := build/nitrofat.bin
|
||||
MAP := build/$(NAME).map
|
||||
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
||||
ROM := $(NAME).nds
|
||||
|
||||
# Tools
|
||||
# -----
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
MKDIR := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
# Verbose flag
|
||||
# ------------
|
||||
|
||||
ifeq ($(VERBOSE),1)
|
||||
V :=
|
||||
else
|
||||
V := @
|
||||
endif
|
||||
|
||||
# Source files
|
||||
# ------------
|
||||
|
||||
ifneq ($(BINDIRS),)
|
||||
SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS))
|
||||
endif
|
||||
ifneq ($(GFXDIRS),)
|
||||
SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS))
|
||||
endif
|
||||
ifneq ($(AUDIODIRS),)
|
||||
SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)')
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
INCLUDEDIRS += $(SOUNDBANKDIR)
|
||||
endif
|
||||
endif
|
||||
|
||||
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
|
||||
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
|
||||
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
||||
|
||||
# Compiler and linker flags
|
||||
# -------------------------
|
||||
|
||||
DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall
|
||||
|
||||
ifeq ($(SOURCES_CPP),)
|
||||
LD := $(CC)
|
||||
else
|
||||
LD := $(CXX)
|
||||
endif
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
||||
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||
-ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fomit-frame-pointer
|
||||
|
||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fno-exceptions -fno-rtti \
|
||||
-fomit-frame-pointer
|
||||
|
||||
LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \
|
||||
-Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.mem \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.ld \
|
||||
-Wl,--no-warn-rwx-segments \
|
||||
-Wl,--start-group $(LIBS) -lgcc -Wl,--end-group
|
||||
|
||||
# Intermediate build files
|
||||
# ------------------------
|
||||
|
||||
OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o
|
||||
HEADERS_ASSETS += $(SOUNDBANKDIR)/soundbank.h
|
||||
endif
|
||||
|
||||
OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
||||
|
||||
OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES)
|
||||
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Targets
|
||||
# -------
|
||||
|
||||
.PHONY: all clean dump dldipatch sdimage
|
||||
|
||||
all: $(ROM)
|
||||
|
||||
ifneq ($(strip $(NITROFATDIR)),)
|
||||
# Additional arguments for ndstool
|
||||
NDSTOOL_FAT := -F $(NITROFAT_IMG)
|
||||
|
||||
$(NITROFAT_IMG): $(NITROFATDIR)
|
||||
@echo " MKFATIMG $@ $(NITROFATDIR)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(NITROFATDIR) $@ 0
|
||||
|
||||
# Make the NDS ROM depend on the filesystem image only if it is needed
|
||||
$(ROM): $(NITROFAT_IMG)
|
||||
endif
|
||||
|
||||
# Combine the title strings
|
||||
ifeq ($(strip $(GAME_SUBTITLE)),)
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR)
|
||||
else
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR)
|
||||
endif
|
||||
|
||||
$(ROM): $(ELF)
|
||||
@echo " NDSTOOL $@"
|
||||
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
|
||||
-7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \
|
||||
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
|
||||
$(NDSTOOL_FAT)
|
||||
|
||||
$(ELF): $(OBJS)
|
||||
@echo " LD $@"
|
||||
$(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS)
|
||||
|
||||
$(DUMP): $(ELF)
|
||||
@echo " OBJDUMP $@"
|
||||
$(V)$(OBJDUMP) -h -C -S $< > $@
|
||||
|
||||
dump: $(DUMP)
|
||||
|
||||
clean:
|
||||
@echo " CLEAN"
|
||||
$(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE)
|
||||
|
||||
sdimage:
|
||||
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) 0
|
||||
|
||||
dldipatch: $(ROM)
|
||||
@echo " DLDITOOL $(ROM)"
|
||||
$(V)$(BLOCKSDS)/tools/dlditool/dlditool \
|
||||
$(BLOCKSDS)/tools/dldi/r4tfv2.dldi $(ROM)
|
||||
|
||||
# Rules
|
||||
# -----
|
||||
|
||||
$(BUILDDIR)/%.s.o : %.s
|
||||
@echo " AS $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.c.o : %.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.cpp.o : %.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin
|
||||
@echo " BIN2C $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c
|
||||
|
||||
$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
||||
@echo " GRIT $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||
$(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.h: $(SOURCES_AUDIO)
|
||||
@echo " MMUTIL $^"
|
||||
@$(MKDIR) -p $(@D)
|
||||
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
||||
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKDIR)/soundbank.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKDIR)/soundbank.h
|
||||
@echo " BIN2C soundbank.bin"
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \
|
||||
$(SOUNDBANKDIR)
|
||||
@echo " CC.9 soundbank_bin.c"
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \
|
||||
$(SOUNDBANKDIR)/soundbank_bin.c
|
||||
|
||||
# All assets must be built before the source code
|
||||
# -----------------------------------------------
|
||||
|
||||
$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS)
|
||||
|
||||
# Include dependency files if they exist
|
||||
# --------------------------------------
|
||||
|
||||
-include $(DEPS)
|
272
examples/templates/3d_single_screen/Makefile.blocksds
Normal file
272
examples/templates/3d_single_screen/Makefile.blocksds
Normal file
@ -0,0 +1,272 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
BLOCKSDS ?= /opt/blocksds/core
|
||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
||||
|
||||
# User config
|
||||
# ===========
|
||||
|
||||
NAME := $(shell basename $(CURDIR))
|
||||
GAME_TITLE := 3D template
|
||||
GAME_SUBTITLE := Nitro Engine example
|
||||
GAME_AUTHOR := github.com/AntonioND/nitro-engine
|
||||
GAME_ICON := $(BLOCKSDS)/sys/icon.bmp
|
||||
|
||||
# DLDI and internal SD slot of DSi
|
||||
# --------------------------------
|
||||
|
||||
# Root folder of the SD image
|
||||
SDROOT := sdroot
|
||||
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
||||
SDIMAGE := image.bin
|
||||
|
||||
# Source code paths
|
||||
# -----------------
|
||||
|
||||
SOURCEDIRS := source
|
||||
INCLUDEDIRS :=
|
||||
GFXDIRS :=
|
||||
BINDIRS :=
|
||||
AUDIODIRS :=
|
||||
NITROFATDIR :=
|
||||
|
||||
# Defines passed to all files
|
||||
# ---------------------------
|
||||
|
||||
DEFINES :=
|
||||
|
||||
# Libraries
|
||||
# ---------
|
||||
|
||||
LIBS := -lNE -lnds9 -lc
|
||||
LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \
|
||||
$(BLOCKSDS)/libs/libnds
|
||||
|
||||
# Build artifacts
|
||||
# ---------------
|
||||
|
||||
BUILDDIR := build
|
||||
ELF := build/$(NAME).elf
|
||||
DUMP := build/$(NAME).dump
|
||||
NITROFAT_IMG := build/nitrofat.bin
|
||||
MAP := build/$(NAME).map
|
||||
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
||||
ROM := $(NAME).nds
|
||||
|
||||
# Tools
|
||||
# -----
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
MKDIR := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
# Verbose flag
|
||||
# ------------
|
||||
|
||||
ifeq ($(VERBOSE),1)
|
||||
V :=
|
||||
else
|
||||
V := @
|
||||
endif
|
||||
|
||||
# Source files
|
||||
# ------------
|
||||
|
||||
ifneq ($(BINDIRS),)
|
||||
SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS))
|
||||
endif
|
||||
ifneq ($(GFXDIRS),)
|
||||
SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS))
|
||||
endif
|
||||
ifneq ($(AUDIODIRS),)
|
||||
SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)')
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
INCLUDEDIRS += $(SOUNDBANKDIR)
|
||||
endif
|
||||
endif
|
||||
|
||||
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
|
||||
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
|
||||
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
||||
|
||||
# Compiler and linker flags
|
||||
# -------------------------
|
||||
|
||||
DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall
|
||||
|
||||
ifeq ($(SOURCES_CPP),)
|
||||
LD := $(CC)
|
||||
else
|
||||
LD := $(CXX)
|
||||
endif
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
||||
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||
-ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fomit-frame-pointer
|
||||
|
||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fno-exceptions -fno-rtti \
|
||||
-fomit-frame-pointer
|
||||
|
||||
LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \
|
||||
-Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.mem \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.ld \
|
||||
-Wl,--no-warn-rwx-segments \
|
||||
-Wl,--start-group $(LIBS) -lgcc -Wl,--end-group
|
||||
|
||||
# Intermediate build files
|
||||
# ------------------------
|
||||
|
||||
OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o
|
||||
HEADERS_ASSETS += $(SOUNDBANKDIR)/soundbank.h
|
||||
endif
|
||||
|
||||
OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
||||
|
||||
OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES)
|
||||
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Targets
|
||||
# -------
|
||||
|
||||
.PHONY: all clean dump dldipatch sdimage
|
||||
|
||||
all: $(ROM)
|
||||
|
||||
ifneq ($(strip $(NITROFATDIR)),)
|
||||
# Additional arguments for ndstool
|
||||
NDSTOOL_FAT := -F $(NITROFAT_IMG)
|
||||
|
||||
$(NITROFAT_IMG): $(NITROFATDIR)
|
||||
@echo " MKFATIMG $@ $(NITROFATDIR)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(NITROFATDIR) $@ 0
|
||||
|
||||
# Make the NDS ROM depend on the filesystem image only if it is needed
|
||||
$(ROM): $(NITROFAT_IMG)
|
||||
endif
|
||||
|
||||
# Combine the title strings
|
||||
ifeq ($(strip $(GAME_SUBTITLE)),)
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR)
|
||||
else
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR)
|
||||
endif
|
||||
|
||||
$(ROM): $(ELF)
|
||||
@echo " NDSTOOL $@"
|
||||
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
|
||||
-7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \
|
||||
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
|
||||
$(NDSTOOL_FAT)
|
||||
|
||||
$(ELF): $(OBJS)
|
||||
@echo " LD $@"
|
||||
$(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS)
|
||||
|
||||
$(DUMP): $(ELF)
|
||||
@echo " OBJDUMP $@"
|
||||
$(V)$(OBJDUMP) -h -C -S $< > $@
|
||||
|
||||
dump: $(DUMP)
|
||||
|
||||
clean:
|
||||
@echo " CLEAN"
|
||||
$(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE)
|
||||
|
||||
sdimage:
|
||||
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) 0
|
||||
|
||||
dldipatch: $(ROM)
|
||||
@echo " DLDITOOL $(ROM)"
|
||||
$(V)$(BLOCKSDS)/tools/dlditool/dlditool \
|
||||
$(BLOCKSDS)/tools/dldi/r4tfv2.dldi $(ROM)
|
||||
|
||||
# Rules
|
||||
# -----
|
||||
|
||||
$(BUILDDIR)/%.s.o : %.s
|
||||
@echo " AS $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.c.o : %.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.cpp.o : %.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin
|
||||
@echo " BIN2C $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c
|
||||
|
||||
$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
||||
@echo " GRIT $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||
$(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.h: $(SOURCES_AUDIO)
|
||||
@echo " MMUTIL $^"
|
||||
@$(MKDIR) -p $(@D)
|
||||
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
||||
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKDIR)/soundbank.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKDIR)/soundbank.h
|
||||
@echo " BIN2C soundbank.bin"
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \
|
||||
$(SOUNDBANKDIR)
|
||||
@echo " CC.9 soundbank_bin.c"
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \
|
||||
$(SOUNDBANKDIR)/soundbank_bin.c
|
||||
|
||||
# All assets must be built before the source code
|
||||
# -----------------------------------------------
|
||||
|
||||
$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS)
|
||||
|
||||
# Include dependency files if they exist
|
||||
# --------------------------------------
|
||||
|
||||
-include $(DEPS)
|
25
examples/templates/Makefile.blocksds
Normal file
25
examples/templates/Makefile.blocksds
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MAKE := make
|
||||
|
||||
all:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
clean:
|
||||
@for i in `ls`; do \
|
||||
if test -e $$i/Makefile.blocksds ; then \
|
||||
cd $$i; \
|
||||
$(MAKE) -f Makefile.blocksds clean --no-print-directory || { exit 1;}; \
|
||||
cd ..; \
|
||||
fi; \
|
||||
done;
|
273
examples/templates/using_nflib/Makefile.blocksds
Normal file
273
examples/templates/using_nflib/Makefile.blocksds
Normal file
@ -0,0 +1,273 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
BLOCKSDS ?= /opt/blocksds/core
|
||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
||||
|
||||
# User config
|
||||
# ===========
|
||||
|
||||
NAME := $(shell basename $(CURDIR))
|
||||
GAME_TITLE := NFlib + Nitro Engine template
|
||||
GAME_SUBTITLE := Nitro Engine example
|
||||
GAME_AUTHOR := github.com/AntonioND/nitro-engine
|
||||
GAME_ICON := $(BLOCKSDS)/sys/icon.bmp
|
||||
|
||||
# DLDI and internal SD slot of DSi
|
||||
# --------------------------------
|
||||
|
||||
# Root folder of the SD image
|
||||
SDROOT := sdroot
|
||||
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
||||
SDIMAGE := image.bin
|
||||
|
||||
# Source code paths
|
||||
# -----------------
|
||||
|
||||
SOURCEDIRS := source
|
||||
INCLUDEDIRS :=
|
||||
GFXDIRS :=
|
||||
BINDIRS :=
|
||||
AUDIODIRS :=
|
||||
NITROFATDIR := nitrofiles
|
||||
|
||||
# Defines passed to all files
|
||||
# ---------------------------
|
||||
|
||||
DEFINES :=
|
||||
|
||||
# Libraries
|
||||
# ---------
|
||||
|
||||
LIBS := -lNE -lnflib -lnds9 -lc
|
||||
LIBDIRS := $(BLOCKSDSEXT)/nitro-engine \
|
||||
$(BLOCKSDSEXT)/nflib \
|
||||
$(BLOCKSDS)/libs/libnds
|
||||
|
||||
# Build artifacts
|
||||
# ---------------
|
||||
|
||||
BUILDDIR := build
|
||||
ELF := build/$(NAME).elf
|
||||
DUMP := build/$(NAME).dump
|
||||
NITROFAT_IMG := build/nitrofat.bin
|
||||
MAP := build/$(NAME).map
|
||||
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
||||
ROM := $(NAME).nds
|
||||
|
||||
# Tools
|
||||
# -----
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
MKDIR := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
# Verbose flag
|
||||
# ------------
|
||||
|
||||
ifeq ($(VERBOSE),1)
|
||||
V :=
|
||||
else
|
||||
V := @
|
||||
endif
|
||||
|
||||
# Source files
|
||||
# ------------
|
||||
|
||||
ifneq ($(BINDIRS),)
|
||||
SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS))
|
||||
endif
|
||||
ifneq ($(GFXDIRS),)
|
||||
SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS))
|
||||
endif
|
||||
ifneq ($(AUDIODIRS),)
|
||||
SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)')
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
INCLUDEDIRS += $(SOUNDBANKDIR)
|
||||
endif
|
||||
endif
|
||||
|
||||
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
|
||||
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
|
||||
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
||||
|
||||
# Compiler and linker flags
|
||||
# -------------------------
|
||||
|
||||
DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall
|
||||
|
||||
ifeq ($(SOURCES_CPP),)
|
||||
LD := $(CC)
|
||||
else
|
||||
LD := $(CXX)
|
||||
endif
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
||||
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||
-ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fomit-frame-pointer
|
||||
|
||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fno-exceptions -fno-rtti \
|
||||
-fomit-frame-pointer
|
||||
|
||||
LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \
|
||||
-Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.mem \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.ld \
|
||||
-Wl,--no-warn-rwx-segments \
|
||||
-Wl,--start-group $(LIBS) -lgcc -Wl,--end-group
|
||||
|
||||
# Intermediate build files
|
||||
# ------------------------
|
||||
|
||||
OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o
|
||||
HEADERS_ASSETS += $(SOUNDBANKDIR)/soundbank.h
|
||||
endif
|
||||
|
||||
OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
||||
|
||||
OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES)
|
||||
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Targets
|
||||
# -------
|
||||
|
||||
.PHONY: all clean dump dldipatch sdimage
|
||||
|
||||
all: $(ROM)
|
||||
|
||||
ifneq ($(strip $(NITROFATDIR)),)
|
||||
# Additional arguments for ndstool
|
||||
NDSTOOL_FAT := -F $(NITROFAT_IMG)
|
||||
|
||||
$(NITROFAT_IMG): $(NITROFATDIR)
|
||||
@echo " MKFATIMG $@ $(NITROFATDIR)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(NITROFATDIR) $@ 0
|
||||
|
||||
# Make the NDS ROM depend on the filesystem image only if it is needed
|
||||
$(ROM): $(NITROFAT_IMG)
|
||||
endif
|
||||
|
||||
# Combine the title strings
|
||||
ifeq ($(strip $(GAME_SUBTITLE)),)
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR)
|
||||
else
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR)
|
||||
endif
|
||||
|
||||
$(ROM): $(ELF)
|
||||
@echo " NDSTOOL $@"
|
||||
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
|
||||
-7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \
|
||||
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
|
||||
$(NDSTOOL_FAT)
|
||||
|
||||
$(ELF): $(OBJS)
|
||||
@echo " LD $@"
|
||||
$(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS)
|
||||
|
||||
$(DUMP): $(ELF)
|
||||
@echo " OBJDUMP $@"
|
||||
$(V)$(OBJDUMP) -h -C -S $< > $@
|
||||
|
||||
dump: $(DUMP)
|
||||
|
||||
clean:
|
||||
@echo " CLEAN"
|
||||
$(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE)
|
||||
|
||||
sdimage:
|
||||
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE) 0
|
||||
|
||||
dldipatch: $(ROM)
|
||||
@echo " DLDITOOL $(ROM)"
|
||||
$(V)$(BLOCKSDS)/tools/dlditool/dlditool \
|
||||
$(BLOCKSDS)/tools/dldi/r4tfv2.dldi $(ROM)
|
||||
|
||||
# Rules
|
||||
# -----
|
||||
|
||||
$(BUILDDIR)/%.s.o : %.s
|
||||
@echo " AS $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.c.o : %.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.cpp.o : %.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin
|
||||
@echo " BIN2C $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c
|
||||
|
||||
$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
||||
@echo " GRIT $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||
$(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.h: $(SOURCES_AUDIO)
|
||||
@echo " MMUTIL $^"
|
||||
@$(MKDIR) -p $(@D)
|
||||
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
||||
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKDIR)/soundbank.h
|
||||
|
||||
$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKDIR)/soundbank.h
|
||||
@echo " BIN2C soundbank.bin"
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \
|
||||
$(SOUNDBANKDIR)
|
||||
@echo " CC.9 soundbank_bin.c"
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \
|
||||
$(SOUNDBANKDIR)/soundbank_bin.c
|
||||
|
||||
# All assets must be built before the source code
|
||||
# -----------------------------------------------
|
||||
|
||||
$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS)
|
||||
|
||||
# Include dependency files if they exist
|
||||
# --------------------------------------
|
||||
|
||||
-include $(DEPS)
|
76
readme.rst
76
readme.rst
@ -1,13 +1,15 @@
|
||||
###################
|
||||
Nitro Engine v0.8.1
|
||||
===================
|
||||
###################
|
||||
|
||||
Introduction
|
||||
------------
|
||||
============
|
||||
|
||||
This is a 3D game engine, a lot of functions designed to simplify the process of
|
||||
making a 3D game. It isn't standalone, it needs libnds to work. However, if you
|
||||
are developing for the NDS it is likely that you already have it installed. If
|
||||
not, you need to install devkitARM and libnds.
|
||||
making a 3D game. It isn't standalone, it needs libnds to work.
|
||||
|
||||
You may use Nitro Engine with both devkitPro installations, and with `BlocksDS
|
||||
<https://github.com/blocksds/sdk>`_.
|
||||
|
||||
Features:
|
||||
|
||||
@ -31,7 +33,10 @@ to integrate Nitro Engine and NFlib in the same project `here
|
||||
<./examples/templates/using_nflib>`_.
|
||||
|
||||
Setup
|
||||
-----
|
||||
=====
|
||||
|
||||
devkitpro
|
||||
---------
|
||||
|
||||
1. Clone this repository. Create a symbolic link to it inside the devkitPro
|
||||
folder in your system. For example, in Linux, create a symlink so that
|
||||
@ -52,21 +57,48 @@ Setup
|
||||
|
||||
3. If you want to check that everything is working as expected, open one of the
|
||||
folders of the examples and type ``make``. That should build an ``.nds`` file
|
||||
that you can run on an emulator or real hardware. Note that some features of
|
||||
the 3D hardware aren't emulated by most emulators, so you may need to use an
|
||||
actual NDS to test some things. **melonDS** seems to emulate all features
|
||||
correctly. **DeSmuME** doesn't emulate the polygon/vertices count registers,
|
||||
so the touch test feature of Nitro Engine doesn't work.
|
||||
that you can run on an emulator or real hardware.
|
||||
|
||||
4. Normally you should link your programs with ``-lNE``, which is the release
|
||||
version of Nitro Engine. If you want to use the debug features of Nitro
|
||||
Engine, you should link with ``-lNE_debug``, and add ``-DNE_DEBUG`` to the
|
||||
``CFLAGS`` and ``CPPFLAGS`` in your Makefile. Make sure to clean and rebuild
|
||||
your project after doing the changes mentioned in this step. Check the
|
||||
**error_handling** example to see how to use the debug mode of Nitro Engine.
|
||||
BlocksDS
|
||||
--------
|
||||
|
||||
1. Clone this repository and run:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
make -f Makefile.blocksds
|
||||
make -f Makefile.blocksds NE_DEBUG=1
|
||||
make -f Makefile.blocksds install
|
||||
|
||||
This should build the library in both debug and release modes and install it.
|
||||
|
||||
2. If you want to check that everything is working as expected, open one of the
|
||||
folders of the examples and run:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
make -f Makefile.blocksds
|
||||
|
||||
That should build an ``.nds`` file that you can run on an emulator or real
|
||||
hardware.
|
||||
|
||||
Common
|
||||
------
|
||||
|
||||
Note that some features of the 3D hardware aren't emulated by most emulators, so
|
||||
you may need to use an actual NDS to test some things. **melonDS** seems to
|
||||
emulate all features correctly. **DeSmuME** doesn't emulate the polygon/vertices
|
||||
count registers, so the touch test feature of Nitro Engine doesn't work.
|
||||
|
||||
Normally you should link your programs with ``-lNE``, which is the release
|
||||
version of Nitro Engine. If you want to use the debug features of Nitro Engine,
|
||||
you should link with ``-lNE_debug``, and add ``-DNE_DEBUG`` to the ``CFLAGS``
|
||||
and ``CPPFLAGS`` in your Makefile. Make sure to clean and rebuild your project
|
||||
after doing the changes mentioned in this step. Check the **error_handling**
|
||||
example to see how to use the debug mode of Nitro Engine.
|
||||
|
||||
Screenshots
|
||||
-----------
|
||||
===========
|
||||
|
||||
Screenshots of some of the examples included with Nitro Engine:
|
||||
|
||||
@ -96,7 +128,7 @@ Screenshots of some of the examples included with Nitro Engine:
|
||||
+------------------+-------------------+
|
||||
|
||||
Contact
|
||||
-------
|
||||
=======
|
||||
|
||||
This project is currently hosted on GitHub at:
|
||||
|
||||
@ -107,7 +139,7 @@ If you want to contact me (Antonio Niño Díaz) directly you can email me at:
|
||||
antonio underscore nd at outlook dot com
|
||||
|
||||
License
|
||||
-------
|
||||
=======
|
||||
|
||||
The code of this repository is under the MIT license. The examples are under the
|
||||
CC0-1.0 license.
|
||||
@ -115,13 +147,13 @@ CC0-1.0 license.
|
||||
The full text of the licenses can be found under the ``licenses`` folder.
|
||||
|
||||
Future work
|
||||
-----------
|
||||
===========
|
||||
|
||||
- Asynchronous loading of assets.
|
||||
- Support for compressed textures.
|
||||
|
||||
Thanks to
|
||||
---------
|
||||
=========
|
||||
|
||||
- **devkitPro**: https://devkitpro.org/
|
||||
- **libnds**: https://github.com/devkitPro/libnds
|
||||
|
1
tests/allocator/Makefile.blocksds
Normal file
1
tests/allocator/Makefile.blocksds
Normal file
@ -0,0 +1 @@
|
||||
include ../../examples/Makefile.example.blocksds
|
3
tests/clone_materials/Makefile.blocksds
Normal file
3
tests/clone_materials/Makefile.blocksds
Normal file
@ -0,0 +1,3 @@
|
||||
BINDIRS := data
|
||||
|
||||
include ../../examples/Makefile.example.blocksds
|
Loading…
Reference in New Issue
Block a user