mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-11-19 02:08:25 +00:00
887b89308a
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <fstream>
|
|
|
|
#include "Memory.h"
|
|
|
|
namespace EightBit {
|
|
// ROM is a basic implementation of the Memory interface.
|
|
// Nothing over and above the interface is exposed to users
|
|
// of the ROM class.
|
|
class Rom : public Memory {
|
|
private:
|
|
std::vector<uint8_t> m_bytes;
|
|
|
|
protected:
|
|
const auto& BYTES() const { return m_bytes; }
|
|
auto& BYTES() { return m_bytes; }
|
|
|
|
virtual void poke(uint16_t address, uint8_t value) override;
|
|
|
|
public:
|
|
static int load(std::ifstream& file, std::vector<uint8_t>& output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1);
|
|
static int load(const std::string& path, std::vector<uint8_t>& output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1);
|
|
|
|
Rom(size_t size = 0) noexcept;
|
|
|
|
virtual size_t size() const final;
|
|
|
|
virtual int load(std::ifstream& file, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
|
virtual int load(const std::string& path, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
|
virtual int load(const std::vector<uint8_t>& bytes, int writeOffset = 0, int readOffset = 0, int limit = -1) final;
|
|
|
|
virtual uint8_t peek(uint16_t address) const final;
|
|
};
|
|
}
|