mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Switches to bit unpacking on the GPU.
This commit is contained in:
parent
506b4da6c3
commit
3821679efd
@ -13,12 +13,13 @@ using namespace ZX8081;
|
||||
Video::Video() :
|
||||
crt_(new Outputs::CRT::CRT(207 * 2, 1, Outputs::CRT::DisplayType::PAL50, 1)) {
|
||||
|
||||
// Set a composite sampling function that assumes 8bpp input grayscale.
|
||||
// TODO: lessen this to 1bpp.
|
||||
// Set a composite sampling function that assumes 1bpp input.
|
||||
crt_->set_composite_sampling_function(
|
||||
"float composite_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate, float phase, float amplitude)"
|
||||
"{"
|
||||
"return float(texture(texID, coordinate).r) / 255.0;"
|
||||
"uint texValue = texture(sampler, coordinate).r;"
|
||||
"texValue <<= int(icoordinate.x * 8) & 7;"
|
||||
"return float(texValue & 128u);"
|
||||
"}");
|
||||
|
||||
// Show only the centre 80% of the TV frame.
|
||||
@ -45,10 +46,10 @@ void Video::flush(bool next_sync) {
|
||||
if(line_data_) {
|
||||
// If there is output data queued, output it either if it's being interrupted by
|
||||
// sync, or if we're past its end anyway. Otherwise let it be.
|
||||
unsigned int data_length = static_cast<unsigned int>(line_data_pointer_ - line_data_);
|
||||
unsigned int data_length = static_cast<unsigned int>(line_data_pointer_ - line_data_) * 8;
|
||||
if(data_length < cycles_since_update_ || next_sync) {
|
||||
unsigned int output_length = std::min(data_length, cycles_since_update_);
|
||||
crt_->output_data(output_length, 1);
|
||||
crt_->output_data(output_length, 8);
|
||||
line_data_pointer_ = line_data_ = nullptr;
|
||||
cycles_since_update_ -= output_length;
|
||||
} else return;
|
||||
@ -79,25 +80,21 @@ void Video::output_byte(uint8_t byte) {
|
||||
|
||||
// Grab a buffer if one isn't already available.
|
||||
if(!line_data_) {
|
||||
line_data_pointer_ = line_data_ = crt_->allocate_write_area(320);
|
||||
line_data_pointer_ = line_data_ = crt_->allocate_write_area(40);
|
||||
}
|
||||
|
||||
// If a buffer was obtained, serialise the new pixels.
|
||||
if(line_data_) {
|
||||
// If the buffer is full, output it now and obtain a new one
|
||||
if(line_data_pointer_ - line_data_ == 320) {
|
||||
crt_->output_data(320, 1);
|
||||
if(line_data_pointer_ - line_data_ == 40) {
|
||||
crt_->output_data(40, 8);
|
||||
cycles_since_update_ -= 320;
|
||||
line_data_pointer_ = line_data_ = crt_->allocate_write_area(320);
|
||||
line_data_pointer_ = line_data_ = crt_->allocate_write_area(40);
|
||||
if(!line_data_) return;
|
||||
}
|
||||
|
||||
uint8_t mask = 0x80;
|
||||
for(int c = 0; c < 8; c++) {
|
||||
line_data_pointer_[c] = (byte & mask) ? 0xff : 0x00;
|
||||
mask >>= 1;
|
||||
}
|
||||
line_data_pointer_ += 8;
|
||||
line_data_pointer_[0] = byte;
|
||||
line_data_pointer_ ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user