1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Clarifies control flow.

This commit is contained in:
Thomas Harte 2021-07-06 20:28:32 -04:00
parent 704dc9bdcb
commit 8e0893bd42

View File

@ -35,29 +35,27 @@
for(int c = 0; c < 250000; c++) { for(int c = 0; c < 250000; c++) {
// Advance one cycle. Clock is 500,000 Hz. // Advance one cycle. Clock is 500,000 Hz.
_interruptSource->run_for(Cycles(2)); _interruptSource->run_for(Cycles(2));
--nextSequencePoint;
// Check for a status bit change.
const uint8_t newDividerState = _interruptSource->get_divider_state(); const uint8_t newDividerState = _interruptSource->get_divider_state();
const bool didToggle = (dividerState^newDividerState)&0x1; const bool didToggle = (dividerState^newDividerState)&0x1;
if(didToggle) {
++toggles;
}
dividerState = newDividerState; dividerState = newDividerState;
toggles += didToggle;
--nextSequencePoint;
// Check for the relevant interrupt. // Check for the relevant interrupt.
const uint8_t newInterrupts = _interruptSource->get_new_interrupts(); const uint8_t newInterrupts = _interruptSource->get_new_interrupts();
if(newInterrupts) {
XCTAssertEqual(nextSequencePoint, 0);
nextSequencePoint = _interruptSource->get_next_sequence_point().as<int>();
if(newInterrupts & 0x02) { if(newInterrupts & 0x02) {
++interrupts; ++interrupts;
XCTAssertEqual(nextSequencePoint, 0);
XCTAssertTrue(didToggle); XCTAssertTrue(didToggle);
nextSequencePoint = _interruptSource->get_next_sequence_point().as<int>(); } else {
}
// Failing that, confirm that the other interrupt happend. // Failing that, confirm that the other interrupt happend.
if(!nextSequencePoint) {
XCTAssertTrue(newInterrupts & 0x08); XCTAssertTrue(newInterrupts & 0x08);
nextSequencePoint = _interruptSource->get_next_sequence_point().as<int>(); }
} }
XCTAssertEqual(nextSequencePoint, _interruptSource->get_next_sequence_point().as<int>(), @"At cycle %d", c); XCTAssertEqual(nextSequencePoint, _interruptSource->get_next_sequence_point().as<int>(), @"At cycle %d", c);