1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-07 23:29:06 +00:00
CLK/Machines/Enterprise/Nick.cpp

63 lines
1.5 KiB
C++
Raw Normal View History

2021-06-15 02:19:25 +00:00
//
// Nick.cpp
// Clock Signal
//
// Created by Thomas Harte on 14/06/2021.
// Copyright © 2021 Thomas Harte. All rights reserved.
//
#include "Nick.hpp"
#include <cstdio>
using namespace Enterprise;
Nick::Nick(const uint8_t *ram) :
crt_(16 * 57, 16, Outputs::Display::Type::PAL50, Outputs::Display::InputDataType::Red4Green4Blue4),
ram_(ram) {
2021-06-15 03:11:48 +00:00
// Just use RGB for now.
crt_.set_display_type(Outputs::Display::DisplayType::RGB);
}
2021-06-15 02:19:25 +00:00
void Nick::write(uint16_t address, uint8_t value) {
printf("Nick write: %02x -> %d\n", value, address & 3);
2021-06-15 02:19:25 +00:00
switch(address & 3) {
default:
printf("Unhandled\n");
break;
case 2:
line_parameter_base_ = uint16_t((line_parameter_base_ & 0xf000) | (value << 4));
break;
case 3:
line_parameter_base_ = uint16_t((line_parameter_base_ & 0x0ff0) | (value << 12));
// Still a mystery to me: the exact meaning of the top two bits here. For now
// just treat a 0 -> 1 transition of the MSB as a forced frame restart.
if((value^line_parameter_control_) & value & 0x80) {
// TODO: restart frame.
printf("Should restart frame from %04x\n", line_parameter_base_);
}
line_parameter_control_ = value & 0xc0;
2021-06-15 02:19:25 +00:00
break;
}
}
uint8_t Nick::read([[maybe_unused]] uint16_t address) {
return 0xff;
}
void Nick::run_for(HalfCycles) {
2021-06-15 03:11:48 +00:00
}
// MARK: - CRT passthroughs.
void Nick::set_scan_target(Outputs::Display::ScanTarget *scan_target) {
crt_.set_scan_target(scan_target);
}
2021-06-15 02:19:25 +00:00
2021-06-15 03:11:48 +00:00
Outputs::Display::ScanStatus Nick::get_scaled_scan_status() const {
return crt_.get_scaled_scan_status();
2021-06-15 02:19:25 +00:00
}