readme: Mark cycle counting complete
refactor: Wrap page when assigning to highAddress
Add cycle counting
The CPU may spend an extra cycle fixing the upper address when adding an
offset, depending on the type of instruction (as indicated by
InstructionType) and whether a page boundary was crossed. Read
instructions tend to only require that extra cycle if a page was
crossed, while all other instructions will always use that extra cycle.
This page cross detection and cycle increments are now performed by
As address modes are processed in getTarget(), this function is now
provided with the type of instruction it is processing, so cycle counts
can be calculated correctly.
Popping from the stack requires spending one cycle beforehand, to
pre-increment the stack pointer. Subsequent pops within an instruction
only require a single cycle, as the stack pointer can be incremented in
the same cycle as popping from the stack.
The preIncrement argument to pop() and popFlags() must be set to true
for the first pop operation of the instruction to include this initial
read() is no longer [[nodiscard]] as some instructions will implicitly read
and discard the result. Such reads have been annotated with a comment.
Some instructions seem to always use an extra cycle during execution, so
in those cases the cycle is manually incremented within the instruction.
Read and increment PC in BRK, fix test
Useful in cycle counting, but also means the expected PC in the test
needs to be incremented.
cmake: Force Catch2 test to use colours
Otherwise running the executable through CTest unhelpfully provides no
colour in the output.
readme: add status, mention Nestest
format: clang-format C++ files
lint: Use const auto * for array iterator
lint: Use same parameter name as declaration
Compare to 0 for Carry in BIT
Instead of casting to bool and negating. A comparison is much clearer.
Use uint8_t and uint16_t instead of size_t
And remove the now unnecessary <cstddef> include.
Add missing <cstdint> include
Remove unused <bitset> and <optional> includes
Add accessor for ValueStore::value
Define member functions out of line
Make more CPU methods constexpr
Replace std::bitset flags with constexpr struct
Many std::bitset methods aren't marked constexpr, so this requires
re-implementing the needed functionality in a new class.