From 8e4d75971b0621410953870d860fa29dd75229e3 Mon Sep 17 00:00:00 2001 From: Asaduji <39374509+Asaduji@users.noreply.github.com> Date: Sun, 1 Mar 2026 02:28:06 +0100 Subject: [PATCH] Properly handle filesystem. Removed the requirement for separate binaries to be built. Added support to load games from both fat:/ and sd:/ on DSpico (or future DSi mode flashcarts) --- Makefile | 35 +---- arm7/source/main.cpp | 11 ++ arm9/Makefile | 7 +- arm9/source/cheatwnd.cpp | 4 +- arm9/source/fsmngr.cpp | 63 ++++++++ arm9/source/fsmngr.h | 30 ++++ arm9/source/globalsettings.cpp | 2 +- arm9/source/helpwnd.cpp | 10 +- arm9/source/launcher/DSpicoLauncher.cpp | 4 +- arm9/source/launcher/NdsBootstrapLauncher.cpp | 46 +++--- arm9/source/launcher/Slot1Launcher.cpp | 10 +- arm9/source/launcher/TopToyLauncher.cpp | 2 +- arm9/source/launcher/nds_loader_arm9.c | 7 +- arm9/source/main.cpp | 13 +- arm9/source/mainlist.cpp | 76 +++++++--- arm9/source/mainlist.h | 9 +- arm9/source/mainwnd.cpp | 84 ++++++----- arm9/source/romlauncher.cpp | 4 +- arm9/source/systemfilenames.h | 37 +++-- arm9_dsi/Makefile | 142 ------------------ arm9_dsi_pico/Makefile | 142 ------------------ package/package.cmd | 28 ++-- package/package.sh | 28 ++-- share/fifotool.h | 1 + 24 files changed, 291 insertions(+), 504 deletions(-) create mode 100644 arm9/source/fsmngr.cpp create mode 100644 arm9/source/fsmngr.h delete mode 100644 arm9_dsi/Makefile delete mode 100644 arm9_dsi_pico/Makefile diff --git a/Makefile b/Makefile index 61ab028b..a058b720 100644 --- a/Makefile +++ b/Makefile @@ -30,12 +30,12 @@ endif include $(DEVKITARM)/ds_rules -.PHONY: nds-bootloader checkarm7 checkarm9 checkarm9_dsi clean +.PHONY: nds-bootloader checkarm7 checkarm9 clean #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- -all: $(TARGET).nds $(TARGET).dsi boot_pico.nds +all:$(TARGET).nds $(TARGET).dsi @$(MAKE) organize_files data: @@ -53,43 +53,24 @@ checkarm9: nds-bootloader $(MAKE) -C arm9 #--------------------------------------------------------------------------------- -checkarm9_dsi: nds-bootloader - $(MAKE) -C arm9_dsi -#--------------------------------------------------------------------------------- -checkarm9_pico: nds-bootloader - $(MAKE) -C arm9_dsi_pico - -#--------------------------------------------------------------------------------- $(TARGET).nds : $(NITRO_FILES) checkarm7 checkarm9 ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ -h 0x200 -t banner.bin \ $(_ADDFILES) -#--------------------------------------------------------------------------------- -$(TARGET).dsi : $(NITRO_FILES) checkarm7 checkarm9_dsi - ndstool -c $@ -7 arm7/$(TARGET).elf -9 arm9_dsi/$(TARGET).elf \ +$(TARGET).dsi : $(NITRO_FILES) checkarm7 checkarm9 + ndstool -c $@ -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ -t banner.bin \ -g NEXT 01 "AKMENU" -z 80040407 -u 00030004 -a 00000138 -p 0001 \ $(_ADDFILES) -boot_pico.nds : $(NITRO_FILES) checkarm7 checkarm9_pico - ndstool -c boot_pico.nds \ - -7 arm7/$(TARGET).elf \ - -9 arm9_dsi_pico/$(TARGET).elf \ - -t banner.bin \ - -g NEXT 01 "AKMENU" -z 80040407 -u 00030004 -a 00000138 -p 0001 \ - $(_ADDFILES) - #--------------------------------------------------------------------------------- organize_files: - @mv -f $(TARGET).nds $(TARGET).dsi boot_pico.nds package/ - cp package/$(TARGET).nds package/_nds/akmenunext/launcher_nds.nds - cp package/$(TARGET).dsi package/_nds/akmenunext/launcher_dsi.nds + @mv -f $(TARGET).nds $(TARGET).dsi package/ cp package/$(TARGET).dsi package/title/00030004/4e455854/content/00000000.app - cp package/boot_pico.nds package/_nds/akmenunext/launcher_pico.nds - cp package/$(TARGET).nds package/boot_nds.nds - cp package/$(TARGET).dsi package/boot_dsi.nds + cp package/$(TARGET).nds package/boot.nds + cp package/$(TARGET).dsi package/boot.dsi @$(MAKE) make_cia rm -f package/$(TARGET).nds package/$(TARGET).dsi cp -r language package/_nds/akmenunext/ @@ -101,11 +82,9 @@ make_cia: #--------------------------------------------------------------------------------- clean: $(MAKE) -C arm9 clean - $(MAKE) -C arm9_dsi clean $(MAKE) -C nds-bootloader clean $(MAKE) -C arm7 clean rm -rf data rm -f package/*.nds package/*.dsi package/*.cia - rm -f package/_nds/akmenunext/launcher_nds.nds package/_nds/akmenunext/launcher_dsi.nds package/_nds/akmenunext/launcher_pico.nds rm -f *.nds *.dsi rm -rf package/_nds/akmenunext/language diff --git a/arm7/source/main.cpp b/arm7/source/main.cpp index 67a6b19e..6237e5db 100644 --- a/arm7/source/main.cpp +++ b/arm7/source/main.cpp @@ -114,6 +114,13 @@ static u8 brightnessGet(void) { return data & PM_NDSLITE_BRIGHTNESS_MASK; } +static u8 checkSD(void) { + //SD_IRQ_STATUS0 + u32 status = *(volatile u32*)(0x400481C); + + return status & (1u << 5); +} + static void menuValue32Handler(u32 value, void* data) { switch (value) { case MENU_MSG_GBA: { @@ -156,6 +163,10 @@ static void menuValue32Handler(u32 value, void* data) { readPowerManagement(PM_CONTROL2_REG) | PM_CONTROL2_RESET); else systemShutDown(); + break; + case MENU_MSG_IS_SD_INSERTED: + fifoSendValue32(FIFO_USER_01, checkSD()); + break; default: break; } diff --git a/arm9/Makefile b/arm9/Makefile index f3be2a78..26fe1526 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -7,6 +7,7 @@ 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 @@ -16,9 +17,9 @@ include $(DEVKITARM)/ds_rules # all directories are relative to this makefile #--------------------------------------------------------------------------------- BUILD := build -SOURCES := source source/ui source/font source/launcher source/saves -INCLUDES := include ../share $(SOURCES) -DATA := data ../data +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 := #--------------------------------------------------------------------------------- diff --git a/arm9/source/cheatwnd.cpp b/arm9/source/cheatwnd.cpp index 7a21ca85..b5ce965b 100644 --- a/arm9/source/cheatwnd.cpp +++ b/arm9/source/cheatwnd.cpp @@ -236,7 +236,7 @@ static void updateDB(u8 value, u32 offset, FILE* db) { } void cCheatWnd::onGenerate(void) { - FILE* db = fopen(SFN_CHEATS, "r+b"); + FILE* db = fopen((SFN_CHEATS).c_str(), "r+b"); if (db) { std::vector::iterator itr = _data.begin(); while (itr != _data.end()) { @@ -288,7 +288,7 @@ bool cCheatWnd::parse(const std::string& aFileName) { _fileName = aFileName; u32 romcrc32, gamecode; if (romData(_fileName, gamecode, romcrc32)) { - FILE* dat = fopen(SFN_CHEATS, "rb"); + FILE* dat = fopen((SFN_CHEATS).c_str(), "rb"); if (dat) { res = parseInternal(dat, gamecode, romcrc32); fclose(dat); diff --git a/arm9/source/fsmngr.cpp b/arm9/source/fsmngr.cpp new file mode 100644 index 00000000..c6160b6a --- /dev/null +++ b/arm9/source/fsmngr.cpp @@ -0,0 +1,63 @@ +#include "fsmngr.h" +#include "fifotool.h" + +cFSManager::cFSManager() : _isSDInserted(false), _isFlashcart(false), _fsRoot() { + +} + +void cFSManager::init(int argc, char* argv[]) { + _isSDInserted = checkSDInserted(); + + // We're always on a flashcart if we're running in NTR mode + if (!isDSiMode()) { + _isFlashcart = true; + // If no SD is inserted, we can only be on a flashcart + } else if (!isSDInserted()) { + _isFlashcart = true; + // If argv tells us we've launched from fat, we're on a flashcart + }else if (argc > 0 && strncmp(argv[0], "fat:/", 5) == 0) { + _isFlashcart = true; + } + + // Mount devices + if (isFlashcart()) { + fatMountSimple("fat", dldiGetInternal()); + chdir("fat:/"); + _fsRoot = "fat:"; + } + + if (isSDInserted()) { + fatMountSimple("sd", get_io_dsisd()); + + if (!isFlashcart()) { + chdir("sd:/"); + _fsRoot = "sd:"; + } + } +} + +bool cFSManager::isFlashcart() const { + return _isFlashcart; +} + +bool cFSManager::isSDInserted() const { + return _isSDInserted; +} + +std::string cFSManager::resolveSystemPath(const char* path) const { + return _fsRoot + path; +} + +std::string cFSManager::getFSRoot() const { + return _fsRoot + "/"; +} + +bool cFSManager::checkSDInserted() const { + fifoSendValue32(FIFO_USER_01, MENU_MSG_IS_SD_INSERTED); + + fifoWaitValue32(FIFO_USER_01); + + int result = fifoGetValue32(FIFO_USER_01); + + return result != 0; +} diff --git a/arm9/source/fsmngr.h b/arm9/source/fsmngr.h new file mode 100644 index 00000000..d3e849df --- /dev/null +++ b/arm9/source/fsmngr.h @@ -0,0 +1,30 @@ +#pragma once +#include +#include +#include +#include +#include +#include "singleton.h" + + +class cFSManager { +public: + cFSManager(); + void init(int argc, char* argv[]); + bool isFlashcart() const; + bool isSDInserted() const; + std::string resolveSystemPath(const char* path) const; + std::string getFSRoot() const; + +private: + bool checkSDInserted() const; + bool _isSDInserted; + bool _isFlashcart; + std::string _fsRoot; +}; + + +typedef t_singleton FSManager_s; +inline cFSManager& fsManager() { + return FSManager_s::instance(); +} diff --git a/arm9/source/globalsettings.cpp b/arm9/source/globalsettings.cpp index c9bd3383..c7fc1994 100644 --- a/arm9/source/globalsettings.cpp +++ b/arm9/source/globalsettings.cpp @@ -114,7 +114,7 @@ void cGlobalSettings::loadSettings() { #endif struct stat st; - if (0 == stat(SFN_CHEATS, &st)) cheatDB = true; + if (0 == stat((SFN_CHEATS).c_str(), &st)) cheatDB = true; CIniFile iniBacklight(SFN_BACKLIGHT); brightness = iniBacklight.GetInt("brightness", "brightness", brightness); diff --git a/arm9/source/helpwnd.cpp b/arm9/source/helpwnd.cpp index 82ab70b6..ad5b1961 100644 --- a/arm9/source/helpwnd.cpp +++ b/arm9/source/helpwnd.cpp @@ -45,11 +45,7 @@ cHelpWnd::cHelpWnd(s32 x, s32 y, u32 w, u32 h, cWindow* parent, const std::strin } _helpText = formatString(_helpText.c_str(), 7, 1, 2, 4, 3, 5, 6, "START", "SELECT"); - #if defined(__DSIMODE__) && !defined(__DSPICO__) - const char* ndsbsVer = "sd:/_nds/release-bootstrap.ver"; - #else - const char* ndsbsVer = "fat:/_nds/release-bootstrap.ver"; - #endif + std::string ndsbsVer = fsManager().resolveSystemPath("/_nds/release-bootstrap.ver"); char ndsbsBuffer[256]; _helpText += "https://github.com/coderkei\n"; @@ -58,8 +54,8 @@ cHelpWnd::cHelpWnd(s32 x, s32 y, u32 w, u32 h, cWindow* parent, const std::strin if(gs().pico){ _helpText += formatString("\n%s %s ", AKMENU_PICO_NAME, AKMENU_LOADER_VERSION); } - else if(access(ndsbsVer, F_OK) == 0 && gs().pico == false){ - FILE* file = fopen(ndsbsVer, "r"); + else if(access(ndsbsVer.c_str(), F_OK) == 0 && gs().pico == false){ + FILE* file = fopen(ndsbsVer.c_str(), "r"); if (file) { if (fgets(ndsbsBuffer, sizeof(ndsbsBuffer), file)) { _helpText += formatString("\n%s %s ", AKMENU_LOADER_NAME, ndsbsBuffer); diff --git a/arm9/source/launcher/DSpicoLauncher.cpp b/arm9/source/launcher/DSpicoLauncher.cpp index df2f4915..85ae50ec 100644 --- a/arm9/source/launcher/DSpicoLauncher.cpp +++ b/arm9/source/launcher/DSpicoLauncher.cpp @@ -35,8 +35,8 @@ typedef void (*pico_loader_9_func_t)(void); bool DSpicoLauncher::launchRom(std::string romPath, std::string savePath, u32 flags, u32 cheatOffset, u32 cheatSize, bool hb) { - const char picoLoader7Path[] = SD_ROOT_0 "/_pico/picoLoader7.bin"; - const char picoLoader9Path[] = SD_ROOT_0 "/_pico/picoLoader9.bin"; + const char picoLoader7Path[] = "fat:/_pico/picoLoader7.bin"; + const char picoLoader9Path[] = "fat:/_pico/picoLoader9.bin"; progressWnd().setTipText("Initializing pico-loader..."); progressWnd().show(); diff --git a/arm9/source/launcher/NdsBootstrapLauncher.cpp b/arm9/source/launcher/NdsBootstrapLauncher.cpp index 3866f29a..6b5b5a7a 100644 --- a/arm9/source/launcher/NdsBootstrapLauncher.cpp +++ b/arm9/source/launcher/NdsBootstrapLauncher.cpp @@ -27,6 +27,7 @@ #include "ILauncher.h" #include "NdsBootstrapLauncher.h" #include "nds_loader_arm9.h" +#include "fsmngr.h" void smoothProgress(u8 start, u8 end) { for(u8 p = start; p <= end; p += 5) { @@ -40,7 +41,7 @@ bool NdsBootstrapLauncher::prepareCheats() { u32 gameCode, crc32; if (cCheatWnd::romData(mRomPath, gameCode, crc32)) { - FILE* cheatDb = fopen(SFN_CHEATS, "rb"); + FILE* cheatDb = fopen((SFN_CHEATS).c_str(), "rb"); if (!cheatDb) goto cheat_failed; long cheatOffset; size_t cheatSize; @@ -90,19 +91,11 @@ bool NdsBootstrapLauncher::prepareIni(bool hb) { ini.SetString("NDS-BOOTSTRAP", "SAV_PATH", mSavePath); - #if defined(__DSIMODE__) && !defined(__DSPICO__) - ini.SetString("NDS-BOOTSTRAP", "QUIT_PATH", "sd:/_nds/akmenunext/launcher.nds"); - #else - ini.SetString("NDS-BOOTSTRAP", "QUIT_PATH", "fat:/_nds/akmenunext/launcher.nds"); - #endif + ini.SetString("NDS-BOOTSTRAP", "QUIT_PATH", fsManager().resolveSystemPath("/_nds/akmenunext/launcher.nds")); - #if defined(__DSIMODE__) && !defined(__DSPICO__) - const char* custIniPath = "sd:/_nds/akmenunext/ndsbs.ini"; - #else - const char* custIniPath = "fat:/_nds/akmenunext/ndsbs.ini"; - #endif + std::string custIniPath = fsManager().resolveSystemPath("/_nds/akmenunext/ndsbs.ini"); - if(access(custIniPath, F_OK) != 0){ + if(access(custIniPath.c_str(), F_OK) != 0){ akui::messageBox(NULL, LANG("nds bootstrap", "inimissingtitle"), LANG("nds bootstrap", "inimissing"), MB_OK); return false; } @@ -194,10 +187,9 @@ bool NdsBootstrapLauncher::prepareIni(bool hb) { if(gs().dsOnly) { ini.SetString("NDS-BOOTSTRAP", "DSI_MODE", "0"); } - if(gs().phatCol) { - #ifdef __DSIMODE__ + + if(gs().phatCol && isDSiMode()) { ini.SetString("NDS-BOOTSTRAP", "PHAT_COLORS", "1"); - #endif } if (access("/_nds/debug.txt", F_OK) == 0) { @@ -212,9 +204,9 @@ bool NdsBootstrapLauncher::prepareIni(bool hb) { bool launchHbStrap(std::string romPath){ progressWnd().setPercent(100); - const char ndsHbBootstrapPath[] = SD_ROOT_0 "/_nds/nds-bootstrap-hb-release.nds"; + std::string ndsHbBootstrapPath = fsManager().resolveSystemPath("/_nds/nds-bootstrap-hb-release.nds"); std::vector argv; - argv.push_back(ndsHbBootstrapPath); + argv.push_back(ndsHbBootstrapPath.c_str()); progressWnd().hide(); eRunNdsRetCode rc = runNdsFile(argv[0], argv.size(), &argv[0]); if (rc == RUN_NDS_OK) return true; @@ -223,17 +215,17 @@ bool launchHbStrap(std::string romPath){ bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath, u32 flags, u32 cheatOffset, u32 cheatSize, bool hb) { - const char ndsBootstrapPath[] = SD_ROOT_0 "/_nds/nds-bootstrap-release.nds"; - const char ndsBootstrapPathNightly[] = SD_ROOT_0 "/_nds/nds-bootstrap-nightly.nds"; - const char ndsHbBootstrapPath[] = SD_ROOT_0 "/_nds/nds-bootstrap-hb-release.nds"; - const char ndsBootstrapCheck[] = SD_ROOT_0 "/_nds/pagefile.sys"; + std::string ndsBootstrapPath = fsManager().resolveSystemPath("/_nds/nds-bootstrap-release.nds"); + std::string ndsBootstrapPathNightly = fsManager().resolveSystemPath("/_nds/nds-bootstrap-nightly.nds"); + std::string ndsHbBootstrapPath = fsManager().resolveSystemPath("/_nds/nds-bootstrap-hb-release.nds"); + std::string ndsBootstrapCheck = fsManager().resolveSystemPath("/_nds/pagefile.sys"); bool useNightly = false; bool hbStrap = hb; //check if rom is homebrew if(hbStrap){ mRomPath = romPath; - if(access(ndsHbBootstrapPath, F_OK) != 0){ + if(access(ndsHbBootstrapPath.c_str(), F_OK) != 0){ progressWnd().hide(); printLoaderNotFound(ndsHbBootstrapPath); return false; @@ -252,7 +244,7 @@ bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath, } //has the user used nds-bootstrap before? - if(access(ndsBootstrapCheck, F_OK) != 0){ + if(access(ndsBootstrapCheck.c_str(), F_OK) != 0){ akui::messageBox(NULL, LANG("nds bootstrap", "firsttimetitle"), LANG("nds bootstrap", "firsttime"), MB_OK); } @@ -271,7 +263,7 @@ bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath, //Check which nds-bootstrap version has been selected if(gs().nightly){ - if(access(ndsBootstrapPathNightly, F_OK) != 0){ + if(access(ndsBootstrapPathNightly.c_str(), F_OK) != 0){ progressWnd().hide(); printLoaderNotFound(ndsBootstrapPathNightly); return false; @@ -281,7 +273,7 @@ bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath, } } else{ - if(access(ndsBootstrapPath, F_OK) != 0){ + if(access(ndsBootstrapPath.c_str(), F_OK) != 0){ progressWnd().hide(); printLoaderNotFound(ndsBootstrapPath); return false; @@ -305,10 +297,10 @@ bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath, // Setup argv to launch nds-bootstrap if(!useNightly){ - argv.push_back(ndsBootstrapPath); + argv.push_back(ndsBootstrapPath.c_str()); } else{ - argv.push_back(ndsBootstrapPathNightly); + argv.push_back(ndsBootstrapPathNightly.c_str()); } progressWnd().setTipText("Initializing nds-bootstrap..."); diff --git a/arm9/source/launcher/Slot1Launcher.cpp b/arm9/source/launcher/Slot1Launcher.cpp index 557afc12..41cae3e2 100644 --- a/arm9/source/launcher/Slot1Launcher.cpp +++ b/arm9/source/launcher/Slot1Launcher.cpp @@ -14,19 +14,15 @@ bool Slot1Launcher::launchRom(std::string romPath, std::string savePath, u32 flags, u32 cheatOffset, u32 cheatSize, bool hb) { - #if defined(__DSIMODE__) && !defined(__DSPICO__) - const char slot1LoaderPath[] = "sd:/_nds/akmenunext/slot1launch.nds"; - #else - const char slot1LoaderPath[] = "fat:/_nds/akmenunext/slot1launch.nds"; - #endif + std::string slot1LoaderPath = fsManager().resolveSystemPath("/_nds/akmenunext/slot1launch.nds"); - if (access(slot1LoaderPath, F_OK) != 0) { + if (access(slot1LoaderPath.c_str(), F_OK) != 0) { printLoaderNotFound(slot1LoaderPath); return false; } std::vector argv; - argv.push_back(slot1LoaderPath); + argv.push_back(slot1LoaderPath.c_str()); eRunNdsRetCode rc = runNdsFile(argv[0], argv.size(), &argv[0]); if (rc == RUN_NDS_OK) return true; diff --git a/arm9/source/launcher/TopToyLauncher.cpp b/arm9/source/launcher/TopToyLauncher.cpp index c8d9d0c6..dde9c37d 100644 --- a/arm9/source/launcher/TopToyLauncher.cpp +++ b/arm9/source/launcher/TopToyLauncher.cpp @@ -60,7 +60,7 @@ bool TopToyLauncher::prepareCheats() { u32 gameCode, crc32; if (cCheatWnd::romData(mRomPath, gameCode, crc32)) { - FILE* cheatDb = fopen(SFN_CHEATS, "rb"); + FILE* cheatDb = fopen((SFN_CHEATS).c_str(), "rb"); if (!cheatDb) goto cheat_failed; long cheatOffset; size_t cheatSize; diff --git a/arm9/source/launcher/nds_loader_arm9.c b/arm9/source/launcher/nds_loader_arm9.c index 3111edb5..9b9cc52c 100644 --- a/arm9/source/launcher/nds_loader_arm9.c +++ b/arm9/source/launcher/nds_loader_arm9.c @@ -283,11 +283,10 @@ eRunNdsRetCode runNds (const void* loader, u32 loaderSize, u32 cluster, bool ini VRAM_C_CR = VRAM_ENABLE | VRAM_C_LCD; //Fix VRAM because for some reason some homebrew screws up without it - #ifdef __DSIMODE__ - //do nothing because this breaks on DSi/3DS mode - #else + //breaks on DSi/3DS mode + if (!isDSiMode()){ memset (LCDC_BANK_C, 0x00, 128 * 1024); - #endif + } // Load the loader/patcher into the correct address vramcpy (LCDC_BANK_C, loader, loaderSize); diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 87a1e1f5..6e2e5c4f 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -43,6 +43,7 @@ #include "romlauncher.h" #include "sram.h" #include "userwnd.h" +#include "fsmngr.h" using namespace akui; @@ -54,7 +55,7 @@ void __libnds_exit(int rc) {} } #endif -int main(void) { +int main(int argc, char* argv[]) { irq().init(); windowManager(); @@ -80,14 +81,8 @@ int main(void) { // wait_press_b(); // init fat -#ifdef __DSPICO__ - fatMountSimple("fat", dldiGetInternal()); - chdir("fat:/"); -#else - bool succ = fatInitDefault(); - if (!succ) dbg_printf("init fat %d\n", succ); -#endif - + fsManager().init(argc, argv); + // wait_press_b(); // setting scripts diff --git a/arm9/source/mainlist.cpp b/arm9/source/mainlist.cpp index c670ef92..f524dff2 100644 --- a/arm9/source/mainlist.cpp +++ b/arm9/source/mainlist.cpp @@ -28,32 +28,58 @@ #include "unicode.h" #include "unknown_banner_bin.h" #include "windowmanager.h" +#include "fsmngr.h" using namespace akui; cMainList::cMainList(s32 x, s32 y, u32 w, u32 h, cWindow* parent, const std::string& text) : cListView(x, y, w, h, parent, text), _showAllFiles(false), - _topCount(3), + _topCount(5), _topuSD(0), - _topSlot2(1), - _topFavorites(2) { + _topuDSiSD(1), + _topFavorites(2), + _topSlot1(3), + _topSlot2(4) { _viewMode = VM_LIST; _activeIconScale = 1; _activeIcon.hide(); _activeIcon.update(); animationManager().addAnimation(&_activeIcon); dbg_printf("_activeIcon.init\n"); - fifoSendValue32(FIFO_USER_01, MENU_MSG_SYSTEM); - while (!fifoCheckValue32(FIFO_USER_02)) - ; - u32 system = fifoGetValue32(FIFO_USER_02); - if (2 == system) // dsi - { + + if (!isDSiMode()) { _topCount = 3; - _topSlot2 = 3; - _topSlot1 = 2; + _topuSD = 0; _topFavorites = 1; + _topSlot2 = 2; + _topuDSiSD = 3; + _topSlot1 = 4; + } else { + if (fsManager().isFlashcart()) { + if (fsManager().isSDInserted()) { + _topCount = 3; + _topuSD = 0; + _topuDSiSD = 1; + _topFavorites = 2; + _topSlot2 = 3; + _topSlot1 = 4; + } else { + _topCount = 2; + _topuSD = 0; + _topFavorites = 1; + _topSlot2 = 2; + _topuDSiSD = 3; + _topSlot1 = 4; + } + } else { + _topCount = 3; + _topuDSiSD = 0; + _topFavorites = 1; + _topSlot1 = 2; + _topuSD = 3; + _topSlot2 = 4; + } } } @@ -110,16 +136,12 @@ static bool extnameFilter(const std::vector& extNames, std::string bool cMainList::enterDir(const std::string& dirName) { -#if defined(__DSIMODE__) && !defined(__DSPICO__) - const char* base = "sd:/_nds/akmenunext/icons/"; -#else - const char* base = "fat:/_nds/akmenunext/icons/"; -#endif + std::string base = fsManager().resolveSystemPath("/_nds/akmenunext/icons/"); - std::string microsd = std::string(base) + "microsd_banner.bin"; - std::string nand = std::string(base) + "nand_banner.bin"; - std::string gba = std::string(base) + "gba_banner.bin"; - std::string folder = std::string(base) + "folder_banner.bin"; + std::string microsd = base + "microsd_banner.bin"; + std::string nand = base + "nand_banner.bin"; + std::string gba = base + "gba_banner.bin"; + std::string folder = base + "folder_banner.bin"; _saves.clear(); if (memcmp(dirName.c_str(), "...", 3) == 0 || dirName.empty()) // select RPG or SD card @@ -133,7 +155,15 @@ bool cMainList::enterDir(const std::string& dirName) { if (_topuSD == i) { a_row.push_back(LANG("mainlist", "microsd card")); a_row.push_back(""); - a_row.push_back(SD_ROOT); + a_row.push_back("fat:/"); + if(gs().icon) + rominfo.setBannerFromFile("folder", microsd); + else + rominfo.setBanner("folder", microsd_banner_bin); + } else if (_topuDSiSD == i) { + a_row.push_back("DSi SD"); + a_row.push_back(""); + a_row.push_back("sd:/"); if(gs().icon) rominfo.setBannerFromFile("folder", microsd); else @@ -191,7 +221,7 @@ bool cMainList::enterDir(const std::string& dirName) { dir = opendir(dirName.c_str()); if (dir == NULL) { - if (SD_ROOT == dirName) { + if (fsManager().getFSRoot() == dirName) { std::string title = LANG("sd card error", "title"); std::string sdError = LANG("sd card error", "text"); messageBox(NULL, title, sdError, MB_OK); @@ -363,7 +393,7 @@ void cMainList::onScrolled(u32 index) { void cMainList::backParentDir() { if ("..." == _currentDir) return; - bool fat1 = (SD_ROOT == _currentDir), favorites = ("favorites:/" == _currentDir); + bool fat1 = (fsManager().getFSRoot() == _currentDir), favorites = ("favorites:/" == _currentDir); if ("fat:/" == _currentDir || "sd:/" == _currentDir || fat1 || favorites || "/" == _currentDir) { enterDir("..."); diff --git a/arm9/source/mainlist.h b/arm9/source/mainlist.h index d3e352dc..e605e904 100644 --- a/arm9/source/mainlist.h +++ b/arm9/source/mainlist.h @@ -17,12 +17,6 @@ #include "touchmessage.h" #include "zoomingicon.h" -#if defined(__DSIMODE__) && !defined(__DSPICO__) -#define SD_ROOT_0 "sd:" -#else -#define SD_ROOT_0 "fat:" -#endif -#define SD_ROOT SD_ROOT_0 "/" // 显示游戏列表,文件列表等等 class cMainList : public akui::cListView { @@ -120,9 +114,10 @@ class cMainList : public akui::cListView { protected: u32 _topCount; u32 _topuSD; + u32 _topuDSiSD; + u32 _topFavorites; u32 _topSlot1; u32 _topSlot2; - u32 _topFavorites; public: u32 Slot1(void) { return _topSlot1; } diff --git a/arm9/source/mainwnd.cpp b/arm9/source/mainwnd.cpp index 6b2d829f..2151a085 100644 --- a/arm9/source/mainwnd.cpp +++ b/arm9/source/mainwnd.cpp @@ -442,7 +442,7 @@ void cMainWnd::setParam(void) { // user interface style _values.clear(); std::vector uiNames; - DIR* dir = opendir(SFN_UI_DIRECTORY); + DIR* dir = opendir((SFN_UI_DIRECTORY).c_str()); struct dirent* entry; if (NULL != dir) { while ((entry = readdir(dir)) != NULL) { @@ -464,7 +464,7 @@ void cMainWnd::setParam(void) { // language _values.clear(); std::vector langNames; - dir = opendir(SFN_LANGUAGE_DIRECTORY); + dir = opendir((SFN_LANGUAGE_DIRECTORY).c_str()); if (NULL != dir) { while ((entry = readdir(dir)) != NULL) { std::string lfn(entry->d_name); @@ -574,19 +574,20 @@ void cMainWnd::setParam(void) { _values.push_back(LANG("override", "8")); settingWnd.addSettingItem(LANG("override", "text"), _values, gs().languageOverride); + if (isDSiMode()){ + _values.clear(); + _values.push_back(LANG("switches", "Disable")); + _values.push_back(LANG("switches", "Enable")); + settingWnd.addSettingItem(LANG("nds bootstrap", "phatCol"), _values, gs().phatCol); + } + + if (fsManager().isFlashcart()){ + _values.clear(); + _values.push_back("nds-bootstrap"); + _values.push_back("Pico-Loader"); + settingWnd.addSettingItem(LANG("nds bootstrap", "loader"), _values, gs().pico); + } -#ifdef __DSIMODE__ - _values.clear(); - _values.push_back(LANG("switches", "Disable")); - _values.push_back(LANG("switches", "Enable")); - settingWnd.addSettingItem(LANG("nds bootstrap", "phatCol"), _values, gs().phatCol); -#endif -#if !defined(__DSIMODE__) || defined(__DSPICO__) - _values.clear(); - _values.push_back("nds-bootstrap"); - _values.push_back("Pico-Loader"); - settingWnd.addSettingItem(LANG("nds bootstrap", "loader"), _values, gs().pico); -#endif #ifdef __KERNEL_LAUNCHER_SUPPORT__ _values.clear(); _values.push_back("Kernel"); @@ -605,12 +606,13 @@ void cMainWnd::setParam(void) { _values.push_back(LANG("gba settings", "modegba")); _values.push_back(LANG("gba settings", "modends")); settingWnd.addSettingItem(LANG("gba settings", "mode"), _values, gs().slot2mode); -#ifdef __DSIMODE__ - _values.clear(); - _values.push_back(LANG("patches", "default")); - _values.push_back(LANG("patches", "ndshb")); - settingWnd.addSettingItem(LANG("patches", "hbstrap"), _values, gs().hbStrap); -#endif + + if (isDSiMode()) { + _values.clear(); + _values.push_back(LANG("patches", "default")); + _values.push_back(LANG("patches", "ndshb")); + settingWnd.addSettingItem(LANG("patches", "hbstrap"), _values, gs().hbStrap); + } u32 ret = settingWnd.doModal(); if (ID_CANCEL == ret) return; @@ -647,22 +649,26 @@ void cMainWnd::setParam(void) { gs().dsOnly = settingWnd.getItemSelection(3, 0); gs().nightly = settingWnd.getItemSelection(3, 1); gs().languageOverride = settingWnd.getItemSelection(3,2); -#ifdef __DSIMODE__ - gs().phatCol = settingWnd.getItemSelection(3, 3); -#else - gs().pico = settingWnd.getItemSelection(3, 3); -#endif -#ifdef __DSPICO__ - gs().pico = settingWnd.getItemSelection(3, 4); -#endif + if (isDSiMode()) { + gs().phatCol = settingWnd.getItemSelection(3, 3); + + if (fsManager().isFlashcart()){ + gs().pico = settingWnd.getItemSelection(3, 4); + } + + }else if (fsManager().isFlashcart()) { + gs().pico = settingWnd.getItemSelection(3, 3); + } // page 5: other gs().cheats = settingWnd.getItemSelection(4, 0); gs().slot2mode = settingWnd.getItemSelection(4, 1); -#ifdef __DSIMODE__ - gs().hbStrap = settingWnd.getItemSelection(4, 2); -#endif + + if (isDSiMode()){ + gs().hbStrap = settingWnd.getItemSelection(4, 2); + } + if (uiIndex != uiIndexAfter) { u32 ret = messageBox(this, LANG("ui style changed", "title"), @@ -671,11 +677,9 @@ void cMainWnd::setParam(void) { gs().uiName = uiNames[uiIndexAfter]; gs().langDirectory = langNames[langIndexAfter]; gs().saveSettings(); - #if defined(__DSIMODE__) && !defined(__DSPICO__) - HomebrewLauncher().launchRom("sd:/_nds/akmenunext/launcher.nds", "", 0, 0, 0, 0); - #else - HomebrewLauncher().launchRom("fat:/_nds/akmenunext/launcher.nds", "", 0, 0, 0, 0); - #endif + + std::string launcherPath = fsManager().resolveSystemPath("/_nds/akmenunext/launcher.nds"); + HomebrewLauncher().launchRom(launcherPath, "", 0, 0, 0, 0); } } @@ -685,11 +689,9 @@ void cMainWnd::setParam(void) { if (ID_YES == ret) { gs().langDirectory = langNames[langIndexAfter]; gs().saveSettings(); - #if defined(__DSIMODE__) && !defined(__DSPICO__) - HomebrewLauncher().launchRom("sd:/_nds/akmenunext/launcher.nds", "", 0, 0, 0, 0); - #else - HomebrewLauncher().launchRom("fat:/_nds/akmenunext/launcher.nds", "", 0, 0, 0, 0); - #endif + + std::string launcherPath = fsManager().resolveSystemPath("/_nds/akmenunext/launcher.nds"); + HomebrewLauncher().launchRom(launcherPath, "", 0, 0, 0, 0); } } diff --git a/arm9/source/romlauncher.cpp b/arm9/source/romlauncher.cpp index ece02243..15ce3a02 100644 --- a/arm9/source/romlauncher.cpp +++ b/arm9/source/romlauncher.cpp @@ -232,7 +232,7 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool if (aRomInfo.saveInfo().isCheat()) { u32 gameCode, crc32; if (cCheatWnd::romData(aFullPath, gameCode, crc32)) { - FILE* dat = fopen(SFN_CHEATS, "rb"); + FILE* dat = fopen((SFN_CHEATS).c_str(), "rb"); if (dat) { if (cCheatWnd::searchCheatData(dat, gameCode, crc32, cheatOffset, cheatSize)) { flags |= PATCH_CHEATS; @@ -246,7 +246,7 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool u8 language = aRomInfo.saveInfo().getLanguage(); if (language) flags |= (language << PATCH_LANGUAGE_SHIFT) & PATCH_LANGUAGE_MASK; #ifndef __KERNEL_LAUNCHER_SUPPORT__ - if(gs().pico){ + if(gs().pico && aFullPath[0] != 's'){ //roms can only be launched from the sd with nds-bootstrap launcher = new DSpicoLauncher(); } else { diff --git a/arm9/source/systemfilenames.h b/arm9/source/systemfilenames.h index 23a3e665..12b6a34c 100644 --- a/arm9/source/systemfilenames.h +++ b/arm9/source/systemfilenames.h @@ -8,22 +8,19 @@ */ #pragma once - -#if defined(__DSIMODE__) && !defined(__DSPICO__) -#define SFN_SYSTEM_DIR "sd:/_nds/akmenunext/" -#else -#define SFN_SYSTEM_DIR "fat:/_nds/akmenunext/" -#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" -#define SFN_LAST_GBA_SAVEINFO SFN_SYSTEM_DIR "lastgba.ini" -#define SFN_SDCARD_LIST SFN_SYSTEM_DIR "sdlist.ini" -#define SFN_GLOBAL_SETTINGS SFN_SYSTEM_DIR "globalsettings.ini" -#define SFN_FAVORITES SFN_SYSTEM_DIR "favorites.ini" -#define SFN_BACKLIGHT SFN_SYSTEM_DIR "backlight.ini" - -#define SFN_UI_DIRECTORY SFN_SYSTEM_DIR "ui/" +#include "fsmngr.h" + +#define SFN_SYSTEM_DIR fsManager().resolveSystemPath("_nds/akmenunext/") +#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" +#define SFN_LAST_GBA_SAVEINFO SFN_SYSTEM_DIR + "lastgba.ini" +#define SFN_SDCARD_LIST SFN_SYSTEM_DIR + "sdlist.ini" +#define SFN_GLOBAL_SETTINGS SFN_SYSTEM_DIR + "globalsettings.ini" +#define SFN_FAVORITES SFN_SYSTEM_DIR + "favorites.ini" +#define SFN_BACKLIGHT SFN_SYSTEM_DIR + "backlight.ini" + +#define SFN_UI_DIRECTORY SFN_SYSTEM_DIR + "ui/" #define SFN_UI_CURRENT_DIRECTORY SFN_UI_DIRECTORY + gs().uiName + "/" #define SFN_USER_CUSTOM SFN_UI_DIRECTORY + gs().uiName + "/custom.ini" #define SFN_UI_SETTINGS SFN_UI_DIRECTORY + gs().uiName + "/uisettings.ini" @@ -50,12 +47,12 @@ #define SFN_GBAFRAME SFN_UI_DIRECTORY + gs().uiName + "/gbaframe.bmp" #define SFN_UI_ICONS_DIRECTORY SFN_UI_DIRECTORY + gs().uiName + "/icons/" -#define SFN_LANGUAGE_DIRECTORY SFN_SYSTEM_DIR "language/" +#define SFN_LANGUAGE_DIRECTORY SFN_SYSTEM_DIR + "language/" #define SFN_LANGUAGE_TEXT SFN_LANGUAGE_DIRECTORY + gs().langDirectory + "/language.txt" -#define SFN_FONTS_DIRECTORY SFN_SYSTEM_DIR "fonts/" +#define SFN_FONTS_DIRECTORY SFN_SYSTEM_DIR + "fonts/" #define SFN_DEFAULT_FONT "liberation.pcf" -#define SFN_ICONS_DIRECTORY SFN_SYSTEM_DIR "icons/" +#define SFN_ICONS_DIRECTORY SFN_SYSTEM_DIR + "icons/" -#define SFN_CHEATS SFN_SYSTEM_DIR "cheats/usrcheat.dat" +#define SFN_CHEATS SFN_SYSTEM_DIR + "cheats/usrcheat.dat" diff --git a/arm9_dsi/Makefile b/arm9_dsi/Makefile deleted file mode 100644 index 4e6b62a6..00000000 --- a/arm9_dsi/Makefile +++ /dev/null @@ -1,142 +0,0 @@ -#--------------------------------------------------------------------------------- -.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\ - -Wno-address-of-packed-member \ - $(ARCH) $(INCLUDE) -DARM9 - -CFLAGS += -D_NO_BOOTSTUB_ -D__DSIMODE__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) $(INCLUDE) -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/arm9_dsi_pico/Makefile b/arm9_dsi_pico/Makefile deleted file mode 100644 index 014a6f2c..00000000 --- a/arm9_dsi_pico/Makefile +++ /dev/null @@ -1,142 +0,0 @@ -#--------------------------------------------------------------------------------- -.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\ - -Wno-address-of-packed-member \ - $(ARCH) $(INCLUDE) -DARM9 - -CFLAGS += -D_NO_BOOTSTUB_ -D__DSIMODE__ -D__DSPICO__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -ASFLAGS := -g $(ARCH) $(INCLUDE) -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/package/package.cmd b/package/package.cmd index c99e2b56..6cbfb23b 100644 --- a/package/package.cmd +++ b/package/package.cmd @@ -5,43 +5,35 @@ mkdir flashcart cp -r _pico flashcart cp -r Autoboot flashcart cp -r _nds flashcart -cp boot_nds.nds flashcart\boot.nds -mv flashcart\_nds\akmenunext\launcher_nds.nds flashcart\_nds\akmenunext\launcher.nds -rm flashcart\_nds\akmenunext\launcher_dsi.nds -rm flashcart\_nds\akmenunext\launcher_pico.nds +cp boot.nds flashcart\boot.nds +cp boot.nds flashcart\_nds\akmenunext\launcher.nds "C:\Program Files\7-Zip\7z.exe" -tzip a -r akmenu-next-flashcart.zip ./flashcart/* :PICO mkdir pico cp -r _pico pico cp -r _nds pico -cp boot_pico.nds pico\boot.nds -cp boot_pico.nds pico\_picoboot.nds -mv pico\_nds\akmenunext\launcher_pico.nds pico\_nds\akmenunext\launcher.nds -rm pico\_nds\akmenunext\launcher_dsi.nds -rm pico\_nds\akmenunext\launcher_nds.nds +cp boot.dsi pico\boot.nds +cp boot.dsi pico\_picoboot.nds +cp boot.dsi pico\_nds\akmenunext\launcher.nds "C:\Program Files\7-Zip\7z.exe" -tzip a -r akmenu-next-pico.zip ./pico/* :DSI mkdir dsi cp -r _nds dsi cp -r title dsi -cp boot_dsi.nds dsi\boot.nds -cp boot_dsi.nds dsi\akmenu-next.dsi -mv dsi\_nds\akmenunext\launcher_dsi.nds dsi\_nds\akmenunext\launcher.nds -rm dsi\_nds\akmenunext\launcher_nds.nds -rm dsi\_nds\akmenunext\launcher_pico.nds +cp boot.dsi dsi\boot.nds +cp boot.dsi dsi\akmenu-next.dsi +cp boot.dsi dsi\_nds\akmenunext\launcher.nds rm dsi\_nds\akmenunext\PassMeLoader.nds "C:\Program Files\7-Zip\7z.exe" -tzip a -r akmenu-next-dsi.zip ./dsi/* :3DS mkdir 3ds cp -r _nds 3ds -cp boot_dsi.nds 3ds\boot.nds +cp boot.dsi 3ds\boot.nds cp akmenu-next.cia 3ds\akmenu-next.cia -mv 3ds\_nds\akmenunext\launcher_dsi.nds 3ds\_nds\akmenunext\launcher.nds -rm 3ds\_nds\akmenunext\launcher_nds.nds -rm 3ds\_nds\akmenunext\launcher_pico.nds +cp boot.dsi 3ds\_nds\akmenunext\launcher.nds rm 3ds\_nds\akmenunext\PassMeLoader.nds "C:\Program Files\7-Zip\7z.exe" -tzip a -r akmenu-next-3ds.zip ./3ds/* diff --git a/package/package.sh b/package/package.sh index b67216bd..785ab7b2 100755 --- a/package/package.sh +++ b/package/package.sh @@ -6,10 +6,8 @@ mkdir -p flashcart cp -r Autoboot flashcart cp -r _nds flashcart cp -r _pico flashcart -cp boot_nds.nds flashcart/boot.nds -mv flashcart/_nds/akmenunext/launcher_nds.nds flashcart/_nds/akmenunext/launcher.nds -rm -f flashcart/_nds/akmenunext/launcher_dsi.nds -rm -f flashcart/_nds/akmenunext/launcher_pico.nds +cp boot.nds flashcart/boot.nds +cp boot.nds flashcart/_nds/akmenunext/launcher.nds cd flashcart zip -r ../akmenu-next-flashcart.zip * cd .. @@ -18,11 +16,9 @@ cd .. mkdir -p pico cp -r _pico pico cp -r _nds pico -cp boot_pico.nds pico/boot.nds -cp boot_pico.nds pico/_picoboot.nds -mv pico/_nds/akmenunext/launcher_pico.nds pico/_nds/akmenunext/launcher.nds -rm -f pico/_nds/akmenunext/launcher_dsi.nds -rm -f pico/_nds/akmenunext/launcher_nds.nds +cp boot.dsi pico/boot.nds +cp boot.dsi pico/_picoboot.nds +cp boot.dsi pico/_nds/akmenunext/launcher.nds cd pico zip -r ../akmenu-next-pico.zip * cd .. @@ -31,11 +27,9 @@ cd .. mkdir -p dsi cp -r _nds dsi cp -r title dsi -cp boot_dsi.nds dsi/boot.nds -cp boot_dsi.nds dsi/akmenu-next.dsi -mv dsi/_nds/akmenunext/launcher_dsi.nds dsi/_nds/akmenunext/launcher.nds -rm -f dsi/_nds/akmenunext/launcher_nds.nds -rm -f dsi/_nds/akmenunext/launcher_pico.nds +cp boot.dsi dsi/boot.nds +cp boot.dsi dsi/akmenu-next.dsi +cp boot.dsi dsi/_nds/akmenunext/launcher.nds rm -f dsi/_nds/akmenunext/PassMeLoader.nds cd dsi zip -r ../akmenu-next-dsi.zip * @@ -44,11 +38,9 @@ cd .. #3DS mkdir -p 3ds cp -r _nds 3ds -cp boot_dsi.nds 3ds/boot.nds +cp boot.dsi 3ds/boot.nds cp akmenu-next.cia 3ds/akmenu-next.cia -mv 3ds/_nds/akmenunext/launcher_dsi.nds 3ds/_nds/akmenunext/launcher.nds -rm -f 3ds/_nds/akmenunext/launcher_nds.nds -rm -f 3ds/_nds/akmenunext/launcher_pico.nds +cp boot.dsi 3ds/_nds/akmenunext/launcher.nds rm -f 3ds/_nds/akmenunext/PassMeLoader.nds cd 3ds zip -r ../akmenu-next-3ds.zip * diff --git a/share/fifotool.h b/share/fifotool.h index f8fec994..36f991cf 100644 --- a/share/fifotool.h +++ b/share/fifotool.h @@ -20,3 +20,4 @@ #define MENU_MSG_SHUTDOWN 12 #define MENU_MSG_ARM7_REBOOT_TT 13 #define MENU_MSG_ARM7_REBOOT_PICOLOADER 14 +#define MENU_MSG_IS_SD_INSERTED 15