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

The Electron's video is now a ClockReceiver.

This commit is contained in:
Thomas Harte 2017-07-24 22:36:42 -04:00
parent df4732be2e
commit a6e377aa57
3 changed files with 9 additions and 7 deletions

View File

@ -353,7 +353,7 @@ void Machine::flush() {
inline void Machine::update_display() { inline void Machine::update_display() {
if(cycles_since_display_update_) { if(cycles_since_display_update_) {
video_output_->run_for_cycles((int)cycles_since_display_update_); video_output_->run_for(Cycles((int)cycles_since_display_update_));
cycles_since_display_update_ = 0; cycles_since_display_update_ = 0;
} }
} }

View File

@ -223,7 +223,8 @@ void VideoOutput::output_pixels(unsigned int number_of_cycles) {
} }
} }
void VideoOutput::run_for_cycles(int number_of_cycles) { void VideoOutput::run_for(const Cycles &cycles) {
int number_of_cycles = cycles.as_int();
output_position_ = (output_position_ + number_of_cycles) % cycles_per_frame; output_position_ = (output_position_ + number_of_cycles) % cycles_per_frame;
while(number_of_cycles) { while(number_of_cycles) {
int draw_action_length = screen_map_[screen_map_pointer_].length; int draw_action_length = screen_map_[screen_map_pointer_].length;

View File

@ -10,6 +10,7 @@
#define Machines_Electron_Video_hpp #define Machines_Electron_Video_hpp
#include "../../Outputs/CRT/CRT.hpp" #include "../../Outputs/CRT/CRT.hpp"
#include "../../Components/ClockReceiver.hpp"
#include "Interrupts.hpp" #include "Interrupts.hpp"
namespace Electron { namespace Electron {
@ -21,7 +22,7 @@ namespace Electron {
running either at 40 or 80 columns. Memory is shared between video and CPU; when the video running either at 40 or 80 columns. Memory is shared between video and CPU; when the video
is accessing it the CPU may not. is accessing it the CPU may not.
*/ */
class VideoOutput { class VideoOutput: public ClockReceiver<VideoOutput> {
public: public:
/*! /*!
Instantiates a VideoOutput that will read its pixels from @c memory. The pointer supplied Instantiates a VideoOutput that will read its pixels from @c memory. The pointer supplied
@ -32,8 +33,8 @@ class VideoOutput {
/// @returns the CRT to which output is being painted. /// @returns the CRT to which output is being painted.
std::shared_ptr<Outputs::CRT::CRT> get_crt(); std::shared_ptr<Outputs::CRT::CRT> get_crt();
/// Produces the next @c number_of_cycles cycles of video output. /// Produces the next @c cycles of video output.
void run_for_cycles(int number_of_cycles); void run_for(const Cycles &cycles);
/*! /*!
Writes @c value to the register at @c address. May mutate the results of @c get_next_interrupt, Writes @c value to the register at @c address. May mutate the results of @c get_next_interrupt,
@ -53,14 +54,14 @@ class VideoOutput {
/*! /*!
@returns the next interrupt that should be generated as a result of the video hardware. @returns the next interrupt that should be generated as a result of the video hardware.
The time until signalling returned is the number of cycles after the final one triggered The time until signalling returned is the number of cycles after the final one triggered
by the most recent call to @c run_for_cycles. by the most recent call to @c run_for.
This result may be mutated by calls to @c set_register. This result may be mutated by calls to @c set_register.
*/ */
Interrupt get_next_interrupt(); Interrupt get_next_interrupt();
/*! /*!
@returns the number of cycles after (final cycle of last run_for_cycles batch + @c from_time) @returns the number of cycles after (final cycle of last run_for batch + @c from_time)
before the video circuits will allow the CPU to access RAM. before the video circuits will allow the CPU to access RAM.
*/ */
unsigned int get_cycles_until_next_ram_availability(int from_time); unsigned int get_cycles_until_next_ram_availability(int from_time);