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:
|
2018-11-25 10:43:51 +00:00
|
|
|
UnusedMemory(size_t size, uint8_t value);
|
2018-11-27 22:36:54 +00:00
|
|
|
~UnusedMemory() {};
|
2018-11-03 23:11:48 +00:00
|
|
|
|
2018-11-29 00:09:40 +00:00
|
|
|
[[nodiscard]] size_t size() const final;
|
|
|
|
[[nodiscard]] uint8_t peek(uint16_t address) const 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;
|
|
|
|
int load(const std::string& path, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
|
|
|
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:
|
2018-11-27 22:36:54 +00:00
|
|
|
void poke(uint16_t address, uint8_t value) final;
|
2018-11-03 23:11:48 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
size_t m_size;
|
|
|
|
uint8_t m_value;
|
|
|
|
};
|
|
|
|
}
|