diff --git a/src/86box.c b/src/86box.c index 16d7cf3de..5e1f58413 100644 --- a/src/86box.c +++ b/src/86box.c @@ -179,7 +179,7 @@ int postcard_enabled = 0; /* (C) enable int unittester_enabled = 0; /* (C) enable unit tester device */ int isamem_type[ISAMEM_MAX] = { 0, 0, 0, 0 }; /* (C) enable ISA mem cards */ int isartc_type = 0; /* (C) enable ISA RTC card */ -int gfxcard[2] = { 0, 0 }; /* (C) graphics/video card */ +int gfxcard[GFXCARD_MAX] = { 0, 0 }; /* (C) graphics/video card */ int show_second_monitors = 1; /* (C) show non-primary monitors */ int sound_is_float = 1; /* (C) sound uses FP values */ int voodoo_enabled = 0; /* (C) video option */ @@ -1004,12 +1004,15 @@ pc_init_modules(void) } } - if (!video_card_available(gfxcard[1])) { - char tempc[512] = { 0 }; - device_get_name(video_card_getdevice(gfxcard[1]), 0, tempc); - swprintf(temp, sizeof_w(temp), plat_get_string(STRING_HW_NOT_AVAILABLE_VIDEO2), tempc); - ui_msgbox_header(MBX_INFO, plat_get_string(STRING_HW_NOT_AVAILABLE_TITLE), temp); - gfxcard[1] = 0; + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if (!video_card_available(gfxcard[i])) { + char tempc[512] = { 0 }; + device_get_name(video_card_getdevice(gfxcard[i]), 0, tempc); + swprintf(temp, sizeof_w(temp), plat_get_string(STRING_HW_NOT_AVAILABLE_VIDEO2), tempc); + ui_msgbox_header(MBX_INFO, plat_get_string(STRING_HW_NOT_AVAILABLE_TITLE), temp); + gfxcard[i] = 0; + } } atfullspeed = 0; diff --git a/src/config.c b/src/config.c index 8a837cf56..43555a704 100644 --- a/src/config.c +++ b/src/config.c @@ -459,10 +459,13 @@ load_video(void) show_second_monitors = !!ini_section_get_int(cat, "show_second_monitors", 1); video_fullscreen_scale_maximized = !!ini_section_get_int(cat, "video_fullscreen_scale_maximized", 0); - p = ini_section_get_string(cat, "gfxcard_2", NULL); - if (!p) - p = "none"; - gfxcard[1] = video_get_video_from_internal_name(p); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + p = ini_section_get_string(cat, "gfxcard_2", NULL); + if (!p) + p = "none"; + gfxcard[i] = video_get_video_from_internal_name(p); + } } /* Load "Input Devices" section. */ @@ -2010,10 +2013,13 @@ save_video(void) else ini_section_set_int(cat, "xga", xga_standalone_enabled); - if (gfxcard[1] == 0) - ini_section_delete_var(cat, "gfxcard_2"); - else - ini_section_set_string(cat, "gfxcard_2", video_get_internal_name(gfxcard[1])); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if (gfxcard[i] == 0) + ini_section_delete_var(cat, "gfxcard_2"); + else + ini_section_set_string(cat, "gfxcard_2", video_get_internal_name(gfxcard[i])); + } if (show_second_monitors == 1) ini_section_delete_var(cat, "show_second_monitors"); diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 0d57b4cae..c91b8d406 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -21,6 +21,7 @@ #define EMU_86BOX_H /* Configuration values. */ +#define GFXCARD_MAX 2 #define SERIAL_MAX 7 #define PARALLEL_MAX 4 #define SCREEN_RES_X 640 @@ -124,7 +125,7 @@ extern int force_43; /* (C) video */ extern int video_filter_method; /* (C) video */ extern int video_vsync; /* (C) video */ extern int video_framerate; /* (C) video */ -extern int gfxcard[2]; /* (C) graphics/video card */ +extern int gfxcard[GFXCARD_MAX]; /* (C) graphics/video card */ extern char video_shader[512]; /* (C) video */ extern int bugger_enabled; /* (C) enable ISAbugger */ extern int novell_keycard_enabled; /* (C) enable Novell NetWare 2.x key card emulation. */ diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 049a7907b..c39007864 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -145,9 +145,11 @@ main_thread_fn() } is_quit = 1; - if (gfxcard[1]) { - ui_deinit_monitor(1); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if (gfxcard[i]) { + ui_deinit_monitor(i); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } } QTimer::singleShot(0, QApplication::instance(), []() { QApplication::processEvents(); QApplication::instance()->quit(); }); } diff --git a/src/qt/qt_settingsdisplay.cpp b/src/qt/qt_settingsdisplay.cpp index 6969a1c2c..db8c30e5d 100644 --- a/src/qt/qt_settingsdisplay.cpp +++ b/src/qt/qt_settingsdisplay.cpp @@ -36,8 +36,8 @@ SettingsDisplay::SettingsDisplay(QWidget *parent) { ui->setupUi(this); - videoCard[0] = gfxcard[0]; - videoCard[1] = gfxcard[1]; + for (uint8_t i = 0; i < GFXCARD_MAX; i ++) + videoCard[i] = gfxcard[i]; onCurrentMachineChanged(machine); } @@ -50,7 +50,9 @@ void SettingsDisplay::save() { gfxcard[0] = ui->comboBoxVideo->currentData().toInt(); - gfxcard[1] = ui->comboBoxVideoSecondary->currentData().toInt(); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) + gfxcard[i] = ui->comboBoxVideoSecondary->currentData().toInt(); voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0; ibm8514_standalone_enabled = ui->checkBox8514->isChecked() ? 1 : 0; xga_standalone_enabled = ui->checkBoxXga->isChecked() ? 1 : 0; @@ -103,8 +105,10 @@ SettingsDisplay::onCurrentMachineChanged(int machineId) ui->pushButtonConfigureSecondary->setEnabled(true); } ui->comboBoxVideo->setCurrentIndex(selectedRow); - if (gfxcard[1] == 0) - ui->pushButtonConfigureSecondary->setEnabled(false); + // TODO + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) + if (gfxcard[i] == 0) + ui->pushButtonConfigureSecondary->setEnabled(false); } void diff --git a/src/qt/qt_settingsdisplay.hpp b/src/qt/qt_settingsdisplay.hpp index 8331bbb5b..6297f7eae 100644 --- a/src/qt/qt_settingsdisplay.hpp +++ b/src/qt/qt_settingsdisplay.hpp @@ -3,6 +3,8 @@ #include +#define VIDEOCARD_MAX 2 + namespace Ui { class SettingsDisplay; } @@ -36,7 +38,7 @@ private slots: private: Ui::SettingsDisplay *ui; int machineId = 0; - int videoCard[2] = { 0, 0 }; + int videoCard[VIDEOCARD_MAX] = { 0, 0 }; }; #endif // QT_SETTINGSDISPLAY_HPP diff --git a/src/unix/unix.c b/src/unix/unix.c index e08b82133..1fe477a23 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -1168,7 +1168,7 @@ monitor_thread(void *param) #endif } -extern int gfxcard[2]; +extern int gfxcard[GFXCARD_MAX]; int main(int argc, char **argv) { @@ -1186,7 +1186,8 @@ main(int argc, char **argv) return 6; } - gfxcard[1] = 0; + for (uint8_t i = 1; i < GFXCARD_MAX; i++) + gfxcard[i] = 0; eventthread = SDL_ThreadID(); blitmtx = SDL_CreateMutex(); if (!blitmtx) { diff --git a/src/video/vid_table.c b/src/video/vid_table.c index bcc7d5de8..284b79a67 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -322,12 +322,14 @@ video_reset(int card) monitor_index_global = 0; loadfont("roms/video/mda/mda.rom", 0); - if ((card != VID_NONE) && !machine_has_flags(machine, MACHINE_VIDEO_ONLY) && - (gfxcard[1] > VID_INTERNAL) && device_is_valid(video_card_getdevice(gfxcard[1]), machine)) { - video_monitor_init(1); - monitor_index_global = 1; - device_add(video_cards[gfxcard[1]].device); - monitor_index_global = 0; + for (uint8_t i = 1; i < GFXCARD_MAX; i ++) { + if ((card != VID_NONE) && !machine_has_flags(machine, MACHINE_VIDEO_ONLY) && + (gfxcard[i] > VID_INTERNAL) && device_is_valid(video_card_getdevice(gfxcard[i]), machine)) { + video_monitor_init(i); + monitor_index_global = 1; + device_add(video_cards[gfxcard[i]].device); + monitor_index_global = 0; + } } /* Do not initialize internal cards here. */