Start DSiWare Support

- Added DSiWare detection
- Start INI Work for DSiWare. PUB and PRV save creation not added yet.
- Only modify VRAM if running on a flashcart (resolved Giana Sisters DS regression)
- Remove Card DMA configuration to align with nds-bootstrap removing it as a configurable value
- Show a message to the user if using akmenu-next for the first time
This commit is contained in:
Kei 2025-02-28 19:34:12 +00:00
parent 935497e4a0
commit 3d3ca0abf7
10 changed files with 68 additions and 22 deletions

View File

@ -53,6 +53,8 @@
"format": "cpp",
"span": "cpp",
"text_encoding": "cpp",
"variant": "cpp"
"variant": "cpp",
"nds.h": "c",
"maxmod9.h": "c"
}
}

View File

@ -47,6 +47,10 @@ bool DSRomInfo::loadDSRomInfo(const std::string& filename, bool loadBanner) {
return false;
}
if (header.unitCode == 0x03) {
_isDSiWare = ETrue;
}
///////// ROM Header /////////
u16 crc = swiCRC16(0xFFFF, &header, 0x15E);
if (crc != header.headerCRC16) // 锟侥硷拷头 CRC 锟斤拷锟襟诧拷锟斤拷nds锟斤拷戏
@ -204,6 +208,7 @@ bool DSRomInfo::loadGbaRomInfo(const std::string& filename) {
void DSRomInfo::load(void) {
if (_isDSRom == EMayBe) loadDSRomInfo(_fileName, true);
if (_isGbaRom == EMayBe) loadGbaRomInfo(_fileName);
if (_isDSiWare == EMayBe) loadDSRomInfo(_fileName, true);
}
tNDSBanner& DSRomInfo::banner(void) {
@ -226,6 +231,11 @@ bool DSRomInfo::isDSRom(void) {
return (_isDSRom == ETrue) ? true : false;
}
bool DSRomInfo::isDSiWare(void) {
load();
return (_isDSiWare == ETrue) ? true : false;
}
bool DSRomInfo::isHomebrew(void) {
load();
return (_isHomebrew == ETrue) ? true : false;

View File

@ -22,6 +22,7 @@ class DSRomInfo {
tNDSBanner _banner;
SAVE_INFO_EX _saveInfo;
TBool _isDSRom;
TBool _isDSiWare;
TBool _isHomebrew;
TBool _isGbaRom;
std::string _fileName;
@ -35,7 +36,7 @@ class DSRomInfo {
public:
DSRomInfo()
: _isDSRom(EFalse), _isHomebrew(EFalse), _isGbaRom(EFalse), _extIcon(-1), _romVersion(0) {
: _isDSRom(EFalse), _isDSiWare(EFalse), _isHomebrew(EFalse), _isGbaRom(EFalse), _extIcon(-1), _romVersion(0) {
// memcpy(&_banner,unknown_banner_bin,unknown_banner_bin_size);
memset(&_banner, 0, sizeof(_banner));
memset(&_saveInfo, 0, sizeof(_saveInfo));
@ -50,12 +51,14 @@ class DSRomInfo {
void setExtIcon(const std::string& aValue);
inline bool isExtIcon(void) { return _extIcon >= 0; };
bool isDSRom(void);
bool isDSiWare(void);
bool isHomebrew(void);
bool isGbaRom(void);
DSRomInfo& operator=(const DSRomInfo& src);
void MayBeDSRom(const std::string& filename) {
_isDSRom = EMayBe;
_isHomebrew = EMayBe;
_isDSiWare = EMayBe;
_fileName = filename;
};
void MayBeGbaRom(const std::string& filename) {

View File

@ -40,7 +40,6 @@ cGlobalSettings::cGlobalSettings() {
saveExt = true;
saveDir = false;
nightly = false;
cardDma = true;
safeMode = false;
show12hrClock = false;
autorunWithLastRom = false;
@ -72,7 +71,6 @@ void cGlobalSettings::loadSettings() {
saveDir = ini.GetInt("system", "savedir", saveDir);
nightly = ini.GetInt("system", "nightly", nightly);
dma = ini.GetInt("system", "dma", dma);
cardDma = ini.GetInt("system", "carddma", cardDma);
sdsave = ini.GetInt("system", "sdsave", sdsave);
safeMode = ini.GetInt("system", "safemode", safeMode);
show12hrClock = ini.GetInt("system", "Show12hrClock", show12hrClock);
@ -121,7 +119,6 @@ void cGlobalSettings::saveSettings() {
ini.SetInt("system", "cheats", cheats);
ini.SetInt("system", "softreset", softreset);
ini.SetInt("system", "dma", dma);
ini.SetInt("system", "carddma", cardDma);
ini.SetInt("system", "sdsave", sdsave);
ini.SetInt("system", "safemode", safeMode);
ini.SetInt("system", "savedir", saveDir);

View File

@ -53,7 +53,6 @@ class cGlobalSettings {
bool Animation;
bool cheats;
bool softreset;
bool cardDma;
bool sdsave;
bool cheatDB;
int slot2mode;

View File

@ -10,6 +10,7 @@
#include <cstring>
#include <string>
#include <vector>
#include <fat.h>
#include <nds/ndstypes.h>
@ -25,6 +26,7 @@
#include "ILauncher.h"
#include "NdsBootstrapLauncher.h"
#include "nds_loader_arm9.h"
#include "fat_ext.h"
bool NdsBootstrapLauncher::prepareCheats() {
u32 gameCode, crc32;
@ -67,16 +69,34 @@ cheat_failed:
bool NdsBootstrapLauncher::prepareIni() {
CIniFile ini;
tDSiHeader header;
char sfnSrl[62];
char sfnPub[62];
char sfnPrv[62];
_romInfo.MayBeDSRom(mRomPath);
bool dsiWare = _romInfo.isDSiWare();
ini.SetString("NDS-BOOTSTRAP", "NDS_PATH", mRomPath);
ini.SetString("NDS-BOOTSTRAP", "SAV_PATH", mSavePath);
if(gs().cardDma){
ini.SetInt("NDS-BOOTSTRAP", "CARD_READ_DMA", 1);
// check for DSiWare
if(dsiWare){
//TODO create pub & prv savwe
#ifdef __DSIMODE__
fatGetAliasPath("sd:/", mRomPath, sfnSrl);
fatGetAliasPath("sd:/", pubPath, sfnPub);
fatGetAliasPath("sd:/", prvPath, sfnPrv);
ini.SetString("NDS-BOOTSTRAP", "APP_PATH", sfnSrl);
ini.SetString("NDS-BOOTSTRAP", "SAV_PATH", sfnPub);
ini.SetString("NDS-BOOTSTRAP", "PRV_PATH", sfnPrv);
#else
//TODO flashcart
#endif
}
else{
ini.SetInt("NDS-BOOTSTRAP", "CARD_READ_DMA", 0);
ini.SetString("NDS-BOOTSTRAP", "SAV_PATH", mSavePath);
}
ini.SaveIniFile("/_nds/nds-bootstrap.ini");
return true;
}
@ -84,7 +104,14 @@ bool NdsBootstrapLauncher::launchRom(std::string romPath, std::string savePath,
u32 cheatOffset, u32 cheatSize) {
const char ndsBootstrapPath[] = SD_ROOT_0 "/_nds/nds-bootstrap-release.nds";
const char ndsBootstrapPathNightly[] = SD_ROOT_0 "/_nds/nds-bootstrap-nightly.nds";
const char ndsBootstrapCheck[] = SD_ROOT_0 "/_nds/pagefile.sys";
bool useNightly = false;
//has the user used nds-bootstrap before?
if(access(ndsBootstrapCheck, F_OK) != 0){
akui::messageBox(NULL, LANG("nds bootstrap", "firsttimetitle"), LANG("nds bootstrap", "firsttime"), MB_OK);
}
progressWnd().setTipText("Initializing nds-bootstrap...");
progressWnd().show();
progressWnd().setPercent(0);

View File

@ -22,4 +22,5 @@ class NdsBootstrapLauncher : public ILauncher {
std::string mRomPath;
std::string mSavePath;
u32 mFlags;
DSRomInfo _romInfo;
};

View File

@ -281,8 +281,14 @@ eRunNdsRetCode runNds (const void* loader, u32 loaderSize, u32 cluster, bool ini
// Direct CPU access to VRAM bank C
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
memset (LCDC_BANK_C, 0x00, 128 * 1024);
#endif
// Load the loader/patcher into the correct address
vramcpy (LCDC_BANK_C, loader, loaderSize);

View File

@ -550,10 +550,6 @@ void cMainWnd::setParam(void) {
_values.push_back(LANG("switches", "Disable"));
_values.push_back(LANG("switches", "Enable"));
settingWnd.addSettingItem(LANG("patches", "cheating system"), _values, gs().cheats);
_values.clear();
_values.push_back(LANG("switches", "Disable"));
_values.push_back(LANG("switches", "Enable"));
settingWnd.addSettingItem(LANG("patches", "carddma"), _values, gs().cardDma);
#ifdef __KERNEL_LAUNCHER_SUPPORT__
_values.clear();
_values.push_back("Kernel");
@ -607,9 +603,8 @@ void cMainWnd::setParam(void) {
// page 4: patches
gs().cheats = settingWnd.getItemSelection(3, 0);
gs().cardDma = settingWnd.getItemSelection(3, 1);
gs().softreset = settingWnd.getItemSelection(3, 2);
gs().homebrewreset = settingWnd.getItemSelection(3, 3);
gs().softreset = settingWnd.getItemSelection(3, 1);
gs().homebrewreset = settingWnd.getItemSelection(3, 2);
// page 5: gba
gs().gbaSleepHack = settingWnd.getItemSelection(4, 0);

View File

@ -140,12 +140,15 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool
std::string saveName;
std::string useSavesPath;
ILauncher* launcher = nullptr;
bool isDsiWare;
if (!aRomInfo.isHomebrew()) {
u32 gameCode;
memcpy(&gameCode, aRomInfo.saveInfo().gameCode, sizeof(gameCode)); // because alignment
bool isBigSave = false;
u32 bigSaveSize = 8 * 1024 * 1024;
u32 bigSaveMask = 14;
// check for DSiWare
isDsiWare = aRomInfo.isDSiWare();
// reading speed setting
std::string disk = aFullPath.substr(0, 5);
// bool dma = false, protection = aRomInfo.saveInfo().isProtection();
@ -209,6 +212,7 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool
saveManager().updateCustomSaveList(aRomInfo.saveInfo());
}
}
if(!isDsiWare){
if (cSaveManager::initializeSaveFile(useSavesPath, aRomInfo.saveInfo().getSlot(),
SaveSize(st))) {
flags |= PATCH_SD_SAVE | (SaveMask(st) << PATCH_SAVE_SHIFT);
@ -217,6 +221,8 @@ TLaunchResult launchRom(const std::string& aFullPath, DSRomInfo& aRomInfo, bool
return ELaunchNoFreeSpace;
}
}
}
__NDSHeader->cardControl13 = 0x00406000 | speed;
// 3in1 support