From b1d1573702f21e3104606d6ade5f5d39ec86a33a Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Thu, 23 Jan 2025 22:02:11 +0100 Subject: restructure project --- src/nes/util/address.hh | 73 ------------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/nes/util/address.hh (limited to 'src/nes/util/address.hh') diff --git a/src/nes/util/address.hh b/src/nes/util/address.hh deleted file mode 100644 index 7987d07..0000000 --- a/src/nes/util/address.hh +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include - -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((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((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((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, std::uint16_t const b) -> address - { - return address{ static_cast(a.get_absolute() + b) }; - } - - constexpr auto operator+(std::uint16_t const a, address const b) -> address - { - return address{ static_cast(a + b.get_absolute()) }; - } - - constexpr auto operator-(address const a, std::uint16_t const b) -> address - { - return address{ static_cast(a.get_absolute() - b) }; - } - - constexpr auto operator%(address const a, std::uint16_t const b) -> address - { - return address{ static_cast(a.get_absolute() % b) }; - } -} // namespace nes \ No newline at end of file -- cgit v1.3.1