@@ 73,7 73,7 @@ impl Processor {
self.pc += 1;
stack.push(self.memory[self.pc] & 0x3FF);
}
- 1 => {
+ 1 => { //push pc
let upper = self.pc & 0b11111111110000000000 >> 10;
let lower = self.pc & 0b1111111111;
stack.push(upper as u16);
@@ 106,6 106,9 @@ impl Processor {
stack.push(a);
stack.push(b);
}
+ 8 => self.carry = false, //clear/set carry
+ 9 => self.carry = true,
+ 10 => _ = stack.pop(), //drop value
0x7F => return false,
_ => ()
}
@@ 129,12 132,10 @@ fn calc(stack: &mut Stack, instruction: u16, carry_in: bool) -> bool {
carry
}
-pub fn mem_to_buf(memory: &[u16]) -> [u32;SCREEN_WIDTH*SCREEN_HEIGHT] {
- let mut result = [0u32;SCREEN_WIDTH*SCREEN_HEIGHT];
- let mut i = 0;
+pub fn mem_to_buf(memory: &[u16]) -> Vec<u32> {
+ let mut result = Vec::new();
for byte in &memory[(MEMORY_SIZE-SCREEN_WIDTH*SCREEN_HEIGHT)..MEMORY_SIZE] {
- result[i] = (((byte & 0b111000000) as u32) << 15) | (((byte & 0b111000) as u32) << 10) | (((byte & 0b111) as u32) << 5); //shifts 3 bits of each 10 bit value into the rgb channels of the buffer, from the last region of memory
- i += 1;
+ result.push((((byte & 0b111000000) as u32) << 15) | (((byte & 0b111000) as u32) << 10) | (((byte & 0b111) as u32) << 5)); //shifts 3 bits of each 10 bit value into the rgb channels of the buffer, from the last region of memory
}
result
}