mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 05:44:11 +08:00
把金手指配置页面提取出来
This commit is contained in:
parent
183e91c698
commit
7494875d96
@ -6,8 +6,21 @@
|
||||
#include "arm11/open_agb_firm.h"
|
||||
|
||||
extern atp_error_t use_config_page( struct global_oaf_config* );
|
||||
extern atp_error_t use_cheat_page( const char* );
|
||||
|
||||
extern atp_error_t help_page( atp_text_t *wording, atp_counter_t length );
|
||||
|
||||
#define use_help_page(text) help_page((text), sizeof((text))/sizeof(atp_text_t))
|
||||
#define WAIT_ON_ACT( act ) ( ATP_POWER_OFF == (act) ) ? ATP_POWER_OFF : ATP_PAGE_REFRESH
|
||||
#define WAIT_ON_ERRPAGE( page ) WAIT_ON_ACT( atp_show(1, (page), NULL) )
|
||||
|
||||
#define DECLARE_ERROR_PAGE(name, message) static atp_error_t name (atp_callerdata_t, atp_counter_t, atp_linecfg_t *c) \
|
||||
{ \
|
||||
c->text = message; \
|
||||
c->text_align = ATP_PLACEMENT_CENTER; \
|
||||
c->text_color = ATP_COLOR_RED; \
|
||||
return ATP_SUCCESS; \
|
||||
}
|
||||
|
||||
|
||||
#endif//__OAF_PAGES_H__
|
@ -205,18 +205,7 @@ static atp_error_t display_folder( atp_callerdata_t data, atp_counter_t index, a
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
#define DECLARE_ERROR_PAGE(name, message) static atp_error_t name (atp_callerdata_t, atp_counter_t, atp_linecfg_t *c) \
|
||||
{ \
|
||||
c->text = message; \
|
||||
c->text_align = ATP_PLACEMENT_CENTER; \
|
||||
c->text_color = ATP_COLOR_RED; \
|
||||
return ATP_SUCCESS; \
|
||||
}
|
||||
|
||||
DECLARE_ERROR_PAGE( display_openlib, "打开金手指文件出错" )
|
||||
DECLARE_ERROR_PAGE( display_selcht, "查找金手指配置出错" )
|
||||
DECLARE_ERROR_PAGE( display_noserial, "提取游戏识别码失败" )
|
||||
DECLARE_ERROR_PAGE( display_nocheat, "找不到对应的金手指配置" )
|
||||
DECLARE_ERROR_PAGE( display_empty, "没有合适的文件" )
|
||||
DECLARE_ERROR_PAGE( display_toolong, "路径过长,改名或移动文件后再试" )
|
||||
DECLARE_ERROR_PAGE( display_pathfull, "游戏或目录过量,最多显示999个" )
|
||||
@ -247,203 +236,6 @@ static atp_error_t disp_str( atp_callerdata_t data, atp_counter_t, atp_linecfg_t
|
||||
}while ( down == 0 );
|
||||
}*/
|
||||
|
||||
static atp_error_t select_region( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *config )
|
||||
{
|
||||
static char text[16];
|
||||
|
||||
acl_region_t sreg;
|
||||
acl_chtid_t sid, id;
|
||||
if( ACHTLIB_SUCCESS != acl_query_cheat_set(index, &sid, &sreg) )
|
||||
{
|
||||
config->text = "无效数据";
|
||||
config->value = index;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
char *t;
|
||||
switch( sreg )
|
||||
{
|
||||
case 'C': t = "官方中文"; break;
|
||||
case 'J': t = "日文版"; break;
|
||||
case 'E': t = "英文版"; break;
|
||||
case 'F': t = "法语版"; break;
|
||||
case 'S': t = "西班牙语"; break;
|
||||
case 'I': t = "意大利语"; break;
|
||||
case 'D': t = "德语版"; break;
|
||||
case 'K': t = "韩文版"; break;
|
||||
case 'X': case 'P': t = "欧洲语种"; break;
|
||||
default: t = "其他语种"; break;
|
||||
}
|
||||
ee_sprintf(text, "%c-%s", 'A'+(char)index, t);
|
||||
|
||||
if( CCHT_NOT_INIT == info_current_cheat( &id, NULL ) )
|
||||
id = 0;
|
||||
|
||||
config->text = text;
|
||||
config->value = index;
|
||||
|
||||
// show saved information
|
||||
if( sid == id )
|
||||
{
|
||||
config->extra_text = "已启用";
|
||||
config->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_holes( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_text_t text;
|
||||
acl_error_t res = acl_entry_get_label(index, &text);
|
||||
if( res == ACHTLIB_SUCCESS )
|
||||
cfg->text = text;
|
||||
else cfg->text = "无效数据";
|
||||
cfg->value = 1+index;
|
||||
|
||||
// show saved information
|
||||
acl_entryid_t id;
|
||||
if( CCHT_OK == get_current_cheat( index, &id ) && ENT_USING(id) )
|
||||
{
|
||||
cfg->extra_text = "开";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_onoff( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_entryid_t eid = (acl_entryid_t)data;
|
||||
eid &= 0xffff;
|
||||
if( index == 0 )
|
||||
{
|
||||
cfg->text = "不开启";
|
||||
cfg->value = eid;
|
||||
}
|
||||
else if( index == 1 )
|
||||
{
|
||||
cfg->text = "开启";
|
||||
cfg->value = 1<<16 | eid;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->text = "调整数值开启[结果未知]";
|
||||
cfg->value = 0;
|
||||
}
|
||||
|
||||
// show saved information
|
||||
if( CCHT_OK == include_current_cheat((acl_entryid_t)cfg->value) )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u16 calc_step( u16 value )
|
||||
{
|
||||
u16 n = value / 50;
|
||||
if( n == 0 ) return 1;
|
||||
else
|
||||
{
|
||||
u16 base = 1;
|
||||
while( n > 10 )
|
||||
{
|
||||
n = n/10;
|
||||
base *= 10;
|
||||
}
|
||||
if( n < 5 ) return base * 5;
|
||||
else return base * 10;
|
||||
}
|
||||
}
|
||||
|
||||
static atp_error_t step_provider( atp_callerdata_t mixid, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
static char number[8];
|
||||
u32 mix = (u32)mixid;
|
||||
u16 max = mix & 0xffff;
|
||||
u16 step = mix >> 16;
|
||||
u16 res = step * (index+1);
|
||||
ee_snprintf( number, 8, "%d", res < max ? res : max );
|
||||
cfg->text = number;
|
||||
cfg->value = res < max ? res : max;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t handle_onoff_entry( acl_entryid_t id, acl_elemlen_t codelen, atp_itemval_t *item )
|
||||
{
|
||||
#define DEFAULT_ONOFF_HANDLER atp_select("选择此项目对应的设置", 2, select_onoff, NULL, (atp_callerdata_t)id, 0, 0, item);
|
||||
#define ONOFF_SAFE_CALLACL( statement ) if( ACHTLIB_SUCCESS != statement ) return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
if( codelen > 4 )// more than 2 address
|
||||
return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
u16 targetval = 0;
|
||||
acl_armcode_t code;
|
||||
|
||||
// one address
|
||||
if( codelen == 2 )
|
||||
{
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(1, &code) );
|
||||
targetval = code & 0xff;
|
||||
}
|
||||
// two addresses
|
||||
else if( codelen == 4 )
|
||||
{
|
||||
u32 addr0, addr1;
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(0, &addr0) );
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(2, &addr1) );
|
||||
if( (addr0 & 1) || (addr0 | 1) != addr1 ) // valid u16 address
|
||||
return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(1, &code) );
|
||||
targetval = code & 0xff;
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(3, &code) );
|
||||
targetval |= (code & 0xff) << 8;
|
||||
}
|
||||
// more than two address, should not overwrite values
|
||||
else return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
atp_error_t res = atp_select( "选择此项目对应的设置", 3, select_onoff, NULL, targetval << 16 | id, 0, 0, item );
|
||||
if( res == ATP_SUCCESS && *item == 0 )
|
||||
{
|
||||
char title[24];
|
||||
ee_snprintf( title, sizeof(title), "默认值:%d", targetval );
|
||||
u16 step = calc_step( targetval );
|
||||
atp_counter_t n = (targetval-1+step)/step;
|
||||
res = atp_select(title, n, step_provider, NULL, (atp_callerdata_t)(step<<16|targetval), n, 0, item );
|
||||
if( res == ATP_SUCCESS && *item != targetval )
|
||||
overwrite_current_cheat( 1<<16|id, *item );
|
||||
|
||||
*item = 1<<16 | id;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static atp_error_t select_keys( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_text_t text;
|
||||
if( index == 0 )
|
||||
{
|
||||
cfg->text = "不开启";
|
||||
}
|
||||
else
|
||||
{
|
||||
acl_error_t res = acl_entry_get_label(index-1, &text);
|
||||
if( res == ACHTLIB_SUCCESS )
|
||||
cfg->text = text;
|
||||
else cfg->text = "无效数据";
|
||||
}
|
||||
acl_entryid_t eid = (acl_entryid_t)data;
|
||||
cfg->value = index<<16 | eid;
|
||||
|
||||
if( CCHT_OK == include_current_cheat((acl_entryid_t)cfg->value) )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static inline void key_tips( key_remix_t *p, atp_boolean_t checking, atp_itemcfg_t *cfg )
|
||||
{
|
||||
if( p->remix_type == REMIX_TYPE_NONE )
|
||||
@ -635,8 +427,6 @@ static atp_error_t active_gbakey( atp_callerdata_t p_curkey, atp_counter_t index
|
||||
extern atp_error_t oaf_config_page();
|
||||
|
||||
#define DIRBUFFSIZE 512
|
||||
#define WAIT_ON_ACT( act ) ( ATP_POWER_OFF == (act) ) ? ATP_POWER_OFF : ATP_PAGE_REFRESH
|
||||
#define WAIT_ON_ERRPAGE( page ) WAIT_ON_ACT( atp_show(1, (page), NULL) )
|
||||
|
||||
static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
|
||||
{
|
||||
@ -683,121 +473,7 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a
|
||||
}
|
||||
else RECOVER_PATH;
|
||||
|
||||
acl_count_t len;
|
||||
if( ACHTLIB_SUCCESS != acl_open_lib( "gba.acl" ) )
|
||||
{
|
||||
return WAIT_ON_ERRPAGE( display_openlib );
|
||||
}
|
||||
if( ACHTLIB_SUCCESS != acl_select_game( serial, 0, &len ) )
|
||||
{
|
||||
acl_close_lib();
|
||||
return WAIT_ON_ERRPAGE( display_selcht );
|
||||
}
|
||||
if( len == 0 )
|
||||
{
|
||||
acl_close_lib();
|
||||
return WAIT_ON_ERRPAGE( display_nocheat );
|
||||
}
|
||||
|
||||
//return WAIT_ON_ACT( oaf_cheat_page() );
|
||||
|
||||
// 显示配置页面
|
||||
atp_error_t res;
|
||||
atp_itemval_t item;
|
||||
acl_elemlen_t cnt;
|
||||
|
||||
#define DISP_DONE 0
|
||||
#define DISP_REGION 1
|
||||
#define DISP_HOLES 2
|
||||
#define DISP_KEYS 3
|
||||
#define SAFE_CALLACL( r ) if( ACHTLIB_SUCCESS!=r ) \
|
||||
{\
|
||||
res = WAIT_ON_ERRPAGE( display_selcht );\
|
||||
break;\
|
||||
}
|
||||
|
||||
uint8_t status = DISP_REGION;
|
||||
atp_counter_t defi = 0;
|
||||
acl_entryid_t eid = 0;
|
||||
atp_text_t oldtips;
|
||||
atp_tips("确定A/返回B", &oldtips);
|
||||
|
||||
while( status != DISP_DONE )
|
||||
{
|
||||
if( status == DISP_REGION )
|
||||
{
|
||||
res = atp_select("请谨慎使用金手指!金手指可能会引起卡顿、死机、损坏存档等现象。 "
|
||||
"选择一个金手指配置:", len, select_region, NULL, NULL, defi, 0, &item );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
defi = item;
|
||||
acl_chtid_t sid;
|
||||
acl_elemlen_t len;
|
||||
u32 ccid, cclen;
|
||||
SAFE_CALLACL( acl_query_cheat_set((acl_index_t)item, &sid, NULL ) );
|
||||
SAFE_CALLACL( acl_select_cheat_set( sid ) );
|
||||
SAFE_CALLACL( acl_select_entry(0, &len) );
|
||||
|
||||
if( CCHT_OK == info_current_cheat(&ccid, &cclen) )
|
||||
{
|
||||
// SKIP the init process when id and len is the same
|
||||
if( ccid != sid || cclen != len )
|
||||
init_current_cheat( sid, len );
|
||||
}
|
||||
else init_current_cheat( sid, len );
|
||||
|
||||
eid = 0;
|
||||
status = DISP_HOLES;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION)
|
||||
{
|
||||
status = DISP_DONE;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_HOLES )
|
||||
{
|
||||
SAFE_CALLACL( acl_select_entry(0, &cnt) );
|
||||
res = atp_select("选择一个金手指项目", cnt, select_holes, NULL, NULL, eid > 0 ? (eid&0xffff)-1 : 0, 0, &item);
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
eid = (acl_entryid_t)item;
|
||||
status = DISP_KEYS;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_REGION;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else // DISP_KEYS
|
||||
{
|
||||
SAFE_CALLACL( acl_select_entry( eid, &cnt ) );
|
||||
if( cnt == 0 )
|
||||
{
|
||||
SAFE_CALLACL( acl_select_entry( 1<<16 | eid, &cnt ) );
|
||||
res = handle_onoff_entry( eid, cnt, &item );
|
||||
}
|
||||
else
|
||||
{
|
||||
res = atp_select("选择此项目对应的设置", cnt, select_keys, NULL, (atp_callerdata_t)eid, 0, 0, &item);
|
||||
}
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
put_current_cheat( (acl_entryid_t)item );
|
||||
status = DISP_HOLES;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_HOLES;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
acl_close_lib();
|
||||
atp_tips( oldtips, NULL );
|
||||
return WAIT_ON_ACT( res );
|
||||
return WAIT_ON_ACT( use_cheat_page( serial ) );
|
||||
}
|
||||
else if( y )
|
||||
{
|
||||
|
@ -187,3 +187,327 @@ atp_error_t use_config_page( OafConfig *g_oafConfig )
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------
|
||||
// code for oaf cheat page
|
||||
// --------------------------
|
||||
|
||||
#define DISP_DONE 0
|
||||
#define DISP_REGION 1
|
||||
#define DISP_HOLES 2
|
||||
#define DISP_KEYS 3
|
||||
#define SAFE_CALLACL( r ) if( ACHTLIB_SUCCESS!=r ) \
|
||||
{\
|
||||
res = WAIT_ON_ERRPAGE( display_selcht );\
|
||||
break;\
|
||||
}
|
||||
|
||||
DECLARE_ERROR_PAGE( display_selcht, "查找金手指配置出错" )
|
||||
DECLARE_ERROR_PAGE( display_openlib, "打开金手指文件出错" )
|
||||
DECLARE_ERROR_PAGE( display_nocheat, "找不到对应的金手指配置" )
|
||||
|
||||
static atp_error_t select_region( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *config )
|
||||
{
|
||||
static char text[16];
|
||||
|
||||
acl_region_t sreg;
|
||||
acl_chtid_t sid, id;
|
||||
if( ACHTLIB_SUCCESS != acl_query_cheat_set(index, &sid, &sreg) )
|
||||
{
|
||||
config->text = "无效数据";
|
||||
config->value = index;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
char *t;
|
||||
switch( sreg )
|
||||
{
|
||||
case 'C': t = "官方中文"; break;
|
||||
case 'J': t = "日文版"; break;
|
||||
case 'E': t = "英文版"; break;
|
||||
case 'F': t = "法语版"; break;
|
||||
case 'S': t = "西班牙语"; break;
|
||||
case 'I': t = "意大利语"; break;
|
||||
case 'D': t = "德语版"; break;
|
||||
case 'K': t = "韩文版"; break;
|
||||
case 'X': case 'P': t = "欧洲语种"; break;
|
||||
default: t = "其他语种"; break;
|
||||
}
|
||||
ee_sprintf(text, "%c-%s", 'A'+(char)index, t);
|
||||
|
||||
if( CCHT_NOT_INIT == info_current_cheat( &id, NULL ) )
|
||||
id = 0;
|
||||
|
||||
config->text = text;
|
||||
config->value = index;
|
||||
|
||||
// show saved information
|
||||
if( sid == id )
|
||||
{
|
||||
config->extra_text = "已启用";
|
||||
config->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_holes( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_text_t text;
|
||||
acl_error_t res = acl_entry_get_label(index, &text);
|
||||
if( res == ACHTLIB_SUCCESS )
|
||||
cfg->text = text;
|
||||
else cfg->text = "无效数据";
|
||||
cfg->value = 1+index;
|
||||
|
||||
// show saved information
|
||||
acl_entryid_t id;
|
||||
if( CCHT_OK == get_current_cheat( index, &id ) && ENT_USING(id) )
|
||||
{
|
||||
cfg->extra_text = "开";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_keys( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_text_t text;
|
||||
if( index == 0 )
|
||||
{
|
||||
cfg->text = "不开启";
|
||||
}
|
||||
else
|
||||
{
|
||||
acl_error_t res = acl_entry_get_label(index-1, &text);
|
||||
if( res == ACHTLIB_SUCCESS )
|
||||
cfg->text = text;
|
||||
else cfg->text = "无效数据";
|
||||
}
|
||||
acl_entryid_t eid = (acl_entryid_t)data;
|
||||
cfg->value = index<<16 | eid;
|
||||
|
||||
if( CCHT_OK == include_current_cheat((acl_entryid_t)cfg->value) )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static atp_error_t select_onoff( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_entryid_t eid = (acl_entryid_t)data;
|
||||
eid &= 0xffff;
|
||||
if( index == 0 )
|
||||
{
|
||||
cfg->text = "不开启";
|
||||
cfg->value = eid;
|
||||
}
|
||||
else if( index == 1 )
|
||||
{
|
||||
cfg->text = "开启";
|
||||
cfg->value = 1<<16 | eid;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->text = "调整数值开启[结果未知]";
|
||||
cfg->value = 0;
|
||||
}
|
||||
|
||||
// show saved information
|
||||
if( CCHT_OK == include_current_cheat((acl_entryid_t)cfg->value) )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u16 calc_step( u16 value )
|
||||
{
|
||||
u16 n = value / 50;
|
||||
if( n == 0 ) return 1;
|
||||
else
|
||||
{
|
||||
u16 base = 1;
|
||||
while( n > 10 )
|
||||
{
|
||||
n = n/10;
|
||||
base *= 10;
|
||||
}
|
||||
if( n < 5 ) return base * 5;
|
||||
else return base * 10;
|
||||
}
|
||||
}
|
||||
|
||||
static atp_error_t step_provider( atp_callerdata_t mixid, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
static char number[8];
|
||||
u32 mix = (u32)mixid;
|
||||
u16 max = mix & 0xffff;
|
||||
u16 step = mix >> 16;
|
||||
u16 res = step * (index+1);
|
||||
ee_snprintf( number, 8, "%d", res < max ? res : max );
|
||||
cfg->text = number;
|
||||
cfg->value = res < max ? res : max;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t handle_onoff_entry( acl_entryid_t id, acl_elemlen_t codelen, atp_itemval_t *item )
|
||||
{
|
||||
#define DEFAULT_ONOFF_HANDLER atp_select("选择此项目对应的设置", 2, select_onoff, NULL, (atp_callerdata_t)id, 0, 0, item);
|
||||
#define ONOFF_SAFE_CALLACL( statement ) if( ACHTLIB_SUCCESS != statement ) return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
if( codelen > 4 )// more than 2 address
|
||||
return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
u16 targetval = 0;
|
||||
acl_armcode_t code;
|
||||
|
||||
// one address
|
||||
if( codelen == 2 )
|
||||
{
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(1, &code) );
|
||||
targetval = code & 0xff;
|
||||
}
|
||||
// two addresses
|
||||
else if( codelen == 4 )
|
||||
{
|
||||
u32 addr0, addr1;
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(0, &addr0) );
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(2, &addr1) );
|
||||
if( (addr0 & 1) || (addr0 | 1) != addr1 ) // valid u16 address
|
||||
return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(1, &code) );
|
||||
targetval = code & 0xff;
|
||||
ONOFF_SAFE_CALLACL( acl_entry_get_armcode(3, &code) );
|
||||
targetval |= (code & 0xff) << 8;
|
||||
}
|
||||
// more than two address, should not overwrite values
|
||||
else return DEFAULT_ONOFF_HANDLER;
|
||||
|
||||
atp_error_t res = atp_select( "选择此项目对应的设置", 3, select_onoff, NULL, targetval << 16 | id, 0, 0, item );
|
||||
if( res == ATP_SUCCESS && *item == 0 )
|
||||
{
|
||||
char title[24];
|
||||
ee_snprintf( title, sizeof(title), "默认值:%d", targetval );
|
||||
u16 step = calc_step( targetval );
|
||||
atp_counter_t n = (targetval-1+step)/step;
|
||||
res = atp_select(title, n, step_provider, NULL, (atp_callerdata_t)(step<<16|targetval), n, 0, item );
|
||||
if( res == ATP_SUCCESS && *item != targetval )
|
||||
overwrite_current_cheat( 1<<16|id, *item );
|
||||
|
||||
*item = 1<<16 | id;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
atp_error_t use_cheat_page( const char *serial )
|
||||
{
|
||||
acl_count_t len;
|
||||
if( ACHTLIB_SUCCESS != acl_open_lib( "gba.acl" ) )
|
||||
{
|
||||
return WAIT_ON_ERRPAGE( display_openlib );
|
||||
}
|
||||
if( ACHTLIB_SUCCESS != acl_select_game( serial, 0, &len ) )
|
||||
{
|
||||
acl_close_lib();
|
||||
return WAIT_ON_ERRPAGE( display_selcht );
|
||||
}
|
||||
if( len == 0 )
|
||||
{
|
||||
acl_close_lib();
|
||||
return WAIT_ON_ERRPAGE( display_nocheat );
|
||||
}
|
||||
|
||||
// 显示配置页面
|
||||
atp_error_t res;
|
||||
atp_itemval_t item;
|
||||
acl_elemlen_t cnt;
|
||||
|
||||
uint8_t status = DISP_REGION;
|
||||
atp_counter_t defi = 0;
|
||||
acl_entryid_t eid = 0;
|
||||
atp_text_t oldtips;
|
||||
atp_tips("确定A/返回B", &oldtips);
|
||||
|
||||
while( status != DISP_DONE )
|
||||
{
|
||||
if( status == DISP_REGION )
|
||||
{
|
||||
res = atp_select("请谨慎使用金手指!金手指可能会引起卡顿、死机、损坏存档等现象。 "
|
||||
"选择一个金手指配置:", len, select_region, NULL, NULL, defi, 0, &item );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
defi = item;
|
||||
acl_chtid_t sid;
|
||||
acl_elemlen_t len;
|
||||
u32 ccid, cclen;
|
||||
SAFE_CALLACL( acl_query_cheat_set((acl_index_t)item, &sid, NULL ) );
|
||||
SAFE_CALLACL( acl_select_cheat_set( sid ) );
|
||||
SAFE_CALLACL( acl_select_entry(0, &len) );
|
||||
|
||||
if( CCHT_OK == info_current_cheat(&ccid, &cclen) )
|
||||
{
|
||||
// SKIP the init process when id and len is the same
|
||||
if( ccid != sid || cclen != len )
|
||||
init_current_cheat( sid, len );
|
||||
}
|
||||
else init_current_cheat( sid, len );
|
||||
|
||||
eid = 0;
|
||||
status = DISP_HOLES;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION)
|
||||
{
|
||||
status = DISP_DONE;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_HOLES )
|
||||
{
|
||||
SAFE_CALLACL( acl_select_entry(0, &cnt) );
|
||||
res = atp_select("选择一个金手指项目", cnt, select_holes, NULL, NULL, eid > 0 ? (eid&0xffff)-1 : 0, 0, &item);
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
eid = (acl_entryid_t)item;
|
||||
status = DISP_KEYS;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_REGION;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else // DISP_KEYS
|
||||
{
|
||||
SAFE_CALLACL( acl_select_entry( eid, &cnt ) );
|
||||
if( cnt == 0 )
|
||||
{
|
||||
SAFE_CALLACL( acl_select_entry( 1<<16 | eid, &cnt ) );
|
||||
res = handle_onoff_entry( eid, cnt, &item );
|
||||
}
|
||||
else
|
||||
{
|
||||
res = atp_select("选择此项目对应的设置", cnt, select_keys, NULL, (atp_callerdata_t)eid, 0, 0, &item);
|
||||
}
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
put_current_cheat( (acl_entryid_t)item );
|
||||
status = DISP_HOLES;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_HOLES;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
acl_close_lib();
|
||||
atp_tips( oldtips, NULL );
|
||||
return res;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user