Add support for DSi SD

- Due to too much hardcoding on flashcart, it requires a compiler flag
  to enable DSi features.
This commit is contained in:
lifehackerhansol 2024-10-05 21:11:16 -07:00
parent 5e413177d4
commit a2a82b6e4e
No known key found for this signature in database
GPG Key ID: 80FB184AFC0B3B0E
12 changed files with 187 additions and 23 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
build
arm9/data/load.bin
data/load.bin
*.elf
*.nds
*.dsi
*.pcf
*.dldi

View File

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

View File

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

View File

@ -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<const char*> 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) {

View File

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

View File

@ -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 "/"
// 显示游戏列表,文件列表等等

View File

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

View File

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

View File

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

141
arm9_dsi/Makefile Normal file
View File

@ -0,0 +1,141 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>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
#---------------------------------------------------------------------------------------

View File

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

View File

@ -1,3 +1,3 @@
make clean
make -C nds-bootloader clean
rm arm9/data/load.bin
rm data/load.bin