Delay computing accurate value of count.

Instead, just bump the counter and don't track cycle count. When
it comes time to use count, shift it to the right by one instead.
This commit is contained in:
Tyler Stachecki 2014-11-14 21:04:03 -05:00
parent 8912b4cc50
commit 85654a891f
3 changed files with 18 additions and 5 deletions

View file

@ -61,7 +61,14 @@ int VR4300_DMFC0(struct vr4300 *vr4300,
unsigned dest = GET_RT(iw);
unsigned src = GET_RD(iw);
exdc_latch->result = mask_reg(src, vr4300->regs[32 + src]);
if (src == (VR4300_CP0_REGISTER_COUNT - 32)) {
exdc_latch->result = (uint32_t)
(vr4300->regs[VR4300_CP0_REGISTER_COUNT] >> 1);
}
else
exdc_latch->result = mask_reg(src, vr4300->regs[32 + src]);
exdc_latch->dest = dest;
return 0;
}
@ -128,7 +135,14 @@ int VR4300_MFC0(struct vr4300 *vr4300,
unsigned dest = GET_RT(iw);
unsigned src = GET_RD(iw);
exdc_latch->result = mask_reg(src, vr4300->regs[32 + src]);
if (src == (VR4300_CP0_REGISTER_COUNT - 32)) {
exdc_latch->result = (uint32_t)
(vr4300->regs[VR4300_CP0_REGISTER_COUNT] >> 1);
}
else
exdc_latch->result = mask_reg(src, vr4300->regs[32 + src]);
exdc_latch->dest = (int32_t) dest;
return 0;
}

View file

@ -100,7 +100,6 @@ struct vr4300 {
struct vr4300_cp1 cp1;
struct bus_controller *bus;
unsigned long long cycles;
unsigned signals;
uint64_t regs[NUM_VR4300_REGISTERS];

View file

@ -429,9 +429,9 @@ void vr4300_cycle(struct vr4300 *vr4300) {
struct vr4300_pipeline *pipeline = &vr4300->pipeline;
// Increment counters.
vr4300->regs[VR4300_CP0_REGISTER_COUNT] += ++(vr4300->cycles) & 0x1;
vr4300->regs[VR4300_CP0_REGISTER_COUNT]++;
if ((uint32_t) vr4300->regs[VR4300_CP0_REGISTER_COUNT] ==
if ((uint32_t) (vr4300->regs[VR4300_CP0_REGISTER_COUNT] >> 1) ==
(uint32_t) vr4300->regs[VR4300_CP0_REGISTER_COMPARE])
vr4300->regs[VR4300_CP0_REGISTER_CAUSE] |= 0x8000;