1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Documents and extends the Video interface.

With the intention of returning it soon to JIT execution.
This commit is contained in:
Thomas Harte 2019-07-08 22:28:05 -04:00
parent 33e2721eb2
commit 52e96e3d2a
2 changed files with 61 additions and 6 deletions

View File

@ -167,9 +167,26 @@ bool Video::vsync() {
return line >= 353 && line < 356; return line >= 353 && line < 356;
} }
bool Video::is_outputting() { HalfCycles Video::get_next_sequence_point() {
const int column = (frame_position_ % line_length).as_int() >> 4;
const int line = (frame_position_ / line_length).as_int(); const int line = (frame_position_ / line_length).as_int();
if(line >= 353 && line < 356) {
// Currently in vsync, so get time until start of line 357,
// when vsync will end.
return HalfCycles(357) * line_length - frame_position_;
} else {
// Not currently in vsync, so get time until start of line 353.
const auto start_of_vsync = HalfCycles(353) * line_length;
if(frame_position_ < start_of_vsync)
return start_of_vsync - frame_position_;
else
return start_of_vsync + HalfCycles(number_of_lines) * line_length - frame_position_;
}
}
bool Video::is_outputting(HalfCycles offset) {
const auto offset_position = frame_position_ + offset % frame_length;
const int column = (offset_position % line_length).as_int() >> 4;
const int line = (offset_position / line_length).as_int();
return line < 342 && column < 32; return line < 342 && column < 32;
} }

View File

@ -17,20 +17,58 @@
namespace Apple { namespace Apple {
namespace Macintosh { namespace Macintosh {
/*!
Models the 68000-era Macintosh video hardware, producing a 512x348 pixel image,
within a total scanning area of 370 lines, at 352 cycles per line.
This class also collects audio and 400kb drive-speed data, forwarding those values.
*/
class Video { class Video {
public: public:
/*!
Constructs an instance of @c Video sourcing its pixel data from @c ram and
providing audio and drive-speed bytes to @c audio and @c drive_speed_accumulator.
*/
Video(uint16_t *ram, DeferredAudio &audio, DriveSpeedAccumulator &drive_speed_accumulator); Video(uint16_t *ram, DeferredAudio &audio, DriveSpeedAccumulator &drive_speed_accumulator);
/*!
Sets the target device for video data.
*/
void set_scan_target(Outputs::Display::ScanTarget *scan_target); void set_scan_target(Outputs::Display::ScanTarget *scan_target);
/*!
Produces the next @c duration period of pixels.
*/
void run_for(HalfCycles duration); void run_for(HalfCycles duration);
/*!
Sets whether the alternate screen and/or audio buffers should be used to source data.
*/
void set_use_alternate_buffers(bool use_alternate_screen_buffer, bool use_alternate_audio_buffer); void set_use_alternate_buffers(bool use_alternate_screen_buffer, bool use_alternate_audio_buffer);
// TODO: feedback on blanks and syncs. /*!
bool vsync(); Provides a mask indicating which parts of the generated video and audio/drive addresses are
bool is_outputting(); actually decoded, accessing *word-sized memory*; e.g. for a 128kb Macintosh this should be (1 << 16) - 1 = 0xffff.
*/
void set_ram_mask(uint32_t); void set_ram_mask(uint32_t);
/*!
@returns @c true if the video is currently outputting a vertical sync, @c false otherwise.
*/
bool vsync();
/*
@returns @c true if in @c offset half cycles from now, the video will be outputting pixels;
@c false otherwise.
*/
bool is_outputting(HalfCycles offset = HalfCycles(0));
/*!
@returns the amount of time until there is next a transition on the
vsync signal.
*/
HalfCycles get_next_sequence_point();
private: private:
DeferredAudio &audio_; DeferredAudio &audio_;
DriveSpeedAccumulator &drive_speed_accumulator_; DriveSpeedAccumulator &drive_speed_accumulator_;