diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-26 23:19:56 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-26 23:19:56 +0100 |
| commit | 430a246fe81d7eab6823bf6ca4562fd1e99f2a5d (patch) | |
| tree | 75c5f4e8eeeb1e5f25c866e828440e5c493bed8b /lib/nes/nes.cc | |
| parent | d1f4b65eafe9c41ecca7bbe8026ec0a693c1ecda (diff) | |
refactor mappers
Diffstat (limited to 'lib/nes/nes.cc')
| -rw-r--r-- | lib/nes/nes.cc | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/nes/nes.cc b/lib/nes/nes.cc index 498ecd7..9a35bfa 100644 --- a/lib/nes/nes.cc +++ b/lib/nes/nes.cc @@ -1,25 +1,17 @@ #include "nes/nes.hh" -#include "nes/mapper.hh" #include "nes/util/display.hh" #include "nes/util/rgb.hh" #include "nes/util/snapshot.hh" -#include <iostream> namespace nes { nes::nes(cartridge cartridge, display& display) : cartridge_{ std::move(cartridge) } , display_{ display } - , mapper_{ mapper::select(cartridge_) } - , ppu_{ cpu_, mapper_, display_ } - , cpu_{ ppu_, mapper_, controller_1_, controller_2_ } + , ppu_{ cpu_, cartridge_, display_ } + , cpu_{ ppu_, cartridge_, controller_1_, controller_2_ } + , status_{ cartridge_.get_status() } { - if (!cartridge_.is_valid()) - { - std::cerr << "Cartridge not valid!" << std::endl; - std::abort(); - } - display_.clear(rgb{}); display_.switch_buffers(); display_.clear(rgb{}); @@ -32,7 +24,9 @@ namespace nes auto nes::step() -> void { - cpu_.step(); + if (get_status() != status::success) { return; } + + status_ = cpu_.step(); while (ppu_.get_cycles() < cpu_.get_cycles()) { ppu_.step(); @@ -42,7 +36,7 @@ namespace nes auto nes::step(cycle_count const delta) -> void { current_cycles_ += delta; - while (cpu_.get_cycles() < current_cycles_) + while (cpu_.get_cycles() < current_cycles_ && get_status() == status::success) { step(); } |
