Skip to content

Debug Window & PPU class rewirte#100

Merged
Jayesh-Dev21 merged 12 commits into
mainfrom
PPU
Jun 11, 2026
Merged

Debug Window & PPU class rewirte#100
Jayesh-Dev21 merged 12 commits into
mainfrom
PPU

Conversation

@Jayesh-Dev21

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 14:34
@Jayesh-Dev21 Jayesh-Dev21 merged commit e2b00e4 into main Jun 11, 2026
1 check passed
@Jayesh-Dev21

Copy link
Copy Markdown
Owner Author

closes #24 #25 #26 #37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the emulator core to route ROM/RAM and interrupt/timer behavior through new Cartridge and InterruptController components, while expanding the PPU into a debug/feature UI that supports runtime controls and savestates.

Changes:

  • Introduces InterruptController and rewires CPU/PPU/Timer/MMU interrupt signaling through it.
  • Adds Cartridge and updates MMU to delegate ROM/RAM banking and expose basic runtime stats + memory dump/load for savestates.
  • Implements a new PPU debug window (breakpoints, opcode trace, virtual gamepad, savestate load/save) and adds helper scripts/files for debugging workflows.

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
utility_scripts/run_debug.sh Adds a helper script to launch the emulator with --debug.
utility_scripts/make_cb_opcode_skeleton.sh Adds a generator script for CB-prefixed opcode declarations/stubs.
utility_scripts/clean_savestates.sh Adds a helper script for clearing savestate .bin files.
utility_scripts/breakpoints.txt Adds a breakpoint list file consumed by the debug UI.
tests/CMakeLists.txt Links SFML targets to the test binary.
src/main.cpp Adds CLI flags (--debug, --fullscreen) and wires up Cartridge/IC/Timer/PPU/MMU construction + debug loop.
src/core/timer.cpp Refactors Timer to request interrupts via InterruptController and adds reset().
src/core/ppu.cpp Major PPU rewrite: interrupt requests via IC + debug window/UI + breakpoints + opcode trace + savestates.
src/core/memory/mmu.cpp Refactors MMU to delegate to Cartridge/PPU/Timer/IC; adds bus stats, reset, and dump/load for savestates.
src/core/cpu/ProcessingUnit.cpp Masks pending interrupts to lower 5 bits.
src/core/cartridge.cpp Adds Cartridge implementation with basic MBC handling and RAM support.
include/timer.hpp Updates Timer API to use InterruptController and adds reset/serialization helpers.
include/ppu.hpp Expands PPU API for debug window/controls/savestates; stores pointers to CPU/MMU.
include/mmu.hpp Refactors MMU interface to use Cartridge/PPU/Timer/IC and adds stats + serialization.
include/interrupt_controller.hpp Adds new InterruptController abstraction for IF/IE and interrupt requests.
include/common.hpp Moves JoypadState to a common header.
include/cartridge.hpp Updates ROM header title field and introduces Cartridge class interface/state.
CMakeLists.txt Adjusts SFML discovery to use the config package and components.
.gitignore Ignores the savestates/ directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +24
# Get ROM files
ROM_FILES=("$PROJECT_ROOT"/roms/*)

# Check if any ROM exists
if [ ${#ROM_FILES[@]} -gt 0 ]; then
FIRST_ROM="${ROM_FILES[0]}"
echo "Launching: $FIRST_ROM --debug"

"$BUILD_DIR"/bin/gb_emu "$FIRST_ROM" --debug
else
echo "No ROM files found in $PROJECT_ROOT/roms"
fi
Comment thread src/main.cpp
Comment on lines 9 to 13
@@ -10,12 +12,6 @@
#include <iterator>
#include <SFML/Graphics.hpp>
Comment thread src/main.cpp
Comment thread src/core/ppu.cpp
Comment on lines 1 to +9
#include "../../include/ppu.hpp"
#include "../../include/mmu.hpp"
#include "../../include/cartridge.hpp"
#include <filesystem>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <algorithm>
Comment thread src/core/ppu.cpp
Comment on lines +691 to +697
u32 size{};
in.read(reinterpret_cast<char*>(&size), sizeof(size));
std::vector<u8> dump(size);
in.read(reinterpret_cast<char*>(dump.data()), size);
mmu->load_memory(dump);

return true;
Comment thread src/core/memory/mmu.cpp
Comment on lines +212 to +214
std::vector<u8> MMU::dump_memory() const {
std::vector<u8> dump(0x10000, 0);

Comment thread src/core/memory/mmu.cpp
Comment on lines +239 to +243
dump[0x04] = ic->get_if();
dump[0x05] = ic->get_ie();

return dump;
}
Comment thread src/core/cartridge.cpp
Comment on lines +66 to +72
current_rom_bank = 1;
current_ram_bank = 0;
ram_enabled = false;
banking_mode = 0;
rom_bank_low = 1;
rom_bank_high = 0;
return true;
Comment thread src/core/cartridge.cpp
Comment on lines +124 to +130
} else if (mbc_type == MBCType::MBC5) {
if (address <= 0x2FFF) {
rom_bank_low = value;
} else {
rom_bank_high = value & 0x01;
}
current_rom_bank = (rom_bank_high << 8) | rom_bank_low;
@Jayesh-Dev21 Jayesh-Dev21 deleted the PPU branch June 11, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants