mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-04-26 21:18:36 +00:00
Looks like the stray tick in the 6502 step method wasn't stray after all!
This commit is contained in:
1 parent
70c316fd4f
commit
22f337569d
2 files changed
+19
-2
No files matched your search
@@ -84,7 +84,7 @@ public:
|
|||||||
[[nodiscard]] constexpr auto cycles() const noexcept { return m_cycles; }
|
[[nodiscard]] constexpr auto cycles() const noexcept { return m_cycles; }
|
||||||
[[nodiscard]] constexpr auto valid() const noexcept { return m_valid; }
|
[[nodiscard]] constexpr auto valid() const noexcept { return m_valid; }
|
||||||
[[nodiscard]] constexpr auto invalid() const noexcept { return !valid(); }
|
[[nodiscard]] constexpr auto invalid() const noexcept { return !valid(); }
|
||||||
[[nodiscard]] constexpr auto unimplemented() const noexcept { return invalid() && m_cycle_count_mismatch && (cycles() == 0); }
|
[[nodiscard]] constexpr auto unimplemented() const noexcept { return invalid() && m_cycle_count_mismatch && (cycles() == 1); }
|
||||||
[[nodiscard]] constexpr auto implemented() const noexcept { return !unimplemented(); }
|
[[nodiscard]] constexpr auto implemented() const noexcept { return !unimplemented(); }
|
||||||
|
|
||||||
[[nodiscard]] constexpr const auto& messages() const noexcept { return m_messages; }
|
[[nodiscard]] constexpr const auto& messages() const noexcept { return m_messages; }
|
||||||
|
|||||||
+18
-1
@@ -21,25 +21,42 @@ DEFINE_PIN_LEVEL_CHANGERS(RDY, MOS6502)
|
|||||||
DEFINE_PIN_LEVEL_CHANGERS(RW, MOS6502)
|
DEFINE_PIN_LEVEL_CHANGERS(RW, MOS6502)
|
||||||
|
|
||||||
int EightBit::MOS6502::step() noexcept {
|
int EightBit::MOS6502::step() noexcept {
|
||||||
|
|
||||||
resetCycles();
|
resetCycles();
|
||||||
|
|
||||||
ExecutingInstruction.fire(*this);
|
ExecutingInstruction.fire(*this);
|
||||||
if (LIKELY(powered())) {
|
if (LIKELY(powered())) {
|
||||||
|
|
||||||
|
tick(); // A cycle is used, whether or RDY is high or not
|
||||||
|
|
||||||
if (UNLIKELY(lowered(SO())))
|
if (UNLIKELY(lowered(SO())))
|
||||||
handleSO();
|
handleSO();
|
||||||
|
|
||||||
if (LIKELY(raised(RDY()))) {
|
if (LIKELY(raised(RDY()))) {
|
||||||
|
|
||||||
lowerSYNC(); // Instruction fetch beginning
|
lowerSYNC(); // Instruction fetch beginning
|
||||||
|
|
||||||
|
// Read the opcode within the existing cycle
|
||||||
|
assert(cycles() == 1 && "An extra cycle has occurred");
|
||||||
|
// Can't use fetchByte, since that would add an extra tick.
|
||||||
raiseRW();
|
raiseRW();
|
||||||
opcode() = BUS().read(PC()++); // can't use fetchByte
|
opcode() = BUS().read(PC()++);
|
||||||
|
assert(cycles() == 1 && "BUS read has introduced stray cycles");
|
||||||
|
|
||||||
|
// Priority: RESET > NMI > INT
|
||||||
if (UNLIKELY(lowered(RESET())))
|
if (UNLIKELY(lowered(RESET())))
|
||||||
handleRESET();
|
handleRESET();
|
||||||
else if (UNLIKELY(lowered(NMI())))
|
else if (UNLIKELY(lowered(NMI())))
|
||||||
handleNMI();
|
handleNMI();
|
||||||
else if (UNLIKELY(lowered(INT()) && !interruptMasked()))
|
else if (UNLIKELY(lowered(INT()) && !interruptMasked()))
|
||||||
handleINT();
|
handleINT();
|
||||||
|
|
||||||
|
// Whatever opcode is available, execute it.
|
||||||
execute();
|
execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExecutedInstruction.fire(*this);
|
ExecutedInstruction.fire(*this);
|
||||||
|
|
||||||
return cycles();
|
return cycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user