mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-18 01:07:58 +00:00
Added a VIA. Now it's time to find out how poor my 6522 emulation is.
This commit is contained in:
parent
c9962f6502
commit
41e7eff6c8
@ -13,6 +13,7 @@ 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)
|
||||
@ -32,15 +33,24 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isReadOperation(operation))
|
||||
*value = _ram[address];
|
||||
if((address & 0xff00) == 0x0300)
|
||||
{
|
||||
if(isReadOperation(operation)) *value = _via.get_register(address);
|
||||
else _via.set_register(address, *value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(address >= 0x9800) update_video();
|
||||
_ram[address] = *value;
|
||||
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;
|
||||
}
|
||||
@ -65,3 +75,8 @@ void Machine::close_output()
|
||||
{
|
||||
_videoOutput.reset();
|
||||
}
|
||||
|
||||
void Machine::mos6522_did_change_interrupt_status(void *mos6522)
|
||||
{
|
||||
set_irq_line(_via.get_interrupt_line());
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define Oric_hpp
|
||||
|
||||
#include "../../Processors/6502/CPU6502.hpp"
|
||||
#include "../../Components/6522/6522.hpp"
|
||||
#include "../../Storage/Tape/Tape.hpp"
|
||||
|
||||
#include "../ConfigurationTarget.hpp"
|
||||
@ -23,10 +24,16 @@
|
||||
|
||||
namespace Oric {
|
||||
|
||||
class VIA: public MOS::MOS6522<VIA>, public MOS::MOS6522IRQDelegate {
|
||||
public:
|
||||
using MOS6522IRQDelegate::set_interrupt_status;
|
||||
};
|
||||
|
||||
class Machine:
|
||||
public CPU6502::Processor<Machine>,
|
||||
public CRTMachine::Machine,
|
||||
public ConfigurationTarget::Machine {
|
||||
public ConfigurationTarget::Machine,
|
||||
public MOS::MOS6522IRQDelegate::Delegate {
|
||||
|
||||
public:
|
||||
Machine();
|
||||
@ -47,6 +54,9 @@ class Machine:
|
||||
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return nullptr; }
|
||||
virtual void run_for_cycles(int number_of_cycles) { CPU6502::Processor<Machine>::run_for_cycles(number_of_cycles); }
|
||||
|
||||
// to satisfy MOS::MOS6522IRQDelegate::Delegate
|
||||
void mos6522_did_change_interrupt_status(void *mos6522);
|
||||
|
||||
private:
|
||||
// RAM and ROM
|
||||
uint8_t _ram[65536], _rom[16384];
|
||||
@ -55,6 +65,9 @@ class Machine:
|
||||
|
||||
// Outputs
|
||||
std::unique_ptr<VideoOutput> _videoOutput;
|
||||
|
||||
//
|
||||
VIA _via;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user