[dsp] Fix display instruction

This commit is contained in:
2024-03-05 22:21:59 +05:30
parent 2e6410ef90
commit ff25f1aba3
2 changed files with 15 additions and 10 deletions

View File

@@ -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

View File

@@ -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);