Skip to content

Commit

Permalink
feat: visual overlay debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseZeroTwo committed Jan 3, 2024
1 parent 3fca7db commit d1586b5
Show file tree
Hide file tree
Showing 13 changed files with 1,182 additions and 503 deletions.
784 changes: 602 additions & 182 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ An example configuration file can be found in [config.example.toml](./config.exa

This software is currently licensed under the [CNPLv7+](./LICENSE.md), a summary of which can be found at [here](https://thufie.lain.haus/NPL.html).
The contents of the `test-roms` folder is excluded from this, and the original license of the test ROMs are placed in their respective subdirectory, they are not compiled into any of the software, they are included in the repository purely for intergration testing in CI.

## Dependency Version Notice

The frontend uses old versions of `winit` and `egui` related libraries, this is due to incompatibility between more modern versions of the underlying crates with `egui`, `pixels`, and `winit`. In order to upgrade them, these compatibility issues need to be fixed by them.
20 changes: 10 additions & 10 deletions config.example.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[bindings]
a = "KeyA"
b = "KeyS"
select = "KeyQ"
start = "KeyW"
up = "ArrowUp"
down = "ArrowDown"
left = "ArrowLeft"
right = "ArrowRight"
pause = "KeyP"
a = "A"
b = "S"
select = "Q"
start = "W"
up = "Up"
down = "Down"
left = "Left"
right = "Right"
pause = "P"
exit = "Escape"
log_ops = "KeyL"
log_ops = "L"
dump_memory = "Comma"
42 changes: 21 additions & 21 deletions meowgb-core/src/gameboy.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub mod bootrom;
mod cpu;
mod interrupts;
mod joypad;
pub mod cpu;
pub mod interrupts;
pub mod joypad;
pub mod mapper;
mod memory;
pub mod memory;
pub mod ppu;
pub mod serial;
mod sound;
mod timer;
pub mod sound;
pub mod timer;

use std::time::{Duration, Instant};

Expand Down Expand Up @@ -115,7 +115,7 @@ fn test_ringbuffer() {
pub struct Gameboy<S: SerialWriter> {
pub ppu: Ppu,
pub memory: Memory,
pub cartridge: Option<Box<dyn Mapper>>,
pub cartridge: Option<Box<dyn Mapper + Send + Sync>>,
pub interrupts: Interrupts,
pub timer: Timer,
pub registers: Registers,
Expand Down Expand Up @@ -370,7 +370,7 @@ impl<S: SerialWriter> Gameboy<S> {
println!();
}
"dumptilemap" => {
let base = match (self.ppu.lcdc >> 3) & 0b1 == 1 {
let base = match (self.ppu.registers.lcdc >> 3) & 0b1 == 1 {
true => 0x1C00,
false => 0x1800,
};
Expand Down Expand Up @@ -481,18 +481,18 @@ impl<S: SerialWriter> Gameboy<S> {
0xFF26 => self.sound.nr52,
0xFF27..=0xFF2F => 0xFF,
0xFF30..=0xFF3F => self.sound.wave_pattern_ram[address as usize - 0xFF30],
0xFF40 => self.ppu.lcdc,
0xFF40 => self.ppu.registers.lcdc,
0xFF41 => self.ppu.get_stat(),
0xFF42 => self.ppu.scy,
0xFF43 => self.ppu.scx,
0xFF44 => self.ppu.ly,
0xFF45 => self.ppu.lyc,
0xFF42 => self.ppu.registers.scy,
0xFF43 => self.ppu.registers.scx,
0xFF44 => self.ppu.registers.ly,
0xFF45 => self.ppu.registers.lyc,
0xFF46 => self.dma.base,
0xFF47 => self.ppu.bgp.value(),
0xFF48 => self.ppu.obp[0].value(),
0xFF49 => self.ppu.obp[1].value(),
0xFF4A => self.ppu.wy,
0xFF4B => self.ppu.wx,
0xFF4A => self.ppu.registers.wy,
0xFF4B => self.ppu.registers.wx,
0xFF4C..=0xFF4E => 0xFF, // Unused
0xFF4F => 0xFF, // CGB VRAM Bank Select
0xFF50 => self.memory.bootrom_disabled as u8,
Expand Down Expand Up @@ -544,8 +544,8 @@ impl<S: SerialWriter> Gameboy<S> {
0xFF27..=0xFF2F => {}
0xFF30..=0xFF3F => self.sound.wave_pattern_ram[address as usize - 0xFF30] = value,
0xFF40 => {
let old_value = self.ppu.lcdc;
self.ppu.lcdc = value;
let old_value = self.ppu.registers.lcdc;
self.ppu.registers.lcdc = value;

if value >> 7 == 0 && old_value >> 7 == 1 {
self.ppu.stop();
Expand All @@ -554,8 +554,8 @@ impl<S: SerialWriter> Gameboy<S> {
}
}
0xFF41 => self.ppu.set_stat(&mut self.interrupts, value),
0xFF42 => self.ppu.scy = value,
0xFF43 => self.ppu.scx = value,
0xFF42 => self.ppu.registers.scy = value,
0xFF43 => self.ppu.registers.scx = value,
0xFF44 => {} // LY is read only
0xFF45 => self.ppu.set_lyc(&mut self.interrupts, value),
0xFF46 => {
Expand All @@ -566,8 +566,8 @@ impl<S: SerialWriter> Gameboy<S> {
0xFF47 => self.ppu.bgp.write_bgp(value),
0xFF48 => self.ppu.obp[0].write_obp(value),
0xFF49 => self.ppu.obp[1].write_obp(value),
0xFF4A => self.ppu.wy = value,
0xFF4B => self.ppu.wx = value,
0xFF4A => self.ppu.registers.wy = value,
0xFF4B => self.ppu.registers.wx = value,
0xFF4C..=0xFF4E => {} // Unused
0xFF4F => {} // CGB VRAM Bank Select
0xFF50 => {
Expand Down
2 changes: 1 addition & 1 deletion meowgb-core/src/gameboy/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub enum CycleResult {
FinishedKeepPc,
}

#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, Copy)]
pub struct Registers {
pub a: u8,
pub f: u8,
Expand Down
10 changes: 9 additions & 1 deletion meowgb-core/src/gameboy/joypad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ macro_rules! joypad_input {
if val && self.mode == JoypadMode::$mode {
self.interrupt_triggered = true;
}
self.$input = val
self.$input = val;
}

pub fn [<invert_ $input>](&mut self) {
let val = !self.$input;
if val && self.mode == JoypadMode::$mode {
self.interrupt_triggered = true;
}
self.$input = val;
}
}
};
Expand Down
Loading

0 comments on commit d1586b5

Please sign in to comment.