diff --git a/src/bin/ponderosa-cpu.rs b/src/bin/ponderosa-cpu.rs index b9e1017..d0e80e9 100644 --- a/src/bin/ponderosa-cpu.rs +++ b/src/bin/ponderosa-cpu.rs @@ -62,7 +62,7 @@ fn parse_rom(path: &String) -> io::Result<(state::Land, Vec, HashMa let x_pos = rom_words.pop_front().unwrap(); let y_pos = rom_words.pop_front().unwrap(); - land.map.insert((x_pos % land.width, y_pos % land.height), value); + land.sow(&(x_pos, y_pos), value); } println!("World\n====="); diff --git a/src/state.rs b/src/state.rs index 88b96c0..d6c5cf0 100644 --- a/src/state.rs +++ b/src/state.rs @@ -83,6 +83,14 @@ impl Land { return self.semaphores.get_mut(position).unwrap(); } + + pub fn sow(&mut self, position: &(u16, u16), value: u16) { + self.map.insert((position.0 % self.width, position.1 % self.height), value); + } + + pub fn reap(&mut self, position: &(u16, u16)) -> u16 { + self.map.insert((position.0 % self.width, position.1 % self.height), 0).unwrap_or(0) + } } pub type Rule = VecDeque;