From d06676bbff8807921f9d27a50a09d4ba1edb30a6 Mon Sep 17 00:00:00 2001 From: root <182859762@qq.com> Date: Wed, 24 Apr 2024 22:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8release=E5=8F=91=E5=B8=83=E5=B0=B1?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E4=BA=86=E5=BC=82=E5=B8=B8=E3=80=82=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E5=B7=B2=E8=A7=A3=E5=86=B3=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E7=9A=84=E6=A0=B8=E5=BF=83=E6=96=B9=E6=A1=88=E6=98=AFfread?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E8=A6=81=E5=A4=9A=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E4=B8=80=E7=82=B9=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/arm11/open_agb_firm.h | 2 +- source/arm11/main.c | 5 +++-- source/arm11/open_agb_firm.c | 32 +++++++++++++++++++------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/arm11/open_agb_firm.h b/include/arm11/open_agb_firm.h index 7d42e78..a91fc16 100644 --- a/include/arm11/open_agb_firm.h +++ b/include/arm11/open_agb_firm.h @@ -63,7 +63,7 @@ struct global_oaf_config Result oafParseConfigEarly(void); u16 oafGetBacklightConfig(void); -Result oafInitAndRun( char * ); +Result oafInitAndRun( char * , bool * ); void oafUpdate(void); void oafFinish(void); Result oafPreboot( const char * ); diff --git a/source/arm11/main.c b/source/arm11/main.c index 0a64b60..758993e 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -76,13 +76,14 @@ int main() strncpy( firm_path, FIRMPATH_INCOME, FIRMPATH_SIZELIMIT ); Result res = fMount(FS_DRIVE_SDMC); + bool direct_off = false; if(res == RES_OK) res = oafParseConfigEarly(); GFX_init(GFX_BGR8, GFX_RGB565); setBacklight(); consoleInit(SCREEN_BOT, NULL); //CODEC_init(); - if(res == RES_OK && (res = oafInitAndRun(firm_path)) == RES_OK) + if(res == RES_OK && (res = oafInitAndRun(firm_path, &direct_off)) == RES_OK) { do { @@ -95,7 +96,7 @@ int main() reboot = oafHaltMode(); oafFinish(); } - else printErrorWaitInput(res, 0); + else if( !direct_off ) printErrorWaitInput(res, 0); if( reboot ) { if( RES_OK == oafPreboot(firm_path) ) diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index ae33b62..61a40e8 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -22,6 +22,7 @@ #include "types.h" #include "arm_intrinsic.h" #include "util.h" +#include "drivers/cache.h" #include "drivers/sha.h" #include "arm11/drivers/hid.h" // @MERGE 231006 START @@ -975,9 +976,10 @@ KHandle setupFrameCapture(const u8 scaler) } // @MERGE 231006 END -Result oafInitAndRun( char *firm_path ) +Result oafInitAndRun( char *firm_path, bool *direct_off ) { Result res; + flushDCache(); repairBootFirm( firm_path ); char *const filePath = (char*)calloc(512, 1); if(filePath != NULL) @@ -988,7 +990,11 @@ Result oafInitAndRun( char *firm_path ) // If this file doesn't exist show the file browser. if((res = fsLoadPathFromFile("autoboot.txt", filePath)) == RES_FR_NO_FILE) { - if((res = showFileBrowser(filePath)) != RES_OK || *filePath == '\0') break; + if((res = showFileBrowser(filePath)) != RES_OK || *filePath == '\0') + { + *direct_off = true; + break; + } ee_puts("Loading..."); } else if(res != RES_OK) break; @@ -1070,6 +1076,7 @@ Result oafInitAndRun( char *firm_path ) else res = RES_OUT_OF_MEM; free(filePath); + flushDCache(); return res; } @@ -1131,29 +1138,28 @@ static bool checkLumaFirm( const char *file ) static void repairBootFirm( char *firm_path ) { - if( 0 == strcmp(firm_path, autorun) ) + size_t n = FIRMPATH_SIZELIMIT-1; + char tmp[512]; // 为啥不是0x40?因为fsLoadPathFromFile要的是512 + if( 0 == strncmp(firm_path, autorun, n) ) { - char firmname[512]; // 为啥不是0x40?因为fsLoadPathFromFile要的是512 - if( RES_OK == fsLoadPathFromFile("autorun", firmname) ) + if( RES_OK == fsLoadPathFromFile("autorun", tmp) ) { - fRename( autorun, firmname ); - strncpy( firm_path, firmname, 0x3f ); + fRename( autorun, tmp ); + strncpy( firm_path, tmp, n ); } else { const char *default_path = "sdmc:/luma/payloads/open_agb_firm.firm"; fRename( autorun, default_path ); - strncpy( firm_path, default_path, 0x3f ); + strncpy( firm_path, default_path, n ); } - firm_path[0x3f] = '\0'; + firm_path[n] = '\0'; } // 把Preboot存档的boot.firm恢复回去 - char tmp[5]; - if( RES_OK == fsQuickRead("luma.firm", tmp, 4) ) + if( RES_OK == fsQuickRead("luma.firm", tmp, 63) ) { - tmp[4] = '\0'; - if( strcmp(tmp, "FIRM") == 0 ){ + if( strncmp(tmp, "FIRM", 4) == 0 ){ fRename("sdmc:/boot.firm", "sdmc:/3ds/open_agb_firm/boot.firm"); fRename("sdmc:/3ds/open_agb_firm/luma.firm", "sdmc:/boot.firm"); }