aboutsummaryrefslogtreecommitdiff
path: root/src/memory_tracker.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory_tracker.rs')
-rw-r--r--src/memory_tracker.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/memory_tracker.rs b/src/memory_tracker.rs
index e35bf2d..26c986a 100644
--- a/src/memory_tracker.rs
+++ b/src/memory_tracker.rs
@@ -1,16 +1,17 @@
-use rustv::isa;
+use rustv::isa::{self, IsaType};
use rustv::memory::{Memory, MemoryInterface, Result};
pub struct MemoryTracker {
memory: Memory,
- program1_byte: u8,
- program2_byte: u8,
- program1: i64,
- program2: i64,
+ program1_byte: isa::Byte,
+ program2_byte: isa::Byte,
+ program1: i32,
+ program2: i32,
}
impl MemoryTracker {
- pub fn new(memory: Memory, program1: u8, program2: u8) -> MemoryTracker {
+ pub fn new(memory: Memory,
+ program1: isa::Byte, program2: isa::Byte) -> MemoryTracker {
MemoryTracker {
memory: memory,
program1_byte: program1,
@@ -20,7 +21,7 @@ impl MemoryTracker {
}
}
- pub fn score(&self) -> (i64, i64) {
+ pub fn score(&self) -> (i32, i32) {
(self.program1, self.program2)
}
}
@@ -48,7 +49,7 @@ impl MemoryInterface for MemoryTracker {
if let Ok(original) = original {
if let Ok(()) = result {
- let p1b = self.program1_byte as u32;
+ let p1b = self.program1_byte.as_word();
let mut p1orig = 0;
let mut p1new = 0;
if original & 0xFF == p1b { p1orig += 1; }
@@ -63,7 +64,7 @@ impl MemoryInterface for MemoryTracker {
self.program1 += p1new - p1orig;
- let p2b = self.program2_byte as u32;
+ let p2b = self.program2_byte.as_word();
let mut p2orig = 0;
let mut p2new = 0;
if original & 0xFF == p2b { p2orig += 1; }