From e14b6677b2a15ada0891dcf97d2f26ada3b30af4 Mon Sep 17 00:00:00 2001 From: joevt Date: Tue, 23 Apr 2024 05:11:49 -0700 Subject: [PATCH] displayid: Fix non-extended sense codes. Sense codes for displays like the 12 inch RGB display (512x384) weren't working since they had the extended part set to 0xff. Related to issues #25. Also added some descriptive information and sizes which may be used for UI purposes such as creating a menu of displays to choose from. The sizes may be used to set the default window size for the display. --- devices/video/displayid.cpp | 224 ++++++++++++++++++++++++++++++++---- 1 file changed, 199 insertions(+), 25 deletions(-) diff --git a/devices/video/displayid.cpp b/devices/video/displayid.cpp index f9e9d54..6e8c570 100644 --- a/devices/video/displayid.cpp +++ b/devices/video/displayid.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-23 divingkatae and maximum +Copyright (C) 2018-24 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -29,26 +29,197 @@ along with this program. If not, see . #include #include +typedef struct { + uint16_t h; + uint16_t v; + float pixel_clock; // MHz + float h_freq; // kHz + float refresh; // Hz +} MonitorRes; + +typedef struct { + uint8_t std_sense_code; + uint8_t ext_sense_code; + const char * apple_enum; + const char * name; + const char * description; + MonitorRes resolutions[4]; +} MonitorInfo; + /** 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 } +static const std::map MonitorIdToCode = { + { "MacColor21in", { + 0, 0x00, + "kESCZero21Inch", + "21\" RGB", + "RGB 21\", 21\" Color, Apple 21S Color", { + {1152, 870, 100 , 68.7 , 75 } + } + }}, + { "PortraitGS", { + 1, 0x14, + "kESCOnePortraitMono", + "Portrait Monochrome", + "B&W 15\", Apple Portrait", { + { 640, 870, 57.2832, 68.9 , 75 } + } + }}, + { "MacRGB12in", { + 2, 0x21, + "kESCTwo12Inch", + "12\" RGB", + "12\" Apple RGB", { + { 512, 384, 15.6672, 24.48 , 60.15} + } + }}, + { "Radius21in", { + 3, 0x31, + "kESCThree21InchRadius", + "21\" RGB (Radius)", + "", { + {1152, 870, 100 , 68.7 , 75 } + } + }}, + { "Radius21inGS", { + 3, 0x34, + "kESCThree21InchMonoRadius", + "21\" Monochrome (Radius)", + "", { + {1152, 870, 100 , 68.7 , 75 } + } + }}, + { "TwoPageGS", { + 3, 0x35, + "kESCThree21InchMono", + "21\" Monochrome", + "B&W 21\", Apple 2 Page Mono", { + {1152, 870, 100 , 68.7 , 75 } + } + }}, + { "NTSC", { + 4, 0x0A, + "kESCFourNTSC", + "NTSC", + "NTSC underscan 512x384, overscan", { + { 640, 480, 12.2727, 15.7 , 59.94} + } + }}, + { "MacRGB15in", { + 5, 0x1E, + "kESCFivePortrait", + "Portrait RGB", + "RGB 15\", 15\" Tilt", { + { 640, 870, 57.2834, 0 , 0 } + } + }}, + { "Multiscan15in", { + 6, 0x03, + "kESCSixMSB1", + "MultiScan Band-1 (12\" thru 16\")", + "Multiple Scan 13, 14\"", { + { 640, 480, 67 , 0 , 0 }, + { 832, 624, 75 , 0 , 0 } + } + }}, + { "Multiscan17in", { + 6, 0x0B, + "kESCSixMSB2", + "MultiScan Band-2 (13\" thru 19\")", + "Multiple Scan 16, 17\"", { + { 640, 480, 67 , 0 , 0 }, + { 832, 624, 75 , 0 , 0 }, + {1024, 768, 75 , 0 , 0 } + } + }}, + { "Multiscan20in", { + 6, 0x23, + "kESCSixMSB3", + "MultiScan Band-3 (13\" thru 21\")", + "Multiple Scan 20, 21\"", { + { 640, 480, 67 , 0 , 0 }, + { 832, 624, 75 , 0 , 0 }, + {1024, 768, 75 , 0 , 0 }, + {1152, 870, 75 , 0 , 0 } + } + }}, + { "HiRes12-14in", { + 6, 0x2B, + "kESCSixStandard", + "13\"/14\" RGB or 12\" Monochrome", + "B&W 12\", 12\" Apple Monochrome, 13\" Apple RGB, Hi-Res 12-14\"", { + { 640, 480, 30.24 , 35.0 , 66.7 }, + } + }}, + { "PALEncoder", { + 7, 0x00, + "kESCSevenPAL", + "PAL", + "PAL, NTSC/PAL (Option 1)", { + { 640, 480, 14.75 , 15.625, 50 }, + { 768, 576, 14.75 , 15.625, 50 } + } + }}, + { "NTSCEncoder", { + 7, 0x14, + "kESCSevenNTSC", + "NTSC", + "NTSC w/convolution (Alternate)", { + { 640, 480, 12.2727, 0 , 0 } + } + }}, + { "VGA-SVGA", { + 7, 0x17, + "kESCSevenVGA", + "VGA", + "VGA", { + { 640, 480, 25.175 , 31.47 , 59.95}, + { 800, 600, 36 , 35.16 , 56 }, + {1024, 768, 35.16 , 60 } + } + }}, + { "MacRGB16in", { + 7, 0x2D, + "kESCSeven16Inch", + "16\" RGB (GoldFish)", + "RGB 16\", 16\" Color", { + { 832, 624, 57.2832, 49.7 , 75 } + } + }}, + { "PAL", { + 7, 0x30, + "kESCSevenPALAlternate", + "PAL (Alternate)", + "PAL w/convolution (Alternate) (Option 2)", { + { 640, 480, 14.75 , 15.625, 50 }, + { 768, 576, 14.75 , 15.625, 50 } + } + }}, + { "MacRGB19in", { + 7, 0x3A, + "kESCSeven19Inch", + "Third-Party 19", + "RGB 19\", 19\" Color", { + {1024, 768, 80 , 0 , 0 } + } + }}, + { "DDC", { + 7, 0x3E, + "kESCSevenDDC", + "DDC display", + "EDID", { + {1024, 768, 80 , 0 , 0 } + } + }}, + { "NotConnected", { + 7, 0x3F, + "kESCSevenNoDisplay", + "No display connected", + "no-connect" + }}, +}; + +static const std::map MonitorAliasToId = { + { "AppleVision1710", "HiRes12-14in" } }; DisplayID::DisplayID() @@ -58,14 +229,17 @@ DisplayID::DisplayID() std::string mon_id = GET_STR_PROP("mon_id"); if (!mon_id.empty()) { + if (MonitorAliasToId.count(mon_id)) { + mon_id = MonitorAliasToId.at(mon_id); + } 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; + auto monitor = MonitorIdToCode.at(mon_id); + this->std_sense_code = monitor.std_sense_code; + this->ext_sense_code = monitor.ext_sense_code; 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); + LOG_F(INFO, "Standard sense code: %d", this->std_sense_code); + LOG_F(INFO, "Extended sense code: 0x%02X", this->ext_sense_code); } }