diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 14:49:20 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 14:49:20 +0100 |
| commit | 5959349f341a2380c0c3f41ec40a1e8e0d969d00 (patch) | |
| tree | 8b36ba3f8cade68562af1dfdcea8b42160619975 /lib/nes/ref/nes.cc | |
| parent | 1d32f7561305d6c86b1c80858bc73d55b1c6c402 (diff) | |
refactor: move emulation logic into sys
Diffstat (limited to 'lib/nes/ref/nes.cc')
| -rw-r--r-- | lib/nes/ref/nes.cc | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/lib/nes/ref/nes.cc b/lib/nes/ref/nes.cc deleted file mode 100644 index e34ca9a..0000000 --- a/lib/nes/ref/nes.cc +++ /dev/null @@ -1,74 +0,0 @@ -#include "nes/ref/nes.hh" -#include "nes/ref/mapper.hh" -#include "nes/util/display.hh" -#include "nes/util/rgb.hh" -#include "nes/util/snapshot.hh" -#include <iostream> - -namespace nes::ref -{ - 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_ } - { - if (!cartridge_.is_valid()) - { - std::cerr << "Cartridge not valid!" << std::endl; - std::abort(); - } - - display_.clear(rgb{}); - display_.switch_buffers(); - display_.clear(rgb{}); - } - - auto nes::step(std::chrono::microseconds const delta) -> void - { - step(cycle_count::from_duration(delta)); - } - - auto nes::step(cycle_count const delta) -> void - { - current_cycles_ += delta; - while (cpu_.get_cycles() < current_cycles_) - { - cpu_.step(); - while (ppu_.get_cycles() < cpu_.get_cycles()) - { - ppu_.step(); - } - } - } - - auto nes::step_to_nmi() -> void - { - while (cpu_.is_nmi_pending()) - { - cpu_.step(); - while (ppu_.get_cycles() < cpu_.get_cycles()) - { - ppu_.step(); - } - } - while (!cpu_.is_nmi_pending()) - { - cpu_.step(); - while (ppu_.get_cycles() < cpu_.get_cycles()) - { - ppu_.step(); - } - } - } - - auto nes::get_snapshot() -> snapshot - { - auto res = snapshot{}; - res.sram = std::vector(cartridge_.get_ram(), cartridge_.get_ram() + cartridge_.get_ram_length()); - cpu_.build_snapshot(res); - ppu_.build_snapshot(res); - return res; - } -} // namespace nes::ref
\ No newline at end of file |
