2017-05-17 01:28:17 +00:00
|
|
|
//
|
|
|
|
// AllRAMProcessor.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/05/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "AllRAMProcessor.hpp"
|
|
|
|
|
|
|
|
using namespace CPU;
|
|
|
|
|
|
|
|
AllRAMProcessor::AllRAMProcessor(size_t memory_size) :
|
|
|
|
memory_(memory_size),
|
|
|
|
timestamp_(0) {}
|
|
|
|
|
|
|
|
void AllRAMProcessor::set_data_at_address(uint16_t startAddress, size_t length, const uint8_t *data) {
|
|
|
|
size_t endAddress = std::min(startAddress + length, (size_t)65536);
|
|
|
|
memcpy(&memory_[startAddress], data, endAddress - startAddress);
|
|
|
|
}
|
|
|
|
|
2017-05-20 01:53:39 +00:00
|
|
|
void AllRAMProcessor::get_data_at_address(uint16_t startAddress, size_t length, uint8_t *data) {
|
|
|
|
size_t endAddress = std::min(startAddress + length, (size_t)65536);
|
|
|
|
memcpy(data, &memory_[startAddress], endAddress - startAddress);
|
|
|
|
}
|
|
|
|
|
2017-05-17 01:28:17 +00:00
|
|
|
uint32_t AllRAMProcessor::get_timestamp() {
|
|
|
|
return timestamp_;
|
|
|
|
}
|
2017-05-20 01:20:28 +00:00
|
|
|
|
|
|
|
void AllRAMProcessor::check_address_for_trap(uint16_t address) {
|
|
|
|
if(trap_addresses_.find(address) != trap_addresses_.end()) {
|
|
|
|
trap_handler_->processor_did_trap(*this, address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AllRAMProcessor::set_trap_handler(TrapHandler *trap_handler) {
|
|
|
|
trap_handler_ = trap_handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AllRAMProcessor::add_trap_address(uint16_t address) {
|
|
|
|
trap_addresses_.insert(address);
|
|
|
|
}
|