summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-09-07 18:29:52 +1200
committerBen Bridle <bridle.benjamin@gmail.com>2024-09-07 18:29:52 +1200
commitb90cd9bd45322c103433e97e775e88991930313c (patch)
tree901373a0a5c2116b69220cc671c5752baa775baf
parent56ce81819b6ce71ba8c5bd46fd5bba5370484984 (diff)
downloadbedrock-pc-b90cd9bd45322c103433e97e775e88991930313c.zip
Implement DB4 instruction for unit tests
When the DB4 instruction is evaluated, a single '.' character will be printed to stdout if the return stack is empty and the working stack contains a single 0xff byte, otherwise a single 'X' character will be printed to stdout. This is to facilitate unit testing the instruction set with a Bedrock program, from within the emulator.
-rw-r--r--src/emulator.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/emulator.rs b/src/emulator.rs
index 4909a27..d983378 100644
--- a/src/emulator.rs
+++ b/src/emulator.rs
@@ -93,6 +93,15 @@ impl BedrockEmulator {
DebugVariant::DB3 => {
// Only resets the debug timer
}
+ DebugVariant::DB4 => {
+ if self.vm.wst.sp == 1
+ && self.vm.rst.sp == 0
+ && self.vm.wst.mem[0] == 0xff {
+ print!(".")
+ } else {
+ print!("X")
+ }
+ }
_ => (),
}
self.cycles_elapsed = self.vm.cycles;