mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 17:00:57 +00:00
unicorn/m68k: Lessen usage of M68K_CPU macro
Reduces the amount of line noise (and avoids syntaxically repeating accesses to the environment state)
This commit is contained in:
parent
6cbcf9ce76
commit
047766c908
|
@ -14,7 +14,9 @@ const int M68K_REGS_STORAGE_SIZE = offsetof(CPUM68KState, tlb_table);
|
|||
|
||||
static void m68k_set_pc(struct uc_struct *uc, uint64_t address)
|
||||
{
|
||||
((CPUM68KState *)uc->current_cpu->env_ptr)->pc = address;
|
||||
CPUM68KState *state = uc->cpu->env_ptr;
|
||||
|
||||
state->pc = address;
|
||||
}
|
||||
|
||||
void m68k_release(void* ctx);
|
||||
|
@ -39,20 +41,21 @@ void m68k_reg_reset(struct uc_struct *uc)
|
|||
int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||
{
|
||||
CPUState *mycpu = uc->cpu;
|
||||
CPUM68KState *state = &M68K_CPU(uc, mycpu)->env;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
unsigned int regid = regs[i];
|
||||
void *value = vals[i];
|
||||
if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7)
|
||||
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.aregs[regid - UC_M68K_REG_A0];
|
||||
*(int32_t *)value = state->aregs[regid - UC_M68K_REG_A0];
|
||||
else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7)
|
||||
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.dregs[regid - UC_M68K_REG_D0];
|
||||
*(int32_t *)value = state->dregs[regid - UC_M68K_REG_D0];
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_M68K_REG_PC:
|
||||
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.pc;
|
||||
*(int32_t *)value = state->pc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -64,20 +67,21 @@ int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int cou
|
|||
int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||
{
|
||||
CPUState *mycpu = uc->cpu;
|
||||
CPUM68KState *state = &M68K_CPU(uc, mycpu)->env;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
unsigned int regid = regs[i];
|
||||
const void *value = vals[i];
|
||||
if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7)
|
||||
M68K_CPU(uc, mycpu)->env.aregs[regid - UC_M68K_REG_A0] = *(uint32_t *)value;
|
||||
state->aregs[regid - UC_M68K_REG_A0] = *(uint32_t *)value;
|
||||
else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7)
|
||||
M68K_CPU(uc, mycpu)->env.dregs[regid - UC_M68K_REG_D0] = *(uint32_t *)value;
|
||||
state->dregs[regid - UC_M68K_REG_D0] = *(uint32_t *)value;
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_M68K_REG_PC:
|
||||
M68K_CPU(uc, mycpu)->env.pc = *(uint32_t *)value;
|
||||
state->pc = *(uint32_t *)value;
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
|
|
Loading…
Reference in a new issue