2018-11-03 23:11:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-11-25 10:43:51 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-11-04 16:38:57 +00:00
|
|
|
#include "Memory.h"
|
2018-11-03 23:11:48 +00:00
|
|
|
|
|
|
|
namespace EightBit {
|
2018-11-04 16:38:57 +00:00
|
|
|
// A read-only Memory implementation that has a fixed size and will
|
|
|
|
// *always* returns the same value, from whichever location
|
|
|
|
// is being read.
|
|
|
|
class UnusedMemory final : public Memory {
|
2018-11-03 23:11:48 +00:00
|
|
|
public:
|
2022-01-03 12:29:32 +00:00
|
|
|
UnusedMemory(uint16_t size, uint8_t value) noexcept;
|
2018-11-03 23:11:48 +00:00
|
|
|
|
2022-01-03 12:29:32 +00:00
|
|
|
[[nodiscard]] uint16_t size() const noexcept final;
|
2021-07-18 13:28:40 +00:00
|
|
|
[[nodiscard]] uint8_t peek(uint16_t address) const noexcept final;
|
2018-11-03 23:11:48 +00:00
|
|
|
|
2018-11-27 22:36:54 +00:00
|
|
|
int load(std::ifstream& file, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
2020-11-07 09:41:12 +00:00
|
|
|
int load(std::string path, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
2018-11-27 22:36:54 +00:00
|
|
|
int load(const std::vector<uint8_t>& bytes, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
2018-11-03 23:11:48 +00:00
|
|
|
|
|
|
|
protected:
|
2021-07-18 13:28:40 +00:00
|
|
|
void poke(uint16_t address, uint8_t value) noexcept final;
|
2018-11-03 23:11:48 +00:00
|
|
|
|
|
|
|
private:
|
2022-01-03 12:29:32 +00:00
|
|
|
uint16_t m_size;
|
2018-11-03 23:11:48 +00:00
|
|
|
uint8_t m_value;
|
|
|
|
};
|
|
|
|
}
|