This commit is contained in:
MS
2025-07-15 12:58:13 -04:00
committed by GitHub
parent 9c9baf3c3e
commit bf98bfffdf
12 changed files with 441 additions and 203 deletions

View File

@@ -593,6 +593,7 @@ if (MSVC_FOR_DECOMP)
endif() endif()
if (ISLE_BUILD_CONFIG) if (ISLE_BUILD_CONFIG)
target_link_options(config PRIVATE "/OPT:REF")
target_link_libraries(config PRIVATE mfc42) target_link_libraries(config PRIVATE mfc42)
endif() endif()

View File

@@ -6,13 +6,16 @@ DECOMP_SIZE_ASSERT(CDialog, 0x60)
DECOMP_SIZE_ASSERT(CAboutDialog, 0x60) DECOMP_SIZE_ASSERT(CAboutDialog, 0x60)
// FUNCTION: CONFIG 0x00403c20 // FUNCTION: CONFIG 0x00403c20
// FUNCTION: CONFIGD 0x00408630
CAboutDialog::CAboutDialog() : CDialog(IDD) CAboutDialog::CAboutDialog() : CDialog(IDD)
{ {
} }
// FUNCTION: CONFIG 0x00403d20 // FUNCTION: CONFIG 0x00403d20
// FUNCTION: CONFIGD 0x004086a3
void CAboutDialog::DoDataExchange(CDataExchange* pDX) void CAboutDialog::DoDataExchange(CDataExchange* pDX)
{ {
CWnd::DoDataExchange(pDX);
} }
BEGIN_MESSAGE_MAP(CAboutDialog, CDialog) BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)

View File

@@ -6,6 +6,7 @@
#include "res/resource.h" #include "res/resource.h"
// VTABLE: CONFIG 0x00406308 // VTABLE: CONFIG 0x00406308
// VTABLE: CONFIGD 0x0040c3f8
// SIZE 0x60 // SIZE 0x60
class CAboutDialog : public CDialog { class CAboutDialog : public CDialog {
public: public:
@@ -22,18 +23,27 @@ protected:
}; };
// SYNTHETIC: CONFIG 0x00403cb0 // SYNTHETIC: CONFIG 0x00403cb0
// SYNTHETIC: CONFIGD 0x00409840
// CAboutDialog::`scalar deleting destructor' // CAboutDialog::`scalar deleting destructor'
// SYNTHETIC: CONFIG 0x00404100
// SYNTHETIC: CONFIGD 0x00409890
// CAboutDialog::~CAboutDialog
// FUNCTION: CONFIG 0x00403d30 // FUNCTION: CONFIG 0x00403d30
// FUNCTION: CONFIGD 0x004086c7
// CAboutDialog::_GetBaseMessageMap // CAboutDialog::_GetBaseMessageMap
// FUNCTION: CONFIG 0x00403d40 // FUNCTION: CONFIG 0x00403d40
// FUNCTION: CONFIGD 0x004086dc
// CAboutDialog::GetMessageMap // CAboutDialog::GetMessageMap
// GLOBAL: CONFIG 0x00406100 // GLOBAL: CONFIG 0x00406100
// GLOBAL: CONFIGD 0x0040c188
// CAboutDialog::messageMap // CAboutDialog::messageMap
// GLOBAL: CONFIG 0x00406108 // GLOBAL: CONFIG 0x00406108
// GLOBAL: CONFIGD 0x0040c190
// CAboutDialog::_messageEntries // CAboutDialog::_messageEntries
#endif // !defined(AFX_ABOUTDLG_H) #endif // !defined(AFX_ABOUTDLG_H)

View File

@@ -6,12 +6,20 @@ DECOMP_SIZE_ASSERT(CCommandLineInfo, 0x24)
DECOMP_SIZE_ASSERT(CConfigCommandLineInfo, 0x24) DECOMP_SIZE_ASSERT(CConfigCommandLineInfo, 0x24)
// FUNCTION: CONFIG 0x00403b10 // FUNCTION: CONFIG 0x00403b10
// FUNCTION: CONFIGD 0x00407caa
CConfigCommandLineInfo::CConfigCommandLineInfo() CConfigCommandLineInfo::CConfigCommandLineInfo()
{ {
currentConfigApp->m_run_config_dialog = FALSE; currentConfigApp->m_run_config_dialog = FALSE;
} }
// FUNCTION: CONFIG 0x00403ba0
// FUNCTION: CONFIGD 0x00407d2e
CConfigCommandLineInfo::~CConfigCommandLineInfo()
{
}
// FUNCTION: CONFIG 0x00403bf0 // FUNCTION: CONFIG 0x00403bf0
// FUNCTION: CONFIGD 0x00407d96
void CConfigCommandLineInfo::ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) void CConfigCommandLineInfo::ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast)
{ {
if (bFlag) { if (bFlag) {

View File

@@ -7,15 +7,18 @@
#include "decomp.h" #include "decomp.h"
// VTABLE: CONFIG 0x004060e8 // VTABLE: CONFIG 0x004060e8
// VTABLE: CONFIGD 0x0040c168
// SIZE 0x24 // SIZE 0x24
class CConfigCommandLineInfo : public CCommandLineInfo { class CConfigCommandLineInfo : public CCommandLineInfo {
public: public:
CConfigCommandLineInfo(); CConfigCommandLineInfo();
~CConfigCommandLineInfo() override;
void ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) override; void ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) override;
}; };
// SYNTHETIC: CONFIG 0x00403b80 // SYNTHETIC: CONFIG 0x00403b80
// SYNTHETIC: CONFIGD 0x004085e0
// CConfigCommandLineInfo::`scalar deleting destructor' // CConfigCommandLineInfo::`scalar deleting destructor'
#endif // !defined(AFX_CONFIGCOMMANDLINEINFO_H) #endif // !defined(AFX_CONFIGCOMMANDLINEINFO_H)

View File

@@ -4,21 +4,24 @@
#include "config.h" #include "config.h"
#include "res/resource.h" #include "res/resource.h"
#include <assert.h>
#include <mxdirectx/legodxinfo.h> #include <mxdirectx/legodxinfo.h>
DECOMP_SIZE_ASSERT(CDialog, 0x60) DECOMP_SIZE_ASSERT(CDialog, 0x60)
DECOMP_SIZE_ASSERT(CMainDialog, 0x70) DECOMP_SIZE_ASSERT(CMainDialog, 0x70)
// FUNCTION: CONFIG 0x00403d50 // FUNCTION: CONFIG 0x00403d50
// FUNCTION: CONFIGD 0x004086f7
CMainDialog::CMainDialog(CWnd* pParent) : CDialog(IDD, pParent) CMainDialog::CMainDialog(CWnd* pParent) : CDialog(IDD, pParent)
{ {
afxCurrentWinApp; m_icon = currentConfigApp->LoadIcon(IDI_CONFIG);
m_icon = LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(IDI_CONFIG), RT_GROUP_ICON), MAKEINTRESOURCE(IDI_CONFIG));
} }
// FUNCTION: CONFIG 0x00403e50 // FUNCTION: CONFIG 0x00403e50
// FUNCTION: CONFIGD 0x00408785
void CMainDialog::DoDataExchange(CDataExchange* pDX) void CMainDialog::DoDataExchange(CDataExchange* pDX)
{ {
CWnd::DoDataExchange(pDX);
} }
BEGIN_MESSAGE_MAP(CMainDialog, CDialog) BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
@@ -44,53 +47,64 @@ ON_COMMAND(IDC_CHK_MUSIC, OnCheckboxMusic)
END_MESSAGE_MAP() END_MESSAGE_MAP()
// FUNCTION: CONFIG 0x00403e80 // FUNCTION: CONFIG 0x00403e80
// FUNCTION: CONFIGD 0x004087d9
BOOL CMainDialog::OnInitDialog() BOOL CMainDialog::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
SwitchToAdvanced(FALSE); SwitchToAdvanced(FALSE);
CMenu* system_menu = CMenu::FromHandle(::GetSystemMenu(m_hWnd, FALSE)); CMenu* system_menu = CWnd::GetSystemMenu(FALSE);
CString about_text; CString about_text;
about_text.LoadString(IDS_ABOUT); about_text.LoadString(IDS_ABOUT);
if (system_menu) { if (!about_text.IsEmpty()) {
AppendMenu(system_menu->m_hMenu, MF_SEPARATOR, 0, NULL); system_menu->AppendMenu(MF_SEPARATOR, 0, (LPCTSTR) NULL);
AppendMenu(system_menu->m_hMenu, MF_STRING, 16, (LPCTSTR) about_text); 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); CWnd::SetIcon(m_icon, TRUE);
LegoDeviceEnumerate* enumerator = currentConfigApp->m_device_enumerator; CWnd::SetIcon(m_icon, FALSE);
enumerator->FUN_1009d210();
LegoDeviceEnumerate* info = currentConfigApp->m_dxInfo;
assert(info);
info->FUN_1009d210();
m_modified = currentConfigApp->ReadRegisterSettings(); 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 driver_i = 0;
int device_i = 0; int device_i = 0;
int selected = 0; int selected = 0;
char device_name[256];
const list<MxDriver>& driver_list = enumerator->m_ddInfo; for (list<MxDriver>::iterator it_driver = info->m_ddInfo.begin(); it_driver != info->m_ddInfo.end();
for (list<MxDriver>::const_iterator it_driver = driver_list.begin(); it_driver != driver_list.end(); it_driver++) { it_driver++, driver_i++) {
const MxDriver& driver = *it_driver; const MxDriver& driver = *it_driver;
for (list<Direct3DDeviceInfo>::const_iterator it_device = driver.m_devices.begin(); for (list<Direct3DDeviceInfo>::const_iterator it_device = driver.m_devices.begin();
it_device != driver.m_devices.end(); it_device != driver.m_devices.end();
it_device++) { it_device++) {
const Direct3DDeviceInfo& device = *it_device;
if (&device == currentConfigApp->m_device) { if (&(*it_device) == currentConfigApp->m_d3dInfo) {
selected = device_i; 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; 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(); UpdateInterface();
return TRUE; return TRUE;
} }
// FUNCTION: CONFIG 0x00404080 // FUNCTION: CONFIG 0x00404080
// FUNCTION: CONFIGD 0x00408ab7
void CMainDialog::OnSysCommand(UINT nID, LPARAM lParam) void CMainDialog::OnSysCommand(UINT nID, LPARAM lParam)
{ {
if ((nID & 0xfff0) == 0x10) { if ((nID & 0xfff0) == 0x10) {
@@ -98,86 +112,109 @@ void CMainDialog::OnSysCommand(UINT nID, LPARAM lParam)
about_dialog.DoModal(); about_dialog.DoModal();
} }
else { else {
Default(); CWnd::OnSysCommand(nID, lParam);
} }
} }
// FUNCTION: CONFIG 0x00404150 // FUNCTION: CONFIG 0x00404150
// FUNCTION: CONFIGD 0x00408b49
void CMainDialog::OnPaint() void CMainDialog::OnPaint()
{ {
if (IsIconic()) { if (IsIconic()) {
CPaintDC painter(this); CPaintDC painter(this);
::SendMessage(m_hWnd, WM_ICONERASEBKGND, (WPARAM) painter.m_hDC, 0); CWnd::SendMessage(WM_ICONERASEBKGND, (WPARAM) painter.GetSafeHdc(), 0);
RECT dim;
int iconWidth = GetSystemMetrics(SM_CXICON);
int iconHeight = GetSystemMetrics(SM_CYICON);
CRect dim;
GetClientRect(&dim); GetClientRect(&dim);
DrawIcon(
painter.m_hDC, int x = (dim.Width() - iconWidth + 1) / 2;
(dim.right - dim.left - GetSystemMetrics(SM_CXICON) + 1) / 2, int y = (dim.Height() - iconHeight + 1) / 2;
(dim.bottom - dim.top - GetSystemMetrics(SM_CYICON) + 1) / 2,
m_icon painter.DrawIcon(x, y, m_icon);
);
} }
else { else {
Default(); CWnd::OnPaint();
} }
} }
// FUNCTION: CONFIG 0x00404230 // FUNCTION: CONFIG 0x00404230
// FUNCTION: CONFIGD 0x00408c61
HCURSOR CMainDialog::OnQueryDragIcon() HCURSOR CMainDialog::OnQueryDragIcon()
{ {
return m_icon; return m_icon;
} }
// FUNCTION: CONFIG 0x00404240 // FUNCTION: CONFIG 0x00404240
// FUNCTION: CONFIGD 0x00408c7d
void CMainDialog::OnList3DevicesSelectionChanged() void CMainDialog::OnList3DevicesSelectionChanged()
{ {
LegoDeviceEnumerate* device_enumerator = currentConfigApp->m_device_enumerator; CConfigApp* app = currentConfigApp;
int selected = ::SendMessage(GetDlgItem(IDC_LIST_3DDEVICES)->m_hWnd, LB_GETCURSEL, 0, 0); assert(app);
device_enumerator->GetDevice(selected, currentConfigApp->m_driver, currentConfigApp->m_device);
if (currentConfigApp->GetHardwareDeviceColorModel()) { LegoDeviceEnumerate* device_enumerator = app->m_dxInfo;
GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(TRUE); assert(device_enumerator);
}
else { 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_3d_video_ram = FALSE;
currentConfigApp->m_flip_surfaces = FALSE; currentConfigApp->m_flip_surfaces = FALSE;
CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram); CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram);
CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces); CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, currentConfigApp->m_flip_surfaces);
} }
else {
GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(TRUE);
}
m_modified = TRUE; m_modified = TRUE;
UpdateInterface(); UpdateInterface();
} }
// FUNCTION: CONFIG 0x00404320 // FUNCTION: CONFIG 0x00404320
// FUNCTION: CONFIGD 0x00408d79
void CMainDialog::OnCancel() void CMainDialog::OnCancel()
{ {
CDialog::OnCancel(); CDialog::OnCancel();
} }
// FUNCTION: CONFIG 0x00404330 // FUNCTION: CONFIG 0x00404330
// FUNCTION: CONFIGD 0x00408de5
void CMainDialog::OnDestroy() void CMainDialog::OnDestroy()
{ {
CDialog::Default(); CWnd::OnDestroy();
} }
// FUNCTION: CONFIG 0x00404340 // FUNCTION: CONFIG 0x00404340
// FUNCTION: CONFIGD 0x00408e03
void CMainDialog::OnButtonCancel() void CMainDialog::OnButtonCancel()
{ {
if (m_modified) { if (m_modified) {
currentConfigApp->WriteRegisterSettings(); currentConfigApp->WriteRegisterSettings();
} }
OnCancel(); CDialog::OnCancel();
} }
// FUNCTION: CONFIG 0x00404360 // FUNCTION: CONFIG 0x00404360
// FUNCTION: CONFIGD 0x00408e2f
void CMainDialog::UpdateInterface() void CMainDialog::UpdateInterface()
{ {
currentConfigApp->ValidateSettings(); currentConfigApp->ValidateSettings();
GetDlgItem(IDC_CHK_3D_VIDEO_MEMORY) BOOL flip_surfaces = currentConfigApp->m_flip_surfaces;
->EnableWindow(!currentConfigApp->m_flip_surfaces && !currentConfigApp->GetHardwareDeviceColorModel());
CheckDlgButton(IDC_CHK_FLIP_VIDEO_MEM_PAGES, 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); CheckDlgButton(IDC_CHK_3D_VIDEO_MEMORY, currentConfigApp->m_3d_video_ram);
BOOL full_screen = currentConfigApp->m_full_screen; BOOL full_screen = currentConfigApp->m_full_screen;
currentConfigApp->AdjustDisplayBitDepthBasedOnRenderStatus(); currentConfigApp->AdjustDisplayBitDepthBasedOnRenderStatus();
if (currentConfigApp->GetHardwareDeviceColorModel()) { if (currentConfigApp->GetHardwareDeviceColorModel()) {
CheckDlgButton(IDC_CHK_DRAW_CURSOR, TRUE); CheckDlgButton(IDC_CHK_DRAW_CURSOR, TRUE);
} }
@@ -186,24 +223,32 @@ void CMainDialog::UpdateInterface()
currentConfigApp->m_draw_cursor = FALSE; currentConfigApp->m_draw_cursor = FALSE;
GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(FALSE); GetDlgItem(IDC_CHK_DRAW_CURSOR)->EnableWindow(FALSE);
} }
if (full_screen) { if (full_screen) {
CheckRadioButton( if (currentConfigApp->m_display_bit_depth == 8) {
IDC_RAD_PALETTE_256, CheckRadioButton(IDC_RAD_PALETTE_256, IDC_RAD_PALETTE_16BIT, IDC_RAD_PALETTE_256);
IDC_RAD_PALETTE_16BIT, }
currentConfigApp->m_display_bit_depth == 8 ? IDC_RAD_PALETTE_256 : IDC_RAD_PALETTE_16BIT else {
); CheckRadioButton(IDC_RAD_PALETTE_256, IDC_RAD_PALETTE_16BIT, IDC_RAD_PALETTE_16BIT);
}
} }
else { else {
CheckDlgButton(IDC_RAD_PALETTE_256, 0); CheckDlgButton(IDC_RAD_PALETTE_256, 0);
CheckDlgButton(IDC_RAD_PALETTE_16BIT, 0); CheckDlgButton(IDC_RAD_PALETTE_16BIT, 0);
currentConfigApp->m_display_bit_depth = 0; currentConfigApp->m_display_bit_depth = 0;
} }
GetDlgItem(IDC_RAD_PALETTE_256)
->EnableWindow(full_screen && currentConfigApp->GetConditionalDeviceRenderBitDepth()); BOOL enable256 = full_screen && currentConfigApp->GetConditionalDeviceRenderBitDepth() != 0;
GetDlgItem(IDC_RAD_PALETTE_16BIT)->EnableWindow(full_screen && currentConfigApp->GetDeviceRenderBitStatus()); 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_3DSOUND, currentConfigApp->m_3d_sound);
CheckDlgButton(IDC_CHK_DRAW_CURSOR, currentConfigApp->m_draw_cursor); CheckDlgButton(IDC_CHK_DRAW_CURSOR, currentConfigApp->m_draw_cursor);
switch (currentConfigApp->m_model_quality) { switch (currentConfigApp->m_model_quality) {
// DECOMP: case 0 removed for retail.
case 1: case 1:
CheckRadioButton(IDC_RAD_MODEL_QUALITY_LOW, IDC_RAD_MODEL_QUALITY_HIGH, IDC_RAD_MODEL_QUALITY_LOW); CheckRadioButton(IDC_RAD_MODEL_QUALITY_LOW, IDC_RAD_MODEL_QUALITY_HIGH, IDC_RAD_MODEL_QUALITY_LOW);
break; break;
@@ -211,16 +256,29 @@ void CMainDialog::UpdateInterface()
CheckRadioButton(IDC_RAD_MODEL_QUALITY_LOW, IDC_RAD_MODEL_QUALITY_HIGH, IDC_RAD_MODEL_QUALITY_HIGH); CheckRadioButton(IDC_RAD_MODEL_QUALITY_LOW, IDC_RAD_MODEL_QUALITY_HIGH, IDC_RAD_MODEL_QUALITY_HIGH);
break; break;
} }
CheckRadioButton(
IDC_RAD_TEXTURE_QUALITY_LOW, if (currentConfigApp->m_texture_quality == 0) {
IDC_RAD_TEXTURE_QUALITY_HIGH, CheckRadioButton(IDC_RAD_TEXTURE_QUALITY_LOW, IDC_RAD_TEXTURE_QUALITY_HIGH, IDC_RAD_TEXTURE_QUALITY_LOW);
currentConfigApp->m_texture_quality == 0 ? IDC_RAD_TEXTURE_QUALITY_LOW : IDC_RAD_TEXTURE_QUALITY_HIGH }
); 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_JOYSTICK, currentConfigApp->m_use_joystick);
CheckDlgButton(IDC_CHK_MUSIC, currentConfigApp->m_music); 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: CONFIG 0x004045e0
// FUNCTION: CONFIGD 0x00409198
void CMainDialog::OnCheckbox3DSound() void CMainDialog::OnCheckbox3DSound()
{ {
currentConfigApp->m_3d_sound = IsDlgButtonChecked(IDC_CHK_3DSOUND); currentConfigApp->m_3d_sound = IsDlgButtonChecked(IDC_CHK_3DSOUND);
@@ -229,6 +287,7 @@ void CMainDialog::OnCheckbox3DSound()
} }
// FUNCTION: CONFIG 0x00404610 // FUNCTION: CONFIG 0x00404610
// FUNCTION: CONFIGD 0x004091de
void CMainDialog::OnCheckbox3DVideoMemory() void CMainDialog::OnCheckbox3DVideoMemory()
{ {
currentConfigApp->m_3d_video_ram = IsDlgButtonChecked(IDC_CHK_3D_VIDEO_MEMORY); currentConfigApp->m_3d_video_ram = IsDlgButtonChecked(IDC_CHK_3D_VIDEO_MEMORY);
@@ -237,6 +296,7 @@ void CMainDialog::OnCheckbox3DVideoMemory()
} }
// FUNCTION: CONFIG 0x00404640 // FUNCTION: CONFIG 0x00404640
// FUNCTION: CONFIGD 0x00409224
void CMainDialog::OnRadiobuttonPalette16bit() void CMainDialog::OnRadiobuttonPalette16bit()
{ {
currentConfigApp->m_display_bit_depth = 16; currentConfigApp->m_display_bit_depth = 16;
@@ -245,6 +305,7 @@ void CMainDialog::OnRadiobuttonPalette16bit()
} }
// FUNCTION: CONFIG 0x00404670 // FUNCTION: CONFIG 0x00404670
// FUNCTION: CONFIGD 0x00409261
void CMainDialog::OnRadiobuttonPalette256() void CMainDialog::OnRadiobuttonPalette256()
{ {
currentConfigApp->m_display_bit_depth = 8; currentConfigApp->m_display_bit_depth = 8;
@@ -253,6 +314,7 @@ void CMainDialog::OnRadiobuttonPalette256()
} }
// FUNCTION: CONFIG 0x004046a0 // FUNCTION: CONFIG 0x004046a0
// FUNCTION: CONFIGD 0x0040929e
void CMainDialog::OnCheckboxFlipVideoMemPages() void CMainDialog::OnCheckboxFlipVideoMemPages()
{ {
currentConfigApp->m_flip_surfaces = IsDlgButtonChecked(IDC_CHK_FLIP_VIDEO_MEM_PAGES); currentConfigApp->m_flip_surfaces = IsDlgButtonChecked(IDC_CHK_FLIP_VIDEO_MEM_PAGES);
@@ -260,7 +322,24 @@ void CMainDialog::OnCheckboxFlipVideoMemPages()
UpdateInterface(); 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: CONFIG 0x004046d0
// FUNCTION: CONFIGD 0x00409367
void CMainDialog::OnRadiobuttonModelLowQuality() void CMainDialog::OnRadiobuttonModelLowQuality()
{ {
currentConfigApp->m_model_quality = 1; currentConfigApp->m_model_quality = 1;
@@ -269,6 +348,7 @@ void CMainDialog::OnRadiobuttonModelLowQuality()
} }
// FUNCTION: CONFIG 0x00404700 // FUNCTION: CONFIG 0x00404700
// FUNCTION: CONFIGD 0x004093a4
void CMainDialog::OnRadiobuttonModelHighQuality() void CMainDialog::OnRadiobuttonModelHighQuality()
{ {
currentConfigApp->m_model_quality = 2; currentConfigApp->m_model_quality = 2;
@@ -277,6 +357,7 @@ void CMainDialog::OnRadiobuttonModelHighQuality()
} }
// FUNCTION: CONFIG 0x00404730 // FUNCTION: CONFIG 0x00404730
// FUNCTION: CONFIGD 0x004093e1
void CMainDialog::OnRadiobuttonTextureLowQuality() void CMainDialog::OnRadiobuttonTextureLowQuality()
{ {
currentConfigApp->m_texture_quality = 0; currentConfigApp->m_texture_quality = 0;
@@ -285,6 +366,7 @@ void CMainDialog::OnRadiobuttonTextureLowQuality()
} }
// FUNCTION: CONFIG 0x00404760 // FUNCTION: CONFIG 0x00404760
// FUNCTION: CONFIGD 0x0040941e
void CMainDialog::OnRadiobuttonTextureHighQuality() void CMainDialog::OnRadiobuttonTextureHighQuality()
{ {
currentConfigApp->m_texture_quality = 1; currentConfigApp->m_texture_quality = 1;
@@ -293,6 +375,7 @@ void CMainDialog::OnRadiobuttonTextureHighQuality()
} }
// FUNCTION: CONFIG 0x00404790 // FUNCTION: CONFIG 0x00404790
// FUNCTION: CONFIGD 0x0040945b
void CMainDialog::OnCheckboxJoystick() void CMainDialog::OnCheckboxJoystick()
{ {
currentConfigApp->m_use_joystick = IsDlgButtonChecked(IDC_CHK_JOYSTICK); currentConfigApp->m_use_joystick = IsDlgButtonChecked(IDC_CHK_JOYSTICK);
@@ -311,8 +394,8 @@ void CMainDialog::SwitchToAdvanced(BOOL p_advanced)
{ {
RECT dialog_rect; RECT dialog_rect;
RECT grp_advanced_rect; RECT grp_advanced_rect;
::GetWindowRect(m_hWnd, &dialog_rect); CWnd::GetWindowRect(&dialog_rect);
::GetWindowRect(GetDlgItem(IDC_GRP_ADVANCED)->m_hWnd, &grp_advanced_rect); GetDlgItem(IDC_GRP_ADVANCED)->GetWindowRect(&grp_advanced_rect);
CWnd* button_advanced = GetDlgItem(IDC_BTN_ADVANCED); CWnd* button_advanced = GetDlgItem(IDC_BTN_ADVANCED);
m_advanced = p_advanced; m_advanced = p_advanced;
int height; int height;

View File

@@ -7,6 +7,7 @@
#include "res/resource.h" #include "res/resource.h"
// VTABLE: CONFIG 0x004063e0 // VTABLE: CONFIG 0x004063e0
// VTABLE: CONFIGD 0x0040c500
// SIZE 0x70 // SIZE 0x70
class CMainDialog : public CDialog { class CMainDialog : public CDialog {
public: public:
@@ -35,11 +36,14 @@ protected:
void OnCancel(); void OnCancel();
void OnDestroy(); void OnDestroy();
void OnButtonCancel(); void OnButtonCancel();
void OnCheckboxWideAngle();
void OnCheckbox3DSound(); void OnCheckbox3DSound();
void OnCheckbox3DVideoMemory(); void OnCheckbox3DVideoMemory();
void OnRadiobuttonPalette16bit(); void OnRadiobuttonPalette16bit();
void OnRadiobuttonPalette256(); void OnRadiobuttonPalette256();
void OnCheckboxFlipVideoMemPages(); void OnCheckboxFlipVideoMemPages();
void OnCheckboxFullScreen();
void OnRadiobuttonModelLowestQuality();
void OnRadiobuttonModelLowQuality(); void OnRadiobuttonModelLowQuality();
void OnRadiobuttonModelHighQuality(); void OnRadiobuttonModelHighQuality();
void OnRadiobuttonTextureLowQuality(); void OnRadiobuttonTextureLowQuality();
@@ -52,19 +56,28 @@ protected:
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
}; };
// SYNTHETIC: CONFIG 0x00403160
// SYNTHETIC: CONFIGD 0x00408490
// CMainDialog::~CMainDialog
// SYNTHETIC: CONFIG 0x00403de0 // SYNTHETIC: CONFIG 0x00403de0
// SYNTHETIC: CONFIGD 0x00409910
// CMainDialog::`scalar deleting destructor' // CMainDialog::`scalar deleting destructor'
// FUNCTION: CONFIG 0x00403e60 // FUNCTION: CONFIG 0x00403e60
// FUNCTION: CONFIGD 0x004087a9
// CMainDialog::_GetBaseMessageMap // CMainDialog::_GetBaseMessageMap
// FUNCTION: CONFIG 0x00403e70 // FUNCTION: CONFIG 0x00403e70
// FUNCTION: CONFIGD 0x004087be
// CMainDialog::GetMessageMap // CMainDialog::GetMessageMap
// GLOBAL: CONFIG 0x00406120 // GLOBAL: CONFIG 0x00406120
// GLOBAL: CONFIGD 0x0040c1a8
// CMainDialog::messageMap // CMainDialog::messageMap
// GLOBAL: CONFIG 0x00406128 // GLOBAL: CONFIG 0x00406128
// GLOBAL: CONFIGD 0x0040c1b0
// CMainDialog::_messageEntries // CMainDialog::_messageEntries
#endif // !defined(AFX_MAINDLG_H) #endif // !defined(AFX_MAINDLG_H)

View File

@@ -55,14 +55,14 @@ BOOL CConfigApp::InitInstance()
m_run_config_dialog = TRUE; m_run_config_dialog = TRUE;
} }
m_device_enumerator = new LegoDeviceEnumerate; m_dxInfo = new LegoDeviceEnumerate;
if (m_device_enumerator->DoEnumerate()) { if (m_dxInfo->DoEnumerate()) {
assert("Could not build device list." == NULL); assert("Could not build device list." == NULL);
return FALSE; return FALSE;
} }
m_driver = NULL; m_ddInfo = NULL;
m_device = NULL; m_d3dInfo = NULL;
m_full_screen = TRUE; m_full_screen = TRUE;
m_wide_view_angle = TRUE; m_wide_view_angle = TRUE;
m_use_joystick = FALSE; m_use_joystick = FALSE;
@@ -99,10 +99,10 @@ BOOL CConfigApp::InitInstance()
ReadRegisterSettings(); ReadRegisterSettings();
ValidateSettings(); ValidateSettings();
WriteRegisterSettings(); WriteRegisterSettings();
delete m_device_enumerator; delete m_dxInfo;
m_device_enumerator = NULL; m_dxInfo = NULL;
m_driver = NULL; m_ddInfo = NULL;
m_device = NULL; m_d3dInfo = NULL;
char password[256]; char password[256];
BOOL read = ReadReg("password", password, sizeof(password)); BOOL read = ReadReg("password", password, sizeof(password));
const char* exe = _stricmp("ogel", password) == 0 ? "isled.exe" : "isle.exe"; const char* exe = _stricmp("ogel", password) == 0 ? "isled.exe" : "isle.exe";
@@ -226,26 +226,26 @@ BOOL CConfigApp::IsDeviceInBasicRGBMode() const
{ {
/* /*
* BUG: should be: * BUG: should be:
* return !GetHardwareDeviceColorModel() && (m_device->m_HELDesc.dcmColorModel & D3DCOLOR_RGB); * return !GetHardwareDeviceColorModel() && (m_d3dInfo->m_HELDesc.dcmColorModel & D3DCOLOR_RGB);
*/ */
assert(m_device); assert(m_d3dInfo);
return !GetHardwareDeviceColorModel() && m_device->m_HELDesc.dcmColorModel == D3DCOLOR_RGB; return !GetHardwareDeviceColorModel() && m_d3dInfo->m_HELDesc.dcmColorModel == D3DCOLOR_RGB;
} }
// FUNCTION: CONFIG 0x00403400 // FUNCTION: CONFIG 0x00403400
// FUNCTION: CONFIGD 0x004070fa // FUNCTION: CONFIGD 0x004070fa
D3DCOLORMODEL CConfigApp::GetHardwareDeviceColorModel() const D3DCOLORMODEL CConfigApp::GetHardwareDeviceColorModel() const
{ {
assert(m_device); assert(m_d3dInfo);
return m_device->m_HWDesc.dcmColorModel; return m_d3dInfo->m_HWDesc.dcmColorModel;
} }
// FUNCTION: CONFIG 0x00403410 // FUNCTION: CONFIG 0x00403410
// FUNCTION: CONFIGD 0x0040714e // FUNCTION: CONFIGD 0x0040714e
BOOL CConfigApp::IsPrimaryDriver() const BOOL CConfigApp::IsPrimaryDriver() const
{ {
assert(m_driver && m_device_enumerator); assert(m_ddInfo && m_dxInfo);
return m_driver == &m_device_enumerator->m_ddInfo.front(); return m_ddInfo == &m_dxInfo->m_ddInfo.front();
} }
// FUNCTION: CONFIG 0x00403430 // FUNCTION: CONFIG 0x00403430
@@ -259,9 +259,9 @@ BOOL CConfigApp::ReadRegisterSettings()
int r = -1; int r = -1;
if (read) { if (read) {
r = m_device_enumerator->ParseDeviceName(buffer); r = m_dxInfo->ParseDeviceName(buffer);
if (r >= 0) { if (r >= 0) {
r = m_device_enumerator->GetDevice(r, m_driver, m_device); r = m_dxInfo->GetDevice(r, m_ddInfo, m_d3dInfo);
if (r) { if (r) {
r = -1; r = -1;
} }
@@ -269,14 +269,14 @@ BOOL CConfigApp::ReadRegisterSettings()
} }
if (r < 0) { if (r < 0) {
m_device_enumerator->FUN_1009d210(); m_dxInfo->FUN_1009d210();
r = m_device_enumerator->GetBestDevice(); r = m_dxInfo->GetBestDevice();
is_modified = TRUE; is_modified = TRUE;
assert(r >= 0); 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)) { if (!ReadRegInt("Display Bit Depth", &m_display_bit_depth)) {
is_modified = TRUE; is_modified = TRUE;
@@ -384,26 +384,26 @@ BOOL CConfigApp::ValidateSettings()
// FUNCTION: CONFIGD 0x00407793 // FUNCTION: CONFIGD 0x00407793
DWORD CConfigApp::GetConditionalDeviceRenderBitDepth() const DWORD CConfigApp::GetConditionalDeviceRenderBitDepth() const
{ {
assert(m_device); assert(m_d3dInfo);
if (IsDeviceInBasicRGBMode()) { if (IsDeviceInBasicRGBMode()) {
return 0; return 0;
} }
if (GetHardwareDeviceColorModel()) { if (GetHardwareDeviceColorModel()) {
return 0; return 0;
} }
return m_device->m_HELDesc.dwDeviceRenderBitDepth & DDBD_8; return m_d3dInfo->m_HELDesc.dwDeviceRenderBitDepth & DDBD_8;
} }
// FUNCTION: CONFIG 0x004037e0 // FUNCTION: CONFIG 0x004037e0
// FUNCTION: CONFIGD 0x00407822 // FUNCTION: CONFIGD 0x00407822
DWORD CConfigApp::GetDeviceRenderBitStatus() const DWORD CConfigApp::GetDeviceRenderBitStatus() const
{ {
assert(m_device); assert(m_d3dInfo);
if (GetHardwareDeviceColorModel()) { if (GetHardwareDeviceColorModel()) {
return m_device->m_HWDesc.dwDeviceRenderBitDepth & DDBD_16; return m_d3dInfo->m_HWDesc.dwDeviceRenderBitDepth & DDBD_16;
} }
else { 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); \ WriteReg(NAME, buffer); \
} while (0) } while (0)
assert(m_device_enumerator && m_driver && m_device); assert(m_dxInfo && m_ddInfo && m_d3dInfo);
m_device_enumerator->FormatDeviceName(buffer, m_driver, m_device); m_dxInfo->FormatDeviceName(buffer, m_ddInfo, m_d3dInfo);
WriteReg("3D Device ID", buffer); 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); WriteRegInt("Display Bit Depth", m_display_bit_depth);
WriteRegBool("Flip Surfaces", m_flip_surfaces); WriteRegBool("Flip Surfaces", m_flip_surfaces);
WriteRegBool("Full Screen", m_full_screen); WriteRegBool("Full Screen", m_full_screen);
@@ -472,9 +472,9 @@ void CConfigApp::WriteRegisterSettings() const
// FUNCTION: CONFIGD 0x00407c44 // FUNCTION: CONFIGD 0x00407c44
int CConfigApp::ExitInstance() int CConfigApp::ExitInstance()
{ {
if (m_device_enumerator) { if (m_dxInfo) {
delete m_device_enumerator; delete m_dxInfo;
m_device_enumerator = NULL; m_dxInfo = NULL;
} }
return CWinApp::ExitInstance(); return CWinApp::ExitInstance();
} }

View File

@@ -11,7 +11,7 @@ class LegoDeviceEnumerate;
struct Direct3DDeviceInfo; struct Direct3DDeviceInfo;
struct MxDriver; struct MxDriver;
#define currentConfigApp ((CConfigApp*) afxCurrentWinApp) #define currentConfigApp ((CConfigApp*) AfxGetApp())
// VTABLE: CONFIG 0x00406040 // VTABLE: CONFIG 0x00406040
// VTABLE: CONFIGD 0x0040c0a0 // VTABLE: CONFIGD 0x0040c0a0
@@ -55,23 +55,23 @@ private:
BOOL IsLegoNotRunning(); BOOL IsLegoNotRunning();
public: public:
LegoDeviceEnumerate* m_device_enumerator; // 0x0c4 LegoDeviceEnumerate* m_dxInfo; // 0x0c4
MxDriver* m_driver; // 0x0c8 MxDriver* m_ddInfo; // 0x0c8
Direct3DDeviceInfo* m_device; // 0x0cc Direct3DDeviceInfo* m_d3dInfo; // 0x0cc
int m_display_bit_depth; // 0x0d0 int m_display_bit_depth; // 0x0d0
BOOL m_flip_surfaces; // 0x0d4 BOOL m_flip_surfaces; // 0x0d4
BOOL m_full_screen; // 0x0d8 BOOL m_full_screen; // 0x0d8
BOOL m_3d_video_ram; // 0x0dc BOOL m_3d_video_ram; // 0x0dc
BOOL m_wide_view_angle; // 0x0e0 BOOL m_wide_view_angle; // 0x0e0
BOOL m_3d_sound; // 0x0e4 BOOL m_3d_sound; // 0x0e4
BOOL m_draw_cursor; // 0x0e8 BOOL m_draw_cursor; // 0x0e8
BOOL m_use_joystick; // 0x0ec BOOL m_use_joystick; // 0x0ec
int m_joystick_index; // 0x0f0 int m_joystick_index; // 0x0f0
BOOL m_run_config_dialog; // 0x0f4 BOOL m_run_config_dialog; // 0x0f4
int m_model_quality; // 0x0f8 int m_model_quality; // 0x0f8
int m_texture_quality; // 0x0fc int m_texture_quality; // 0x0fc
undefined m_unk0x100[4]; // 0x100 undefined m_unk0x100[4]; // 0x100
BOOL m_music; // 0x104 BOOL m_music; // 0x104
}; };
// SYNTHETIC: CONFIG 0x00402cd0 // SYNTHETIC: CONFIG 0x00402cd0

View File

@@ -3,140 +3,255 @@
#include <ddraw.h> #include <ddraw.h>
#include <dinput.h> #include <dinput.h>
typedef HRESULT WINAPI DirectDrawCreate_fn(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter); typedef HRESULT(WINAPI* DIRECTDRAWCREATE)(GUID*, LPDIRECTDRAW*, IUnknown*);
typedef HRESULT WINAPI typedef HRESULT(WINAPI* DIRECTINPUTCREATE)(HINSTANCE, DWORD, LPDIRECTINPUT*, IUnknown*);
DirectInputCreateA_fn(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter);
// FUNCTION: CONFIG 0x004048f0 // FUNCTION: CONFIG 0x004048f0
BOOL DetectDirectX5() BOOL DetectDirectX5()
{ {
unsigned int version; DWORD version;
BOOL found; DWORD platform;
DetectDirectX(&version, &found); GetDXVersion(&version, &platform);
return version >= 0x500; return version >= 0x500;
} }
// FUNCTION: CONFIG 0x00404920 // 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)) { * First get the windows platform
*p_version = 0; */
*p_found = 0; osVer.dwOSVersionInfoSize = sizeof(osVer);
if (!GetVersionEx(&osVer)) {
*pdwDXVersion = 0;
*pdwDXPlatform = 0;
return; return;
} }
if (os_version.dwPlatformId == 2) {
*p_found = 2; if (osVer.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if (os_version.dwMajorVersion < 4) { *pdwDXPlatform = VER_PLATFORM_WIN32_NT;
*p_found = 0; /*
* 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; return;
} }
if (os_version.dwMajorVersion != 4) { if (osVer.dwMajorVersion == 4) {
*p_version = 0x501; /*
* 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; return;
} }
*p_version = 0x200; /*
HMODULE dinput_module = LoadLibrary("DINPUT.DLL"); * Else it's NT5 or higher, and it's DX5a or higher:
if (!dinput_module) { */
OutputDebugString("Couldn't LoadLibrary DInput\r\n"); *pdwDXVersion = 0x501; // DX5a on NT5
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;
return; 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; return;
} }
HMODULE ddraw_module = LoadLibrary("DDRAW.DLL");
if (!ddraw_module) { /*
*p_version = 0; * Now we know we are in Windows 9x (or maybe 3.1), so anything's possible.
*p_found = 0; * First see if DDRAW.DLL even exists.
FreeLibrary(ddraw_module); */
DDHinst = LoadLibrary("DDRAW.DLL");
if (DDHinst == 0) {
*pdwDXVersion = 0;
*pdwDXPlatform = 0;
FreeLibrary(DDHinst);
return; return;
} }
DirectDrawCreate_fn* func_DirectDrawCreate =
(DirectDrawCreate_fn*) GetProcAddress(ddraw_module, "DirectDrawCreate"); /*
if (!func_DirectDrawCreate) { * See if we can create the DirectDraw object.
*p_version = 0; */
*p_found = 0; DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(DDHinst, "DirectDrawCreate");
FreeLibrary(ddraw_module); if (DirectDrawCreate == 0) {
*pdwDXVersion = 0;
*pdwDXPlatform = 0;
FreeLibrary(DDHinst);
OutputDebugString("Couldn't LoadLibrary DDraw\r\n"); OutputDebugString("Couldn't LoadLibrary DDraw\r\n");
return; return;
} }
LPDIRECTDRAW ddraw;
if (FAILED(func_DirectDrawCreate(NULL, &ddraw, NULL))) { hr = DirectDrawCreate(NULL, &pDDraw, NULL);
*p_version = 0; if (FAILED(hr)) {
*p_found = 0; *pdwDXVersion = 0;
FreeLibrary(ddraw_module); *pdwDXPlatform = 0;
FreeLibrary(DDHinst);
OutputDebugString("Couldn't create DDraw\r\n"); OutputDebugString("Couldn't create DDraw\r\n");
return; return;
} }
*p_version = 0x100;
LPDIRECTDRAW2 ddraw2; /*
if (FAILED(ddraw->QueryInterface(IID_IDirectDraw2, (LPVOID*) &ddraw2))) { * So DirectDraw exists. We are at least DX1.
ddraw->Release(); */
FreeLibrary(ddraw_module); *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"); OutputDebugString("Couldn't QI DDraw2\r\n");
return; return;
} }
ddraw->Release(); /*
*p_version = 0x200; * IDirectDraw2 exists. We must be at least DX2
HMODULE dinput_module = LoadLibrary("DINPUT.DLL"); */
if (!dinput_module) { 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"); OutputDebugString("Couldn't LoadLibrary DInput\r\n");
ddraw2->Release(); pDDraw->Release();
FreeLibrary(ddraw_module); FreeLibrary(DDHinst);
return; return;
} }
DirectInputCreateA_fn* func_DirectInputCreateA =
(DirectInputCreateA_fn*) GetProcAddress(dinput_module, "DirectInputCreateA"); DirectInputCreate = (DIRECTINPUTCREATE) GetProcAddress(DIHinst, "DirectInputCreateA");
FreeLibrary(dinput_module); FreeLibrary(DIHinst);
if (!func_DirectInputCreateA) {
FreeLibrary(ddraw_module); if (DirectInputCreate == 0) {
ddraw2->Release(); /*
* No DInput... must be DX2
*/
FreeLibrary(DDHinst);
pDDraw->Release();
OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n"); OutputDebugString("Couldn't GetProcAddress DInputCreate\r\n");
return; return;
} }
*p_version = 0x300;
DDSURFACEDESC surface_desc; /*
memset(&surface_desc, 0, sizeof(surface_desc)); * DirectInputCreate exists. That's enough to tell us that we are at least DX3
surface_desc.dwSize = sizeof(surface_desc); */
surface_desc.dwFlags = DDSD_CAPS; *pdwDXVersion = 0x300;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(ddraw2->SetCooperativeLevel(NULL, DDSCL_NORMAL))) { /*
ddraw2->Release(); * Checks for 3a vs 3b?
FreeLibrary(ddraw_module); */
*p_version = 0;
/*
* 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"); OutputDebugString("Couldn't Set coop level\r\n");
return; return;
} }
LPDIRECTDRAWSURFACE surface;
if (FAILED(ddraw2->CreateSurface(&surface_desc, &surface, NULL))) { hr = pDDraw->CreateSurface(&desc, &pSurf, NULL);
ddraw2->Release(); if (FAILED(hr)) {
FreeLibrary(ddraw_module); /*
*p_version = 0; * Failure. This means DDraw isn't properly installed.
*/
pDDraw->Release();
FreeLibrary(DDHinst);
*pdwDXVersion = 0;
OutputDebugString("Couldn't CreateSurface\r\n"); OutputDebugString("Couldn't CreateSurface\r\n");
return; return;
} }
LPDIRECTDRAWSURFACE3 surface3;
if (FAILED(surface->QueryInterface(IID_IDirectDrawSurface3, (LPVOID*) &surface3))) { /*
ddraw2->Release(); * Try for the IDirectDrawSurface3 interface. If it works, we're on DX5 at least
FreeLibrary(ddraw_module); */
if (FAILED(pSurf->QueryInterface(IID_IDirectDrawSurface3, (LPVOID*) &pSurf3))) {
pDDraw->Release();
FreeLibrary(DDHinst);
return; return;
} }
*p_version = 0x500;
surface3->Release(); /*
ddraw2->Release(); * QI for IDirectDrawSurface3 succeeded. We must be at least DX5
FreeLibrary(ddraw_module); */
*pdwDXVersion = 0x500;
pSurf->Release();
pDDraw->Release();
FreeLibrary(DDHinst);
return;
} }

View File

@@ -5,6 +5,6 @@
extern BOOL DetectDirectX5(); 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) #endif // !defined(AFX_DETECTDX5_H)

View File

@@ -7,10 +7,12 @@
#define IDC_LIST_3DDEVICES 1000 #define IDC_LIST_3DDEVICES 1000
#define IDC_CHK_FLIP_VIDEO_MEM_PAGES 1001 #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_CHK_3D_VIDEO_MEMORY 1003
#define IDC_RAD_PALETTE_256 1004 #define IDC_RAD_PALETTE_256 1004
#define IDC_RAD_PALETTE_16BIT 1005 #define IDC_RAD_PALETTE_16BIT 1005
#define IDC_CHK_3DSOUND 1006 #define IDC_CHK_3DSOUND 1006
#define IDC_CHK_WIDE_ANGLE 1007 // beta only
#define IDC_CHK_DRAW_CURSOR 1008 #define IDC_CHK_DRAW_CURSOR 1008
#define IDC_RAD_MODEL_QUALITY_LOW 1010 #define IDC_RAD_MODEL_QUALITY_LOW 1010
#define IDC_RAD_MODEL_QUALITY_HIGH 1011 #define IDC_RAD_MODEL_QUALITY_HIGH 1011