Compare commits
133 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8932de1fff | ||
![]() |
86955bc0a0 | ||
![]() |
6e1dca996c | ||
![]() |
02f3cd7012 | ||
![]() |
926bb4f361 | ||
![]() |
f6b0200be3 | ||
![]() |
d42cb2c08e | ||
![]() |
d52a92812e | ||
![]() |
cb2e62f953 | ||
![]() |
5a10679dfb | ||
![]() |
b67c60d5f0 | ||
![]() |
fff1a65647 | ||
![]() |
efbf4b6546 | ||
![]() |
dd20800334 | ||
![]() |
39117696aa | ||
![]() |
459d8f8960 | ||
![]() |
e5ae245674 | ||
![]() |
8a18dfa586 | ||
![]() |
de9ca58286 | ||
![]() |
446e27110e | ||
![]() |
09c3712431 | ||
![]() |
a6738a9ab5 | ||
![]() |
afdd56eda4 | ||
![]() |
fe6e4a0dcc | ||
![]() |
4642bdf982 | ||
![]() |
26823c024f | ||
![]() |
5a4824f461 | ||
![]() |
de16a59722 | ||
![]() |
4115a62800 | ||
![]() |
88d1b489f6 | ||
![]() |
7d13c2d637 | ||
![]() |
5dda97fe52 | ||
![]() |
c2af70fe15 | ||
![]() |
dce5e99f0f | ||
![]() |
1c752174e9 | ||
![]() |
935f7eb084 | ||
![]() |
0f92fc9da7 | ||
![]() |
3f4bfbdb25 | ||
![]() |
b52b704000 | ||
![]() |
902314a2ac | ||
![]() |
3ba35ba48e | ||
![]() |
381e4071ac | ||
![]() |
ccb3739f98 | ||
![]() |
230a65541e | ||
![]() |
7dda3abe54 | ||
![]() |
3f3e266a4f | ||
![]() |
5ce71a9b02 | ||
![]() |
12b7389d1f | ||
![]() |
48ff37231f | ||
![]() |
ff734036fc | ||
![]() |
d7ecc5cc4d | ||
![]() |
5ea29c4f81 | ||
![]() |
b40f67c593 | ||
![]() |
8cb10264bb | ||
![]() |
cf1a3c48e2 | ||
![]() |
b0d9151455 | ||
![]() |
82171bbf69 | ||
![]() |
47c8061168 | ||
![]() |
9f81541075 | ||
![]() |
a06617a93f | ||
![]() |
fc73687b79 | ||
![]() |
052a15b974 | ||
![]() |
bf63ddea8a | ||
![]() |
636a7d73c3 | ||
![]() |
521012d4d1 | ||
![]() |
15ce18b74c | ||
![]() |
dd746c0ef5 | ||
![]() |
a49ddecda7 | ||
![]() |
30ac9ab8e9 | ||
![]() |
edf4457d49 | ||
![]() |
e952990ae4 | ||
![]() |
3273bd7333 | ||
![]() |
c22fa167e7 | ||
![]() |
5a2b722128 | ||
![]() |
227bffddc5 | ||
![]() |
a85b16284f | ||
![]() |
006bcf9d01 | ||
![]() |
366a9532c1 | ||
![]() |
719935647a | ||
![]() |
e94ed5b4e3 | ||
![]() |
935c06e296 | ||
![]() |
c0d41eabff | ||
![]() |
9c62fbf0f2 | ||
![]() |
9c3bb283cc | ||
![]() |
3e6af44b1b | ||
![]() |
9fd31b81ad | ||
![]() |
50e14b2c21 | ||
![]() |
951f0f87ca | ||
![]() |
e7fc9f8203 | ||
![]() |
a7f8353bac | ||
![]() |
3af40682cb | ||
![]() |
b00a4f29b8 | ||
![]() |
25fc0bcff3 | ||
![]() |
83dd805fe8 | ||
![]() |
4d0066465e | ||
![]() |
91abea3e87 | ||
![]() |
a44073e9ce | ||
![]() |
cf12e3d51d | ||
![]() |
441997c50c | ||
![]() |
d432916f0a | ||
![]() |
488f5c7d8f | ||
![]() |
33f9bd4416 | ||
![]() |
9ce79478e0 | ||
![]() |
1a29d63a6d | ||
![]() |
83928fd8aa | ||
![]() |
1c58dd09ed | ||
![]() |
55a53a91dc | ||
![]() |
c037b79af4 | ||
![]() |
c8324ca1b9 | ||
![]() |
1d0b3058aa | ||
![]() |
8e6d64d2d9 | ||
![]() |
640d2441f6 | ||
![]() |
fb503d5972 | ||
![]() |
5fbe47c7fc | ||
![]() |
a57af044f4 | ||
![]() |
142e1662b6 | ||
![]() |
65b4eb55a3 | ||
![]() |
0a7db208da | ||
![]() |
bacb1d1811 | ||
![]() |
eca99150c4 | ||
![]() |
9a5c6dfa67 | ||
![]() |
e6e27fed0a | ||
![]() |
36957b04ab | ||
![]() |
53a382e8ac | ||
![]() |
f885f25bfb | ||
![]() |
2ec91e1100 | ||
![]() |
d03ccfddd5 | ||
![]() |
2d7a71a056 | ||
![]() |
7cd5d3999c | ||
![]() |
76dc2f9901 | ||
![]() |
6fde18d712 | ||
![]() |
ec72c4080d | ||
![]() |
88e222c756 |
79
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
#
|
||||||
|
# SPDX-FileContributor: Antonio Niño Díaz, 2025
|
||||||
|
|
||||||
|
name: Documentation
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
paths-ignore:
|
||||||
|
- '**.rst'
|
||||||
|
- 'examples'
|
||||||
|
- 'licenses'
|
||||||
|
- 'Makefile*'
|
||||||
|
- 'source*'
|
||||||
|
- 'tests'
|
||||||
|
- 'tools'
|
||||||
|
workflow_dispatch:
|
||||||
|
repository_dispatch:
|
||||||
|
types: [run_build]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
generate_website:
|
||||||
|
name: Generate website
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone project
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: 'master'
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get install doxygen
|
||||||
|
|
||||||
|
- name: Build documentation
|
||||||
|
run: |
|
||||||
|
cd documentation
|
||||||
|
bash generate.sh
|
||||||
|
|
||||||
|
# Create tarball with everything to upload to GitHub pages
|
||||||
|
cd html
|
||||||
|
tar -cvf ../../repo.tar ./*
|
||||||
|
|
||||||
|
- name: Upload repo artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: github-pages
|
||||||
|
path: repo.tar
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
publish_repo:
|
||||||
|
name: Publish website with GitHub pages
|
||||||
|
if: contains(github.ref,'refs/heads/master')
|
||||||
|
needs: [generate_website]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup Pages
|
||||||
|
uses: actions/configure-pages@v5
|
||||||
|
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
146
Makefile
@ -1,139 +1,23 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
.SUFFIXES:
|
#
|
||||||
#---------------------------------------------------------------------------------
|
# SPDX-FileContributor: Antonio Niño Díaz, 2024
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
# Tools
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
# -----
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
MAKE := make
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
# Targets
|
||||||
# TARGET is the name of the output
|
# -------
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# DATA is a list of directories containing data files
|
|
||||||
# INCLUDES is a list of directories containing header files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
SOURCES := source source/dsma
|
|
||||||
DATA := data
|
|
||||||
INCLUDES := include
|
|
||||||
|
|
||||||
ifeq ($(NE_DEBUG),1)
|
.PHONY: all install clean
|
||||||
TARGET := NE_debug
|
|
||||||
BUILD := build_debug
|
|
||||||
else
|
|
||||||
TARGET := NE
|
|
||||||
BUILD := build_release
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
all:
|
||||||
# options for code generation
|
$(MAKE) -f Makefile.blocksds
|
||||||
#---------------------------------------------------------------------------------
|
$(MAKE) -f Makefile.blocksds NE_DEBUG=1
|
||||||
ARCH := -mthumb -mthumb-interwork
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O2\
|
install: all
|
||||||
-march=armv5te -mtune=arm946e-s \
|
$(MAKE) -f Makefile.blocksds install
|
||||||
-fomit-frame-pointer -ffast-math \
|
|
||||||
$(ARCH) -Wno-address-of-packed-member
|
|
||||||
|
|
||||||
ifeq ($(NE_DEBUG),1)
|
|
||||||
CFLAGS += -DNE_DEBUG
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS :=
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
|
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
|
||||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean all
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
all: $(BUILD)
|
|
||||||
|
|
||||||
lib:
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
|
|
||||||
$(BUILD): lib
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
clean:
|
||||||
@echo clean ...
|
$(MAKE) -f Makefile.blocksds clean
|
||||||
@rm -fr build_debug build_release lib
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT) : $(OFILES)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
|
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -12,7 +12,7 @@ ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
SOURCEDIRS := source
|
SOURCEDIRS := source
|
||||||
INCLUDEDIRS := include
|
INCLUDEDIRS := include source/libdsf
|
||||||
GFXDIRS :=
|
GFXDIRS :=
|
||||||
BINDIRS :=
|
BINDIRS :=
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ ARCHIVE := lib/lib$(NAME).a
|
|||||||
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
|
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
|
||||||
CC := $(PREFIX)gcc
|
CC := $(PREFIX)gcc
|
||||||
CXX := $(PREFIX)g++
|
CXX := $(PREFIX)g++
|
||||||
AR := ar
|
AR := $(PREFIX)ar
|
||||||
MKDIR := mkdir
|
MKDIR := mkdir
|
||||||
RM := rm -rf
|
RM := rm -rf
|
||||||
CP := cp
|
CP := cp
|
||||||
@ -92,16 +92,16 @@ WARNFLAGS := -Wall -Wno-address-of-packed-member
|
|||||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||||
|
|
||||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
ASFLAGS += -g -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||||
-ffunction-sections -fdata-sections
|
-ffunction-sections -fdata-sections
|
||||||
|
|
||||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
CFLAGS += -g -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||||
-ffunction-sections -fdata-sections \
|
-ffunction-sections -fdata-sections \
|
||||||
-fomit-frame-pointer
|
-fomit-frame-pointer
|
||||||
|
|
||||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
CXXFLAGS += -g -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||||
-ffunction-sections -fdata-sections \
|
-ffunction-sections -fdata-sections \
|
||||||
-fno-exceptions -fno-rtti \
|
-fno-exceptions -fno-rtti \
|
||||||
@ -139,8 +139,15 @@ $(ARCHIVE): $(OBJS)
|
|||||||
install: all
|
install: all
|
||||||
@echo " INSTALL $(BLOCKSDSEXT)/$(INSTALLNAME)/"
|
@echo " INSTALL $(BLOCKSDSEXT)/$(INSTALLNAME)/"
|
||||||
$(V)$(RM) $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
$(V)$(RM) $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
||||||
$(V)$(INSTALL) -d $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
$(V)$(INSTALL) -d $(BLOCKSDSEXT)/$(INSTALLNAME)/ \
|
||||||
|
$(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds \
|
||||||
|
$(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma \
|
||||||
|
$(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl
|
||||||
$(V)$(CP) -r include lib $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
$(V)$(CP) -r include lib $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
||||||
|
$(V)$(CP) -r tools/img2ds/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds
|
||||||
|
$(V)$(CP) -r tools/md5_to_dsma/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma
|
||||||
|
$(V)$(CP) -r tools/obj2dl/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl
|
||||||
|
$(V)$(CP) -r licenses $(BLOCKSDSEXT)/$(INSTALLNAME)/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo " CLEAN"
|
@echo " CLEAN"
|
||||||
|
123
changelog.rst
@ -1,6 +1,123 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Version 0.15.3 (2025-03-26)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- The devkitARM makefiles have been removed as they only work with old versions
|
||||||
|
of devkitARM, which aren't supported by its maintainers. The code and examples
|
||||||
|
of Nitro Engine will probably need changes to work with current devkitARM.
|
||||||
|
- The GRF files used in an example have been updated, they were built before the
|
||||||
|
format was changed.
|
||||||
|
- The build scripts for assets have been modified to use the value of the
|
||||||
|
environment variables ``BLOCKSDS`` and ``BLOCKSDSEXT`` if they are found.
|
||||||
|
- Build library with debug symbols to help debug applications that use it.
|
||||||
|
|
||||||
|
Version 0.15.2 (2025-01-15)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Fix `ar` binary used to build the library.
|
||||||
|
- Update documentation.
|
||||||
|
- Fix build of examples in devkitARM.
|
||||||
|
- Improve setup instructions.
|
||||||
|
|
||||||
|
Version 0.15.1 (2024-12-23)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Install licenses with the rest of the library.
|
||||||
|
- Clarify some comments in examples.
|
||||||
|
|
||||||
|
Version 0.15.0 (2024-12-01)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Allow users to specify the transformation matrix of a model manually.
|
||||||
|
- Fix a devkitARM Makefile in an example.
|
||||||
|
|
||||||
|
Version 0.14.0 (2024-09-10)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Use ``stdint.h`` types instead of libnds types.
|
||||||
|
- Update BlocksDS makefiles.
|
||||||
|
- Update libdsf to v0.1.3.
|
||||||
|
- Fix some memory leaks/use-after-free bugs in the RichText module.
|
||||||
|
|
||||||
|
Version 0.13.0 (2024-06-08)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Define BlocksDS as the main toolchain to use with Nitro Engine.
|
||||||
|
- Simplify build and installation instructions of the library.
|
||||||
|
- Update ``md5_2_dsma`` to correctly export the base animation of models.
|
||||||
|
- Stop using ``NE_RGB5`` in the examples, this format is discouraged.
|
||||||
|
- Optimize copy of ``NE_RGB5`` textures to VRAM.
|
||||||
|
|
||||||
|
Version 0.12.0 (2024-03-30)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Deprecate ``NE_ShadingEnable()``. The name was misleading. All examples that
|
||||||
|
use it have stopped calling it.
|
||||||
|
- For sprites, add a way to specify texture coordinates inside the material to
|
||||||
|
use a small part of the texture instead of the whole texture:
|
||||||
|
``NE_SpriteSetMaterialCanvas()``. This is now used in the sprites example.
|
||||||
|
- Stop using global variables in most examples. Instead, the rendering functions
|
||||||
|
get values through the arguments of ``NE_ProcessArg()`` and
|
||||||
|
``NE_ProcessDualArg()``.
|
||||||
|
- Don't expect palette objects when loading GRF files if the file doesn't
|
||||||
|
contain a palette.
|
||||||
|
- Allow loading BMFont fonts from RAM, not just nitroFS. Add an example of
|
||||||
|
using rich text fonts from RAM.
|
||||||
|
- Added a function to reset the rich text font system. Also add a function to
|
||||||
|
return the size that a specific text string would have if drawn.
|
||||||
|
- Add shadow volume example.
|
||||||
|
- Build some functions that do lots of multiplications as ARM to increase
|
||||||
|
performance.
|
||||||
|
- Fix compilation with devkitARM.
|
||||||
|
- Fix linker invocation for C++ with BlocksDS.
|
||||||
|
- Update libDSF to version 0.1.2, with some speed improvements.
|
||||||
|
- Relicensed libDSF under "Zlib OR MIT" to simplify licensing with Nitro Engine.
|
||||||
|
- Some minor documentation improvements.
|
||||||
|
|
||||||
|
Version 0.11.0 (2024-03-02)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Added a rich text system. This allows the user to draw non-monospaced text,
|
||||||
|
and it's based on `BMFont <https://www.angelcode.com/products/bmfont/>`_. An
|
||||||
|
example has been added to show how to use it to render text. It can render
|
||||||
|
text by using one quad per character, or by rendering to a texture which is
|
||||||
|
then drawn as a single quad.
|
||||||
|
- Fix "properties" typo. This involves renaming some functions, but compatibilty
|
||||||
|
definitions have been added.
|
||||||
|
- Update calls to GRF libnds functions after their prototypes have changed.
|
||||||
|
- Cleanup setup of dual 3D modes that involve setting up 2D sprites to be used
|
||||||
|
as a framebuffer.
|
||||||
|
- Now the size of a sprite is set to the size of the material it is assigned. It
|
||||||
|
can be modified later as usual.
|
||||||
|
|
||||||
|
Version 0.10.0 (2024-01-28)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
- Create variants of ``NE_Process()`` and ``NE_ProcessDual()`` that can pass an
|
||||||
|
argument to the screen draw callbacks.
|
||||||
|
|
||||||
|
- Add function to load textures in GRF format (BlocksDS only).
|
||||||
|
|
||||||
|
- Add functions to load compressed textures (Texel 4x4 format).
|
||||||
|
|
||||||
|
- Add examples to load assets from the filesystem, both in binary and GRF
|
||||||
|
function.
|
||||||
|
|
||||||
|
- Cleanup code style: Use stdint types, turn some functions ``static inline``...
|
||||||
|
|
||||||
|
- Remove unneeded call to ``DC_FlushAll()``.
|
||||||
|
|
||||||
|
- ``obj2dl``: Improve error message. Fix vertical coordinates being flipped.
|
||||||
|
|
||||||
|
- ``img2ds``: Deprecate it except for generating ``DEPTHBMP`` binaries.
|
||||||
|
|
||||||
|
- The makefile for BlocksDS now installs the tools to ``/opt/blockds/external``,
|
||||||
|
not only the library and headers.
|
||||||
|
|
||||||
|
- Migrate all examples to using ``grit`` instead of ``img2ds``.
|
||||||
|
|
||||||
Version 0.9.1 (2023-11-12)
|
Version 0.9.1 (2023-11-12)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@ -170,9 +287,9 @@ Version 0.6.0 (2009-6-30)
|
|||||||
- The functions used to modify textures and palettes now return a pointer to the
|
- The functions used to modify textures and palettes now return a pointer to the
|
||||||
data so that you can modify them easily.
|
data so that you can modify them easily.
|
||||||
|
|
||||||
- Each material can have different propierties (amient, diffuse...). You can set
|
- Each material can have different properties (amient, diffuse...). You can set
|
||||||
the default ones, the propierties each new material will have, and then you
|
the default ones, the properties each new material will have, and then you
|
||||||
can set each material's propierties individually.
|
can set each material's properties individually.
|
||||||
|
|
||||||
- New texture and palette allocation system, it is faster and better.
|
- New texture and palette allocation system, it is faster and better.
|
||||||
Defragmenting functions don't work now, but I'll fix them for the next
|
Defragmenting functions don't work now, but I'll fix them for the next
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
SUBDIRS:= `ls`
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
#
|
||||||
|
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
MAKE := make
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
@for i in `ls`; do \
|
||||||
|
if test -e $$i/Makefile ; then \
|
||||||
|
cd $$i; \
|
||||||
|
$(MAKE) --no-print-directory || exit 1 ; \
|
||||||
|
cd ..; \
|
||||||
|
fi; \
|
||||||
|
done;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
@for i in `ls`; do \
|
||||||
|
if test -e $$i/Makefile ; then \
|
||||||
|
cd $$i; \
|
||||||
|
$(MAKE) clean --no-print-directory || exit 1 ; \
|
||||||
|
cd ..; \
|
||||||
|
fi; \
|
||||||
|
done;
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
# 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;
|
|
@ -1,220 +1,6 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
GFXDIRS := graphics
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,25 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
mkdir -p data
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/button.png \
|
|
||||||
--name button \
|
|
||||||
--output data \
|
|
||||||
--format PAL256
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/empty.png \
|
|
||||||
--name empty \
|
|
||||||
--output data \
|
|
||||||
--format PAL256
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/true.png \
|
|
||||||
--name true \
|
|
||||||
--output data \
|
|
||||||
--format PAL256
|
|
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 678 B |
Before Width: | Height: | Size: 882 B |
2
examples/2d_system/gui/graphics/button.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 256 color palette
|
||||||
|
-gx -gb -gB8 -gTFF00FF
|
BIN
examples/2d_system/gui/graphics/button.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
2
examples/2d_system/gui/graphics/empty.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 256 color palette
|
||||||
|
-gx -gb -gB8 -gTFF00FF
|
BIN
examples/2d_system/gui/graphics/empty.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
2
examples/2d_system/gui/graphics/true.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 256 color palette
|
||||||
|
-gx -gb -gB8 -gTFF00FF
|
BIN
examples/2d_system/gui/graphics/true.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
@ -1,17 +1,14 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2022
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
#include <NEMain.h>
|
#include <NEMain.h>
|
||||||
|
|
||||||
#include "button_tex_bin.h"
|
#include "button.h"
|
||||||
#include "button_pal_bin.h"
|
#include "empty.h"
|
||||||
#include "empty_tex_bin.h"
|
#include "true.h"
|
||||||
#include "empty_pal_bin.h"
|
|
||||||
#include "true_tex_bin.h"
|
|
||||||
#include "true_pal_bin.h"
|
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene(void)
|
||||||
{
|
{
|
||||||
@ -19,7 +16,7 @@ void Draw3DScene(void)
|
|||||||
NE_GUIDraw();
|
NE_GUIDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
@ -50,20 +47,20 @@ int main(void)
|
|||||||
|
|
||||||
NE_MaterialTexLoad(ButtonImg, NE_PAL256, 64, 64,
|
NE_MaterialTexLoad(ButtonImg, NE_PAL256, 64, 64,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
||||||
(void *)button_tex_bin);
|
buttonBitmap);
|
||||||
NE_PaletteLoad(ButtonPal, (void *)button_pal_bin, 256, NE_PAL256);
|
NE_PaletteLoad(ButtonPal, buttonPal, 256, NE_PAL256);
|
||||||
NE_MaterialSetPalette(ButtonImg, ButtonPal);
|
NE_MaterialSetPalette(ButtonImg, ButtonPal);
|
||||||
|
|
||||||
NE_MaterialTexLoad(EmptyImg, NE_PAL256, 64, 64,
|
NE_MaterialTexLoad(EmptyImg, NE_PAL256, 64, 64,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
||||||
(void *)empty_tex_bin);
|
emptyBitmap);
|
||||||
NE_PaletteLoad(EmptyPal, (void *)empty_pal_bin, 256, NE_PAL256);
|
NE_PaletteLoad(EmptyPal, emptyPal, 256, NE_PAL256);
|
||||||
NE_MaterialSetPalette(EmptyImg, EmptyPal);
|
NE_MaterialSetPalette(EmptyImg, EmptyPal);
|
||||||
|
|
||||||
NE_MaterialTexLoad(TrueImg, NE_PAL256, 64, 64,
|
NE_MaterialTexLoad(TrueImg, NE_PAL256, 64, 64,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
||||||
(void *)true_tex_bin);
|
trueBitmap);
|
||||||
NE_PaletteLoad(TruePal, (void *)true_pal_bin, 256, NE_PAL256);
|
NE_PaletteLoad(TruePal, truePal, 256, NE_PAL256);
|
||||||
NE_MaterialSetPalette(TrueImg, TruePal);
|
NE_MaterialSetPalette(TrueImg, TruePal);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,220 +1,6 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
GFXDIRS := graphics
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
mkdir -p data
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/s8.png \
|
|
||||||
--name s8 \
|
|
||||||
--output data \
|
|
||||||
--format PAL16
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/s16.png \
|
|
||||||
--name s16 \
|
|
||||||
--output data \
|
|
||||||
--format PAL16
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/s64.png \
|
|
||||||
--name s64 \
|
|
||||||
--output data \
|
|
||||||
--format PAL16
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/s256.png \
|
|
||||||
--name s256 \
|
|
||||||
--output data \
|
|
||||||
--format PAL16
|
|
@ -1 +0,0 @@
|
|||||||
!!1DD1DDA`&A`&A6eA6eA&`A&`Ae6Ae6!DD!DD11!!1DD1DDA`&A`&A6eA6eA&`A&`Ae6Ae6!DD!DD11
|
|
@ -1 +0,0 @@
|
|||||||
!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111!!!!!!!!1DD1DD1DD1DD1DD1DD1DD1DDA`&A`&A`&A`&A`&A`&A`&A`&A6eA6eA6eA6eA6eA6eA6eA6eA&`A&`A&`A&`A&`A&`A&`A&`Ae6Ae6Ae6Ae6Ae6Ae6Ae6Ae6!DD!DD!DD!DD!DD!DD!DD!DD11111111
|
|
@ -1 +0,0 @@
|
|||||||
!1DDA`&A6eA&`Ae6!DD1
|
|
2
examples/2d_system/quad_texture_sizes/graphics/s16.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 16 color palette
|
||||||
|
-gx -gb -gB4 -gTFF00FF
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B |
2
examples/2d_system/quad_texture_sizes/graphics/s256.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 16 color palette
|
||||||
|
-gx -gb -gB4 -gTFF00FF
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
2
examples/2d_system/quad_texture_sizes/graphics/s64.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 16 color palette
|
||||||
|
-gx -gb -gB4 -gTFF00FF
|
Before Width: | Height: | Size: 678 B After Width: | Height: | Size: 678 B |
2
examples/2d_system/quad_texture_sizes/graphics/s8.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 16 color palette
|
||||||
|
-gx -gb -gB4 -gTFF00FF
|
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
@ -13,20 +13,20 @@
|
|||||||
|
|
||||||
#include <NEMain.h>
|
#include <NEMain.h>
|
||||||
|
|
||||||
#include "s8_tex_bin.h"
|
#include "s8.h"
|
||||||
#include "s8_pal_bin.h"
|
#include "s16.h"
|
||||||
#include "s16_tex_bin.h"
|
#include "s64.h"
|
||||||
#include "s16_pal_bin.h"
|
#include "s256.h"
|
||||||
#include "s64_tex_bin.h"
|
|
||||||
#include "s64_pal_bin.h"
|
|
||||||
#include "s256_tex_bin.h"
|
|
||||||
#include "s256_pal_bin.h"
|
|
||||||
|
|
||||||
NE_Material *Material_s8, *Material_s16, *Material_s64, *Material_s256;
|
typedef struct {
|
||||||
NE_Palette *Palette_s8, *Palette_s16, *Palette_s64, *Palette_s256;
|
NE_Material *Material_s8, *Material_s16, *Material_s64, *Material_s256;
|
||||||
|
NE_Palette *Palette_s8, *Palette_s16, *Palette_s64, *Palette_s256;
|
||||||
|
} SceneData;
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
NE_ClearColorSet(NE_DarkGray, 31, 63);
|
NE_ClearColorSet(NE_DarkGray, 31, 63);
|
||||||
|
|
||||||
NE_2DViewInit();
|
NE_2DViewInit();
|
||||||
@ -34,27 +34,29 @@ void Draw3DScene(void)
|
|||||||
// Texture scaled from 64x64 to 128x128
|
// Texture scaled from 64x64 to 128x128
|
||||||
NE_2DDrawTexturedQuad(10, 10,
|
NE_2DDrawTexturedQuad(10, 10,
|
||||||
10 + 128, 10 + 128,
|
10 + 128, 10 + 128,
|
||||||
2, Material_s64);
|
2, Scene->Material_s64);
|
||||||
|
|
||||||
// Texture scaled from 8x8 to 32x32
|
// Texture scaled from 8x8 to 32x32
|
||||||
NE_2DDrawTexturedQuad(150, 10,
|
NE_2DDrawTexturedQuad(150, 10,
|
||||||
150 + 32, 10 + 32,
|
150 + 32, 10 + 32,
|
||||||
0, Material_s8);
|
0, Scene->Material_s8);
|
||||||
|
|
||||||
// Texture not scaled
|
// Texture not scaled
|
||||||
NE_2DDrawTexturedQuad(160, 50,
|
NE_2DDrawTexturedQuad(160, 50,
|
||||||
160 + 64, 50 + 64,
|
160 + 64, 50 + 64,
|
||||||
10, Material_s64);
|
10, Scene->Material_s64);
|
||||||
|
|
||||||
|
|
||||||
// Texture scaled from 16x16 to 64x64
|
// Texture scaled from 16x16 to 64x64
|
||||||
NE_2DDrawTexturedQuad(150, 120,
|
NE_2DDrawTexturedQuad(150, 120,
|
||||||
150 + 64, 120 + 64,
|
150 + 64, 120 + 64,
|
||||||
1, Material_s16);
|
1, Scene->Material_s16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw3DScene2(void)
|
void Draw3DScene2(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
NE_ClearColorSet(NE_Magenta, 31, 63);
|
NE_ClearColorSet(NE_Magenta, 31, 63);
|
||||||
|
|
||||||
NE_2DViewInit();
|
NE_2DViewInit();
|
||||||
@ -62,55 +64,57 @@ void Draw3DScene2(void)
|
|||||||
// Texture not scaled
|
// Texture not scaled
|
||||||
NE_2DDrawTexturedQuad(-10, -70,
|
NE_2DDrawTexturedQuad(-10, -70,
|
||||||
-10 + 256, -70 + 256,
|
-10 + 256, -70 + 256,
|
||||||
3, Material_s256);
|
3, Scene->Material_s256);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
SceneData Scene = { 0 };
|
||||||
|
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
irqSet(IRQ_HBLANK, NE_HBLFunc);
|
irqSet(IRQ_HBLANK, NE_HBLFunc);
|
||||||
|
|
||||||
NE_InitDual3D();
|
NE_InitDual3D();
|
||||||
|
|
||||||
Material_s8 = NE_MaterialCreate();
|
Scene.Material_s8 = NE_MaterialCreate();
|
||||||
Material_s16 = NE_MaterialCreate();
|
Scene.Material_s16 = NE_MaterialCreate();
|
||||||
Material_s64 = NE_MaterialCreate();
|
Scene.Material_s64 = NE_MaterialCreate();
|
||||||
Material_s256 = NE_MaterialCreate();
|
Scene.Material_s256 = NE_MaterialCreate();
|
||||||
|
|
||||||
Palette_s8 = NE_PaletteCreate();
|
Scene.Palette_s8 = NE_PaletteCreate();
|
||||||
Palette_s16 = NE_PaletteCreate();
|
Scene.Palette_s16 = NE_PaletteCreate();
|
||||||
Palette_s64 = NE_PaletteCreate();
|
Scene.Palette_s64 = NE_PaletteCreate();
|
||||||
Palette_s256 = NE_PaletteCreate();
|
Scene.Palette_s256 = NE_PaletteCreate();
|
||||||
|
|
||||||
NE_MaterialTexLoad(Material_s8, NE_PAL16, 8, 8,
|
NE_MaterialTexLoad(Scene.Material_s8, NE_PAL16, 8, 8,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
||||||
(void *)s8_tex_bin);
|
s8Bitmap);
|
||||||
NE_MaterialTexLoad(Material_s16, NE_PAL16, 16, 16,
|
NE_MaterialTexLoad(Scene.Material_s16, NE_PAL16, 16, 16,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
||||||
(void *)s16_tex_bin);
|
s16Bitmap);
|
||||||
NE_MaterialTexLoad(Material_s64, NE_PAL16, 64, 64,
|
NE_MaterialTexLoad(Scene.Material_s64, NE_PAL16, 64, 64,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
||||||
(void *)s64_tex_bin);
|
s64Bitmap);
|
||||||
NE_MaterialTexLoad(Material_s256, NE_PAL16, 256, 256,
|
NE_MaterialTexLoad(Scene.Material_s256, NE_PAL16, 256, 256,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
||||||
(void *)s256_tex_bin);
|
s256Bitmap);
|
||||||
|
|
||||||
NE_PaletteLoad(Palette_s8, (u16 *)s8_pal_bin, 16, NE_PAL16);
|
NE_PaletteLoad(Scene.Palette_s8, s8Pal, 16, NE_PAL16);
|
||||||
NE_PaletteLoad(Palette_s16, (u16 *)s16_pal_bin, 16, NE_PAL16);
|
NE_PaletteLoad(Scene.Palette_s16, s16Pal, 16, NE_PAL16);
|
||||||
NE_PaletteLoad(Palette_s64, (u16 *)s64_pal_bin, 16, NE_PAL16);
|
NE_PaletteLoad(Scene.Palette_s64, s64Pal, 16, NE_PAL16);
|
||||||
NE_PaletteLoad(Palette_s256, (u16 *)s256_pal_bin, 16, NE_PAL16);
|
NE_PaletteLoad(Scene.Palette_s256, s256Pal, 16, NE_PAL16);
|
||||||
|
|
||||||
NE_MaterialSetPalette(Material_s8, Palette_s8);
|
NE_MaterialSetPalette(Scene.Material_s8, Scene.Palette_s8);
|
||||||
NE_MaterialSetPalette(Material_s16, Palette_s16);
|
NE_MaterialSetPalette(Scene.Material_s16, Scene.Palette_s16);
|
||||||
NE_MaterialSetPalette(Material_s64, Palette_s64);
|
NE_MaterialSetPalette(Scene.Material_s64, Scene.Palette_s64);
|
||||||
NE_MaterialSetPalette(Material_s256, Palette_s256);
|
NE_MaterialSetPalette(Scene.Material_s256, Scene.Palette_s256);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
NE_WaitForVBL(0);
|
NE_WaitForVBL(0);
|
||||||
|
|
||||||
NE_ProcessDual(Draw3DScene, Draw3DScene2);
|
NE_ProcessDualArg(Draw3DScene, Draw3DScene2, &Scene, &Scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,220 +1,4 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
include ../../Makefile.example
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
include ../../Makefile.example.blocksds
|
|
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ typedef struct {
|
|||||||
|
|
||||||
quad_t Quad[NUM_QUADS];
|
quad_t Quad[NUM_QUADS];
|
||||||
|
|
||||||
uint32 kheld;
|
bool enable_alpha = false;
|
||||||
|
|
||||||
void UpdateQuads(void)
|
void UpdateQuads(void)
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ void Draw3DScene(void)
|
|||||||
if (!Quad[i].enabled)
|
if (!Quad[i].enabled)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (kheld & KEY_A)
|
if (enable_alpha)
|
||||||
NE_PolyFormat(Quad[i].alpha, Quad[i].id, 0, NE_CULL_NONE, 0);
|
NE_PolyFormat(Quad[i].alpha, Quad[i].id, 0, NE_CULL_NONE, 0);
|
||||||
|
|
||||||
NE_2DDrawQuad(Quad[i].x1, Quad[i].y1, Quad[i].x2, Quad[i].y2, i,
|
NE_2DDrawQuad(Quad[i].x1, Quad[i].y1, Quad[i].x2, Quad[i].y2, i,
|
||||||
@ -63,7 +63,7 @@ void Draw3DScene(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
@ -83,7 +83,11 @@ int main(void)
|
|||||||
NE_WaitForVBL(0);
|
NE_WaitForVBL(0);
|
||||||
|
|
||||||
scanKeys();
|
scanKeys();
|
||||||
kheld = keysHeld();
|
uint16_t kheld = keysHeld();
|
||||||
|
if (kheld & KEY_A)
|
||||||
|
enable_alpha = true;
|
||||||
|
else
|
||||||
|
enable_alpha = false;
|
||||||
|
|
||||||
UpdateQuads();
|
UpdateQuads();
|
||||||
|
|
||||||
|
@ -1,220 +1,6 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
GFXDIRS := graphics
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,13 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
mkdir -p data
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/icon.png \
|
|
||||||
--name icon \
|
|
||||||
--output data \
|
|
||||||
--format PAL16
|
|
Before Width: | Height: | Size: 796 B |
2
examples/2d_system/sprites/graphics/assets.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 256 color palette
|
||||||
|
-gx -gb -gB8 -gTFF00FF
|
BIN
examples/2d_system/sprites/graphics/assets.png
Normal file
After Width: | Height: | Size: 41 KiB |
7
examples/2d_system/sprites/graphics/assets.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
This file is derived from:
|
||||||
|
|
||||||
|
Name: Ancient ruins pixel art
|
||||||
|
License: CC-BY 3.0
|
||||||
|
Author: CraftPix.net 2D Game Assets
|
||||||
|
|
||||||
|
https://opengameart.org/content/ancient-ruins-pixel-art
|
2
examples/2d_system/sprites/graphics/icon.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 16 color palette
|
||||||
|
-gx -gb -gB4 -gTFF00FF
|
BIN
examples/2d_system/sprites/graphics/icon.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
@ -1,74 +1,116 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
#include <NEMain.h>
|
#include <NEMain.h>
|
||||||
|
|
||||||
#include "icon_tex_bin.h"
|
#include "assets.h"
|
||||||
#include "icon_pal_bin.h"
|
#include "icon.h"
|
||||||
|
|
||||||
NE_Material *Material;
|
NE_Sprite *Sprite[6];
|
||||||
NE_Palette *Palette;
|
|
||||||
NE_Sprite *Sprite[4];
|
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene1(void)
|
||||||
{
|
{
|
||||||
NE_2DViewInit();
|
NE_2DViewInit();
|
||||||
NE_SpriteDrawAll();
|
|
||||||
|
NE_ClearColorSet(NE_White, 31, 63);
|
||||||
|
|
||||||
|
NE_SpriteDraw(Sprite[3]);
|
||||||
|
NE_SpriteDraw(Sprite[4]);
|
||||||
|
NE_SpriteDraw(Sprite[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
void Draw3DScene2(void)
|
||||||
|
{
|
||||||
|
NE_2DViewInit();
|
||||||
|
|
||||||
|
NE_ClearColorSet(NE_Gray, 31, 63);
|
||||||
|
|
||||||
|
NE_SpriteDraw(Sprite[0]);
|
||||||
|
NE_SpriteDraw(Sprite[1]);
|
||||||
|
NE_SpriteDraw(Sprite[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
irqSet(IRQ_HBLANK, NE_HBLFunc);
|
irqSet(IRQ_HBLANK, NE_HBLFunc);
|
||||||
|
|
||||||
NE_Init3D();
|
NE_InitDual3D();
|
||||||
NE_SwapScreens();
|
NE_InitConsole();
|
||||||
|
|
||||||
Material = NE_MaterialCreate();
|
NE_Material *MaterialIcon = NE_MaterialCreate();
|
||||||
Palette = NE_PaletteCreate();
|
NE_Palette *PaletteIcon = NE_PaletteCreate();
|
||||||
|
|
||||||
NE_MaterialTexLoad(Material, NE_PAL16, 128, 128, NE_TEXGEN_TEXCOORD,
|
NE_MaterialTexLoad(MaterialIcon, NE_PAL16, 128, 128,
|
||||||
(void *)icon_tex_bin);
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
||||||
NE_PaletteLoad(Palette, (void *)icon_pal_bin, 32, NE_PAL16);
|
iconBitmap);
|
||||||
NE_MaterialSetPalette(Material, Palette);
|
NE_PaletteLoad(PaletteIcon, iconPal, iconPalLen / 2, NE_PAL16);
|
||||||
|
NE_MaterialSetPalette(MaterialIcon, PaletteIcon);
|
||||||
|
|
||||||
|
NE_Material *MaterialAssets = NE_MaterialCreate();
|
||||||
|
NE_Palette *PaletteAssets = NE_PaletteCreate();
|
||||||
|
|
||||||
NE_ClearColorSet(NE_Gray, 31, 63);
|
NE_MaterialTexLoad(MaterialAssets, NE_PAL256, 512, 256,
|
||||||
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
|
||||||
|
assetsBitmap);
|
||||||
|
NE_PaletteLoad(PaletteAssets, assetsPal, assetsPalLen / 2, NE_PAL16);
|
||||||
|
NE_MaterialSetPalette(MaterialAssets, PaletteAssets);
|
||||||
|
|
||||||
Sprite[0] = NE_SpriteCreate();
|
Sprite[0] = NE_SpriteCreate();
|
||||||
Sprite[1] = NE_SpriteCreate();
|
Sprite[1] = NE_SpriteCreate();
|
||||||
Sprite[2] = NE_SpriteCreate();
|
Sprite[2] = NE_SpriteCreate();
|
||||||
Sprite[3] = NE_SpriteCreate();
|
Sprite[3] = NE_SpriteCreate();
|
||||||
|
Sprite[4] = NE_SpriteCreate();
|
||||||
|
Sprite[5] = NE_SpriteCreate();
|
||||||
|
|
||||||
NE_SpriteSetPos(Sprite[0], 0, 0);
|
// Sprite with the same size as the texture
|
||||||
NE_SpriteSetSize(Sprite[0], 128, 128);
|
NE_SpriteSetMaterial(Sprite[0], MaterialIcon);
|
||||||
|
NE_SpriteSetPos(Sprite[0], 10, 40);
|
||||||
NE_SpriteSetPriority(Sprite[0], 10);
|
NE_SpriteSetPriority(Sprite[0], 10);
|
||||||
NE_SpriteSetMaterial(Sprite[0], Material);
|
|
||||||
|
|
||||||
|
// Sprite with a different size than the texture (scaled down) and a
|
||||||
|
// different color
|
||||||
|
NE_SpriteSetMaterial(Sprite[1], MaterialIcon);
|
||||||
NE_SpriteSetPos(Sprite[1], 114, 32);
|
NE_SpriteSetPos(Sprite[1], 114, 32);
|
||||||
NE_SpriteSetSize(Sprite[1], 56, 56);
|
|
||||||
NE_SpriteSetPriority(Sprite[1], 5);
|
NE_SpriteSetPriority(Sprite[1], 5);
|
||||||
NE_SpriteSetParams(Sprite[1], 15, 1, NE_Green);
|
NE_SpriteSetParams(Sprite[1], 15, 1, NE_Green);
|
||||||
NE_SpriteSetMaterial(Sprite[1], Material);
|
NE_SpriteSetSize(Sprite[1], 56, 56);
|
||||||
|
|
||||||
|
// Sprite with a different size than the texture (scaled down), and with
|
||||||
|
// transparency.
|
||||||
|
NE_SpriteSetMaterial(Sprite[2], MaterialIcon);
|
||||||
NE_SpriteSetPos(Sprite[2], 100, 50);
|
NE_SpriteSetPos(Sprite[2], 100, 50);
|
||||||
NE_SpriteSetSize(Sprite[2], 56, 56);
|
|
||||||
NE_SpriteSetPriority(Sprite[2], 1);
|
NE_SpriteSetPriority(Sprite[2], 1);
|
||||||
NE_SpriteSetMaterial(Sprite[2], Material);
|
|
||||||
NE_SpriteSetParams(Sprite[2], 15, 2, NE_White);
|
NE_SpriteSetParams(Sprite[2], 15, 2, NE_White);
|
||||||
|
NE_SpriteSetSize(Sprite[2], 56, 56);
|
||||||
|
|
||||||
NE_SpriteSetPos(Sprite[3], 256 - 64, 192 - 64);
|
// The following sprites will only use a small part of the texture
|
||||||
NE_SpriteSetSize(Sprite[3], 64, 64);
|
|
||||||
NE_SpriteSetPriority(Sprite[3], 12);
|
NE_SpriteSetMaterial(Sprite[3], MaterialAssets);
|
||||||
NE_SpriteSetMaterial(Sprite[3], Material);
|
NE_SpriteSetPos(Sprite[3], 50, 60);
|
||||||
|
NE_SpriteSetMaterialCanvas(Sprite[3], 384, 0, 484, 118);
|
||||||
|
NE_SpriteSetSize(Sprite[3], 484 - 384, 118 - 0);
|
||||||
|
|
||||||
|
NE_SpriteSetMaterial(Sprite[4], MaterialAssets);
|
||||||
|
NE_SpriteSetPos(Sprite[4], 0, 0);
|
||||||
|
NE_SpriteSetMaterialCanvas(Sprite[4], 73, 0, 152, 75);
|
||||||
|
NE_SpriteSetSize(Sprite[4], 152 - 73, 75 - 0);
|
||||||
|
|
||||||
|
NE_SpriteSetMaterial(Sprite[5], MaterialAssets);
|
||||||
|
NE_SpriteSetPos(Sprite[5], 170, 20);
|
||||||
|
NE_SpriteSetMaterialCanvas(Sprite[5], 0, 77, 72, 175);
|
||||||
|
NE_SpriteSetSize(Sprite[5], 72 - 0, 175 - 77);
|
||||||
|
|
||||||
int rot = 0;
|
int rot = 0;
|
||||||
int x = 100, y = 50;
|
int x = 100, y = 50;
|
||||||
|
|
||||||
|
printf("PAD: Move\n");
|
||||||
|
printf("START: Exit to loader\n");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
NE_WaitForVBL(0);
|
NE_WaitForVBL(0);
|
||||||
@ -88,9 +130,12 @@ int main(void)
|
|||||||
if (keys & KEY_LEFT)
|
if (keys & KEY_LEFT)
|
||||||
x--;
|
x--;
|
||||||
|
|
||||||
|
if (keys & KEY_START)
|
||||||
|
break;
|
||||||
|
|
||||||
NE_SpriteSetPos(Sprite[2], x, y);
|
NE_SpriteSetPos(Sprite[2], x, y);
|
||||||
|
|
||||||
NE_Process(Draw3DScene);
|
NE_ProcessDual(Draw3DScene1, Draw3DScene2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,220 +0,0 @@
|
|||||||
#---------------------------------------------------------------------------------
|
|
||||||
.SUFFIXES:
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,19 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
mkdir -p data
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/text.png \
|
|
||||||
--name text \
|
|
||||||
--output data \
|
|
||||||
--format A1RGB5
|
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input assets/text2.png \
|
|
||||||
--name text2 \
|
|
||||||
--output data \
|
|
||||||
--format A1RGB5
|
|
@ -1,20 +1,28 @@
|
|||||||
SUBDIRS:= $(shell ls)
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
#
|
||||||
|
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
.PHONY: all clean
|
||||||
all: examples
|
|
||||||
#-------------------------------------------------------------------------------
|
MAKE := make
|
||||||
@rm -fr build-all
|
|
||||||
|
all:
|
||||||
|
@for i in `ls`; do \
|
||||||
|
if test -e $$i/Makefile ; then \
|
||||||
|
cd $$i; \
|
||||||
|
$(MAKE) --no-print-directory || exit 1 ; \
|
||||||
|
cd ..; \
|
||||||
|
fi; \
|
||||||
|
done;
|
||||||
@mkdir -p build-all
|
@mkdir -p build-all
|
||||||
@find . -name "*.nds" -not -path build-all -exec cp -fv {} build-all \;
|
@find . -name "*.nds" -not -path build-all -exec cp -fv {} build-all \;
|
||||||
|
|
||||||
# TODO: The previous target tries to copy the files from build-all into
|
|
||||||
# themselves. Exclude them correctly.
|
|
||||||
|
|
||||||
examples:
|
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
clean:
|
clean:
|
||||||
#-------------------------------------------------------------------------------
|
@for i in `ls`; do \
|
||||||
|
if test -e $$i/Makefile ; then \
|
||||||
|
cd $$i; \
|
||||||
|
$(MAKE) clean --no-print-directory || exit 1 ; \
|
||||||
|
cd ..; \
|
||||||
|
fi; \
|
||||||
|
done;
|
||||||
@rm -fr build-all
|
@rm -fr build-all
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
# 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
|
|
@ -1,11 +1,11 @@
|
|||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
#
|
#
|
||||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
|
||||||
|
|
||||||
BLOCKSDS ?= /opt/blocksds/core
|
export BLOCKSDS ?= /opt/blocksds/core
|
||||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
export BLOCKSDSEXT ?= /opt/blocksds/external
|
||||||
|
|
||||||
WONDERFUL_TOOLCHAIN ?= /opt/wonderful
|
export WONDERFUL_TOOLCHAIN ?= /opt/wonderful
|
||||||
ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
|
ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
|
||||||
|
|
||||||
# User config
|
# User config
|
||||||
@ -17,11 +17,6 @@ GAME_SUBTITLE := Nitro Engine example
|
|||||||
GAME_AUTHOR := github.com/AntonioND/nitro-engine
|
GAME_AUTHOR := github.com/AntonioND/nitro-engine
|
||||||
GAME_ICON := $(BLOCKSDS)/sys/icon.bmp
|
GAME_ICON := $(BLOCKSDS)/sys/icon.bmp
|
||||||
|
|
||||||
# Source code paths
|
|
||||||
# -----------------
|
|
||||||
|
|
||||||
SOURCEDIRS ?= source
|
|
||||||
|
|
||||||
# DLDI and internal SD slot of DSi
|
# DLDI and internal SD slot of DSi
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
||||||
@ -30,6 +25,22 @@ SDROOT := sdroot
|
|||||||
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
||||||
SDIMAGE := image.bin
|
SDIMAGE := image.bin
|
||||||
|
|
||||||
|
# Source code paths
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
SOURCEDIRS ?= source
|
||||||
|
INCLUDEDIRS ?=
|
||||||
|
GFXDIRS ?=
|
||||||
|
BINDIRS ?=
|
||||||
|
AUDIODIRS ?=
|
||||||
|
# A single directory that is the root of NitroFS:
|
||||||
|
NITROFSDIR ?=
|
||||||
|
|
||||||
|
# Defines passed to all files
|
||||||
|
# ---------------------------
|
||||||
|
|
||||||
|
DEFINES ?=
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
# ---------
|
# ---------
|
||||||
|
|
||||||
@ -40,18 +51,18 @@ LIBDIRS += $(BLOCKSDSEXT)/nitro-engine \
|
|||||||
# Build artifacts
|
# Build artifacts
|
||||||
# ---------------
|
# ---------------
|
||||||
|
|
||||||
BUILDDIR := build
|
BUILDDIR := build/$(NAME)
|
||||||
ELF := build/$(NAME).elf
|
ELF := build/$(NAME).elf
|
||||||
DUMP := build/$(NAME).dump
|
DUMP := build/$(NAME).dump
|
||||||
MAP := build/$(NAME).map
|
MAP := build/$(NAME).map
|
||||||
ROM := $(NAME).nds
|
ROM := $(NAME).nds
|
||||||
|
|
||||||
# If NITROFSDIR is set, the output of mmutil will be placed in that directory
|
# If NITROFSDIR is set, the soundbank created by mmutil will be saved to NitroFS
|
||||||
SOUNDBANKINFODIR := $(BUILDDIR)/maxmod
|
SOUNDBANKINFODIR := $(BUILDDIR)/maxmod
|
||||||
ifeq ($(strip $(NITROFSDIR)),)
|
ifeq ($(strip $(NITROFSDIR)),)
|
||||||
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
||||||
else
|
else
|
||||||
SOUNDBANKDIR := $(NITROFSDIR)
|
SOUNDBANKDIR := $(BUILDDIR)/maxmod_nitrofs
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
@ -60,6 +71,7 @@ endif
|
|||||||
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
|
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
|
||||||
CC := $(PREFIX)gcc
|
CC := $(PREFIX)gcc
|
||||||
CXX := $(PREFIX)g++
|
CXX := $(PREFIX)g++
|
||||||
|
LD := $(PREFIX)gcc
|
||||||
OBJDUMP := $(PREFIX)objdump
|
OBJDUMP := $(PREFIX)objdump
|
||||||
MKDIR := mkdir
|
MKDIR := mkdir
|
||||||
RM := rm -rf
|
RM := rm -rf
|
||||||
@ -98,17 +110,15 @@ SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
|||||||
# Compiler and linker flags
|
# Compiler and linker flags
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
DEFINES += -D__NDS__ -DARM9
|
ARCH := -mthumb -mcpu=arm946e-s+nofp
|
||||||
|
|
||||||
ARCH := -march=armv5te -mtune=arm946e-s
|
SPECS := $(BLOCKSDS)/sys/crts/ds_arm9.specs
|
||||||
|
|
||||||
WARNFLAGS := -Wall
|
WARNFLAGS := -Wall
|
||||||
|
|
||||||
ifeq ($(SOURCES_CPP),)
|
ifeq ($(SOURCES_CPP),)
|
||||||
LD := $(CC)
|
|
||||||
LIBS += -lc
|
LIBS += -lc
|
||||||
else
|
else
|
||||||
LD := $(CXX)
|
|
||||||
LIBS += -lstdc++ -lc
|
LIBS += -lstdc++ -lc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -117,27 +127,21 @@ INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
|||||||
|
|
||||||
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
||||||
|
|
||||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
ASFLAGS += -x assembler-with-cpp $(INCLUDEFLAGS) $(DEFINES) \
|
||||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
$(ARCH) -ffunction-sections -fdata-sections \
|
||||||
-ffunction-sections -fdata-sections
|
-specs=$(SPECS)
|
||||||
|
|
||||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
CFLAGS += -std=gnu17 $(WARNFLAGS) $(INCLUDEFLAGS) $(DEFINES) \
|
||||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
$(ARCH) -O2 -ffunction-sections -fdata-sections \
|
||||||
-ffunction-sections -fdata-sections \
|
-specs=$(SPECS)
|
||||||
-fomit-frame-pointer
|
|
||||||
|
|
||||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
CXXFLAGS += -std=gnu++17 $(WARNFLAGS) $(INCLUDEFLAGS) $(DEFINES) \
|
||||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
$(ARCH) -O2 -ffunction-sections -fdata-sections \
|
||||||
-ffunction-sections -fdata-sections \
|
|
||||||
-fno-exceptions -fno-rtti \
|
-fno-exceptions -fno-rtti \
|
||||||
-fomit-frame-pointer
|
-specs=$(SPECS)
|
||||||
|
|
||||||
LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \
|
LDFLAGS := $(ARCH) $(LIBDIRSFLAGS) -Wl,-Map,$(MAP) $(DEFINES) \
|
||||||
-Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \
|
-Wl,--start-group $(LIBS) -Wl,--end-group -specs=$(SPECS)
|
||||||
-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
|
# Intermediate build files
|
||||||
# ------------------------
|
# ------------------------
|
||||||
@ -174,6 +178,10 @@ ifneq ($(strip $(NITROFSDIR)),)
|
|||||||
# Additional arguments for ndstool
|
# Additional arguments for ndstool
|
||||||
NDSTOOL_ARGS := -d $(NITROFSDIR)
|
NDSTOOL_ARGS := -d $(NITROFSDIR)
|
||||||
|
|
||||||
|
ifneq ($(SOURCES_AUDIO),)
|
||||||
|
NDSTOOL_ARGS += -d $(SOUNDBANKDIR)
|
||||||
|
endif
|
||||||
|
|
||||||
# Make the NDS ROM depend on the filesystem only if it is needed
|
# Make the NDS ROM depend on the filesystem only if it is needed
|
||||||
$(ROM): $(NITROFSDIR)
|
$(ROM): $(NITROFSDIR)
|
||||||
endif
|
endif
|
||||||
@ -194,7 +202,7 @@ $(ROM): $(ELF)
|
|||||||
|
|
||||||
$(ELF): $(OBJS)
|
$(ELF): $(OBJS)
|
||||||
@echo " LD $@"
|
@echo " LD $@"
|
||||||
$(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS)
|
$(V)$(LD) -o $@ $(OBJS) $(LDFLAGS)
|
||||||
|
|
||||||
$(DUMP): $(ELF)
|
$(DUMP): $(ELF)
|
||||||
@echo " OBJDUMP $@"
|
@echo " OBJDUMP $@"
|
||||||
@ -204,8 +212,7 @@ dump: $(DUMP)
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo " CLEAN"
|
@echo " CLEAN"
|
||||||
$(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \
|
$(V)$(RM) $(ROM) $(DUMP) build $(SDIMAGE)
|
||||||
$(SOUNDBANKDIR)/soundbank.bin
|
|
||||||
|
|
||||||
sdimage:
|
sdimage:
|
||||||
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
||||||
@ -255,12 +262,14 @@ $(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
|||||||
@$(MKDIR) -p $(@D)
|
@$(MKDIR) -p $(@D)
|
||||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||||
|
$(V)touch $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.h
|
||||||
|
|
||||||
ifneq ($(SOURCES_AUDIO),)
|
ifneq ($(SOURCES_AUDIO),)
|
||||||
|
|
||||||
$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO)
|
$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO)
|
||||||
@echo " MMUTIL $^"
|
@echo " MMUTIL $^"
|
||||||
@$(MKDIR) -p $(@D)
|
@$(MKDIR) -p $(SOUNDBANKDIR)
|
||||||
|
@$(MKDIR) -p $(SOUNDBANKINFODIR)
|
||||||
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
||||||
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h
|
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h
|
||||||
|
|
@ -1,5 +1,25 @@
|
|||||||
SUBDIRS:= `ls`
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
#
|
||||||
|
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
MAKE := make
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
@for i in `ls`; do \
|
||||||
|
if test -e $$i/Makefile ; then \
|
||||||
|
cd $$i; \
|
||||||
|
$(MAKE) --no-print-directory || exit 1 ; \
|
||||||
|
cd ..; \
|
||||||
|
fi; \
|
||||||
|
done;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
@for i in `ls`; do \
|
||||||
|
if test -e $$i/Makefile ; then \
|
||||||
|
cd $$i; \
|
||||||
|
$(MAKE) clean --no-print-directory || exit 1 ; \
|
||||||
|
cd ..; \
|
||||||
|
fi; \
|
||||||
|
done;
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
# 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;
|
|
@ -1,220 +1,7 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
BINDIRS := data
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
GFXDIRS := graphics
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,21 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
NITRO_ENGINE=../../..
|
||||||
ASSETS=$NITRO_ENGINE/examples/assets
|
ASSETS=$NITRO_ENGINE/examples/assets
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
TOOLS=$NITRO_ENGINE/tools
|
||||||
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
|
rm -rf data
|
||||||
mkdir -p data
|
mkdir -p data
|
||||||
|
|
||||||
python3 $OBJ2DL \
|
python3 $OBJ2DL \
|
||||||
--input $ASSETS/sphere.obj \
|
--input $ASSETS/sphere.obj \
|
||||||
--output data/sphere.bin \
|
--output data/sphere.bin \
|
||||||
--texture 256 256
|
--texture 256 256
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input $ASSETS/teapot.png \
|
|
||||||
--name texture \
|
|
||||||
--output data \
|
|
||||||
--format A1RGB5
|
|
||||||
|
|
||||||
|
2
examples/effects/fog/graphics/texture.grit
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 16-bit palette, no transparency
|
||||||
|
-gx -gb -gB16 -gT!
|
BIN
examples/effects/fog/graphics/texture.png
Normal file
After Width: | Height: | Size: 100 KiB |
@ -1,34 +1,39 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
#include <NEMain.h>
|
#include <NEMain.h>
|
||||||
|
|
||||||
#include "texture_tex_bin.h"
|
#include "texture.h"
|
||||||
#include "sphere_bin.h"
|
#include "sphere_bin.h"
|
||||||
|
|
||||||
NE_Camera *Camera;
|
typedef struct {
|
||||||
NE_Model *Model, *Model2, *Model3;
|
NE_Camera *Camera;
|
||||||
NE_Material *Material;
|
NE_Model *Model, *Model2, *Model3;
|
||||||
|
} SceneData;
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
// Set camera
|
// Set camera
|
||||||
NE_CameraUse(Camera);
|
NE_CameraUse(Scene->Camera);
|
||||||
|
|
||||||
// This has to be used to use fog
|
// This has to be used to use fog
|
||||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_BACK, NE_FOG_ENABLE);
|
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_BACK, NE_FOG_ENABLE);
|
||||||
|
|
||||||
// Draw models
|
// Draw models
|
||||||
NE_ModelDraw(Model);
|
NE_ModelDraw(Scene->Model);
|
||||||
NE_ModelDraw(Model2);
|
NE_ModelDraw(Scene->Model2);
|
||||||
NE_ModelDraw(Model3);
|
NE_ModelDraw(Scene->Model3);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
SceneData Scene = { 0 };
|
||||||
|
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
irqSet(IRQ_VBLANK, NE_HBLFunc);
|
irqSet(IRQ_VBLANK, NE_HBLFunc);
|
||||||
@ -41,39 +46,39 @@ int main(void)
|
|||||||
consoleDemoInit();
|
consoleDemoInit();
|
||||||
|
|
||||||
// Allocate objects
|
// Allocate objects
|
||||||
Model = NE_ModelCreate(NE_Static);
|
Scene.Model = NE_ModelCreate(NE_Static);
|
||||||
Model2 = NE_ModelCreate(NE_Static);
|
Scene.Model2 = NE_ModelCreate(NE_Static);
|
||||||
Model3 = NE_ModelCreate(NE_Static);
|
Scene.Model3 = NE_ModelCreate(NE_Static);
|
||||||
Camera = NE_CameraCreate();
|
Scene.Camera = NE_CameraCreate();
|
||||||
Material = NE_MaterialCreate();
|
NE_Material *Material = NE_MaterialCreate();
|
||||||
|
|
||||||
// Set camera coordinates
|
// Set camera coordinates
|
||||||
NE_CameraSet(Camera,
|
NE_CameraSet(Scene.Camera,
|
||||||
-1, 2, -1,
|
-1, 2, -1,
|
||||||
1, 1, 1,
|
1, 1, 1,
|
||||||
0, 1, 0);
|
0, 1, 0);
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
NE_ModelLoadStaticMesh(Model, (u32 *)sphere_bin);
|
NE_ModelLoadStaticMesh(Scene.Model, sphere_bin);
|
||||||
NE_ModelLoadStaticMesh(Model2, (u32 *)sphere_bin);
|
NE_ModelLoadStaticMesh(Scene.Model2, sphere_bin);
|
||||||
NE_ModelLoadStaticMesh(Model3, (u32 *)sphere_bin);
|
NE_ModelLoadStaticMesh(Scene.Model3, sphere_bin);
|
||||||
|
|
||||||
// Load texture
|
// Load texture
|
||||||
NE_MaterialTexLoad(Material, NE_RGB5, 256, 256, NE_TEXGEN_TEXCOORD,
|
NE_MaterialTexLoad(Material, NE_A1RGB5, 256, 256, NE_TEXGEN_TEXCOORD,
|
||||||
(u8 *)texture_tex_bin);
|
textureBitmap);
|
||||||
|
|
||||||
// Assign the same material to every model object.
|
// Assign the same material to every model object.
|
||||||
NE_ModelSetMaterial(Model, Material);
|
NE_ModelSetMaterial(Scene.Model, Material);
|
||||||
NE_ModelSetMaterial(Model2, Material);
|
NE_ModelSetMaterial(Scene.Model2, Material);
|
||||||
NE_ModelSetMaterial(Model3, Material);
|
NE_ModelSetMaterial(Scene.Model3, Material);
|
||||||
|
|
||||||
// Set light and vector of light 0
|
// Set light and vector of light 0
|
||||||
NE_LightSet(0, NE_White, 0, -1, -1);
|
NE_LightSet(0, NE_White, 0, -1, -1);
|
||||||
|
|
||||||
// Set position of every object
|
// Set position of every object
|
||||||
NE_ModelSetCoord(Model, 1, 0, 1);
|
NE_ModelSetCoord(Scene.Model, 1, 0, 1);
|
||||||
NE_ModelSetCoord(Model2, 3, 1, 3);
|
NE_ModelSetCoord(Scene.Model2, 3, 1, 3);
|
||||||
NE_ModelSetCoord(Model3, 7, 2, 7);
|
NE_ModelSetCoord(Scene.Model3, 7, 2, 7);
|
||||||
|
|
||||||
// Set initial fog color to black
|
// Set initial fog color to black
|
||||||
u32 color = NE_Black;
|
u32 color = NE_Black;
|
||||||
@ -89,7 +94,7 @@ int main(void)
|
|||||||
|
|
||||||
// Refresh keys
|
// Refresh keys
|
||||||
scanKeys();
|
scanKeys();
|
||||||
uint32 keys = keysDown();
|
uint32_t keys = keysDown();
|
||||||
|
|
||||||
// Modify parameters
|
// Modify parameters
|
||||||
if (keys & KEY_UP)
|
if (keys & KEY_UP)
|
||||||
@ -125,7 +130,7 @@ int main(void)
|
|||||||
shift, mass, depth);
|
shift, mass, depth);
|
||||||
|
|
||||||
// Draw scene
|
// Draw scene
|
||||||
NE_Process(Draw3DScene);
|
NE_ProcessArg(Draw3DScene, &Scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,220 +1,6 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
BINDIRS := data
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
NITRO_ENGINE=../../..
|
||||||
ASSETS=$NITRO_ENGINE/examples/assets
|
ASSETS=$NITRO_ENGINE/examples/assets
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
TOOLS=$NITRO_ENGINE/tools
|
||||||
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
@ -8,29 +8,37 @@
|
|||||||
|
|
||||||
#include "teapot_bin.h"
|
#include "teapot_bin.h"
|
||||||
|
|
||||||
NE_Camera *Camera;
|
typedef struct {
|
||||||
NE_Model *Model;
|
NE_Camera *Camera;
|
||||||
|
NE_Model *Model;
|
||||||
|
} SceneData;
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
// Set rear plane color
|
// Set rear plane color
|
||||||
NE_ClearColorSet(NE_Red, 31, 63);
|
NE_ClearColorSet(NE_Red, 31, 63);
|
||||||
|
|
||||||
NE_CameraUse(Camera);
|
NE_CameraUse(Scene->Camera);
|
||||||
NE_ModelDraw(Model);
|
NE_ModelDraw(Scene->Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw3DScene2(void)
|
void Draw3DScene2(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
// Set rear plane color
|
// Set rear plane color
|
||||||
NE_ClearColorSet(NE_Green, 31, 63);
|
NE_ClearColorSet(NE_Green, 31, 63);
|
||||||
|
|
||||||
NE_CameraUse(Camera);
|
NE_CameraUse(Scene->Camera);
|
||||||
NE_ModelDraw(Model);
|
NE_ModelDraw(Scene->Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
SceneData Scene = { 0 };
|
||||||
|
|
||||||
// This is needed for special screen effects
|
// This is needed for special screen effects
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
@ -41,24 +49,21 @@ int main(void)
|
|||||||
NE_InitConsole();
|
NE_InitConsole();
|
||||||
|
|
||||||
// Allocate objects...
|
// Allocate objects...
|
||||||
Model = NE_ModelCreate(NE_Static);
|
Scene.Model = NE_ModelCreate(NE_Static);
|
||||||
Camera = NE_CameraCreate();
|
Scene.Camera = NE_CameraCreate();
|
||||||
|
|
||||||
// Setup camera
|
// Setup camera
|
||||||
NE_CameraSet(Camera,
|
NE_CameraSet(Scene.Camera,
|
||||||
0, 0, -3,
|
0, 0, -3,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
0, 1, 0);
|
0, 1, 0);
|
||||||
|
|
||||||
// Load model
|
// Load model
|
||||||
NE_ModelLoadStaticMesh(Model, (u32 *)teapot_bin);
|
NE_ModelLoadStaticMesh(Scene.Model, teapot_bin);
|
||||||
|
|
||||||
// Set light color and direction
|
// Set light color and direction
|
||||||
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
|
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
|
||||||
|
|
||||||
// Enable shading
|
|
||||||
NE_ShadingEnable(true);
|
|
||||||
|
|
||||||
// Other test configurations
|
// Other test configurations
|
||||||
//NE_SpecialEffectNoiseConfig(31);
|
//NE_SpecialEffectNoiseConfig(31);
|
||||||
//NE_SpecialEffectSineConfig(3, 8);
|
//NE_SpecialEffectSineConfig(3, 8);
|
||||||
@ -69,8 +74,8 @@ int main(void)
|
|||||||
|
|
||||||
// Refresh keys
|
// Refresh keys
|
||||||
scanKeys();
|
scanKeys();
|
||||||
uint32 keys = keysHeld();
|
uint32_t keys = keysHeld();
|
||||||
uint32 kdown = keysDown();
|
uint32_t kdown = keysDown();
|
||||||
|
|
||||||
printf("\x1b[0;0H"
|
printf("\x1b[0;0H"
|
||||||
"Pad: Rotate.\nA: Sine effect.\nB: Noise effect.\n"
|
"Pad: Rotate.\nA: Sine effect.\nB: Noise effect.\n"
|
||||||
@ -78,13 +83,13 @@ int main(void)
|
|||||||
|
|
||||||
// Rotate model
|
// Rotate model
|
||||||
if (keys & KEY_UP)
|
if (keys & KEY_UP)
|
||||||
NE_ModelRotate(Model, 0, 0, 2);
|
NE_ModelRotate(Scene.Model, 0, 0, 2);
|
||||||
if (keys & KEY_DOWN)
|
if (keys & KEY_DOWN)
|
||||||
NE_ModelRotate(Model, 0, 0, -2);
|
NE_ModelRotate(Scene.Model, 0, 0, -2);
|
||||||
if (keys & KEY_RIGHT)
|
if (keys & KEY_RIGHT)
|
||||||
NE_ModelRotate(Model, 0, 2, 0);
|
NE_ModelRotate(Scene.Model, 0, 2, 0);
|
||||||
if (keys & KEY_LEFT)
|
if (keys & KEY_LEFT)
|
||||||
NE_ModelRotate(Model, 0, -2, 0);
|
NE_ModelRotate(Scene.Model, 0, -2, 0);
|
||||||
|
|
||||||
// Activate effects
|
// Activate effects
|
||||||
if (kdown & KEY_B)
|
if (kdown & KEY_B)
|
||||||
@ -102,7 +107,7 @@ int main(void)
|
|||||||
NE_SpecialEffectPause(false);
|
NE_SpecialEffectPause(false);
|
||||||
|
|
||||||
// Draw 3D scenes
|
// Draw 3D scenes
|
||||||
NE_ProcessDual(Draw3DScene, Draw3DScene2);
|
NE_ProcessDualArg(Draw3DScene, Draw3DScene2, &Scene, &Scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,220 +1,6 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
BINDIRS := data
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
NITRO_ENGINE=../../..
|
||||||
ASSETS=$NITRO_ENGINE/examples/assets
|
ASSETS=$NITRO_ENGINE/examples/assets
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
TOOLS=$NITRO_ENGINE/tools
|
||||||
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022-2023
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
@ -11,27 +11,35 @@
|
|||||||
#include "teapot_bin.h"
|
#include "teapot_bin.h"
|
||||||
#include "sphere_bin.h"
|
#include "sphere_bin.h"
|
||||||
|
|
||||||
NE_Camera *Camera;
|
typedef struct {
|
||||||
NE_Model *Teapot, *Sphere;
|
NE_Camera *Camera;
|
||||||
|
NE_Model *Teapot, *Sphere;
|
||||||
|
} SceneData;
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
NE_ClearColorSet(NE_Red, 31, 63);
|
NE_ClearColorSet(NE_Red, 31, 63);
|
||||||
|
|
||||||
NE_CameraUse(Camera);
|
NE_CameraUse(Scene->Camera);
|
||||||
NE_ModelDraw(Teapot);
|
NE_ModelDraw(Scene->Teapot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw3DScene2(void)
|
void Draw3DScene2(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
NE_ClearColorSet(NE_Green, 31, 63);
|
NE_ClearColorSet(NE_Green, 31, 63);
|
||||||
|
|
||||||
NE_CameraUse(Camera);
|
NE_CameraUse(Scene->Camera);
|
||||||
NE_ModelDraw(Sphere);
|
NE_ModelDraw(Scene->Sphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
SceneData Scene = { 0 };
|
||||||
|
|
||||||
// This is needed for special screen effects
|
// This is needed for special screen effects
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
@ -42,26 +50,23 @@ int main(void)
|
|||||||
NE_InitConsole();
|
NE_InitConsole();
|
||||||
|
|
||||||
// Allocate objects...
|
// Allocate objects...
|
||||||
Teapot = NE_ModelCreate(NE_Static);
|
Scene.Teapot = NE_ModelCreate(NE_Static);
|
||||||
Sphere = NE_ModelCreate(NE_Static);
|
Scene.Sphere = NE_ModelCreate(NE_Static);
|
||||||
Camera = NE_CameraCreate();
|
Scene.Camera = NE_CameraCreate();
|
||||||
|
|
||||||
// Setup camera
|
// Setup camera
|
||||||
NE_CameraSet(Camera,
|
NE_CameraSet(Scene.Camera,
|
||||||
0, 0, -2,
|
0, 0, -2,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
0, 1, 0);
|
0, 1, 0);
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
NE_ModelLoadStaticMesh(Teapot, (u32 *)teapot_bin);
|
NE_ModelLoadStaticMesh(Scene.Teapot, teapot_bin);
|
||||||
NE_ModelLoadStaticMesh(Sphere, (u32 *)sphere_bin);
|
NE_ModelLoadStaticMesh(Scene.Sphere, sphere_bin);
|
||||||
|
|
||||||
// Set light color and direction
|
// Set light color and direction
|
||||||
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
|
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
|
||||||
|
|
||||||
// Enable shading
|
|
||||||
NE_ShadingEnable(true);
|
|
||||||
|
|
||||||
// Other test configurations
|
// Other test configurations
|
||||||
//NE_SpecialEffectNoiseConfig(31);
|
//NE_SpecialEffectNoiseConfig(31);
|
||||||
//NE_SpecialEffectSineConfig(3, 8);
|
//NE_SpecialEffectSineConfig(3, 8);
|
||||||
@ -71,12 +76,12 @@ int main(void)
|
|||||||
NE_WaitForVBL(0);
|
NE_WaitForVBL(0);
|
||||||
|
|
||||||
// Draw 3D scenes
|
// Draw 3D scenes
|
||||||
NE_ProcessDual(Draw3DScene, Draw3DScene2);
|
NE_ProcessDualArg(Draw3DScene, Draw3DScene2, &Scene, &Scene);
|
||||||
|
|
||||||
// Refresh keys
|
// Refresh keys
|
||||||
scanKeys();
|
scanKeys();
|
||||||
uint32 keys = keysHeld();
|
uint32_t keys = keysHeld();
|
||||||
uint32 kdown = keysDown();
|
uint32_t kdown = keysDown();
|
||||||
|
|
||||||
printf("\x1b[0;0H"
|
printf("\x1b[0;0H"
|
||||||
"START: Lock CPU until released\n"
|
"START: Lock CPU until released\n"
|
||||||
@ -93,23 +98,23 @@ int main(void)
|
|||||||
// Rotate model
|
// Rotate model
|
||||||
if (keys & KEY_UP)
|
if (keys & KEY_UP)
|
||||||
{
|
{
|
||||||
NE_ModelRotate(Sphere, 0, 0, 2);
|
NE_ModelRotate(Scene.Sphere, 0, 0, 2);
|
||||||
NE_ModelRotate(Teapot, 0, 0, 2);
|
NE_ModelRotate(Scene.Teapot, 0, 0, 2);
|
||||||
}
|
}
|
||||||
if (keys & KEY_DOWN)
|
if (keys & KEY_DOWN)
|
||||||
{
|
{
|
||||||
NE_ModelRotate(Sphere, 0, 0, -2);
|
NE_ModelRotate(Scene.Sphere, 0, 0, -2);
|
||||||
NE_ModelRotate(Teapot, 0, 0, -2);
|
NE_ModelRotate(Scene.Teapot, 0, 0, -2);
|
||||||
}
|
}
|
||||||
if (keys & KEY_RIGHT)
|
if (keys & KEY_RIGHT)
|
||||||
{
|
{
|
||||||
NE_ModelRotate(Sphere, 0, 2, 0);
|
NE_ModelRotate(Scene.Sphere, 0, 2, 0);
|
||||||
NE_ModelRotate(Teapot, 0, 2, 0);
|
NE_ModelRotate(Scene.Teapot, 0, 2, 0);
|
||||||
}
|
}
|
||||||
if (keys & KEY_LEFT)
|
if (keys & KEY_LEFT)
|
||||||
{
|
{
|
||||||
NE_ModelRotate(Sphere, 0, -2, 0);
|
NE_ModelRotate(Scene.Sphere, 0, -2, 0);
|
||||||
NE_ModelRotate(Teapot, 0, -2, 0);
|
NE_ModelRotate(Scene.Teapot, 0, -2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate effects
|
// Activate effects
|
||||||
|
@ -1,220 +1,7 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
BINDIRS := data
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
GFXDIRS := graphics
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,11 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
NITRO_ENGINE=../../..
|
||||||
ASSETS=$NITRO_ENGINE/examples/assets
|
ASSETS=$NITRO_ENGINE/examples/assets
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
TOOLS=$NITRO_ENGINE/tools
|
||||||
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
|
rm -rf data
|
||||||
mkdir -p data
|
mkdir -p data
|
||||||
|
|
||||||
python3 $OBJ2DL \
|
python3 $OBJ2DL \
|
||||||
@ -13,9 +13,3 @@ python3 $OBJ2DL \
|
|||||||
--output data/teapot.bin \
|
--output data/teapot.bin \
|
||||||
--texture 256 256 \
|
--texture 256 256 \
|
||||||
--scale 0.1
|
--scale 0.1
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input $ASSETS/teapot.png \
|
|
||||||
--name teapot \
|
|
||||||
--output data \
|
|
||||||
--format A1RGB5
|
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
# 16-bit palette, no transparency
|
||||||
|
-gx -gb -gB16 -gT!
|
BIN
examples/effects/shading_alpha_outlining/graphics/teapot.png
Normal file
After Width: | Height: | Size: 100 KiB |
@ -1,34 +1,40 @@
|
|||||||
// SPDX-License-Identifier: CC0-1.0
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2011, 2019, 2022
|
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
|
||||||
//
|
//
|
||||||
// This file is part of Nitro Engine
|
// This file is part of Nitro Engine
|
||||||
|
|
||||||
#include <NEMain.h>
|
#include <NEMain.h>
|
||||||
|
|
||||||
#include "teapot_bin.h"
|
#include "teapot_bin.h"
|
||||||
#include "teapot_tex_bin.h"
|
#include "teapot.h"
|
||||||
|
|
||||||
NE_Camera *Camera;
|
typedef struct {
|
||||||
NE_Model *Model;
|
NE_Camera *Camera;
|
||||||
NE_Material *Material;
|
NE_Model *Model;
|
||||||
|
|
||||||
int shading, alpha, id;
|
int shading, alpha, id;
|
||||||
|
} SceneData;
|
||||||
|
|
||||||
void Draw3DScene(void)
|
void Draw3DScene(void *arg)
|
||||||
{
|
{
|
||||||
|
SceneData *Scene = arg;
|
||||||
|
|
||||||
// Set camera
|
// Set camera
|
||||||
NE_CameraUse(Camera);
|
NE_CameraUse(Scene->Camera);
|
||||||
|
|
||||||
// Set polygon format
|
// Set polygon format
|
||||||
NE_PolyFormat(alpha, id, NE_LIGHT_0, NE_CULL_BACK, shading);
|
NE_PolyFormat(Scene->alpha, Scene->id, NE_LIGHT_0, NE_CULL_BACK,
|
||||||
|
Scene->shading);
|
||||||
|
|
||||||
// Draw model
|
// Draw model
|
||||||
NE_ModelDraw(Model);
|
NE_ModelDraw(Scene->Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
SceneData Scene = { 0 };
|
||||||
|
|
||||||
// This is needed for special screen effects
|
// This is needed for special screen effects
|
||||||
irqEnable(IRQ_HBLANK);
|
irqEnable(IRQ_HBLANK);
|
||||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||||
@ -43,28 +49,28 @@ int main(void)
|
|||||||
consoleDemoInit();
|
consoleDemoInit();
|
||||||
|
|
||||||
// Allocate the objects we will use
|
// Allocate the objects we will use
|
||||||
Model = NE_ModelCreate(NE_Static);
|
Scene.Model = NE_ModelCreate(NE_Static);
|
||||||
Camera = NE_CameraCreate();
|
Scene.Camera = NE_CameraCreate();
|
||||||
Material = NE_MaterialCreate();
|
NE_Material *Material = NE_MaterialCreate();
|
||||||
|
|
||||||
// Set camera coordinates
|
// Set camera coordinates
|
||||||
NE_CameraSet(Camera,
|
NE_CameraSet(Scene.Camera,
|
||||||
0, 0, -3,
|
0, 0, -3,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
0, 1, 0);
|
0, 1, 0);
|
||||||
|
|
||||||
// Load mesh from RAM and assign it to a model
|
// Load mesh from RAM and assign it to a model
|
||||||
NE_ModelLoadStaticMesh(Model, (u32 *)teapot_bin);
|
NE_ModelLoadStaticMesh(Scene.Model, teapot_bin);
|
||||||
// Load teapot from RAM and assign it to a material
|
// Load teapot texture from RAM and assign it to a material
|
||||||
NE_MaterialTexLoad(Material, NE_RGB5, 256, 256,
|
NE_MaterialTexLoad(Material, NE_A1RGB5, 256, 256,
|
||||||
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
|
||||||
(u8 *)teapot_tex_bin);
|
teapotBitmap);
|
||||||
|
|
||||||
// Assign material to the model
|
// Assign material to the model
|
||||||
NE_ModelSetMaterial(Model, Material);
|
NE_ModelSetMaterial(Scene.Model, Material);
|
||||||
|
|
||||||
// Set some propierties to the material
|
// Set some properties to the material
|
||||||
NE_MaterialSetPropierties(Material,
|
NE_MaterialSetProperties(Material,
|
||||||
RGB15(24, 24, 24), // Diffuse
|
RGB15(24, 24, 24), // Diffuse
|
||||||
RGB15(8, 8, 8), // Ambient
|
RGB15(8, 8, 8), // Ambient
|
||||||
RGB15(0, 0, 0), // Specular
|
RGB15(0, 0, 0), // Specular
|
||||||
@ -75,7 +81,7 @@ int main(void)
|
|||||||
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
|
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
|
||||||
|
|
||||||
// This enables shading (you can choose normal or toon).
|
// This enables shading (you can choose normal or toon).
|
||||||
NE_ShadingEnable(true);
|
NE_SetupToonShadingTables(true);
|
||||||
// This enables outlining in all polygons, so be careful
|
// This enables outlining in all polygons, so be careful
|
||||||
NE_OutliningEnable(true);
|
NE_OutliningEnable(true);
|
||||||
|
|
||||||
@ -89,7 +95,7 @@ int main(void)
|
|||||||
|
|
||||||
// Refresh keys
|
// Refresh keys
|
||||||
scanKeys();
|
scanKeys();
|
||||||
uint32 keys = keysHeld();
|
uint32_t keys = keysHeld();
|
||||||
|
|
||||||
printf("\x1b[0;0H"
|
printf("\x1b[0;0H"
|
||||||
"Pad: Rotate.\nA: Toon shading.\n"
|
"Pad: Rotate.\nA: Toon shading.\n"
|
||||||
@ -98,35 +104,35 @@ int main(void)
|
|||||||
|
|
||||||
// Rotate model using the pad
|
// Rotate model using the pad
|
||||||
if (keys & KEY_UP)
|
if (keys & KEY_UP)
|
||||||
NE_ModelRotate(Model, 0, 0, 2);
|
NE_ModelRotate(Scene.Model, 0, 0, 2);
|
||||||
if (keys & KEY_DOWN)
|
if (keys & KEY_DOWN)
|
||||||
NE_ModelRotate(Model, 0, 0, -2);
|
NE_ModelRotate(Scene.Model, 0, 0, -2);
|
||||||
if (keys & KEY_RIGHT)
|
if (keys & KEY_RIGHT)
|
||||||
NE_ModelRotate(Model, 0, 2, 0);
|
NE_ModelRotate(Scene.Model, 0, 2, 0);
|
||||||
if (keys & KEY_LEFT)
|
if (keys & KEY_LEFT)
|
||||||
NE_ModelRotate(Model, 0, -2, 0);
|
NE_ModelRotate(Scene.Model, 0, -2, 0);
|
||||||
|
|
||||||
// Change shading type
|
// Change shading type
|
||||||
if (keys & KEY_A)
|
if (keys & KEY_A)
|
||||||
shading = NE_TOON_HIGHLIGHT_SHADING;
|
Scene.shading = NE_TOON_HIGHLIGHT_SHADING;
|
||||||
else
|
else
|
||||||
shading = NE_MODULATION;
|
Scene.shading = NE_MODULATION;
|
||||||
|
|
||||||
if (keys & KEY_B)
|
if (keys & KEY_B)
|
||||||
alpha = 15; // Transparent
|
Scene.alpha = 15; // Transparent
|
||||||
else if (keys & KEY_Y)
|
else if (keys & KEY_Y)
|
||||||
alpha = 0; // Wireframe
|
Scene.alpha = 0; // Wireframe
|
||||||
else
|
else
|
||||||
alpha = 31; // Opaque
|
Scene.alpha = 31; // Opaque
|
||||||
|
|
||||||
// Change polygon ID to change outlining color
|
// Change polygon ID to change outlining color
|
||||||
if (keys & KEY_X)
|
if (keys & KEY_X)
|
||||||
id = 8;
|
Scene.id = 8;
|
||||||
else
|
else
|
||||||
id = 0;
|
Scene.id = 0;
|
||||||
|
|
||||||
// Draw scene
|
// Draw scene
|
||||||
NE_Process(Draw3DScene);
|
NE_ProcessArg(Draw3DScene, &Scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,220 +1,7 @@
|
|||||||
#---------------------------------------------------------------------------------
|
# This is a minimal makefile only used for the examples. If you want a makefile
|
||||||
.SUFFIXES:
|
# for your project, take one from the templates inside examples/templates.
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
BINDIRS := data
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
GFXDIRS := graphics
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/ds_rules
|
include ../../Makefile.example
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# INCLUDES is a list of directories containing extra header files
|
|
||||||
# DATA is a list of directories containing binary files embedded using bin2o
|
|
||||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
|
||||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
|
||||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
|
||||||
# NITRO is a directory that will be accessible via NitroFS
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := $(shell basename $(CURDIR))
|
|
||||||
BUILD := build
|
|
||||||
SOURCES := source
|
|
||||||
INCLUDES := include
|
|
||||||
DATA := data
|
|
||||||
GRAPHICS :=
|
|
||||||
AUDIO :=
|
|
||||||
ICON :=
|
|
||||||
|
|
||||||
# specify a directory which contains the nitro filesystem
|
|
||||||
# this is relative to the Makefile
|
|
||||||
NITRO :=
|
|
||||||
|
|
||||||
# These set the information text in the nds file
|
|
||||||
GAME_TITLE := $(shell basename $(CURDIR))
|
|
||||||
GAME_SUBTITLE1 := Nitro Engine example
|
|
||||||
GAME_SUBTITLE2 := github.com/AntonioND/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O3\
|
|
||||||
$(ARCH) $(INCLUDE) -DARM9
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
|
||||||
ASFLAGS := -g $(ARCH)
|
|
||||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# any extra libraries we wish to link with the project (order is important)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBS := -lNE -lfat -lnds9
|
|
||||||
|
|
||||||
# automatigically add libraries for NitroFS
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
LIBS := -lfilesystem -lfat $(LIBS)
|
|
||||||
endif
|
|
||||||
# automagically add maxmod library
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
LIBS := -lmm9 $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
|
||||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
|
||||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
# prepare NitroFS directory
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# get audio list for maxmod
|
|
||||||
ifneq ($(strip $(AUDIO)),)
|
|
||||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
|
||||||
|
|
||||||
# place the soundbank file in NitroFS if using it
|
|
||||||
ifneq ($(strip $(NITRO)),)
|
|
||||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
|
||||||
|
|
||||||
# otherwise, needs to be loaded from memory
|
|
||||||
else
|
|
||||||
export SOUNDBANK := soundbank.bin
|
|
||||||
BINFILES += $(SOUNDBANK)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
|
||||||
-I$(CURDIR)/$(BUILD)
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
|
||||||
icons := $(wildcard *.bmp)
|
|
||||||
|
|
||||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
|
||||||
else
|
|
||||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
|
||||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(suffix $(ICON)), .grf)
|
|
||||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
|
||||||
else
|
|
||||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(BUILD):
|
|
||||||
@mkdir -p $@
|
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
|
||||||
# source files depend on generated headers
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
# need to build soundbank first
|
|
||||||
$(OFILES): $(SOUNDBANK)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rule to build solution from music files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(SOUNDBANK) : $(MODFILES)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
mmutil $^ -d -o$@ -hsoundbank.h
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# This rule creates assembly source files using grit
|
|
||||||
# grit takes an image file and a .grit describing how the file is to be processed
|
|
||||||
# add additional rules like this for each image extension
|
|
||||||
# you use in the graphics folders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.s %.h: %.png %.grit
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
grit $< -fts -o$*
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# Convert non-GRF game icon to GRF if needed
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(GAME_ICON): $(notdir $(ICON))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo convert $(notdir $<)
|
|
||||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
|
||||||
|
|
||||||
-include $(DEPSDIR)/*.d
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
BINDIRS := data
|
|
||||||
|
|
||||||
include ../../Makefile.example.blocksds
|
|
@ -1,11 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
NITRO_ENGINE=$DEVKITPRO/nitro-engine
|
NITRO_ENGINE=../../..
|
||||||
ASSETS=$NITRO_ENGINE/examples/assets
|
ASSETS=$NITRO_ENGINE/examples/assets
|
||||||
TOOLS=$NITRO_ENGINE/tools
|
TOOLS=$NITRO_ENGINE/tools
|
||||||
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
|
||||||
IMG2DS=$TOOLS/img2ds/img2ds.py
|
|
||||||
|
|
||||||
|
rm -rf data
|
||||||
mkdir -p data
|
mkdir -p data
|
||||||
|
|
||||||
python3 $OBJ2DL \
|
python3 $OBJ2DL \
|
||||||
@ -13,9 +13,3 @@ python3 $OBJ2DL \
|
|||||||
--output data/teapot.bin \
|
--output data/teapot.bin \
|
||||||
--texture 256 256 \
|
--texture 256 256 \
|
||||||
--scale 0.1
|
--scale 0.1
|
||||||
|
|
||||||
python3 $IMG2DS \
|
|
||||||
--input $ASSETS/teapot.png \
|
|
||||||
--name teapot \
|
|
||||||
--output data \
|
|
||||||
--format A1RGB5
|
|
||||||
|