Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/
Expand All @@ -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
11 changes: 11 additions & 0 deletions arm7/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions arm9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 :=

#---------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions arm9/source/cheatwnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cParsedItem>::iterator itr = _data.begin();
while (itr != _data.end()) {
Expand Down Expand Up @@ -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);
Expand Down
63 changes: 63 additions & 0 deletions arm9/source/fsmngr.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
30 changes: 30 additions & 0 deletions arm9/source/fsmngr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#include <nds.h>
#include <nds/arm9/dldi.h>
#include <fat.h>
#include <string>
#include <vector>
#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<cFSManager> FSManager_s;
inline cFSManager& fsManager() {
return FSManager_s::instance();
}
2 changes: 1 addition & 1 deletion arm9/source/globalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 3 additions & 7 deletions arm9/source/helpwnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions arm9/source/launcher/DSpicoLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading