mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 05:44:11 +08:00
处理boot.firm不存在的问题
This commit is contained in:
parent
edf7a4898a
commit
decffac7e1
3
Makefile
3
Makefile
@ -82,5 +82,6 @@ endif
|
|||||||
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/gba_db.bin
|
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/gba_db.bin
|
||||||
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/wqy11.fnt
|
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/wqy11.fnt
|
||||||
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/gba.acl
|
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/gba.acl
|
||||||
|
@7z u -mx -m0=LZMA $(TARGET)$(VERS_STRING).7z resources/boot.firm
|
||||||
@7z u -mx -m0=PPMD $(TARGET)$(VERS_STRING).7z libn3ds/thirdparty/fatfs/LICENSE.txt thirdparty/inih/LICENSE.txt LICENSE.txt README.md
|
@7z u -mx -m0=PPMD $(TARGET)$(VERS_STRING).7z libn3ds/thirdparty/fatfs/LICENSE.txt thirdparty/inih/LICENSE.txt LICENSE.txt README.md
|
||||||
@7z rn $(TARGET)$(VERS_STRING).7z resources/gba_db.bin 3ds/open_agb_firm/gba_db.bin resources/wqy11.fnt 3ds/open_agb_firm/wqy11.fnt libn3ds/thirdparty/fatfs/LICENSE.txt LICENSE_fatfs.txt thirdparty/inih/LICENSE.txt LICENSE_inih.txt resources/gba.acl 3ds/open_agb_firm/gba.acl
|
@7z rn $(TARGET)$(VERS_STRING).7z resources/gba_db.bin 3ds/open_agb_firm/gba_db.bin resources/wqy11.fnt 3ds/open_agb_firm/wqy11.fnt libn3ds/thirdparty/fatfs/LICENSE.txt LICENSE_fatfs.txt thirdparty/inih/LICENSE.txt LICENSE_inih.txt resources/gba.acl 3ds/open_agb_firm/gba.acl resources/boot.firm 3ds/open_agb_firm/boot.firm
|
||||||
|
@ -67,5 +67,6 @@ Result oafInitAndRun( char * );
|
|||||||
void oafUpdate(void);
|
void oafUpdate(void);
|
||||||
void oafFinish(void);
|
void oafFinish(void);
|
||||||
Result oafPreboot( const char * );
|
Result oafPreboot( const char * );
|
||||||
|
bool oafRebootReady( void );
|
||||||
int oafCheatMode(void);
|
int oafCheatMode(void);
|
||||||
int oafHaltMode(void);
|
int oafHaltMode(void);
|
||||||
|
Binary file not shown.
@ -1094,6 +1094,41 @@ void oafFinish(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *autorun = "sdmc:/luma/payloads/autorun.luma";
|
static const char *autorun = "sdmc:/luma/payloads/autorun.luma";
|
||||||
|
|
||||||
|
static u32 luma_reboot_ctx = 0;
|
||||||
|
#define LUMA_REBOOT_READY 1
|
||||||
|
#define LUMA_REBOOT_LOCAL 2
|
||||||
|
#define LUMA_REBOOT_GLOBAL 4
|
||||||
|
static bool checkLumaFirm( const char *file )
|
||||||
|
{
|
||||||
|
FHandle h;
|
||||||
|
char text[64]; // 比length大就行
|
||||||
|
u32 readed;
|
||||||
|
u32 length = strlen( autorun );
|
||||||
|
Result res = fOpen(&h, file, FA_OPEN_EXISTING | FA_READ);
|
||||||
|
if( RES_OK != res ) return false;
|
||||||
|
|
||||||
|
res = fLseek(h, 0x3bd50); // 有疑问,就自己用16进制编辑器看这个地址
|
||||||
|
if( RES_OK != res )
|
||||||
|
{
|
||||||
|
fClose(h);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = fRead(h, text, length, &readed);
|
||||||
|
fClose(h);
|
||||||
|
|
||||||
|
if( RES_OK != res || readed != length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text[length] = '\0';
|
||||||
|
return 0 == strcmp(text, autorun);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void repairBootFirm( char *firm_path )
|
static void repairBootFirm( char *firm_path )
|
||||||
{
|
{
|
||||||
if( 0 == strcmp(firm_path, autorun) )
|
if( 0 == strcmp(firm_path, autorun) )
|
||||||
@ -1112,14 +1147,56 @@ static void repairBootFirm( char *firm_path )
|
|||||||
}
|
}
|
||||||
firm_path[0x3f] = '\0';
|
firm_path[0x3f] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 把Preboot存档的boot.firm恢复回去
|
||||||
|
char tmp[5];
|
||||||
|
if( RES_OK == fsQuickRead("luma.firm", tmp, 4) )
|
||||||
|
{
|
||||||
|
tmp[4] = '\0';
|
||||||
|
if( strcmp(tmp, "FIRM") == 0 ){
|
||||||
|
fRename("sdmc:/boot.firm", "sdmc:/3ds/open_agb_firm/boot.firm");
|
||||||
|
fRename("sdmc:/3ds/open_agb_firm/luma.firm", "sdmc:/boot.firm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查哪个boot.firm是支持autorun.luma文件的
|
||||||
|
if( checkLumaFirm("sdmc:/3ds/open_agb_firm/boot.firm") )
|
||||||
|
{
|
||||||
|
luma_reboot_ctx |= LUMA_REBOOT_LOCAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( checkLumaFirm( "sdmc:/boot.firm" ) )
|
||||||
|
{
|
||||||
|
luma_reboot_ctx |= LUMA_REBOOT_GLOBAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
luma_reboot_ctx |= LUMA_REBOOT_READY;
|
||||||
|
|
||||||
|
if( !oafRebootReady() )
|
||||||
|
g_oafConfig.haltMode = HALT_MODE_POWEROFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result oafPreboot( const char *firm_path )
|
Result oafPreboot( const char *firm_path )
|
||||||
{
|
{
|
||||||
// 记下来要恢复的文件名。加上\n是因为fsLoadPathFromFile靠它来识别路径结尾
|
// 记下来要恢复的文件名。加上\n是因为fsLoadPathFromFile靠它来识别路径结尾
|
||||||
char memo[0x50];
|
char memo[FIRMPATH_SIZELIMIT+0x10];
|
||||||
ee_snprintf(memo, 0x49, "%s\n", firm_path);
|
ee_snprintf(memo, FIRMPATH_SIZELIMIT+0xF, "%s\n", firm_path);
|
||||||
fsQuickWrite("autorun", memo, strlen(memo));
|
fsQuickWrite("autorun", memo, strlen(memo));
|
||||||
|
|
||||||
|
// 用户的boot.firm没有执行autorun.luma的功能。
|
||||||
|
// 这里要用改版的boot.firm替换用户原来的boot.firm,然后在repairBootFirm还原
|
||||||
|
if( 0 == (luma_reboot_ctx & LUMA_REBOOT_GLOBAL) ){
|
||||||
|
fRename("sdmc:/boot.firm", "sdmc:/3ds/open_agb_firm/luma.firm");
|
||||||
|
fRename("sdmc:/3ds/open_agb_firm/boot.firm", "sdmc:/boot.firm");
|
||||||
|
}
|
||||||
|
|
||||||
return fRename(firm_path, autorun);
|
return fRename(firm_path, autorun);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oafRebootReady( void )
|
||||||
|
{
|
||||||
|
return (luma_reboot_ctx & LUMA_REBOOT_READY)
|
||||||
|
&& ( (luma_reboot_ctx & LUMA_REBOOT_LOCAL)
|
||||||
|
|| (luma_reboot_ctx & LUMA_REBOOT_GLOBAL )
|
||||||
|
);
|
||||||
}
|
}
|
@ -182,6 +182,11 @@ static atp_pageopt_t config_adjust( atp_callerdata_t gblcfg, atp_counter_t index
|
|||||||
{
|
{
|
||||||
g_oafConfig->haltMode = ( HALT_MODE_SIZE + (g_oafConfig->haltMode+(l?-1:1) ) ) % HALT_MODE_SIZE;
|
g_oafConfig->haltMode = ( HALT_MODE_SIZE + (g_oafConfig->haltMode+(l?-1:1) ) ) % HALT_MODE_SIZE;
|
||||||
}
|
}
|
||||||
|
else if( !oafRebootReady() )
|
||||||
|
{
|
||||||
|
return ATP_POWER_OFF == atp_show(1, disp_str, "请正确放置boot.firm文件")
|
||||||
|
? ATP_POWER_OFF : ATP_PAGE_REFRESH;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ATP_POWER_OFF == atp_show(1, disp_str, "SD卡的open_agb_firm文件名太长")
|
return ATP_POWER_OFF == atp_show(1, disp_str, "SD卡的open_agb_firm文件名太长")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user