1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-03-11 04:42:20 +00:00

Re-establishes output from the machines with 9918s and derivatives.

This commit is contained in:
Thomas Harte
2018-11-14 22:25:19 -05:00
parent a47de9a884
commit 9dff13cbbf
6 changed files with 81 additions and 96 deletions

View File

@@ -94,6 +94,7 @@ class ConcreteMachine:
region_(target.region),
paging_scheme_(target.paging_scheme),
z80_(*this),
vdp_(tms_personality_for_model(target.model)),
sn76489_(
(target.model == Target::Model::SG1000) ? TI::SN76489::Personality::SN76489 : TI::SN76489::Personality::SMS,
audio_queue_,
@@ -162,29 +163,21 @@ class ConcreteMachine:
}
void set_scan_target(Outputs::Display::ScanTarget *scan_target) override {
TI::TMS::Personality personality = TI::TMS::TMS9918A;
switch(model_) {
case Target::Model::SG1000: personality = TI::TMS::TMS9918A; break;
case Target::Model::MasterSystem: personality = TI::TMS::SMSVDP; break;
case Target::Model::MasterSystem2: personality = TI::TMS::SMS2VDP; break;
}
vdp_.reset(new TI::TMS::TMS9918(personality));
vdp_->set_tv_standard(
// TI::TMS::Personality personality = TI::TMS::TMS9918A;
// switch(model_) {
// case Target::Model::SG1000: personality = TI::TMS::TMS9918A; break;
// case Target::Model::MasterSystem: personality = TI::TMS::SMSVDP; break;
// case Target::Model::MasterSystem2: personality = TI::TMS::SMS2VDP; break;
// }
// vdp_.reset(new TI::TMS::TMS9918(personality));
vdp_.set_tv_standard(
(region_ == Target::Region::Europe) ?
TI::TMS::TVStandard::PAL : TI::TMS::TVStandard::NTSC);
// get_crt()->set_video_signal(Outputs::Display::VideoSignal::Composite);
time_until_debounce_ = vdp_->get_time_until_line(-1);
time_until_debounce_ = vdp_.get_time_until_line(-1);
}
// void close_output() override {
// vdp_.reset();
// }
//
// Outputs::CRT::CRT *get_crt() override {
// return vdp_->get_crt();
// }
Outputs::Speaker::Speaker *get_speaker() override {
return &speaker_;
}
@@ -239,16 +232,16 @@ class ConcreteMachine:
break;
case 0x40:
update_video();
*cycle.value = vdp_->get_current_line();
*cycle.value = vdp_.get_current_line();
break;
case 0x41:
*cycle.value = vdp_->get_latched_horizontal_counter();
*cycle.value = vdp_.get_latched_horizontal_counter();
break;
case 0x80: case 0x81:
update_video();
*cycle.value = vdp_->get_register(address);
z80_.set_interrupt_line(vdp_->get_interrupt_line());
time_until_interrupt_ = vdp_->get_time_until_interrupt();
*cycle.value = vdp_.get_register(address);
z80_.set_interrupt_line(vdp_.get_interrupt_line());
time_until_interrupt_ = vdp_.get_time_until_interrupt();
break;
case 0xc0: {
Joystick *const joypad1 = static_cast<Joystick *>(joysticks_[0].get());
@@ -290,7 +283,7 @@ class ConcreteMachine:
// Latch if either TH has newly gone to 1.
if((new_ths^previous_ths)&new_ths) {
update_video();
vdp_->latch_horizontal_counter();
vdp_.latch_horizontal_counter();
}
} break;
case 0x40: case 0x41:
@@ -299,9 +292,9 @@ class ConcreteMachine:
break;
case 0x80: case 0x81:
update_video();
vdp_->set_register(address, *cycle.value);
z80_.set_interrupt_line(vdp_->get_interrupt_line());
time_until_interrupt_ = vdp_->get_time_until_interrupt();
vdp_.set_register(address, *cycle.value);
z80_.set_interrupt_line(vdp_.get_interrupt_line());
time_until_interrupt_ = vdp_.get_time_until_interrupt();
break;
case 0xc0:
LOG("TODO: [output] I/O port A/N; " << int(*cycle.value));
@@ -337,7 +330,7 @@ class ConcreteMachine:
if(time_until_debounce_ <= HalfCycles(0)) {
z80_.set_non_maskable_interrupt_line(pause_is_pressed_);
update_video();
time_until_debounce_ = vdp_->get_time_until_line(-1);
time_until_debounce_ = vdp_.get_time_until_line(-1);
}
return HalfCycles(0);
@@ -395,6 +388,14 @@ class ConcreteMachine:
}
private:
static TI::TMS::Personality tms_personality_for_model(Analyser::Static::Sega::Target::Model model) {
switch(model) {
case Target::Model::SG1000: return TI::TMS::TMS9918A;
case Target::Model::MasterSystem: return TI::TMS::SMSVDP;
case Target::Model::MasterSystem2: return TI::TMS::SMSVDP;
}
}
inline uint8_t get_th_values() {
// Quick not on TH inputs here: if either is setup as an output, then the
// currently output level is returned. Otherwise they're fixed at 1.
@@ -410,7 +411,7 @@ class ConcreteMachine:
speaker_.run_for(audio_queue_, time_since_sn76489_update_.divide_cycles(Cycles(sn76489_divider)));
}
inline void update_video() {
vdp_->run_for(time_since_vdp_update_.flush());
vdp_.run_for(time_since_vdp_update_.flush());
}
using Target = Analyser::Static::Sega::Target;
@@ -418,7 +419,7 @@ class ConcreteMachine:
Target::Region region_;
Target::PagingScheme paging_scheme_;
CPU::Z80::Processor<ConcreteMachine, false, false> z80_;
std::unique_ptr<TI::TMS::TMS9918> vdp_;
TI::TMS::TMS9918 vdp_;
Concurrency::DeferringAsyncTaskQueue audio_queue_;
TI::SN76489 sn76489_;