PowerPC: Parametrize CTR macro.

This commit is contained in:
Admiral H. Curtiss 2023-01-10 01:19:56 +01:00
parent 0a343007cb
commit c13ca271d8
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
4 changed files with 10 additions and 9 deletions

View File

@ -441,7 +441,7 @@ static void ReadRegister()
wbe32hex(reply, LR(PowerPC::ppcState)); wbe32hex(reply, LR(PowerPC::ppcState));
break; break;
case 68: case 68:
wbe32hex(reply, CTR); wbe32hex(reply, CTR(PowerPC::ppcState));
break; break;
case 69: case 69:
wbe32hex(reply, PowerPC::ppcState.spr[SPR_XER]); wbe32hex(reply, PowerPC::ppcState.spr[SPR_XER]);
@ -653,7 +653,7 @@ static void WriteRegister()
LR(PowerPC::ppcState) = re32hex(bufptr); LR(PowerPC::ppcState) = re32hex(bufptr);
break; break;
case 68: case 68:
CTR = re32hex(bufptr); CTR(PowerPC::ppcState) = re32hex(bufptr);
break; break;
case 69: case 69:
PowerPC::ppcState.spr[SPR_XER] = re32hex(bufptr); PowerPC::ppcState.spr[SPR_XER] = re32hex(bufptr);

View File

@ -29,12 +29,12 @@ void Interpreter::bx(UGeckoInstruction inst)
void Interpreter::bcx(UGeckoInstruction inst) void Interpreter::bcx(UGeckoInstruction inst)
{ {
if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0) if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
CTR--; CTR(PowerPC::ppcState)--;
const bool true_false = ((inst.BO >> 3) & 1) != 0; const bool true_false = ((inst.BO >> 3) & 1) != 0;
const bool only_counter_check = ((inst.BO >> 4) & 1) != 0; const bool only_counter_check = ((inst.BO >> 4) & 1) != 0;
const bool only_condition_check = ((inst.BO >> 2) & 1) != 0; const bool only_condition_check = ((inst.BO >> 2) & 1) != 0;
const u32 ctr_check = ((CTR != 0) ^ (inst.BO >> 1)) & 1; const u32 ctr_check = ((CTR(PowerPC::ppcState) != 0) ^ (inst.BO >> 1)) & 1;
const bool counter = only_condition_check || ctr_check != 0; const bool counter = only_condition_check || ctr_check != 0;
const bool condition = const bool condition =
only_counter_check || (PowerPC::ppcState.cr.GetBit(inst.BI) == u32(true_false)); only_counter_check || (PowerPC::ppcState.cr.GetBit(inst.BI) == u32(true_false));
@ -65,7 +65,7 @@ void Interpreter::bcctrx(UGeckoInstruction inst)
if (condition != 0) if (condition != 0)
{ {
PowerPC::ppcState.npc = CTR & (~3); PowerPC::ppcState.npc = CTR(PowerPC::ppcState) & (~3);
if (inst.LK_3) if (inst.LK_3)
LR(PowerPC::ppcState) = PowerPC::ppcState.pc + 4; LR(PowerPC::ppcState) = PowerPC::ppcState.pc + 4;
} }
@ -76,9 +76,9 @@ void Interpreter::bcctrx(UGeckoInstruction inst)
void Interpreter::bclrx(UGeckoInstruction inst) void Interpreter::bclrx(UGeckoInstruction inst)
{ {
if ((inst.BO_2 & BO_DONT_DECREMENT_FLAG) == 0) if ((inst.BO_2 & BO_DONT_DECREMENT_FLAG) == 0)
CTR--; CTR(PowerPC::ppcState)--;
const u32 counter = ((inst.BO_2 >> 2) | ((CTR != 0) ^ (inst.BO_2 >> 1))) & 1; const u32 counter = ((inst.BO_2 >> 2) | ((CTR(PowerPC::ppcState) != 0) ^ (inst.BO_2 >> 1))) & 1;
const u32 condition = const u32 condition =
((inst.BO_2 >> 4) | (PowerPC::ppcState.cr.GetBit(inst.BI_2) == ((inst.BO_2 >> 3) & 1))) & 1; ((inst.BO_2 >> 4) | (PowerPC::ppcState.cr.GetBit(inst.BI_2) == ((inst.BO_2 >> 3) & 1))) & 1;

View File

@ -247,7 +247,7 @@ void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst);
#define THRM3(ppc_state) ((UReg_THRM3&)(ppc_state).spr[SPR_THRM3]) #define THRM3(ppc_state) ((UReg_THRM3&)(ppc_state).spr[SPR_THRM3])
#define LR(ppc_state) (ppc_state).spr[SPR_LR] #define LR(ppc_state) (ppc_state).spr[SPR_LR]
#define CTR PowerPC::ppcState.spr[SPR_CTR] #define CTR(ppc_state) (ppc_state).spr[SPR_CTR]
#define rDEC PowerPC::ppcState.spr[SPR_DEC] #define rDEC PowerPC::ppcState.spr[SPR_DEC]
#define SRR0 PowerPC::ppcState.spr[SPR_SRR0] #define SRR0 PowerPC::ppcState.spr[SPR_SRR0]
#define SRR1 PowerPC::ppcState.spr[SPR_SRR1] #define SRR1 PowerPC::ppcState.spr[SPR_SRR1]

View File

@ -471,7 +471,8 @@ static bool WillInstructionReturn(UGeckoInstruction inst)
// Is a rfi instruction // Is a rfi instruction
if (inst.hex == 0x4C000064u) if (inst.hex == 0x4C000064u)
return true; return true;
bool counter = (inst.BO_2 >> 2 & 1) != 0 || (CTR != 0) != ((inst.BO_2 >> 1 & 1) != 0); bool counter =
(inst.BO_2 >> 2 & 1) != 0 || (CTR(PowerPC::ppcState) != 0) != ((inst.BO_2 >> 1 & 1) != 0);
bool condition = bool condition =
inst.BO_2 >> 4 != 0 || PowerPC::ppcState.cr.GetBit(inst.BI_2) == (inst.BO_2 >> 3 & 1); inst.BO_2 >> 4 != 0 || PowerPC::ppcState.cr.GetBit(inst.BI_2) == (inst.BO_2 >> 3 & 1);
bool isBclr = inst.OPCD_7 == 0b010011 && (inst.hex >> 1 & 0b10000) != 0; bool isBclr = inst.OPCD_7 == 0b010011 && (inst.hex >> 1 & 0b10000) != 0;