summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-06-30 14:28:25 +1200
committerBen Bridle <bridle.benjamin@gmail.com>2024-06-30 14:28:25 +1200
commitc99d7600c5add0829333c2d844ca03a5112a27d1 (patch)
tree06d9c88c1e198b0875342a4715d90879bba734a7
parent0c72ba049ba52f29b576bdbdd5fdaac9e58dee97 (diff)
downloadbedrock-pc-c99d7600c5add0829333c2d844ca03a5112a27d1.zip
Prevent clock device from locking out all other devices
When the clock device was first in order to be responded to, a fast enough recurring timer could successfully prevent any other device from being able to wake the emulator, if a timer was able to expire in the time it took to run the clock wake handler.
-rw-r--r--src/devices.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/devices.rs b/src/devices.rs
index 4ba29a8..e0c4280 100644
--- a/src/devices.rs
+++ b/src/devices.rs
@@ -58,10 +58,15 @@ impl StandardDevices {
};
}
self.clock.update_timers();
- test_wake!(self.clock.wake_flag, 0x3, 0x1000);
+ // The order here is important. If clock comes first, it could
+ // block out all other events with a fast enough recurring timer.
+ // It might be preferable to implement a queue system, so that
+ // the flags are tested in the opposite order to how recently
+ // they were matched.
test_wake!(self.input.wake_flag, 0x4, 0x0800);
test_wake!(self.screen.wake_flag, 0x5, 0x0400);
test_wake!(self.stream.wake_flag, 0x8, 0x0080);
+ test_wake!(self.clock.wake_flag, 0x3, 0x1000);
return false;
}
}