给参数配置添加说明页面

This commit is contained in:
anod 2022-10-17 17:51:51 +08:00
parent 2447941e6c
commit c79fc2dfc3
4 changed files with 72 additions and 23 deletions

View File

@ -40,8 +40,8 @@ typedef void * atp_callerdata_t;
// page option
#define ATP_PAGE_NOOPTION 0
#define ATP_PAGE_UPDATE 1 // UPDATE THE CURSOR ROW
#define ATP_PAGE_REFRESH 2 // UPDATE THE WHOLE PAGE
#define ATP_PAGE_UPDATE 2 // UPDATE THE CURSOR ROW
#define ATP_PAGE_REFRESH 3 // UPDATE THE WHOLE PAGE
typedef struct {
atp_text_t text;

View File

@ -314,6 +314,8 @@ atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t
screen_clean_zone( CONTAINER_LEFTTOP_X, CONTAINER_LEFTTOP_Y+FONT_HEIGHT*(row), CONTAINER_RECT_WIDTH, FONT_HEIGHT );
draw_one_option( item_sel, item_sel, row, provider, data );
break;
case ATP_POWER_OFF:
return ATP_POWER_OFF;
default:
;
}

View File

@ -146,10 +146,12 @@ static atp_text_t folder_help[] = {
"蓝色             目录",
"白色             游戏",
"~ ~ ~ ~ ~ ~ ~",
"上下方向键   切换选中文件或目录",
"左右方向键          翻页",
"A键      查看目录或启动游戏",
"B键          上层文件夹",
"X键            金手指",
"Y键           游戏设置",
"Y键           暂不使用",
"START        查看说明",
"SELECT       系统设置"
};
@ -187,26 +189,25 @@ static atp_error_t display_help( atp_callerdata_t table, atp_counter_t index, at
return ATP_SUCCESS;
}
static void help_page( atp_text_t *wording, atp_counter_t length )
atp_error_t help_page( atp_text_t *wording, atp_counter_t length )
{
atp_tips( NULL, "返回按A/B" );
atp_show( length, display_help, (atp_callerdata_t)wording );
return atp_show( length, display_help, (atp_callerdata_t)wording );
}
extern void oaf_config_page();
extern atp_error_t oaf_config_page();
static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
{
if( start )
{
atp_tips( "", NULL );
help_page( folder_help, sizeof(folder_help)/sizeof(atp_text_t) );
return ATP_PAGE_REFRESH;
return ATP_POWER_OFF == help_page( folder_help, sizeof(folder_help)/sizeof(atp_text_t) )
? ATP_POWER_OFF : ATP_PAGE_REFRESH;
}
else if( select )
{
oaf_config_page();
return ATP_PAGE_REFRESH;
return ATP_POWER_OFF == oaf_config_page() ? ATP_POWER_OFF : ATP_PAGE_REFRESH;
}
return ATP_PAGE_NOOPTION;
}

View File

@ -50,7 +50,7 @@
"directBoot=false\n" \
"useGbaDb=true\n\n" \
"[video]\n" \
"scaler=2\n" \
"scaler=1\n" \
"gbaGamma=2.2\n" \
"lcdGamma=1.54\n" \
"contrast=1.0\n" \
@ -59,6 +59,11 @@
"saveOverride=false\n" \
"defaultSave=14"
#define SAVE_POLICY_GBADB 0
#define SAVE_POLICY_FIRM 1
#define SAVE_POLICY_SRAM 2
#define SAVE_POLICY_POPUP 3
#define SAVE_POLICY_SIZE 3
typedef struct
{
@ -81,6 +86,9 @@ typedef struct
// [advanced]
bool saveOverride;
u16 defaultSave;
// [by-anod]
u8 savePolicy;
} OafConfig;
typedef struct
@ -113,17 +121,34 @@ static OafConfig g_oafConfig =
// [advanced]
false, // saveOverride
14 // defaultSave
// [by-anod]
, SAVE_POLICY_GBADB // savePolicy
};
static KHandle g_frameReadyEvent = 0;
// --------------------------
// code for oaf config page
// --------------------------
atp_text_t config_help[] =
{
"参数配置操作指引",
"---------------",
"上下方向键         切换参数项目",
"左右方向键             翻页",
"L键和R键         调整当前参数",
"A键            保存修改退出",
"B键           不保存修改退出"
};
extern atp_error_t help_page( atp_text_t *wording, atp_counter_t length )
#define LIGHT_MIN (MCU_getSystemModel() > 3 ? 16 : 20)
#define LIGHT_MAX (MCU_getSystemModel() > 3 ? 142 : 117)
#define SCALER_SIZE 3
static atp_error_t config_item( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
{
const char *scaler_val[] = {"上屏无缩放", "上屏GPU放大", "上屏DMA放大", "下屏无缩放"};
const char *savetype_name[] = {"和卡带序列号一致", "读取ROM的特定标记", "汉化带SRAM补丁"};
static char buf[16];
cfg->extra_text_color = ATP_COLOR_GREEN;
if( index == 0 )
@ -146,8 +171,8 @@ static atp_error_t config_item( atp_callerdata_t data, atp_counter_t index, atp_
}
else if( index == 3 )
{
cfg->text = "推测存档类型";
cfg->extra_text = g_oafConfig.saveOverride ? "禁用" : "启用";
cfg->text = "存档方案";
cfg->extra_text = savetype_name[g_oafConfig.savePolicy];
}
cfg->value = index;
return ATP_SUCCESS;
@ -157,16 +182,15 @@ static atp_pageopt_t config_adjust( atp_callerdata_t data, atp_counter_t index,
{
if( l || r )
{
if( index == 0 )
{
u8 light = g_oafConfig.backlight;
if( l || x )
if( l )
{
light -= 10;
if( light % 10 ) light += 10 - light%10;
}
else if( r || y )
else if( r )
{
light += 10;
if( light % 10 ) light -= light % 10;
@ -176,20 +200,37 @@ static atp_pageopt_t config_adjust( atp_callerdata_t data, atp_counter_t index,
g_oafConfig.backlight = light;
}
else if( index == 1 ) g_oafConfig.directBoot = !g_oafConfig.directBoot;
else if( index == 2 ) g_oafConfig.scaler = ( 4 + ( g_oafConfig.scaler+(l?1:-1) ) ) % 4;
else if( index == 3 ) g_oafConfig.saveOverride = !g_oafConfig.saveOverride;
else if( index == 2 ) g_oafConfig.scaler = ( SCALER_SIZE + ( g_oafConfig.scaler+(l?-1:1) ) ) % SCALER_SIZE;
else if( index == 3 ) g_oafConfig.savePolicy = ( SAVE_POLICY_SIZE + ( g_oafConfig.savePolicy+(l?-1:1) ) ) % SAVE_POLICY_SIZE;
}
else if( start )
{
return ATP_POWER_OFF == help_page( config_help, sizeof(config_help)/sizeof(atp_text_t) )
? ATP_POWER_OFF : ATP_PAGE_REFRESH;
}
return ATP_PAGE_UPDATE;
}
void oaf_config_page()
atp_error_t oaf_config_page()
{
u8 light = g_oafConfig.backlight;
atp_select( "参数配置", 4, config_item, config_adjust, NULL, 0, 0, NULL );
u8 base[sizeof(g_oafConfig)];
memcpy( base, g_oafConfig, sizeof(g_oafConfig) );
struct OafConfig *prev = &base[0];
if( light != g_oafConfig.backlight )
GFX_setBrightness(g_oafConfig.backlight, g_oafConfig.backlight);
atp_error_t res = atp_select( "参数配置", 4, config_item, config_adjust, NULL, 0, 0, NULL );
if( res == ATP_NO_ACTION )
{
memcpy( g_oafConfig, base, sizeof(g_oafConfig) );
return ATP_SUCCESS;
}
else if( res == ATP_SUCCESS )
{
if( prev->backlight != g_oafConfig.backlight )
GFX_setBrightness(g_oafConfig.backlight, g_oafConfig.backlight);
// TODO : STRING FORMAT AND QUICK SAVE
}
return res;
}
static u32 fixRomPadding(u32 romFileSize)
@ -653,6 +694,11 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
if(strcmp(name, "defaultSave") == 0)
config->defaultSave = (u16)strtoul(value, NULL, 10);
}
else if( strcmp(section, "by-anod") == 0 )
{
if(strcmp(name, "savePolicy") == 0)
config->savePolicy = (u8)strtoul(value, NULL, 10);
}
else return 0; // Error.
return 1; // 1 is no error? Really?