// // 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; Machine::Machine() : _cycles_since_video_update(0) { set_clock_rate(1000000); _via.set_interrupt_delegate(this); } void Machine::configure_as_target(const StaticAnalyser::Target &target) { } void Machine::set_rom(std::vector data) { memcpy(_rom, data.data(), std::min(data.size(), sizeof(_rom))); } unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) { if(address >= 0xc000) { if(isReadOperation(operation)) *value = _rom[address&16383]; } else { if((address & 0xff00) == 0x0300) { if(isReadOperation(operation)) *value = _via.get_register(address); else _via.set_register(address, *value); } else { if(isReadOperation(operation)) *value = _ram[address]; else { if(address >= 0x9800) update_video(); _ram[address] = *value; } } } _via.run_for_half_cycles(2); _cycles_since_video_update++; return 1; } void Machine::synchronise() { update_video(); } void Machine::update_video() { _videoOutput->run_for_cycles(_cycles_since_video_update); _cycles_since_video_update = 0; } void Machine::setup_output(float aspect_ratio) { _videoOutput.reset(new VideoOutput(_ram)); } void Machine::close_output() { _videoOutput.reset(); } void Machine::mos6522_did_change_interrupt_status(void *mos6522) { set_irq_line(_via.get_interrupt_line()); }