diff --git a/CMakeLists.txt b/CMakeLists.txt index c9fe6030..c8d030e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -593,6 +593,7 @@ if (MSVC_FOR_DECOMP) endif() if (ISLE_BUILD_CONFIG) + target_link_options(config PRIVATE "/OPT:REF") target_link_libraries(config PRIVATE mfc42) endif() diff --git a/CONFIG/AboutDlg.cpp b/CONFIG/AboutDlg.cpp index 9585d1c1..61d0d075 100644 --- a/CONFIG/AboutDlg.cpp +++ b/CONFIG/AboutDlg.cpp @@ -6,13 +6,16 @@ DECOMP_SIZE_ASSERT(CDialog, 0x60) DECOMP_SIZE_ASSERT(CAboutDialog, 0x60) // FUNCTION: CONFIG 0x00403c20 +// FUNCTION: CONFIGD 0x00408630 CAboutDialog::CAboutDialog() : CDialog(IDD) { } // FUNCTION: CONFIG 0x00403d20 +// FUNCTION: CONFIGD 0x004086a3 void CAboutDialog::DoDataExchange(CDataExchange* pDX) { + CWnd::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDialog, CDialog) diff --git a/CONFIG/AboutDlg.h b/CONFIG/AboutDlg.h index dc648d63..65db159f 100644 --- a/CONFIG/AboutDlg.h +++ b/CONFIG/AboutDlg.h @@ -6,6 +6,7 @@ #include "res/resource.h" // VTABLE: CONFIG 0x00406308 +// VTABLE: CONFIGD 0x0040c3f8 // SIZE 0x60 class CAboutDialog : public CDialog { public: @@ -22,18 +23,27 @@ protected: }; // SYNTHETIC: CONFIG 0x00403cb0 +// SYNTHETIC: CONFIGD 0x00409840 // CAboutDialog::`scalar deleting destructor' +// SYNTHETIC: CONFIG 0x00404100 +// SYNTHETIC: CONFIGD 0x00409890 +// CAboutDialog::~CAboutDialog + // FUNCTION: CONFIG 0x00403d30 +// FUNCTION: CONFIGD 0x004086c7 // CAboutDialog::_GetBaseMessageMap // FUNCTION: CONFIG 0x00403d40 +// FUNCTION: CONFIGD 0x004086dc // CAboutDialog::GetMessageMap // GLOBAL: CONFIG 0x00406100 +// GLOBAL: CONFIGD 0x0040c188 // CAboutDialog::messageMap // GLOBAL: CONFIG 0x00406108 +// GLOBAL: CONFIGD 0x0040c190 // CAboutDialog::_messageEntries #endif // !defined(AFX_ABOUTDLG_H) diff --git a/CONFIG/ConfigCommandLineInfo.cpp b/CONFIG/ConfigCommandLineInfo.cpp index cf3180c4..4542746f 100644 --- a/CONFIG/ConfigCommandLineInfo.cpp +++ b/CONFIG/ConfigCommandLineInfo.cpp @@ -6,12 +6,20 @@ DECOMP_SIZE_ASSERT(CCommandLineInfo, 0x24) DECOMP_SIZE_ASSERT(CConfigCommandLineInfo, 0x24) // FUNCTION: CONFIG 0x00403b10 +// FUNCTION: CONFIGD 0x00407caa CConfigCommandLineInfo::CConfigCommandLineInfo() { currentConfigApp->m_run_config_dialog = FALSE; } +// FUNCTION: CONFIG 0x00403ba0 +// FUNCTION: CONFIGD 0x00407d2e +CConfigCommandLineInfo::~CConfigCommandLineInfo() +{ +} + // FUNCTION: CONFIG 0x00403bf0 +// FUNCTION: CONFIGD 0x00407d96 void CConfigCommandLineInfo::ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) { if (bFlag) { diff --git a/CONFIG/ConfigCommandLineInfo.h b/CONFIG/ConfigCommandLineInfo.h index 82510df1..762ecb16 100644 --- a/CONFIG/ConfigCommandLineInfo.h +++ b/CONFIG/ConfigCommandLineInfo.h @@ -7,15 +7,18 @@ #include "decomp.h" // VTABLE: CONFIG 0x004060e8 +// VTABLE: CONFIGD 0x0040c168 // SIZE 0x24 class CConfigCommandLineInfo : public CCommandLineInfo { public: CConfigCommandLineInfo(); + ~CConfigCommandLineInfo() override; void ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) override; }; // SYNTHETIC: CONFIG 0x00403b80 +// SYNTHETIC: CONFIGD 0x004085e0 // CConfigCommandLineInfo::`scalar deleting destructor' #endif // !defined(AFX_CONFIGCOMMANDLINEINFO_H) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index cf88727a..9a99f121 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -4,21 +4,24 @@ #include "config.h" #include "res/resource.h" +#include #include DECOMP_SIZE_ASSERT(CDialog, 0x60) DECOMP_SIZE_ASSERT(CMainDialog, 0x70) // FUNCTION: CONFIG 0x00403d50 +// FUNCTION: CONFIGD 0x004086f7 CMainDialog::CMainDialog(CWnd* pParent) : CDialog(IDD, pParent) { - afxCurrentWinApp; - m_icon = LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(IDI_CONFIG), RT_GROUP_ICON), MAKEINTRESOURCE(IDI_CONFIG)); + m_icon = currentConfigApp->LoadIcon(IDI_CONFIG); } // FUNCTION: CONFIG 0x00403e50 +// FUNCTION: CONFIGD 0x00408785 void CMainDialog::DoDataExchange(CDataExchange* pDX) { + CWnd::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CMainDialog, CDialog) @@ -44,53 +47,64 @@ ON_COMMAND(IDC_CHK_MUSIC, OnCheckboxMusic) END_MESSAGE_MAP() // FUNCTION: CONFIG 0x00403e80 +// FUNCTION: CONFIGD 0x004087d9 BOOL CMainDialog::OnInitDialog() { CDialog::OnInitDialog(); SwitchToAdvanced(FALSE); - CMenu* system_menu = CMenu::FromHandle(::GetSystemMenu(m_hWnd, FALSE)); + CMenu* system_menu = CWnd::GetSystemMenu(FALSE); CString about_text; about_text.LoadString(IDS_ABOUT); - if (system_menu) { - AppendMenu(system_menu->m_hMenu, MF_SEPARATOR, 0, NULL); - AppendMenu(system_menu->m_hMenu, MF_STRING, 16, (LPCTSTR) about_text); + if (!about_text.IsEmpty()) { + system_menu->AppendMenu(MF_SEPARATOR, 0, (LPCTSTR) NULL); + system_menu->AppendMenu(MF_STRING, 16, (LPCTSTR) about_text); } - SendMessage(WM_SETICON, ICON_BIG, (LPARAM) m_icon); - SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) m_icon); - LegoDeviceEnumerate* enumerator = currentConfigApp->m_device_enumerator; - enumerator->FUN_1009d210(); + + CWnd::SetIcon(m_icon, TRUE); + CWnd::SetIcon(m_icon, FALSE); + + LegoDeviceEnumerate* info = currentConfigApp->m_dxInfo; + assert(info); + + info->FUN_1009d210(); m_modified = currentConfigApp->ReadRegisterSettings(); - CWnd* list_3d_devices = GetDlgItem(IDC_LIST_3DDEVICES); + CListBox* list_3d_devices = (CListBox*) GetDlgItem(IDC_LIST_3DDEVICES); int driver_i = 0; int device_i = 0; int selected = 0; - char device_name[256]; - const list& driver_list = enumerator->m_ddInfo; - for (list::const_iterator it_driver = driver_list.begin(); it_driver != driver_list.end(); it_driver++) { + + for (list::iterator it_driver = info->m_ddInfo.begin(); it_driver != info->m_ddInfo.end(); + it_driver++, driver_i++) { const MxDriver& driver = *it_driver; + for (list::const_iterator it_device = driver.m_devices.begin(); it_device != driver.m_devices.end(); it_device++) { - const Direct3DDeviceInfo& device = *it_device; - if (&device == currentConfigApp->m_device) { + + if (&(*it_device) == currentConfigApp->m_d3dInfo) { selected = device_i; } + + char device_name[256]; + if (driver_i == 0) { + sprintf(device_name, "%s ( Primary Device )", (*it_device).m_deviceName); + } + else { + sprintf(device_name, "%s ( Secondary Device )", (*it_device).m_deviceName); + } + + list_3d_devices->AddString(device_name); device_i += 1; - sprintf( - device_name, - driver_i == 0 ? "%s ( Primary Device )" : "%s ( Secondary Device )", - device.m_deviceName - ); - ::SendMessage(list_3d_devices->m_hWnd, LB_ADDSTRING, 0, (LPARAM) device_name); } - driver_i += 1; } - ::SendMessage(list_3d_devices->m_hWnd, LB_SETCURSEL, selected, 0); + + list_3d_devices->SetCurSel(selected); UpdateInterface(); return TRUE; } // FUNCTION: CONFIG 0x00404080 +// FUNCTION: CONFIGD 0x00408ab7 void CMainDialog::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xfff0) == 0x10) { @@ -98,86 +112,109 @@ void CMainDialog::OnSysCommand(UINT nID, LPARAM lParam) about_dialog.DoModal(); } else { - Default(); + CWnd::OnSysCommand(nID, lParam); } } // FUNCTION: CONFIG 0x00404150 +// FUNCTION: CONFIGD 0x00408b49 void CMainDialog::OnPaint() { if (IsIconic()) { CPaintDC painter(this); - ::SendMessage(m_hWnd, WM_ICONERASEBKGND, (WPARAM) painter.m_hDC, 0); - RECT dim; + CWnd::SendMessage(WM_ICONERASEBKGND, (WPARAM) painter.GetSafeHdc(), 0); + + int iconWidth = GetSystemMetrics(SM_CXICON); + int iconHeight = GetSystemMetrics(SM_CYICON); + + CRect dim; GetClientRect(&dim); - DrawIcon( - painter.m_hDC, - (dim.right - dim.left - GetSystemMetrics(SM_CXICON) + 1) / 2, - (dim.bottom - dim.top - GetSystemMetrics(SM_CYICON) + 1) / 2, - m_icon - ); + + int x = (dim.Width() - iconWidth + 1) / 2; + int y = (dim.Height() - iconHeight + 1) / 2; + + painter.DrawIcon(x, y, m_icon); } else { - Default(); + CWnd::OnPaint(); } } // FUNCTION: CONFIG 0x00404230 +// FUNCTION: CONFIGD 0x00408c61 HCURSOR CMainDialog::OnQueryDragIcon() { return m_icon; } // FUNCTION: CONFIG 0x00404240 +// FUNCTION: CONFIGD 0x00408c7d void CMainDialog::OnList3DevicesSelectionChanged() { - LegoDeviceEnumerate* device_enumerator = currentConfigApp->m_device_enumerator; - int selected = ::SendMessage(GetDlgItem(IDC_LIST_3DDEVICES)->m_hWnd, LB_GETCURSEL, 0, 0); - device_enumerator->GetDevice(selected, currentConfigApp->m_driver, currentConfigApp->m_device); - if (currentConfigApp->GetHardwareDeviceColorModel()) { - GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(TRUE); - } - else { + CConfigApp* app = currentConfigApp; + assert(app); + + LegoDeviceEnumerate* device_enumerator = app->m_dxInfo; + assert(device_enumerator); + + CListBox* listbox = (CListBox*) GetDlgItem(IDC_LIST_3DDEVICES); + int selected = listbox->GetCurSel(); + int r = device_enumerator->GetDevice(selected, app->m_ddInfo, app->m_d3dInfo); + assert(r == 0); + + if (!currentConfigApp->GetHardwareDeviceColorModel()) { currentConfigApp->m_3d_video_ram = FALSE; currentConfigApp->m_flip_surfaces = FALSE; CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram); CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces); } + else { + GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(TRUE); + } + m_modified = TRUE; UpdateInterface(); } // FUNCTION: CONFIG 0x00404320 +// FUNCTION: CONFIGD 0x00408d79 void CMainDialog::OnCancel() { CDialog::OnCancel(); } // FUNCTION: CONFIG 0x00404330 +// FUNCTION: CONFIGD 0x00408de5 void CMainDialog::OnDestroy() { - CDialog::Default(); + CWnd::OnDestroy(); } // FUNCTION: CONFIG 0x00404340 +// FUNCTION: CONFIGD 0x00408e03 void CMainDialog::OnButtonCancel() { if (m_modified) { currentConfigApp->WriteRegisterSettings(); } - OnCancel(); + CDialog::OnCancel(); } // FUNCTION: CONFIG 0x00404360 +// FUNCTION: CONFIGD 0x00408e2f void CMainDialog::UpdateInterface() { currentConfigApp->ValidateSettings(); - GetDlgItem(IDC_CHK_3D_VIDEO_MEMORY) - ->EnableWindow(!currentConfigApp->m_flip_surfaces && !currentConfigApp->GetHardwareDeviceColorModel()); - CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces); + BOOL flip_surfaces = currentConfigApp->m_flip_surfaces; + + BOOL enable3d = !flip_surfaces && !currentConfigApp->GetHardwareDeviceColorModel(); + GetDlgItem(IDC_CHK_3D_VIDEO_MEMORY)->EnableWindow(enable3d); + + CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, flip_surfaces); CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram); BOOL full_screen = currentConfigApp->m_full_screen; currentConfigApp->AdjustDisplayBitDepthBasedOnRenderStatus(); + if (currentConfigApp->GetHardwareDeviceColorModel()) { CheckDlgButton(IDC_CHK_DRAW_CURSOR, TRUE); } @@ -186,24 +223,32 @@ void CMainDialog::UpdateInterface() currentConfigApp->m_draw_cursor = FALSE; GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(FALSE); } + if (full_screen) { - CheckRadioButton( - IDC_RAD_PALETTE_256, - IDC_RAD_PALETTE_16BIT, - currentConfigApp->m_display_bit_depth == 8 ? IDC_RAD_PALETTE_256 : IDC_RAD_PALETTE_16BIT - ); + if (currentConfigApp->m_display_bit_depth == 8) { + CheckRadioButton(IDC_RAD_PALETTE_256, IDC_RAD_PALETTE_16BIT, IDC_RAD_PALETTE_256); + } + else { + CheckRadioButton(IDC_RAD_PALETTE_256, IDC_RAD_PALETTE_16BIT, IDC_RAD_PALETTE_16BIT); + } } else { CheckDlgButton(IDC_RAD_PALETTE_256, 0); CheckDlgButton(IDC_RAD_PALETTE_16BIT, 0); currentConfigApp->m_display_bit_depth = 0; } - GetDlgItem(IDC_RAD_PALETTE_256) - ->EnableWindow(full_screen && currentConfigApp->GetConditionalDeviceRenderBitDepth()); - GetDlgItem(IDC_RAD_PALETTE_16BIT)->EnableWindow(full_screen && currentConfigApp->GetDeviceRenderBitStatus()); + + BOOL enable256 = full_screen && currentConfigApp->GetConditionalDeviceRenderBitDepth() != 0; + GetDlgItem(IDC_RAD_PALETTE_256)->EnableWindow(enable256); + + BOOL enable16 = full_screen && currentConfigApp->GetDeviceRenderBitStatus() != 0; + GetDlgItem(IDC_RAD_PALETTE_16BIT)->EnableWindow(enable16); + CheckDlgButton(IDC_CHK_3DSOUND, currentConfigApp->m_3d_sound); CheckDlgButton(IDC_CHK_DRAW_CURSOR, currentConfigApp->m_draw_cursor); + switch (currentConfigApp->m_model_quality) { + // DECOMP: case 0 removed for retail. case 1: CheckRadioButton(IDC_RAD_MODEL_QUALITY_LOW, IDC_RAD_MODEL_QUALITY_HIGH, IDC_RAD_MODEL_QUALITY_LOW); break; @@ -211,16 +256,29 @@ void CMainDialog::UpdateInterface() CheckRadioButton(IDC_RAD_MODEL_QUALITY_LOW, IDC_RAD_MODEL_QUALITY_HIGH, IDC_RAD_MODEL_QUALITY_HIGH); break; } - CheckRadioButton( - IDC_RAD_TEXTURE_QUALITY_LOW, - IDC_RAD_TEXTURE_QUALITY_HIGH, - currentConfigApp->m_texture_quality == 0 ? IDC_RAD_TEXTURE_QUALITY_LOW : IDC_RAD_TEXTURE_QUALITY_HIGH - ); + + if (currentConfigApp->m_texture_quality == 0) { + CheckRadioButton(IDC_RAD_TEXTURE_QUALITY_LOW, IDC_RAD_TEXTURE_QUALITY_HIGH, IDC_RAD_TEXTURE_QUALITY_LOW); + } + else { + CheckRadioButton(IDC_RAD_TEXTURE_QUALITY_LOW, IDC_RAD_TEXTURE_QUALITY_HIGH, IDC_RAD_TEXTURE_QUALITY_HIGH); + } + CheckDlgButton(IDC_CHK_JOYSTICK, currentConfigApp->m_use_joystick); CheckDlgButton(IDC_CHK_MUSIC, currentConfigApp->m_music); } +// STUB: CONFIGD 0x00409152 +void CMainDialog::OnCheckboxWideAngle() +{ + // DECOMP: m_wide_angle member removed for retail. + // currentConfigApp->m_wide_angle = IsDlgButtonChecked(IDC_CHK_WIDE_ANGLE); + // m_modified = TRUE; + // UpdateInterface(); +} + // FUNCTION: CONFIG 0x004045e0 +// FUNCTION: CONFIGD 0x00409198 void CMainDialog::OnCheckbox3DSound() { currentConfigApp->m_3d_sound = IsDlgButtonChecked(IDC_CHK_3DSOUND); @@ -229,6 +287,7 @@ void CMainDialog::OnCheckbox3DSound() } // FUNCTION: CONFIG 0x00404610 +// FUNCTION: CONFIGD 0x004091de void CMainDialog::OnCheckbox3DVideoMemory() { currentConfigApp->m_3d_video_ram = IsDlgButtonChecked(IDC_CHK_3D_VIDEO_MEMORY); @@ -237,6 +296,7 @@ void CMainDialog::OnCheckbox3DVideoMemory() } // FUNCTION: CONFIG 0x00404640 +// FUNCTION: CONFIGD 0x00409224 void CMainDialog::OnRadiobuttonPalette16bit() { currentConfigApp->m_display_bit_depth = 16; @@ -245,6 +305,7 @@ void CMainDialog::OnRadiobuttonPalette16bit() } // FUNCTION: CONFIG 0x00404670 +// FUNCTION: CONFIGD 0x00409261 void CMainDialog::OnRadiobuttonPalette256() { currentConfigApp->m_display_bit_depth = 8; @@ -253,6 +314,7 @@ void CMainDialog::OnRadiobuttonPalette256() } // FUNCTION: CONFIG 0x004046a0 +// FUNCTION: CONFIGD 0x0040929e void CMainDialog::OnCheckboxFlipVideoMemPages() { currentConfigApp->m_flip_surfaces = IsDlgButtonChecked(IDC_CHK_FLIP_VIDEO_MEM_PAGES); @@ -260,7 +322,24 @@ void CMainDialog::OnCheckboxFlipVideoMemPages() UpdateInterface(); } +// FUNCTION: CONFIGD 0x004092e4 +void CMainDialog::OnCheckboxFullScreen() +{ + currentConfigApp->m_full_screen = IsDlgButtonChecked(IDC_CHK_FULL_SCREEN); + m_modified = TRUE; + UpdateInterface(); +} + +// FUNCTION: CONFIGD 0x0040932a +void CMainDialog::OnRadiobuttonModelLowestQuality() +{ + currentConfigApp->m_model_quality = 0; + m_modified = TRUE; + UpdateInterface(); +} + // FUNCTION: CONFIG 0x004046d0 +// FUNCTION: CONFIGD 0x00409367 void CMainDialog::OnRadiobuttonModelLowQuality() { currentConfigApp->m_model_quality = 1; @@ -269,6 +348,7 @@ void CMainDialog::OnRadiobuttonModelLowQuality() } // FUNCTION: CONFIG 0x00404700 +// FUNCTION: CONFIGD 0x004093a4 void CMainDialog::OnRadiobuttonModelHighQuality() { currentConfigApp->m_model_quality = 2; @@ -277,6 +357,7 @@ void CMainDialog::OnRadiobuttonModelHighQuality() } // FUNCTION: CONFIG 0x00404730 +// FUNCTION: CONFIGD 0x004093e1 void CMainDialog::OnRadiobuttonTextureLowQuality() { currentConfigApp->m_texture_quality = 0; @@ -285,6 +366,7 @@ void CMainDialog::OnRadiobuttonTextureLowQuality() } // FUNCTION: CONFIG 0x00404760 +// FUNCTION: CONFIGD 0x0040941e void CMainDialog::OnRadiobuttonTextureHighQuality() { currentConfigApp->m_texture_quality = 1; @@ -293,6 +375,7 @@ void CMainDialog::OnRadiobuttonTextureHighQuality() } // FUNCTION: CONFIG 0x00404790 +// FUNCTION: CONFIGD 0x0040945b void CMainDialog::OnCheckboxJoystick() { currentConfigApp->m_use_joystick = IsDlgButtonChecked(IDC_CHK_JOYSTICK); @@ -311,8 +394,8 @@ void CMainDialog::SwitchToAdvanced(BOOL p_advanced) { RECT dialog_rect; RECT grp_advanced_rect; - ::GetWindowRect(m_hWnd, &dialog_rect); - ::GetWindowRect(GetDlgItem(IDC_GRP_ADVANCED)->m_hWnd, &grp_advanced_rect); + CWnd::GetWindowRect(&dialog_rect); + GetDlgItem(IDC_GRP_ADVANCED)->GetWindowRect(&grp_advanced_rect); CWnd* button_advanced = GetDlgItem(IDC_BTN_ADVANCED); m_advanced = p_advanced; int height; diff --git a/CONFIG/MainDlg.h b/CONFIG/MainDlg.h index eeebc868..b89299e3 100644 --- a/CONFIG/MainDlg.h +++ b/CONFIG/MainDlg.h @@ -7,6 +7,7 @@ #include "res/resource.h" // VTABLE: CONFIG 0x004063e0 +// VTABLE: CONFIGD 0x0040c500 // SIZE 0x70 class CMainDialog : public CDialog { public: @@ -35,11 +36,14 @@ protected: void OnCancel(); void OnDestroy(); void OnButtonCancel(); + void OnCheckboxWideAngle(); void OnCheckbox3DSound(); void OnCheckbox3DVideoMemory(); void OnRadiobuttonPalette16bit(); void OnRadiobuttonPalette256(); void OnCheckboxFlipVideoMemPages(); + void OnCheckboxFullScreen(); + void OnRadiobuttonModelLowestQuality(); void OnRadiobuttonModelLowQuality(); void OnRadiobuttonModelHighQuality(); void OnRadiobuttonTextureLowQuality(); @@ -52,19 +56,28 @@ protected: DECLARE_MESSAGE_MAP() }; +// SYNTHETIC: CONFIG 0x00403160 +// SYNTHETIC: CONFIGD 0x00408490 +// CMainDialog::~CMainDialog + // SYNTHETIC: CONFIG 0x00403de0 +// SYNTHETIC: CONFIGD 0x00409910 // CMainDialog::`scalar deleting destructor' // FUNCTION: CONFIG 0x00403e60 +// FUNCTION: CONFIGD 0x004087a9 // CMainDialog::_GetBaseMessageMap // FUNCTION: CONFIG 0x00403e70 +// FUNCTION: CONFIGD 0x004087be // CMainDialog::GetMessageMap // GLOBAL: CONFIG 0x00406120 +// GLOBAL: CONFIGD 0x0040c1a8 // CMainDialog::messageMap // GLOBAL: CONFIG 0x00406128 +// GLOBAL: CONFIGD 0x0040c1b0 // CMainDialog::_messageEntries #endif // !defined(AFX_MAINDLG_H) diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index c42469ee..9eac2dcb 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -55,14 +55,14 @@ BOOL CConfigApp::InitInstance() m_run_config_dialog = TRUE; } - m_device_enumerator = new LegoDeviceEnumerate; - if (m_device_enumerator->DoEnumerate()) { + m_dxInfo = new LegoDeviceEnumerate; + if (m_dxInfo->DoEnumerate()) { assert("Could not build device list." == NULL); return FALSE; } - m_driver = NULL; - m_device = NULL; + m_ddInfo = NULL; + m_d3dInfo = NULL; m_full_screen = TRUE; m_wide_view_angle = TRUE; m_use_joystick = FALSE; @@ -99,10 +99,10 @@ BOOL CConfigApp::InitInstance() ReadRegisterSettings(); ValidateSettings(); WriteRegisterSettings(); - delete m_device_enumerator; - m_device_enumerator = NULL; - m_driver = NULL; - m_device = NULL; + delete m_dxInfo; + m_dxInfo = NULL; + m_ddInfo = NULL; + m_d3dInfo = NULL; char password[256]; BOOL read = ReadReg("password", password, sizeof(password)); const char* exe = _stricmp("ogel", password) == 0 ? "isled.exe" : "isle.exe"; @@ -226,26 +226,26 @@ BOOL CConfigApp::IsDeviceInBasicRGBMode() const { /* * BUG: should be: - * return !GetHardwareDeviceColorModel() && (m_device->m_HELDesc.dcmColorModel & D3DCOLOR_RGB); + * return !GetHardwareDeviceColorModel() && (m_d3dInfo->m_HELDesc.dcmColorModel & D3DCOLOR_RGB); */ - assert(m_device); - return !GetHardwareDeviceColorModel() && m_device->m_HELDesc.dcmColorModel == D3DCOLOR_RGB; + assert(m_d3dInfo); + return !GetHardwareDeviceColorModel() && m_d3dInfo->m_HELDesc.dcmColorModel == D3DCOLOR_RGB; } // FUNCTION: CONFIG 0x00403400 // FUNCTION: CONFIGD 0x004070fa D3DCOLORMODEL CConfigApp::GetHardwareDeviceColorModel() const { - assert(m_device); - return m_device->m_HWDesc.dcmColorModel; + assert(m_d3dInfo); + return m_d3dInfo->m_HWDesc.dcmColorModel; } // FUNCTION: CONFIG 0x00403410 // FUNCTION: CONFIGD 0x0040714e BOOL CConfigApp::IsPrimaryDriver() const { - assert(m_driver && m_device_enumerator); - return m_driver == &m_device_enumerator->m_ddInfo.front(); + assert(m_ddInfo && m_dxInfo); + return m_ddInfo == &m_dxInfo->m_ddInfo.front(); } // FUNCTION: CONFIG 0x00403430 @@ -259,9 +259,9 @@ BOOL CConfigApp::ReadRegisterSettings() int r = -1; if (read) { - r = m_device_enumerator->ParseDeviceName(buffer); + r = m_dxInfo->ParseDeviceName(buffer); if (r >= 0) { - r = m_device_enumerator->GetDevice(r, m_driver, m_device); + r = m_dxInfo->GetDevice(r, m_ddInfo, m_d3dInfo); if (r) { r = -1; } @@ -269,14 +269,14 @@ BOOL CConfigApp::ReadRegisterSettings() } if (r < 0) { - m_device_enumerator->FUN_1009d210(); - r = m_device_enumerator->GetBestDevice(); + m_dxInfo->FUN_1009d210(); + r = m_dxInfo->GetBestDevice(); is_modified = TRUE; assert(r >= 0); - r = m_device_enumerator->GetDevice(r, m_driver, m_device); + r = m_dxInfo->GetDevice(r, m_ddInfo, m_d3dInfo); } - assert(r == 0 && m_driver && m_device); + assert(r == 0 && m_ddInfo && m_d3dInfo); if (!ReadRegInt("Display Bit Depth", &m_display_bit_depth)) { is_modified = TRUE; @@ -384,26 +384,26 @@ BOOL CConfigApp::ValidateSettings() // FUNCTION: CONFIGD 0x00407793 DWORD CConfigApp::GetConditionalDeviceRenderBitDepth() const { - assert(m_device); + assert(m_d3dInfo); if (IsDeviceInBasicRGBMode()) { return 0; } if (GetHardwareDeviceColorModel()) { return 0; } - return m_device->m_HELDesc.dwDeviceRenderBitDepth & DDBD_8; + return m_d3dInfo->m_HELDesc.dwDeviceRenderBitDepth & DDBD_8; } // FUNCTION: CONFIG 0x004037e0 // FUNCTION: CONFIGD 0x00407822 DWORD CConfigApp::GetDeviceRenderBitStatus() const { - assert(m_device); + assert(m_d3dInfo); if (GetHardwareDeviceColorModel()) { - return m_device->m_HWDesc.dwDeviceRenderBitDepth & DDBD_16; + return m_d3dInfo->m_HWDesc.dwDeviceRenderBitDepth & DDBD_16; } else { - return m_device->m_HELDesc.dwDeviceRenderBitDepth & DDBD_16; + return m_d3dInfo->m_HELDesc.dwDeviceRenderBitDepth & DDBD_16; } } @@ -447,10 +447,10 @@ void CConfigApp::WriteRegisterSettings() const WriteReg(NAME, buffer); \ } while (0) - assert(m_device_enumerator && m_driver && m_device); - m_device_enumerator->FormatDeviceName(buffer, m_driver, m_device); + assert(m_dxInfo && m_ddInfo && m_d3dInfo); + m_dxInfo->FormatDeviceName(buffer, m_ddInfo, m_d3dInfo); WriteReg("3D Device ID", buffer); - WriteReg("3D Device Name", m_device->m_deviceName); + WriteReg("3D Device Name", m_d3dInfo->m_deviceName); WriteRegInt("Display Bit Depth", m_display_bit_depth); WriteRegBool("Flip Surfaces", m_flip_surfaces); WriteRegBool("Full Screen", m_full_screen); @@ -472,9 +472,9 @@ void CConfigApp::WriteRegisterSettings() const // FUNCTION: CONFIGD 0x00407c44 int CConfigApp::ExitInstance() { - if (m_device_enumerator) { - delete m_device_enumerator; - m_device_enumerator = NULL; + if (m_dxInfo) { + delete m_dxInfo; + m_dxInfo = NULL; } return CWinApp::ExitInstance(); } diff --git a/CONFIG/config.h b/CONFIG/config.h index 02366100..1c8a94a4 100644 --- a/CONFIG/config.h +++ b/CONFIG/config.h @@ -11,7 +11,7 @@ class LegoDeviceEnumerate; struct Direct3DDeviceInfo; struct MxDriver; -#define currentConfigApp ((CConfigApp*) afxCurrentWinApp) +#define currentConfigApp ((CConfigApp*) AfxGetApp()) // VTABLE: CONFIG 0x00406040 // VTABLE: CONFIGD 0x0040c0a0 @@ -55,23 +55,23 @@ private: BOOL IsLegoNotRunning(); public: - LegoDeviceEnumerate* m_device_enumerator; // 0x0c4 - MxDriver* m_driver; // 0x0c8 - Direct3DDeviceInfo* m_device; // 0x0cc - int m_display_bit_depth; // 0x0d0 - BOOL m_flip_surfaces; // 0x0d4 - BOOL m_full_screen; // 0x0d8 - BOOL m_3d_video_ram; // 0x0dc - BOOL m_wide_view_angle; // 0x0e0 - BOOL m_3d_sound; // 0x0e4 - BOOL m_draw_cursor; // 0x0e8 - BOOL m_use_joystick; // 0x0ec - int m_joystick_index; // 0x0f0 - BOOL m_run_config_dialog; // 0x0f4 - int m_model_quality; // 0x0f8 - int m_texture_quality; // 0x0fc - undefined m_unk0x100[4]; // 0x100 - BOOL m_music; // 0x104 + LegoDeviceEnumerate* m_dxInfo; // 0x0c4 + MxDriver* m_ddInfo; // 0x0c8 + Direct3DDeviceInfo* m_d3dInfo; // 0x0cc + int m_display_bit_depth; // 0x0d0 + BOOL m_flip_surfaces; // 0x0d4 + BOOL m_full_screen; // 0x0d8 + BOOL m_3d_video_ram; // 0x0dc + BOOL m_wide_view_angle; // 0x0e0 + BOOL m_3d_sound; // 0x0e4 + BOOL m_draw_cursor; // 0x0e8 + BOOL m_use_joystick; // 0x0ec + int m_joystick_index; // 0x0f0 + BOOL m_run_config_dialog; // 0x0f4 + int m_model_quality; // 0x0f8 + int m_texture_quality; // 0x0fc + undefined m_unk0x100[4]; // 0x100 + BOOL m_music; // 0x104 }; // SYNTHETIC: CONFIG 0x00402cd0 diff --git a/CONFIG/detectdx5.cpp b/CONFIG/detectdx5.cpp index 8a308a8d..4e27fbee 100644 --- a/CONFIG/detectdx5.cpp +++ b/CONFIG/detectdx5.cpp @@ -3,140 +3,255 @@ #include #include -typedef HRESULT WINAPI DirectDrawCreate_fn(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter); -typedef HRESULT WINAPI -DirectInputCreateA_fn(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter); +typedef HRESULT(WINAPI* DIRECTDRAWCREATE)(GUID*, LPDIRECTDRAW*, IUnknown*); +typedef HRESULT(WINAPI* DIRECTINPUTCREATE)(HINSTANCE, DWORD, LPDIRECTINPUT*, IUnknown*); // FUNCTION: CONFIG 0x004048f0 BOOL DetectDirectX5() { - unsigned int version; - BOOL found; - DetectDirectX(&version, &found); + DWORD version; + DWORD platform; + GetDXVersion(&version, &platform); return version >= 0x500; } // FUNCTION: CONFIG 0x00404920 -void DetectDirectX(unsigned int* p_version, BOOL* p_found) +void GetDXVersion(LPDWORD pdwDXVersion, LPDWORD pdwDXPlatform) { - OSVERSIONINFOA os_version; + // From GetDXVer.cpp + HRESULT hr; + HINSTANCE DDHinst = 0; + HINSTANCE DIHinst = 0; + LPDIRECTDRAW pDDraw = 0; + LPDIRECTDRAW2 pDDraw2 = 0; + DIRECTDRAWCREATE DirectDrawCreate = 0; + DIRECTINPUTCREATE DirectInputCreate = 0; + OSVERSIONINFO osVer; + LPDIRECTDRAWSURFACE pSurf = 0; + LPDIRECTDRAWSURFACE3 pSurf3 = 0; - os_version.dwOSVersionInfoSize = sizeof(os_version); - if (!GetVersionEx(&os_version)) { - *p_version = 0; - *p_found = 0; + /* + * First get the windows platform + */ + osVer.dwOSVersionInfoSize = sizeof(osVer); + if (!GetVersionEx(&osVer)) { + *pdwDXVersion = 0; + *pdwDXPlatform = 0; return; } - if (os_version.dwPlatformId == 2) { - *p_found = 2; - if (os_version.dwMajorVersion < 4) { - *p_found = 0; + + if (osVer.dwPlatformId == VER_PLATFORM_WIN32_NT) { + *pdwDXPlatform = VER_PLATFORM_WIN32_NT; + /* + * NT is easy... NT 4.0 is DX2, 4.0 SP3 is DX3, 5.0 is DX5 + * and no DX on earlier versions. + */ + if (osVer.dwMajorVersion < 4) { + *pdwDXPlatform = 0; // No DX on NT3.51 or earlier return; } - if (os_version.dwMajorVersion != 4) { - *p_version = 0x501; + if (osVer.dwMajorVersion == 4) { + /* + * NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 + */ + *pdwDXVersion = 0x200; + + /* + * We're not supposed to be able to tell which SP we're on, so check for dinput + */ + DIHinst = LoadLibrary("DINPUT.DLL"); + if (DIHinst == 0) { + /* + * No DInput... must be DX2 on NT 4 pre-SP3 + */ + OutputDebugString("Couldn't LoadLibrary DInput\r\n"); + return; + } + + DirectInputCreate = (DIRECTINPUTCREATE) GetProcAddress(DIHinst, "DirectInputCreateA"); + FreeLibrary(DIHinst); + + if (DirectInputCreate == 0) { + /* + * No DInput... must be pre-SP3 DX2 + */ + OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n"); + return; + } + + /* + * It must be NT4, DX2 + */ + *pdwDXVersion = 0x300; // DX3 on NT4 SP3 or higher return; } - *p_version = 0x200; - HMODULE dinput_module = LoadLibrary("DINPUT.DLL"); - if (!dinput_module) { - OutputDebugString("Couldn't LoadLibrary DInput\r\n"); - return; - } - DirectInputCreateA_fn* func_DirectInputCreateA = - (DirectInputCreateA_fn*) GetProcAddress(dinput_module, "DirectInputCreateA"); - FreeLibrary(dinput_module); - if (!func_DirectInputCreateA) { - OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n"); - return; - } - *p_version = 0x300; + /* + * Else it's NT5 or higher, and it's DX5a or higher: + */ + *pdwDXVersion = 0x501; // DX5a on NT5 return; } - *p_found = 1; - if (LOWORD(os_version.dwBuildNumber) >= 0x550) { - *p_version = 0x501; + + /* + * Not NT... must be Win9x + */ + *pdwDXPlatform = VER_PLATFORM_WIN32_WINDOWS; + + /* + * If we are on Memphis or higher, then we are at least DX5a + */ + if ((osVer.dwBuildNumber & 0xffff) > 1353) // Check for higher than developer release + { + *pdwDXVersion = 0x501; // DX5a on Memphis or higher return; } - HMODULE ddraw_module = LoadLibrary("DDRAW.DLL"); - if (!ddraw_module) { - *p_version = 0; - *p_found = 0; - FreeLibrary(ddraw_module); + + /* + * Now we know we are in Windows 9x (or maybe 3.1), so anything's possible. + * First see if DDRAW.DLL even exists. + */ + DDHinst = LoadLibrary("DDRAW.DLL"); + if (DDHinst == 0) { + *pdwDXVersion = 0; + *pdwDXPlatform = 0; + FreeLibrary(DDHinst); return; } - DirectDrawCreate_fn* func_DirectDrawCreate = - (DirectDrawCreate_fn*) GetProcAddress(ddraw_module, "DirectDrawCreate"); - if (!func_DirectDrawCreate) { - *p_version = 0; - *p_found = 0; - FreeLibrary(ddraw_module); + + /* + * See if we can create the DirectDraw object. + */ + DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(DDHinst, "DirectDrawCreate"); + if (DirectDrawCreate == 0) { + *pdwDXVersion = 0; + *pdwDXPlatform = 0; + FreeLibrary(DDHinst); OutputDebugString("Couldn't LoadLibrary DDraw\r\n"); return; } - LPDIRECTDRAW ddraw; - if (FAILED(func_DirectDrawCreate(NULL, &ddraw, NULL))) { - *p_version = 0; - *p_found = 0; - FreeLibrary(ddraw_module); + + hr = DirectDrawCreate(NULL, &pDDraw, NULL); + if (FAILED(hr)) { + *pdwDXVersion = 0; + *pdwDXPlatform = 0; + FreeLibrary(DDHinst); OutputDebugString("Couldn't create DDraw\r\n"); return; } - *p_version = 0x100; - LPDIRECTDRAW2 ddraw2; - if (FAILED(ddraw->QueryInterface(IID_IDirectDraw2, (LPVOID*) &ddraw2))) { - ddraw->Release(); - FreeLibrary(ddraw_module); + + /* + * So DirectDraw exists. We are at least DX1. + */ + *pdwDXVersion = 0x100; + + /* + * Let's see if IID_IDirectDraw2 exists. + */ + hr = pDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID*) &pDDraw2); + if (FAILED(hr)) { + /* + * No IDirectDraw2 exists... must be DX1 + */ + pDDraw->Release(); + FreeLibrary(DDHinst); OutputDebugString("Couldn't QI DDraw2\r\n"); return; } - ddraw->Release(); - *p_version = 0x200; - HMODULE dinput_module = LoadLibrary("DINPUT.DLL"); - if (!dinput_module) { + /* + * IDirectDraw2 exists. We must be at least DX2 + */ + pDDraw2->Release(); + *pdwDXVersion = 0x200; + + /* + * See if we can create the DirectInput object. + */ + DIHinst = LoadLibrary("DINPUT.DLL"); + if (DIHinst == 0) { + /* + * No DInput... must be DX2 + */ OutputDebugString("Couldn't LoadLibrary DInput\r\n"); - ddraw2->Release(); - FreeLibrary(ddraw_module); + pDDraw->Release(); + FreeLibrary(DDHinst); return; } - DirectInputCreateA_fn* func_DirectInputCreateA = - (DirectInputCreateA_fn*) GetProcAddress(dinput_module, "DirectInputCreateA"); - FreeLibrary(dinput_module); - if (!func_DirectInputCreateA) { - FreeLibrary(ddraw_module); - ddraw2->Release(); + + DirectInputCreate = (DIRECTINPUTCREATE) GetProcAddress(DIHinst, "DirectInputCreateA"); + FreeLibrary(DIHinst); + + if (DirectInputCreate == 0) { + /* + * No DInput... must be DX2 + */ + FreeLibrary(DDHinst); + pDDraw->Release(); OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n"); return; } - *p_version = 0x300; - DDSURFACEDESC surface_desc; - memset(&surface_desc, 0, sizeof(surface_desc)); - surface_desc.dwSize = sizeof(surface_desc); - surface_desc.dwFlags = DDSD_CAPS; - surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - if (FAILED(ddraw2->SetCooperativeLevel(NULL, DDSCL_NORMAL))) { - ddraw2->Release(); - FreeLibrary(ddraw_module); - *p_version = 0; + + /* + * DirectInputCreate exists. That's enough to tell us that we are at least DX3 + */ + *pdwDXVersion = 0x300; + + /* + * Checks for 3a vs 3b? + */ + + /* + * We can tell if DX5 is present by checking for the existence of IDirectDrawSurface3. + * First we need a surface to QI off of. + */ + DDSURFACEDESC desc; + + ZeroMemory(&desc, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = pDDraw->SetCooperativeLevel(NULL, DDSCL_NORMAL); + if (FAILED(hr)) { + /* + * Failure. This means DDraw isn't properly installed. + */ + pDDraw->Release(); + FreeLibrary(DDHinst); + *pdwDXVersion = 0; OutputDebugString("Couldn't Set coop level\r\n"); return; } - LPDIRECTDRAWSURFACE surface; - if (FAILED(ddraw2->CreateSurface(&surface_desc, &surface, NULL))) { - ddraw2->Release(); - FreeLibrary(ddraw_module); - *p_version = 0; + + hr = pDDraw->CreateSurface(&desc, &pSurf, NULL); + if (FAILED(hr)) { + /* + * Failure. This means DDraw isn't properly installed. + */ + pDDraw->Release(); + FreeLibrary(DDHinst); + *pdwDXVersion = 0; OutputDebugString("Couldn't CreateSurface\r\n"); return; } - LPDIRECTDRAWSURFACE3 surface3; - if (FAILED(surface->QueryInterface(IID_IDirectDrawSurface3, (LPVOID*) &surface3))) { - ddraw2->Release(); - FreeLibrary(ddraw_module); + + /* + * Try for the IDirectDrawSurface3 interface. If it works, we're on DX5 at least + */ + if (FAILED(pSurf->QueryInterface(IID_IDirectDrawSurface3, (LPVOID*) &pSurf3))) { + pDDraw->Release(); + FreeLibrary(DDHinst); + return; } - *p_version = 0x500; - surface3->Release(); - ddraw2->Release(); - FreeLibrary(ddraw_module); + + /* + * QI for IDirectDrawSurface3 succeeded. We must be at least DX5 + */ + *pdwDXVersion = 0x500; + + pSurf->Release(); + pDDraw->Release(); + FreeLibrary(DDHinst); + + return; } diff --git a/CONFIG/detectdx5.h b/CONFIG/detectdx5.h index 6f45837c..ddb56f60 100644 --- a/CONFIG/detectdx5.h +++ b/CONFIG/detectdx5.h @@ -5,6 +5,6 @@ extern BOOL DetectDirectX5(); -extern void DetectDirectX(unsigned int* p_version, BOOL* p_found); +extern void GetDXVersion(LPDWORD pdwDXVersion, LPDWORD pdwDXPlatform); #endif // !defined(AFX_DETECTDX5_H) diff --git a/CONFIG/res/resource.h b/CONFIG/res/resource.h index 4c72eaa1..bf3dfe74 100644 --- a/CONFIG/res/resource.h +++ b/CONFIG/res/resource.h @@ -7,10 +7,12 @@ #define IDC_LIST_3DDEVICES 1000 #define IDC_CHK_FLIP_VIDEO_MEM_PAGES 1001 +#define IDC_CHK_FULL_SCREEN 1002 // beta only #define IDC_CHK_3D_VIDEO_MEMORY 1003 #define IDC_RAD_PALETTE_256 1004 #define IDC_RAD_PALETTE_16BIT 1005 #define IDC_CHK_3DSOUND 1006 +#define IDC_CHK_WIDE_ANGLE 1007 // beta only #define IDC_CHK_DRAW_CURSOR 1008 #define IDC_RAD_MODEL_QUALITY_LOW 1010 #define IDC_RAD_MODEL_QUALITY_HIGH 1011