From 221795c70c77db443dade1dc1d0a47fe3a6ecf5f Mon Sep 17 00:00:00 2001 From: Deletecat Date: Wed, 8 Apr 2026 15:09:06 +0100 Subject: [PATCH 1/2] treewide: startup in favorites folder Closes #15 --- arm9/source/main.cpp | 13 +++++++++---- arm9/source/mainwnd.cpp | 2 +- arm9/source/romlauncher.cpp | 12 ++++++------ arm9/source/romlauncher.h | 4 ++-- arm9/source/savemngr.cpp | 5 +++-- arm9/source/savemngr.h | 2 +- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index db4e2ddf..2cc59ede 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -136,16 +136,21 @@ int main(int argc, char* argv[]) { irq().vblankStart(); // enter last directory - std::string lastDirectory = "...", lastFile = "..."; + std::string lastDirectory = "...", lastFile = "...", favorite = "no"; if (gs().enterLastDirWhenBoot || gs().autorunWithLastRom) { CIniFile f; if (f.LoadIniFile(SFN_LAST_SAVEINFO)) { lastFile = f.GetString("Save Info", "lastLoaded", ""); + favorite = f.GetString("Save Info", "favorite", "no"); if ("" == lastFile) { lastFile = "..."; } else if (gs().enterLastDirWhenBoot) { - size_t slashPos = lastFile.find_last_of('/'); - if (lastFile.npos != slashPos) lastDirectory = lastFile.substr(0, slashPos + 1); + if (favorite == "yes") { + lastDirectory = "favorites:/"; + } else { + size_t slashPos = lastFile.find_last_of('/'); + if (lastFile.npos != slashPos) lastDirectory = lastFile.substr(0, slashPos + 1); + } } } } @@ -201,7 +206,7 @@ int main(int argc, char* argv[]) { if (gs().autorunWithLastRom && "..." != lastFile) { INPUT& inputs = updateInput(); - if (!(inputs.keysHeld & KEY_B)) autoLaunchRom(lastFile); + if (!(inputs.keysHeld & KEY_B)) autoLaunchRom(lastFile, favorite); } while (true) { diff --git a/arm9/source/mainwnd.cpp b/arm9/source/mainwnd.cpp index 3210b77e..06f7b24b 100644 --- a/arm9/source/mainwnd.cpp +++ b/arm9/source/mainwnd.cpp @@ -414,7 +414,7 @@ void cMainWnd::launchSelected() { progressWnd().show(); progressWnd().setPercent(0); switch (launchRom(fullPath, rominfo, - rominfo.isHomebrew() && "BOOT.NDS" == _mainList->getSelectedShowName(), savesPath)) { + rominfo.isHomebrew() && "BOOT.NDS" == _mainList->getSelectedShowName(), savesPath, _mainList->IsFavorites() ? "yes" : "no")) { case ELaunchNoFreeSpace: title = LANG("no free space", "title"); text = LANG("no free space", "text"); diff --git a/arm9/source/romlauncher.cpp b/arm9/source/romlauncher.cpp index 8122f60f..c5c69275 100644 --- a/arm9/source/romlauncher.cpp +++ b/arm9/source/romlauncher.cpp @@ -132,7 +132,7 @@ static u32 SaveSize(SAVE_TYPE st) { return result; } -TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool aMenu, const std::string& savesPath) { +TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool aMenu, const std::string& savesPath, const std::string& favorite) { u32 flags = 0; long cheatOffset = 0; size_t cheatSize = 0; @@ -200,7 +200,7 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool bigSaveSize); if (!isBigSave) return ELaunchNoFreeSpace; flags |= PATCH_SD_SAVE | (bigSaveMask << PATCH_SAVE_SHIFT); - saveManager().saveLastInfo(aFullPath); + saveManager().saveLastInfo(aFullPath, favorite); } else { SAVE_TYPE st = (SAVE_TYPE)aRomInfo.saveInfo().saveType; if (ST_UNKNOWN == st) st = ST_AUTO; @@ -217,7 +217,7 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool if (cSaveManager::initializeSaveFile(useSavesPath, aRomInfo.saveInfo().getSlot(), SaveSize(st))) { flags |= PATCH_SD_SAVE | (SaveMask(st) << PATCH_SAVE_SHIFT); - saveManager().saveLastInfo(aFullPath); + saveManager().saveLastInfo(aFullPath, favorite); } else { return ELaunchNoFreeSpace; } @@ -255,7 +255,7 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool } } else { - if (!aMenu) saveManager().saveLastInfo(aFullPath); + if (!aMenu) saveManager().saveLastInfo(aFullPath, favorite); if (gs().hbStrap == 1) { hb = true; @@ -269,8 +269,8 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool return ELaunchRomOk; } -void autoLaunchRom(const std::string& aFullPath) { +void autoLaunchRom(const std::string& aFullPath, const std::string& favorite) { DSRomInfo rominfo; rominfo.MayBeDSRom(aFullPath); - if (rominfo.isDSRom()) launchRom(aFullPath, rominfo, false, ""); + if (rominfo.isDSRom()) launchRom(aFullPath, rominfo, false, "", favorite); } diff --git a/arm9/source/romlauncher.h b/arm9/source/romlauncher.h index d7ef438d..c6c64200 100644 --- a/arm9/source/romlauncher.h +++ b/arm9/source/romlauncher.h @@ -17,5 +17,5 @@ enum TLaunchResult { ELaunchNoFreeSpace }; -TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool aMenu, const std::string& savesPath); -void autoLaunchRom(const std::string& aFullPath); +TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool aMenu, const std::string& savesPath, const std::string& favorite); +void autoLaunchRom(const std::string& aFullPath, const std::string& favorite); diff --git a/arm9/source/savemngr.cpp b/arm9/source/savemngr.cpp index 8d2433b5..b2337f49 100644 --- a/arm9/source/savemngr.cpp +++ b/arm9/source/savemngr.cpp @@ -137,9 +137,10 @@ void cSaveManager::updateCustomSaveList(const SAVE_INFO_EX& aSaveInfo) { exportCustomSaveList(SFN_CUSTOM_SAVELIST); } -bool cSaveManager::saveLastInfo(const std::string& romFilename) { +bool cSaveManager::saveLastInfo(const std::string& romFilename, const std::string& favorite) { CIniFile f; f.SetString("Save Info", "lastLoaded", romFilename); + f.SetString("Save Info", "favorite", favorite); if (!f.SaveIniFile(SFN_LAST_SAVEINFO)) return false; return true; @@ -161,7 +162,7 @@ bool cSaveManager::loadLastInfo(std::string& lastLoadedFilename) { bool cSaveManager::clearLastInfo() { std::string loadLoadedFile; if (loadLastInfo(loadLoadedFile)) { - return saveLastInfo(""); + return saveLastInfo("",""); } return true; } diff --git a/arm9/source/savemngr.h b/arm9/source/savemngr.h index 733b8641..85022ab7 100644 --- a/arm9/source/savemngr.h +++ b/arm9/source/savemngr.h @@ -217,7 +217,7 @@ class cSaveManager { void updateCustomSaveList(const SAVE_INFO_EX& aSaveInfo); - bool saveLastInfo(const std::string& romFilename); + bool saveLastInfo(const std::string& romFilename, const std::string& favorite); bool loadLastInfo(std::string& lastLoadedFilename); From fa9857cccfb871cf2c5210de33c578b2a53723d2 Mon Sep 17 00:00:00 2001 From: Deletecat Date: Wed, 8 Apr 2026 16:59:21 +0100 Subject: [PATCH 2/2] mainlist, main: select last rom on startup --- arm9/source/main.cpp | 5 ++++- arm9/source/mainlist.cpp | 9 +++++++++ arm9/source/mainlist.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 2cc59ede..28579c4b 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -196,8 +196,11 @@ int main(int argc, char* argv[]) { } dbg_printf("lastDirectory '%s'\n", lastDirectory.c_str()); - if (!wnd->_mainList->enterDir("..." != lastDirectory ? lastDirectory : gs().startupFolder)) + if (!wnd->_mainList->enterDir("..." != lastDirectory ? lastDirectory : gs().startupFolder)) { wnd->_mainList->enterDir("..."); + } else { + wnd->_mainList->selectRom(lastFile); + } *(u32*)(0xCFFFD0C) = 0x454D4D43; while (*(u32*)(0xCFFFD0C) != 0) { diff --git a/arm9/source/mainlist.cpp b/arm9/source/mainlist.cpp index 59502aa6..be670975 100644 --- a/arm9/source/mainlist.cpp +++ b/arm9/source/mainlist.cpp @@ -444,6 +444,15 @@ void cMainList::setRomInfo(u32 rowIndex, const DSRomInfo& info) { } } +void cMainList::selectRom(const std::string& romPath){ + for(unsigned int row = 0; row < _rows.size(); row++){ + if(romPath == _rows[row][REALNAME_COLUMN].text()){ + selectRow(row); + break; + } + } +} + void cMainList::draw() { updateInternalNames(); cListView::draw(); diff --git a/arm9/source/mainlist.h b/arm9/source/mainlist.h index e605e904..837f904e 100644 --- a/arm9/source/mainlist.h +++ b/arm9/source/mainlist.h @@ -53,6 +53,8 @@ class cMainList : public akui::cListView { void setRomInfo(u32 rowIndex, const DSRomInfo& info); + void selectRom(const std::string& romPath); + void setViewMode(VIEW_MODE mode); std::string getSelectedFullPath();