mirror of https://github.com/mgba-emu/mgba.git
LR35902: Optimize CPU loop to prevent no-op cycles from being calculated
This commit is contained in:
parent
ed94288902
commit
c89c3964db
|
@ -148,8 +148,15 @@ void LR35902Tick(struct LR35902Core* cpu) {
|
|||
}
|
||||
|
||||
void LR35902Run(struct LR35902Core* cpu) {
|
||||
while (cpu->cycles < cpu->nextEvent) {
|
||||
while (true) {
|
||||
_LR35902Step(cpu);
|
||||
if (cpu->cycles >= cpu->nextEvent) {
|
||||
break;
|
||||
} else if (cpu->executionState < LR35902_CORE_EXECUTE) {
|
||||
// Silly hack: keep us from calling step if we know the next step is a no-op
|
||||
++cpu->cycles;
|
||||
++cpu->executionState;
|
||||
}
|
||||
}
|
||||
cpu->irqh.processEvents(cpu);
|
||||
}
|
||||
|
|
|
@ -36,16 +36,16 @@ union FlagRegister {
|
|||
#pragma pack(pop)
|
||||
|
||||
enum LR35902ExecutionState {
|
||||
LR35902_CORE_FETCH = 0,
|
||||
LR35902_CORE_IDLE_0,
|
||||
LR35902_CORE_IDLE_1,
|
||||
LR35902_CORE_EXECUTE = 3,
|
||||
LR35902_CORE_FETCH = 3,
|
||||
LR35902_CORE_IDLE_0 = 0,
|
||||
LR35902_CORE_IDLE_1 = 1,
|
||||
LR35902_CORE_EXECUTE = 2,
|
||||
|
||||
LR35902_CORE_MEMORY_LOAD = 4,
|
||||
LR35902_CORE_MEMORY_STORE = 8,
|
||||
LR35902_CORE_READ_PC = 12,
|
||||
LR35902_CORE_STALL = 16,
|
||||
LR35902_CORE_OP2 = 20
|
||||
LR35902_CORE_MEMORY_LOAD = 7,
|
||||
LR35902_CORE_MEMORY_STORE = 11,
|
||||
LR35902_CORE_READ_PC = 15,
|
||||
LR35902_CORE_STALL = 19,
|
||||
LR35902_CORE_OP2 = 23
|
||||
};
|
||||
|
||||
struct LR35902Memory {
|
||||
|
|
Loading…
Reference in New Issue