diff --git a/.gitignore b/.gitignore index f454228..35ce465 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ build -arm9/data/load.bin +data/load.bin *.elf *.nds +*.dsi *.pcf *.dldi diff --git a/Makefile b/Makefile index bc938e2..97377e5 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,12 @@ GAME_SUBTITLE2 := www.acekard.com include $(DEVKITARM)/ds_rules -.PHONY: checkarm7 checkarm9 clean +.PHONY: checkarm7 checkarm9 checkarm9_dsi clean #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- -all: checkarm7 checkarm9 $(TARGET).nds +all: checkarm7 checkarm9 checkarm9_dsi $(TARGET).nds $(TARGET).dsi #--------------------------------------------------------------------------------- checkarm7: @@ -37,12 +37,22 @@ checkarm7: checkarm9: $(MAKE) -C arm9 +#--------------------------------------------------------------------------------- +checkarm9_dsi: + $(MAKE) -C arm9_dsi + #--------------------------------------------------------------------------------- $(TARGET).nds : $(NITRO_FILES) arm7/$(TARGET).elf arm9/$(TARGET).elf ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ $(_ADDFILES) +#--------------------------------------------------------------------------------- +$(TARGET).dsi : $(NITRO_FILES) arm7/$(TARGET).elf arm9_dsi/$(TARGET).elf + ndstool -c $@ -7 arm7/$(TARGET).elf -9 arm9_dsi/$(TARGET).elf \ + -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ + $(_ADDFILES) + #--------------------------------------------------------------------------------- arm7/$(TARGET).elf: $(MAKE) -C arm7 @@ -51,8 +61,13 @@ arm7/$(TARGET).elf: arm9/$(TARGET).elf: $(MAKE) -C arm9 +#--------------------------------------------------------------------------------- +arm9_dsi/$(TARGET).elf: + $(MAKE) -C arm9_dsi + #--------------------------------------------------------------------------------- clean: $(MAKE) -C arm9 clean + $(MAKE) -C arm9_dsi clean $(MAKE) -C arm7 clean - rm -f $(TARGET).nds + rm -f *.nds *.dsi diff --git a/arm9/Makefile b/arm9/Makefile index 6835215..494b496 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -18,7 +18,7 @@ include $(DEVKITARM)/ds_rules BUILD := build SOURCES := source source/ui source/font source/launcher source/saves INCLUDES := include ../share $(SOURCES) -DATA := data +DATA := data ../data GRAPHICS := #--------------------------------------------------------------------------------- @@ -27,7 +27,10 @@ GRAPHICS := ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s CFLAGS := -g -Wall -O3\ - $(ARCH) $(INCLUDE) -DARM9 -D_NO_BOOTSTUB_ + $(ARCH) $(INCLUDE) -DARM9 + +CFLAGS += -D_NO_BOOTSTUB_ + CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions ASFLAGS := -g $(ARCH) LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) diff --git a/arm9/source/launcher/NdsBootstrapLauncher.cpp b/arm9/source/launcher/NdsBootstrapLauncher.cpp index 4f07542..426bb72 100644 --- a/arm9/source/launcher/NdsBootstrapLauncher.cpp +++ b/arm9/source/launcher/NdsBootstrapLauncher.cpp @@ -17,6 +17,7 @@ #include "../dsrom.h" #include "../flags.h" #include "../inifile.h" +#include "../mainlist.h" #include "ILauncher.h" #include "NdsBootstrapLauncher.h" #include "nds_loader_arm9.h" @@ -71,28 +72,20 @@ bool NdsBootstrapLauncher::prepareIni() { bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath, u32 flags, u32 cheatOffset, u32 cheatSize) { - std::string ndsBootstrapPath = "/_nds/nds-bootstrap-release.nds"; + const char ndsBootstrapPath[] = SD_ROOT_0 "/_nds/nds-bootstrap-release.nds"; std::vector argv; mRomPath = romPath; mSavePath = savePath; mFlags = flags; - // mRomPath *should* have the drive name set - // If it doesn't for some reason, default to `fat:/`, because most people are probably using - // this on flashcart - if (mRomPath.find("sd:/", 0) == std::string::npos) - ndsBootstrapPath = "fat:" + ndsBootstrapPath; - else - ndsBootstrapPath = "sd:" + ndsBootstrapPath; - // Create the nds-bootstrap directory if it doesn't exist if (access("/_nds/nds-bootstrap/", F_OK) != 0) { mkdir("/_nds/nds-bootstrap/", 0777); } // Setup argv to launch nds-bootstrap - argv.push_back(ndsBootstrapPath.c_str()); + argv.push_back(ndsBootstrapPath); // Prepare cheat codes if enabled if (flags & PATCH_CHEATS) { diff --git a/arm9/source/mainlist.cpp b/arm9/source/mainlist.cpp index eabf4fa..067135d 100644 --- a/arm9/source/mainlist.cpp +++ b/arm9/source/mainlist.cpp @@ -321,7 +321,8 @@ void cMainList::backParentDir() { if ("..." == _currentDir) return; bool fat1 = (SD_ROOT == _currentDir), favorites = ("favorites:/" == _currentDir); - if ("fat:/" == _currentDir || fat1 || favorites || "/" == _currentDir) { + if ("fat:/" == _currentDir || "sd:/" == _currentDir || fat1 || favorites || + "/" == _currentDir) { enterDir("..."); if (fat1) selectRow(_topuSD); if (favorites) selectRow(_topFavorites); diff --git a/arm9/source/mainlist.h b/arm9/source/mainlist.h index 804269e..1374d06 100644 --- a/arm9/source/mainlist.h +++ b/arm9/source/mainlist.h @@ -17,7 +17,11 @@ #include "touchmessage.h" #include "zoomingicon.h" +#ifndef __DSIMODE__ #define SD_ROOT_0 "fat:" +#else +#define SD_ROOT_0 "sd:" +#endif #define SD_ROOT SD_ROOT_0 "/" // 显示游戏列表,文件列表等等 diff --git a/arm9/source/mainwnd.cpp b/arm9/source/mainwnd.cpp index 8773998..51fca9d 100644 --- a/arm9/source/mainwnd.cpp +++ b/arm9/source/mainwnd.cpp @@ -583,7 +583,7 @@ void cMainWnd::setParam(void) { gs().uiName = uiNames[uiIndexAfter]; gs().langDirectory = langNames[langIndexAfter]; gs().saveSettings(); - HomebrewLauncher().launchRom("fat:/akmenu4.nds", "", 0, 0, 0); + HomebrewLauncher().launchRom("/akmenu4.nds", "", 0, 0, 0); } } @@ -593,7 +593,7 @@ void cMainWnd::setParam(void) { if (ID_YES == ret) { gs().langDirectory = langNames[langIndexAfter]; gs().saveSettings(); - HomebrewLauncher().launchRom("fat:/akmenu4.nds", "", 0, 0, 0); + HomebrewLauncher().launchRom("/akmenu4.nds", "", 0, 0, 0); } } diff --git a/arm9/source/rominfownd.cpp b/arm9/source/rominfownd.cpp index f6ff9fa..e2a69a3 100644 --- a/arm9/source/rominfownd.cpp +++ b/arm9/source/rominfownd.cpp @@ -211,7 +211,7 @@ void cRomInfoWnd::setFileInfo(const std::string& fullName, const std::string& sh return; } - if ("fat:/" == fullName) { + if ("fat:/" == fullName || "sd:/" == fullName) { return; } diff --git a/arm9/source/systemfilenames.h b/arm9/source/systemfilenames.h index 57b9c35..1d63254 100644 --- a/arm9/source/systemfilenames.h +++ b/arm9/source/systemfilenames.h @@ -9,7 +9,11 @@ #pragma once +#ifndef __DSIMODE__ #define SFN_SYSTEM_DIR "fat:/__rpg/" +#else +#define SFN_SYSTEM_DIR "sd:/__rpg/" +#endif #define SFN_OFFICIAL_SAVELIST SFN_SYSTEM_DIR "savelist.bin" #define SFN_CUSTOM_SAVELIST SFN_SYSTEM_DIR "gamedata.bin" #define SFN_LAST_SAVEINFO SFN_SYSTEM_DIR "lastsave.ini" diff --git a/arm9_dsi/Makefile b/arm9_dsi/Makefile new file mode 100644 index 0000000..837aa5f --- /dev/null +++ b/arm9_dsi/Makefile @@ -0,0 +1,141 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/ds_rules + +SOURCE_PATH := ../arm9 +#--------------------------------------------------------------------------------- +# 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 +# all directories are relative to this makefile +#--------------------------------------------------------------------------------- +BUILD := build +SOURCES := $(SOURCE_PATH)/source $(SOURCE_PATH)/source/ui $(SOURCE_PATH)/source/font $(SOURCE_PATH)/source/launcher $(SOURCE_PATH)/source/saves +INCLUDES := $(SOURCE_PATH)/include ../share $(SOURCES) +DATA := $(SOURCE_PATH)/data ../data +GRAPHICS := + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s + +CFLAGS := -g -Wall -O3\ + $(ARCH) $(INCLUDE) -DARM9 + +CFLAGS += -D_NO_BOOTSTUB_ -D__DSIMODE__ + +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 +#--------------------------------------------------------------------------------- +LIBS := -lfat -lnds9 + +#--------------------------------------------------------------------------------- +# 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 ARM9ELF := $(CURDIR)/$(TARGET).elf + +export VPATH := $(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)/*.*))) + +#--------------------------------------------------------------------------------- +# 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) + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf + + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(ARM9ELF) : $(OFILES) + @echo linking $(notdir $@) + @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + +#--------------------------------------------------------------------------------- +%.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$* + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/build.sh b/build.sh index 3d19fe1..dfbcd7f 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,5 @@ -mkdir arm9/data -make -C nds-bootloader LOADBIN=$PWD/arm9/data/load.bin +set -e + +mkdir -p data +make -C nds-bootloader LOADBIN=$PWD/data/load.bin make diff --git a/clean.sh b/clean.sh index 6f9aebe..eaa85fa 100755 --- a/clean.sh +++ b/clean.sh @@ -1,3 +1,3 @@ make clean make -C nds-bootloader clean -rm arm9/data/load.bin +rm data/load.bin