From 580f3477278f7532a8f29a43f2b81929fc44a13d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 10 Dec 2016 13:55:56 -0500 Subject: [PATCH] Fixed Oric SCART mode by having it change what it's giving to the CRT based on which shader it knows will be active. --- Machines/Oric/Oric.cpp | 5 +++ Machines/Oric/Oric.hpp | 1 + Machines/Oric/Video.cpp | 42 +++++++++++-------- Machines/Oric/Video.hpp | 4 +- .../Clock Signal/Machine/Wrappers/CSOric.mm | 2 +- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 6a6a8310c..55d7c3806 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -218,6 +218,11 @@ void Machine::set_use_fast_tape_hack(bool activate) use_fast_tape_hack_ = activate; } +void Machine::set_output_device(Outputs::CRT::OutputDevice output_device) +{ + video_output_->set_output_device(output_device); +} + void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player) { // set CB1 diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index b7c72889c..aec4d0495 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -73,6 +73,7 @@ class Machine: void clear_all_keys(); void set_use_fast_tape_hack(bool activate); + void set_output_device(Outputs::CRT::OutputDevice output_device); // to satisfy ConfigurationTarget::Machine void configure_as_target(const StaticAnalyser::Target &target); diff --git a/Machines/Oric/Video.cpp b/Machines/Oric/Video.cpp index b8838e53b..71dec70e8 100644 --- a/Machines/Oric/Video.cpp +++ b/Machines/Oric/Video.cpp @@ -33,7 +33,6 @@ VideoOutput::VideoOutput(uint8_t *memory) : "vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)" "{" "uint texValue = texture(sampler, coordinate).r;" - "texValue >>= 4 - (int(icoordinate.x * 8) & 4);" "return vec3( uvec3(texValue) & uvec3(4u, 2u, 1u));" "}"); crt_->set_composite_sampling_function( @@ -46,10 +45,16 @@ VideoOutput::VideoOutput(uint8_t *memory) : "}" ); - crt_->set_output_device(Outputs::CRT::Television); + set_output_device(Outputs::CRT::Television); crt_->set_visible_area(crt_->get_rect_for_area(50, 224, 16 * 6, 40 * 6, 4.0f / 3.0f)); } +void VideoOutput::set_output_device(Outputs::CRT::OutputDevice output_device) +{ + output_device_ = output_device; + crt_->set_output_device(output_device); +} + void VideoOutput::set_colour_rom(const std::vector &rom) { for(size_t c = 0; c < 8; c++) @@ -135,19 +140,17 @@ void VideoOutput::run_for_cycles(int number_of_cycles) { if(pixel_target_) { -// uint8_t colours[2] = { -// (uint8_t)(paper_ ^ inverse_mask), -// (uint8_t)(ink_ ^ inverse_mask), -// }; -// -// pixel_target_[0] = (colours[(pixels >> 4)&1] & 0x0f) | (colours[(pixels >> 5)&1] & 0xf0); -// pixel_target_[1] = (colours[(pixels >> 2)&1] & 0x0f) | (colours[(pixels >> 3)&1] & 0xf0); -// pixel_target_[2] = (colours[(pixels >> 0)&1] & 0x0f) | (colours[(pixels >> 1)&1] & 0xf0); - - uint16_t colours[2] = { - colour_forms_[(paper_ ^ inverse_mask)&0xf], - colour_forms_[(ink_ ^ inverse_mask)&0xf], - }; + uint16_t colours[2]; + if(output_device_ == Outputs::CRT::Monitor) + { + colours[0] = (uint8_t)((paper_ ^ inverse_mask) & 0xf); + colours[1] = (uint8_t)((ink_ ^ inverse_mask) & 0xf); + } + else + { + colours[0] = colour_forms_[(paper_ ^ inverse_mask)&0xf]; + colours[1] = colour_forms_[(ink_ ^ inverse_mask)&0xf]; + } pixel_target_[0] = colours[(pixels >> 5)&1]; pixel_target_[1] = colours[(pixels >> 4)&1]; pixel_target_[2] = colours[(pixels >> 3)&1]; @@ -194,8 +197,13 @@ void VideoOutput::run_for_cycles(int number_of_cycles) default: break; } -// if(pixel_target_) pixel_target_[0] = pixel_target_[1] = pixel_target_[2] = (uint8_t)(paper_ ^ inverse_mask); - if(pixel_target_) pixel_target_[0] = pixel_target_[1] = pixel_target_[2] = pixel_target_[3] = pixel_target_[4] = pixel_target_[5] = colour_forms_[(paper_&0xf) ^ inverse_mask]; + if(pixel_target_) + { + pixel_target_[0] = pixel_target_[1] = + pixel_target_[2] = pixel_target_[3] = + pixel_target_[4] = pixel_target_[5] = + (output_device_ == Outputs::CRT::Monitor) ? (paper_ ^ inverse_mask)&0xf : colour_forms_[(paper_ ^ inverse_mask)&0xf]; + } } if(pixel_target_) pixel_target_ += 6; h_counter++; diff --git a/Machines/Oric/Video.hpp b/Machines/Oric/Video.hpp index fe7b91d53..992d73470 100644 --- a/Machines/Oric/Video.hpp +++ b/Machines/Oric/Video.hpp @@ -19,6 +19,7 @@ class VideoOutput { std::shared_ptr get_crt(); void run_for_cycles(int number_of_cycles); void set_colour_rom(const std::vector &rom); + void set_output_device(Outputs::CRT::OutputDevice output_device); private: uint8_t *ram_; @@ -28,9 +29,10 @@ class VideoOutput { int counter_, frame_counter_; int v_sync_start_position_, v_sync_end_position_, counter_period_; - // Output target + // Output target and device uint16_t *pixel_target_; uint16_t colour_forms_[8]; + Outputs::CRT::OutputDevice output_device_; // Registers uint8_t ink_, paper_; diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm index efc8c6e69..c2f38479d 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm @@ -152,7 +152,7 @@ - (void)setUseCompositeOutput:(BOOL)useCompositeOutput { @synchronized(self) { _useCompositeOutput = useCompositeOutput; - _oric.get_crt()->set_output_device(useCompositeOutput ? Outputs::CRT::Television : Outputs::CRT::Monitor); + _oric.set_output_device(useCompositeOutput ? Outputs::CRT::Television : Outputs::CRT::Monitor); } }