summaryrefslogtreecommitdiff
path: root/lib/nes/app
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-01-31 23:30:56 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-01-31 23:30:56 +0100
commitccb81b60dac888e44079fb0228c1d5d8542ceade (patch)
tree297b672e2cd4de2ce4203c19b973274c5750e60d /lib/nes/app
parentcd8ae0e4f628bd491fcaf1dd4778bc283d619065 (diff)
move components into dedicated namespaces
Diffstat (limited to 'lib/nes/app')
-rw-r--r--lib/nes/app/application.cc20
-rw-r--r--lib/nes/app/application.hh7
-rw-r--r--lib/nes/app/input/input-device-controller.hh4
-rw-r--r--lib/nes/app/input/input-device-keyboard.hh4
-rw-r--r--lib/nes/app/input/input-device.hh24
-rw-r--r--lib/nes/app/input/input-manager.cc4
-rw-r--r--lib/nes/app/input/input-manager.hh4
7 files changed, 32 insertions, 35 deletions
diff --git a/lib/nes/app/application.cc b/lib/nes/app/application.cc
index ad3c1af..4da3848 100644
--- a/lib/nes/app/application.cc
+++ b/lib/nes/app/application.cc
@@ -8,7 +8,7 @@
#include "nes/common/display.hh"
#include <iostream>
-namespace nes
+namespace nes::app
{
namespace
{
@@ -18,9 +18,9 @@ namespace nes
application::application(display& display, input_device_keyboard& keyboard)
: display_{ display }
, input_manager_{ keyboard }
- , console_{ cartridge::from_file(file), display_ }
+ , console_{ sys::cartridge::from_file(file), display_ }
{
- if (console_.get_status() != status::success)
+ if (console_.get_status() != sys::status::success)
{
std::cerr << "Unable to load cartridge: " << to_string(console_.get_status()) << std::endl;
std::abort();
@@ -29,21 +29,15 @@ namespace nes
auto application::frame(std::chrono::microseconds const elapsed_time) -> void
{
- /*console_.ref_controller_1().set_pressed(input_manager_.get_input_1().read_mask());
+ console_.ref_controller_1().set_pressed(input_manager_.get_input_1().read_mask());
console_.ref_controller_2().set_pressed(input_manager_.get_input_2().read_mask());
console_.step(elapsed_time);
- if (console_.get_status() != status::success)
+ if (console_.get_status() != sys::status::success)
{
std::cerr << "Invalid state: " << to_string(console_.get_status()) << std::endl;
std::abort();
- }*/
-
- auto r = app::renderer{ display_ };
- r.render_fill(app::color::background_primary);
- r.render_mask_tile(10, 5, app::tiles::letter_a, app::color::foreground_primary);
- r.render_image_tile(5, 5, app::tiles::test);
- display_.switch_buffers();
+ }
}
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/application.hh b/lib/nes/app/application.hh
index 9f6bd16..5cd6ac7 100644
--- a/lib/nes/app/application.hh
+++ b/lib/nes/app/application.hh
@@ -7,7 +7,10 @@
namespace nes
{
class display;
+} // namespace nes
+namespace nes::app
+{
/// Entrypoint for the application.
///
/// This class takes care of presenting a UI screen or the emulator, handling any errors and implementing the main
@@ -18,7 +21,7 @@ namespace nes
{
display& display_;
input_manager input_manager_;
- nes console_;
+ sys::nes console_;
public:
explicit application(display&, input_device_keyboard&);
@@ -34,4 +37,4 @@ namespace nes
auto add_controller(input_device_controller& c) -> void { input_manager_.add_controller(c); }
auto remove_controller(input_device_controller& c) -> void { input_manager_.remove_controller(c); }
};
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/input/input-device-controller.hh b/lib/nes/app/input/input-device-controller.hh
index 6adb79c..b4e6570 100644
--- a/lib/nes/app/input/input-device-controller.hh
+++ b/lib/nes/app/input/input-device-controller.hh
@@ -4,7 +4,7 @@
#include "nes/common/list.hh"
#include <string_view>
-namespace nes
+namespace nes::app
{
/// A game controller input device.
class input_device_controller : public input_device, public list<input_device_controller>::node
@@ -35,4 +35,4 @@ namespace nes
protected:
explicit input_device_controller() = default;
};
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/input/input-device-keyboard.hh b/lib/nes/app/input/input-device-keyboard.hh
index d61417d..dddcab6 100644
--- a/lib/nes/app/input/input-device-keyboard.hh
+++ b/lib/nes/app/input/input-device-keyboard.hh
@@ -2,7 +2,7 @@
#include "nes/app/input/input-device.hh"
-namespace nes
+namespace nes::app
{
/// A keyboard input device.
class input_device_keyboard : public input_device
@@ -13,4 +13,4 @@ namespace nes
protected:
explicit input_device_keyboard() = default;
};
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/input/input-device.hh b/lib/nes/app/input/input-device.hh
index 9ac7423..8e54f61 100644
--- a/lib/nes/app/input/input-device.hh
+++ b/lib/nes/app/input/input-device.hh
@@ -2,7 +2,7 @@
#include "nes/sys/types/button-mask.hh"
-namespace nes
+namespace nes::app
{
/// An abstract input device which can be used to play games.
class input_device
@@ -24,21 +24,21 @@ namespace nes
virtual auto read_key_select() -> bool = 0;
virtual auto read_key_start() -> bool = 0;
- auto read_mask() -> button_mask
+ auto read_mask() -> sys::button_mask
{
- auto res = button_mask{};
- if (read_key_up()) { res.add(buttons::up); }
- if (read_key_down()) { res.add(buttons::down); }
- if (read_key_left()) { res.add(buttons::left); }
- if (read_key_right()) { res.add(buttons::right); }
- if (read_key_a()) { res.add(buttons::a); }
- if (read_key_b()) { res.add(buttons::b); }
- if (read_key_select()) { res.add(buttons::select); }
- if (read_key_start()) { res.add(buttons::start); }
+ auto res = sys::button_mask{};
+ if (read_key_up()) { res.add(sys::buttons::up); }
+ if (read_key_down()) { res.add(sys::buttons::down); }
+ if (read_key_left()) { res.add(sys::buttons::left); }
+ if (read_key_right()) { res.add(sys::buttons::right); }
+ if (read_key_a()) { res.add(sys::buttons::a); }
+ if (read_key_b()) { res.add(sys::buttons::b); }
+ if (read_key_select()) { res.add(sys::buttons::select); }
+ if (read_key_start()) { res.add(sys::buttons::start); }
return res;
}
protected:
explicit input_device() = default;
};
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/input/input-manager.cc b/lib/nes/app/input/input-manager.cc
index 1c9db9e..dec899a 100644
--- a/lib/nes/app/input/input-manager.cc
+++ b/lib/nes/app/input/input-manager.cc
@@ -1,6 +1,6 @@
#include "nes/app/input/input-manager.hh"
-namespace nes
+namespace nes::app
{
namespace
{
@@ -99,4 +99,4 @@ namespace nes
}
}
}
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file
diff --git a/lib/nes/app/input/input-manager.hh b/lib/nes/app/input/input-manager.hh
index 10308c7..525debc 100644
--- a/lib/nes/app/input/input-manager.hh
+++ b/lib/nes/app/input/input-manager.hh
@@ -4,7 +4,7 @@
#include "nes/app/input/input-device-controller.hh"
#include "nes/common/list.hh"
-namespace nes
+namespace nes::app
{
/// Manages input devices.
///
@@ -42,4 +42,4 @@ namespace nes
private:
auto fill_unassigned_inputs() -> void;
};
-} // namespace nes \ No newline at end of file
+} // namespace nes::app \ No newline at end of file