mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-07-05 23:00:33 +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)
|
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);
|
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)
|
int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||||
{
|
{
|
||||||
CPUState *mycpu = uc->cpu;
|
CPUState *mycpu = uc->cpu;
|
||||||
|
CPUM68KState *state = &M68K_CPU(uc, mycpu)->env;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
unsigned int regid = regs[i];
|
unsigned int regid = regs[i];
|
||||||
void *value = vals[i];
|
void *value = vals[i];
|
||||||
if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7)
|
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)
|
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 {
|
else {
|
||||||
switch(regid) {
|
switch(regid) {
|
||||||
default: break;
|
default: break;
|
||||||
case UC_M68K_REG_PC:
|
case UC_M68K_REG_PC:
|
||||||
*(int32_t *)value = M68K_CPU(uc, mycpu)->env.pc;
|
*(int32_t *)value = state->pc;
|
||||||
break;
|
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)
|
int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||||
{
|
{
|
||||||
CPUState *mycpu = uc->cpu;
|
CPUState *mycpu = uc->cpu;
|
||||||
|
CPUM68KState *state = &M68K_CPU(uc, mycpu)->env;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
unsigned int regid = regs[i];
|
unsigned int regid = regs[i];
|
||||||
const void *value = vals[i];
|
const void *value = vals[i];
|
||||||
if (regid >= UC_M68K_REG_A0 && regid <= UC_M68K_REG_A7)
|
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)
|
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 {
|
else {
|
||||||
switch(regid) {
|
switch(regid) {
|
||||||
default: break;
|
default: break;
|
||||||
case UC_M68K_REG_PC:
|
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
|
// force to quit execution and flush TB
|
||||||
uc->quit_request = true;
|
uc->quit_request = true;
|
||||||
uc_emu_stop(uc);
|
uc_emu_stop(uc);
|
||||||
|
|
Loading…
Reference in a new issue