mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-08 23:04:13 +08:00
实现插值替换的代码
This commit is contained in:
parent
ad1962892c
commit
fc7c12c257
@ -19,10 +19,11 @@ typedef instruction_t* CodeLocation;
|
||||
typedef struct {
|
||||
u32 chtId; // acl_chtid_t
|
||||
u16 entLen; // entArr.length
|
||||
acl_index_t *entArr; // 下标表示hole,值表示key
|
||||
acl_index_t *entArr; // 下标表示hole,值表示key *改为分两段,前段key,后段overwrite value
|
||||
} CurrentCheat;
|
||||
|
||||
static CurrentCheat setting = {0, 0, NULL};
|
||||
#define CCHT_OVERWRITE(c) (&c.entArr[c.entLen])
|
||||
|
||||
cheat_error_t init_current_cheat( u32 id, u16 len )
|
||||
{
|
||||
@ -33,9 +34,9 @@ cheat_error_t init_current_cheat( u32 id, u16 len )
|
||||
setting.entLen = len;
|
||||
if( len )
|
||||
{
|
||||
acl_index_t *p = (acl_index_t*)malloc( len * sizeof(acl_index_t) );
|
||||
acl_index_t *p = (acl_index_t*)malloc( len * sizeof(acl_index_t) * 2 );
|
||||
if( p == NULL ) return CCHT_NO_MEM;
|
||||
memset(p, 0, len*sizeof(acl_index_t));
|
||||
memset(p, 0, len*sizeof(acl_index_t)*2);
|
||||
setting.entArr = p;
|
||||
}
|
||||
return CCHT_OK;
|
||||
@ -56,6 +57,23 @@ cheat_error_t put_current_cheat( acl_entryid_t entid )
|
||||
else return CCHT_INVALID;
|
||||
}
|
||||
|
||||
cheat_error_t overwrite_current_cheat( acl_entryid_t id, u16 value )
|
||||
{
|
||||
if( setting.chtId == 0 ) return CCHT_NOT_INIT;
|
||||
|
||||
u16 index = ENT_HOLE(id);
|
||||
u16 option = ENT_KEY(id);
|
||||
if( index == 0 ) return CCHT_INVALID;
|
||||
|
||||
if( index <= setting.entLen )
|
||||
{
|
||||
u16 *valarr = CCHT_OVERWRITE(setting);
|
||||
valarr[index-1] = value;
|
||||
return CCHT_OK;
|
||||
}
|
||||
else return CCHT_INVALID;
|
||||
}
|
||||
|
||||
cheat_error_t info_current_cheat( u32 *id, u32 *len )
|
||||
{
|
||||
if( setting.chtId == 0 ) return CCHT_NOT_INIT;
|
||||
@ -76,11 +94,6 @@ cheat_error_t get_current_cheat( u32 index, acl_entryid_t *id )
|
||||
else return CCHT_INVALID;
|
||||
}
|
||||
|
||||
cheat_error_t overwrite_current_cheat( acl_entryid_t id, u16 value )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
cheat_error_t include_current_cheat( acl_entryid_t id )
|
||||
{
|
||||
if( setting.chtId == 0 ) return CCHT_NOT_INIT;
|
||||
@ -408,6 +421,7 @@ static void rom_append_cheatproc( int mode, CodeLocation start, u16 bindkey, u32
|
||||
memcpy( start, MEM_OVERWRITE_INSTR, MO_INSTR_SIZE );
|
||||
start += MO_INSTR_LEN;
|
||||
|
||||
u16 overwrite = CCHT_OVERWRITE(setting);
|
||||
for( int i=0; i < setting.entLen; ++i )
|
||||
{
|
||||
u16 val = setting.entArr[i];
|
||||
@ -415,9 +429,17 @@ static void rom_append_cheatproc( int mode, CodeLocation start, u16 bindkey, u32
|
||||
{
|
||||
acl_elemlen_t len;
|
||||
acl_select_entry( MAKE_ENT(i+1, val), &len );
|
||||
val = overwrite[i];
|
||||
for( int j=0; j < len; ++j )
|
||||
{
|
||||
acl_entry_get_armcode(j, start++);
|
||||
if( (val > 0) && (j & 1) )
|
||||
{
|
||||
acl_armcode_t temp;
|
||||
acl_entry_get_armcode(j, &temp);
|
||||
*start++ = (temp & ~(0xff)) | (val & 0xff);
|
||||
val >>= 8;
|
||||
}
|
||||
else acl_entry_get_armcode(j, start++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user