mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 22:04:10 +08:00
暂时提交用于后续对比修改
This commit is contained in:
parent
da04e14d52
commit
30cb8eec81
@ -2,6 +2,7 @@
|
|||||||
#define _CHEAT_H_
|
#define _CHEAT_H_
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "arm11/acl.h"
|
||||||
|
|
||||||
typedef int cheat_error_t;
|
typedef int cheat_error_t;
|
||||||
|
|
||||||
@ -9,6 +10,9 @@ typedef int cheat_error_t;
|
|||||||
#define CCHT_NO_SPACE 1
|
#define CCHT_NO_SPACE 1
|
||||||
#define CCHT_NO_IRQ 2
|
#define CCHT_NO_IRQ 2
|
||||||
#define CCHT_NO_CHEAT 3
|
#define CCHT_NO_CHEAT 3
|
||||||
|
#define CCHT_NO_MEM 4
|
||||||
|
#define CCHT_NOT_INIT 5
|
||||||
|
#define CCHT_INVALID 6
|
||||||
|
|
||||||
#define CHEAT_MODE_DISABLED 0
|
#define CHEAT_MODE_DISABLED 0
|
||||||
#define CHEAT_MODE_FULLTIME 1
|
#define CHEAT_MODE_FULLTIME 1
|
||||||
@ -16,9 +20,11 @@ typedef int cheat_error_t;
|
|||||||
#define CHEAT_MODE_KEYONOFF 3
|
#define CHEAT_MODE_KEYONOFF 3
|
||||||
#define CHEAT_MODE_SIZE 3
|
#define CHEAT_MODE_SIZE 3
|
||||||
|
|
||||||
cheat_error_t init_current_cheat( u32 id, u32 len );
|
#define MAKE_ENTID(hole, key) ((key+1)<<16|(hole+1))
|
||||||
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 init_current_cheat( u32 id, u16 len );
|
||||||
|
cheat_error_t put_current_cheat( acl_entryid_t entry_id );
|
||||||
|
cheat_error_t get_current_cheat( u32 *id, u32 *len, void **entry_array );
|
||||||
cheat_error_t fini_current_cheat();
|
cheat_error_t fini_current_cheat();
|
||||||
|
|
||||||
cheat_error_t push_current_cheat( const char *filename, int is_using );
|
cheat_error_t push_current_cheat( const char *filename, int is_using );
|
||||||
|
@ -9,13 +9,63 @@
|
|||||||
typedef u32 instruction_t;
|
typedef u32 instruction_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 chtId;
|
u32 chtId; // acl_chtid_t
|
||||||
u16 entLen;
|
u16 entLen; // entArr.length
|
||||||
acl_index_t *entArr;
|
acl_index_t *entArr; // 下标表示hole,值表示key
|
||||||
} CurrentCheat;
|
} CurrentCheat;
|
||||||
|
|
||||||
static CurrentCheat setting = {0, 0, NULL};
|
static CurrentCheat setting = {0, 0, NULL};
|
||||||
|
|
||||||
|
cheat_error_t init_current_cheat( u32 id, u16 len )
|
||||||
|
{
|
||||||
|
if( setting.entArr ) fini_current_cheat();
|
||||||
|
if( id == 0 ) return CCHT_OK;
|
||||||
|
|
||||||
|
setting.chtId = id;
|
||||||
|
setting.entLen = len;
|
||||||
|
if( len )
|
||||||
|
{
|
||||||
|
acl_index_t *p = (acl_index_t*)malloc( len * sizeof(acl_index_t) );
|
||||||
|
if( p == NULL ) return CCHT_NO_MEM;
|
||||||
|
memset(p, 0, len*sizeof(acl_index_t));
|
||||||
|
setting.entArr = p;
|
||||||
|
}
|
||||||
|
return CCHT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheat_error_t put_current_cheat( acl_entryid_t entid )
|
||||||
|
{
|
||||||
|
if( setting.chtId == 0 ) return CCHT_NOT_INIT;
|
||||||
|
u16 index = entid & 0xffff;
|
||||||
|
u16 option = entid >> 16;
|
||||||
|
if( index == 0 ) return CCHT_INVALID;
|
||||||
|
|
||||||
|
if( index <= setting.entLen )
|
||||||
|
{
|
||||||
|
setting.entArr[index-1] = option;
|
||||||
|
return CCHT_OK;
|
||||||
|
}
|
||||||
|
else return CCHT_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheat_error_t get_current_cheat( u32 *id, u32 *len, void **entry_array )
|
||||||
|
{
|
||||||
|
if( setting.chtId == 0 ) return CCHT_NOT_INIT;
|
||||||
|
*id = setting.chtId;
|
||||||
|
*len = setting.entLen;
|
||||||
|
*entry_array = setting.entArr;
|
||||||
|
return CCHT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheat_error_t fini_current_cheat()
|
||||||
|
{
|
||||||
|
if( setting.entArr ) free( setting.entArr );
|
||||||
|
setting.entArr = NULL;
|
||||||
|
setting.entLen = 0;
|
||||||
|
setting.chtId = 0;
|
||||||
|
return CCHT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
typedef instruction_t* CodeLocation;
|
typedef instruction_t* CodeLocation;
|
||||||
#define CodeAtLocation(p) (*p)
|
#define CodeAtLocation(p) (*p)
|
||||||
|
|
||||||
@ -25,7 +75,7 @@ typedef instruction_t* CodeLocation;
|
|||||||
|
|
||||||
#define GBACPU_PREFETCH 2
|
#define GBACPU_PREFETCH 2
|
||||||
#define GBACPU_PREFETCH_BYTE (sizeof(instruction_t)*GBACPU_PREFETCH)
|
#define GBACPU_PREFETCH_BYTE (sizeof(instruction_t)*GBACPU_PREFETCH)
|
||||||
#define MAKE_ENT(lock, key) ((key+1)<<16|(lock+1))
|
#define MAKE_ENT(hole,key) ((key<<16) | hole)
|
||||||
|
|
||||||
const instruction_t HOOKPOINT_INSTR[] = {
|
const instruction_t HOOKPOINT_INSTR[] = {
|
||||||
0xe92d8000, // STMDB sp!, {pc}
|
0xe92d8000, // STMDB sp!, {pc}
|
||||||
@ -321,7 +371,7 @@ static void rom_append_cheatproc( int mode, CodeLocation start, u16 bindkey, u32
|
|||||||
*start++ = 0;
|
*start++ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cheat_error_t apply_cheat( int mode, u32 szrom )
|
cheat_error_t apply_cheat( int mode, u32 szrom, u16 bindkey, u32 storagemem )
|
||||||
{
|
{
|
||||||
// try ignore patch
|
// try ignore patch
|
||||||
if( mode == CHEAT_MODE_DISABLED ) return CCHT_OK;
|
if( mode == CHEAT_MODE_DISABLED ) return CCHT_OK;
|
||||||
@ -345,7 +395,7 @@ cheat_error_t apply_cheat( int mode, u32 szrom )
|
|||||||
|
|
||||||
// patching the rom
|
// patching the rom
|
||||||
rom_append_newirq( page, hookpoint, n_hookpoint );
|
rom_append_newirq( page, hookpoint, n_hookpoint );
|
||||||
rom_patch_hookpoint( page, hookpoint, n_hookpoint ); // FIXME: romdata+realend
|
rom_patch_hookpoint( page, hookpoint, n_hookpoint );
|
||||||
rom_append_cheatproc( mode, page + n_hookpoint * IW_INSTR_LEN );
|
rom_append_cheatproc( mode, page + n_hookpoint * IW_INSTR_LEN, bindkey, storagemem );
|
||||||
return CCHT_OK;
|
return CCHT_OK;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user