summaryrefslogtreecommitdiff
path: root/lib/nes/util/address.hh
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 /lib/nes/util/address.hh
parent1d32f7561305d6c86b1c80858bc73d55b1c6c402 (diff)
refactor: move emulation logic into sys
Diffstat (limited to 'lib/nes/util/address.hh')
-rw-r--r--lib/nes/util/address.hh73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/nes/util/address.hh b/lib/nes/util/address.hh
deleted file mode 100644
index 2cce2f0..0000000
--- a/lib/nes/util/address.hh
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-#include <cstdint>
-
-namespace nes
-{
- /// An address on the NES.
- class address
- {
- std::uint16_t absolute_{ 0 };
-
- public:
- /// Create a zero address.
- constexpr explicit address() = default;
-
- /// Create an address from its absolute value.
- constexpr explicit address(std::uint16_t const absolute)
- : absolute_{ absolute }
- {
- }
-
- /// Create an address from its page and offset combination.
- constexpr explicit address(std::uint8_t const page, std::uint8_t const offset)
- : address{ static_cast<std::uint16_t>((page << 8) | (offset << 0)) }
- {
- }
-
- /// Get the absolute address value.
- constexpr auto get_absolute() const -> std::uint16_t
- {
- return absolute_;
- }
-
- /// Get the address page (the first 8 bits).
- constexpr auto get_page() const -> std::uint8_t
- {
- return static_cast<std::uint8_t>((get_absolute() & 0xFF00) >> 8);
- }
-
- /// Get the offset within the page (the last 8 bits).
- constexpr auto get_offset() const -> std::uint8_t
- {
- return static_cast<std::uint8_t>((get_absolute() & 0x00FF) >> 0);
- }
- };
-
- constexpr auto operator==(address const a, address const b) -> bool { return a.get_absolute() == b.get_absolute(); }
- constexpr auto operator!=(address const a, address const b) -> bool { return a.get_absolute() != b.get_absolute(); }
- constexpr auto operator<(address const a, address const b) -> bool { return a.get_absolute() < b.get_absolute(); }
- constexpr auto operator>(address const a, address const b) -> bool { return a.get_absolute() > b.get_absolute(); }
- constexpr auto operator<=(address const a, address const b) -> bool { return a.get_absolute() <= b.get_absolute(); }
- constexpr auto operator>=(address const a, address const b) -> bool { return a.get_absolute() >= b.get_absolute(); }
-
- constexpr auto operator+(address const a, unsigned const b) -> address
- {
- return address{ static_cast<std::uint16_t>(a.get_absolute() + b) };
- }
-
- constexpr auto operator+(unsigned const a, address const b) -> address
- {
- return address{ static_cast<std::uint16_t>(a + b.get_absolute()) };
- }
-
- constexpr auto operator-(address const a, unsigned const b) -> address
- {
- return address{ static_cast<std::uint16_t>(a.get_absolute() - b) };
- }
-
- constexpr auto operator%(address const a, unsigned const b) -> address
- {
- return address{ static_cast<std::uint16_t>(a.get_absolute() % b) };
- }
-} // namespace nes \ No newline at end of file