From f742fd5d4a959a41d229f10e2a016e961924529e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 31 Jul 2017 22:13:20 -0400 Subject: [PATCH] Made basic attempt to get something on screen: white where the display is enabled, black for the border. --- Machines/AmstradCPC/AmstradCPC.cpp | 2 +- Machines/AmstradCPC/AmstradCPC.hpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index a9c33348f..5beee29b2 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -124,7 +124,7 @@ void Machine::set_rom(ROMType type, std::vector data) { } void Machine::setup_output(float aspect_ratio) { - crtc_bus_handler_.crt_.reset(new Outputs::CRT::CRT(256, 1, Outputs::CRT::DisplayType::PAL50, 1)); + crtc_bus_handler_.crt_.reset(new Outputs::CRT::CRT(1024, 8, Outputs::CRT::DisplayType::PAL50, 1)); crtc_bus_handler_.crt_->set_rgb_sampling_function( "vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)" "{" diff --git a/Machines/AmstradCPC/AmstradCPC.hpp b/Machines/AmstradCPC/AmstradCPC.hpp index 9584cf285..ca650b367 100644 --- a/Machines/AmstradCPC/AmstradCPC.hpp +++ b/Machines/AmstradCPC/AmstradCPC.hpp @@ -26,10 +26,32 @@ enum ROMType: uint8_t { struct CRTCBusHandler { public: + CRTCBusHandler() : cycles_(0), was_enabled_(false), was_sync_(false) { + } + inline void perform_bus_cycle(const Motorola::CRTC::BusState &state) { + cycles_++; + bool is_sync = state.hsync || state.vsync; + if(state.display_enable != was_enabled_ || is_sync != was_sync_) { + if(was_sync_) { + crt_->output_sync((unsigned int)(cycles_ * 2)); + } else { + uint8_t *colour_pointer = (uint8_t *)crt_->allocate_write_area(1); + if(colour_pointer) *colour_pointer = was_enabled_ ? 0xff : 0x00; + crt_->output_level((unsigned int)(cycles_ * 2)); + } + + cycles_ = 0; + was_sync_ = is_sync; + was_enabled_ = state.display_enable; + } } std::shared_ptr crt_; + + private: + int cycles_; + bool was_enabled_, was_sync_; }; class Machine: