From 048f0c292ecb853b6d4a55735006cba2573dbc21 Mon Sep 17 00:00:00 2001 From: riccardom Date: Sun, 2 Oct 2011 11:27:29 +0000 Subject: [PATCH] firmware: Move firmware.dfc to Battery directory, #3349229 There currently is no official place for the firmware.dfc file. The current behavior is to save the .dfc in the same directory as the executable. Per zeromus' suggestion, the .dfc will now be saved in the Battery directory. This will be true for all ports that support DeSmuME's directory structure. Patch from rogerman. --- desmume/src/firmware.cpp | 15 +++++++++++++-- desmume/src/firmware.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/desmume/src/firmware.cpp b/desmume/src/firmware.cpp index f306f29f9..b0dda1aa2 100644 --- a/desmume/src/firmware.cpp +++ b/desmume/src/firmware.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 DeSmuME Team +/* Copyright (C) 2009-2011 DeSmuME Team This file is part of DeSmuME @@ -566,7 +566,9 @@ bool CFIRMWARE::load() INFO(" * ARM7 unpacked size: 0x%08X (%i) bytes\n", size7, size7); } - snprintf(MMU.fw.userfile, MAX_PATH, "%sFirmware%cfirmware.dfc", path.pathToModule, DIRECTORY_DELIMITER_CHAR); + // Generate the path for the external firmware config file. + std::string extFilePath = CFIRMWARE::GetExternalFilePath(); + strncpy(MMU.fw.userfile, extFilePath.c_str(), MAX_PATH); fclose(fp); fp = fopen(MMU.fw.userfile, "rb"); @@ -607,6 +609,15 @@ bool CFIRMWARE::load() return true; } +std::string CFIRMWARE::GetExternalFilePath() +{ + std::string fwPath = CommonSettings.Firmware; + std::string fwFileName = Path::GetFileNameFromPathWithoutExt(fwPath); + std::string configPath = path.pathToBattery; + std::string finalPath = configPath + DIRECTORY_DELIMITER_CHAR + fwFileName + FILE_EXT_DELIMITER_CHAR + FW_CONFIG_FILE_EXT; + + return finalPath; +} //===================================================================================================== static u32 diff --git a/desmume/src/firmware.h b/desmume/src/firmware.h index 2a4888544..5342bc3a1 100644 --- a/desmume/src/firmware.h +++ b/desmume/src/firmware.h @@ -24,6 +24,8 @@ // the count of bytes copied from the firmware into memory #define NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT 0x70 +#define FW_CONFIG_FILE_EXT "dfc" + class CFIRMWARE { private: @@ -48,6 +50,8 @@ public: bool load(); + static std::string GetExternalFilePath(); + struct HEADER { u16 part3_rom_gui9_addr; // 000h