2019-10-04 00:17:26 +00:00
|
|
|
//
|
|
|
|
// AtariST.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 03/10/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "AtariST.hpp"
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
#include "../../MachineTypes.hpp"
|
2019-11-09 20:31:41 +00:00
|
|
|
#include "../../../Activity/Source.hpp"
|
2019-10-04 02:47:57 +00:00
|
|
|
|
2019-10-26 20:52:06 +00:00
|
|
|
//#define LOG_TRACE
|
2020-01-03 01:15:48 +00:00
|
|
|
//bool should_log = false;
|
2023-05-10 22:13:01 +00:00
|
|
|
#include "../../../Processors/68000/68000.hpp"
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2019-11-09 20:31:41 +00:00
|
|
|
#include "../../../Components/AY38910/AY38910.hpp"
|
|
|
|
#include "../../../Components/68901/MFP68901.hpp"
|
|
|
|
#include "../../../Components/6850/6850.hpp"
|
2019-10-07 02:30:48 +00:00
|
|
|
|
2019-10-27 01:33:57 +00:00
|
|
|
#include "DMAController.hpp"
|
2019-11-02 23:47:44 +00:00
|
|
|
#include "IntelligentKeyboard.hpp"
|
2019-10-05 01:34:15 +00:00
|
|
|
#include "Video.hpp"
|
2019-10-27 01:33:57 +00:00
|
|
|
|
2019-11-09 20:31:41 +00:00
|
|
|
#include "../../../ClockReceiver/JustInTime.hpp"
|
|
|
|
#include "../../../ClockReceiver/ForceInline.hpp"
|
2019-12-21 01:49:14 +00:00
|
|
|
#include "../../../Configurable/StandardOptions.hpp"
|
2019-10-07 02:30:48 +00:00
|
|
|
|
2019-11-09 20:31:41 +00:00
|
|
|
#include "../../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
|
2019-12-09 02:01:30 +00:00
|
|
|
|
2019-11-09 20:31:41 +00:00
|
|
|
#include "../../../Outputs/Log.hpp"
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2019-11-09 20:31:41 +00:00
|
|
|
#include "../../Utility/MemoryPacker.hpp"
|
|
|
|
#include "../../Utility/MemoryFuzzer.hpp"
|
2019-10-05 02:38:46 +00:00
|
|
|
|
2022-08-10 16:00:06 +00:00
|
|
|
#include "../../../Analyser/Static/AtariST/Target.hpp"
|
|
|
|
|
2024-01-19 19:16:13 +00:00
|
|
|
namespace {
|
2024-01-20 03:17:35 +00:00
|
|
|
Log::Logger<Log::Source::AtariST> logger;
|
2024-01-19 19:16:13 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 01:34:15 +00:00
|
|
|
namespace Atari {
|
|
|
|
namespace ST {
|
2019-10-04 02:47:57 +00:00
|
|
|
|
2019-12-22 05:22:17 +00:00
|
|
|
constexpr int CLOCK_RATE = 8021247;
|
2019-10-04 02:47:57 +00:00
|
|
|
|
2022-08-10 16:00:06 +00:00
|
|
|
using Target = Analyser::Static::AtariST::Target;
|
2019-10-04 02:47:57 +00:00
|
|
|
class ConcreteMachine:
|
|
|
|
public Atari::ST::Machine,
|
2023-05-10 22:13:01 +00:00
|
|
|
public CPU::MC68000::BusHandler,
|
2020-04-02 03:19:34 +00:00
|
|
|
public MachineTypes::TimedMachine,
|
|
|
|
public MachineTypes::ScanProducer,
|
|
|
|
public MachineTypes::AudioProducer,
|
|
|
|
public MachineTypes::MouseMachine,
|
|
|
|
public MachineTypes::JoystickMachine,
|
|
|
|
public MachineTypes::MappedKeyboardMachine,
|
|
|
|
public MachineTypes::MediaTarget,
|
2019-10-22 03:02:30 +00:00
|
|
|
public ClockingHint::Observer,
|
2019-10-26 02:36:01 +00:00
|
|
|
public Motorola::ACIA::ACIA::InterruptDelegate,
|
2019-10-29 01:13:21 +00:00
|
|
|
public Motorola::MFP68901::MFP68901::InterruptDelegate,
|
2019-11-04 02:11:25 +00:00
|
|
|
public DMAController::Delegate,
|
2019-11-04 02:57:54 +00:00
|
|
|
public Activity::Source,
|
2019-12-09 01:20:13 +00:00
|
|
|
public GI::AY38910::PortHandler,
|
2019-12-21 01:49:14 +00:00
|
|
|
public Configurable::Device,
|
2019-12-09 01:20:13 +00:00
|
|
|
public Video::RangeObserver {
|
2019-10-04 02:47:57 +00:00
|
|
|
public:
|
2019-10-05 01:34:15 +00:00
|
|
|
ConcreteMachine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher) :
|
2019-10-07 02:30:48 +00:00
|
|
|
mc68000_(*this),
|
2019-10-14 01:32:34 +00:00
|
|
|
keyboard_acia_(Cycles(500000)),
|
|
|
|
midi_acia_(Cycles(500000)),
|
2019-12-19 00:28:41 +00:00
|
|
|
ay_(GI::AY38910::Personality::YM2149F, audio_queue_),
|
2019-10-17 03:21:14 +00:00
|
|
|
speaker_(ay_),
|
|
|
|
ikbd_(keyboard_acia_->transmit, keyboard_acia_->receive) {
|
2019-10-04 02:47:57 +00:00
|
|
|
set_clock_rate(CLOCK_RATE);
|
2019-12-11 01:25:27 +00:00
|
|
|
speaker_.set_input_rate(float(CLOCK_RATE) / 4.0f);
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2022-08-10 16:00:06 +00:00
|
|
|
switch(target.memory_size) {
|
|
|
|
default:
|
|
|
|
case Target::MemorySize::FiveHundredAndTwelveKilobytes:
|
|
|
|
ram_.resize(512 * 1024);
|
|
|
|
break;
|
|
|
|
case Target::MemorySize::OneMegabyte:
|
|
|
|
ram_.resize(1024 * 1024);
|
|
|
|
break;
|
|
|
|
case Target::MemorySize::FourMegabytes:
|
|
|
|
ram_.resize(4 * 1024 * 1024);
|
|
|
|
break;
|
|
|
|
}
|
2019-10-05 02:38:46 +00:00
|
|
|
Memory::Fuzz(ram_);
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2022-08-10 20:41:45 +00:00
|
|
|
video_->set_ram(
|
|
|
|
reinterpret_cast<uint16_t *>(ram_.data()),
|
|
|
|
ram_.size() >> 1
|
|
|
|
);
|
2022-08-10 16:00:06 +00:00
|
|
|
|
2021-06-04 01:55:59 +00:00
|
|
|
constexpr ROM::Name rom_name = ROM::Name::AtariSTTOS100;
|
|
|
|
ROM::Request request(rom_name);
|
2021-06-04 22:54:50 +00:00
|
|
|
auto roms = rom_fetcher(request);
|
2021-06-04 01:55:59 +00:00
|
|
|
if(!request.validate(roms)) {
|
2019-10-05 01:34:15 +00:00
|
|
|
throw ROMMachine::Error::MissingROMs;
|
|
|
|
}
|
2021-06-04 01:55:59 +00:00
|
|
|
Memory::PackBigEndian16(roms.find(rom_name)->second, rom_);
|
2019-10-06 21:15:29 +00:00
|
|
|
|
|
|
|
// Set up basic memory map.
|
2023-11-27 20:48:30 +00:00
|
|
|
int c = 0;
|
2019-12-09 01:20:13 +00:00
|
|
|
for(; c < int(ram_.size() >> 16); ++c) memory_map_[c] = BusDevice::RAM;
|
2019-12-08 16:52:43 +00:00
|
|
|
for(; c < 0x40; ++c) memory_map_[c] = BusDevice::Floating;
|
2019-10-26 20:52:06 +00:00
|
|
|
for(; c < 0xff; ++c) memory_map_[c] = BusDevice::Unassigned;
|
2019-10-06 21:15:29 +00:00
|
|
|
|
2019-10-26 20:52:06 +00:00
|
|
|
const bool is_early_tos = true;
|
|
|
|
if(is_early_tos) {
|
2020-01-31 04:09:24 +00:00
|
|
|
rom_start_ = 0xfc0000;
|
2019-10-26 20:52:06 +00:00
|
|
|
for(c = 0xfc; c < 0xff; ++c) memory_map_[c] = BusDevice::ROM;
|
|
|
|
} else {
|
2020-01-31 04:09:24 +00:00
|
|
|
rom_start_ = 0xe00000;
|
2019-10-26 20:52:06 +00:00
|
|
|
for(c = 0xe0; c < 0xe4; ++c) memory_map_[c] = BusDevice::ROM;
|
|
|
|
}
|
2019-10-06 21:15:29 +00:00
|
|
|
|
2019-10-26 20:52:06 +00:00
|
|
|
memory_map_[0xfa] = memory_map_[0xfb] = BusDevice::Cartridge;
|
2019-10-06 21:15:29 +00:00
|
|
|
memory_map_[0xff] = BusDevice::IO;
|
2019-10-21 02:10:05 +00:00
|
|
|
|
2023-11-27 20:48:30 +00:00
|
|
|
// Copy the first 8 bytes of ROM into RAM.
|
|
|
|
reinstall_rom_vector();
|
|
|
|
|
2019-10-22 03:02:30 +00:00
|
|
|
midi_acia_->set_interrupt_delegate(this);
|
|
|
|
keyboard_acia_->set_interrupt_delegate(this);
|
|
|
|
|
2019-10-21 02:10:05 +00:00
|
|
|
midi_acia_->set_clocking_hint_observer(this);
|
|
|
|
keyboard_acia_->set_clocking_hint_observer(this);
|
2019-10-21 03:13:44 +00:00
|
|
|
ikbd_.set_clocking_hint_observer(this);
|
2019-10-31 02:42:06 +00:00
|
|
|
mfp_->set_clocking_hint_observer(this);
|
2019-10-31 02:59:32 +00:00
|
|
|
dma_->set_clocking_hint_observer(this);
|
2019-10-22 03:02:30 +00:00
|
|
|
|
2019-10-26 02:36:01 +00:00
|
|
|
mfp_->set_interrupt_delegate(this);
|
2019-11-04 02:11:25 +00:00
|
|
|
dma_->set_delegate(this);
|
2019-11-03 03:04:08 +00:00
|
|
|
ay_.set_port_handler(this);
|
2019-10-26 02:36:01 +00:00
|
|
|
|
2019-10-22 03:02:30 +00:00
|
|
|
set_gpip_input();
|
2019-11-03 03:26:42 +00:00
|
|
|
|
2019-12-09 01:20:13 +00:00
|
|
|
video_->set_range_observer(this);
|
|
|
|
|
2019-11-03 03:26:42 +00:00
|
|
|
// Insert any supplied media.
|
|
|
|
insert_media(target.media);
|
2019-10-04 02:47:57 +00:00
|
|
|
}
|
|
|
|
|
2019-10-07 02:30:48 +00:00
|
|
|
~ConcreteMachine() {
|
|
|
|
audio_queue_.flush();
|
|
|
|
}
|
|
|
|
|
2019-10-05 01:34:15 +00:00
|
|
|
// MARK: CRTMachine::Machine
|
2019-10-04 02:47:57 +00:00
|
|
|
void set_scan_target(Outputs::Display::ScanTarget *scan_target) final {
|
2019-10-05 01:34:15 +00:00
|
|
|
video_->set_scan_target(scan_target);
|
2019-10-04 02:47:57 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 03:28:25 +00:00
|
|
|
Outputs::Display::ScanStatus get_scaled_scan_status() const final {
|
|
|
|
return video_->get_scaled_scan_status();
|
2020-01-21 02:45:10 +00:00
|
|
|
}
|
|
|
|
|
2019-12-21 01:49:14 +00:00
|
|
|
void set_display_type(Outputs::Display::DisplayType display_type) final {
|
|
|
|
video_->set_display_type(display_type);
|
|
|
|
}
|
|
|
|
|
2020-05-21 03:34:26 +00:00
|
|
|
Outputs::Display::DisplayType get_display_type() const final {
|
2020-03-18 03:52:55 +00:00
|
|
|
return video_->get_display_type();
|
|
|
|
}
|
|
|
|
|
2019-10-04 02:47:57 +00:00
|
|
|
Outputs::Speaker::Speaker *get_speaker() final {
|
2019-10-07 02:30:48 +00:00
|
|
|
return &speaker_;
|
2019-10-04 02:47:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void run_for(const Cycles cycles) final {
|
2019-11-03 01:25:45 +00:00
|
|
|
// Give the keyboard an opportunity to consume any events.
|
|
|
|
if(!keyboard_needs_clock_) {
|
|
|
|
ikbd_.run_for(HalfCycles(0));
|
|
|
|
}
|
|
|
|
|
2019-10-05 01:34:15 +00:00
|
|
|
mc68000_.run_for(cycles);
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: MC68000::BusHandler
|
2023-12-22 04:08:18 +00:00
|
|
|
template <typename Microcycle> HalfCycles perform_bus_operation(const Microcycle &cycle, int is_supervisor) {
|
2019-11-01 01:00:05 +00:00
|
|
|
// Just in case the last cycle was an interrupt acknowledge or bus error. TODO: find a better solution?
|
|
|
|
mc68000_.set_is_peripheral_address(false);
|
|
|
|
mc68000_.set_bus_error(false);
|
|
|
|
|
2019-10-05 02:38:46 +00:00
|
|
|
// Advance time.
|
2019-10-07 02:30:48 +00:00
|
|
|
advance_time(cycle.length);
|
2019-10-05 02:38:46 +00:00
|
|
|
|
2019-12-09 02:01:30 +00:00
|
|
|
// Check for assertion of reset.
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::Reset) {
|
2024-01-19 19:16:13 +00:00
|
|
|
logger.error().append("Unhandled Reset");
|
2019-12-09 02:01:30 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 02:38:46 +00:00
|
|
|
// A null cycle leaves nothing else to do.
|
2023-12-22 04:08:18 +00:00
|
|
|
if(!(cycle.operation & (CPU::MC68000::Operation::NewAddress | CPU::MC68000::Operation::SameAddress))) return HalfCycles(0);
|
2019-10-05 02:38:46 +00:00
|
|
|
|
2019-10-26 02:36:01 +00:00
|
|
|
// An interrupt acknowledge, perhaps?
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::InterruptAcknowledge) {
|
2021-07-23 23:23:54 +00:00
|
|
|
// Current implementation: everything other than 6 (i.e. the MFP) is autovectored.
|
2019-12-31 04:00:55 +00:00
|
|
|
const int interrupt_level = cycle.word_address()&7;
|
|
|
|
if(interrupt_level != 6) {
|
|
|
|
video_interrupts_pending_ &= ~interrupt_level;
|
|
|
|
update_interrupt_input();
|
2019-10-26 02:36:01 +00:00
|
|
|
mc68000_.set_is_peripheral_address(true);
|
|
|
|
return HalfCycles(0);
|
|
|
|
} else {
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::SelectByte) {
|
2019-11-01 01:00:05 +00:00
|
|
|
const int interrupt = mfp_->acknowledge_interrupt();
|
|
|
|
if(interrupt != Motorola::MFP68901::MFP68901::NoAcknowledgement) {
|
2022-06-04 12:43:43 +00:00
|
|
|
cycle.value->b = uint8_t(interrupt);
|
2019-11-01 01:00:05 +00:00
|
|
|
} else {
|
|
|
|
// TODO: this should take a while. Find out how long.
|
|
|
|
mc68000_.set_bus_error(true);
|
|
|
|
}
|
2019-10-26 02:36:01 +00:00
|
|
|
}
|
|
|
|
return HalfCycles(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-09 01:20:13 +00:00
|
|
|
auto address = cycle.host_endian_byte_address();
|
2019-11-19 03:57:13 +00:00
|
|
|
|
2019-11-08 00:55:00 +00:00
|
|
|
// If this is a new strobing of the address signal, test for bus error and pre-DTack delay.
|
|
|
|
HalfCycles delay(0);
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::NewAddress) {
|
2019-12-09 01:20:13 +00:00
|
|
|
// Bus error test.
|
2019-12-08 16:52:43 +00:00
|
|
|
if(
|
|
|
|
// Anything unassigned should generate a bus error.
|
2019-12-09 01:20:13 +00:00
|
|
|
(memory_map_[address >> 16] == BusDevice::Unassigned) ||
|
2019-12-08 16:52:43 +00:00
|
|
|
|
|
|
|
// Bus errors also apply to unprivileged access to the first 0x800 bytes, or the IO area.
|
2019-12-09 01:20:13 +00:00
|
|
|
(!is_supervisor && (address < 0x800 || memory_map_[address >> 16] == BusDevice::IO))
|
2019-12-08 16:52:43 +00:00
|
|
|
) {
|
|
|
|
mc68000_.set_bus_error(true);
|
|
|
|
return delay; // TODO: there should be an extra delay here.
|
2019-11-08 00:55:00 +00:00
|
|
|
}
|
|
|
|
|
2019-12-08 16:52:43 +00:00
|
|
|
// DTack delay rule: if accessing RAM or the shifter, align with the two cycles next available
|
|
|
|
// for the CPU to access that side of the bus.
|
2019-12-09 01:20:13 +00:00
|
|
|
if(address < ram_.size() || (address == 0xff8260)) {
|
2019-12-08 16:52:43 +00:00
|
|
|
// DTack will be implicit; work out how long until that should be,
|
|
|
|
// and apply bus error constraints.
|
|
|
|
const int i_phase = bus_phase_.as<int>() & 7;
|
|
|
|
if(i_phase < 4) {
|
|
|
|
delay = HalfCycles(4 - i_phase);
|
|
|
|
advance_time(delay);
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 00:55:00 +00:00
|
|
|
}
|
|
|
|
|
2019-12-09 01:20:13 +00:00
|
|
|
uint8_t *memory = nullptr;
|
|
|
|
switch(memory_map_[address >> 16]) {
|
2019-11-09 21:12:37 +00:00
|
|
|
default:
|
2019-10-06 21:15:29 +00:00
|
|
|
case BusDevice::RAM:
|
|
|
|
memory = ram_.data();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BusDevice::ROM:
|
|
|
|
memory = rom_.data();
|
2023-12-22 04:08:18 +00:00
|
|
|
if(!(cycle.operation & CPU::MC68000::Operation::Read)) {
|
2023-11-27 20:48:30 +00:00
|
|
|
return delay;
|
|
|
|
}
|
2020-01-31 04:09:24 +00:00
|
|
|
address -= rom_start_;
|
2019-10-06 21:15:29 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-08 16:52:43 +00:00
|
|
|
case BusDevice::Floating:
|
|
|
|
// TODO: provide vapour reads here. But: will these always be of the last video fetch?
|
2019-10-10 03:01:11 +00:00
|
|
|
case BusDevice::Unassigned:
|
2019-10-06 21:15:29 +00:00
|
|
|
case BusDevice::Cartridge:
|
|
|
|
/*
|
|
|
|
TOS 1.0 appears to attempt to read from the catridge before it has setup
|
|
|
|
the bus error vector. Therefore I assume no bus error flows.
|
|
|
|
*/
|
2023-12-22 04:08:18 +00:00
|
|
|
switch(cycle.operation & (CPU::MC68000::Operation::SelectWord | CPU::MC68000::Operation::SelectByte | CPU::MC68000::Operation::Read)) {
|
2019-10-06 21:15:29 +00:00
|
|
|
default: break;
|
2023-12-21 21:03:53 +00:00
|
|
|
case CPU::MC68000::Operation::SelectWord | CPU::MC68000::Operation::Read:
|
2022-06-04 12:43:43 +00:00
|
|
|
cycle.value->w = 0xffff;
|
2019-10-06 21:15:29 +00:00
|
|
|
break;
|
2023-12-21 21:03:53 +00:00
|
|
|
case CPU::MC68000::Operation::SelectByte | CPU::MC68000::Operation::Read:
|
2022-06-04 12:43:43 +00:00
|
|
|
cycle.value->b = 0xff;
|
2019-10-06 21:15:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-11-08 00:55:00 +00:00
|
|
|
return delay;
|
2019-10-06 21:15:29 +00:00
|
|
|
|
|
|
|
case BusDevice::IO:
|
2020-01-05 01:35:47 +00:00
|
|
|
switch(address & 0xfffe) { // TODO: surely it's going to be even less precise than this?
|
2019-10-07 02:30:48 +00:00
|
|
|
default:
|
2019-10-26 20:52:06 +00:00
|
|
|
// assert(false);
|
2019-10-07 02:30:48 +00:00
|
|
|
|
2020-01-05 01:35:47 +00:00
|
|
|
case 0x8000:
|
2019-10-07 02:30:48 +00:00
|
|
|
/* Memory controller configuration:
|
|
|
|
b0, b1: bank 1
|
|
|
|
b2, b3: bank 0
|
|
|
|
|
|
|
|
00 = 128k
|
|
|
|
01 = 512k
|
|
|
|
10 = 2mb
|
|
|
|
11 = reserved
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2020-01-05 02:06:21 +00:00
|
|
|
// Video controls.
|
|
|
|
case 0x8200: case 0x8202: case 0x8204: case 0x8206:
|
|
|
|
case 0x8208: case 0x820a: case 0x820c: case 0x820e:
|
|
|
|
case 0x8210: case 0x8212: case 0x8214: case 0x8216:
|
|
|
|
case 0x8218: case 0x821a: case 0x821c: case 0x821e:
|
|
|
|
case 0x8220: case 0x8222: case 0x8224: case 0x8226:
|
|
|
|
case 0x8228: case 0x822a: case 0x822c: case 0x822e:
|
|
|
|
case 0x8230: case 0x8232: case 0x8234: case 0x8236:
|
|
|
|
case 0x8238: case 0x823a: case 0x823c: case 0x823e:
|
|
|
|
case 0x8240: case 0x8242: case 0x8244: case 0x8246:
|
|
|
|
case 0x8248: case 0x824a: case 0x824c: case 0x824e:
|
|
|
|
case 0x8250: case 0x8252: case 0x8254: case 0x8256:
|
|
|
|
case 0x8258: case 0x825a: case 0x825c: case 0x825e:
|
|
|
|
case 0x8260: case 0x8262:
|
2023-12-22 04:08:18 +00:00
|
|
|
if(!cycle.data_select_active()) return delay;
|
2020-01-05 02:06:21 +00:00
|
|
|
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::Read) {
|
2020-01-05 02:06:21 +00:00
|
|
|
cycle.set_value16(video_->read(int(address >> 1)));
|
|
|
|
} else {
|
|
|
|
video_->write(int(address >> 1), cycle.value16());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// DMA.
|
|
|
|
case 0x8604: case 0x8606: case 0x8608: case 0x860a: case 0x860c:
|
2023-12-22 04:08:18 +00:00
|
|
|
if(!cycle.data_select_active()) return delay;
|
2020-01-05 02:06:21 +00:00
|
|
|
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::Read) {
|
2020-01-05 02:06:21 +00:00
|
|
|
cycle.set_value16(dma_->read(int(address >> 1)));
|
|
|
|
} else {
|
|
|
|
dma_->write(int(address >> 1), cycle.value16());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Audio.
|
|
|
|
//
|
|
|
|
// Re: mirrors, Dan Hollis' hardware register list asserts:
|
|
|
|
//
|
|
|
|
// "Note: PSG Registers are now fixed at these addresses. All other addresses are masked out on the Falcon. Any
|
|
|
|
// writes to the shadow registers $8804-$88FF will cause bus errors.", which I am taking to imply that those shadow
|
|
|
|
// registers exist on the Atari ST.
|
|
|
|
case 0x8800: case 0x8802: case 0x8804: case 0x8806: case 0x8808: case 0x880a: case 0x880c: case 0x880e:
|
|
|
|
case 0x8810: case 0x8812: case 0x8814: case 0x8816: case 0x8818: case 0x881a: case 0x881c: case 0x881e:
|
|
|
|
case 0x8820: case 0x8822: case 0x8824: case 0x8826: case 0x8828: case 0x882a: case 0x882c: case 0x882e:
|
|
|
|
case 0x8830: case 0x8832: case 0x8834: case 0x8836: case 0x8838: case 0x883a: case 0x883c: case 0x883e:
|
|
|
|
case 0x8840: case 0x8842: case 0x8844: case 0x8846: case 0x8848: case 0x884a: case 0x884c: case 0x884e:
|
|
|
|
case 0x8850: case 0x8852: case 0x8854: case 0x8856: case 0x8858: case 0x885a: case 0x885c: case 0x885e:
|
|
|
|
case 0x8860: case 0x8862: case 0x8864: case 0x8866: case 0x8868: case 0x886a: case 0x886c: case 0x886e:
|
|
|
|
case 0x8870: case 0x8872: case 0x8874: case 0x8876: case 0x8878: case 0x887a: case 0x887c: case 0x887e:
|
|
|
|
case 0x8880: case 0x8882: case 0x8884: case 0x8886: case 0x8888: case 0x888a: case 0x888c: case 0x888e:
|
|
|
|
case 0x8890: case 0x8892: case 0x8894: case 0x8896: case 0x8898: case 0x889a: case 0x889c: case 0x889e:
|
|
|
|
case 0x88a0: case 0x88a2: case 0x88a4: case 0x88a6: case 0x88a8: case 0x88aa: case 0x88ac: case 0x88ae:
|
|
|
|
case 0x88b0: case 0x88b2: case 0x88b4: case 0x88b6: case 0x88b8: case 0x88ba: case 0x88bc: case 0x88be:
|
|
|
|
case 0x88c0: case 0x88c2: case 0x88c4: case 0x88c6: case 0x88c8: case 0x88ca: case 0x88cc: case 0x88ce:
|
|
|
|
case 0x88d0: case 0x88d2: case 0x88d4: case 0x88d6: case 0x88d8: case 0x88da: case 0x88dc: case 0x88de:
|
|
|
|
case 0x88e0: case 0x88e2: case 0x88e4: case 0x88e6: case 0x88e8: case 0x88ea: case 0x88ec: case 0x88ee:
|
|
|
|
case 0x88f0: case 0x88f2: case 0x88f4: case 0x88f6: case 0x88f8: case 0x88fa: case 0x88fc: case 0x88fe:
|
2023-12-22 04:08:18 +00:00
|
|
|
if(!cycle.data_select_active()) return delay;
|
2019-10-07 02:30:48 +00:00
|
|
|
|
|
|
|
advance_time(HalfCycles(2));
|
|
|
|
update_audio();
|
2019-11-02 03:01:06 +00:00
|
|
|
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::Read) {
|
2021-03-27 03:19:47 +00:00
|
|
|
cycle.set_value8_high(GI::AY38910::Utility::read(ay_));
|
2019-10-07 02:30:48 +00:00
|
|
|
} else {
|
2020-01-05 02:32:34 +00:00
|
|
|
// Net effect here: addresses with bit 1 set write to a register,
|
|
|
|
// addresses with bit 1 clear select a register.
|
2021-03-27 03:19:47 +00:00
|
|
|
GI::AY38910::Utility::write(ay_, address&2, cycle.value8_high());
|
2019-10-07 02:30:48 +00:00
|
|
|
}
|
2019-11-08 00:55:00 +00:00
|
|
|
return delay + HalfCycles(2);
|
2019-10-07 03:14:05 +00:00
|
|
|
|
|
|
|
// The MFP block:
|
2020-01-05 01:35:47 +00:00
|
|
|
case 0xfa00: case 0xfa02: case 0xfa04: case 0xfa06:
|
|
|
|
case 0xfa08: case 0xfa0a: case 0xfa0c: case 0xfa0e:
|
|
|
|
case 0xfa10: case 0xfa12: case 0xfa14: case 0xfa16:
|
|
|
|
case 0xfa18: case 0xfa1a: case 0xfa1c: case 0xfa1e:
|
|
|
|
case 0xfa20: case 0xfa22: case 0xfa24: case 0xfa26:
|
|
|
|
case 0xfa28: case 0xfa2a: case 0xfa2c: case 0xfa2e:
|
|
|
|
case 0xfa30: case 0xfa32: case 0xfa34: case 0xfa36:
|
|
|
|
case 0xfa38: case 0xfa3a: case 0xfa3c: case 0xfa3e:
|
2023-12-22 04:08:18 +00:00
|
|
|
if(!cycle.data_select_active()) return delay;
|
2019-10-07 03:14:05 +00:00
|
|
|
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::Read) {
|
2019-12-09 01:20:13 +00:00
|
|
|
cycle.set_value8_low(mfp_->read(int(address >> 1)));
|
2019-10-07 03:14:05 +00:00
|
|
|
} else {
|
2019-12-09 01:20:13 +00:00
|
|
|
mfp_->write(int(address >> 1), cycle.value8_low());
|
2019-10-07 03:14:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-10 03:01:11 +00:00
|
|
|
|
2019-10-11 00:54:29 +00:00
|
|
|
// ACIAs.
|
2020-01-05 01:35:47 +00:00
|
|
|
case 0xfc00: case 0xfc02: case 0xfc04: case 0xfc06: {
|
2019-10-11 00:54:29 +00:00
|
|
|
// Set VPA.
|
2023-12-22 04:08:18 +00:00
|
|
|
mc68000_.set_is_peripheral_address(!cycle.data_select_active());
|
|
|
|
if(!cycle.data_select_active()) return delay;
|
2019-10-11 00:54:29 +00:00
|
|
|
|
2020-01-04 22:27:55 +00:00
|
|
|
const auto acia_ = (address & 4) ? &midi_acia_ : &keyboard_acia_;
|
2023-12-22 04:08:18 +00:00
|
|
|
if(cycle.operation & CPU::MC68000::Operation::Read) {
|
2019-12-09 01:20:13 +00:00
|
|
|
cycle.set_value8_high((*acia_)->read(int(address >> 1)));
|
2019-10-11 00:54:29 +00:00
|
|
|
} else {
|
2019-12-09 01:20:13 +00:00
|
|
|
(*acia_)->write(int(address >> 1), cycle.value8_high());
|
2019-10-11 00:54:29 +00:00
|
|
|
}
|
|
|
|
} break;
|
2019-10-07 02:30:48 +00:00
|
|
|
}
|
|
|
|
return HalfCycles(0);
|
2019-10-05 02:38:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If control has fallen through to here, the access is either a read from ROM, or a read or write to RAM.
|
2023-11-27 20:48:30 +00:00
|
|
|
//
|
|
|
|
// In both write cases, immediately reinstall the first eight bytes of RAM from ROM, so that any write to
|
|
|
|
// that area is in effect a no-op. This is cheaper than the conditionality of actually checking.
|
2023-12-22 04:08:18 +00:00
|
|
|
switch(cycle.operation & (CPU::MC68000::Operation::SelectWord | CPU::MC68000::Operation::SelectByte | CPU::MC68000::Operation::Read)) {
|
2019-10-05 02:38:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
2023-12-21 21:03:53 +00:00
|
|
|
case CPU::MC68000::Operation::SelectWord | CPU::MC68000::Operation::Read:
|
2022-06-04 12:43:43 +00:00
|
|
|
cycle.value->w = *reinterpret_cast<uint16_t *>(&memory[address]);
|
2019-10-05 02:38:46 +00:00
|
|
|
break;
|
2023-12-21 21:03:53 +00:00
|
|
|
case CPU::MC68000::Operation::SelectByte | CPU::MC68000::Operation::Read:
|
2022-06-04 12:43:43 +00:00
|
|
|
cycle.value->b = memory[address];
|
2019-10-05 02:38:46 +00:00
|
|
|
break;
|
2023-12-21 21:03:53 +00:00
|
|
|
case CPU::MC68000::Operation::SelectWord:
|
2019-12-09 01:20:13 +00:00
|
|
|
if(address >= video_range_.low_address && address < video_range_.high_address)
|
|
|
|
video_.flush();
|
2022-06-04 12:43:43 +00:00
|
|
|
*reinterpret_cast<uint16_t *>(&memory[address]) = cycle.value->w;
|
2023-11-27 20:48:30 +00:00
|
|
|
reinstall_rom_vector();
|
2019-10-05 02:38:46 +00:00
|
|
|
break;
|
2023-12-21 21:03:53 +00:00
|
|
|
case CPU::MC68000::Operation::SelectByte:
|
2019-12-09 01:20:13 +00:00
|
|
|
if(address >= video_range_.low_address && address < video_range_.high_address)
|
|
|
|
video_.flush();
|
2022-06-04 12:43:43 +00:00
|
|
|
memory[address] = cycle.value->b;
|
2023-11-27 20:48:30 +00:00
|
|
|
reinstall_rom_vector();
|
2019-10-05 02:38:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-10-05 01:34:15 +00:00
|
|
|
return HalfCycles(0);
|
2019-10-04 02:47:57 +00:00
|
|
|
}
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2023-11-27 20:48:30 +00:00
|
|
|
void reinstall_rom_vector() {
|
|
|
|
std::copy(rom_.begin(), rom_.begin() + 8, ram_.begin());
|
|
|
|
}
|
|
|
|
|
2022-07-09 17:33:46 +00:00
|
|
|
void flush_output(int outputs) final {
|
2019-11-04 04:03:50 +00:00
|
|
|
dma_.flush();
|
|
|
|
mfp_.flush();
|
|
|
|
keyboard_acia_.flush();
|
|
|
|
midi_acia_.flush();
|
2022-07-08 20:04:32 +00:00
|
|
|
|
2022-07-09 17:33:46 +00:00
|
|
|
if(outputs & Output::Video) {
|
2022-07-08 20:04:32 +00:00
|
|
|
video_.flush();
|
|
|
|
}
|
2022-07-09 17:33:46 +00:00
|
|
|
if(outputs & Output::Audio) {
|
2022-07-08 20:04:32 +00:00
|
|
|
update_audio();
|
|
|
|
audio_queue_.perform();
|
|
|
|
}
|
2019-10-07 02:30:48 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 01:34:15 +00:00
|
|
|
private:
|
2019-10-07 02:30:48 +00:00
|
|
|
forceinline void advance_time(HalfCycles length) {
|
2019-10-31 02:42:06 +00:00
|
|
|
// Advance the relevant counters.
|
2019-10-07 02:30:48 +00:00
|
|
|
cycles_since_audio_update_ += length;
|
2019-10-07 03:14:05 +00:00
|
|
|
mfp_ += length;
|
2020-02-13 04:23:42 +00:00
|
|
|
if(dma_clocking_preference_ != ClockingHint::Preference::None)
|
|
|
|
dma_ += length;
|
2019-10-13 22:19:39 +00:00
|
|
|
keyboard_acia_ += length;
|
|
|
|
midi_acia_ += length;
|
2019-11-08 00:55:00 +00:00
|
|
|
bus_phase_ += length;
|
2019-10-31 02:42:06 +00:00
|
|
|
|
|
|
|
// Don't even count time for the keyboard unless it has requested it.
|
|
|
|
if(keyboard_needs_clock_) {
|
|
|
|
cycles_since_ikbd_update_ += length;
|
|
|
|
ikbd_.run_for(cycles_since_ikbd_update_.divide(HalfCycles(512)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flush anything that needs real-time updating.
|
2019-10-21 02:10:05 +00:00
|
|
|
if(!may_defer_acias_) {
|
|
|
|
keyboard_acia_.flush();
|
|
|
|
midi_acia_.flush();
|
|
|
|
}
|
2019-10-09 03:06:50 +00:00
|
|
|
|
2019-10-31 02:42:06 +00:00
|
|
|
if(mfp_is_realtime_) {
|
|
|
|
mfp_.flush();
|
|
|
|
}
|
|
|
|
|
2020-02-13 04:23:42 +00:00
|
|
|
if(dma_clocking_preference_ == ClockingHint::Preference::RealTime) {
|
2019-10-31 02:42:06 +00:00
|
|
|
dma_.flush();
|
2019-10-21 03:13:44 +00:00
|
|
|
}
|
|
|
|
|
2019-10-31 02:42:06 +00:00
|
|
|
// Update the video output, checking whether a sequence point has been hit.
|
2020-11-16 02:58:18 +00:00
|
|
|
if(video_.will_flush(length)) {
|
|
|
|
length -= video_.cycles_until_implicit_flush();
|
|
|
|
video_ += video_.cycles_until_implicit_flush();
|
2019-10-09 03:06:50 +00:00
|
|
|
|
2023-11-27 19:57:41 +00:00
|
|
|
mfp_->set_timer_event_input<1>(video_->display_enabled());
|
2019-10-26 02:42:13 +00:00
|
|
|
update_interrupt_input();
|
2019-10-09 03:06:50 +00:00
|
|
|
}
|
2020-11-16 02:58:18 +00:00
|
|
|
|
2019-10-09 03:06:50 +00:00
|
|
|
video_ += length;
|
2019-10-07 02:30:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void update_audio() {
|
|
|
|
speaker_.run_for(audio_queue_, cycles_since_audio_update_.divide_cycles(Cycles(4)));
|
|
|
|
}
|
|
|
|
|
2023-05-10 22:13:01 +00:00
|
|
|
CPU::MC68000::Processor<ConcreteMachine, true, true> mc68000_;
|
2019-11-08 00:55:00 +00:00
|
|
|
HalfCycles bus_phase_;
|
|
|
|
|
2019-10-13 22:19:39 +00:00
|
|
|
JustInTimeActor<Video> video_;
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2019-10-29 01:35:10 +00:00
|
|
|
// The MFP runs at 819200/2673749ths of the CPU clock rate.
|
2021-04-04 21:33:49 +00:00
|
|
|
JustInTimeActor<Motorola::MFP68901::MFP68901, HalfCycles, 819200, 2673749> mfp_;
|
|
|
|
JustInTimeActor<Motorola::ACIA::ACIA, HalfCycles, 16> keyboard_acia_;
|
|
|
|
JustInTimeActor<Motorola::ACIA::ACIA, HalfCycles, 16> midi_acia_;
|
2019-10-11 00:54:29 +00:00
|
|
|
|
2022-07-16 18:41:04 +00:00
|
|
|
Concurrency::AsyncTaskQueue<false> audio_queue_;
|
2020-02-16 23:31:45 +00:00
|
|
|
GI::AY38910::AY38910<false> ay_;
|
2021-11-21 20:37:29 +00:00
|
|
|
Outputs::Speaker::PullLowpass<GI::AY38910::AY38910<false>> speaker_;
|
2019-10-07 02:30:48 +00:00
|
|
|
HalfCycles cycles_since_audio_update_;
|
|
|
|
|
2019-10-27 01:33:57 +00:00
|
|
|
JustInTimeActor<DMAController> dma_;
|
|
|
|
|
2019-10-21 03:13:44 +00:00
|
|
|
HalfCycles cycles_since_ikbd_update_;
|
2019-10-17 03:21:14 +00:00
|
|
|
IntelligentKeyboard ikbd_;
|
|
|
|
|
2019-12-09 01:20:13 +00:00
|
|
|
std::vector<uint8_t> ram_;
|
|
|
|
std::vector<uint8_t> rom_;
|
2020-01-31 04:09:24 +00:00
|
|
|
uint32_t rom_start_ = 0;
|
2019-10-05 01:34:15 +00:00
|
|
|
|
2019-10-06 21:15:29 +00:00
|
|
|
enum class BusDevice {
|
2019-12-08 16:52:43 +00:00
|
|
|
/// Allows reads and writes to ram_.
|
|
|
|
RAM,
|
|
|
|
/// Nothing is mapped to this area, and it also doesn't trigger an exception upon access.
|
|
|
|
Floating,
|
|
|
|
/// Allows reading from rom_; writes do nothing.
|
|
|
|
ROM,
|
|
|
|
/// Allows interaction with a cartrige_.
|
|
|
|
Cartridge,
|
|
|
|
/// Marks the IO page, in which finer decoding will occur.
|
|
|
|
IO,
|
|
|
|
/// An unassigned page has nothing below it, in a way that triggers exceptions.
|
|
|
|
Unassigned
|
2019-10-06 21:15:29 +00:00
|
|
|
};
|
|
|
|
BusDevice memory_map_[256];
|
2019-10-21 02:10:05 +00:00
|
|
|
|
2019-10-22 03:02:30 +00:00
|
|
|
// MARK: - Clocking Management.
|
2019-10-21 02:10:05 +00:00
|
|
|
bool may_defer_acias_ = true;
|
2019-10-21 03:13:44 +00:00
|
|
|
bool keyboard_needs_clock_ = false;
|
2019-10-31 02:42:06 +00:00
|
|
|
bool mfp_is_realtime_ = false;
|
2020-02-13 04:23:42 +00:00
|
|
|
ClockingHint::Preference dma_clocking_preference_ = ClockingHint::Preference::None;
|
2020-05-30 04:37:06 +00:00
|
|
|
void set_component_prefers_clocking(ClockingHint::Source *, ClockingHint::Preference) final {
|
2019-10-21 02:10:05 +00:00
|
|
|
// This is being called by one of the components; avoid any time flushing here as that's
|
|
|
|
// already dealt with (and, just to be absolutely sure, to avoid recursive mania).
|
|
|
|
may_defer_acias_ =
|
|
|
|
(keyboard_acia_.last_valid()->preferred_clocking() != ClockingHint::Preference::RealTime) &&
|
|
|
|
(midi_acia_.last_valid()->preferred_clocking() != ClockingHint::Preference::RealTime);
|
2019-10-21 03:13:44 +00:00
|
|
|
keyboard_needs_clock_ = ikbd_.preferred_clocking() != ClockingHint::Preference::None;
|
2019-10-31 02:42:06 +00:00
|
|
|
mfp_is_realtime_ = mfp_.last_valid()->preferred_clocking() == ClockingHint::Preference::RealTime;
|
2020-02-13 04:23:42 +00:00
|
|
|
dma_clocking_preference_ = dma_.last_valid()->preferred_clocking();
|
2019-10-21 02:10:05 +00:00
|
|
|
}
|
2019-10-22 03:02:30 +00:00
|
|
|
|
|
|
|
// MARK: - GPIP input.
|
2019-10-29 01:13:21 +00:00
|
|
|
void acia6850_did_change_interrupt_status(Motorola::ACIA::ACIA *) final {
|
|
|
|
set_gpip_input();
|
|
|
|
}
|
2019-11-04 02:11:25 +00:00
|
|
|
void dma_controller_did_change_output(DMAController *) final {
|
2019-10-22 03:02:30 +00:00
|
|
|
set_gpip_input();
|
2019-11-04 02:11:25 +00:00
|
|
|
|
|
|
|
// Filty hack, here! Should: set the 68000's bus request line. But until
|
|
|
|
// that's implemented, just offers magical zero-cost DMA insertion and
|
|
|
|
// extrication.
|
|
|
|
if(dma_->get_bus_request_line()) {
|
2019-12-20 03:58:07 +00:00
|
|
|
dma_->bus_grant(reinterpret_cast<uint16_t *>(ram_.data()), ram_.size() >> 1);
|
2019-11-04 02:11:25 +00:00
|
|
|
}
|
2019-10-22 03:02:30 +00:00
|
|
|
}
|
|
|
|
void set_gpip_input() {
|
|
|
|
/*
|
|
|
|
Atari ST GPIP bits:
|
|
|
|
|
|
|
|
GPIP 7: monochrome monitor detect
|
|
|
|
GPIP 6: RS-232 ring indicator
|
|
|
|
GPIP 5: FD/HD interrupt
|
|
|
|
GPIP 4: keyboard/MIDI interrupt
|
|
|
|
GPIP 3: unused
|
|
|
|
GPIP 2: RS-232 clear to send
|
|
|
|
GPIP 1: RS-232 carrier detect
|
|
|
|
GPIP 0: centronics busy
|
|
|
|
*/
|
|
|
|
mfp_->set_port_input(
|
2020-02-02 22:26:39 +00:00
|
|
|
0x80 | // b7: Monochrome monitor detect (0 = is monochrome).
|
2019-10-28 02:39:21 +00:00
|
|
|
0x40 | // b6: RS-232 ring indicator.
|
2019-10-29 01:13:21 +00:00
|
|
|
(dma_->get_interrupt_line() ? 0x00 : 0x20) | // b5: FD/HS interrupt (0 = interrupt requested).
|
|
|
|
((keyboard_acia_->get_interrupt_line() || midi_acia_->get_interrupt_line()) ? 0x00 : 0x10) | // b4: Keyboard/MIDI interrupt (0 = interrupt requested).
|
2019-10-28 02:39:21 +00:00
|
|
|
0x08 | // b3: Unused
|
|
|
|
0x04 | // b2: RS-232 clear to send.
|
|
|
|
0x02 | // b1 : RS-232 carrier detect.
|
|
|
|
0x00 // b0: Centronics busy (1 = busy).
|
2019-10-22 03:02:30 +00:00
|
|
|
);
|
|
|
|
}
|
2019-10-26 02:36:01 +00:00
|
|
|
|
|
|
|
// MARK - MFP input.
|
2020-05-30 04:37:06 +00:00
|
|
|
void mfp68901_did_change_interrupt_status(Motorola::MFP68901::MFP68901 *) final {
|
2019-10-26 02:36:01 +00:00
|
|
|
update_interrupt_input();
|
|
|
|
}
|
|
|
|
|
2019-12-31 04:00:55 +00:00
|
|
|
int video_interrupts_pending_ = 0;
|
|
|
|
bool previous_hsync_ = false, previous_vsync_ = false;
|
2019-10-26 02:36:01 +00:00
|
|
|
void update_interrupt_input() {
|
2019-12-31 04:00:55 +00:00
|
|
|
// Complete guess: set video interrupts pending if/when hsync of vsync
|
|
|
|
// go inactive. Reset upon IACK.
|
|
|
|
const bool hsync = video_.last_valid()->hsync();
|
|
|
|
const bool vsync = video_.last_valid()->vsync();
|
|
|
|
if(previous_hsync_ != hsync && previous_hsync_) {
|
|
|
|
video_interrupts_pending_ |= 2;
|
|
|
|
}
|
|
|
|
if(previous_vsync_ != vsync && previous_vsync_) {
|
|
|
|
video_interrupts_pending_ |= 4;
|
|
|
|
}
|
|
|
|
previous_vsync_ = vsync;
|
|
|
|
previous_hsync_ = hsync;
|
|
|
|
|
2019-10-26 02:36:01 +00:00
|
|
|
if(mfp_->get_interrupt_line()) {
|
|
|
|
mc68000_.set_interrupt_level(6);
|
2019-12-31 04:00:55 +00:00
|
|
|
} else if(video_interrupts_pending_ & 4) {
|
2019-10-26 02:42:13 +00:00
|
|
|
mc68000_.set_interrupt_level(4);
|
2019-12-31 04:00:55 +00:00
|
|
|
} else if(video_interrupts_pending_ & 2) {
|
2019-10-26 02:42:13 +00:00
|
|
|
mc68000_.set_interrupt_level(2);
|
2019-10-26 02:36:01 +00:00
|
|
|
} else {
|
|
|
|
mc68000_.set_interrupt_level(0);
|
|
|
|
}
|
|
|
|
}
|
2019-11-03 01:25:45 +00:00
|
|
|
|
|
|
|
// MARK: - MouseMachine
|
|
|
|
Inputs::Mouse &get_mouse() final {
|
|
|
|
return ikbd_;
|
|
|
|
}
|
2019-11-03 02:30:02 +00:00
|
|
|
|
|
|
|
// MARK: - KeyboardMachine
|
|
|
|
void set_key_state(uint16_t key, bool is_pressed) final {
|
|
|
|
ikbd_.set_key_state(Key(key), is_pressed);
|
|
|
|
}
|
|
|
|
|
|
|
|
IntelligentKeyboard::KeyboardMapper keyboard_mapper_;
|
|
|
|
KeyboardMapper *get_keyboard_mapper() final {
|
|
|
|
return &keyboard_mapper_;
|
|
|
|
}
|
|
|
|
|
2019-11-09 23:19:05 +00:00
|
|
|
// MARK: - JoystickMachine
|
|
|
|
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final {
|
|
|
|
return ikbd_.get_joysticks();
|
|
|
|
}
|
|
|
|
|
2019-11-03 03:04:08 +00:00
|
|
|
// MARK: - AYPortHandler
|
|
|
|
void set_port_output(bool port_b, uint8_t value) final {
|
|
|
|
if(port_b) {
|
|
|
|
// TODO: ?
|
|
|
|
} else {
|
|
|
|
/*
|
2019-12-20 03:19:59 +00:00
|
|
|
Port A:
|
2019-11-03 03:04:08 +00:00
|
|
|
b7: reserved
|
|
|
|
b6: "freely usable output (monitor jack)"
|
|
|
|
b5: centronics strobe
|
|
|
|
b4: RS-232 DTR output
|
|
|
|
b3: RS-232 RTS output
|
|
|
|
b2: select floppy drive 1
|
|
|
|
b1: select floppy drive 0
|
|
|
|
b0: "page choice signal for double-sided floppy drive"
|
|
|
|
*/
|
2019-11-04 02:11:25 +00:00
|
|
|
dma_->set_floppy_drive_selection(!(value & 2), !(value & 4), !(value & 1));
|
2019-11-03 03:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-03 03:26:42 +00:00
|
|
|
|
|
|
|
// MARK: - MediaTarget
|
|
|
|
bool insert_media(const Analyser::Static::Media &media) final {
|
|
|
|
size_t c = 0;
|
|
|
|
for(const auto &disk: media.disks) {
|
|
|
|
dma_->set_floppy_disk(disk, c);
|
|
|
|
++c;
|
|
|
|
if(c == 2) break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2019-11-04 02:57:54 +00:00
|
|
|
|
|
|
|
// MARK: - Activity Source
|
2020-01-24 03:57:51 +00:00
|
|
|
void set_activity_observer(Activity::Observer *observer) final {
|
2019-11-04 02:57:54 +00:00
|
|
|
dma_->set_activity_observer(observer);
|
|
|
|
}
|
2019-12-09 01:20:13 +00:00
|
|
|
|
|
|
|
// MARK: - Video Range
|
|
|
|
Video::Range video_range_;
|
|
|
|
void video_did_change_access_range(Video *video) final {
|
|
|
|
video_range_ = video->get_memory_access_range();
|
|
|
|
}
|
2019-12-21 01:49:14 +00:00
|
|
|
|
|
|
|
// MARK: - Configuration options.
|
2020-03-17 03:25:05 +00:00
|
|
|
std::unique_ptr<Reflection::Struct> get_options() final {
|
2020-03-18 03:52:55 +00:00
|
|
|
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
|
|
|
options->output = get_video_signal_configurable();
|
|
|
|
return options;
|
2019-12-21 01:49:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-18 03:52:55 +00:00
|
|
|
void set_options(const std::unique_ptr<Reflection::Struct> &str) final {
|
|
|
|
const auto options = dynamic_cast<Options *>(str.get());
|
|
|
|
set_video_signal_configurable(options->output);
|
2019-12-21 01:49:14 +00:00
|
|
|
}
|
2019-11-03 02:30:02 +00:00
|
|
|
};
|
2019-10-04 02:47:57 +00:00
|
|
|
|
2019-10-05 01:34:15 +00:00
|
|
|
}
|
2019-10-04 02:47:57 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 00:17:26 +00:00
|
|
|
using namespace Atari::ST;
|
|
|
|
|
2024-01-13 03:03:19 +00:00
|
|
|
std::unique_ptr<Machine> Machine::AtariST(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) {
|
2022-08-10 16:00:06 +00:00
|
|
|
auto *const atari_target = dynamic_cast<const Analyser::Static::AtariST::Target *>(target);
|
|
|
|
if(!atari_target) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-01-13 03:03:19 +00:00
|
|
|
return std::make_unique<ConcreteMachine>(*atari_target, rom_fetcher);
|
2019-10-04 00:17:26 +00:00
|
|
|
}
|