2021-07-17 00:30:48 +00:00
|
|
|
//
|
|
|
|
// Amiga.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/07/2021.
|
|
|
|
// Copyright © 2021 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Amiga.hpp"
|
|
|
|
|
2021-07-17 00:49:12 +00:00
|
|
|
#include "../MachineTypes.hpp"
|
|
|
|
|
2021-07-17 01:07:12 +00:00
|
|
|
#include "../../Processors/68000/68000.hpp"
|
|
|
|
|
2021-07-17 00:30:48 +00:00
|
|
|
#include "../../Analyser/Static/Amiga/Target.hpp"
|
|
|
|
|
2021-07-17 01:07:12 +00:00
|
|
|
#include "../Utility/MemoryPacker.hpp"
|
|
|
|
#include "../Utility/MemoryFuzzer.hpp"
|
|
|
|
|
2021-07-17 00:30:48 +00:00
|
|
|
namespace Amiga {
|
|
|
|
|
|
|
|
class ConcreteMachine:
|
2021-07-17 01:07:12 +00:00
|
|
|
public CPU::MC68000::BusHandler,
|
2021-07-17 00:49:12 +00:00
|
|
|
public MachineTypes::ScanProducer,
|
|
|
|
public MachineTypes::TimedMachine,
|
2021-07-17 00:30:48 +00:00
|
|
|
public Machine {
|
|
|
|
public:
|
2021-07-17 01:07:12 +00:00
|
|
|
ConcreteMachine(const Analyser::Static::Amiga::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) :
|
|
|
|
mc68000_(*this)
|
|
|
|
{
|
2021-07-17 00:30:48 +00:00
|
|
|
(void)target;
|
|
|
|
(void)rom_fetcher;
|
2021-07-17 00:49:12 +00:00
|
|
|
|
2021-07-17 01:07:12 +00:00
|
|
|
// Temporary: use a hard-coded Kickstart selection.
|
|
|
|
constexpr ROM::Name rom_name = ROM::Name::AmigaA500Kickstart13;
|
|
|
|
ROM::Request request(rom_name);
|
|
|
|
auto roms = rom_fetcher(request);
|
|
|
|
if(!request.validate(roms)) {
|
|
|
|
throw ROMMachine::Error::MissingROMs;
|
|
|
|
}
|
|
|
|
Memory::PackBigEndian16(roms.find(rom_name)->second, kickstart_);
|
|
|
|
|
2021-07-17 00:49:12 +00:00
|
|
|
// NTSC clock rate: 2*3.579545 = 7.15909Mhz.
|
|
|
|
// PAL clock rate: 7.09379Mhz.
|
|
|
|
set_clock_rate(7'093'790.0);
|
|
|
|
}
|
|
|
|
|
2021-07-17 01:07:12 +00:00
|
|
|
// MARK: - MC68000::BusHandler.
|
|
|
|
using Microcycle = CPU::MC68000::Microcycle;
|
|
|
|
HalfCycles perform_bus_operation(const CPU::MC68000::Microcycle &cycle, int is_supervisor) {
|
|
|
|
(void)cycle;
|
|
|
|
(void)is_supervisor;
|
|
|
|
|
|
|
|
return HalfCycles(0);
|
|
|
|
}
|
2021-07-17 00:49:12 +00:00
|
|
|
|
|
|
|
private:
|
2021-07-17 01:07:12 +00:00
|
|
|
CPU::MC68000::Processor<ConcreteMachine, true> mc68000_;
|
|
|
|
std::vector<uint8_t> kickstart_;
|
|
|
|
|
2021-07-17 00:49:12 +00:00
|
|
|
// MARK: - MachineTypes::ScanProducer.
|
|
|
|
|
|
|
|
void set_scan_target(Outputs::Display::ScanTarget *scan_target) final {
|
|
|
|
(void)scan_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
Outputs::Display::ScanStatus get_scaled_scan_status() const {
|
|
|
|
return Outputs::Display::ScanStatus();
|
2021-07-17 00:30:48 +00:00
|
|
|
}
|
|
|
|
|
2021-07-17 00:49:12 +00:00
|
|
|
// MARK: - MachineTypes::TimedMachine.
|
|
|
|
|
|
|
|
void run_for(const Cycles cycles) {
|
2021-07-17 01:07:12 +00:00
|
|
|
mc68000_.run_for(cycles);
|
2021-07-17 00:49:12 +00:00
|
|
|
}
|
2021-07-17 00:30:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Amiga;
|
|
|
|
|
|
|
|
Machine *Machine::Amiga(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) {
|
|
|
|
using Target = Analyser::Static::Amiga::Target;
|
|
|
|
const Target *const amiga_target = dynamic_cast<const Target *>(target);
|
|
|
|
return new Amiga::ConcreteMachine(*amiga_target, rom_fetcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
Machine::~Machine() {}
|