2016-10-12 02:20:13 +00:00
|
|
|
//
|
|
|
|
// Oric.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 11/10/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Oric.hpp"
|
|
|
|
|
|
|
|
using namespace Oric;
|
|
|
|
|
2016-10-12 23:20:23 +00:00
|
|
|
Machine::Machine() : _cycles_since_video_update(0)
|
2016-10-12 02:20:13 +00:00
|
|
|
{
|
|
|
|
set_clock_rate(1000000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Machine::configure_as_target(const StaticAnalyser::Target &target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-12 22:51:02 +00:00
|
|
|
void Machine::set_rom(std::vector<uint8_t> data)
|
|
|
|
{
|
|
|
|
memcpy(_rom, data.data(), std::min(data.size(), sizeof(_rom)));
|
|
|
|
}
|
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
|
|
|
{
|
2016-10-12 22:51:02 +00:00
|
|
|
if(address > 0xc000)
|
|
|
|
{
|
|
|
|
if(isReadOperation(operation)) *value = _rom[address&16383];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(isReadOperation(operation))
|
|
|
|
*value = _ram[address];
|
|
|
|
else
|
2016-10-12 23:20:23 +00:00
|
|
|
{
|
|
|
|
if(address >= 0xa000) update_video();
|
2016-10-12 22:51:02 +00:00
|
|
|
_ram[address] = *value;
|
2016-10-12 23:20:23 +00:00
|
|
|
}
|
2016-10-12 22:51:02 +00:00
|
|
|
}
|
|
|
|
|
2016-10-12 23:20:23 +00:00
|
|
|
_cycles_since_video_update++;
|
2016-10-12 02:20:13 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-10-13 01:29:21 +00:00
|
|
|
void Machine::synchronise()
|
|
|
|
{
|
|
|
|
update_video();
|
|
|
|
}
|
|
|
|
|
2016-10-12 23:20:23 +00:00
|
|
|
void Machine::update_video()
|
|
|
|
{
|
|
|
|
_videoOutput->run_for_cycles(_cycles_since_video_update);
|
|
|
|
_cycles_since_video_update = 0;
|
|
|
|
}
|
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
void Machine::setup_output(float aspect_ratio)
|
|
|
|
{
|
2016-10-12 23:20:23 +00:00
|
|
|
_videoOutput.reset(new VideoOutput(_ram));
|
2016-10-12 02:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Machine::close_output()
|
|
|
|
{
|
2016-10-13 01:29:21 +00:00
|
|
|
_videoOutput.reset();
|
2016-10-12 02:20:13 +00:00
|
|
|
}
|