mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-28 01:29:18 +00:00
Try to remove some casting warnings by redefining ROM size types.
This commit is contained in:
parent
53ef92dbc4
commit
70a785b5c2
@ -10,7 +10,7 @@ namespace EightBit {
|
|||||||
public:
|
public:
|
||||||
enum class AccessType { Unknown, Reading, Writing };
|
enum class AccessType { Unknown, Reading, Writing };
|
||||||
|
|
||||||
[[nodiscard]] size_t size() const noexcept override;
|
[[nodiscard]] uint16_t size() const noexcept override;
|
||||||
[[nodiscard]] uint8_t peek(uint16_t address) const noexcept override;
|
[[nodiscard]] uint8_t peek(uint16_t address) const noexcept override;
|
||||||
|
|
||||||
[[nodiscard]] uint8_t& reference(uint16_t address) noexcept override;
|
[[nodiscard]] uint8_t& reference(uint16_t address) noexcept override;
|
||||||
|
@ -16,7 +16,7 @@ namespace EightBit {
|
|||||||
public:
|
public:
|
||||||
virtual ~Memory() {};
|
virtual ~Memory() {};
|
||||||
|
|
||||||
[[nodiscard]] virtual size_t size() const noexcept = 0;
|
[[nodiscard]] virtual uint16_t size() const noexcept = 0;
|
||||||
[[nodiscard]] virtual uint8_t peek(uint16_t address) const noexcept = 0;
|
[[nodiscard]] virtual uint8_t peek(uint16_t address) const noexcept = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual uint8_t& reference(uint16_t) noexcept;
|
[[nodiscard]] virtual uint8_t& reference(uint16_t) noexcept;
|
||||||
|
@ -30,7 +30,7 @@ namespace EightBit {
|
|||||||
Rom& operator=(const Rom& rhs);
|
Rom& operator=(const Rom& rhs);
|
||||||
bool operator==(const Rom& rhs) const;
|
bool operator==(const Rom& rhs) const;
|
||||||
|
|
||||||
[[nodiscard]] size_t size() const noexcept final;
|
[[nodiscard]] uint16_t size() const noexcept final;
|
||||||
|
|
||||||
int load(std::ifstream& file, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
int load(std::ifstream& file, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
||||||
int load(std::string path, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
int load(std::string path, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
||||||
|
@ -13,10 +13,10 @@ namespace EightBit {
|
|||||||
// is being read.
|
// is being read.
|
||||||
class UnusedMemory final : public Memory {
|
class UnusedMemory final : public Memory {
|
||||||
public:
|
public:
|
||||||
UnusedMemory(size_t size, uint8_t value) noexcept;
|
UnusedMemory(uint16_t size, uint8_t value) noexcept;
|
||||||
~UnusedMemory() = default;
|
~UnusedMemory() = default;
|
||||||
|
|
||||||
[[nodiscard]] size_t size() const noexcept final;
|
[[nodiscard]] uint16_t size() const noexcept final;
|
||||||
[[nodiscard]] uint8_t peek(uint16_t address) const noexcept final;
|
[[nodiscard]] uint8_t peek(uint16_t address) const noexcept final;
|
||||||
|
|
||||||
int load(std::ifstream& file, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
int load(std::ifstream& file, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
||||||
@ -27,7 +27,7 @@ namespace EightBit {
|
|||||||
void poke(uint16_t address, uint8_t value) noexcept final;
|
void poke(uint16_t address, uint8_t value) noexcept final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_size;
|
uint16_t m_size;
|
||||||
uint8_t m_value;
|
uint8_t m_value;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "../inc/Register.h"
|
#include "../inc/Register.h"
|
||||||
|
|
||||||
size_t EightBit::InputOutput::size() const noexcept {
|
uint16_t EightBit::InputOutput::size() const noexcept {
|
||||||
return 0x100;
|
return 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,10 @@ EightBit::Rom& EightBit::Rom::operator=(const Rom& rhs) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t EightBit::Rom::size() const noexcept {
|
uint16_t EightBit::Rom::size() const noexcept {
|
||||||
return m_bytes.size();
|
const auto size = BYTES().size();
|
||||||
|
assert(size <= 0x10000);
|
||||||
|
return static_cast<uint16_t>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EightBit::Rom::load(std::ifstream& file, const int writeOffset, const int readOffset, const int limit) {
|
int EightBit::Rom::load(std::ifstream& file, const int writeOffset, const int readOffset, const int limit) {
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
EightBit::UnusedMemory::UnusedMemory(const size_t size, const uint8_t value) noexcept
|
EightBit::UnusedMemory::UnusedMemory(const uint16_t size, const uint8_t value) noexcept
|
||||||
: m_size(size), m_value(value) {}
|
: m_size(size), m_value(value) {}
|
||||||
|
|
||||||
size_t EightBit::UnusedMemory::size() const noexcept {
|
uint16_t EightBit::UnusedMemory::size() const noexcept {
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user