mirror of
https://github.com/ApacheThunder/dldi-driver-benchmark.git
synced 2025-06-18 18:45:38 -04:00
first commit
This commit is contained in:
commit
3582d0071d
19
LICENSE
Normal file
19
LICENSE
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2023 Adrian "asie" Siekierka
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
298
Makefile.blocks
Normal file
298
Makefile.blocks
Normal file
@ -0,0 +1,298 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# SPDX-FileContributor: Antonio Niño Díaz, 2023
|
||||
|
||||
BLOCKSDS ?= /opt/blocksds/core
|
||||
BLOCKSDSEXT ?= /opt/blocksds/external
|
||||
|
||||
WONDERFUL_TOOLCHAIN ?= /opt/wonderful
|
||||
ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
|
||||
|
||||
# User config
|
||||
# ===========
|
||||
|
||||
NAME := filesystem_benchmark_blocks
|
||||
|
||||
GAME_TITLE := SD filesystem benchmark
|
||||
GAME_SUBTITLE := Built with BlocksDS
|
||||
GAME_AUTHOR := github.com/blocksds/sdk
|
||||
GAME_ICON := icon.bmp
|
||||
|
||||
# DLDI and internal SD slot of DSi
|
||||
# --------------------------------
|
||||
|
||||
# Root folder of the SD image
|
||||
SDROOT := sdroot
|
||||
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
|
||||
SDIMAGE := image.bin
|
||||
|
||||
# Source code paths
|
||||
# -----------------
|
||||
|
||||
SOURCEDIRS := source
|
||||
INCLUDEDIRS :=
|
||||
GFXDIRS := graphics
|
||||
BINDIRS := data
|
||||
AUDIODIRS := audio
|
||||
NITROFSDIR := nitrofs
|
||||
|
||||
# Defines passed to all files
|
||||
# ---------------------------
|
||||
|
||||
DEFINES :=
|
||||
|
||||
# Libraries
|
||||
# ---------
|
||||
|
||||
LIBS := -lmm9 -lnds9
|
||||
LIBDIRS := $(BLOCKSDS)/libs/maxmod \
|
||||
$(BLOCKSDS)/libs/libnds
|
||||
|
||||
# Build artifacts
|
||||
# ---------------
|
||||
|
||||
BUILDDIR := build
|
||||
ELF := build/$(NAME).elf
|
||||
DUMP := build/$(NAME).dump
|
||||
MAP := build/$(NAME).map
|
||||
ROM := $(NAME).nds
|
||||
|
||||
# If NITROFSDIR is set, the output of mmutil will be placed in that directory
|
||||
SOUNDBANKINFODIR := $(BUILDDIR)/maxmod
|
||||
ifeq ($(strip $(NITROFSDIR)),)
|
||||
SOUNDBANKDIR := $(BUILDDIR)/maxmod
|
||||
else
|
||||
SOUNDBANKDIR := $(NITROFSDIR)
|
||||
endif
|
||||
|
||||
# Tools
|
||||
# -----
|
||||
|
||||
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
MKDIR := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
# Verbose flag
|
||||
# ------------
|
||||
|
||||
ifeq ($(VERBOSE),1)
|
||||
V :=
|
||||
else
|
||||
V := @
|
||||
endif
|
||||
|
||||
# Source files
|
||||
# ------------
|
||||
|
||||
ifneq ($(BINDIRS),)
|
||||
SOURCES_BIN := $(shell find -L $(BINDIRS) -name "*.bin")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(BINDIRS))
|
||||
endif
|
||||
ifneq ($(GFXDIRS),)
|
||||
SOURCES_PNG := $(shell find -L $(GFXDIRS) -name "*.png")
|
||||
INCLUDEDIRS += $(addprefix $(BUILDDIR)/,$(GFXDIRS))
|
||||
endif
|
||||
ifneq ($(AUDIODIRS),)
|
||||
SOURCES_AUDIO := $(shell find -L $(AUDIODIRS) -regex '.*\.\(it\|mod\|s3m\|wav\|xm\)')
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
INCLUDEDIRS += $(SOUNDBANKINFODIR)
|
||||
endif
|
||||
endif
|
||||
|
||||
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
|
||||
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
|
||||
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
|
||||
|
||||
# Compiler and linker flags
|
||||
# -------------------------
|
||||
|
||||
DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall
|
||||
|
||||
ifeq ($(SOURCES_CPP),)
|
||||
LD := $(CC)
|
||||
LIBS += -lc
|
||||
else
|
||||
LD := $(CXX)
|
||||
LIBS += -lstdc++ -lc
|
||||
endif
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
||||
LIBDIRSFLAGS := $(foreach path,$(LIBDIRS),-L$(path)/lib)
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
|
||||
-ffunction-sections -fdata-sections
|
||||
|
||||
CFLAGS += -std=gnu11 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fomit-frame-pointer -DBLOCKSDS
|
||||
|
||||
CXXFLAGS += -std=gnu++14 $(WARNFLAGS) $(DEFINES) $(ARCH) \
|
||||
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -O2 \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-fno-exceptions -fno-rtti \
|
||||
-fomit-frame-pointer -DBLOCKSDS
|
||||
|
||||
LDFLAGS := -mthumb -mthumb-interwork $(LIBDIRSFLAGS) \
|
||||
-Wl,-Map,$(MAP) -Wl,--gc-sections -nostdlib \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.mem \
|
||||
-T$(BLOCKSDS)/sys/crts/ds_arm9.ld \
|
||||
-Wl,--no-warn-rwx-segments \
|
||||
-Wl,--start-group $(LIBS) -lgcc -Wl,--end-group
|
||||
|
||||
# Intermediate build files
|
||||
# ------------------------
|
||||
|
||||
OBJS_ASSETS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
HEADERS_ASSETS := $(patsubst %.bin,%_bin.h,$(addprefix $(BUILDDIR)/,$(SOURCES_BIN))) \
|
||||
$(patsubst %.png,%.h,$(addprefix $(BUILDDIR)/,$(SOURCES_PNG)))
|
||||
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
ifeq ($(strip $(NITROFSDIR)),)
|
||||
OBJS_ASSETS += $(SOUNDBANKDIR)/soundbank.c.o
|
||||
endif
|
||||
HEADERS_ASSETS += $(SOUNDBANKINFODIR)/soundbank.h
|
||||
endif
|
||||
|
||||
OBJS_SOURCES := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
|
||||
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
|
||||
|
||||
OBJS := $(OBJS_ASSETS) $(OBJS_SOURCES)
|
||||
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
# Targets
|
||||
# -------
|
||||
|
||||
.PHONY: all clean dump dldipatch sdimage
|
||||
|
||||
all: $(ROM)
|
||||
|
||||
ifneq ($(strip $(NITROFSDIR)),)
|
||||
# Additional arguments for ndstool
|
||||
NDSTOOL_ARGS := -d $(NITROFSDIR)
|
||||
|
||||
# Make the NDS ROM depend on the filesystem only if it is needed
|
||||
$(ROM): $(NITROFSDIR)
|
||||
endif
|
||||
|
||||
# Combine the title strings
|
||||
ifeq ($(strip $(GAME_SUBTITLE)),)
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR)
|
||||
else
|
||||
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR)
|
||||
endif
|
||||
|
||||
$(ROM): $(ELF)
|
||||
@echo " NDSTOOL $@"
|
||||
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
|
||||
-7 $(BLOCKSDS)/sys/default_arm7/arm7.elf -9 $(ELF) \
|
||||
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
|
||||
$(NDSTOOL_ARGS)
|
||||
|
||||
$(ELF): $(OBJS)
|
||||
@echo " LD $@"
|
||||
$(V)$(LD) -o $@ $(OBJS) $(BLOCKSDS)/sys/crts/ds_arm9_crt0.o $(LDFLAGS)
|
||||
|
||||
$(DUMP): $(ELF)
|
||||
@echo " OBJDUMP $@"
|
||||
$(V)$(OBJDUMP) -h -C -S $< > $@
|
||||
|
||||
dump: $(DUMP)
|
||||
|
||||
clean:
|
||||
@echo " CLEAN"
|
||||
$(V)$(RM) $(ROM) $(DUMP) $(BUILDDIR) $(SDIMAGE) \
|
||||
$(SOUNDBANKDIR)/soundbank.bin
|
||||
|
||||
sdimage:
|
||||
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
|
||||
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE)
|
||||
|
||||
dldipatch: $(ROM)
|
||||
@echo " DLDIPATCH $(ROM)"
|
||||
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \
|
||||
$(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM)
|
||||
|
||||
# Rules
|
||||
# -----
|
||||
|
||||
$(BUILDDIR)/%.s.o : %.s
|
||||
@echo " AS $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.c.o : %.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.arm.c.o : %.arm.c
|
||||
@echo " CC $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.cpp.o : %.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.arm.cpp.o : %.arm.cpp
|
||||
@echo " CXX $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -marm -mlong-calls -c -o $@ $<
|
||||
|
||||
$(BUILDDIR)/%.bin.o $(BUILDDIR)/%_bin.h : %.bin
|
||||
@echo " BIN2C $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.bin.o $(BUILDDIR)/$*_bin.c
|
||||
|
||||
$(BUILDDIR)/%.png.o $(BUILDDIR)/%.h : %.png %.grit
|
||||
@echo " GRIT $<"
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(V)$(BLOCKSDS)/tools/grit/grit $< -ftc -W1 -o$(BUILDDIR)/$*
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(BUILDDIR)/$*.png.o $(BUILDDIR)/$*.c
|
||||
|
||||
ifneq ($(SOURCES_AUDIO),)
|
||||
|
||||
$(SOUNDBANKINFODIR)/soundbank.h: $(SOURCES_AUDIO)
|
||||
@echo " MMUTIL $^"
|
||||
@$(MKDIR) -p $(@D)
|
||||
@$(BLOCKSDS)/tools/mmutil/mmutil $^ -d \
|
||||
-o$(SOUNDBANKDIR)/soundbank.bin -h$(SOUNDBANKINFODIR)/soundbank.h
|
||||
|
||||
ifeq ($(strip $(NITROFSDIR)),)
|
||||
$(SOUNDBANKDIR)/soundbank.c.o: $(SOUNDBANKINFODIR)/soundbank.h
|
||||
@echo " BIN2C soundbank.bin"
|
||||
$(V)$(BLOCKSDS)/tools/bin2c/bin2c $(SOUNDBANKDIR)/soundbank.bin \
|
||||
$(SOUNDBANKDIR)
|
||||
@echo " CC.9 soundbank_bin.c"
|
||||
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $(SOUNDBANKDIR)/soundbank.c.o \
|
||||
$(SOUNDBANKDIR)/soundbank_bin.c
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# All assets must be built before the source code
|
||||
# -----------------------------------------------
|
||||
|
||||
$(SOURCES_S) $(SOURCES_C) $(SOURCES_CPP): $(HEADERS_ASSETS)
|
||||
|
||||
# Include dependency files if they exist
|
||||
# --------------------------------------
|
||||
|
||||
-include $(DEPS)
|
220
Makefile.dkp
Normal file
220
Makefile.dkp
Normal file
@ -0,0 +1,220 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
# These set the information text in the nds file
|
||||
GAME_TITLE := SD filesystem benchmark
|
||||
GAME_SUBTITLE1 := built with devkitARM
|
||||
GAME_SUBTITLE2 := http://devitpro.org
|
||||
|
||||
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 := filesystem_benchmark_dkp
|
||||
BUILD := build_dkp
|
||||
SOURCES := source
|
||||
INCLUDES := include
|
||||
DATA := data
|
||||
GRAPHICS :=
|
||||
AUDIO :=
|
||||
ICON :=
|
||||
|
||||
# specify a directory which contains the nitro filesystem
|
||||
# this is relative to the Makefile
|
||||
NITRO := nitrofs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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 := -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)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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.dkp
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).nds: $(OUTPUT).elf $(NITRO_FILES) $(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
|
||||
#---------------------------------------------------------------------------------------
|
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# nds-sd-benchmark
|
||||
|
||||
Simple filesystem I/O benchmark for NDS homebrew.
|
||||
|
||||
## Building
|
||||
|
||||
$ ./generate_padding.sh
|
||||
$ make -f Makefile.blocks # or Makefile.dkp
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
3
generate_padding.sh
Executable file
3
generate_padding.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
mkdir -p nitrofs
|
||||
dd if=/dev/urandom of=nitrofs/pad.bin bs=1M count=16
|
135
source/main.c
Normal file
135
source/main.c
Normal file
@ -0,0 +1,135 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// SPDX-FileContributor: Adrian "asie" Siekierka, 2023
|
||||
|
||||
//#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef BLOCKSDS
|
||||
#include <fatfs.h>
|
||||
#else
|
||||
#include <fat.h>
|
||||
#endif
|
||||
#include <nds.h>
|
||||
|
||||
#include <nds/arm9/dldi.h>
|
||||
|
||||
static inline uint32_t my_rand(void)
|
||||
{
|
||||
static uint32_t seed = 0;
|
||||
|
||||
seed = seed * 0xFDB97531 + 0x2468ACE;
|
||||
|
||||
return seed;
|
||||
}
|
||||
|
||||
static inline uint32_t get_ticks(void) {
|
||||
return TIMER0_DATA | (TIMER1_DATA << 16);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
FILE *file = NULL;
|
||||
consoleDemoInit();
|
||||
|
||||
printf("\x1b[2J"); // Clear console
|
||||
|
||||
// 012345678901234567890123456sssss78901
|
||||
printf(" \x1b[43m*\x1b[39m SD file system benchmark \x1b[43m*\x1b[39m\n");
|
||||
printf("\x1b[37mDLDI: %s\x1b[39m\n\n", io_dldi_data->friendlyName);
|
||||
|
||||
if (argc <= 0 || argv[0][0] == 0) {
|
||||
printf("\x1b[41mCould not find argv!\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
int buf_size = 2*1024*1024;
|
||||
char *buffer = malloc(buf_size);
|
||||
if (buffer == NULL) {
|
||||
printf("\x1b[41mOut of memory!\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
fatInitDefault();
|
||||
file = fopen(argv[0], "rb");
|
||||
if (file == NULL) {
|
||||
printf("\x1b[41mCould not open '%s'!\n", argv[0]);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* printf("Main RAM: (A) ARM7, (B) ARM9");
|
||||
|
||||
while (1)
|
||||
{
|
||||
swiWaitForVBlank();
|
||||
|
||||
scanKeys();
|
||||
|
||||
uint32_t keys_down = keysDown();
|
||||
if (keys_down & KEY_A) {
|
||||
REG_EXMEMCNT |= EXMEMCNT_MAIN_RAM_PRIORITY_ARM7;
|
||||
printf(" \x1b[43mA\x1b[39m\n");
|
||||
break;
|
||||
}
|
||||
if (keys_down & KEY_B) {
|
||||
REG_EXMEMCNT &= ~EXMEMCNT_MAIN_RAM_PRIORITY_ARM7;
|
||||
printf(" \x1b[43mB\x1b[39m\n");
|
||||
break;
|
||||
}
|
||||
} */
|
||||
|
||||
TIMER0_DATA = 0;
|
||||
TIMER1_DATA = 0;
|
||||
TIMER0_CR = TIMER_ENABLE | TIMER_DIV_256;
|
||||
TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE;
|
||||
|
||||
char msg_buffer[33];
|
||||
int reads_count = 4;
|
||||
for (int curr_size = buf_size; curr_size >= 512; curr_size >>= 1) {
|
||||
if (curr_size >= 1024*1024) {
|
||||
printf(" %3d MiB", curr_size >> 20);
|
||||
} else if (curr_size >= 1024) {
|
||||
printf(" %3d KiB", curr_size >> 10);
|
||||
reads_count <<= 1;
|
||||
} else {
|
||||
printf(" 0.5 KiB");
|
||||
}
|
||||
|
||||
uint32_t ticks_start = get_ticks();
|
||||
uint32_t reads = 0;
|
||||
while (reads < reads_count) {
|
||||
fseek(file, (my_rand() & (~0x1FF)) & 0x7FFFFF, SEEK_SET);
|
||||
fread(buffer, curr_size, 1, file);
|
||||
reads++;
|
||||
}
|
||||
double read_kilobytes = (curr_size / 1024.0) * reads_count;
|
||||
uint32_t ticks_end = get_ticks();
|
||||
double seconds_time = (ticks_end - ticks_start) / (double)(BUS_CLOCK >> 8);
|
||||
double kilobytes_per_second = read_kilobytes / seconds_time;
|
||||
if (kilobytes_per_second >= 1024.0) {
|
||||
sprintf(msg_buffer, "%.3f MB/s", kilobytes_per_second / 1024.0);
|
||||
} else {
|
||||
sprintf(msg_buffer, "%.3f KB/s", kilobytes_per_second);
|
||||
}
|
||||
|
||||
printf("\x1b[32D\x1b[%dC\x1b[42m%s\x1b[39m\n", 32 - strlen(msg_buffer)-1, msg_buffer);
|
||||
}
|
||||
|
||||
exit:
|
||||
if (file != NULL)
|
||||
fclose(file);
|
||||
printf("\x1b[39m\n");
|
||||
printf("Press START to exit to loader\n");
|
||||
|
||||
while (1)
|
||||
{
|
||||
swiWaitForVBlank();
|
||||
|
||||
scanKeys();
|
||||
|
||||
uint32_t keys_down = keysDown();
|
||||
if (keys_down & KEY_START)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user