Compare commits

...

81 Commits

Author SHA1 Message Date
jonko0493
8932de1fff rich text: Optionally return cursor position from dry run & allow indenting text
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
The goal of the changes made in this PR is to create something with this
effect ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
    crestfallen.

In order to do this, I need to call `NE_RichTextRender3D` or
`NE_RichTextRender3DAlpha` three times: once to draw the first part of
the sentence with the white font, once to draw "Jonko" in turquoise, and
once to draw the remainder of the sentence in white again. In order to
ensure that text is being drawn in the correct location, I need the
position where the previous call stopped drawing, which leads to the
first change this PR makes: I have added a version of
`DSF_StringRenderDryRun` which accepts pointers to `final_x` and
`final_y` and stores the last position of `font->pointer_x` and
`font->pointer_y` in them and I have added a new variant of
`NE_RichTextRenderDryRun` called `NE_RichTextRenderDryRunWithPos` which
uses that DSF function and has analogous parameters.

These functions get us the position where we need to place the next
cursor, but the next issue is that currently NitroEngine and libDSF only
allow for specifying the position of the overall box to draw text in,
but not where to offset the cursor in that box. This leads to the
following problem ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
                        crestfallen.

Thus, the second change: I have introduced new versions of
`DSF_StringRender3D` and `DSF_StringRender3DAlpha` which accept an
`xStart` position that is added to the `pointerX`. Correspondingly, I
have added versions of `NE_RichTextRender3D` and
`NE_RichTextRender3DAlpha` that use these new functions as well.

Let me know if there are any issues with how I've written this (C is not
my forte, after all), but the first screenshot is this being tested in
production code.
2025-06-11 00:03:38 +01:00
Antonio Niño Díaz
86955bc0a0 rich text: Allow the number of fonts to be specified dynamically
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
This switches the rich text library from using a constant for the max
number of fonts to allowing the user to specify how many fonts should be
used dynamically. To accomplish this, a new method is introduced to the
rich text system: `NE_RichTextStartSystem`, which accepts the number of
slots to allocate. Those slots are allocated and then freed when
`NE_RichTextResetSystem` is called.

To maintain compatibility, I have not removed `NE_MAX_RICH_TEXT_FONTS`
(instead opting to mark it as deprecated), and have added functionality
to automatically call `NE_RichTextStartSystem` with that old value (8)
if the user decides to init a rich text slot before calling
`NE_RichTextStartSystem` (which would likely be the previous default
behavior).
2025-05-25 01:32:55 +02:00
jonko0493
6e1dca996c rich text: Allow the number of fonts to be specified dynamically 2025-05-24 09:37:46 -07:00
Antonio Niño Díaz
02f3cd7012 github: Add workflow to publish the documentation
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
2025-05-14 00:02:21 +01:00
Antonio Niño Díaz
926bb4f361 docs: library: Update changelog and version number to 0.15.3 2025-03-26 18:08:47 +00:00
Antonio Niño Díaz
f6b0200be3 build: Build library with debug symbols enabled
They are excluded from the final binaries, so the only effect of this is
to help with debugging by using a bit more of disk space.
2025-03-26 18:06:36 +00:00
Antonio Niño Díaz
d42cb2c08e docs: Update changelog 2025-03-24 21:19:31 +00:00
Antonio Niño Díaz
d52a92812e examples: Use BLOCKSDS environment variables to find tools
Only use the hardcoded paths if the variable isn't set to anything.
2025-03-24 21:18:00 +00:00
Antonio Niño Díaz
cb2e62f953 examples: Refresh pre-converted textures in the repository 2025-03-24 21:05:15 +00:00
Antonio Niño Díaz
5a10679dfb build: docs: Remove outdated devkitARM makefiles
Nitro Engine doesn't work with the current libraries of devkitARM. It's
better to remove the makefiles and to stop pretending that devkitARM is
supported. Updating the makefiles wouldn't be enough, though, it's likely
that the library will require code changes, as well as the examples.
2025-03-24 21:03:01 +00:00
Antonio Niño Díaz
b67c60d5f0 docs: library: Update changelog and library version to 0.15.2 2025-01-15 18:26:00 +00:00
Antonio Niño Díaz
fff1a65647 docs: Add note about using devkitARM 2025-01-15 18:24:47 +00:00
Antonio Niño Díaz
efbf4b6546 docs: Fix link 2025-01-14 01:29:06 +00:00
Antonio Niño Díaz
dd20800334 docs: Mention BlocksDS package in setup instructions 2025-01-14 01:27:25 +00:00
Antonio Niño Díaz
39117696aa build: Uniformize all devkitARM makefiles
Add DATA and GRAPHICS directories to all of them so that it's easier to
maintain the files.
2024-12-31 16:20:02 +01:00
Antonio Niño Díaz
459d8f8960 build: Use ar from ARM toolchain instead of the system one 2024-12-30 02:13:53 +01:00
Antonio Niño Díaz
e5ae245674 examples: Fix build of example on devkitARM 2024-12-28 12:44:36 +01:00
Antonio Niño Díaz
8a18dfa586 doxygen: Update version number in Doxyfile 2024-12-23 00:50:19 +01:00
Antonio Niño Díaz
de9ca58286 docs: library: Update changelog and version number 2024-12-23 00:40:45 +01:00
Antonio Niño Díaz
446e27110e examples: Clarify some comments 2024-12-17 00:38:28 +00:00
Antonio Niño Díaz
09c3712431 build: Install licenses with the rest of the library 2024-12-01 13:42:18 +00:00
Antonio Niño Díaz
a6738a9ab5 docs: library: Update changelog and version number 2024-12-01 12:07:51 +00:00
W3SLAV/gt4ous
afdd56eda4 examples: Fix devkitARM makefile
Added missing data directory.
2024-11-30 13:38:07 +00:00
Antonio Niño Díaz
fe6e4a0dcc examples: Add example of assigning a matrix to a model 2024-10-11 13:33:33 +02:00
Antonio Niño Díaz
4642bdf982 library: Allow users to specify model transformation matrices
A manual matrix overrides scale, translation and rotation. It can be
removed to switch back to individual scale, translation and rotation.
2024-10-11 13:33:21 +02:00
Antonio Niño Díaz
26823c024f docs: library: Update changelog and bump version to 0.14.0 2024-09-10 18:18:30 +01:00
Antonio Niño Díaz
5a4824f461 library: Fix use-after-free in RichText module
When this function doesn't fail, it should preserve the buffers that
have just been allocated, as they will be used later.
2024-08-14 00:47:06 +01:00
Antonio Niño Díaz
de16a59722 library: Fixes to RichText module 2024-08-14 00:45:07 +01:00
Antonio Niño Díaz
4115a62800 libdsf: Update to v0.1.3 2024-08-14 00:44:23 +01:00
Antonio Niño Díaz
88d1b489f6 examples: Update BlocksDS Makefiles
They were missing several updates made over the last few months.
2024-08-14 00:43:55 +01:00
Antonio Niño Díaz
7d13c2d637 docs: Update Doxyfile 2024-08-01 18:02:17 +01:00
Antonio Niño Díaz
5dda97fe52 Use stdint.h types instead of libnds custom types 2024-07-29 00:09:41 +01:00
Antonio Niño Díaz
c2af70fe15 docs: Update changelog 2024-06-08 12:53:34 +01:00
Antonio Niño Díaz
dce5e99f0f library: Optimize copy of NE_RGB5 textures to VRAM
This is the same optimization made by asie here:

479ca8fb77
2024-06-05 02:28:40 +01:00
Antonio Niño Díaz
1c752174e9 examples: Stop using NE_RGB5 in examples
This texture format sets bit 15 manually to 1. This is slow, and it's
better if the developer converts graphics in a way that the bit is already
set to 1.
2024-06-03 18:39:33 +01:00
Antonio Niño Díaz
935f7eb084 examples: Update binaries used by the examples
This isn't strictly required, but this way running the global assets.sh
won't cause lots of files to be marked as modified.
2024-06-02 21:55:32 +01:00
Antonio Niño Díaz
0f92fc9da7 build: Use BlocksDS paths for assets conversion scripts 2024-06-02 21:50:06 +01:00
Antonio Niño Díaz
3f4bfbdb25 examples: Remove unused files 2024-06-02 18:06:51 +01:00
Antonio Niño Díaz
b52b704000 build: Rename BlocksDS makefile 2024-06-02 18:06:00 +01:00
Antonio Niño Díaz
902314a2ac docs: build: Add simplified global build targets 2024-06-02 17:38:55 +01:00
Antonio Niño Díaz
3ba35ba48e docs: build: library: examples: Set BlocksDS as main toolchain
Until now the main makefiles of Nitro Engine have been the ones of
devkitPro, forcing users to go through extra steps to build everything
under BlocksDS.

Now, the easy makefiles are the BlocksDS ones, and additional notes have
been added to warn about the limitations of devkitPro:

- No GRF support in libnds.
- NitroFS doesn't work in melonDS.
2024-06-02 17:38:52 +01:00
Antonio Niño Díaz
381e4071ac tools: Update md5_2_dsma
This fixes a bug where the base animation of the model (its standing pose)
would be exported with the wrong extension.
2024-06-02 12:08:08 +01:00
Antonio Niño Díaz
ccb3739f98 docs: Add note about ArchitectDS to the readme 2024-06-01 02:03:38 +01:00
Antonio Niño Díaz
230a65541e docs: Remove version from readme
This gets out of date easily and it isn't that useful anyway.
2024-04-09 01:53:49 +01:00
Antonio Niño Díaz
7dda3abe54 docs: Update changelog 2024-03-30 11:41:28 +00:00
Antonio Niño Díaz
3f3e266a4f library: Implement priority setting functions in RichText
This reverts commit 48ff37231f ("library: Remove unimplemented
functions from RichText system").

I thought the 3D drawing functions took a "depth" argument, but I was
wrong. I'm re-introducing the functions (and, this time, with an actual
implementation).
2024-03-30 00:34:39 +00:00
Antonio Niño Díaz
5ce71a9b02 library: Add function to calculate rendered text size
This simply exposes DSF_StringRenderDryRun() in a way that can be easily
used with Nitro Engine.
2024-03-29 22:21:22 +00:00
Antonio Niño Díaz
12b7389d1f examples: Remove asset from example that doesn't use it 2024-03-29 19:39:12 +00:00
Antonio Niño Díaz
48ff37231f library: Remove unimplemented functions from RichText system
They were never meant to be there, they are a copy-paste error from taking
the code of the original text system to create the original files of the
rich text system.
2024-03-29 14:56:55 +00:00
William
ff734036fc
fix: NE_RichTextMetadataLoadFAT returning error code on success 2024-03-28 14:19:30 +00:00
Antonio Niño Díaz
d7ecc5cc4d templates: examples: Fix linker invocation for C++
Using g++ to link object files automatically links the STD of C++. It looks
like this library is linked outside of the start/end-group commands with
the other libraries, which causes undefined reference errors when linking
C++ projects that use standard library functions that interface with the
OS, like `fopen()`.

Thanks to @lifehackerhansol for the report and testing the fix.
2024-03-26 18:54:35 +00:00
Antonio Niño Díaz
5ea29c4f81 docs: Update sprites screenshot in readme 2024-03-24 16:52:19 +00:00
Antonio Niño Díaz
b40f67c593 examples: Improve sprites example 2024-03-24 16:50:51 +00:00
Antonio Niño Díaz
8cb10264bb library: Support setting texture coordinates in sprites
This allows you to use one single texture for multiple images, and to
specify the coordinates that a sprite needs to use so that you don't need
to keep track of them.
2024-03-24 16:14:21 +00:00
Antonio Niño Díaz
cf1a3c48e2 library: Fix build on devkitARM 2024-03-20 23:42:15 +00:00
Antonio Niño Díaz
b0d9151455 library: Build some functions as ARM to increase performance
Using `mulf32()` while compiling functions to Thumb makes the compiler
add calls to `__aeabi_lmul()` once per multiplication. This routine is
quite slow, so the cost of any function that uses `mulf32()` a lot is
quite high.

Switching math-heavy functions to ARM increases performance and reduces
code size.
2024-03-16 03:04:02 +01:00
Antonio Niño Díaz
82171bbf69 chore: Simplify copyright years in notices
Instead of listing every individual year, keep only the first and last
years.
2024-03-09 01:42:29 +00:00
Antonio Niño Díaz
47c8061168 examples: test: Refactor to avoid global variables
Using global variables is generally discouraged. Now that NE_ProcessArg()
and NE_ProcessDualArg() exist, it's better to show how to use them instead
of NE_Process() and NE_ProcessDual() while using global variables.

Also, switch from "int main(void)" to "int main(int argc, char *argv[])".
2024-03-08 18:44:02 +00:00
Antonio Niño Díaz
9f81541075 examples: Remove global variables from some examples 2024-03-08 02:43:18 +00:00
Antonio Niño Díaz
a06617a93f examples: Cleanup variables of 2D quads example 2024-03-08 02:43:18 +00:00
Antonio Niño Díaz
fc73687b79 docs: Update list of future work items 2024-03-07 02:41:06 +00:00
Antonio Niño Díaz
052a15b974 example: Stop using deprecated NE_ShadingEnabled() 2024-03-07 01:49:25 +00:00
Antonio Niño Díaz
bf63ddea8a examples: Remove unneeded calls to NE_ShadowEnable()
This function wasn't required for regular shading, but for toon shading.
2024-03-07 01:49:07 +00:00
Antonio Niño Díaz
636a7d73c3 library: Deprecate NE_ShadingEnable()
This has been replaced by NE_SetupToonShadingTables(), which is a more
sensible name.

A define has been added for compatibility.
2024-03-07 01:48:34 +00:00
Antonio Niño Díaz
521012d4d1 library: Add function to reset rich text system 2024-03-07 01:26:15 +00:00
Antonio Niño Díaz
15ce18b74c examples: Add example of loading rich text fonts from RAM 2024-03-07 01:22:36 +00:00
Antonio Niño Díaz
dd746c0ef5 library: Allow loading font bitmaps from RAM, not just the filesystem 2024-03-07 01:20:00 +00:00
Antonio Niño Díaz
a49ddecda7 examples: Fix incorrect comments 2024-03-06 23:05:28 +00:00
Antonio Niño Díaz
30ac9ab8e9 library: Don't expect palette objects when loading GRF files
Currently, if the user wants to load a GRF file with a palette, the
function NE_MaterialTexLoadGRF() will fail unless it is provided a palette
object.

With this change, if a palette object isn't provided, it will be created
and marked for automatic deletion when the material is deleted.
2024-03-06 22:17:49 +00:00
Antonio Niño Díaz
edf4457d49 examples: Fix typo 2024-03-06 22:02:30 +00:00
Antonio Niño Díaz
e952990ae4 examples: Improve volumetric shadow example
The light in the dark room was too bright.
2024-03-06 21:41:11 +00:00
Antonio Niño Díaz
3273bd7333 examples: Fix comment 2024-03-06 21:41:11 +00:00
Antonio Niño Díaz
c22fa167e7 docs: Add shadow volume screenshot to readme 2024-03-06 21:41:11 +00:00
Antonio Niño Díaz
5a2b722128 examples: Add shadow volume example 2024-03-06 21:41:11 +00:00
Antonio Niño Díaz
227bffddc5 library: Fix compilation with devkitARM 2024-03-06 01:31:40 +00:00
Antonio Niño Díaz
a85b16284f library: Update libDSF to version 0.1.2 2024-03-05 01:55:19 +00:00
Antonio Niño Díaz
006bcf9d01 library: Add note about texture sizes for rich text 2024-03-03 19:59:49 +00:00
Antonio Niño Díaz
366a9532c1 libdsf: Update to version 0.1.1 2024-03-03 19:59:15 +00:00
Antonio Niño Díaz
719935647a library: Relicense libdsf under "Zlib OR MIT"
Nitro Engine and DSMA use the MIT license. This way everything can be used
under the MIT license.
2024-03-02 18:47:38 +00:00
Antonio Niño Díaz
e94ed5b4e3 docs: Add screenshot of text rendering to readme 2024-03-02 18:43:19 +00:00
Antonio Niño Díaz
935c06e296 library: Add note about the replacement character 2024-03-02 18:42:00 +00:00
268 changed files with 4333 additions and 12639 deletions

79
.github/workflows/build.yml vendored Normal file
View 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
View File

@ -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 source/libdsf
DATA := data
INCLUDES := include source/libdsf
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
#---------------------------------------------------------------------------------------

View File

@ -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 \
@ -147,6 +147,7 @@ install: all
$(V)$(CP) -r tools/img2ds/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/img2ds $(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/md5_to_dsma/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/md5_to_dsma
$(V)$(CP) -r tools/obj2dl/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl $(V)$(CP) -r tools/obj2dl/*.py $(BLOCKSDSEXT)/$(INSTALLNAME)/tools/obj2dl
$(V)$(CP) -r licenses $(BLOCKSDSEXT)/$(INSTALLNAME)/
clean: clean:
@echo " CLEAN" @echo " CLEAN"

View File

@ -1,6 +1,81 @@
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) Version 0.11.0 (2024-03-02)
--------------------------- ---------------------------

View File

@ -1,4 +1,4 @@
# Doxyfile 1.9.4 # Doxyfile 1.9.8
# This file describes the settings to be used by the documentation system # This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project. # doxygen (www.doxygen.org) for a project.
@ -19,7 +19,8 @@
# configuration file: # configuration file:
# doxygen -x [configFile] # doxygen -x [configFile]
# Use doxygen to compare the used configuration file with the template # Use doxygen to compare the used configuration file with the template
# configuration file without replacing the environment variables: # configuration file without replacing the environment variables or CMake type
# replacement variables:
# doxygen -x_noenv [configFile] # doxygen -x_noenv [configFile]
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -47,7 +48,7 @@ PROJECT_NAME = "Nitro Engine"
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 0.11.0 PROJECT_NUMBER = 0.15.3
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a
@ -85,7 +86,7 @@ CREATE_SUBDIRS = NO
# level increment doubles the number of directories, resulting in 4096 # level increment doubles the number of directories, resulting in 4096
# directories at level 8 which is the default and also the maximum value. The # directories at level 8 which is the default and also the maximum value. The
# sub-directories are organized in 2 levels, the first level always has a fixed # sub-directories are organized in 2 levels, the first level always has a fixed
# numer of 16 directories. # number of 16 directories.
# Minimum value: 0, maximum value: 8, default value: 8. # Minimum value: 0, maximum value: 8, default value: 8.
# This tag requires that the tag CREATE_SUBDIRS is set to YES. # This tag requires that the tag CREATE_SUBDIRS is set to YES.
@ -362,6 +363,17 @@ MARKDOWN_SUPPORT = YES
TOC_INCLUDE_HEADINGS = 0 TOC_INCLUDE_HEADINGS = 0
# The MARKDOWN_ID_STYLE tag can be used to specify the algorithm used to
# generate identifiers for the Markdown headings. Note: Every identifier is
# unique.
# Possible values are: DOXYGEN use a fixed 'autotoc_md' string followed by a
# sequence number starting at 0 and GITHUB use the lower case version of title
# with any whitespace replaced by '-' and punctuation characters removed.
# The default value is: DOXYGEN.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
MARKDOWN_ID_STYLE = DOXYGEN
# When enabled doxygen tries to link words that correspond to documented # When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can # classes, or namespaces to their corresponding documentation. Such a link can
# be prevented in individual cases by putting a % sign in front of the word or # be prevented in individual cases by putting a % sign in front of the word or
@ -486,6 +498,14 @@ LOOKUP_CACHE_SIZE = 0
NUM_PROC_THREADS = 1 NUM_PROC_THREADS = 1
# If the TIMESTAMP tag is set different from NO then each generated page will
# contain the date or date and time when the page was generated. Setting this to
# NO can help when comparing the output of multiple runs.
# Possible values are: YES, NO, DATETIME and DATE.
# The default value is: NO.
TIMESTAMP = NO
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Build related configuration options # Build related configuration options
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -567,7 +587,8 @@ HIDE_UNDOC_MEMBERS = YES
# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy. If set # undocumented classes that are normally visible in the class hierarchy. If set
# to NO, these classes will be included in the various overviews. This option # to NO, these classes will be included in the various overviews. This option
# has no effect if EXTRACT_ALL is enabled. # will also hide undocumented C++ concepts if enabled. This option has no effect
# if EXTRACT_ALL is enabled.
# The default value is: NO. # The default value is: NO.
HIDE_UNDOC_CLASSES = YES HIDE_UNDOC_CLASSES = YES
@ -605,7 +626,8 @@ INTERNAL_DOCS = NO
# Windows (including Cygwin) and MacOS, users should typically set this option # Windows (including Cygwin) and MacOS, users should typically set this option
# to NO, whereas on Linux or other Unix flavors it should typically be set to # to NO, whereas on Linux or other Unix flavors it should typically be set to
# YES. # YES.
# The default value is: system dependent. # Possible values are: SYSTEM, NO and YES.
# The default value is: SYSTEM.
CASE_SENSE_NAMES = YES CASE_SENSE_NAMES = YES
@ -857,11 +879,26 @@ WARN_IF_INCOMPLETE_DOC = YES
WARN_NO_PARAMDOC = YES WARN_NO_PARAMDOC = YES
# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about
# undocumented enumeration values. If set to NO, doxygen will accept
# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag
# will automatically be disabled.
# The default value is: NO.
WARN_IF_UNDOC_ENUM_VAL = NO
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS # a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS
# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but # then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but
# at the end of the doxygen process doxygen will return with a non-zero status. # at the end of the doxygen process doxygen will return with a non-zero status.
# Possible values are: NO, YES and FAIL_ON_WARNINGS. # If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS_PRINT then doxygen behaves
# like FAIL_ON_WARNINGS but in case no WARN_LOGFILE is defined doxygen will not
# write the warning messages in between other messages but write them at the end
# of a run, in case a WARN_LOGFILE is defined the warning messages will be
# besides being in the defined file also be shown at the end of a run, unless
# the WARN_LOGFILE is defined as - i.e. standard output (stdout) in that case
# the behavior will remain as with the setting FAIL_ON_WARNINGS.
# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT.
# The default value is: NO. # The default value is: NO.
WARN_AS_ERROR = NO WARN_AS_ERROR = NO
@ -914,10 +951,21 @@ INPUT = ../source \
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv # libiconv (or the iconv built into libc) for the transcoding. See the libiconv
# documentation (see: # documentation (see:
# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # https://www.gnu.org/software/libiconv/) for the list of possible encodings.
# See also: INPUT_FILE_ENCODING
# The default value is: UTF-8. # The default value is: UTF-8.
INPUT_ENCODING = UTF-8 INPUT_ENCODING = UTF-8
# This tag can be used to specify the character encoding of the source files
# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify
# character encoding on a per file pattern basis. Doxygen will compare the file
# name with each pattern and apply the encoding instead of the default
# INPUT_ENCODING) if there is a match. The character encodings are a list of the
# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding
# "INPUT_ENCODING" for further information on supported encodings.
INPUT_FILE_ENCODING =
# If the value of the INPUT tag contains directories, you can use the # If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
# *.h) to filter out the source-files in the directories. # *.h) to filter out the source-files in the directories.
@ -929,12 +977,12 @@ INPUT_ENCODING = UTF-8
# Note the list of default checked file patterns might differ from the list of # Note the list of default checked file patterns might differ from the list of
# default file extension mappings. # default file extension mappings.
# #
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cxxm,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.cpp, *.cppm, *.c++, *.c++m, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl,
# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, # *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, *.h++, *.ixx, *.l, *.cs, *.d, *.php,
# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C # *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be
# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, # provided as doxygen C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
# *.vhdl, *.ucf, *.qsf and *.ice. # *.f18, *.f, *.for, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.h *.h
@ -975,9 +1023,6 @@ EXCLUDE_PATTERNS =
# output. The symbol name can be a fully qualified name, a word, or if the # output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass, # wildcard * is used, a substring. Examples: ANamespace, AClass,
# ANamespace::AClass, ANamespace::*Test # ANamespace::AClass, ANamespace::*Test
#
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/*
EXCLUDE_SYMBOLS = EXCLUDE_SYMBOLS =
@ -1022,6 +1067,11 @@ IMAGE_PATH =
# code is scanned, but not when the output code is generated. If lines are added # code is scanned, but not when the output code is generated. If lines are added
# or removed, the anchors will not be placed correctly. # or removed, the anchors will not be placed correctly.
# #
# Note that doxygen will use the data processed and written to standard output
# for further processing, therefore nothing else, like debug statements or used
# commands (so in case of a Windows batch file always use @echo OFF), should be
# written to standard output.
#
# Note that for custom extensions or not directly supported extensions you also # Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not # need to set EXTENSION_MAPPING for the extension otherwise the files are not
# properly processed by doxygen. # properly processed by doxygen.
@ -1063,6 +1113,15 @@ FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE = USE_MDFILE_AS_MAINPAGE =
# The Fortran standard specifies that for fixed formatted Fortran code all
# characters from position 72 are to be considered as comment. A common
# extension is to allow longer lines before the automatic comment starts. The
# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can
# be processed before the automatic comment starts.
# Minimum value: 7, maximum value: 10000, default value: 72.
FORTRAN_COMMENT_AFTER = 72
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to source browsing # Configuration options related to source browsing
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -1200,10 +1259,11 @@ CLANG_DATABASE_PATH =
ALPHABETICAL_INDEX = YES ALPHABETICAL_INDEX = YES
# In case all classes in a project start with a common prefix, all classes will # The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes)
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # that should be ignored while generating the index headers. The IGNORE_PREFIX
# can be used to specify a prefix (or a list of prefixes) that should be ignored # tag works for classes, function and member names. The entity will be placed in
# while generating the index headers. # the alphabetical list under the first letter of the entity name that remains
# after removing the prefix.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
IGNORE_PREFIX = IGNORE_PREFIX =
@ -1282,7 +1342,12 @@ HTML_STYLESHEET =
# Doxygen will copy the style sheet files to the output directory. # Doxygen will copy the style sheet files to the output directory.
# Note: The order of the extra style sheet files is of importance (e.g. the last # Note: The order of the extra style sheet files is of importance (e.g. the last
# style sheet in the list overrules the setting of the previous ones in the # style sheet in the list overrules the setting of the previous ones in the
# list). For an example see the documentation. # list).
# Note: Since the styling of scrollbars can currently not be overruled in
# Webkit/Chromium, the styling will be left out of the default doxygen.css if
# one or more extra stylesheets have been specified. So if scrollbar
# customization is desired it has to be added explicitly. For an example see the
# documentation.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = HTML_EXTRA_STYLESHEET =
@ -1297,6 +1362,19 @@ HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES = HTML_EXTRA_FILES =
# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output
# should be rendered with a dark or light theme.
# Possible values are: LIGHT always generate light mode output, DARK always
# generate dark mode output, AUTO_LIGHT automatically set the mode according to
# the user preference, use light mode if no preference is set (the default),
# AUTO_DARK automatically set the mode according to the user preference, use
# dark mode if no preference is set and TOGGLE allow to user to switch between
# light and dark mode via a button.
# The default value is: AUTO_LIGHT.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE = AUTO_LIGHT
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to # will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a color-wheel, see # this color. Hue is specified as an angle on a color-wheel, see
@ -1327,15 +1405,6 @@ HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80 HTML_COLORSTYLE_GAMMA = 80
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
# page will contain the date and time when the page was generated. Setting this
# to YES can help to show when doxygen was last run and thus if the
# documentation is up to date.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_TIMESTAMP = NO
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that # documentation will contain a main index with vertical navigation menus that
# are dynamically created via JavaScript. If disabled, the navigation index will # are dynamically created via JavaScript. If disabled, the navigation index will
@ -1355,6 +1424,13 @@ HTML_DYNAMIC_MENUS = YES
HTML_DYNAMIC_SECTIONS = NO HTML_DYNAMIC_SECTIONS = NO
# If the HTML_CODE_FOLDING tag is set to YES then classes and functions can be
# dynamically folded and expanded in the generated HTML source code.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_CODE_FOLDING = YES
# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
# shown in the various tree structured indices initially; the user can expand # shown in the various tree structured indices initially; the user can expand
# and collapse entries dynamically later on. Doxygen will expand the tree to # and collapse entries dynamically later on. Doxygen will expand the tree to
@ -1485,6 +1561,16 @@ BINARY_TOC = NO
TOC_EXPAND = NO TOC_EXPAND = NO
# The SITEMAP_URL tag is used to specify the full URL of the place where the
# generated documentation will be placed on the server by the user during the
# deployment of the documentation. The generated sitemap is called sitemap.xml
# and placed on the directory specified by HTML_OUTPUT. In case no SITEMAP_URL
# is specified no sitemap is generated. For information about the sitemap
# protocol see https://www.sitemaps.org
# This tag requires that the tag GENERATE_HTML is set to YES.
SITEMAP_URL =
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
@ -1660,17 +1746,6 @@ HTML_FORMULA_FORMAT = png
FORMULA_FONTSIZE = 10 FORMULA_FONTSIZE = 10
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
# Note that when changing this option you need to delete any form_*.png files in
# the HTML output directory before the changes have effect.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_TRANSPARENT = YES
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands # The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
# to create new LaTeX commands to be used in formulas as building blocks. See # to create new LaTeX commands to be used in formulas as building blocks. See
# the section "Including formulas" for details. # the section "Including formulas" for details.
@ -1984,9 +2059,16 @@ PDF_HYPERLINKS = YES
USE_PDFLATEX = YES USE_PDFLATEX = YES
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode # The LATEX_BATCHMODE tag signals the behavior of LaTeX in case of an error.
# command to the generated LaTeX files. This will instruct LaTeX to keep running # Possible values are: NO same as ERROR_STOP, YES same as BATCH, BATCH In batch
# if errors occur, instead of asking the user for help. # mode nothing is printed on the terminal, errors are scrolled as if <return> is
# hit at every error; missing files that TeX tries to input or request from
# keyboard input (\read on a not open input stream) cause the job to abort,
# NON_STOP In nonstop mode the diagnostic message will appear on the terminal,
# but there is no possibility of user interaction just like in batch mode,
# SCROLL In scroll mode, TeX will stop only for missing files to input or if
# keyboard input is necessary and ERROR_STOP In errorstop mode, TeX will stop at
# each error, asking for user intervention.
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES. # This tag requires that the tag GENERATE_LATEX is set to YES.
@ -2007,14 +2089,6 @@ LATEX_HIDE_INDICES = NO
LATEX_BIB_STYLE = plain LATEX_BIB_STYLE = plain
# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
# page will contain the date and time when the page was generated. Setting this
# to NO can help when comparing the output of multiple runs.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_TIMESTAMP = NO
# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) # The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
# path from which the emoji images will be read. If a relative path is entered, # path from which the emoji images will be read. If a relative path is entered,
# it will be relative to the LATEX_OUTPUT directory. If left blank the # it will be relative to the LATEX_OUTPUT directory. If left blank the
@ -2180,13 +2254,39 @@ DOCBOOK_OUTPUT = docbook
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures # AutoGen Definitions (see https://autogen.sourceforge.net/) file that captures
# the structure of the code including all documentation. Note that this feature # the structure of the code including all documentation. Note that this feature
# is still experimental and incomplete at the moment. # is still experimental and incomplete at the moment.
# The default value is: NO. # The default value is: NO.
GENERATE_AUTOGEN_DEF = NO GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to Sqlite3 output
#---------------------------------------------------------------------------
# If the GENERATE_SQLITE3 tag is set to YES doxygen will generate a Sqlite3
# database with symbols found by doxygen stored in tables.
# The default value is: NO.
GENERATE_SQLITE3 = NO
# The SQLITE3_OUTPUT tag is used to specify where the Sqlite3 database will be
# put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put
# in front of it.
# The default directory is: sqlite3.
# This tag requires that the tag GENERATE_SQLITE3 is set to YES.
SQLITE3_OUTPUT = sqlite3
# The SQLITE3_OVERWRITE_DB tag is set to YES, the existing doxygen_sqlite3.db
# database file will be recreated with each doxygen run. If set to NO, doxygen
# will warn if an a database file is already found and not modify it.
# The default value is: YES.
# This tag requires that the tag GENERATE_SQLITE3 is set to YES.
SQLITE3_RECREATE_DB = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the Perl module output # Configuration options related to the Perl module output
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -2329,15 +2429,15 @@ TAGFILES =
GENERATE_TAGFILE = GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES, all external class will be listed in # If the ALLEXTERNALS tag is set to YES, all external classes and namespaces
# the class index. If set to NO, only the inherited external classes will be # will be listed in the class and namespace index. If set to NO, only the
# listed. # inherited external classes will be listed.
# The default value is: NO. # The default value is: NO.
ALLEXTERNALS = NO ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed # If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will be # in the topic index. If set to NO, only the current project's groups will be
# listed. # listed.
# The default value is: YES. # The default value is: YES.
@ -2351,16 +2451,9 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES EXTERNAL_PAGES = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the dot tool # Configuration options related to diagram generator tools
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
# If left empty dia is assumed to be found in the default search path.
DIA_PATH =
# If set to YES the inheritance and collaboration graphs will hide inheritance # If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class. # and usage relations if the target is undocumented or is not a class.
# The default value is: YES. # The default value is: YES.
@ -2369,7 +2462,7 @@ HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz (see: # available from the path. This tool is part of Graphviz (see:
# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # https://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
# Bell Labs. The other options in this section have no effect if this option is # Bell Labs. The other options in this section have no effect if this option is
# set to NO # set to NO
# The default value is: YES. # The default value is: YES.
@ -2386,37 +2479,51 @@ HAVE_DOT = NO
DOT_NUM_THREADS = 0 DOT_NUM_THREADS = 0
# When you want a differently looking font in the dot files that doxygen # DOT_COMMON_ATTR is common attributes for nodes, edges and labels of
# generates you can specify the font name using DOT_FONTNAME. You need to make # subgraphs. When you want a differently looking font in the dot files that
# sure dot is able to find the font, which can be done by putting it in a # doxygen generates you can specify fontname, fontcolor and fontsize attributes.
# standard location or by setting the DOTFONTPATH environment variable or by # For details please see <a href=https://graphviz.org/doc/info/attrs.html>Node,
# setting DOT_FONTPATH to the directory containing the font. # Edge and Graph Attributes specification</a> You need to make sure dot is able
# The default value is: Helvetica. # to find the font, which can be done by putting it in a standard location or by
# setting the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
# directory containing the font. Default graphviz fontsize is 14.
# The default value is: fontname=Helvetica,fontsize=10.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTNAME = FreeSans DOT_COMMON_ATTR = "fontname=FreeSans,fontsize=10"
# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of # DOT_EDGE_ATTR is concatenated with DOT_COMMON_ATTR. For elegant style you can
# dot graphs. # add 'arrowhead=open, arrowtail=open, arrowsize=0.5'. <a
# Minimum value: 4, maximum value: 24, default value: 10. # href=https://graphviz.org/doc/info/arrows.html>Complete documentation about
# arrows shapes.</a>
# The default value is: labelfontname=Helvetica,labelfontsize=10.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTSIZE = 10 DOT_EDGE_ATTR = "labelfontname=FreeSans,labelfontsize=10"
# By default doxygen will tell dot to use the default font as specified with # DOT_NODE_ATTR is concatenated with DOT_COMMON_ATTR. For view without boxes
# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set # around nodes set 'shape=plain' or 'shape=plaintext' <a
# the path where dot can find it using this tag. # href=https://www.graphviz.org/doc/info/shapes.html>Shapes specification</a>
# The default value is: shape=box,height=0.2,width=0.4.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4"
# You can set the path where dot can find font specified with fontname in
# DOT_COMMON_ATTR and others dot attributes.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTPATH = DOT_FONTPATH =
# If the CLASS_GRAPH tag is set to YES (or GRAPH) then doxygen will generate a # If the CLASS_GRAPH tag is set to YES or GRAPH or BUILTIN then doxygen will
# graph for each documented class showing the direct and indirect inheritance # generate a graph for each documented class showing the direct and indirect
# relations. In case HAVE_DOT is set as well dot will be used to draw the graph, # inheritance relations. In case the CLASS_GRAPH tag is set to YES or GRAPH and
# otherwise the built-in generator will be used. If the CLASS_GRAPH tag is set # HAVE_DOT is enabled as well, then dot will be used to draw the graph. In case
# to TEXT the direct and indirect inheritance relations will be shown as texts / # the CLASS_GRAPH tag is set to YES and HAVE_DOT is disabled or if the
# links. # CLASS_GRAPH tag is set to BUILTIN, then the built-in generator will be used.
# Possible values are: NO, YES, TEXT and GRAPH. # If the CLASS_GRAPH tag is set to TEXT the direct and indirect inheritance
# relations will be shown as texts / links.
# Possible values are: NO, YES, TEXT, GRAPH and BUILTIN.
# The default value is: YES. # The default value is: YES.
CLASS_GRAPH = TEXT CLASS_GRAPH = TEXT
@ -2424,15 +2531,21 @@ CLASS_GRAPH = TEXT
# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a # If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
# graph for each documented class showing the direct and indirect implementation # graph for each documented class showing the direct and indirect implementation
# dependencies (inheritance, containment, and class references variables) of the # dependencies (inheritance, containment, and class references variables) of the
# class with other documented classes. # class with other documented classes. Explicit enabling a collaboration graph,
# when COLLABORATION_GRAPH is set to NO, can be accomplished by means of the
# command \collaborationgraph. Disabling a collaboration graph can be
# accomplished by means of the command \hidecollaborationgraph.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
COLLABORATION_GRAPH = YES COLLABORATION_GRAPH = YES
# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
# groups, showing the direct groups dependencies. See also the chapter Grouping # groups, showing the direct groups dependencies. Explicit enabling a group
# in the manual. # dependency graph, when GROUP_GRAPHS is set to NO, can be accomplished by means
# of the command \groupgraph. Disabling a directory graph can be accomplished by
# means of the command \hidegroupgraph. See also the chapter Grouping in the
# manual.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
@ -2492,7 +2605,9 @@ TEMPLATE_RELATIONS = NO
# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to # If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
# YES then doxygen will generate a graph for each documented file showing the # YES then doxygen will generate a graph for each documented file showing the
# direct and indirect include dependencies of the file with other documented # direct and indirect include dependencies of the file with other documented
# files. # files. Explicit enabling an include graph, when INCLUDE_GRAPH is is set to NO,
# can be accomplished by means of the command \includegraph. Disabling an
# include graph can be accomplished by means of the command \hideincludegraph.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
@ -2501,7 +2616,10 @@ INCLUDE_GRAPH = YES
# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
# set to YES then doxygen will generate a graph for each documented file showing # set to YES then doxygen will generate a graph for each documented file showing
# the direct and indirect include dependencies of the file with other documented # the direct and indirect include dependencies of the file with other documented
# files. # files. Explicit enabling an included by graph, when INCLUDED_BY_GRAPH is set
# to NO, can be accomplished by means of the command \includedbygraph. Disabling
# an included by graph can be accomplished by means of the command
# \hideincludedbygraph.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
@ -2541,7 +2659,10 @@ GRAPHICAL_HIERARCHY = YES
# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the # If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
# dependencies a directory has on other directories in a graphical way. The # dependencies a directory has on other directories in a graphical way. The
# dependency relations are determined by the #include relations between the # dependency relations are determined by the #include relations between the
# files in the directories. # files in the directories. Explicit enabling a directory graph, when
# DIRECTORY_GRAPH is set to NO, can be accomplished by means of the command
# \directorygraph. Disabling a directory graph can be accomplished by means of
# the command \hidedirectorygraph.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES. # This tag requires that the tag HAVE_DOT is set to YES.
@ -2557,7 +2678,7 @@ DIR_GRAPH_MAX_DEPTH = 1
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. For an explanation of the image formats see the section # generated by dot. For an explanation of the image formats see the section
# output formats in the documentation of the dot tool (Graphviz (see: # output formats in the documentation of the dot tool (Graphviz (see:
# http://www.graphviz.org/)). # https://www.graphviz.org/)).
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
# to make the SVG files visible in IE 9+ (other browsers do not have this # to make the SVG files visible in IE 9+ (other browsers do not have this
# requirement). # requirement).
@ -2595,11 +2716,12 @@ DOT_PATH =
DOTFILE_DIRS = DOTFILE_DIRS =
# The MSCFILE_DIRS tag can be used to specify one or more directories that # You can include diagrams made with dia in doxygen documentation. Doxygen will
# contain msc files that are included in the documentation (see the \mscfile # then run dia to produce the diagram and insert it in the documentation. The
# command). # DIA_PATH tag allows you to specify the directory where the dia binary resides.
# If left empty dia is assumed to be found in the default search path.
MSCFILE_DIRS = DIA_PATH =
# The DIAFILE_DIRS tag can be used to specify one or more directories that # The DIAFILE_DIRS tag can be used to specify one or more directories that
# contain dia files that are included in the documentation (see the \diafile # contain dia files that are included in the documentation (see the \diafile
@ -2649,18 +2771,6 @@ DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000 MAX_DOT_GRAPH_DEPTH = 1000
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
# background. This is disabled by default, because dot on Windows does not seem
# to support this out of the box.
#
# Warning: Depending on the platform used, enabling this option may lead to
# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
# read).
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_TRANSPARENT = YES
# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This # files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10) support # makes dot run faster, but since only newer versions of dot (>1.8.10) support
@ -2688,3 +2798,19 @@ GENERATE_LEGEND = YES
# The default value is: YES. # The default value is: YES.
DOT_CLEANUP = YES DOT_CLEANUP = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. If the MSCGEN_TOOL tag is left empty (the default), then doxygen will
# use a built-in version of mscgen tool to produce the charts. Alternatively,
# the MSCGEN_TOOL tag can also specify the name an external tool. For instance,
# specifying prog as the value, doxygen will call the tool as prog -T
# <outfile_format> -o <outputfile> <inputfile>. The external tool should support
# output file formats "png", "eps", "svg", and "ismap".
MSCGEN_TOOL =
# The MSCFILE_DIRS tag can be used to specify one or more directories that
# contain msc files that are included in the documentation (see the \mscfile
# command).
MSCFILE_DIRS =

View File

@ -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;

View File

@ -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;

View File

@ -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 :=
GRAPHICS := 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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
GFXDIRS := graphics
include ../../Makefile.example.blocksds

View File

@ -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-2022
// //
// This file is part of Nitro Engine // This file is part of Nitro Engine
@ -16,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);

View File

@ -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 :=
GRAPHICS := 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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
GFXDIRS := graphics
include ../../Makefile.example.blocksds

View File

@ -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
@ -18,11 +18,15 @@
#include "s64.h" #include "s64.h"
#include "s256.h" #include "s256.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();
@ -30,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();
@ -58,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,
s8Bitmap); 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,
s16Bitmap); 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,
s64Bitmap); 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,
s256Bitmap); s256Bitmap);
NE_PaletteLoad(Palette_s8, s8Pal, 16, NE_PAL16); NE_PaletteLoad(Scene.Palette_s8, s8Pal, 16, NE_PAL16);
NE_PaletteLoad(Palette_s16, s16Pal, 16, NE_PAL16); NE_PaletteLoad(Scene.Palette_s16, s16Pal, 16, NE_PAL16);
NE_PaletteLoad(Palette_s64, s64Pal, 16, NE_PAL16); NE_PaletteLoad(Scene.Palette_s64, s64Pal, 16, NE_PAL16);
NE_PaletteLoad(Palette_s256, s256Pal, 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;

View File

@ -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
#---------------------------------------------------------------------------------------

View File

@ -1,4 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
include ../../Makefile.example.blocksds

View File

@ -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_t 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();

View File

@ -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 :=
GRAPHICS := 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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
GFXDIRS := graphics
include ../../Makefile.example.blocksds

View File

@ -0,0 +1,2 @@
# 256 color palette
-gx -gb -gB8 -gTFF00FF

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 796 B

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -1,73 +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 "assets.h"
#include "icon.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,
NE_TEXGEN_TEXCOORD | NE_TEXTURE_COLOR0_TRANSPARENT,
iconBitmap); iconBitmap);
NE_PaletteLoad(Palette, iconPal, 32, NE_PAL16); NE_PaletteLoad(PaletteIcon, iconPal, iconPalLen / 2, NE_PAL16);
NE_MaterialSetPalette(Material, Palette); 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);
@ -87,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;

View File

@ -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;

View File

@ -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

View File

@ -1,6 +1,6 @@
# 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
export BLOCKSDS ?= /opt/blocksds/core export BLOCKSDS ?= /opt/blocksds/core
export BLOCKSDSEXT ?= /opt/blocksds/external export BLOCKSDSEXT ?= /opt/blocksds/external
@ -51,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
@ -71,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
@ -116,10 +117,8 @@ 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
@ -132,16 +131,16 @@ ASFLAGS += -x assembler-with-cpp $(INCLUDEFLAGS) $(DEFINES) \
$(ARCH) -ffunction-sections -fdata-sections \ $(ARCH) -ffunction-sections -fdata-sections \
-specs=$(SPECS) -specs=$(SPECS)
CFLAGS += -std=gnu11 $(WARNFLAGS) $(INCLUDEFLAGS) $(DEFINES) \ CFLAGS += -std=gnu17 $(WARNFLAGS) $(INCLUDEFLAGS) $(DEFINES) \
$(ARCH) -O2 -ffunction-sections -fdata-sections \ $(ARCH) -O2 -ffunction-sections -fdata-sections \
-specs=$(SPECS) -specs=$(SPECS)
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(INCLUDEFLAGS) $(DEFINES) \ CXXFLAGS += -std=gnu++17 $(WARNFLAGS) $(INCLUDEFLAGS) $(DEFINES) \
$(ARCH) -O2 -ffunction-sections -fdata-sections \ $(ARCH) -O2 -ffunction-sections -fdata-sections \
-fno-exceptions -fno-rtti \ -fno-exceptions -fno-rtti \
-specs=$(SPECS) -specs=$(SPECS)
LDFLAGS := $(ARCH) $(LIBDIRSFLAGS) -Wl,-Map,$(MAP) \ LDFLAGS := $(ARCH) $(LIBDIRSFLAGS) -Wl,-Map,$(MAP) $(DEFINES) \
-Wl,--start-group $(LIBS) -Wl,--end-group -specs=$(SPECS) -Wl,--start-group $(LIBS) -Wl,--end-group -specs=$(SPECS)
# Intermediate build files # Intermediate build files
@ -179,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
@ -209,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)"
@ -260,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

View File

@ -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;

View File

@ -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;

View File

@ -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 := 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
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
GFXDIRS := graphics
include ../../Makefile.example.blocksds

View File

@ -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

Binary file not shown.

View File

@ -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
@ -9,26 +9,31 @@
#include "texture.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, sphere_bin); NE_ModelLoadStaticMesh(Scene.Model, sphere_bin);
NE_ModelLoadStaticMesh(Model2, sphere_bin); NE_ModelLoadStaticMesh(Scene.Model2, sphere_bin);
NE_ModelLoadStaticMesh(Model3, 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,
textureBitmap); 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;
@ -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;

View File

@ -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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
include ../../Makefile.example.blocksds

View File

@ -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

View File

@ -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, 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);
@ -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;

View File

@ -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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
include ../../Makefile.example.blocksds

View File

@ -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

View File

@ -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, teapot_bin); NE_ModelLoadStaticMesh(Scene.Teapot, teapot_bin);
NE_ModelLoadStaticMesh(Sphere, 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,7 +76,7 @@ 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();
@ -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

View File

@ -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 := 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
#---------------------------------------------------------------------------------------

View File

@ -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

View File

@ -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
@ -9,26 +9,32 @@
#include "teapot_bin.h" #include "teapot_bin.h"
#include "teapot.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,25 +49,25 @@ 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, 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,
teapotBitmap); teapotBitmap);
// Assign material to the model // Assign material to the model
NE_ModelSetMaterial(Model, Material); NE_ModelSetMaterial(Scene.Model, Material);
// Set some properties to the material // Set some properties to the material
NE_MaterialSetProperties(Material, NE_MaterialSetProperties(Material,
@ -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);
@ -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;

View File

@ -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 := 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
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
GFXDIRS := graphics
include ../../Makefile.example.blocksds

View File

@ -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

View File

@ -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
@ -10,19 +10,22 @@
#include "teapot_bin.h" #include "teapot_bin.h"
#include "teapot.h" #include "teapot.h"
NE_Camera *Camera; typedef struct {
NE_Model *ModelSpecular, *ModelDiffuse; NE_Camera *Camera;
NE_Material *MaterialSpecular, *MaterialDiffuse; NE_Model *ModelSpecular, *ModelDiffuse;
bool wireframe; bool wireframe;
} SceneData;
void Draw3DScene1(void) void Draw3DScene1(void *arg)
{ {
NE_CameraUse(Camera); SceneData *Scene = arg;
NE_PolyFormat(wireframe ? 0 : 31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0); NE_CameraUse(Scene->Camera);
NE_ModelDraw(ModelSpecular); NE_PolyFormat(Scene->wireframe ? 0 : 31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0);
NE_ModelDraw(Scene->ModelSpecular);
printf("\x1b[22;0H" printf("\x1b[22;0H"
"Polygon count: %d \n" "Polygon count: %d \n"
@ -31,17 +34,21 @@ void Draw3DScene1(void)
NE_GetVertexCount()); NE_GetVertexCount());
} }
void Draw3DScene2(void) void Draw3DScene2(void *arg)
{ {
NE_CameraUse(Camera); SceneData *Scene = arg;
NE_PolyFormat(wireframe ? 0 : 31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0); NE_CameraUse(Scene->Camera);
NE_ModelDraw(ModelDiffuse); NE_PolyFormat(Scene->wireframe ? 0 : 31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0);
NE_ModelDraw(Scene->ModelDiffuse);
} }
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);
@ -50,21 +57,21 @@ int main(void)
NE_InitConsole(); NE_InitConsole();
// Allocate objects // Allocate objects
Camera = NE_CameraCreate(); Scene.Camera = NE_CameraCreate();
ModelSpecular = NE_ModelCreate(NE_Static); Scene.ModelSpecular = NE_ModelCreate(NE_Static);
ModelDiffuse = NE_ModelCreate(NE_Static); Scene.ModelDiffuse = NE_ModelCreate(NE_Static);
MaterialSpecular = NE_MaterialCreate(); NE_Material *MaterialSpecular = NE_MaterialCreate();
MaterialDiffuse = NE_MaterialCreate(); NE_Material *MaterialDiffuse = NE_MaterialCreate();
// 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(ModelSpecular, (u32*)teapot_bin); NE_ModelLoadStaticMesh(Scene.ModelSpecular, teapot_bin);
NE_ModelClone(ModelDiffuse, ModelSpecular); NE_ModelClone(Scene.ModelDiffuse, Scene.ModelSpecular);
// Load texture and clone it. The texture coordinates of the model are // Load texture and clone it. The texture coordinates of the model are
// outside of [0.0, 1.0], so it is needed to enable wrapping. // outside of [0.0, 1.0], so it is needed to enable wrapping.
@ -73,8 +80,8 @@ int main(void)
teapotBitmap); teapotBitmap);
NE_MaterialClone(MaterialSpecular, MaterialDiffuse); NE_MaterialClone(MaterialSpecular, MaterialDiffuse);
NE_ModelSetMaterial(ModelSpecular, MaterialSpecular); NE_ModelSetMaterial(Scene.ModelSpecular, MaterialSpecular);
NE_ModelSetMaterial(ModelDiffuse, MaterialDiffuse); NE_ModelSetMaterial(Scene.ModelDiffuse, MaterialDiffuse);
// Set some properties to the materials // Set some properties to the materials
@ -115,30 +122,30 @@ int main(void)
"L/R: Change shininess\n"); "L/R: Change shininess\n");
if (keys & KEY_A) if (keys & KEY_A)
wireframe = true; Scene.wireframe = true;
else else
wireframe = false; Scene.wireframe = false;
// Rotate model // Rotate model
if (keys & KEY_UP) if (keys & KEY_UP)
{ {
NE_ModelRotate(ModelSpecular, -2, 0, 0); NE_ModelRotate(Scene.ModelSpecular, -2, 0, 0);
NE_ModelRotate(ModelDiffuse, -2, 0, 0); NE_ModelRotate(Scene.ModelDiffuse, -2, 0, 0);
} }
if (keys & KEY_DOWN) if (keys & KEY_DOWN)
{ {
NE_ModelRotate(ModelSpecular, 2, 0, 0); NE_ModelRotate(Scene.ModelSpecular, 2, 0, 0);
NE_ModelRotate(ModelDiffuse, 2, 0, 0); NE_ModelRotate(Scene.ModelDiffuse, 2, 0, 0);
} }
if (keys & KEY_RIGHT) if (keys & KEY_RIGHT)
{ {
NE_ModelRotate(ModelSpecular, 0, 2, 0); NE_ModelRotate(Scene.ModelSpecular, 0, 2, 0);
NE_ModelRotate(ModelDiffuse, 0, 2, 0); NE_ModelRotate(Scene.ModelDiffuse, 0, 2, 0);
} }
if (keys & KEY_LEFT) if (keys & KEY_LEFT)
{ {
NE_ModelRotate(ModelSpecular, 0, -2, 0); NE_ModelRotate(Scene.ModelSpecular, 0, -2, 0);
NE_ModelRotate(ModelDiffuse, 0, -2, 0); NE_ModelRotate(Scene.ModelDiffuse, 0, -2, 0);
} }
// Shininess table // Shininess table
@ -166,7 +173,7 @@ int main(void)
NE_ShininessTableGenerate(shininess); NE_ShininessTableGenerate(shininess);
NE_ProcessDual(Draw3DScene1, Draw3DScene2); NE_ProcessDualArg(Draw3DScene1, Draw3DScene2, &Scene, &Scene);
} }
return 0; return 0;

View File

@ -4,4 +4,4 @@
BINDIRS := data BINDIRS := data
GFXDIRS := graphics GFXDIRS := graphics
include ../../Makefile.example.blocksds include ../../Makefile.example

View File

@ -0,0 +1,15 @@
#!/bin/sh
NITRO_ENGINE=../../..
ASSETS=$NITRO_ENGINE/examples/assets
TOOLS=$NITRO_ENGINE/tools
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
rm -rf data
mkdir -p data
python3 $OBJ2DL \
--input $ASSETS/teapot.obj \
--output data/teapot.bin \
--texture 256 256 \
--scale 0.1

Binary file not shown.

View File

@ -0,0 +1,2 @@
# 16-bit palette, no transparency
-gx -gb -gB16 -gT!

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -0,0 +1,277 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2024
//
// This file is part of Nitro Engine
#include <NEMain.h>
#include "teapot_bin.h"
#include "teapot.h"
typedef struct {
NE_Camera *Camera;
NE_Model *Teapot;
NE_Material *Material;
bool draw_edges;
} SceneData;
void DrawFloor(void)
{
NE_PolyNormal(0, -0.97, 0);
NE_PolyBegin(GL_QUAD);
NE_PolyTexCoord(0, 0);
NE_PolyVertex(-10, 0, -10);
NE_PolyTexCoord(0, 256);
NE_PolyVertex(-10, 0, 10);
NE_PolyTexCoord(256, 256);
NE_PolyVertex(10, 0, 10);
NE_PolyTexCoord(256, 0);
NE_PolyVertex(10, 0, -10);
NE_PolyEnd();
}
void DrawLid(void)
{
NE_PolyNormal(0, -0.97, 0);
NE_PolyBegin(GL_QUAD);
NE_PolyTexCoord(0, 0);
NE_PolyVertex(-0.75, 3, -0.75);
NE_PolyTexCoord(0, 256);
NE_PolyVertex(-0.75, 3, 0.75);
NE_PolyTexCoord(256, 256);
NE_PolyVertex( 0.75, 3, 0.75);
NE_PolyTexCoord(256, 0);
NE_PolyVertex( 0.75, 3, -0.75);
NE_PolyEnd();
}
void DrawShadowVolume(void)
{
// Lid
NE_PolyBegin(GL_QUAD);
NE_PolyVertex(-0.75, 3, -0.75);
NE_PolyVertex(-0.75, 3, 0.75);
NE_PolyVertex( 0.75, 3, 0.75);
NE_PolyVertex( 0.75, 3, -0.75);
NE_PolyEnd();
// Walls
NE_PolyBegin(GL_QUAD_STRIP);
NE_PolyVertex(-0.75, 3, -0.75);
NE_PolyVertex(-0.75, 0, -0.75);
NE_PolyVertex(-0.75, 3, 0.75);
NE_PolyVertex(-0.75, 0, 0.75);
NE_PolyVertex( 0.75, 3, 0.75);
NE_PolyVertex( 0.75, 0, 0.75);
NE_PolyVertex( 0.75, 3, -0.75);
NE_PolyVertex( 0.75, 0, -0.75);
NE_PolyVertex(-0.75, 3, -0.75);
NE_PolyVertex(-0.75, 0, -0.75);
NE_PolyEnd();
// Bottom
NE_PolyBegin(GL_QUAD);
NE_PolyVertex(-0.75, 0, -0.75);
NE_PolyVertex(-0.75, 0, 0.75);
NE_PolyVertex( 0.75, 0, 0.75);
NE_PolyVertex( 0.75, 0, -0.75);
NE_PolyEnd();
}
void Draw3DSceneBright(void *arg)
{
NE_LightSet(0, NE_White, 0, -0.97, -0.0);
SceneData *Scene = arg;
// Set camera
NE_CameraUse(Scene->Camera);
// Set polygon format for regular models
NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_BACK, NE_MODULATION);
// Draw regular models
NE_ModelDraw(Scene->Teapot);
NE_MaterialUse(Scene->Material);
DrawFloor();
DrawLid();
// Draw shadow volume as a black volume (shadow)
NE_MaterialUse(NULL);
NE_PolyColor(NE_Black);
if (Scene->draw_edges)
{
// Draw the shadow volume in wireframe mode to see where it is
NE_PolyFormat(0, 0, 0, NE_CULL_NONE, NE_MODULATION);
DrawShadowVolume();
}
NE_PolyFormat(1, 0, 0, NE_CULL_NONE, NE_SHADOW_POLYGONS);
DrawShadowVolume();
NE_PolyFormat(20, 63, 0, NE_CULL_NONE, NE_SHADOW_POLYGONS);
DrawShadowVolume();
}
void Draw3DSceneDark(void *arg)
{
NE_LightSet(0, RGB15(8, 8, 8), 0, -0.97, -0.0);
SceneData *Scene = arg;
// Set camera
NE_CameraUse(Scene->Camera);
// Set polygon format for regular models
NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_BACK, NE_MODULATION);
// Draw regular models
NE_ModelDraw(Scene->Teapot);
NE_MaterialUse(Scene->Material);
DrawFloor();
DrawLid();
// Draw shadow volume as a yellow volume (light)
NE_MaterialUse(NULL);
NE_PolyColor(RGB15(15, 15, 0));
if (Scene->draw_edges)
{
// Draw the shadow volume in wireframe mode to see where it is
NE_PolyFormat(0, 0, 0, NE_CULL_NONE, NE_MODULATION);
DrawShadowVolume();
}
NE_PolyFormat(1, 0, 0, NE_CULL_NONE, NE_SHADOW_POLYGONS);
DrawShadowVolume();
NE_PolyFormat(20, 63, 0, NE_CULL_NONE, NE_SHADOW_POLYGONS);
DrawShadowVolume();
}
int main(int argc, char *argv[])
{
SceneData Scene = { 0 };
// This is needed for special screen effects
irqEnable(IRQ_HBLANK);
irqSet(IRQ_VBLANK, NE_VBLFunc);
irqSet(IRQ_VBLANK, NE_HBLFunc);
// Init console and Nitro Engine
NE_InitDual3D();
NE_InitConsole();
// Setup camera
Scene.Camera = NE_CameraCreate();
NE_CameraSet(Scene.Camera,
0, 3.25, -3.25,
0, 1.25, 0,
0, 1, 0);
// Load teapot and texture
{
Scene.Teapot = NE_ModelCreate(NE_Static);
Scene.Material = NE_MaterialCreate();
// Load mesh from RAM and assign it to a model
NE_ModelLoadStaticMesh(Scene.Teapot, teapot_bin);
// Load teapot texture from RAM and assign it to a material
NE_MaterialTexLoad(Scene.Material, NE_A1RGB5, 256, 256,
NE_TEXGEN_TEXCOORD | NE_TEXTURE_WRAP_S | NE_TEXTURE_WRAP_T,
teapotBitmap);
// Assign material to the model
NE_ModelSetMaterial(Scene.Teapot, Scene.Material);
// Set some properties to the material
NE_MaterialSetProperties(Scene.Material,
RGB15(24, 24, 24), // Diffuse
RGB15(8, 8, 8), // Ambient
RGB15(0, 0, 0), // Specular
RGB15(0, 0, 0), // Emission
false, false); // Vertex color, use shininess table
// Set initial position of the object
NE_ModelSetCoordI(Scene.Teapot,
floattof32(0), floattof32(1.5), floattof32(0));
}
printf("\x1b[0;0H"
"ABXY: Rotate\n"
"Pad: Move\n"
"SELECT: Show edges of shadow\n"
"START: Exit to loader\n");
while (1)
{
NE_WaitForVBL(0);
// Refresh keys
scanKeys();
uint32_t keys = keysHeld();
// Move model using the pad
if (keys & KEY_UP)
NE_ModelTranslate(Scene.Teapot, 0, 0, 0.05);
if (keys & KEY_DOWN)
NE_ModelTranslate(Scene.Teapot, 0, 0, -0.05);
if (keys & KEY_RIGHT)
NE_ModelTranslate(Scene.Teapot, -0.05, 0, 0);
if (keys & KEY_LEFT)
NE_ModelTranslate(Scene.Teapot, 0.05, 0, 0);
// Rotate model using the pad
if (keys & KEY_Y)
NE_ModelRotate(Scene.Teapot, 0, 0, 2);
if (keys & KEY_B)
NE_ModelRotate(Scene.Teapot, 0, 0, -2);
if (keys & KEY_X)
NE_ModelRotate(Scene.Teapot, 0, 2, 0);
if (keys & KEY_A)
NE_ModelRotate(Scene.Teapot, 0, -2, 0);
if (keys & KEY_SELECT)
Scene.draw_edges = true;
else
Scene.draw_edges = false;
if (keys & KEY_START)
break;
// Draw Scene
NE_ProcessDualArg(Draw3DSceneBright, Draw3DSceneDark, &Scene, &Scene);
}
return 0;
}

View File

@ -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;

View File

@ -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;

View File

@ -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 := 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
#---------------------------------------------------------------------------------------

View File

@ -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
MD5_TO_DSMA=$TOOLS/md5_to_dsma/md5_to_dsma.py MD5_TO_DSMA=$TOOLS/md5_to_dsma/md5_to_dsma.py

View File

@ -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
@ -10,22 +10,26 @@
#include "robot_wave_dsa_bin.h" #include "robot_wave_dsa_bin.h"
#include "texture.h" #include "texture.h"
NE_Camera *Camera; typedef struct {
NE_Model *Model; NE_Camera *Camera;
NE_Animation *Animation; NE_Model *Model;
NE_Material *Texture; } SceneData;
void Draw3DScene(void) void Draw3DScene(void *arg)
{ {
SceneData *Scene = arg;
NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_BACK, 0); NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_BACK, 0);
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 };
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);
@ -33,25 +37,25 @@ int main(void)
NE_Init3D(); NE_Init3D();
NE_InitConsole(); NE_InitConsole();
Camera = NE_CameraCreate(); Scene.Camera = NE_CameraCreate();
Model = NE_ModelCreate(NE_Animated); Scene.Model = NE_ModelCreate(NE_Animated);
Animation = NE_AnimationCreate(); NE_Animation *Animation = NE_AnimationCreate();
NE_AnimationLoad(Animation, robot_wave_dsa_bin); NE_AnimationLoad(Animation, robot_wave_dsa_bin);
NE_ModelLoadDSM(Model, robot_dsm_bin); NE_ModelLoadDSM(Scene.Model, robot_dsm_bin);
NE_ModelSetAnimation(Model, Animation); NE_ModelSetAnimation(Scene.Model, Animation);
NE_ModelAnimStart(Model, NE_ANIM_LOOP, floattof32(0.1)); NE_ModelAnimStart(Scene.Model, NE_ANIM_LOOP, floattof32(0.1));
NE_CameraSet(Camera, NE_CameraSet(Scene.Camera,
6, 3, -4, 6, 3, -4,
0, 3, 0, 0, 3, 0,
0, 1, 0); 0, 1, 0);
Texture = NE_MaterialCreate(); NE_Material *Texture = NE_MaterialCreate();
NE_MaterialTexLoad(Texture, NE_A1RGB5, 256, 256, NE_TEXGEN_TEXCOORD, NE_MaterialTexLoad(Texture, NE_A1RGB5, 256, 256, NE_TEXGEN_TEXCOORD,
textureBitmap); textureBitmap);
NE_ModelSetMaterial(Model, Texture); NE_ModelSetMaterial(Scene.Model, Texture);
NE_LightSet(0, NE_White, -0.9, 0, 0); NE_LightSet(0, NE_White, -0.9, 0, 0);
NE_ClearColorSet(NE_Black, 31, 63); NE_ClearColorSet(NE_Black, 31, 63);
@ -64,19 +68,20 @@ int main(void)
uint32_t keys = keysHeld(); uint32_t keys = keysHeld();
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);
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);
printf("\x1b[0;0H" printf("\x1b[0;0H"
"CPU%%: %d \nFrame: %.3f ", "CPU%%: %d \nFrame: %.3f ",
NE_GetCPUPercent(), f32tofloat(NE_ModelAnimGetFrame(Model))); NE_GetCPUPercent(),
f32tofloat(NE_ModelAnimGetFrame(Scene.Model)));
NE_Process(Draw3DScene); NE_ProcessArg(Draw3DScene, &Scene);
} }
return 0; return 0;

View File

@ -3,4 +3,4 @@
BINDIRS := data BINDIRS := data
include ../../Makefile.example.blocksds include ../../Makefile.example

View File

@ -0,0 +1,13 @@
#!/bin/sh
NITRO_ENGINE=../../..
ASSETS=$NITRO_ENGINE/examples/assets
TOOLS=$NITRO_ENGINE/tools
OBJ2DL=$TOOLS/obj2dl/obj2dl.py
mkdir -p data
python3 $OBJ2DL \
--input $ASSETS/sphere.obj \
--output data/sphere.bin \
--texture 32 32

View File

@ -0,0 +1,105 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2008-2024
//
// This file is part of Nitro Engine
// TODO
#include <NEMain.h>
#include "sphere_bin.h"
typedef struct {
NE_Camera *Camera;
NE_Model *ModelWithoutMatrix;
NE_Model *ModelWithMatrix;
} SceneData;
void Draw3DScene(void *arg)
{
SceneData *Scene = arg;
NE_CameraUse(Scene->Camera);
NE_ModelDraw(Scene->ModelWithoutMatrix);
NE_ModelDraw(Scene->ModelWithMatrix);
}
int main(int argc, char *argv[])
{
SceneData Scene = { 0 };
irqEnable(IRQ_HBLANK);
irqSet(IRQ_VBLANK, NE_VBLFunc);
irqSet(IRQ_HBLANK, NE_HBLFunc);
// Init Nitro Engine.
NE_Init3D();
// libnds uses VRAM_C for the text console, reserve A and B only
NE_TextureSystemReset(0, 0, NE_VRAM_AB);
// Init console in non-3D screen
consoleDemoInit();
// Allocate space for everything.
Scene.ModelWithoutMatrix = NE_ModelCreate(NE_Static);
Scene.ModelWithMatrix = NE_ModelCreate(NE_Static);
Scene.Camera = NE_CameraCreate();
// Setup camera
NE_CameraSet(Scene.Camera,
0, 0, 3,
0, 0, 0,
0, 1, 0);
// Load models
NE_ModelLoadStaticMesh(Scene.ModelWithoutMatrix, sphere_bin);
NE_ModelLoadStaticMesh(Scene.ModelWithMatrix, sphere_bin);
// Set up light
NE_LightSet(0, NE_Yellow, 0, -0.5, -0.5);
// Set start coordinates/rotation of the models
NE_ModelSetCoord(Scene.ModelWithoutMatrix, -1, 0, 0);
// Transformation matrix we are going to use for a model. Note that this
// matrix is transposed compared to what most 3D documentation describes.
m4x3 matrix = {{
// 3x3 transformation
inttof32(1), 0, 0,
0, inttof32(1), 0,
0, 0, inttof32(1),
// Translation vector
inttof32(2), 0, 0
}};
int translation = inttof32(2);
printf("The right ball uses a matrix\n"
"assigned by the user, the left\n"
"one has rotation managed by\n"
"Nitro Engine.");
while (1)
{
NE_WaitForVBL(0);
// Rotate the first model
NE_ModelRotate(Scene.ModelWithoutMatrix, -1, 2, 1);
// Update matrix manually
translation += floattof32(0.05);
if (translation > inttof32(3))
translation = inttof32(1);
matrix.m[9] = translation;
// Assign matrix again
NE_ModelSetMatrix(Scene.ModelWithMatrix, &matrix);
// Draw scene
NE_ProcessArg(Draw3DScene, &Scene);
}
return 0;
}

View File

@ -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
#---------------------------------------------------------------------------------------

View File

@ -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

View File

@ -1,18 +1,9 @@
// 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 "sphere_bin.h"
#define NUM_MODELS 16
NE_Camera *Camera;
NE_Model *Model[NUM_MODELS];
// Cloning models will avoid loading into memory the same mesh many times. This // Cloning models will avoid loading into memory the same mesh many times. This
// is really useful when you want to draw lots of the same model in different // is really useful when you want to draw lots of the same model in different
// locations, with different animations, etc. You won't need to store multiple // locations, with different animations, etc. You won't need to store multiple
@ -21,13 +12,26 @@ NE_Model *Model[NUM_MODELS];
// If you clone an animated model you will be able to set different animations // If you clone an animated model you will be able to set different animations
// for each model. // for each model.
void Draw3DScene(void) #include <NEMain.h>
#include "sphere_bin.h"
#define NUM_MODELS 16
typedef struct {
NE_Camera *Camera;
NE_Model *Model[NUM_MODELS];
} SceneData;
void Draw3DScene(void *arg)
{ {
SceneData *Scene = arg;
// Setup camera and draw all objects. // Setup camera and draw all objects.
NE_CameraUse(Camera); NE_CameraUse(Scene->Camera);
for (int i = 0; i < NUM_MODELS; i++) for (int i = 0; i < NUM_MODELS; i++)
NE_ModelDraw(Model[i]); NE_ModelDraw(Scene->Model[i]);
// Get some information AFTER drawing but BEFORE returning from the // Get some information AFTER drawing but BEFORE returning from the
// function. // function.
@ -35,8 +39,10 @@ void Draw3DScene(void)
NE_GetPolygonCount(), NE_GetVertexCount()); NE_GetPolygonCount(), NE_GetVertexCount());
} }
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);
@ -50,37 +56,34 @@ int main(void)
// Allocate space for everything. // Allocate space for everything.
for (int i = 0; i < NUM_MODELS; i++) for (int i = 0; i < NUM_MODELS; i++)
Model[i] = NE_ModelCreate(NE_Static); Scene.Model[i] = NE_ModelCreate(NE_Static);
Camera = NE_CameraCreate(); Scene.Camera = NE_CameraCreate();
// Setup camera // Setup camera
NE_CameraSet(Camera, NE_CameraSet(Scene.Camera,
-3.5, 1.5, 1.25, -3.5, 1.5, 1.25,
0, 1.5, 1.25, 0, 1.5, 1.25,
0, 1, 0); 0, 1, 0);
// Load model once // Load model once
NE_ModelLoadStaticMesh(Model[0], sphere_bin); NE_ModelLoadStaticMesh(Scene.Model[0], sphere_bin);
// Clone model to the test of the objects // Clone model to the test of the objects
for (int i = 1; i < NUM_MODELS; i++) for (int i = 1; i < NUM_MODELS; i++)
{ {
NE_ModelClone(Model[i], // Destination NE_ModelClone(Scene.Model[i], // Destination
Model[0]); // Source model Scene.Model[0]); // Source model
} }
// Set up light // Set up light
NE_LightSet(0, NE_Yellow, 0, -0.5, -0.5); NE_LightSet(0, NE_Yellow, 0, -0.5, -0.5);
// Enable shading
NE_ShadingEnable(true);
// Set start coordinates/rotation of the models // Set start coordinates/rotation of the models
for (int i = 0; i < NUM_MODELS; i++) for (int i = 0; i < NUM_MODELS; i++)
{ {
NE_ModelSetRot(Model[i], i, i * 30, i * 20); NE_ModelSetRot(Scene.Model[i], i, i * 30, i * 20);
NE_ModelSetCoord(Model[i], 0, i % 4, i / 4); NE_ModelSetCoord(Scene.Model[i], 0, i % 4, i / 4);
} }
while (1) while (1)
@ -89,10 +92,10 @@ int main(void)
// Rotate every model // Rotate every model
for (int i = 0; i < NUM_MODELS; i++) for (int i = 0; i < NUM_MODELS; i++)
NE_ModelRotate(Model[i], -i, i % 5, 5 - i); NE_ModelRotate(Scene.Model[i], -i, i % 5, 5 - i);
// Draw scene // Draw scene
NE_Process(Draw3DScene); NE_ProcessArg(Draw3DScene, &Scene);
} }
return 0; return 0;

View File

@ -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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
include ../../Makefile.example.blocksds

View File

@ -3,14 +3,16 @@
rm -rf data rm -rf data
mkdir -p data mkdir -p data
BLOCKSDSEXT="${BLOCKSDSEXT:-/opt/blocksds/external/}"
# ptexconv can be obtained here: https://github.com/Garhoogin/ptexconv/ # ptexconv can be obtained here: https://github.com/Garhoogin/ptexconv/
/opt/blocksds/external/ptexconv/ptexconv \ $BLOCKSDSEXT/ptexconv/ptexconv \
-gt -ob -k FF00FF -v -f tex4x4 \ -gt -ob -k FF00FF -v -f tex4x4 \
-o data/grill \ -o data/grill \
assets/grill.png assets/grill.png
/opt/blocksds/external/ptexconv/ptexconv \ $BLOCKSDSEXT/ptexconv/ptexconv \
-gt -ob -k FF00FF -v -f tex4x4 \ -gt -ob -k FF00FF -v -f tex4x4 \
-o data/landscape \ -o data/landscape \
assets/landscape.jpg assets/landscape.jpg

View File

@ -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,33 +13,45 @@
#include "landscape_pal_bin.h" #include "landscape_pal_bin.h"
#include "landscape_tex_bin.h" #include "landscape_tex_bin.h"
NE_Material *Material1, *Material2; typedef struct {
NE_Palette *Palette1, *Palette2; NE_Material *Material1;
} SceneData1;
void Draw3DScene1(void) typedef struct {
NE_Material *Material2;
} SceneData2;
void Draw3DScene1(void *arg)
{ {
SceneData1 *Scene = arg;
NE_ClearColorSet(RGB15(5, 5, 10), 31, 63); NE_ClearColorSet(RGB15(5, 5, 10), 31, 63);
NE_2DViewInit(); NE_2DViewInit();
NE_2DDrawTexturedQuad(32, 32, NE_2DDrawTexturedQuad(32, 32,
32 + 128, 32 + 128, 32 + 128, 32 + 128,
0, Material1); 0, Scene->Material1);
} }
void Draw3DScene2(void) void Draw3DScene2(void *arg)
{ {
SceneData2 *Scene = arg;
NE_ClearColorSet(RGB15(10, 5, 0), 31, 63); NE_ClearColorSet(RGB15(10, 5, 0), 31, 63);
NE_2DViewInit(); NE_2DViewInit();
NE_2DDrawTexturedQuad(64, 0, NE_2DDrawTexturedQuad(64, 0,
64 + 128, 0 + 128, 64 + 128, 0 + 128,
0, Material2); 0, Scene->Material2);
} }
int main(void) int main(int argc, char *argv[])
{ {
SceneData1 Scene1 = { 0 };
SceneData2 Scene2 = { 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);
@ -47,28 +59,29 @@ int main(void)
NE_InitDual3D(); NE_InitDual3D();
// Allocate objects // Allocate objects
Material1 = NE_MaterialCreate(); Scene1.Material1 = NE_MaterialCreate();
Material2 = NE_MaterialCreate(); Scene2.Material2 = NE_MaterialCreate();
Palette1 = NE_PaletteCreate();
Palette2 = NE_PaletteCreate();
NE_MaterialTex4x4Load(Material1, 128, 128, NE_TEXGEN_TEXCOORD, NE_Palette *Palette1 = NE_PaletteCreate();
NE_Palette *Palette2 = NE_PaletteCreate();
NE_MaterialTex4x4Load(Scene1.Material1, 128, 128, NE_TEXGEN_TEXCOORD,
grill_tex_bin, grill_idx_bin); grill_tex_bin, grill_idx_bin);
NE_PaletteLoadSize(Palette1, grill_pal_bin, grill_pal_bin_size, NE_PaletteLoadSize(Palette1, grill_pal_bin, grill_pal_bin_size,
NE_TEX4X4); NE_TEX4X4);
NE_MaterialSetPalette(Material1, Palette1); NE_MaterialSetPalette(Scene1.Material1, Palette1);
NE_MaterialTex4x4Load(Material2, 128, 128, NE_TEXGEN_TEXCOORD, NE_MaterialTex4x4Load(Scene2.Material2, 128, 128, NE_TEXGEN_TEXCOORD,
landscape_tex_bin, landscape_idx_bin); landscape_tex_bin, landscape_idx_bin);
NE_PaletteLoadSize(Palette2, landscape_pal_bin, NE_PaletteLoadSize(Palette2, landscape_pal_bin,
landscape_pal_bin_size, NE_TEX4X4); landscape_pal_bin_size, NE_TEX4X4);
NE_MaterialSetPalette(Material2, Palette2); NE_MaterialSetPalette(Scene2.Material2, Palette2);
while (1) while (1)
{ {
NE_WaitForVBL(0); NE_WaitForVBL(0);
NE_ProcessDual(Draw3DScene1, Draw3DScene2); NE_ProcessDualArg(Draw3DScene1, Draw3DScene2, &Scene1, &Scene2);
} }
return 0; return 0;

View File

@ -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)),) NITROFSDIR := nitrofiles
$(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 := nitrofiles
# 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
#---------------------------------------------------------------------------------------

View File

@ -1,10 +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
MD5_TO_DSMA=$TOOLS/md5_to_dsma/md5_to_dsma.py MD5_TO_DSMA=$TOOLS/md5_to_dsma/md5_to_dsma.py
GRIT=grit BLOCKSDS="${BLOCKSDS:-/opt/blocksds/core/}"
GRIT=$BLOCKSDS/tools/grit/grit
rm -rf nitrofiles rm -rf nitrofiles
mkdir -p nitrofiles mkdir -p nitrofiles

View File

@ -1,25 +0,0 @@
//{{BLOCK(texture)
//======================================================================
//
// texture, 256x256@16,
// Alphabit on.
// + bitmap not compressed
// Total size: 131072 = 131072
//
// Time-stamp: 2024-01-27, 18:07:12
// Exported by Cearn's GBA Image Transmogrifier, v0.9.2
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
#ifndef GRIT_TEXTURE_H
#define GRIT_TEXTURE_H
#define textureBitmapLen 131072
extern const unsigned int textureBitmap[32768];
#endif // GRIT_TEXTURE_H
//}}BLOCK(texture)

View File

@ -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
@ -11,22 +11,24 @@
#include <NEMain.h> #include <NEMain.h>
NE_Camera *Camera; typedef struct {
NE_Model *Model; NE_Camera *Camera;
NE_Animation *Animation; NE_Model *Model;
NE_Material *Material; } SceneData;
void Draw3DScene(void) void Draw3DScene(void *arg)
{ {
NE_CameraUse(Camera); SceneData *Scene = arg;
NE_CameraUse(Scene->Camera);
NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_NONE, 0); NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_NONE, 0);
NE_ModelDraw(Model); NE_ModelDraw(Scene->Model);
} }
void WaitLoop(void) void WaitLoop(void)
{ {
while(1) while (1)
{ {
swiWaitForVBlank(); swiWaitForVBlank();
scanKeys(); scanKeys();
@ -35,8 +37,10 @@ void WaitLoop(void)
} }
} }
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);
@ -55,18 +59,18 @@ int main(void)
} }
// Allocate space for objects... // Allocate space for objects...
Model = NE_ModelCreate(NE_Animated); Scene.Model = NE_ModelCreate(NE_Animated);
Camera = NE_CameraCreate(); Scene.Camera = NE_CameraCreate();
Material = NE_MaterialCreate(); NE_Material *Material = NE_MaterialCreate();
Animation = NE_AnimationCreate(); NE_Animation *Animation = NE_AnimationCreate();
// Setup camera // Setup camera
NE_CameraSet(Camera, NE_CameraSet(Scene.Camera,
6, 3, -4, 6, 3, -4,
0, 3, 0, 0, 3, 0,
0, 1, 0); 0, 1, 0);
if (NE_ModelLoadDSMFAT(Model, "robot.dsm") == 0) if (NE_ModelLoadDSMFAT(Scene.Model, "robot.dsm") == 0)
{ {
printf("Couldn't load model..."); printf("Couldn't load model...");
WaitLoop(); WaitLoop();
@ -89,10 +93,10 @@ int main(void)
} }
// Assign material to the model // Assign material to the model
NE_ModelSetMaterial(Model, Material); NE_ModelSetMaterial(Scene.Model, Material);
NE_ModelSetAnimation(Model, Animation); NE_ModelSetAnimation(Scene.Model, Animation);
NE_ModelAnimStart(Model, NE_ANIM_LOOP, floattof32(0.1)); NE_ModelAnimStart(Scene.Model, NE_ANIM_LOOP, floattof32(0.1));
NE_LightSet(0, NE_White, 0, -1, -1); NE_LightSet(0, NE_White, 0, -1, -1);
@ -111,16 +115,15 @@ int main(void)
break; break;
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);
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);
// Draw scene... NE_ProcessArg(Draw3DScene, &Scene);
NE_Process(Draw3DScene);
} }
return 0; return 0;

View File

@ -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)),) NITROFSDIR := nitrofiles
$(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 := nitrofiles
# 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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
NITROFSDIR := nitrofiles
include ../../Makefile.example.blocksds

View File

@ -1,10 +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
GRIT=grit BLOCKSDS="${BLOCKSDS:-/opt/blocksds/core/}"
GRIT=$BLOCKSDS/tools/grit/grit
rm -rf nitrofiles rm -rf nitrofiles
mkdir -p nitrofiles mkdir -p nitrofiles

View File

@ -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
@ -10,21 +10,25 @@
#include <NEMain.h> #include <NEMain.h>
NE_Camera *Camera; typedef struct {
NE_Model *Model; NE_Camera *Camera;
NE_Material *MaterialBlue, *MaterialRed; NE_Model *Model;
NE_Palette *PaletteBlue, *PaletteRed; } SceneData;
void Draw3DScene(void) void Draw3DScene(void *arg)
{ {
NE_CameraUse(Camera); SceneData *Scene = arg;
NE_CameraUse(Scene->Camera);
NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_NONE, 0); NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_NONE, 0);
NE_ModelDraw(Model); NE_ModelDraw(Scene->Model);
} }
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);
@ -48,21 +52,21 @@ int main(void)
} }
// Allocate space for objects... // Allocate space for objects...
Model = NE_ModelCreate(NE_Static); Scene.Model = NE_ModelCreate(NE_Static);
Camera = NE_CameraCreate(); Scene.Camera = NE_CameraCreate();
MaterialBlue = NE_MaterialCreate(); NE_Material *MaterialBlue = NE_MaterialCreate();
MaterialRed = NE_MaterialCreate(); NE_Material *MaterialRed = NE_MaterialCreate();
PaletteBlue = NE_PaletteCreate(); NE_Palette *PaletteBlue = NE_PaletteCreate();
PaletteRed = NE_PaletteCreate(); NE_Palette *PaletteRed = NE_PaletteCreate();
// Setup camera // Setup camera
NE_CameraSet(Camera, NE_CameraSet(Scene.Camera,
-1, -1, -1, -1, -1, -1,
0, 0, 0, 0, 0, 0,
0, 1, 0); 0, 1, 0);
// Load things from FAT // Load things from FAT
NE_ModelLoadStaticMeshFAT(Model, "cube.bin"); NE_ModelLoadStaticMeshFAT(Scene.Model, "cube.bin");
NE_MaterialTexLoadFAT(MaterialBlue, NE_A3PAL32, 64, 64, NE_TEXGEN_TEXCOORD, NE_MaterialTexLoadFAT(MaterialBlue, NE_A3PAL32, 64, 64, NE_TEXGEN_TEXCOORD,
"spiral_blue_pal32.img.bin"); "spiral_blue_pal32.img.bin");
@ -76,7 +80,7 @@ int main(void)
NE_MaterialSetPalette(MaterialRed, PaletteRed); NE_MaterialSetPalette(MaterialRed, PaletteRed);
// Assign material to model // Assign material to model
NE_ModelSetMaterial(Model, MaterialBlue); NE_ModelSetMaterial(Scene.Model, MaterialBlue);
// Set up light // Set up light
NE_LightSet(0, NE_White, 0, -1, -1); NE_LightSet(0, NE_White, 0, -1, -1);
@ -96,19 +100,18 @@ int main(void)
// Change material if pressed // Change material if pressed
if (keys & KEY_B) if (keys & KEY_B)
NE_ModelSetMaterial(Model, MaterialBlue); NE_ModelSetMaterial(Scene.Model, MaterialBlue);
if (keys & KEY_A) if (keys & KEY_A)
NE_ModelSetMaterial(Model, MaterialRed); NE_ModelSetMaterial(Scene.Model, MaterialRed);
printf("\x1b[0;0HA/B: Change material.\n\nSTART: Exit."); printf("\x1b[0;0HA/B: Change material.\n\nSTART: Exit.");
// Increase rotation, you can't get the rotation angle after // Increase rotation, you can't get the rotation angle after
// this. If you want to know always the angle, you should use // this. If you want to know always the angle, you should use
// NE_ModelSetRot(). // NE_ModelSetRot().
NE_ModelRotate(Model, 1, 2, 0); NE_ModelRotate(Scene.Model, 1, 2, 0);
// Draw scene... NE_ProcessArg(Draw3DScene, &Scene);
NE_Process(Draw3DScene);
} }
return 0; return 0;

View File

@ -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)),) NITROFSDIR := nitrofiles
$(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 :=
GRAPHICS :=
AUDIO :=
ICON :=
# specify a directory which contains the nitro filesystem
# this is relative to the Makefile
NITRO := nitrofiles
# 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
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
NITROFSDIR := nitrofiles
include ../../Makefile.example.blocksds

View File

@ -1,10 +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
GRIT=grit BLOCKSDS="${BLOCKSDS:-/opt/blocksds/core/}"
GRIT=$BLOCKSDS/tools/grit/grit
rm -rf nitrofiles rm -rf nitrofiles
mkdir -p nitrofiles mkdir -p nitrofiles

View File

@ -1,25 +0,0 @@
//{{BLOCK(texture)
//======================================================================
//
// texture, 256x256@16,
// Alphabit on.
// + bitmap not compressed
// Total size: 131072 = 131072
//
// Time-stamp: 2024-01-27, 18:13:28
// Exported by Cearn's GBA Image Transmogrifier, v0.9.2
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
#ifndef GRIT_TEXTURE_H
#define GRIT_TEXTURE_H
#define textureBitmapLen 131072
extern const unsigned int textureBitmap[32768];
#endif // GRIT_TEXTURE_H
//}}BLOCK(texture)

View File

@ -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,18 +8,23 @@
#include <filesystem.h> #include <filesystem.h>
NE_Camera *Camera; typedef struct {
NE_Model *Model; NE_Camera *Camera;
NE_Material *Material; NE_Model *Model;
} SceneData;
void Draw3DScene(void) void Draw3DScene(void *arg)
{ {
NE_CameraUse(Camera); SceneData *Scene = arg;
NE_ModelDraw(Model);
NE_CameraUse(Scene->Camera);
NE_ModelDraw(Scene->Model);
} }
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);
@ -40,32 +45,30 @@ int main(void)
NE_WaitForVBL(0); NE_WaitForVBL(0);
scanKeys(); scanKeys();
uint32_t keys = keysHeld(); if (keysHeld() & KEY_START)
return 0;
if (keys & KEY_START)
return 0;
} }
} }
// Allocate space for the objects we'll use // Allocate space for the objects we'll 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 coordinates for the camera // Set coordinates for the camera
NE_CameraSet(Camera, NE_CameraSet(Scene.Camera,
-8, 3, 0, // Position -8, 3, 0, // Position
0, 3, 0, // Look at 0, 3, 0, // Look at
0, 1, 0); // Up direction 0, 1, 0); // Up direction
// Load mesh from the filesystem and assign it to the object "Model". // Load mesh from the filesystem and assign it to the object "Model".
NE_ModelLoadStaticMeshFAT(Model, "robot.bin"); NE_ModelLoadStaticMeshFAT(Scene.Model, "robot.bin");
// Load a RGB texture from RAM and assign it to "Material". // Load a RGB texture from RAM and assign it to "Material".
NE_MaterialTexLoadFAT(Material, NE_RGB5, 256, 256, NE_TEXGEN_TEXCOORD, NE_MaterialTexLoadFAT(Material, NE_A1RGB5, 256, 256, NE_TEXGEN_TEXCOORD,
"texture.img.bin"); "texture.img.bin");
// Assign texture to model... // Assign texture to model...
NE_ModelSetMaterial(Model, Material); NE_ModelSetMaterial(Scene.Model, Material);
// We set up a light and its color // We set up a light and its color
NE_LightSet(0, NE_White, -0.5, -0.5, -0.5); NE_LightSet(0, NE_White, -0.5, -0.5, -0.5);
@ -83,16 +86,16 @@ 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);
// Draw scene // Draw scene
NE_Process(Draw3DScene); NE_ProcessArg(Draw3DScene, &Scene);
} }
return 0; return 0;

View File

@ -3,4 +3,4 @@
NITROFSDIR := nitrofiles NITROFSDIR := nitrofiles
include ../../Makefile.example.blocksds include ../../Makefile.example

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
NITROFSDIR := nitrofiles
include ../../Makefile.example.blocksds

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
GRIT=/opt/blocksds/core/tools/grit/grit BLOCKSDS="${BLOCKSDS:-/opt/blocksds/core/}"
GRIT=$BLOCKSDS/tools/grit/grit
rm -rf nitrofiles rm -rf nitrofiles
mkdir -p nitrofiles mkdir -p nitrofiles

View File

@ -10,25 +10,34 @@
#include <filesystem.h> #include <filesystem.h>
#include <NEMain.h> #include <NEMain.h>
NE_Material *Material1, *Material2; typedef struct {
NE_Palette *Palette2; NE_Material *Material1;
} SceneData1;
void Draw3DScene(void) typedef struct {
NE_Material *Material2;
} SceneData2;
void Draw3DScene(void *arg)
{ {
SceneData1 *Scene = arg;
NE_2DViewInit(); NE_2DViewInit();
NE_2DDrawTexturedQuad(0, 0, NE_2DDrawTexturedQuad(0, 0,
256, 192, 256, 192,
0, Material1); 0, Scene->Material1);
} }
void Draw3DScene2(void) void Draw3DScene2(void *arg)
{ {
SceneData2 *Scene = arg;
NE_2DViewInit(); NE_2DViewInit();
NE_2DDrawTexturedQuad(64, 32, NE_2DDrawTexturedQuad(64, 32,
64 + 128, 32 + 128, 64 + 128, 32 + 128,
0, Material2); 0, Scene->Material2);
} }
__attribute__((noreturn)) void WaitLoop(void) __attribute__((noreturn)) void WaitLoop(void)
@ -43,8 +52,11 @@ __attribute__((noreturn)) void WaitLoop(void)
} }
} }
int main(void) int main(int argc, char *argv[])
{ {
SceneData1 Scene1 = { 0 };
SceneData2 Scene2 = { 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);
@ -62,18 +74,20 @@ int main(void)
NE_InitConsole(); NE_InitConsole();
// Allocate objects // Allocate objects
Material1 = NE_MaterialCreate(); Scene1.Material1 = NE_MaterialCreate();
Material2 = NE_MaterialCreate(); Scene2.Material2 = NE_MaterialCreate();
Palette2 = NE_PaletteCreate();
if (NE_MaterialTexLoadGRF(Material1, NULL, NE_TEXGEN_TEXCOORD, if (NE_MaterialTexLoadGRF(Scene1.Material1, NULL, NE_TEXGEN_TEXCOORD,
"a1rgb5_png.grf") == 0) "a1rgb5_png.grf") == 0)
{ {
printf("Failed to load GRF 1\n"); printf("Failed to load GRF 1\n");
WaitLoop(); WaitLoop();
} }
if (NE_MaterialTexLoadGRF(Material2, Palette2, NE_TEXGEN_TEXCOORD, // This material has a palette, but we don't care about it. By setting the
// pointer to NULL it will be marked to be autoedeleted when the material is
// deleted.
if (NE_MaterialTexLoadGRF(Scene2.Material2, NULL, NE_TEXGEN_TEXCOORD,
"a3pal32_png.grf") == 0) "a3pal32_png.grf") == 0)
{ {
printf("Failed to load GRF 2\n"); printf("Failed to load GRF 2\n");
@ -84,7 +98,7 @@ int main(void)
{ {
NE_WaitForVBL(0); NE_WaitForVBL(0);
NE_ProcessDual(Draw3DScene, Draw3DScene2); NE_ProcessDualArg(Draw3DScene, Draw3DScene2, &Scene1, &Scene2);
} }
return 0; return 0;

View File

@ -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 :=
GRAPHICS := 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
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
GFXDIRS := graphics
include ../../Makefile.example.blocksds

View File

@ -1,17 +1,9 @@
// 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 "a3pal32.h"
#include "pal4.h"
NE_Material *Material, *Material2;
NE_Palette *Palette, *Palette2;
// This is an example to show how Nitro Engine can load textures of any height. // This is an example to show how Nitro Engine can load textures of any height.
// Internally, the NDS thinks that the texture is bigger, but Nitro Engine only // Internally, the NDS thinks that the texture is bigger, but Nitro Engine only
// uses the parts that the user has loaded. // uses the parts that the user has loaded.
@ -28,21 +20,34 @@ NE_Palette *Palette, *Palette2;
// - They save space in the final ROM, but you can achieve the same effect // - They save space in the final ROM, but you can achieve the same effect
// compressing them with LZSS compression, for example. // compressing them with LZSS compression, for example.
void Draw3DScene(void) #include <NEMain.h>
#include "a3pal32.h"
#include "pal4.h"
typedef struct {
NE_Material *Material, *Material2;
} SceneData;
void Draw3DScene(void *arg)
{ {
SceneData *Scene = arg;
NE_2DViewInit(); NE_2DViewInit();
NE_2DDrawTexturedQuad(40, 10, NE_2DDrawTexturedQuad(40, 10,
40 + 32, 10 + 100, 40 + 32, 10 + 100,
0, Material); 0, Scene->Material);
NE_2DDrawTexturedQuad(128, 10, NE_2DDrawTexturedQuad(128, 10,
128 + 64, 10 + 100, 128 + 64, 10 + 100,
0, Material2); 0, Scene->Material2);
} }
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);
@ -51,31 +56,31 @@ int main(void)
NE_Init3D(); NE_Init3D();
// Allocate objects for a material // Allocate objects for a material
Material = NE_MaterialCreate(); Scene.Material = NE_MaterialCreate();
Palette = NE_PaletteCreate(); NE_Palette *Palette = NE_PaletteCreate();
NE_MaterialTexLoad(Material, NE_MaterialTexLoad(Scene.Material,
NE_A3PAL32, // Texture type NE_A3PAL32, // Texture type
64, 200, // Width, height (in pixels) 64, 200, // Width, height (in pixels)
NE_TEXGEN_TEXCOORD, a3pal32Bitmap); NE_TEXGEN_TEXCOORD, a3pal32Bitmap);
NE_PaletteLoad(Palette, a3pal32Pal, 32, NE_A3PAL32); NE_PaletteLoad(Palette, a3pal32Pal, 32, NE_A3PAL32);
NE_MaterialSetPalette(Material, Palette); NE_MaterialSetPalette(Scene.Material, Palette);
// Allocate objects for another material // Allocate objects for another material
Material2 = NE_MaterialCreate(); Scene.Material2 = NE_MaterialCreate();
Palette2 = NE_PaletteCreate(); NE_Palette *Palette2 = NE_PaletteCreate();
NE_MaterialTexLoad(Material2, NE_PAL4, 64, 100, NE_TEXGEN_TEXCOORD, NE_MaterialTexLoad(Scene.Material2, NE_PAL4, 64, 100, NE_TEXGEN_TEXCOORD,
pal4Bitmap); pal4Bitmap);
NE_PaletteLoad(Palette2, pal4Pal, 4, NE_PAL4); NE_PaletteLoad(Palette2, pal4Pal, 4, NE_PAL4);
NE_MaterialSetPalette(Material2, Palette2); NE_MaterialSetPalette(Scene.Material2, Palette2);
while (1) while (1)
{ {
NE_WaitForVBL(0); NE_WaitForVBL(0);
// Draw 3D scene // Draw 3D scene
NE_Process(Draw3DScene); NE_ProcessArg(Draw3DScene, &Scene);
} }
return 0; return 0;

View File

@ -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 := 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
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
# This is a minimal makefile only used for the examples. If you want a makefile
# for your project, take one from the templates inside examples/templates.
BINDIRS := data
GFXDIRS := graphics
include ../../Makefile.example.blocksds

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