From ff25f1aba3b1d36eccf0fd3f153a95bb7e1b2f4b Mon Sep 17 00:00:00 2001 From: Atreya Bain Date: Tue, 5 Mar 2024 22:21:59 +0530 Subject: [PATCH] [dsp] Fix display instruction --- README.md | 15 ++++++++------- src/device/device.rs | 10 +++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f8f4319..1a7aa1d 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,15 @@ Chip 8 emulator/interpreter. - [X] Registers - [X] Stack - [X] Display -- [ ] Instruction Processing +- [X] Instruction Processing - [X] Bare requirements for IBM Logo - - [ ] ALU operations - - [ ] Procedure related - - [ ] Timer - - [ ] Super chip8 compatibility. -- [ ] Audio -- [ ] Keyboard + - [X] ALU operations + - [X] Procedure related + - [X] Timer + - [X] Super chip8 compatibility. +- [X] Audio + - Audio seems to be broken on my device. I will check with other devices. +- [X] Keyboard ### More information on CHIP-8 diff --git a/src/device/device.rs b/src/device/device.rs index 1ae43df..a955ee2 100644 --- a/src/device/device.rs +++ b/src/device/device.rs @@ -290,10 +290,14 @@ impl Device { for i in 0..n as usize { let index = Self::get_framebuffer_index(x, y + i); let slice_from_memory = self.memory[self.registers.i as usize + i]; - + // if we are drawing below the screen + if (y+i)>=Self::FRAME_BUFFER_HEIGHT { + log::trace!("Overdraw detected, skipping"); + continue; + } for bit_index in (0..8).rev() { - // if i'm going to the next line, stop - if Self::get_framebuffer_index(0, y + 1) == index { + // if going out of the screen, stop + if Self::get_framebuffer_index(0, y+i + 1) <= (index + (7 - bit_index)) { break; } let bit_is_true = (slice_from_memory & (1 << bit_index)) == (1 << bit_index);