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
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
#include "../MachineTypes.hpp"
|
2020-03-16 03:48:53 +00:00
|
|
|
#include "../../Configurable/Configurable.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 {
|
|
|
|
|
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
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
void did_set_input(const Input &digital_input, bool is_active) final {
|
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,
|
2019-03-03 03:59:40 +00:00
|
|
|
public Configurable::Device,
|
2020-04-02 03:19:34 +00:00
|
|
|
public MachineTypes::TimedMachine,
|
|
|
|
public MachineTypes::ScanProducer,
|
|
|
|
public MachineTypes::AudioProducer,
|
|
|
|
public MachineTypes::JoystickMachine {
|
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-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_) {
|
2020-05-10 03:00:39 +00:00
|
|
|
speaker_.set_input_rate(3579545.0f / 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
|
|
|
|
2021-06-04 01:55:59 +00:00
|
|
|
constexpr ROM::Name rom_name = ROM::Name::ColecoVisionBIOS;
|
|
|
|
const 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)) {
|
2018-07-11 00:00:46 +00:00
|
|
|
throw ROMMachine::Error::MissingROMs;
|
|
|
|
}
|
2021-06-04 01:55:59 +00:00
|
|
|
bios_ = roms.find(rom_name)->second;
|
2018-07-11 00:00:46 +00:00
|
|
|
|
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
|
2020-05-10 03:00:39 +00:00
|
|
|
cartridge_address_limit_ = uint16_t(0x8000 + cartridge_.size() - 1);
|
2018-07-11 01:40:13 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final {
|
2018-02-26 00:08:50 +00:00
|
|
|
return joysticks_;
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
void set_scan_target(Outputs::Display::ScanTarget *scan_target) final {
|
2023-03-13 03:20:48 +00:00
|
|
|
vdp_.last_valid()->set_scan_target(scan_target);
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 03:28:25 +00:00
|
|
|
Outputs::Display::ScanStatus get_scaled_scan_status() const final {
|
2023-03-13 03:20:48 +00:00
|
|
|
return vdp_.last_valid()->get_scaled_scan_status();
|
2020-01-21 02:45:10 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
void set_display_type(Outputs::Display::DisplayType display_type) final {
|
2023-03-13 03:20:48 +00:00
|
|
|
vdp_.last_valid()->set_display_type(display_type);
|
2018-11-30 04:44:21 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 03:34:26 +00:00
|
|
|
Outputs::Display::DisplayType get_display_type() const final {
|
2023-03-13 03:20:48 +00:00
|
|
|
return vdp_.last_valid()->get_display_type();
|
2020-03-18 04:06:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
Outputs::Speaker::Speaker *get_speaker() final {
|
2018-02-28 03:25:12 +00:00
|
|
|
return &speaker_;
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
void run_for(const Cycles cycles) final {
|
2018-02-24 23:14:38 +00:00
|
|
|
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;
|
|
|
|
|
2021-04-06 01:02:37 +00:00
|
|
|
if(vdp_ += length) {
|
|
|
|
z80_.set_non_maskable_interrupt_line(vdp_->get_interrupt_line());
|
|
|
|
}
|
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_++;
|
2020-06-20 03:36:51 +00:00
|
|
|
[[fallthrough]];
|
2018-09-22 02:53:35 +00:00
|
|
|
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());
|
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();
|
2021-03-27 03:19:47 +00:00
|
|
|
*cycle.value = GI::AY38910::Utility::read(ay_);
|
2018-09-22 02:53:35 +00:00
|
|
|
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());
|
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();
|
2021-03-27 03:19:47 +00:00
|
|
|
GI::AY38910::Utility::select_register(ay_, *cycle.value);
|
2018-09-22 02:53:35 +00:00
|
|
|
break;
|
|
|
|
case 0x51:
|
|
|
|
// Set AY data.
|
|
|
|
update_audio();
|
2021-03-27 03:19:47 +00:00
|
|
|
GI::AY38910::Utility::write_data(ay_, *cycle.value);
|
2018-09-22 02:53:35 +00:00
|
|
|
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-05-16 23:06:03 +00:00
|
|
|
return penalty;
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2022-07-09 17:33:46 +00:00
|
|
|
void flush_output(int outputs) final {
|
|
|
|
if(outputs & Output::Video) {
|
2022-07-08 20:04:32 +00:00
|
|
|
vdp_.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();
|
|
|
|
}
|
2018-02-24 23:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
float get_confidence() final {
|
2018-03-07 00:06:35 +00:00
|
|
|
if(pc_zero_accesses_ > 1) return 0.0f;
|
|
|
|
return confidence_counter_.get_confidence();
|
|
|
|
}
|
|
|
|
|
2019-03-03 03:59:40 +00:00
|
|
|
// MARK: - Configuration options.
|
2020-03-17 03:25:05 +00:00
|
|
|
std::unique_ptr<Reflection::Struct> get_options() final {
|
2020-03-18 04:06:52 +00:00
|
|
|
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
|
|
|
options->output = get_video_signal_configurable();
|
|
|
|
return options;
|
2019-03-03 03:59:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-18 04:06:52 +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-03-03 03:59:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 23:14:38 +00:00
|
|
|
private:
|
2018-03-02 23:40:01 +00:00
|
|
|
inline void page_megacart(uint16_t address) {
|
2020-05-10 03:00:39 +00:00
|
|
|
const std::size_t selected_start = (size_t(address&63) << 14) % cartridge_.size();
|
2018-03-02 23:40:01 +00:00
|
|
|
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_;
|
2022-12-31 20:08:33 +00:00
|
|
|
JustInTimeActor<TI::TMS::TMS9918<TI::TMS::Personality::TMS9918A>> vdp_;
|
2018-02-24 23:14:38 +00:00
|
|
|
|
2022-07-16 18:41:04 +00:00
|
|
|
Concurrency::AsyncTaskQueue<false> audio_queue_;
|
2018-02-27 03:04:34 +00:00
|
|
|
TI::SN76489 sn76489_;
|
2020-02-16 23:31:45 +00:00
|
|
|
GI::AY38910::AY38910<false> ay_;
|
|
|
|
Outputs::Speaker::CompoundSource<TI::SN76489, GI::AY38910::AY38910<false>> mixer_;
|
2021-11-21 20:37:29 +00:00
|
|
|
Outputs::Speaker::PullLowpass<Outputs::Speaker::CompoundSource<TI::SN76489, GI::AY38910::AY38910<false>>> 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-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;
|
|
|
|
|
2024-01-13 03:03:19 +00:00
|
|
|
std::unique_ptr<Machine> Machine::ColecoVision(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) {
|
|
|
|
return std::make_unique<ConcreteMachine>(*target, rom_fetcher);
|
2018-02-24 03:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Machine::~Machine() {}
|