1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-27 02:55:07 +00:00

Take slightly wrong-headed steps towards proper command timing.

This commit is contained in:
Thomas Harte 2023-01-27 22:20:36 -05:00
parent 8a673a697b
commit 95e00dd958
2 changed files with 42 additions and 1 deletions

View File

@ -159,7 +159,7 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
#endif
if(fetch_cycles_pool) {
// Determine how much writing to do.
// Determine how much writing to do; at the absolute most go to the end of this line.
const int fetch_cycles = std::min(
Timing<personality>::CyclesPerLine - this->fetch_pointer_.column,
fetch_cycles_pool
@ -171,6 +171,15 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
this->minimum_access_column_ = this->fetch_pointer_.column + this->cycles_until_access_;
this->cycles_until_access_ -= fetch_cycles;
// ... and to any pending Yamaha commands.
if constexpr (is_yamaha_vdp(personality)) {
if(Storage<personality>::command_) {
Storage<personality>::minimum_command_column_ =
this->fetch_pointer_.column + Storage<personality>::command_->cycles;
Storage<personality>::command_->cycles -= fetch_cycles;
}
}
// ---------------------------------------
// Latch scrolling position, if necessary.

View File

@ -187,6 +187,27 @@ template <Personality personality> struct Storage<personality, std::enable_if_t<
CommandContext command_context_;
std::unique_ptr<Command> command_ = nullptr;
enum class CommandStep {
None,
ReadPixel,
WritePixel,
};
CommandStep next_command_step_ = CommandStep::None;
int minimum_command_column_ = 0;
void update_command_step() {
if(!command_) {
next_command_step_ = CommandStep::None;
return;
}
switch(command_->access) {
case Command::AccessType::PlotPoint:
next_command_step_ = CommandStep::ReadPixel;
break;
}
}
Storage() noexcept {
// Perform sanity checks on the event lists.
#ifndef NDEBUG
@ -552,6 +573,17 @@ template <Personality personality> struct Base: public Storage<personality> {
// Don't do anything if the required time for the access to become executable
// has yet to pass.
if(queued_access_ == MemoryAccess::None || access_column < minimum_access_column_) {
if constexpr (is_yamaha_vdp(personality)) {
// if(
// Storage<personality>::next_command_step_ == Storage<personality>::CommandStep::None ||
// access_column < Storage<personality>::minimum_access_column_
// ) {
// return;
// }
// TODO: command-engine action.
}
return;
}