From fff597075dcba6febb59f4a6cd18e49be7dab675 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sun, 5 Dec 2021 20:07:22 +0100 Subject: [PATCH] Monitor type can be now specified from the command line. --- devices/ioctrl/amic.cpp | 2 +- devices/video/atirage.cpp | 2 +- devices/video/displayid.cpp | 47 +++++++++++++++++++++++++++++++++---- devices/video/displayid.h | 2 +- machines/machinefactory.cpp | 29 ++++++++++++++++++++--- 5 files changed, 71 insertions(+), 11 deletions(-) diff --git a/devices/ioctrl/amic.cpp b/devices/ioctrl/amic.cpp index 2660ebb..0e7c7dd 100644 --- a/devices/ioctrl/amic.cpp +++ b/devices/ioctrl/amic.cpp @@ -62,7 +62,7 @@ AMIC::AMIC() this->awacs->set_dma_out(this->snd_out_dma.get()); // initialize on-board video - this->disp_id = std::unique_ptr (new DisplayID(Disp_Id_Kind::AppleSense)); + this->disp_id = std::unique_ptr (new DisplayID()); } bool AMIC::supports_type(HWCompType type) { diff --git a/devices/video/atirage.cpp b/devices/video/atirage.cpp index 5d4f723..89d2891 100644 --- a/devices/video/atirage.cpp +++ b/devices/video/atirage.cpp @@ -121,7 +121,7 @@ ATIRage::ATIRage(uint16_t dev_id, uint32_t vmem_size_mb) (asic_id << 24) | dev_id); /* initialize display identification */ - this->disp_id = std::unique_ptr (new DisplayID(Disp_Id_Kind::DDC2B)); + this->disp_id = std::unique_ptr (new DisplayID()); } const char* ATIRage::get_reg_name(uint32_t reg_offset) { diff --git a/devices/video/displayid.cpp b/devices/video/displayid.cpp index 0f94504..ef11333 100644 --- a/devices/video/displayid.cpp +++ b/devices/video/displayid.cpp @@ -23,14 +23,51 @@ along with this program. If not, see . #include #include +#include -DisplayID::DisplayID(Disp_Id_Kind id_kind) +#include +#include +#include + +/** Mapping between monitor IDs and their sense codes. */ +static const std::map MonitorIdToCode = { + { "MacColor21in" , 0x00FF }, + { "PortraitGS" , 0x01FF }, + { "MacRGB12in" , 0x02FF }, + { "TwoPageGS" , 0x03FF }, + { "NTSC" , 0x04FF }, + { "MacRGB15in" , 0x05FF }, + { "HiRes12-14in" , 0x06FF }, + { "Multiscan15in" , 0x0603 }, + { "Multiscan17in" , 0x060B }, + { "Multiscan20in" , 0x0623 }, + { "AppleVision1710" , 0x062B }, // this code is assigned to several different monitors! + { "PALEncoder" , 0x0700 }, // no clue what it means + { "NTSCEncoder" , 0x0714 }, // no clue what it means + { "VGA-SVGA" , 0x0717 }, + { "MacRGB16in" , 0x072D }, + { "MacRGB19in" , 0x073A }, + { "PAL" , 0x0730 }, + { "NotConnected" , 0x07FF } +}; + +DisplayID::DisplayID() { - this->id_kind = id_kind; + // assume a DDC monitor is connected by default + this->id_kind = Disp_Id_Kind::DDC2B; - /* Initialize Apple monitor codes */ - this->std_sense_code = 6; - this->ext_sense_code = 0x2B; + std::string mon_id = GET_STR_PROP("mon_id"); + if (!mon_id.empty()) { + if (MonitorIdToCode.count(mon_id)) { + auto sense_code = MonitorIdToCode.at(mon_id); + this->std_sense_code = (sense_code >> 8) & 0xFFU; + this->ext_sense_code = (sense_code >> 0) & 0xFFU; + this->id_kind = Disp_Id_Kind::AppleSense; + LOG_F(INFO, "DisplayID mode set to AppleSense"); + LOG_F(INFO, "Standard sense code: 0x%d", this->std_sense_code); + LOG_F(INFO, "Extended sense code: 0x%X", this->ext_sense_code); + } + } /* Initialize DDC I2C bus */ this->next_state = I2CState::STOP; diff --git a/devices/video/displayid.h b/devices/video/displayid.h index c74f1bd..b756149 100644 --- a/devices/video/displayid.h +++ b/devices/video/displayid.h @@ -55,7 +55,7 @@ enum I2CState : uint8_t { class DisplayID { public: - DisplayID(Disp_Id_Kind id_kind); + DisplayID(); ~DisplayID() = default; uint8_t read_monitor_sense(uint8_t levels, uint8_t dirs); diff --git a/machines/machinefactory.cpp b/machines/machinefactory.cpp index 7940c4e..efd5736 100644 --- a/machines/machinefactory.cpp +++ b/machines/machinefactory.cpp @@ -76,15 +76,27 @@ static const PropMap GossamerSettings = { new IntProperty( 0, vector({0, 8, 16, 32, 64, 128, 256}))}, {"gfxmem_size", new IntProperty( 2, vector({2, 4, 6}))}, + {"mon_id", + new StrProperty("")}, {"fdd_img", new StrProperty("")}, }; +/** Monitors supported by the PDM on-board video. */ +/* see displayid.cpp for the full list of supported monitor IDs. */ +static const vector PDMBuiltinMonitorIDs = { + "PortraitGS", "MacRGB12in", "MacRGB15in", "HiRes12-14in", "VGA-SVGA", + "MacRGB16in", "Multiscan15in", "Multiscan17in", "Multiscan20in", + "NotConnected" +}; + static const PropMap PDMSettings = { {"rambank1_size", new IntProperty(0, vector({0, 8, 16, 32, 64, 128}))}, {"rambank2_size", new IntProperty(0, vector({0, 8, 16, 32, 64, 128}))}, + {"mon_id", + new StrProperty("HiRes12-14in", PDMBuiltinMonitorIDs)}, {"fdd_img", new StrProperty("")}, }; @@ -95,6 +107,7 @@ static const map PropHelp = { {"rambank3_size", "specifies RAM bank 3 size in MB"}, {"gfxmem_size", "specifies video memory size in MB"}, {"fdd_img", "specifies path to floppy disk image"}, + {"mon_id", "specifies which monitor to emulate"}, }; static const map, string>> machines = { @@ -210,10 +223,20 @@ void list_properties() { for (auto& p : get<0>(mach.second)) { cout << setw(13) << p.first << "\t\t" << PropHelp.at(p.first) << endl; - if (p.second->get_type() == PROP_TYPE_INTEGER) { - cout << setw(13) << "\t\t\t" "Valid values: " << - dynamic_cast(p.second)->get_valid_values_as_str() + + cout << setw(13) << "\t\t\t" "Valid values: "; + + switch(p.second->get_type()) { + case PROP_TYPE_INTEGER: + cout << dynamic_cast(p.second)->get_valid_values_as_str() << endl; + break; + case PROP_TYPE_STRING: + cout << dynamic_cast(p.second)->get_valid_values_as_str() + << endl; + break; + default: + break; } cout << endl; }