S3SAVGetBIOSModeTable( int iDepth, S3VMODETABLE* s3vModeTable )
S3SAVGetBIOSModeTable( int iDepth )
S3SAVGetBIOSModeTable( int iDepth, S3VMODETABLE* s3vModeTable ){    struct LRMI_regs r;    short int *mode_list;    unsigned short iModeCount = 0;    if( !vbe.initialized )	if (!LRMI_init())	    return 1;    vbe.initialized = 1;    vbe.info = LRMI_alloc_real(sizeof(struct vbe_info_block)     + sizeof(struct vbe_mode_info_block));    if (vbe.info == NULL)    {	ErrorF("Can't alloc real mode memory\n");	return 1;    }    vbe.mode = (struct vbe_mode_info_block *)(vbe.info + 1);    /* Allow access to bogus port 80h. */    ioperm( 0x80, 1, 1 );    /* Fetch VESA driver information. */    memset(&r, 0, sizeof(r));    r.eax = 0x4f00;    r.es = (unsigned int)vbe.info >> 4;    r.edi = 0;    memcpy(vbe.info->vbe_signature, "VBE2", 4);    if (!LRMI_int(0x10, &r))    {	ErrorF("Can't get VESA info (vm86 failure)\n");	ioperm( 0x80, 1, 0 );	return 1;    }    if ((r.eax & 0xffff) != 0x4f || 	strncmp(vbe.info->vbe_signature, "VESA", 4) != 0)    {	ErrorF("No VESA bios\n");	ioperm( 0x80, 1, 0 );	return 1;    }    if( !s3vModeTable )    {	ErrorF("%s %s: VBE Version %x.%x\n",	    XCONFIG_PROBED, vga256InfoRec.name,	    (int)(vbe.info->vbe_version >> 8) & 0xff,	    (int)vbe.info->vbe_version & 0xff);	ErrorF("%s %s: BIOS label is \"%s\"\n",	    XCONFIG_PROBED, vga256InfoRec.name,	    (char *)(vbe.info->oem_string_seg * 16 + vbe.info->oem_string_off));    }    mode_list = (short int *)	(vbe.info->video_mode_list_seg * 16 + vbe.info->video_mode_list_off);    while (*mode_list != -1)    {	memset(&r, 0, sizeof(r));	r.eax = 0x4f01;	r.ecx = *mode_list;	r.es = (unsigned int)vbe.mode >> 4;	r.edi = (unsigned int)vbe.mode & 0xf;	if (!LRMI_int(0x10, &r))	{	    ErrorF("Can't get mode info (vm86 failure)\n");	    ioperm( 0x80, 1, 0 );	    return 1;	}	if( 	   (vbe.mode->bits_per_pixel == iDepth) &&	   (	      (vbe.mode->memory_model == VBE_MODEL_256) ||	      (vbe.mode->memory_model == VBE_MODEL_PACKED) ||	      (vbe.mode->memory_model == VBE_MODEL_RGB)	   )	)	{	    /* This mode is a match. */	    iModeCount++;	    /* If we're supposed to fetch information, do it now. */	    if( s3vModeTable )	    {	        int iRefresh = 0;		s3vModeTable->Width = vbe.mode->x_resolution;		s3vModeTable->Height = vbe.mode->y_resolution;		s3vModeTable->VesaMode = *mode_list;				/* Query the refresh rates at this mode. */		r.ecx = *mode_list;		r.edx = 0;		do		{		    r.eax = 0x4f14;		    r.ebx = 0x0201;		/* query refresh rates */		    if( !LRMI_int(0x10, &r) )		    {			ErrorF( "Can't get refresh rate.\n");			ioperm( 0x80, 1, 0 );			return 0;		    }		    s3vModeTable->RefreshRate[iRefresh++] = r.edi;		}		while( r.edx );		s3vModeTable->RefreshCount = iRefresh;	    	s3vModeTable++;	    }	}	mode_list++;    }    ioperm( 0x80, 1, 0 );    LRMI_free_real(vbe.info);    return iModeCount;}