2018-02-24 03:47:15 +00:00
|
|
|
//
|
|
|
|
// ColecoVision.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 23/02/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-02-24 03:47:15 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "ColecoVision.hpp"
|
|
|
|
|
2018-02-24 23:14:38 +00:00
|
|
|
#include "../../Processors/Z80/Z80.hpp"
|
|
|
|
|
|
|
|
#include "../../Components/9918/9918.hpp"
|
2018-03-03 18:08:33 +00:00
|
|
|
#include "../../Components/AY38910/AY38910.hpp" // For the Super Game Module.
|
2018-02-27 03:04:34 +00:00
|
|
|
#include "../../Components/SN76489/SN76489.hpp"
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2018-02-26 00:08:50 +00:00
|
|
|
#include "../CRTMachine.hpp"
|
|
|
|
#include "../JoystickMachine.hpp"
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2019-03-03 03:59:40 +00:00
|
|
|
#include "../../Configurable/StandardOptions.hpp"
|
2018-02-24 23:14:38 +00:00
|
|
|
#include "../../ClockReceiver/ForceInline.hpp"
|
2019-07-30 01:22:31 +00:00
|
|
|
#include "../../ClockReceiver/JustInTime.hpp"
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2018-03-03 18:08:33 +00:00
|
|
|
#include "../../Outputs/Speaker/Implementation/CompoundSource.hpp"
|
2018-02-27 03:04:34 +00:00
|
|
|
#include "../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
|
|
|
|
|
2018-03-07 00:06:35 +00:00
|
|
|
#include "../../Analyser/Dynamic/ConfidenceCounter.hpp"
|
|
|
|
|
2018-03-01 23:51:05 +00:00
|
|
|
namespace {
|
2019-12-22 05:22:17 +00:00
|
|
|
constexpr int sn76489_divider = 2;
|
2018-03-01 23:51:05 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 03:47:15 +00:00
|
|
|
namespace Coleco {
|
|
|
|
namespace Vision {
|
|
|
|
|
2019-03-03 03:59:40 +00:00
|
|
|
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
|
|
|
|
return Configurable::standard_options(
|
|
|
|
static_cast<Configurable::StandardOptions>(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-06-12 01:35:03 +00:00
|
|
|
class Joystick: public Inputs::ConcreteJoystick {
|
2018-02-26 00:08:50 +00:00
|
|
|
public:
|
2018-06-12 01:35:03 +00:00
|
|
|
Joystick() :
|
|
|
|
ConcreteJoystick({
|
2018-06-11 00:45:52 +00:00
|
|
|
Input(Input::Up),
|
|
|
|
Input(Input::Down),
|
|
|
|
Input(Input::Left),
|
|
|
|
Input(Input::Right),
|
|
|
|
|
|
|
|
Input(Input::Fire, 0),
|
|
|
|
Input(Input::Fire, 1),
|
|
|
|
|
|
|
|
Input('0'), Input('1'), Input('2'),
|
|
|
|
Input('3'), Input('4'), Input('5'),
|
|
|
|
Input('6'), Input('7'), Input('8'),
|
|
|
|
Input('9'), Input('*'), Input('#'),
|
2018-06-12 01:35:03 +00:00
|
|
|
}) {}
|
2018-02-26 00:08:50 +00:00
|
|
|
|
2018-06-12 01:35:03 +00:00
|
|
|
void did_set_input(const Input &digital_input, bool is_active) override {
|
2018-02-26 00:08:50 +00:00
|
|
|
switch(digital_input.type) {
|
|
|
|
default: return;
|
|
|
|
|
2018-06-11 00:45:52 +00:00
|
|
|
case Input::Key:
|
2018-02-26 00:08:50 +00:00
|
|
|
if(!is_active) keypad_ |= 0xf;
|
|
|
|
else {
|
|
|
|
uint8_t mask = 0xf;
|
|
|
|
switch(digital_input.info.key.symbol) {
|
2018-02-26 03:47:47 +00:00
|
|
|
case '8': mask = 0x1; break;
|
|
|
|
case '4': mask = 0x2; break;
|
|
|
|
case '5': mask = 0x3; break;
|
|
|
|
case '7': mask = 0x5; break;
|
2018-02-26 00:08:50 +00:00
|
|
|
case '#': mask = 0x6; break;
|
2018-02-26 03:47:47 +00:00
|
|
|
case '2': mask = 0x7; break;
|
|
|
|
case '*': mask = 0x9; break;
|
|
|
|
case '0': mask = 0xa; break;
|
|
|
|
case '9': mask = 0xb; break;
|
|
|
|
case '3': mask = 0xc; break;
|
|
|
|
case '1': mask = 0xd; break;
|
|
|
|
case '6': mask = 0xe; break;
|
2018-02-26 00:08:50 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2018-02-28 03:25:12 +00:00
|
|
|
keypad_ = (keypad_ & 0xf0) | mask;
|
2018-02-26 00:08:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-11-24 03:32:32 +00:00
|
|
|
case Input::Up: if(is_active) direction_ &= ~0x01; else direction_ |= 0x01; break;
|
2018-06-11 00:45:52 +00:00
|
|
|
case Input::Right: if(is_active) direction_ &= ~0x02; else direction_ |= 0x02; break;
|
|
|
|
case Input::Down: if(is_active) direction_ &= ~0x04; else direction_ |= 0x04; break;
|
|
|
|
case Input::Left: if(is_active) direction_ &= ~0x08; else direction_ |= 0x08; break;
|
|
|
|
case Input::Fire:
|
2018-02-26 00:08:50 +00:00
|
|
|
switch(digital_input.info.control.index) {
|
|
|
|
default: break;
|
2018-02-26 03:47:47 +00:00
|
|
|
case 0: if(is_active) direction_ &= ~0x40; else direction_ |= 0x40; break;
|
|
|
|
case 1: if(is_active) keypad_ &= ~0x40; else keypad_ |= 0x40; break;
|
2018-02-26 00:08:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t get_direction_input() {
|
|
|
|
return direction_;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t get_keypad_input() {
|
|
|
|
return keypad_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t direction_ = 0xff;
|
2018-10-19 01:05:58 +00:00
|
|
|
uint8_t keypad_ = 0x7f;
|
2018-02-26 00:08:50 +00:00
|
|
|
};
|
|
|
|
|
2018-02-24 03:47:15 +00:00
|
|
|
class ConcreteMachine:
|
2018-02-24 23:14:38 +00:00
|
|
|
public Machine,
|
|
|
|
public CPU::Z80::BusHandler,
|
2018-02-24 23:26:44 +00:00
|
|
|
public CRTMachine::Machine,
|
2019-03-03 03:59:40 +00:00
|
|
|
public Configurable::Device,
|
2018-02-26 00:08:50 +00:00
|
|
|
public JoystickMachine::Machine {
|
2018-02-24 23:14:38 +00:00
|
|
|
|
|
|
|
public:
|
2018-07-11 00:00:46 +00:00
|
|
|
ConcreteMachine(const Analyser::Static::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) :
|
2018-02-27 03:04:34 +00:00
|
|
|
z80_(*this),
|
2018-11-15 03:25:19 +00:00
|
|
|
vdp_(TI::TMS::TMS9918A),
|
2018-03-01 23:51:05 +00:00
|
|
|
sn76489_(TI::SN76489::Personality::SN76489, audio_queue_, sn76489_divider),
|
2019-12-19 00:28:41 +00:00
|
|
|
ay_(GI::AY38910::Personality::AY38910, audio_queue_),
|
2018-03-03 18:08:33 +00:00
|
|
|
mixer_(sn76489_, ay_),
|
|
|
|
speaker_(mixer_) {
|
2018-03-01 23:51:05 +00:00
|
|
|
speaker_.set_input_rate(3579545.0f / static_cast<float>(sn76489_divider));
|
2018-02-24 23:14:38 +00:00
|
|
|
set_clock_rate(3579545);
|
2018-02-26 00:08:50 +00:00
|
|
|
joysticks_.emplace_back(new Joystick);
|
|
|
|
joysticks_.emplace_back(new Joystick);
|
2018-07-11 00:00:46 +00:00
|
|
|
|
|
|
|
const auto roms = rom_fetcher(
|
2019-07-23 01:14:21 +00:00
|
|
|
{ {"ColecoVision", "the ColecoVision BIOS", "coleco.rom", 8*1024, 0x3aa93ef3} });
|
2018-07-11 00:00:46 +00:00
|
|
|
|
|
|
|
if(!roms[0]) {
|
|
|
|
throw ROMMachine::Error::MissingROMs;
|
|
|
|
}
|
|
|
|
|
|
|
|
bios_ = *roms[0];
|
|
|
|
bios_.resize(8192);
|
|
|
|
|
2018-07-11 01:40:13 +00:00
|
|
|
if(!target.media.cartridges.empty()) {
|
|
|
|
const auto &segment = target.media.cartridges.front()->get_segments().front();
|
|
|
|
cartridge_ = segment.data;
|
|
|
|
if(cartridge_.size() >= 32768)
|
|
|
|
cartridge_address_limit_ = 0xffff;
|
|
|
|
else
|
|
|
|
cartridge_address_limit_ = static_cast<uint16_t>(0x8000 + cartridge_.size() - 1);
|
|
|
|
|
|
|
|
if(cartridge_.size() > 32768) {
|
2018-10-19 01:09:05 +00:00
|
|
|
// Ensure the cartrige is a multiple of 16kb in size, as that won't
|
|
|
|
// be checked when paging.
|
2018-10-19 02:37:04 +00:00
|
|
|
const size_t extension = (16384 - (cartridge_.size() & 16383)) % 16384;
|
2018-10-19 01:09:05 +00:00
|
|
|
cartridge_.resize(cartridge_.size() + extension);
|
|
|
|
|
2018-07-11 01:40:13 +00:00
|
|
|
cartridge_pages_[0] = &cartridge_[cartridge_.size() - 16384];
|
|
|
|
cartridge_pages_[1] = cartridge_.data();
|
|
|
|
is_megacart_ = true;
|
|
|
|
} else {
|
2018-10-19 01:09:05 +00:00
|
|
|
// Ensure at least 32kb is allocated to the cartrige so that
|
|
|
|
// reads are never out of bounds.
|
2018-10-19 01:05:58 +00:00
|
|
|
cartridge_.resize(32768);
|
2018-10-19 01:09:05 +00:00
|
|
|
|
2018-07-11 01:40:13 +00:00
|
|
|
cartridge_pages_[0] = cartridge_.data();
|
|
|
|
cartridge_pages_[1] = cartridge_.data() + 16384;
|
|
|
|
is_megacart_ = false;
|
|
|
|
}
|
|
|
|
}
|
2019-02-25 03:37:24 +00:00
|
|
|
|
|
|
|
// ColecoVisions have composite output only.
|
2019-07-30 01:22:31 +00:00
|
|
|
vdp_->set_display_type(Outputs::Display::DisplayType::CompositeColour);
|
2018-02-26 00:08:50 +00:00
|
|
|
}
|
|
|
|
|
2018-03-23 01:59:19 +00:00
|
|
|
~ConcreteMachine() {
|
|
|
|
audio_queue_.flush();
|
|
|
|
}
|
|
|
|
|
2019-11-09 23:19:05 +00:00
|
|
|
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
2018-02-26 00:08:50 +00:00
|
|
|
return joysticks_;
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2018-11-15 02:52:57 +00:00
|
|
|
void set_scan_target(Outputs::Display::ScanTarget *scan_target) override {
|
2019-07-30 01:22:31 +00:00
|
|
|
vdp_->set_scan_target(scan_target);
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 04:44:21 +00:00
|
|
|
void set_display_type(Outputs::Display::DisplayType display_type) override {
|
2019-07-30 01:22:31 +00:00
|
|
|
vdp_->set_display_type(display_type);
|
2018-11-30 04:44:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 23:14:38 +00:00
|
|
|
Outputs::Speaker::Speaker *get_speaker() override {
|
2018-02-28 03:25:12 +00:00
|
|
|
return &speaker_;
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void run_for(const Cycles cycles) override {
|
|
|
|
z80_.run_for(cycles);
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Z80::BusHandler
|
|
|
|
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
|
2019-02-28 03:58:43 +00:00
|
|
|
// The SN76489 will use its ready line to trigger the Z80's wait, which will add
|
|
|
|
// thirty-one (!) cycles when accessed. M1 cycles are extended by a single cycle.
|
|
|
|
// This code works out the delay up front in order to simplify execution flow, though
|
|
|
|
// technically this is a little duplicative.
|
2019-02-28 03:01:30 +00:00
|
|
|
HalfCycles penalty(0);
|
2019-02-28 23:46:28 +00:00
|
|
|
if(cycle.operation == CPU::Z80::PartialMachineCycle::Output && ((*cycle.address >> 5) & 7) == 7) {
|
2019-02-28 03:58:43 +00:00
|
|
|
penalty = HalfCycles(62);
|
2019-02-28 03:01:30 +00:00
|
|
|
} else if(cycle.operation == CPU::Z80::PartialMachineCycle::ReadOpcode) {
|
|
|
|
penalty = HalfCycles(2);
|
|
|
|
}
|
2018-05-16 23:06:03 +00:00
|
|
|
const HalfCycles length = cycle.length + penalty;
|
|
|
|
|
2019-07-30 01:22:31 +00:00
|
|
|
vdp_ += length;
|
2018-05-16 23:06:03 +00:00
|
|
|
time_since_sn76489_update_ += length;
|
2018-03-07 22:00:18 +00:00
|
|
|
|
2018-09-22 02:53:35 +00:00
|
|
|
// Act only if necessary.
|
|
|
|
if(cycle.is_terminal()) {
|
|
|
|
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
|
|
|
switch(cycle.operation) {
|
|
|
|
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
|
|
|
if(!address) pc_zero_accesses_++;
|
|
|
|
case CPU::Z80::PartialMachineCycle::Read:
|
|
|
|
if(address < 0x2000) {
|
|
|
|
if(super_game_module_.replace_bios) {
|
|
|
|
*cycle.value = super_game_module_.ram[address];
|
|
|
|
} else {
|
|
|
|
*cycle.value = bios_[address];
|
|
|
|
}
|
|
|
|
} else if(super_game_module_.replace_ram && address < 0x8000) {
|
2018-03-03 18:08:33 +00:00
|
|
|
*cycle.value = super_game_module_.ram[address];
|
2018-09-22 02:53:35 +00:00
|
|
|
} else if(address >= 0x6000 && address < 0x8000) {
|
|
|
|
*cycle.value = ram_[address & 1023];
|
|
|
|
} else if(address >= 0x8000 && address <= cartridge_address_limit_) {
|
|
|
|
if(is_megacart_ && address >= 0xffc0) {
|
|
|
|
page_megacart(address);
|
|
|
|
}
|
|
|
|
*cycle.value = cartridge_pages_[(address >> 14)&1][address&0x3fff];
|
2018-03-03 18:08:33 +00:00
|
|
|
} else {
|
2018-09-22 02:53:35 +00:00
|
|
|
*cycle.value = 0xff;
|
2018-03-03 18:08:33 +00:00
|
|
|
}
|
2018-09-22 02:53:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Write:
|
|
|
|
if(super_game_module_.replace_bios && address < 0x2000) {
|
|
|
|
super_game_module_.ram[address] = *cycle.value;
|
|
|
|
} else if(super_game_module_.replace_ram && address >= 0x2000 && address < 0x8000) {
|
|
|
|
super_game_module_.ram[address] = *cycle.value;
|
|
|
|
} else if(address >= 0x6000 && address < 0x8000) {
|
|
|
|
ram_[address & 1023] = *cycle.value;
|
|
|
|
} else if(is_megacart_ && address >= 0xffc0) {
|
2018-03-02 23:40:01 +00:00
|
|
|
page_megacart(address);
|
|
|
|
}
|
2018-09-22 02:53:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Input:
|
|
|
|
switch((address >> 5) & 7) {
|
|
|
|
case 5:
|
2020-01-05 18:40:02 +00:00
|
|
|
*cycle.value = vdp_->read(address);
|
2019-07-30 01:22:31 +00:00
|
|
|
z80_.set_non_maskable_interrupt_line(vdp_->get_interrupt_line());
|
|
|
|
time_until_interrupt_ = vdp_->get_time_until_interrupt();
|
2018-09-22 02:53:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: {
|
|
|
|
const std::size_t joystick_id = (address&2) >> 1;
|
|
|
|
Joystick *joystick = static_cast<Joystick *>(joysticks_[joystick_id].get());
|
|
|
|
if(joysticks_in_keypad_mode_) {
|
|
|
|
*cycle.value = joystick->get_keypad_input();
|
|
|
|
} else {
|
|
|
|
*cycle.value = joystick->get_direction_input();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hitting exactly the recommended joypad input port is an indicator that
|
|
|
|
// this really is a ColecoVision game. The BIOS won't do this when just waiting
|
|
|
|
// to start a game (unlike accessing the VDP and SN).
|
|
|
|
if((address&0xfc) == 0xfc) confidence_counter_.add_hit();
|
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch(address&0xff) {
|
|
|
|
default: *cycle.value = 0xff; break;
|
|
|
|
case 0x52:
|
|
|
|
// Read AY data.
|
|
|
|
update_audio();
|
|
|
|
ay_.set_control_lines(GI::AY38910::ControlLines(GI::AY38910::BC2 | GI::AY38910::BC1));
|
|
|
|
*cycle.value = ay_.get_data_output();
|
|
|
|
ay_.set_control_lines(GI::AY38910::ControlLines(0));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPU::Z80::PartialMachineCycle::Output: {
|
|
|
|
const int eighth = (address >> 5) & 7;
|
|
|
|
switch(eighth) {
|
|
|
|
case 4: case 6:
|
|
|
|
joysticks_in_keypad_mode_ = eighth == 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2020-01-05 18:40:02 +00:00
|
|
|
vdp_->write(address, *cycle.value);
|
2019-07-30 01:22:31 +00:00
|
|
|
z80_.set_non_maskable_interrupt_line(vdp_->get_interrupt_line());
|
|
|
|
time_until_interrupt_ = vdp_->get_time_until_interrupt();
|
2018-09-22 02:53:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
update_audio();
|
2020-01-05 18:40:02 +00:00
|
|
|
sn76489_.write(*cycle.value);
|
2018-09-22 02:53:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Catch Super Game Module accesses; it decodes more thoroughly.
|
|
|
|
switch(address&0xff) {
|
|
|
|
default: break;
|
|
|
|
case 0x7f:
|
|
|
|
super_game_module_.replace_bios = !((*cycle.value)&0x2);
|
|
|
|
break;
|
|
|
|
case 0x50:
|
|
|
|
// Set AY address.
|
|
|
|
update_audio();
|
|
|
|
ay_.set_control_lines(GI::AY38910::BC1);
|
|
|
|
ay_.set_data_input(*cycle.value);
|
|
|
|
ay_.set_control_lines(GI::AY38910::ControlLines(0));
|
|
|
|
break;
|
|
|
|
case 0x51:
|
|
|
|
// Set AY data.
|
|
|
|
update_audio();
|
|
|
|
ay_.set_control_lines(GI::AY38910::ControlLines(GI::AY38910::BC2 | GI::AY38910::BDIR));
|
|
|
|
ay_.set_data_input(*cycle.value);
|
|
|
|
ay_.set_control_lines(GI::AY38910::ControlLines(0));
|
|
|
|
break;
|
|
|
|
case 0x53:
|
|
|
|
super_game_module_.replace_ram = !!((*cycle.value)&0x1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} break;
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2018-09-22 02:53:35 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2018-03-01 03:36:03 +00:00
|
|
|
if(time_until_interrupt_ > 0) {
|
2018-05-16 23:06:03 +00:00
|
|
|
time_until_interrupt_ -= length;
|
2018-03-01 03:36:03 +00:00
|
|
|
if(time_until_interrupt_ <= HalfCycles(0)) {
|
|
|
|
z80_.set_non_maskable_interrupt_line(true, time_until_interrupt_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-16 23:06:03 +00:00
|
|
|
return penalty;
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush() {
|
2019-07-30 01:22:31 +00:00
|
|
|
vdp_.flush();
|
2018-02-27 03:04:34 +00:00
|
|
|
update_audio();
|
|
|
|
audio_queue_.perform();
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 00:06:35 +00:00
|
|
|
float get_confidence() override {
|
|
|
|
if(pc_zero_accesses_ > 1) return 0.0f;
|
|
|
|
return confidence_counter_.get_confidence();
|
|
|
|
}
|
|
|
|
|
2019-03-03 03:59:40 +00:00
|
|
|
// MARK: - Configuration options.
|
|
|
|
std::vector<std::unique_ptr<Configurable::Option>> get_options() override {
|
|
|
|
return Coleco::Vision::get_options();
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_selections(const Configurable::SelectionSet &selections_by_option) override {
|
|
|
|
Configurable::Display display;
|
|
|
|
if(Configurable::get_display(selections_by_option, display)) {
|
|
|
|
set_video_signal_configurable(display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Configurable::SelectionSet get_accurate_selections() override {
|
|
|
|
Configurable::SelectionSet selection_set;
|
|
|
|
Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour);
|
|
|
|
return selection_set;
|
|
|
|
}
|
|
|
|
|
|
|
|
Configurable::SelectionSet get_user_friendly_selections() override {
|
|
|
|
Configurable::SelectionSet selection_set;
|
|
|
|
Configurable::append_display_selection(selection_set, Configurable::Display::SVideo);
|
|
|
|
return selection_set;
|
|
|
|
}
|
|
|
|
|
2018-02-24 23:14:38 +00:00
|
|
|
private:
|
2018-03-02 23:40:01 +00:00
|
|
|
inline void page_megacart(uint16_t address) {
|
|
|
|
const std::size_t selected_start = (static_cast<std::size_t>(address&63) << 14) % cartridge_.size();
|
|
|
|
cartridge_pages_[1] = &cartridge_[selected_start];
|
|
|
|
}
|
|
|
|
inline void update_audio() {
|
2018-03-01 23:51:05 +00:00
|
|
|
speaker_.run_for(audio_queue_, time_since_sn76489_update_.divide_cycles(Cycles(sn76489_divider)));
|
2018-02-27 03:04:34 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 23:14:38 +00:00
|
|
|
CPU::Z80::Processor<ConcreteMachine, false, false> z80_;
|
2019-10-29 01:35:10 +00:00
|
|
|
JustInTimeActor<TI::TMS::TMS9918, 1, 1, HalfCycles> vdp_;
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2018-02-27 03:04:34 +00:00
|
|
|
Concurrency::DeferringAsyncTaskQueue audio_queue_;
|
|
|
|
TI::SN76489 sn76489_;
|
2018-03-03 18:08:33 +00:00
|
|
|
GI::AY38910::AY38910 ay_;
|
|
|
|
Outputs::Speaker::CompoundSource<TI::SN76489, GI::AY38910::AY38910> mixer_;
|
|
|
|
Outputs::Speaker::LowpassSpeaker<Outputs::Speaker::CompoundSource<TI::SN76489, GI::AY38910::AY38910>> speaker_;
|
2018-02-27 03:04:34 +00:00
|
|
|
|
2018-02-24 23:14:38 +00:00
|
|
|
std::vector<uint8_t> bios_;
|
2018-02-24 23:26:44 +00:00
|
|
|
std::vector<uint8_t> cartridge_;
|
2018-03-02 23:40:01 +00:00
|
|
|
uint8_t *cartridge_pages_[2];
|
2018-02-24 23:14:38 +00:00
|
|
|
uint8_t ram_[1024];
|
2018-03-02 23:40:01 +00:00
|
|
|
bool is_megacart_ = false;
|
|
|
|
uint16_t cartridge_address_limit_ = 0;
|
2018-03-03 18:08:33 +00:00
|
|
|
struct {
|
|
|
|
bool replace_bios = false;
|
|
|
|
bool replace_ram = false;
|
|
|
|
uint8_t ram[32768];
|
|
|
|
} super_game_module_;
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2018-02-26 00:08:50 +00:00
|
|
|
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
|
|
|
|
bool joysticks_in_keypad_mode_ = false;
|
|
|
|
|
2018-02-27 03:04:34 +00:00
|
|
|
HalfCycles time_since_sn76489_update_;
|
2018-02-24 23:14:38 +00:00
|
|
|
HalfCycles time_until_interrupt_;
|
2018-03-07 00:06:35 +00:00
|
|
|
|
|
|
|
Analyser::Dynamic::ConfidenceCounter confidence_counter_;
|
|
|
|
int pc_zero_accesses_ = 0;
|
2018-02-24 03:47:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace Coleco::Vision;
|
|
|
|
|
2018-07-11 00:00:46 +00:00
|
|
|
Machine *Machine::ColecoVision(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) {
|
|
|
|
return new ConcreteMachine(*target, rom_fetcher);
|
2018-02-24 03:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Machine::~Machine() {}
|