CPU: Allow move instructions to be interrupted by an IRQ/NMI
+ Implemented WAI instruction
This commit is contained in:
parent
28a151e00d
commit
e321b247ac
1 changed files with 32 additions and 34 deletions
|
@ -655,11 +655,10 @@ Move operations
|
|||
****************/
|
||||
void Cpu::MVN()
|
||||
{
|
||||
#ifndef DUMMYCPU
|
||||
_state.DBR = _operand & 0xFF;
|
||||
uint32_t destBank = _state.DBR << 16;
|
||||
uint32_t srcBank = (_operand << 8) & 0xFF0000;
|
||||
do {
|
||||
|
||||
uint8_t value = ReadData(srcBank | _state.X);
|
||||
Write(destBank | _state.Y, value);
|
||||
|
||||
|
@ -670,23 +669,19 @@ void Cpu::MVN()
|
|||
_state.Y++;
|
||||
_state.A--;
|
||||
|
||||
|
||||
if(_state.A != 0xFFFF) {
|
||||
//"Idle" cycles, instruction re-reads OP code and operands before every new byte
|
||||
Read((_state.K << 16) | (_state.PC - 3), MemoryOperationType::Read);
|
||||
Read((_state.K << 16) | (_state.PC - 2), MemoryOperationType::Read);
|
||||
Read((_state.K << 16) | (_state.PC - 1), MemoryOperationType::Read);
|
||||
//Operation isn't done, set the PC back to the start of the instruction
|
||||
_state.PC -= 3;
|
||||
}
|
||||
} while(_state.A != 0xFFFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Cpu::MVP()
|
||||
{
|
||||
#ifndef DUMMYCPU
|
||||
_state.DBR = _operand & 0xFF;
|
||||
uint32_t destBank = _state.DBR << 16;
|
||||
uint32_t srcBank = (_operand << 8) & 0xFF0000;
|
||||
do {
|
||||
|
||||
uint8_t value = ReadData(srcBank | _state.X);
|
||||
Write(destBank | _state.Y, value);
|
||||
|
||||
|
@ -698,13 +693,9 @@ void Cpu::MVP()
|
|||
_state.A--;
|
||||
|
||||
if(_state.A != 0xFFFF) {
|
||||
//"Idle" cycles, instruction re-reads OP code and operands before every new byte
|
||||
Read((_state.K << 16) | (_state.PC - 3), MemoryOperationType::Read);
|
||||
Read((_state.K << 16) | (_state.PC - 2), MemoryOperationType::Read);
|
||||
Read((_state.K << 16) | (_state.PC - 1), MemoryOperationType::Read);
|
||||
//Operation isn't done, set the PC back to the start of the instruction
|
||||
_state.PC -= 3;
|
||||
}
|
||||
} while(_state.A != 0xFFFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************
|
||||
|
@ -1090,7 +1081,14 @@ void Cpu::STP()
|
|||
|
||||
void Cpu::WAI()
|
||||
{
|
||||
#ifndef DUMMYCPU
|
||||
//Wait for interrupt
|
||||
while(!_irqSource && !_nmiFlag) {
|
||||
_memoryManager->IncrementMasterClockValue<4>();
|
||||
}
|
||||
Idle();
|
||||
Idle();
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************
|
||||
|
|
Loading…
Add table
Reference in a new issue