mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 22:04:10 +08:00
能完成重启,但是会panic的版本,还要继续查一下怎么跑飞的
This commit is contained in:
parent
e16e705ab0
commit
d5aca97197
@ -60,7 +60,9 @@ struct global_oaf_config
|
|||||||
|
|
||||||
Result oafParseConfigEarly(void);
|
Result oafParseConfigEarly(void);
|
||||||
u16 oafGetBacklightConfig(void);
|
u16 oafGetBacklightConfig(void);
|
||||||
Result oafInitAndRun(void);
|
Result oafInitAndRun( char * );
|
||||||
void oafUpdate(void);
|
void oafUpdate(void);
|
||||||
void oafFinish(void);
|
void oafFinish(void);
|
||||||
|
Result oafPreboot( const char * );
|
||||||
int oafCheatMode(void);
|
int oafCheatMode(void);
|
||||||
|
int oafHaltMode(void);
|
||||||
|
@ -48,6 +48,20 @@
|
|||||||
|
|
||||||
|
|
||||||
BEGIN_ASM_FUNC _start
|
BEGIN_ASM_FUNC _start
|
||||||
|
@ 如果argc > 0,则保存argv的字符串到0x20001000,也就是RAM_FIRM_BOOT_ADDR
|
||||||
|
cmp r0, #0
|
||||||
|
beq _start_firm
|
||||||
|
|
||||||
|
mov r0, #0x20000000
|
||||||
|
add r0, #0x1000
|
||||||
|
ldr r1, [r1] @ r1 = r1[0]
|
||||||
|
_strcpy_firm:
|
||||||
|
ldrb r2, [r1], #1 @ r2 = *r1
|
||||||
|
strb r2, [r0], #1 @ *r0 = r2
|
||||||
|
cmp r2, #0
|
||||||
|
bne _strcpy_firm
|
||||||
|
|
||||||
|
_start_firm:
|
||||||
msr cpsr_cxsf, #PSR_INT_OFF | PSR_SVC_MODE
|
msr cpsr_cxsf, #PSR_INT_OFF | PSR_SVC_MODE
|
||||||
|
|
||||||
@ Control register:
|
@ Control register:
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "arm11/console.h"
|
#include "arm11/console.h"
|
||||||
#include "arm11/drivers/codec.h"
|
#include "arm11/drivers/codec.h"
|
||||||
#include "arm11/drivers/hid.h"
|
#include "arm11/drivers/hid.h"
|
||||||
|
#include "arm11/drivers/timer.h"
|
||||||
#include "arm11/power.h"
|
#include "arm11/power.h"
|
||||||
#include "arm11/acf.h"
|
#include "arm11/acf.h"
|
||||||
|
|
||||||
@ -64,8 +65,13 @@ Result fReadSize( FHandle file, void *buff, unsigned size, uint32_t *readout )
|
|||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
static char firm_path[0x40];
|
||||||
|
|
||||||
|
int main()
|
||||||
{
|
{
|
||||||
|
int reboot = 0;
|
||||||
|
strncpy( firm_path, 0x20001000, 0x40 );
|
||||||
|
|
||||||
Result res = fMount(FS_DRIVE_SDMC);
|
Result res = fMount(FS_DRIVE_SDMC);
|
||||||
if(res == RES_OK) res = oafParseConfigEarly();
|
if(res == RES_OK) res = oafParseConfigEarly();
|
||||||
GFX_init(GFX_BGR8, GFX_RGB565);
|
GFX_init(GFX_BGR8, GFX_RGB565);
|
||||||
@ -73,7 +79,7 @@ int main(void)
|
|||||||
consoleInit(SCREEN_BOT, NULL);
|
consoleInit(SCREEN_BOT, NULL);
|
||||||
//CODEC_init();
|
//CODEC_init();
|
||||||
|
|
||||||
if(res == RES_OK && (res = oafInitAndRun()) == RES_OK)
|
if(res == RES_OK && (res = oafInitAndRun(firm_path)) == RES_OK)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -83,10 +89,23 @@ int main(void)
|
|||||||
oafUpdate();
|
oafUpdate();
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
|
reboot = oafHaltMode();
|
||||||
oafFinish();
|
oafFinish();
|
||||||
}
|
}
|
||||||
else printErrorWaitInput(res, 0);
|
else printErrorWaitInput(res, 0);
|
||||||
|
|
||||||
|
if( reboot ) {
|
||||||
|
if( RES_OK == oafPreboot(firm_path) )
|
||||||
|
{
|
||||||
|
CODEC_deinit();
|
||||||
|
GFX_deinit();
|
||||||
|
fUnmount(FS_DRIVE_SDMC);
|
||||||
|
TIMER_sleepMs(500);
|
||||||
|
power_reboot();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CODEC_deinit();
|
CODEC_deinit();
|
||||||
GFX_deinit();
|
GFX_deinit();
|
||||||
fUnmount(FS_DRIVE_SDMC);
|
fUnmount(FS_DRIVE_SDMC);
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "kevent.h"
|
#include "kevent.h"
|
||||||
#include "arm11/drivers/codec.h"
|
#include "arm11/drivers/codec.h"
|
||||||
|
#include "arm11/drivers/timer.h"
|
||||||
|
|
||||||
|
|
||||||
#define OAF_WORK_DIR "sdmc:/3ds/open_agb_firm"
|
#define OAF_WORK_DIR "sdmc:/3ds/open_agb_firm"
|
||||||
@ -147,6 +148,11 @@ int oafCheatMode()
|
|||||||
return g_oafConfig.cheatMode;
|
return g_oafConfig.cheatMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int oafHaltMode()
|
||||||
|
{
|
||||||
|
return g_oafConfig.haltMode;
|
||||||
|
}
|
||||||
|
|
||||||
atp_error_t oaf_config_page()
|
atp_error_t oaf_config_page()
|
||||||
{
|
{
|
||||||
return use_config_page(&g_oafConfig);
|
return use_config_page(&g_oafConfig);
|
||||||
@ -631,6 +637,8 @@ static void adjustGammaTableForGba(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void repairBootFirm( char *firm_path );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
static Result dumpFrameTex(void)
|
static Result dumpFrameTex(void)
|
||||||
{
|
{
|
||||||
@ -758,6 +766,10 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
|
|||||||
if( strcmp(name, "cheatMode") == 0 )
|
if( strcmp(name, "cheatMode") == 0 )
|
||||||
config->cheatMode = (u8)strtoul(value, NULL, 10);
|
config->cheatMode = (u8)strtoul(value, NULL, 10);
|
||||||
if( config->cheatMode >= CHEAT_MODE_SIZE ) config->cheatMode = CHEAT_MODE_DISABLED;
|
if( config->cheatMode >= CHEAT_MODE_SIZE ) config->cheatMode = CHEAT_MODE_DISABLED;
|
||||||
|
|
||||||
|
if( strcmp(name, "haltMode") == 0 )
|
||||||
|
config->haltMode = (u8)strtoul( value, NULL, 10 );
|
||||||
|
if( config->haltMode > HALT_MODE_SIZE ) config->haltMode = HALT_MODE_POWEROFF;
|
||||||
}
|
}
|
||||||
else return 0; // Error.
|
else return 0; // Error.
|
||||||
|
|
||||||
@ -883,9 +895,10 @@ u16 oafGetBacklightConfig(void)
|
|||||||
return g_oafConfig.backlight;
|
return g_oafConfig.backlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result oafInitAndRun(void)
|
Result oafInitAndRun( char *firm_path )
|
||||||
{
|
{
|
||||||
Result res;
|
Result res;
|
||||||
|
repairBootFirm( firm_path );
|
||||||
char *const filePath = (char*)calloc(512, 1);
|
char *const filePath = (char*)calloc(512, 1);
|
||||||
if(filePath != NULL)
|
if(filePath != NULL)
|
||||||
{
|
{
|
||||||
@ -982,3 +995,34 @@ void oafFinish(void)
|
|||||||
}
|
}
|
||||||
LGY_deinit();
|
LGY_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *autorun = "sdmc:/luma/payloads/autorun.luma";
|
||||||
|
static void repairBootFirm( char *firm_path )
|
||||||
|
{
|
||||||
|
if( 0 == strcmp(firm_path, autorun) )
|
||||||
|
{
|
||||||
|
char firmname[0x40];
|
||||||
|
memset( firmname, 0, 0x40 );
|
||||||
|
if( RES_OK == fsQuickRead("autorun", firmname, 0x3f) )
|
||||||
|
{
|
||||||
|
fRename( autorun, firmname );
|
||||||
|
strncpy( firm_path, firmname, 0x40 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *default_path = "sdmc:/luma/payloads/open_agb_firm.firm";
|
||||||
|
fRename( autorun, default_path );
|
||||||
|
strncpy( firm_path, default_path, 0x40 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result oafPreboot( const char *firm_path )
|
||||||
|
{
|
||||||
|
ee_puts( firm_path );
|
||||||
|
|
||||||
|
fsQuickWrite("autorun", firm_path, strlen(firm_path));
|
||||||
|
Result ret = fRename(firm_path, autorun);
|
||||||
|
TIMER_sleepMs(500);
|
||||||
|
return ret;
|
||||||
|
}
|
@ -222,7 +222,7 @@ atp_error_t use_config_page( OafConfig *g_oafConfig )
|
|||||||
page_strbuf, sizeof(page_strbuf),
|
page_strbuf, sizeof(page_strbuf),
|
||||||
"参数配置 当前电量:%3d%%"
|
"参数配置 当前电量:%3d%%"
|
||||||
"每次开机存档方案重置为“和卡带序列号一致”,这个方案会优先使用游戏最后一次启动时设置的存档类型", MCU_getBatteryLevel());
|
"每次开机存档方案重置为“和卡带序列号一致”,这个方案会优先使用游戏最后一次启动时设置的存档类型", MCU_getBatteryLevel());
|
||||||
atp_error_t res = atp_select( page_strbuf, 5, config_item, config_adjust, g_oafConfig, 0, 0, NULL );
|
atp_error_t res = atp_select( page_strbuf, 6, config_item, config_adjust, g_oafConfig, 0, 0, NULL );
|
||||||
atp_tips( oldtips, NULL );
|
atp_tips( oldtips, NULL );
|
||||||
if( res == ATP_NO_ACTION )
|
if( res == ATP_NO_ACTION )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user