diff --git a/Machines/PCCompatible/CGA.hpp b/Machines/PCCompatible/CGA.hpp index 897924656..ce47ee18e 100644 --- a/Machines/PCCompatible/CGA.hpp +++ b/Machines/PCCompatible/CGA.hpp @@ -15,6 +15,7 @@ namespace PCCompatible { +// TODO: border colour isn't currently honoured. class CGA { public: CGA() : crtc_(Motorola::CRTC::Personality::HD6845S, outputter_) {} @@ -102,8 +103,7 @@ class CGA { crt(910, 8, Outputs::Display::Type::NTSC60, Outputs::Display::InputDataType::Red2Green2Blue2) { crt.set_visible_area(Outputs::Display::Rect(0.097f, 0.095f, 0.82f, 0.82f)); -// crt.set_display_type(Outputs::Display::DisplayType::CompositeColour); // TODO: needs to be a user option. - crt.set_display_type(Outputs::Display::DisplayType::RGB); // TODO: needs to be a user option. + crt.set_display_type(Outputs::Display::DisplayType::RGB); } void set_mode(uint8_t control) { diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index a0e57a8dd..55529d43b 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -15,6 +15,7 @@ #include "Memory.hpp" #include "PIC.hpp" #include "PIT.hpp" +#include "RTC.hpp" #include "../../InstructionSets/x86/Decoder.hpp" #include "../../InstructionSets/x86/Flags.hpp" @@ -549,6 +550,25 @@ class i8255PortHandler : public Intel::i8255::PortHandler { if(drive_count) low_switches_ |= 0xb0001; } + /// Supplies a hint about the user's display choice. If the high switches haven't been read yet and this is a CGA device, + /// this hint will be used to select between 40- and 80-column default display. + void hint_is_composite(bool composite) { + if(high_switches_observed_) { + return; + } + + switch(high_switches_ & 3) { + // Do nothing if a non-CGA card is in use. + case 0b00: case 0b11: + break; + + default: + high_switches_ &= ~0b11; + high_switches_ |= composite ? 0b01 : 0b10; + break; + } + } + void set_value(int port, uint8_t value) { switch(port) { case 1: @@ -571,6 +591,7 @@ class i8255PortHandler : public Intel::i8255::PortHandler { uint8_t get_value(int port) { switch(port) { case 0: + high_switches_observed_ = true; return enable_keyboard_ ? keyboard_.read() : uint8_t((high_switches_ << 4) | low_switches_); // Guesses that switches is high and low combined as below. @@ -580,6 +601,7 @@ class i8255PortHandler : public Intel::i8255::PortHandler { // b5: timer 2 output; [TODO] // b4: cassette data input; [TODO] // b3...b0: whichever of the high and low switches is selected. + high_switches_observed_ |= use_high_switches_; return use_high_switches_ ? high_switches_ : low_switches_; } @@ -587,6 +609,7 @@ class i8255PortHandler : public Intel::i8255::PortHandler { }; private: + bool high_switches_observed_ = false; uint8_t high_switches_ = 0; uint8_t low_switches_ = 0; @@ -601,8 +624,8 @@ using PPI = Intel::i8255::i8255; template class IO { public: - IO(PIT &pit, DMA &dma, PPI &ppi, PIC &pic, typename Adaptor