|
|
|
@ -27,7 +27,7 @@ namespace Plip::Core::GameBoy {
|
|
|
|
|
|
|
|
|
|
// Quirk: If IF is written during the interrupt cycle, the
|
|
|
|
|
// written value will override this.
|
|
|
|
|
if(m_lastWrite.address == Plip::Cpu::SharpLr35902::MemInterruptFlag) |
|
|
|
|
if(m_lastWrite.address != Plip::Cpu::SharpLr35902::MemInterruptFlag) |
|
|
|
|
m_cpu->Interrupt(INTERRUPT_TIMER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -59,12 +59,19 @@ namespace Plip::Core::GameBoy {
|
|
|
|
|
|
|
|
|
|
inline void GameBoyInstance::TimerIncreaseTima() { |
|
|
|
|
uint8_t tima = m_ioRegisters->GetByte(m_regTima) + 1; |
|
|
|
|
m_ioRegisters->SetByte(m_regTima, tima); |
|
|
|
|
|
|
|
|
|
if(tima == 0) { |
|
|
|
|
// TIMA overflow.
|
|
|
|
|
m_timerTimaOverflow = true; |
|
|
|
|
if(m_lastWrite.address == m_addrRegisters + m_regTima) { |
|
|
|
|
// Quirk: If TIMA is written to during the cycle that causes it to
|
|
|
|
|
// overflow, the pending reset and interrupt are cancelled.
|
|
|
|
|
tima = m_lastWrite.value; |
|
|
|
|
} else { |
|
|
|
|
// TIMA overflow.
|
|
|
|
|
m_timerTimaOverflow = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m_ioRegisters->SetByte(m_regTima, tima); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GameBoyInstance::TimerTima() { |
|
|
|
@ -86,13 +93,6 @@ namespace Plip::Core::GameBoy {
|
|
|
|
|
TimerIncreaseTima(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(m_lastWrite.address == m_addrRegisters + m_regTima && m_timerTimaOverflow) { |
|
|
|
|
// Quirk: If TIMA is written to during the cycle that causes it to
|
|
|
|
|
// overflow, the pending reset and interrupt are cancelled.
|
|
|
|
|
m_timerTimaOverflow = false; |
|
|
|
|
m_ioRegisters->SetByte(m_regTima, m_lastWrite.value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m_timerTacLast = tac; |
|
|
|
|
|
|
|
|
|
// Write TAC back into memory to ensure that only the low 3 bits are set.
|
|
|
|
|