diff --git a/machines/machinefactory.cpp b/machines/machinefactory.cpp index 5f32166..f6b9fcc 100644 --- a/machines/machinefactory.cpp +++ b/machines/machinefactory.cpp @@ -81,6 +81,7 @@ static const map PropHelp = { {"fdd_wr_prot", "toggles floppy disk's write protection"}, {"hdd_img", "specifies path to hard disk image"}, {"hdd_wr_prot", "toggles hard disk's write protection"}, + {"cdr_config", "CD-ROM device path in [bus]:[device#] format"}, {"cdr_img", "specifies path to CD-ROM image"}, {"mon_id", "specifies which monitor to emulate"}, {"pci_A1", "insert a PCI device into A1 slot"}, diff --git a/machines/machineproperties.cpp b/machines/machineproperties.cpp index e4bfe6d..8ae7d55 100644 --- a/machines/machineproperties.cpp +++ b/machines/machineproperties.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-22 divingkatae and maximum +Copyright (C) 2018-23 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -144,3 +144,21 @@ void BinProperty::set_string(string val) LOG_F(ERROR, "Invalid BinProperty value %s!", val.c_str()); } } + +void parse_device_path(string dev_path, string& bus_id, uint32_t& dev_num) { + bus_id = ""; + dev_num = -1; + + size_t delimiter_pos = dev_path.find(":"); + if (delimiter_pos == string::npos) + ABORT_F("Invalid device path %s", dev_path.c_str()); + + bus_id = dev_path.substr(0, delimiter_pos); + + try { + dev_num = (uint32_t)strtoul(dev_path.substr(delimiter_pos+1).c_str(), 0, 0); + } catch (string bad_string) { + ABORT_F("Invalid device number %s in device path %s", bad_string.c_str(), + dev_path.c_str()); + } +} diff --git a/machines/machineproperties.h b/machines/machineproperties.h index 87943f8..7805b91 100644 --- a/machines/machineproperties.h +++ b/machines/machineproperties.h @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-22 divingkatae and maximum +Copyright (C) 2018-23 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -189,6 +189,8 @@ private: int bin_val; }; +void parse_device_path(string dev_path, string& bus_id, uint32_t& dev_num); + /** Special map type for specifying machine presets. */ typedef map PropMap; @@ -205,4 +207,4 @@ extern map> gMachineSettings; #define GET_BIN_PROP(name) \ dynamic_cast(gMachineSettings.at(name).get())->get_val() -#endif /* MACHINE_PROPERTIES_H */ +#endif // MACHINE_PROPERTIES_H