Exemplo n.º 1
0
void CDX8Disp::LoadSettings(char *reg_path, int flags)
{
   	if(m_dx8_initialised_ok == false)
	{
		return;
	}

	DWORD adapter, aatype;

	if(reg_get_dword(reg_path, "D3D8_Adapter", &adapter) == false)
	{
		UpdateAdapterList();
		return;
	}

	UpdateAdapterList(adapter);

	// Getting mode options is a bit more complicated
	char mode_string[1024];
	bool result = false;
	unsigned int width, height;
	int cdepth;

	char *reg_name = "Videocard";

	if(reg_get_sz(reg_path, reg_name, mode_string, 1024))
		if(sscanf(mode_string, "D3D8-(%dx%d)x%d bit", &width, &height, &cdepth)  == 3) 
			result = true;

	// No mode found, show user choice and return
	if(result == false)
	{
		UpdateResList();
		return;
	}

	// Show user choice and set if next setting is already set
	UpdateResList(width, height, cdepth);

	if(reg_get_dword(reg_path, "D3D8_AAType", &aatype) == false)
	{
		// No setting found, show user choice and return
		UpdateAntialiasList();
		return;
	}

	UpdateAntialiasList(aatype);
}
Exemplo n.º 2
0
void CDX8Disp::UpdateResList(
	unsigned int requested_width, unsigned int requested_height, int requested_cdepth)
{
	
	int selected_sel = -1;

 	m_res_list.ResetContent();
 	if(d3d_interface == NULL) return;

	int selected_adapter  = m_adapter_list.GetCurSel();
	int num_modes		  = d3d_interface->GetAdapterModeCount(selected_adapter);
//num_modes = 2;
	// Only list different resolutions and bit type NOT different refresh rates
	int index_count = 0;
	for(int i = num_modes - 1; i >= 0; i--)
	{
		D3DDISPLAYMODE mode;
		if(FAILED(d3d_interface->EnumAdapterModes(selected_adapter, i, &mode)))
		{
			MessageBox("Failed EnumAdapterModes", "Error", MB_ICONERROR);
			return;
		}

		bool non_standard_match = 
			(mode.Width == requested_width && 
			 mode.Height == requested_height &&
			d3d_get_mode_bit(mode.Format) == requested_cdepth);

		// ignore invalid modes unless we have an exact match (user picked non standard mode last time)
		if(m_allow_only_standard_modes && !non_standard_match)
		{
			// Just the standard modes
			if(/*	!(mode.Width == 1280 && mode.Height == 1024) &&*/
				!(mode.Width == 1024 && mode.Height == 768) &&
				!(mode.Width == 640 && mode.Height == 480))
			{
				DBUGFILE_OUTPUT_0("Chuck this mode its not standard");
				continue;
			}
		}
	/*	else
		{
			// Anything above the minimum
			if(	!(mode.Width == 640 && mode.Height == 480) &&
				(mode.Width < 800 || mode.Height < 600))
			{
				DBUGFILE_OUTPUT_0("Chuck this mode its too low");
		  		continue;
			}
		}*/

		// Lets look ahead and get the lowest refresh rate
		// Cant assume there will be at least 60 or 0
		while(i > 0)
		{
			D3DDISPLAYMODE next_mode;
			if(FAILED(d3d_interface->EnumAdapterModes(selected_adapter, i-1, &next_mode)))
			{
				MessageBox("Failed EnumAdapterModes", "Fatal Error", MB_ICONERROR);
				return;
			}

			// Modes are the same execpt refresh rate
			if( mode.Width == next_mode.Width && 
				mode.Height == next_mode.Height && 
				d3d_get_mode_bit(mode.Format) == d3d_get_mode_bit(next_mode.Format)) 
			{
				DBUGFILE_OUTPUT_2("Changing stored mode from %d to %d", i, i-1);
				i--;
			}
			else
			{
				DBUGFILE_OUTPUT_0("Not the same, next!");
				break;
			}
		}

		char mode_string[20];
		sprintf(mode_string, "%dx%dx%d", mode.Width, mode.Height, d3d_get_mode_bit(mode.Format));
		
		// stupid hack to get around 640x480 res getting displayed more then once
		if (m_res_list.FindString(1, mode_string) < 0) {
		
			int index = m_res_list.InsertString(index_count, mode_string);
			m_res_list.SetItemData(index, i);
			
			if( requested_width  == mode.Width &&
				requested_height == mode.Height &&
				requested_cdepth == d3d_get_mode_bit(mode.Format))

			{
	   			selected_sel = index_count;
			} 

			index_count++;
		}
	}

	if(selected_sel < 0) selected_sel = 0;

	m_res_list.SetCurSel(selected_sel);
 	UpdateAntialiasList();




}
Exemplo n.º 3
0
void CDX8Disp::OnSelchangeResList() 
{
	UpdateAntialiasList();
}
Exemplo n.º 4
0
void CDX8Disp::UpdateResList(
	unsigned int requested_width, unsigned int requested_height, int requested_cdepth)
{
	int selected_sel = -1;
	bool standard_match = TRUE;

 	m_res_list.ResetContent();

 	if (d3d_interface == NULL)
		return;

	requested_cdepth = GetCDepth(requested_cdepth);

	int selected_adapter  = m_adapter_list.GetCurSel();
	int num_modes		  = d3d_interface->GetAdapterModeCount(selected_adapter);

	int index = -1;
	char mode_string[20] = "";

	// Only list different resolutions and bit type NOT different refresh rates
	int index_count = 0;
	for(int i = 0; i < num_modes; i++)
	{
		D3DDISPLAYMODE mode;
		if(FAILED(d3d_interface->EnumAdapterModes(selected_adapter, i, &mode)))
		{
			MessageBox("Failed EnumAdapterModes", "Error", MB_ICONERROR);
			return;
		}

		if (d3d8_get_mode_bit(mode.Format) != requested_cdepth)
			continue;

		// skip anything below the minimum
		if(	!(mode.Width == 640 && mode.Height == 480) &&
			(mode.Width < 800 || mode.Height < 600))
		{
		  	continue;
		}

/*
		// Lets look ahead and get the lowest refresh rate
		// Can't assume there will be at least 60 or 0
		while(i > 0)
		{
			D3DDISPLAYMODE next_mode;
			if(FAILED(d3d_interface->EnumAdapterModes(selected_adapter, i-1, &next_mode)))
			{
				MessageBox("Failed EnumAdapterModes", "Fatal Error", MB_ICONERROR);
				return;
			}

			// Modes are the same execpt refresh rate
			if( mode.Width == next_mode.Width && 
				mode.Height == next_mode.Height && 
				d3d8_get_mode_bit(mode.Format) == d3d8_get_mode_bit(next_mode.Format)) 
			{
				DBUGFILE_OUTPUT_2("Changing stored mode from %d to %d", i, i-1);
				i--;
			}
			else
			{
				DBUGFILE_OUTPUT_0("Not the same, next!");
				break;
			}
		}
		*/
/*
		char new_string[20];
		sprintf(new_string, "%dx%dx%d", mode.Width, mode.Height, d3d8_get_mode_bit(mode.Format));
		
		if(stricmp(new_string, mode_string) == 0)
		{
			continue;
		}
		strcpy(mode_string,new_string); 
		*/

		// If not the first mode
		if(index > -1)
		{
			bool ignore_this_mode = false;
			int count_back = index;

			while(count_back > -1)
			{
				int back_mode_index = m_res_list.GetItemData(count_back);

				D3DDISPLAYMODE last_mode;
				if(FAILED(d3d_interface->EnumAdapterModes(selected_adapter, back_mode_index, &last_mode)))
				{
					MessageBox("Failed EnumAdapterModes", "Fatal Error", MB_ICONERROR);
					return;
				}

				// If we already have this mode ignore it
				if( mode.Width == last_mode.Width && 
					mode.Height == last_mode.Height && 
					d3d8_get_mode_bit(mode.Format) == d3d8_get_mode_bit(last_mode.Format))
				{
					ignore_this_mode = true;
					break;
				}

				count_back--;
			}

			if(ignore_this_mode)
			{
				continue;
			}
		}

		sprintf(mode_string, "%d x %d", mode.Width, mode.Height);
		index = m_res_list.InsertString(index_count, mode_string);
		m_res_list.SetItemData(index, i);

		if( requested_width  == mode.Width &&
			requested_height == mode.Height &&
			requested_cdepth == d3d8_get_mode_bit(mode.Format))

		{
	   		selected_sel = index_count;

			// identify whether this is one of the standard video modes or not
			standard_match = ((mode.Width == 1024 && mode.Height == 768) ||
									(mode.Width == 640 && mode.Height == 480));
		}
				
	//	char buffer[100];
	//	sprintf(buffer,"refresh %d", mode.RefreshRate);
	//	MessageBox(buffer, "DEBUG", MB_OK);

		index_count++;
	}

	if (selected_sel < 0)
		selected_sel = 0;

	// show or hide the non-standard video mode text if needed
	GetDlgItem(IDC_NSVM_TEXT)->ShowWindow( (standard_match) ? SW_HIDE : SW_SHOW );

	m_res_list.SetCurSel(selected_sel);
 	UpdateAntialiasList();
}