2019-05-04 02:16:07 +00:00
|
|
|
//
|
|
|
|
// Macintosh.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 03/05/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Macintosh.hpp"
|
|
|
|
|
2019-05-04 03:25:42 +00:00
|
|
|
#include "Video.hpp"
|
|
|
|
|
|
|
|
#include "../../CRTMachine.hpp"
|
|
|
|
|
2019-05-04 02:16:07 +00:00
|
|
|
#include "../../../Processors/68000/68000.hpp"
|
|
|
|
#include "../../../Components/6522/6522.hpp"
|
2019-05-04 03:25:42 +00:00
|
|
|
|
2019-05-04 02:39:09 +00:00
|
|
|
#include "../../Utility/MemoryPacker.hpp"
|
2019-05-04 02:16:07 +00:00
|
|
|
|
|
|
|
namespace Apple {
|
|
|
|
namespace Macintosh {
|
|
|
|
|
|
|
|
class ConcreteMachine:
|
|
|
|
public Machine,
|
2019-05-04 03:25:42 +00:00
|
|
|
public CRTMachine::Machine,
|
2019-05-04 02:16:07 +00:00
|
|
|
public CPU::MC68000::BusHandler {
|
|
|
|
public:
|
|
|
|
ConcreteMachine(const ROMMachine::ROMFetcher &rom_fetcher) :
|
2019-05-04 03:25:42 +00:00
|
|
|
mc68000_(*this),
|
2019-05-04 03:40:22 +00:00
|
|
|
video_(ram_),
|
|
|
|
via_(via_port_handler_) {
|
2019-05-04 02:16:07 +00:00
|
|
|
|
2019-05-04 02:39:09 +00:00
|
|
|
// Grab a copy of the ROM and convert it into big-endian data.
|
2019-05-04 02:16:07 +00:00
|
|
|
const auto roms = rom_fetcher("Macintosh", { "mac128k.rom" });
|
|
|
|
if(!roms[0]) {
|
|
|
|
throw ROMMachine::Error::MissingROMs;
|
|
|
|
}
|
|
|
|
roms[0]->resize(64*1024);
|
2019-05-04 02:39:09 +00:00
|
|
|
Memory::PackBigEndian16(*roms[0], rom_);
|
2019-05-04 03:25:42 +00:00
|
|
|
|
|
|
|
// The Mac runs at 7.8336mHz.
|
|
|
|
set_clock_rate(7833600.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_scan_target(Outputs::Display::ScanTarget *scan_target) override {
|
|
|
|
video_.set_scan_target(scan_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
Outputs::Speaker::Speaker *get_speaker() override {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void run_for(const Cycles cycles) override {
|
|
|
|
mc68000_.run_for(cycles);
|
2019-05-04 02:16:07 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 03:40:22 +00:00
|
|
|
HalfCycles perform_bus_operation(const CPU::MC68000::Microcycle &cycle, int is_supervisor) {
|
|
|
|
via_.run_for(cycle.length);
|
|
|
|
|
|
|
|
// TODO: the entirety of dealing with this cycle.
|
|
|
|
|
|
|
|
return HalfCycles(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Notes to self: accesses to the VIA are via the 68000's
|
|
|
|
synchronous bus.
|
|
|
|
*/
|
|
|
|
|
2019-05-04 02:16:07 +00:00
|
|
|
private:
|
2019-05-04 03:40:22 +00:00
|
|
|
class VIAPortHandler: public MOS::MOS6522::PortHandler {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-05-04 02:16:07 +00:00
|
|
|
CPU::MC68000::Processor<ConcreteMachine, true> mc68000_;
|
2019-05-04 03:25:42 +00:00
|
|
|
Video video_;
|
2019-05-04 03:40:22 +00:00
|
|
|
|
|
|
|
MOS::MOS6522::MOS6522<VIAPortHandler> via_;
|
|
|
|
VIAPortHandler via_port_handler_;
|
|
|
|
|
2019-05-04 02:39:09 +00:00
|
|
|
uint16_t rom_[32*1024];
|
|
|
|
uint16_t ram_[64*1024];
|
2019-05-04 02:16:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace Apple::Macintosh;
|
|
|
|
|
|
|
|
Machine *Machine::Macintosh(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) {
|
|
|
|
return new ConcreteMachine(rom_fetcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
Machine::~Machine() {}
|