mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-01-23 19:16:21 +00:00
Attempted move to a "BUS" oriented memory architecture (TBC!)
Signed-off-by: Adrian.Conlon <adrian.conlon@arup.com>
This commit is contained in:
@@ -1,55 +1,8 @@
|
||||
#include "stdafx.h"
|
||||
#include "Memory.h"
|
||||
#include "Processor.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
EightBit::Memory::Memory(uint16_t addressMask)
|
||||
: m_addressMask(addressMask),
|
||||
m_temporary(0),
|
||||
m_data(nullptr) {
|
||||
clear();
|
||||
m_address.word = 0;
|
||||
m_bus.resize(0x10000);
|
||||
m_locked.resize(0x10000);
|
||||
}
|
||||
|
||||
uint8_t EightBit::Memory::peek(uint16_t address) {
|
||||
bool rom;
|
||||
return reference(address, rom);
|
||||
}
|
||||
|
||||
void EightBit::Memory::poke(uint16_t address, uint8_t value) {
|
||||
bool rom;
|
||||
reference(address, rom) = value;
|
||||
}
|
||||
|
||||
uint16_t EightBit::Memory::peekWord(uint16_t address) {
|
||||
register16_t returned;
|
||||
returned.low = peek(address);
|
||||
returned.high = peek(address + 1);
|
||||
return returned.word;
|
||||
}
|
||||
|
||||
void EightBit::Memory::clear() {
|
||||
std::fill(m_bus.begin(), m_bus.end(), 0);
|
||||
std::fill(m_locked.begin(), m_locked.end(), false);
|
||||
}
|
||||
|
||||
void EightBit::Memory::loadRom(const std::string& path, uint16_t offset) {
|
||||
auto size = loadMemory(path, offset);
|
||||
lock(offset, size);
|
||||
}
|
||||
|
||||
void EightBit::Memory::loadRam(const std::string& path, uint16_t offset) {
|
||||
loadMemory(path, offset);
|
||||
}
|
||||
|
||||
int EightBit::Memory::loadMemory(const std::string& path, uint16_t offset) {
|
||||
return loadBinary(path, m_bus, offset, 0x10000 - offset);
|
||||
}
|
||||
|
||||
int EightBit::Memory::loadBinary(const std::string& path, std::vector<uint8_t>& output, int offset, int maximumSize) {
|
||||
std::ifstream file;
|
||||
|
||||
Reference in New Issue
Block a user