else if (Chipset == CHIP_S3_SavageMX_MV || Chipset == CHIP_S3_SavageMX || Chipset == CHIP_S3_SavageIX_MV || Chipset == CHIP_S3_SavageIX) { int memsize[] = { 2, 8, 4, 16, 8, 16, 4, 16 }; int sel = (config & 0x0E) >> 1; Mem = memsize[sel] * 1024; } else if (Chipset == CHIP_S3_SavageNB) { int memsize[] = { 0, 2, 4, 8, 16, 32, 2, 2 }; int sel = (config & 0xE0) >> 5; Mem = memsize[sel] * 1024; }
static int MemProbe_S3(Chipset)int Chipset;{	Byte config, old, config2;	int Mem = 0, MemOffScreen = 0;	EnableIOPorts(NUMPORTS, Ports);	old = rdinx(CRTC_IDX, 0x38);	wrinx(CRTC_IDX, 0x38, 0x00);	if (!testinx2(CRTC_IDX, 0x35, 0x0F))	{		wrinx(CRTC_IDX, 0x38, 0x48);		if (testinx2(CRTC_IDX, 0x35, 0x0F))		{			config = rdinx(CRTC_IDX, 0x36);			config2 = rdinx(CRTC_IDX, 0x37);			if ((Chipset == CHIP_S3_911) || 			    (Chipset == CHIP_S3_924))			{			   if ((config & 0x20) != 0)			      Mem = 512;			   else			      Mem = 1024;			}			else if (Chipset == CHIP_S3_ViRGE)			{			   switch((config & 0xE0) >> 5)			   {			   case 0:			      Mem = 4 * 1024;			      break;			   case 4:			      Mem = 2 * 1024;			      break;			   case 6:			      Mem = 1 * 1024;			      break;			   }			}			else if (Chipset == CHIP_S3_ViRGE_GX2 ||				 Chipset == CHIP_S3_ViRGE_MX  ||				 Chipset == CHIP_S3_ViRGE_MXP)			{			   switch((config & 0xC0) >> 6)			   {			   case 1:			      Mem = 4 * 1024;			      break;			   case 3:			      Mem = 2 * 1024;			      break;			   }			}			else if (Chipset == CHIP_S3_Trio3D)			{			   switch((config & 0xE0) >> 5)			   {			   case 0:			   case 2:			      Mem = 4 * 1024;			      break;			   case 4:			      Mem = 2 * 1024;			      break;			   }			}			else if (Chipset == CHIP_S3_Trio3D_2X)			{			   switch((config & 0xE0) >> 5)			   {			   case 0:			      Mem = 8 * 1024;			      break;			   case 1:  /* 32 bit interface -- yuck */			   case 2:			      Mem = 4 * 1024;			      break;			   case 6:			      Mem = 2 * 1024;			      break;			   }			}			else if (Chipset == CHIP_S3_Savage3D || Chipset == CHIP_S3_Savage3D_M)			{  			  int memsize[] = { 8, 4, 4, 2};			  int sel = (config & 0xC0) >> 6;			  Mem = memsize[sel] * 1024;			}			else if (Chipset == CHIP_S3_Savage4)			{  			  int memsize[] = { 2, 4, 8, 12, 16, 32, 0, 32 };			  int sel = (config & 0xE0) >> 5;			  Mem = memsize[sel] * 1024;			}			else if (Chipset == CHIP_S3_Savage2000)			{  			  int memsize[] = { 2, 4, 8, 12, 16, 32, 64, 32 };			  int sel = (config & 0xE0) >> 5;			  Mem = memsize[sel] * 1024;			}			else if (Chipset == CHIP_S3_ViRGE_VX)			{			   switch((config2 & 0x60) >> 5)			   {			   case 1:			      MemOffScreen = 4 * 1024;			      break;			   case 2:			      MemOffScreen = 2 * 1024;			      break;			   }			   switch((config & 0x60) >> 5)			   {			   case 0:			      Mem = 2 * 1024;			      break;			   case 1:			      Mem = 4 * 1024;			      break;			   case 2:			      Mem = 6 * 1024;			      break;			   case 3:			      Mem = 8 * 1024;			      break;			   }			   Mem -= MemOffScreen;			}			else 			{				switch((config & 0xE0) >> 5)				{				case 0:					Mem = 4 * 1024;					break;				case 2:					Mem = 3 * 1024;					break;				case 3:					Mem = 8 * 1024;					break;				case 4:					Mem = 2 * 1024;					break;				case 5:					Mem = 6 * 1024;					break;				case 6:					Mem = 1 * 1024;					break;				}			}		}	}	wrinx(CRTC_IDX, 0x38, old);	DisableIOPorts(NUMPORTS, Ports);	return((MemOffScreen << 16) | Mem);}