summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-01-29 14:49:20 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-01-29 14:49:20 +0100
commit5959349f341a2380c0c3f41ec40a1e8e0d969d00 (patch)
tree8b36ba3f8cade68562af1dfdcea8b42160619975 /app
parent1d32f7561305d6c86b1c80858bc73d55b1c6c402 (diff)
refactor: move emulation logic into sys
Diffstat (limited to 'app')
-rw-r--r--app/CMakeLists.txt4
-rw-r--r--app/mac/controller-adapter.hh2
-rw-r--r--app/mac/scene.mm4
-rw-r--r--app/test/CMakeLists.txt14
-rw-r--r--app/test/main.cc82
5 files changed, 4 insertions, 102 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 8ff9434..f3e864f 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,5 +1,3 @@
if(APPLE)
add_subdirectory(mac)
-endif()
-
-add_subdirectory(test) \ No newline at end of file
+endif() \ No newline at end of file
diff --git a/app/mac/controller-adapter.hh b/app/mac/controller-adapter.hh
index 7a4c4b4..09e8b6d 100644
--- a/app/mac/controller-adapter.hh
+++ b/app/mac/controller-adapter.hh
@@ -1,6 +1,6 @@
#pragma once
-#import "nes/util/button-mask.hh"
+#import "nes/sys/types/button-mask.hh"
#import <Foundation/Foundation.h>
diff --git a/app/mac/scene.mm b/app/mac/scene.mm
index 4ede6e0..97caadf 100644
--- a/app/mac/scene.mm
+++ b/app/mac/scene.mm
@@ -1,6 +1,6 @@
#import "scene.hh"
-#import "nes/nes.hh"
-#import "nes/util/display.hh"
+#import "nes/sys/nes.hh"
+#import "nes/common/display.hh"
#import <memory>
#import <optional>
#import <iostream>
diff --git a/app/test/CMakeLists.txt b/app/test/CMakeLists.txt
deleted file mode 100644
index b88acc2..0000000
--- a/app/test/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-add_executable(nes_test)
-
-target_include_directories(nes_test PRIVATE .)
-target_link_libraries(
- nes_test
- PRIVATE
- nes::options
- nes::nes
- nes::ref)
-
-target_sources(
- nes_test
- PRIVATE
- main.cc) \ No newline at end of file
diff --git a/app/test/main.cc b/app/test/main.cc
deleted file mode 100644
index 70a66ac..0000000
--- a/app/test/main.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "nes/util/display.hh"
-#include "nes/util/rgb.hh"
-#include "nes/util/snapshot.hh"
-#include "nes/nes.hh"
-#include "nes/ref/nes.hh"
-#include <iostream>
-
-namespace
-{
- class dummy_display final : public nes::display
- {
- std::uint8_t buffer_a_[width * height * 3]{};
- std::uint8_t buffer_b_[width * height * 3]{};
- std::uint8_t* front_buffer_{ buffer_a_ };
- std::uint8_t* back_buffer_{ buffer_b_ };
-
- public:
- explicit dummy_display() = default;
-
- auto get(unsigned const x, unsigned const y) const -> nes::rgb override
- {
- auto const offset = ((y * width) + x) * 3;
- return nes::rgb{ back_buffer_[offset + 0], back_buffer_[offset + 1], back_buffer_[offset + 2] };
- }
-
- auto set(unsigned const x, unsigned const y, nes::rgb const value) -> void override
- {
- auto const offset = ((y * width) + x) * 3;
- back_buffer_[offset + 0] = value.r;
- back_buffer_[offset + 1] = value.g;
- back_buffer_[offset + 2] = value.b;
- }
-
- auto switch_buffers() -> void override
- {
- std::swap(front_buffer_, back_buffer_);
- }
- };
-} // namespace
-
-int main()
-{
- auto const path = "/Users/hannes/Documents/temp/supermario.nes";
-
- // Initialize the system to be tested.
- auto cartridge_a = nes::cartridge::from_file(path);
- if (cartridge_a.get_status() != nes::status::success)
- {
- std::cerr << "Could not load cartridge: " << to_string(cartridge_a.get_status()) << std::endl;
- std::abort();
- }
- auto display_a = std::make_unique<dummy_display>();
- auto sys_a = nes::nes{ std::move(cartridge_a), *display_a };
-
- // Initialize the (assumed to be working) reference implementation.
- auto cartridge_b = nes::ref::cartridge::from_file(path);
- if (!cartridge_b.is_valid())
- {
- std::cerr << "Could not load cartridge!" << std::endl;
- std::abort();
- }
- auto display_b = std::make_unique<dummy_display>();
- auto sys_b = nes::ref::nes{ std::move(cartridge_b), *display_b };
-
- // Run.
- while (true)
- {
- auto const status_a = sys_a.get_snapshot();
- auto const status_b = sys_b.get_snapshot();
-
- if (status_a != status_b)
- {
- std::cout << "Different snapshot!\n";
- return 1;
- }
-
- std::cout << "Cycle: " << status_a.cpu_cycle.to_cpu() << ", " << status_b.cpu_cycle.to_cpu() << '\n';
-
- sys_a.step_to_nmi();
- sys_b.step_to_nmi();
- }
-} \ No newline at end of file