2017-06-04 21:55:19 +00:00
|
|
|
//
|
|
|
|
// ZX8081.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/06/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "ZX8081.hpp"
|
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
#include "../../Processors/Z80/Z80.hpp"
|
|
|
|
#include "../../Storage/Tape/Tape.hpp"
|
|
|
|
#include "../../Storage/Tape/Parsers/ZX8081.hpp"
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
#include "../../ClockReceiver/ForceInline.hpp"
|
|
|
|
|
2017-10-21 14:30:02 +00:00
|
|
|
#include "../Utility/MemoryFuzzer.hpp"
|
|
|
|
#include "../Utility/Typer.hpp"
|
2017-06-05 13:38:49 +00:00
|
|
|
|
2017-10-21 14:52:35 +00:00
|
|
|
#include "Keyboard.hpp"
|
2017-08-03 02:12:59 +00:00
|
|
|
#include "Video.hpp"
|
|
|
|
|
2017-08-03 15:42:31 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-06-06 14:13:32 +00:00
|
|
|
namespace {
|
2017-06-11 20:42:49 +00:00
|
|
|
// The clock rate is 3.25Mhz.
|
2017-06-06 14:13:32 +00:00
|
|
|
const unsigned int ZX8081ClockRate = 3250000;
|
|
|
|
}
|
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
namespace ZX8081 {
|
|
|
|
|
2017-08-27 20:45:36 +00:00
|
|
|
template<bool is_zx81> class ConcreteMachine:
|
2017-08-03 02:16:09 +00:00
|
|
|
public Utility::TypeRecipient,
|
2017-08-03 02:12:59 +00:00
|
|
|
public CPU::Z80::BusHandler,
|
|
|
|
public Machine {
|
|
|
|
public:
|
|
|
|
ConcreteMachine() :
|
|
|
|
z80_(*this),
|
2017-11-11 03:31:27 +00:00
|
|
|
tape_player_(ZX8081ClockRate) {
|
2017-08-03 02:12:59 +00:00
|
|
|
set_clock_rate(ZX8081ClockRate);
|
|
|
|
clear_all_keys();
|
|
|
|
}
|
2017-06-04 21:55:19 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
|
2017-08-03 02:12:59 +00:00
|
|
|
HalfCycles previous_counter = horizontal_counter_;
|
|
|
|
horizontal_counter_ += cycle.length;
|
2017-06-14 00:09:09 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
if(previous_counter < vsync_start_ && horizontal_counter_ >= vsync_start_) {
|
|
|
|
video_->run_for(vsync_start_ - previous_counter);
|
|
|
|
set_hsync(true);
|
|
|
|
line_counter_ = (line_counter_ + 1) & 7;
|
|
|
|
if(nmi_is_enabled_) {
|
|
|
|
z80_.set_non_maskable_interrupt_line(true);
|
|
|
|
}
|
|
|
|
video_->run_for(horizontal_counter_ - vsync_start_);
|
|
|
|
} else if(previous_counter < vsync_end_ && horizontal_counter_ >= vsync_end_) {
|
|
|
|
video_->run_for(vsync_end_ - previous_counter);
|
|
|
|
set_hsync(false);
|
|
|
|
if(nmi_is_enabled_) {
|
|
|
|
z80_.set_non_maskable_interrupt_line(false);
|
|
|
|
z80_.set_wait_line(false);
|
|
|
|
}
|
|
|
|
video_->run_for(horizontal_counter_ - vsync_end_);
|
|
|
|
} else {
|
|
|
|
video_->run_for(cycle.length);
|
2017-06-23 02:44:06 +00:00
|
|
|
}
|
2017-06-04 22:32:23 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
if(is_zx81_) horizontal_counter_ %= HalfCycles(Cycles(207));
|
|
|
|
if(!tape_advance_delay_) {
|
|
|
|
tape_player_.run_for(cycle.length);
|
|
|
|
} else {
|
|
|
|
tape_advance_delay_ = std::max(tape_advance_delay_ - cycle.length, HalfCycles(0));
|
|
|
|
}
|
2017-06-06 13:25:18 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
if(nmi_is_enabled_ && !z80_.get_halt_line() && z80_.get_non_maskable_interrupt_line()) {
|
|
|
|
z80_.set_wait_line(true);
|
|
|
|
}
|
2017-06-06 14:13:32 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
if(!cycle.is_terminal()) {
|
|
|
|
return Cycles(0);
|
2017-06-04 22:32:23 +00:00
|
|
|
}
|
2017-08-03 02:12:59 +00:00
|
|
|
|
|
|
|
uint16_t address = cycle.address ? *cycle.address : 0;
|
|
|
|
bool is_opcode_read = false;
|
|
|
|
switch(cycle.operation) {
|
|
|
|
case CPU::Z80::PartialMachineCycle::Output:
|
|
|
|
if(!(address & 2)) nmi_is_enabled_ = false;
|
|
|
|
if(!(address & 1)) nmi_is_enabled_ = is_zx81_;
|
|
|
|
if(!nmi_is_enabled_) {
|
|
|
|
// Line counter reset is held low while vsync is active; simulate that lazily by performing
|
|
|
|
// an instant reset upon the transition from active to inactive.
|
|
|
|
if(vsync_) line_counter_ = 0;
|
|
|
|
set_vsync(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Input: {
|
|
|
|
uint8_t value = 0xff;
|
|
|
|
if(!(address&1)) {
|
|
|
|
if(!nmi_is_enabled_) set_vsync(true);
|
|
|
|
|
|
|
|
uint16_t mask = 0x100;
|
|
|
|
for(int c = 0; c < 8; c++) {
|
|
|
|
if(!(address & mask)) value &= key_states_[c];
|
|
|
|
mask <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
value &= ~(tape_player_.get_input() ? 0x00 : 0x80);
|
|
|
|
}
|
|
|
|
*cycle.value = value;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Interrupt:
|
|
|
|
// resetting event is M1 and IOREQ both simultaneously having leading edges;
|
|
|
|
// that happens 2 cycles before the end of INTACK. So the timer was reset and
|
|
|
|
// now has advanced twice.
|
|
|
|
horizontal_counter_ = HalfCycles(2);
|
|
|
|
|
|
|
|
*cycle.value = 0xff;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Refresh:
|
|
|
|
// The ZX80 and 81 signal an interrupt while refresh is active and bit 6 of the refresh
|
|
|
|
// address is low. The Z80 signals a refresh, providing the refresh address during the
|
|
|
|
// final two cycles of an opcode fetch. Therefore communicate a transient signalling
|
|
|
|
// of the IRQ line if necessary.
|
|
|
|
if(!(address & 0x40)) {
|
|
|
|
z80_.set_interrupt_line(true, Cycles(-2));
|
|
|
|
z80_.set_interrupt_line(false);
|
|
|
|
}
|
|
|
|
if(has_latched_video_byte_) {
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t char_address = static_cast<std::size_t>((address & 0xfe00) | ((latched_video_byte_ & 0x3f) << 3) | line_counter_);
|
2017-08-03 02:12:59 +00:00
|
|
|
uint8_t mask = (latched_video_byte_ & 0x80) ? 0x00 : 0xff;
|
|
|
|
if(char_address < ram_base_) {
|
|
|
|
latched_video_byte_ = rom_[char_address & rom_mask_] ^ mask;
|
|
|
|
} else {
|
|
|
|
latched_video_byte_ = ram_[address & ram_mask_] ^ mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
video_->output_byte(latched_video_byte_);
|
|
|
|
has_latched_video_byte_ = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
|
|
|
// Check for use of the fast tape hack.
|
|
|
|
if(use_fast_tape_hack_ && address == tape_trap_address_ && tape_player_.has_tape()) {
|
|
|
|
uint64_t prior_offset = tape_player_.get_tape()->get_offset();
|
|
|
|
int next_byte = parser_.get_next_byte(tape_player_.get_tape());
|
|
|
|
if(next_byte != -1) {
|
|
|
|
uint16_t hl = z80_.get_value_of_register(CPU::Z80::Register::HL);
|
2017-10-22 01:50:53 +00:00
|
|
|
ram_[hl & ram_mask_] = static_cast<uint8_t>(next_byte);
|
2017-08-03 02:12:59 +00:00
|
|
|
*cycle.value = 0x00;
|
|
|
|
z80_.set_value_of_register(CPU::Z80::Register::ProgramCounter, tape_return_address_ - 1);
|
|
|
|
|
|
|
|
// Assume that having read one byte quickly, we're probably going to be asked to read
|
|
|
|
// another shortly. Therefore, temporarily disable the tape motor for 1000 cycles in order
|
|
|
|
// to avoid fighting with real time. This is a stop-gap fix.
|
|
|
|
tape_advance_delay_ = 1000;
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
tape_player_.get_tape()->set_offset(prior_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for automatic tape control.
|
|
|
|
if(use_automatic_tape_motor_control_) {
|
|
|
|
tape_player_.set_motor_control((address >= automatic_tape_motor_start_address_) && (address < automatic_tape_motor_end_address_));
|
|
|
|
}
|
|
|
|
is_opcode_read = true;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Read:
|
|
|
|
if(address < ram_base_) {
|
|
|
|
*cycle.value = rom_[address & rom_mask_];
|
|
|
|
} else {
|
|
|
|
uint8_t value = ram_[address & ram_mask_];
|
|
|
|
|
|
|
|
// If this is an M1 cycle reading from above the 32kb mark and HALT is not
|
|
|
|
// currently active, latch for video output and return a NOP. Otherwise,
|
|
|
|
// just return the value as read.
|
|
|
|
if(is_opcode_read && address&0x8000 && !(value & 0x40) && !z80_.get_halt_line()) {
|
|
|
|
latched_video_byte_ = value;
|
|
|
|
has_latched_video_byte_ = true;
|
|
|
|
*cycle.value = 0;
|
|
|
|
} else *cycle.value = value;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Write:
|
|
|
|
if(address >= ram_base_) {
|
|
|
|
ram_[address & ram_mask_] = *cycle.value;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: break;
|
2017-06-22 01:03:39 +00:00
|
|
|
}
|
2017-06-22 01:18:09 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
if(typer_) typer_->run_for(cycle.length);
|
|
|
|
|
|
|
|
return HalfCycles(0);
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
forceinline void flush() {
|
2017-08-03 02:12:59 +00:00
|
|
|
video_->flush();
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void setup_output(float aspect_ratio) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
video_.reset(new Video);
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void close_output() override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
video_.reset();
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
std::shared_ptr<Outputs::CRT::CRT> get_crt() override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
return video_->get_crt();
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
std::shared_ptr<Outputs::Speaker> get_speaker() override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void run_for(const Cycles cycles) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
z80_.run_for(cycles);
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void configure_as_target(const StaticAnalyser::Target &target) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
is_zx81_ = target.zx8081.isZX81;
|
|
|
|
if(is_zx81_) {
|
|
|
|
rom_ = zx81_rom_;
|
|
|
|
tape_trap_address_ = 0x37c;
|
|
|
|
tape_return_address_ = 0x380;
|
|
|
|
vsync_start_ = HalfCycles(32);
|
|
|
|
vsync_end_ = HalfCycles(64);
|
|
|
|
automatic_tape_motor_start_address_ = 0x0340;
|
|
|
|
automatic_tape_motor_end_address_ = 0x03c3;
|
|
|
|
} else {
|
|
|
|
rom_ = zx80_rom_;
|
|
|
|
tape_trap_address_ = 0x220;
|
|
|
|
tape_return_address_ = 0x248;
|
|
|
|
vsync_start_ = HalfCycles(26);
|
|
|
|
vsync_end_ = HalfCycles(66);
|
|
|
|
automatic_tape_motor_start_address_ = 0x0206;
|
|
|
|
automatic_tape_motor_end_address_ = 0x024d;
|
2017-06-22 01:18:09 +00:00
|
|
|
}
|
2017-10-22 01:50:53 +00:00
|
|
|
rom_mask_ = static_cast<uint16_t>(rom_.size() - 1);
|
2017-08-03 02:12:59 +00:00
|
|
|
|
|
|
|
switch(target.zx8081.memory_model) {
|
|
|
|
case StaticAnalyser::ZX8081MemoryModel::Unexpanded:
|
|
|
|
ram_.resize(1024);
|
|
|
|
ram_base_ = 16384;
|
|
|
|
ram_mask_ = 1023;
|
|
|
|
break;
|
|
|
|
case StaticAnalyser::ZX8081MemoryModel::SixteenKB:
|
|
|
|
ram_.resize(16384);
|
|
|
|
ram_base_ = 16384;
|
|
|
|
ram_mask_ = 16383;
|
|
|
|
break;
|
|
|
|
case StaticAnalyser::ZX8081MemoryModel::SixtyFourKB:
|
|
|
|
ram_.resize(65536);
|
|
|
|
ram_base_ = 8192;
|
|
|
|
ram_mask_ = 65535;
|
|
|
|
break;
|
2017-06-23 00:20:31 +00:00
|
|
|
}
|
2017-08-03 02:12:59 +00:00
|
|
|
Memory::Fuzz(ram_);
|
2017-07-08 23:31:20 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
if(target.loadingCommand.length()) {
|
2017-08-03 15:50:50 +00:00
|
|
|
set_typer_for_string(target.loadingCommand.c_str());
|
2017-06-04 22:32:23 +00:00
|
|
|
}
|
2017-08-17 14:48:29 +00:00
|
|
|
|
|
|
|
insert_media(target.media);
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
bool insert_media(const StaticAnalyser::Media &media) override final {
|
2017-08-17 14:48:29 +00:00
|
|
|
if(!media.tapes.empty()) {
|
|
|
|
tape_player_.set_tape(media.tapes.front());
|
|
|
|
}
|
|
|
|
|
|
|
|
return !media.tapes.empty();
|
2017-08-03 02:12:59 +00:00
|
|
|
}
|
2017-06-04 22:32:23 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void set_typer_for_string(const char *string) override final {
|
2017-08-03 15:50:50 +00:00
|
|
|
std::unique_ptr<CharacterMapper> mapper(new CharacterMapper(is_zx81_));
|
|
|
|
Utility::TypeRecipient::set_typer_for_string(string, std::move(mapper));
|
|
|
|
}
|
|
|
|
|
2017-11-08 02:19:51 +00:00
|
|
|
void set_rom(ROMType type, const std::vector<uint8_t> &data) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
switch(type) {
|
|
|
|
case ZX80: zx80_rom_ = data; break;
|
|
|
|
case ZX81: zx81_rom_ = data; break;
|
2017-06-11 23:29:02 +00:00
|
|
|
}
|
2017-08-03 02:12:59 +00:00
|
|
|
}
|
2017-06-04 22:32:23 +00:00
|
|
|
|
2017-11-07 03:14:15 +00:00
|
|
|
// Obtains the system ROMs.
|
2017-11-08 02:19:51 +00:00
|
|
|
bool set_rom_fetcher(const std::function<std::vector<std::unique_ptr<std::vector<uint8_t>>>(const std::string &machine, const std::vector<std::string> &names)> &roms_with_names) override {
|
|
|
|
auto roms = roms_with_names(
|
|
|
|
"ZX8081",
|
|
|
|
{
|
|
|
|
"zx80.rom", "zx81.rom",
|
|
|
|
});
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
for(std::size_t index = 0; index < roms.size(); ++index) {
|
2017-11-08 02:19:51 +00:00
|
|
|
auto &data = roms[index];
|
2017-11-07 03:14:15 +00:00
|
|
|
if(!data) return false;
|
|
|
|
set_rom(static_cast<ROMType>(index), *data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-12 20:59:11 +00:00
|
|
|
// MARK: - Keyboard
|
2017-06-04 22:32:23 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void set_key_state(uint16_t key, bool isPressed) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
if(isPressed)
|
2017-10-22 01:50:53 +00:00
|
|
|
key_states_[key >> 8] &= static_cast<uint8_t>(~key);
|
2017-08-03 02:12:59 +00:00
|
|
|
else
|
2017-10-22 01:50:53 +00:00
|
|
|
key_states_[key >> 8] |= static_cast<uint8_t>(key);
|
2017-08-03 02:12:59 +00:00
|
|
|
}
|
2017-07-10 02:00:34 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void clear_all_keys() override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
memset(key_states_, 0xff, 8);
|
|
|
|
}
|
2017-06-04 21:55:19 +00:00
|
|
|
|
2017-11-12 20:59:11 +00:00
|
|
|
// MARK: - Tape control
|
2017-06-06 21:53:23 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void set_use_fast_tape_hack(bool activate) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
use_fast_tape_hack_ = activate;
|
|
|
|
}
|
2017-06-04 22:08:35 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
void set_use_automatic_tape_motor_control(bool enabled) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
use_automatic_tape_motor_control_ = enabled;
|
|
|
|
if(!enabled) {
|
|
|
|
tape_player_.set_motor_control(false);
|
|
|
|
}
|
|
|
|
}
|
2017-08-22 01:56:42 +00:00
|
|
|
void set_tape_is_playing(bool is_playing) override final {
|
2017-08-03 02:12:59 +00:00
|
|
|
tape_player_.set_motor_control(is_playing);
|
|
|
|
}
|
2017-06-04 21:55:19 +00:00
|
|
|
|
2017-11-12 20:59:11 +00:00
|
|
|
// MARK: - Typer timing
|
2017-06-04 21:55:19 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
HalfCycles get_typer_delay() override final { return Cycles(7000000); }
|
|
|
|
HalfCycles get_typer_frequency() override final { return Cycles(390000); }
|
2017-06-04 21:55:19 +00:00
|
|
|
|
2017-10-13 02:25:02 +00:00
|
|
|
KeyboardMapper &get_keyboard_mapper() override {
|
|
|
|
return keyboard_mapper_;
|
|
|
|
}
|
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
private:
|
2017-08-27 20:45:36 +00:00
|
|
|
CPU::Z80::Processor<ConcreteMachine, false, is_zx81> z80_;
|
2017-06-04 22:08:35 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
std::shared_ptr<Video> video_;
|
|
|
|
std::vector<uint8_t> zx81_rom_, zx80_rom_;
|
2017-06-04 22:32:23 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
uint16_t tape_trap_address_, tape_return_address_;
|
|
|
|
uint16_t automatic_tape_motor_start_address_, automatic_tape_motor_end_address_;
|
2017-06-04 22:32:23 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
std::vector<uint8_t> ram_;
|
|
|
|
uint16_t ram_mask_, ram_base_;
|
2017-06-05 01:54:55 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
std::vector<uint8_t> rom_;
|
|
|
|
uint16_t rom_mask_;
|
2017-06-05 14:47:42 +00:00
|
|
|
|
2017-11-11 03:31:27 +00:00
|
|
|
bool vsync_ = false, hsync_ = false;
|
|
|
|
int line_counter_ = 0;
|
2017-06-06 13:25:18 +00:00
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
uint8_t key_states_[8];
|
2017-10-13 02:25:02 +00:00
|
|
|
ZX8081::KeyboardMapper keyboard_mapper_;
|
2017-08-03 02:12:59 +00:00
|
|
|
|
|
|
|
HalfClockReceiver<Storage::Tape::BinaryTapePlayer> tape_player_;
|
|
|
|
Storage::Tape::ZX8081::Parser parser_;
|
|
|
|
|
|
|
|
bool is_zx81_;
|
2017-11-11 03:31:27 +00:00
|
|
|
bool nmi_is_enabled_ = false;
|
2017-08-03 02:12:59 +00:00
|
|
|
|
|
|
|
HalfCycles vsync_start_, vsync_end_;
|
|
|
|
HalfCycles horizontal_counter_;
|
|
|
|
|
2017-11-11 03:31:27 +00:00
|
|
|
uint8_t latched_video_byte_ = 0;
|
|
|
|
bool has_latched_video_byte_ = false;
|
2017-08-03 02:12:59 +00:00
|
|
|
|
2017-11-11 03:31:27 +00:00
|
|
|
bool use_fast_tape_hack_ = false;
|
2017-08-03 02:12:59 +00:00
|
|
|
bool use_automatic_tape_motor_control_;
|
2017-11-11 03:31:27 +00:00
|
|
|
HalfCycles tape_advance_delay_ = 0;
|
2017-08-03 02:12:59 +00:00
|
|
|
|
2017-11-12 20:59:11 +00:00
|
|
|
// MARK: - Video
|
2017-08-03 02:12:59 +00:00
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
inline void set_vsync(bool sync) {
|
2017-08-03 02:12:59 +00:00
|
|
|
vsync_ = sync;
|
|
|
|
update_sync();
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
inline void set_hsync(bool sync) {
|
2017-08-03 02:12:59 +00:00
|
|
|
hsync_ = sync;
|
|
|
|
update_sync();
|
|
|
|
}
|
|
|
|
|
2017-08-22 01:56:42 +00:00
|
|
|
inline void update_sync() {
|
2017-08-03 02:12:59 +00:00
|
|
|
video_->set_sync(vsync_ || hsync_);
|
|
|
|
}
|
|
|
|
};
|
2017-06-06 13:25:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-03 02:12:59 +00:00
|
|
|
using namespace ZX8081;
|
|
|
|
|
2017-08-27 20:42:16 +00:00
|
|
|
// See header; constructs and returns an instance of the ZX80 or 81.
|
|
|
|
Machine *Machine::ZX8081(const StaticAnalyser::Target &target_hint) {
|
2017-08-27 20:45:36 +00:00
|
|
|
// Instantiate the correct type of machine.
|
|
|
|
if(target_hint.zx8081.isZX81)
|
|
|
|
return new ZX8081::ConcreteMachine<true>();
|
|
|
|
else
|
|
|
|
return new ZX8081::ConcreteMachine<false>();
|
2017-06-06 13:25:18 +00:00
|
|
|
}
|
2017-08-11 16:11:01 +00:00
|
|
|
|
|
|
|
Machine::~Machine() {}
|