mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-08 23:04:13 +08:00
Merge branch 'dev_cheat' of https://gitee.com/anod/open_agb_firm into dev_cheat
This commit is contained in:
commit
ef37f8e04c
22
include/arm11/cheat.h
Normal file
22
include/arm11/cheat.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef _CHEAT_H_
|
||||||
|
#define _CHEAT_H_
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
typedef int cheat_error_t;
|
||||||
|
|
||||||
|
#define CCHT_OK 0
|
||||||
|
|
||||||
|
cheat_error_t init_current_cheat( u32 id, u32 len );
|
||||||
|
cheat_error_t put_current_cheat( u32 index, u32 entry_id );
|
||||||
|
cheat_error_t get_current_cheat( u32 *id, u32 *len, u32 *entry_array );
|
||||||
|
cheat_error_t fini_current_cheat();
|
||||||
|
|
||||||
|
cheat_error_t push_current_cheat( const char *filename, int is_using );
|
||||||
|
cheat_error_t pop_current_cheat( const char *filename, u32 chtid );
|
||||||
|
cheat_error_t chtid_current_cheat( const char *filename, u32 *pointer_id );
|
||||||
|
cheat_error_t chtlst_current_cheat( const char *filename, u8 pointer_data[256] );
|
||||||
|
|
||||||
|
cheat_error_t apply_cheat( int mode, int szrom );
|
||||||
|
|
||||||
|
#endif//_CHEAT_H_
|
@ -20,6 +20,4 @@
|
|||||||
|
|
||||||
#include "error_codes.h"
|
#include "error_codes.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Result browseFiles(const char *const basePath, char selected[512]);
|
Result browseFiles(const char *const basePath, char selected[512]);
|
||||||
|
7
source/arm11/cheat.c
Normal file
7
source/arm11/cheat.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "arm11/cheat.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u32 chtId;
|
||||||
|
u8 entLen;
|
||||||
|
u32 *entArr;
|
||||||
|
} CurrentCheat;
|
@ -29,6 +29,7 @@
|
|||||||
#include "arm11/acf.h"
|
#include "arm11/acf.h"
|
||||||
#include "arm11/atp.h"
|
#include "arm11/atp.h"
|
||||||
#include "arm11/acl.h"
|
#include "arm11/acl.h"
|
||||||
|
#include "arm11/cheat.h"
|
||||||
|
|
||||||
#define screenClean() memset(consoleGet()->frameBuffer, 0, CWIDTH*CHEIGHT*sizeof(uint16_t))
|
#define screenClean() memset(consoleGet()->frameBuffer, 0, CWIDTH*CHEIGHT*sizeof(uint16_t))
|
||||||
|
|
||||||
@ -235,11 +236,13 @@ static atp_error_t disp_str( atp_callerdata_t data, atp_counter_t, atp_linecfg_t
|
|||||||
}
|
}
|
||||||
#define DEBUG( str ) atp_show(1, disp_str, str)
|
#define DEBUG( str ) atp_show(1, disp_str, str)
|
||||||
|
|
||||||
static atp_error_t select_region( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *config )
|
static atp_error_t select_region( atp_callerdata_t *dat, atp_counter_t index, atp_itemcfg_t *config )
|
||||||
{
|
{
|
||||||
static char text[16];
|
static char text[16];
|
||||||
|
u32 id = *(u32*)dat;
|
||||||
acl_region_t sreg;
|
acl_region_t sreg;
|
||||||
if( ACHTLIB_SUCCESS != acl_query_cheat_set(index, NULL, &sreg) )
|
acl_chtid_t sid;
|
||||||
|
if( ACHTLIB_SUCCESS != acl_query_cheat_set(index, &sid, &sreg) )
|
||||||
{
|
{
|
||||||
config->text = "无效数据";
|
config->text = "无效数据";
|
||||||
config->value = index;
|
config->value = index;
|
||||||
@ -262,6 +265,8 @@ static atp_error_t select_region( atp_callerdata_t, atp_counter_t index, atp_ite
|
|||||||
ee_sprintf(text, "%c-%s", 'A'+(char)index, t);
|
ee_sprintf(text, "%c-%s", 'A'+(char)index, t);
|
||||||
config->text = text;
|
config->text = text;
|
||||||
config->value = index;
|
config->value = index;
|
||||||
|
config->extra_text = sid == id ? "已启用" : "未启用";
|
||||||
|
config->extra_text_color = sid == id ? ATP_COLOR_GREEN : ATP_COLOR_LIGHT;
|
||||||
return ATP_SUCCESS;
|
return ATP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,17 +386,25 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a
|
|||||||
uint8_t status = DISP_REGION;
|
uint8_t status = DISP_REGION;
|
||||||
atp_counter_t defi = 0;
|
atp_counter_t defi = 0;
|
||||||
acl_entryid_t eid = 0;
|
acl_entryid_t eid = 0;
|
||||||
|
char cheat_cfg_file[9];
|
||||||
|
strncpy(cheat_cfg_file, serial, 4);
|
||||||
|
strcpy(cheat_cfg_file+4, ".cht");
|
||||||
|
cheat_cfg_file[8] = '\0';
|
||||||
while( status != DISP_DONE )
|
while( status != DISP_DONE )
|
||||||
{
|
{
|
||||||
if( status == DISP_REGION )
|
if( status == DISP_REGION )
|
||||||
{
|
{
|
||||||
res = atp_select("选择一个金手指配置", len, select_region, NULL, NULL, defi, 0, &item );
|
u8 all_cheat_ids[256];
|
||||||
|
chtlst_current_cheat( cheat_cfg_file, all_cheat_ids );
|
||||||
|
chtid_current_cheat( cheat_cfg_file, all_cheat_ids + sizeof(all_cheat_ids)-sizeof(u32) );
|
||||||
|
res = atp_select("选择一个金手指配置", len, select_region, NULL, all_cheat_ids, defi, 0, &item );
|
||||||
if( res == ATP_SUCCESS )
|
if( res == ATP_SUCCESS )
|
||||||
{
|
{
|
||||||
defi = item;
|
defi = item;
|
||||||
acl_chtid_t sid;
|
acl_chtid_t sid;
|
||||||
acl_query_cheat_set((acl_index_t)item, &sid, NULL );
|
acl_query_cheat_set((acl_index_t)item, &sid, NULL );
|
||||||
acl_select_cheat_set( sid );
|
acl_select_cheat_set( sid );
|
||||||
|
pop_current_cheat( cheat_cfg_file, sid );
|
||||||
eid = 0;
|
eid = 0;
|
||||||
status = DISP_HOLES;
|
status = DISP_HOLES;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,12 @@
|
|||||||
#define SAVE_POLICY_POPUP 3
|
#define SAVE_POLICY_POPUP 3
|
||||||
#define SAVE_POLICY_SIZE 4
|
#define SAVE_POLICY_SIZE 4
|
||||||
|
|
||||||
|
#define CHEAT_MODE_DISABLED 0
|
||||||
|
#define CHEAT_MODE_FULLTIME 1
|
||||||
|
#define CHEAT_MODE_ENABYKEY 2
|
||||||
|
#define CHEAT_MODE_KEYONOFF 3
|
||||||
|
#define CHEAT_MODE_SIZE 3
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// [general]
|
// [general]
|
||||||
@ -90,6 +96,8 @@ typedef struct
|
|||||||
|
|
||||||
// [by-anod]
|
// [by-anod]
|
||||||
u8 savePolicy;
|
u8 savePolicy;
|
||||||
|
u8 cheatMode;
|
||||||
|
u16 cheatKeys;
|
||||||
} OafConfig;
|
} OafConfig;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -100,7 +108,6 @@ typedef struct
|
|||||||
u32 attr;
|
u32 attr;
|
||||||
} GameDbEntry;
|
} GameDbEntry;
|
||||||
|
|
||||||
|
|
||||||
// Default config.
|
// Default config.
|
||||||
static OafConfig g_oafConfig =
|
static OafConfig g_oafConfig =
|
||||||
{
|
{
|
||||||
@ -125,6 +132,8 @@ static OafConfig g_oafConfig =
|
|||||||
|
|
||||||
// [by-anod]
|
// [by-anod]
|
||||||
, SAVE_POLICY_GBADB // savePolicy
|
, SAVE_POLICY_GBADB // savePolicy
|
||||||
|
, 0 // cheatMode
|
||||||
|
, KEY_L|KEY_R|KEY_DOWN|KEY_SELECT
|
||||||
};
|
};
|
||||||
static KHandle g_frameReadyEvent = 0;
|
static KHandle g_frameReadyEvent = 0;
|
||||||
|
|
||||||
@ -135,9 +144,11 @@ atp_text_t config_help[] =
|
|||||||
{
|
{
|
||||||
"全局参数编辑操作指引",
|
"全局参数编辑操作指引",
|
||||||
"~ ~ ~ ~ ~ ~ ~",
|
"~ ~ ~ ~ ~ ~ ~",
|
||||||
"修改后的全局参数保存在config.ini",
|
"-修改后的全局参数保存在config.ini",
|
||||||
"保存修改时,存档方案的修改不会保存",
|
"保存修改时,存档方案的修改不会保存",
|
||||||
"~ ~ ~ ~ ~ ~ ~",
|
"~ ~ ~ ~ ~ ~ ~",
|
||||||
|
"-金手指组合键为下方向+L+R+SELECT",
|
||||||
|
"~ ~ ~ ~ ~ ~ ~",
|
||||||
"上下方向键 切换参数项目",
|
"上下方向键 切换参数项目",
|
||||||
"左右方向键 翻页",
|
"左右方向键 翻页",
|
||||||
"L键和R键 调整当前参数",
|
"L键和R键 调整当前参数",
|
||||||
@ -157,7 +168,9 @@ atp_text_t CONFIG_OUTPUT = "[general]\n" \
|
|||||||
"brightness=0.0\n\n" \
|
"brightness=0.0\n\n" \
|
||||||
"[advanced]\n" \
|
"[advanced]\n" \
|
||||||
"saveOverride=false\n" \
|
"saveOverride=false\n" \
|
||||||
"defaultSave=14";
|
"defaultSave=14\n" \
|
||||||
|
"[by-anod]\n" \
|
||||||
|
"cheatMode=%d";
|
||||||
|
|
||||||
extern atp_error_t help_page( atp_text_t *wording, atp_counter_t length );
|
extern atp_error_t help_page( atp_text_t *wording, atp_counter_t length );
|
||||||
|
|
||||||
@ -168,6 +181,7 @@ static atp_error_t config_item( atp_callerdata_t, atp_counter_t index, atp_itemc
|
|||||||
{
|
{
|
||||||
const char *scaler_val[] = {"上屏无缩放", "上屏GPU放大", "上屏DMA放大", "下屏无缩放"};
|
const char *scaler_val[] = {"上屏无缩放", "上屏GPU放大", "上屏DMA放大", "下屏无缩放"};
|
||||||
const char *savetype_name[] = {"和卡带序列号一致", "读取ROM的特定标记", "汉化带SRAM补丁", "自行决定"};
|
const char *savetype_name[] = {"和卡带序列号一致", "读取ROM的特定标记", "汉化带SRAM补丁", "自行决定"};
|
||||||
|
const char *cheatmode_name[] = {"关闭金手指", "全程激活", "组合键单次激活", "组合键激活/关闭"};
|
||||||
static char buf[16];
|
static char buf[16];
|
||||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||||
if( index == 0 )
|
if( index == 0 )
|
||||||
@ -193,6 +207,11 @@ static atp_error_t config_item( atp_callerdata_t, atp_counter_t index, atp_itemc
|
|||||||
cfg->text = "存档方案";
|
cfg->text = "存档方案";
|
||||||
cfg->extra_text = savetype_name[g_oafConfig.savePolicy];
|
cfg->extra_text = savetype_name[g_oafConfig.savePolicy];
|
||||||
}
|
}
|
||||||
|
else if( index == 4 )
|
||||||
|
{
|
||||||
|
cfg->text = "激活金手指";
|
||||||
|
cfg->extra_text = cheatmode_name[g_oafConfig.cheatMode];
|
||||||
|
}
|
||||||
cfg->value = index;
|
cfg->value = index;
|
||||||
return ATP_SUCCESS;
|
return ATP_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -221,6 +240,7 @@ static atp_pageopt_t config_adjust( atp_callerdata_t, atp_counter_t index, atp_b
|
|||||||
else if( index == 1 ) g_oafConfig.directBoot = !g_oafConfig.directBoot;
|
else if( index == 1 ) g_oafConfig.directBoot = !g_oafConfig.directBoot;
|
||||||
else if( index == 2 ) g_oafConfig.scaler = ( SCALER_SIZE + ( g_oafConfig.scaler+(l?-1:1) ) ) % SCALER_SIZE;
|
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( index == 3 ) g_oafConfig.savePolicy = ( SAVE_POLICY_SIZE + ( g_oafConfig.savePolicy+(l?-1:1) ) ) % SAVE_POLICY_SIZE;
|
||||||
|
else if( index == 4 ) g_oafConfig.cheatMode = ( CHEAT_MODE_SIZE + (g_oafConfig.cheatMode+(l?-1:1) ) ) % CHEAT_MODE_SIZE;
|
||||||
}
|
}
|
||||||
else if( start )
|
else if( start )
|
||||||
{
|
{
|
||||||
@ -236,7 +256,7 @@ static atp_pageopt_t config_adjust( atp_callerdata_t, atp_counter_t index, atp_b
|
|||||||
|
|
||||||
ee_snprintf(
|
ee_snprintf(
|
||||||
data, len, CONFIG_OUTPUT,
|
data, len, CONFIG_OUTPUT,
|
||||||
g_oafConfig.backlight, g_oafConfig.directBoot ? "true":"false", g_oafConfig.scaler
|
g_oafConfig.backlight, g_oafConfig.directBoot ? "true":"false", g_oafConfig.scaler, g_oafConfig.cheatMode
|
||||||
);
|
);
|
||||||
fsQuickWrite("config.ini", data, strlen(data));
|
fsQuickWrite("config.ini", data, strlen(data));
|
||||||
free( data );
|
free( data );
|
||||||
@ -823,6 +843,12 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
|
|||||||
if(strcmp(name, "defaultSave") == 0)
|
if(strcmp(name, "defaultSave") == 0)
|
||||||
config->defaultSave = (u16)strtoul(value, NULL, 10);
|
config->defaultSave = (u16)strtoul(value, NULL, 10);
|
||||||
}
|
}
|
||||||
|
else if(strcmp(section, "by-anod") == 0)
|
||||||
|
{
|
||||||
|
if( strcmp(name, "cheatMode") == 0 )
|
||||||
|
config->cheatMode = (u8)strtoul(value, NULL, 10);
|
||||||
|
if( config->cheatMode > CHEAT_MODE_SIZE ) config->cheatMode = CHEAT_MODE_DISABLED;
|
||||||
|
}
|
||||||
else return 0; // Error.
|
else return 0; // Error.
|
||||||
|
|
||||||
return 1; // 1 is no error? Really?
|
return 1; // 1 is no error? Really?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user