From aa276588640fac2010ed20d04b755a53a1770195 Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Tue, 10 Dec 2024 18:50:24 +0200 Subject: [PATCH] fix clear display instruction --- src/emulator.rs | 3 ++- src/instruction.rs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/emulator.rs b/src/emulator.rs index f8a852f..df968f1 100644 --- a/src/emulator.rs +++ b/src/emulator.rs @@ -201,9 +201,10 @@ where match instruction.processor_instruction() { ProcessorInstruction::ClearScreen => { trace!("Clear display"); + self.display_data = [false; DISPLAY_WIDTH * DISPLAY_HEIGHT]; self.display.clear() } - ProcessorInstruction::Jump(address) => { + ProcessorInstruction::Jump {address} => { trace!("Jump to address {:04x}", address); self.program_counter = address } diff --git a/src/instruction.rs b/src/instruction.rs index 3ec6525..deecd50 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -17,7 +17,7 @@ pub enum ProcessorInstruction { /// Clears the screen ClearScreen, /// Jumps to a given address - Jump(u16), + Jump {address: u16}, /// Sets the register in the first argument to the given value SetRegister(u8, u8), /// Adds the value to the register @@ -125,7 +125,9 @@ impl Instruction { // Jump (0x1, _, _, _) => { // 1NNN - ProcessorInstruction::Jump(Self::grab_inner_data(data)) + ProcessorInstruction::Jump { + address: Self::grab_inner_data(data) + } } // Set Register (0x6, _, _, _) => {