src/video/photon/SDL_ph_modes.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 11 Mar 2002 17:38:56 +0000
changeset 309 2de77f7b7a28
parent 297 f6ffac90895c
child 315 3333b6e68289
permissions -rw-r--r--
*** empty log message ***
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@297
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
#include "SDL_ph_modes_c.h"
slouken@0
    29
slouken@0
    30
static unsigned long key1, key2;
slouken@0
    31
static PgVideoModeInfo_t mode_info;
slouken@0
    32
static PgVideoModes_t mode_list;
slouken@266
    33
slouken@0
    34
  /* The current list of available video modes */
slouken@266
    35
SDL_Rect  SDL_modelist[PH_MAX_VIDEOMODES];
slouken@266
    36
SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
slouken@0
    37
slouken@0
    38
static int compare_modes_by_res(const void* mode1, const void* mode2)
slouken@0
    39
{
slouken@0
    40
slouken@0
    41
	if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
slouken@0
    42
	{
slouken@0
    43
	    fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    44
        	    *(unsigned short*)mode1);
slouken@266
    45
    	    return 0;
slouken@0
    46
	}
slouken@0
    47
	key1 = mode_info.width * mode_info.height;
slouken@0
    48
slouken@0
    49
	if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
slouken@0
    50
	{
slouken@266
    51
    	    fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    52
	            *(unsigned short*)mode2);
slouken@0
    53
	    return 0;
slouken@0
    54
	}
slouken@266
    55
        key2 = mode_info.width * mode_info.height;
slouken@0
    56
slouken@0
    57
	if (key1 > key2)
slouken@0
    58
		return 1;
slouken@0
    59
	else if (key1 == key2)
slouken@0
    60
		return 0;
slouken@0
    61
	else
slouken@0
    62
		return -1;
slouken@0
    63
}
slouken@0
    64
slouken@266
    65
/*
slouken@0
    66
static int compare_modes_by_bpp(const void* mode1, const void* mode2)
slouken@0
    67
{
slouken@0
    68
slouken@0
    69
    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
slouken@0
    70
    {
slouken@0
    71
        fprintf(stderr,"error: In compare_modes_by_bpp PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    72
                *(unsigned short*)mode1);
slouken@0
    73
        return 0;
slouken@0
    74
    }
slouken@0
    75
    key1 = mode_info.bits_per_pixel;
slouken@0
    76
slouken@0
    77
    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
slouken@0
    78
    {
slouken@0
    79
        fprintf(stderr,"error: In compare_modes_by_bpp PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    80
                *(unsigned short*)mode2);
slouken@0
    81
        return 0;
slouken@0
    82
    }
slouken@0
    83
    key2 = mode_info.bits_per_pixel;
slouken@0
    84
slouken@0
    85
    if (key1 > key2)
slouken@0
    86
        return 1;
slouken@0
    87
    else if (key1 == key2)
slouken@0
    88
        return 0;
slouken@0
    89
    else
slouken@0
    90
        return -1;
slouken@0
    91
}
slouken@266
    92
*/
slouken@0
    93
slouken@266
    94
/*
slouken@0
    95
int ph_GetVideoModes(_THIS)
slouken@0
    96
{
slouken@0
    97
	unsigned short *front;
slouken@0
    98
	int i, bpp_group_size;
slouken@0
    99
slouken@0
   100
	// TODO: add mode_list member to _THIS
slouken@0
   101
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   102
	{
slouken@0
   103
		fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   104
		return -1;
slouken@0
   105
	}
slouken@0
   106
	
slouken@0
   107
	// sort list first by bits per pixel (bpp), 
slouken@0
   108
	// then sort groups with same bpp by resolution.
slouken@0
   109
	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_bpp);
slouken@0
   110
	bpp_group_size = 1;
slouken@0
   111
	front = &mode_list.modes[0];
slouken@0
   112
	for(i=0;i<mode_list.num_modes-2;i++)
slouken@0
   113
	{
slouken@0
   114
		if (compare_modes_by_bpp(&mode_list.modes[i],&mode_list.modes[i+1]))
slouken@0
   115
		{
slouken@0
   116
			qsort(front, bpp_group_size, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   117
			front = &mode_list.modes[i+1];
slouken@0
   118
			bpp_group_size = 1;
slouken@0
   119
		}
slouken@0
   120
		else
slouken@0
   121
		{
slouken@0
   122
			bpp_group_size++;
slouken@0
   123
		}
slouken@0
   124
	}
slouken@0
   125
slouken@0
   126
	//SDL_modelist = (SDL_Rect **)malloc((mode_list.num_modes+1)*sizeof(SDL_Rect *));
slouken@0
   127
	if ( SDL_modelist ) {
slouken@0
   128
		for (i=0;i<mode_list.num_modes;i++) {
slouken@0
   129
        //	SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
slouken@0
   130
	     //   if ( SDL_modelist[i] == NULL ) {
slouken@0
   131
    	  //      break;
slouken@0
   132
	     //   }
slouken@0
   133
		    if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   134
		    {
slouken@0
   135
        		fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
   136
                		mode_list.modes[i]);
slouken@0
   137
		        return -1;
slouken@0
   138
    		}
slouken@0
   139
    	    SDL_modelist[i].x = 0;
slouken@0
   140
	        SDL_modelist[i].y = 0;
slouken@0
   141
    	    SDL_modelist[i].w = mode_info.height;
slouken@0
   142
        	SDL_modelist[i].h = mode_info.width;
slouken@0
   143
	    }
slouken@0
   144
    	//SDL_modelist[i] = NULL;
slouken@0
   145
	}
slouken@0
   146
	else
slouken@0
   147
	{
slouken@0
   148
		fprintf(stderr,"error: malloc failed on SDL_modelist\n");
slouken@0
   149
		return -1;
slouken@0
   150
	}
slouken@0
   151
	
slouken@0
   152
	return 0;
slouken@0
   153
}
slouken@266
   154
*/
slouken@0
   155
slouken@266
   156
SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
slouken@0
   157
{
slouken@309
   158
    int i = 0;
slouken@309
   159
    int j = 0;
slouken@309
   160
    SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
slouken@0
   161
slouken@309
   162
    for (i=0; i<PH_MAX_VIDEOMODES; i++)
slouken@309
   163
    {
slouken@309
   164
        SDL_modearray[i]=&SDL_modelist[i];
slouken@309
   165
    }
slouken@309
   166
slouken@309
   167
    if (PgGetVideoModeList( &mode_list ) < 0)
slouken@309
   168
    {
slouken@309
   169
       fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@309
   170
       return NULL;
slouken@309
   171
    }
slouken@309
   172
slouken@309
   173
    mode_info.bits_per_pixel = 0;
slouken@309
   174
slouken@309
   175
    for (i=0; i < mode_list.num_modes; i++) 
slouken@309
   176
    {
slouken@309
   177
        if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@266
   178
        {
slouken@309
   179
            fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n", mode_list.modes[i]);
slouken@309
   180
            return NULL;
slouken@266
   181
        }
slouken@309
   182
        if(mode_info.bits_per_pixel == format->BitsPerPixel)
slouken@309
   183
        {
slouken@309
   184
            Amodelist[j].w = mode_info.width;
slouken@309
   185
            Amodelist[j].h = mode_info.height;
slouken@309
   186
            Amodelist[j].x = 0;
slouken@309
   187
            Amodelist[j].y = 0;
slouken@309
   188
            j++;	
slouken@309
   189
        }
slouken@309
   190
    }
slouken@309
   191
	
slouken@309
   192
    /* reorder biggest for smallest, assume width dominates */
slouken@0
   193
slouken@309
   194
    for(i=0; i<j; i++)
slouken@309
   195
    {
slouken@309
   196
        SDL_modelist[i].w = Amodelist[j - i -1].w;
slouken@309
   197
        SDL_modelist[i].h = Amodelist[j - i -1].h;
slouken@309
   198
        SDL_modelist[i].x = Amodelist[j - i -1].x;
slouken@309
   199
        SDL_modelist[i].y = Amodelist[j - i -1].y;
slouken@309
   200
    }
slouken@309
   201
    SDL_modearray[j]=NULL;
slouken@0
   202
	
slouken@309
   203
    return SDL_modearray;
slouken@0
   204
}
slouken@0
   205
slouken@0
   206
void ph_FreeVideoModes(_THIS)
slouken@0
   207
{
slouken@266
   208
   return;
slouken@0
   209
}
slouken@0
   210
slouken@0
   211
static void set_best_resolution(_THIS, int width, int height)
slouken@0
   212
{
slouken@0
   213
slouken@0
   214
    if ( use_vidmode ) {
slouken@0
   215
		PgDisplaySettings_t 	settings;
slouken@0
   216
		PgVideoModeInfo_t		current_mode_info;
slouken@204
   217
		PgHWCaps_t my_hwcaps;
slouken@0
   218
		unsigned short			current_bpp;
slouken@0
   219
        int i;
slouken@204
   220
	/*
slouken@0
   221
		if (PgGetVideoMode( &settings ) < 0)
slouken@0
   222
		{
slouken@0
   223
			fprintf(stderr,"error: PgGetVideoMode failed\n");
slouken@0
   224
			return;
slouken@0
   225
		}
slouken@0
   226
		if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
slouken@0
   227
		{
slouken@0
   228
			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   229
			return;
slouken@0
   230
		}
slouken@204
   231
		*/
slouken@204
   232
		//lu_zero 
slouken@204
   233
         if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
slouken@204
   234
         	{
slouken@204
   235
                fprintf(stderr,"set_best_resolution:  GetGraphicsHWCaps failed!! \n");
slouken@204
   236
      			//that HAVE to work
slouken@204
   237
            }
slouken@204
   238
         if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
slouken@204
   239
            {
slouken@204
   240
                fprintf(stderr,"set_best_resolution:  PgGetVideoModeInfo failed\n");
slouken@204
   241
            }
slouken@0
   242
		current_bpp = current_mode_info.bits_per_pixel;
slouken@0
   243
slouken@0
   244
        if (PgGetVideoModeList(&mode_list) >= 0)
slouken@0
   245
		{
slouken@0
   246
			qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   247
#ifdef PH_DEBUG
slouken@0
   248
  			printf("Available modes:\n");
slouken@0
   249
  			for ( i = 0; i < mode_list.num_modes; ++i ) 
slouken@0
   250
			{
slouken@0
   251
				PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
slouken@0
   252
    			printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
slouken@0
   253
  			}
slouken@0
   254
#endif
slouken@0
   255
            for ( i = mode_list.num_modes-1; i >= 0 ; --i ) 
slouken@0
   256
			{
slouken@0
   257
				if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   258
				{
slouken@0
   259
					fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   260
				}
slouken@0
   261
                if ( (mode_info.width >= width) &&
slouken@0
   262
                     (mode_info.height >= height) &&
slouken@0
   263
					 (mode_info.bits_per_pixel == current_bpp) )
slouken@0
   264
                    break;
slouken@0
   265
            }
slouken@0
   266
			if (i >= 0)
slouken@0
   267
			{
slouken@0
   268
                if ( (mode_info.width != current_mode_info.width) ||
slouken@0
   269
                     (mode_info.height != current_mode_info.height) ) 
slouken@0
   270
				{
slouken@0
   271
					settings.mode = mode_list.modes[i];
slouken@0
   272
					if(PgSetVideoMode( &settings ) < 0)	
slouken@0
   273
					{
slouken@0
   274
						fprintf(stderr,"error: PgSetVideoMode failed\n");
slouken@0
   275
					}
slouken@0
   276
                }
slouken@0
   277
            }
slouken@0
   278
        }
slouken@0
   279
    }
slouken@0
   280
}
slouken@0
   281
slouken@0
   282
int ph_ResizeFullScreen(_THIS)
slouken@0
   283
{
slouken@309
   284
    if (currently_fullscreen) {
slouken@0
   285
        set_best_resolution(this, current_w, current_h);
slouken@0
   286
    }
slouken@309
   287
    return (1);
slouken@0
   288
}
slouken@0
   289
slouken@309
   290
/* return the mode associated with width, height and bpp */
slouken@309
   291
/* if there is no mode then zero is returned             */
slouken@0
   292
int get_mode(int width, int height, int bpp)
slouken@0
   293
{
slouken@309
   294
    int i;
slouken@0
   295
slouken@309
   296
    if(width<640)
slouken@309
   297
    {
slouken@309
   298
        width=640;
slouken@309
   299
    }
slouken@309
   300
    if(height<480)
slouken@309
   301
    {
slouken@309
   302
        height=480;
slouken@309
   303
    }
slouken@0
   304
slouken@309
   305
    if (PgGetVideoModeList(&mode_list) < 0)
slouken@309
   306
    {
slouken@309
   307
        fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@309
   308
        return -1;
slouken@309
   309
    }
slouken@0
   310
slouken@309
   311
    /* search list for exact match */
slouken@309
   312
    for (i=0;i<mode_list.num_modes;i++)
slouken@309
   313
    {
slouken@309
   314
        if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@309
   315
        {
slouken@309
   316
            fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@309
   317
            return 0;
slouken@309
   318
        }
slouken@0
   319
slouken@309
   320
        if ((mode_info.width == width) && 
slouken@309
   321
            (mode_info.height == height) && 
slouken@309
   322
            (mode_info.bits_per_pixel == bpp))
slouken@309
   323
        {
slouken@309
   324
            return mode_list.modes[i];
slouken@309
   325
        }
slouken@309
   326
    }
slouken@0
   327
slouken@309
   328
    return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
slouken@0
   329
}
slouken@0
   330
slouken@0
   331
int get_mode_any_format(int width, int height, int bpp)
slouken@0
   332
/* return the mode associated with width, height and bpp */
slouken@0
   333
/* if requested bpp is not found the mode with closest bpp is returned */
slouken@0
   334
{
slouken@0
   335
    int i, closest, delta, min_delta;
slouken@0
   336
slouken@0
   337
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   338
	{
slouken@0
   339
	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   340
	    return -1;
slouken@0
   341
	}
slouken@0
   342
slouken@0
   343
	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   344
	for(i=0;i<mode_list.num_modes;i++)
slouken@0
   345
	{
slouken@0
   346
       if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   347
       {
slouken@0
   348
           fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   349
           return 0;
slouken@0
   350
       }
slouken@0
   351
       if ((mode_info.width == width) &&
slouken@0
   352
           (mode_info.height == height))
slouken@0
   353
           break;
slouken@0
   354
	}
slouken@0
   355
	if (i<mode_list.num_modes)
slouken@0
   356
	{
slouken@0
   357
		// get closest bpp
slouken@0
   358
		closest = i++;
slouken@0
   359
		if (mode_info.bits_per_pixel == bpp)
slouken@0
   360
			return mode_list.modes[ closest ];
slouken@0
   361
slouken@0
   362
		min_delta = abs(mode_info.bits_per_pixel - bpp);
slouken@0
   363
		while(1)
slouken@0
   364
		{
slouken@0
   365
			if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   366
			{
slouken@0
   367
			    fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   368
			    return 0;
slouken@0
   369
			}
slouken@0
   370
slouken@0
   371
			if ((mode_info.width != width) ||
slouken@0
   372
				(mode_info.height != height))
slouken@0
   373
				break;
slouken@0
   374
			else if (mode_info.bits_per_pixel == bpp)
slouken@0
   375
			{
slouken@0
   376
				closest = i;
slouken@0
   377
				break;
slouken@0
   378
			}
slouken@0
   379
			else
slouken@0
   380
			{
slouken@0
   381
				delta = abs(mode_info.bits_per_pixel - bpp);
slouken@0
   382
				if (delta < min_delta)
slouken@0
   383
				{
slouken@0
   384
					closest = i;
slouken@0
   385
					min_delta = delta;
slouken@0
   386
				}
slouken@0
   387
				i++;
slouken@0
   388
			}
slouken@0
   389
		}
slouken@0
   390
		return mode_list.modes[ closest ];
slouken@0
   391
	}
slouken@0
   392
	else
slouken@309
   393
    return 0;
slouken@0
   394
}
slouken@0
   395
slouken@0
   396
void ph_WaitMapped(_THIS);
slouken@0
   397
void ph_WaitUnmapped(_THIS);
slouken@0
   398
void ph_QueueEnterFullScreen(_THIS);
slouken@0
   399
slouken@0
   400
int ph_ToggleFullScreen(_THIS, int on)
slouken@0
   401
{
slouken@309
   402
    if (currently_fullscreen)
slouken@309
   403
    {
slouken@309
   404
        return ph_LeaveFullScreen(this);
slouken@309
   405
    }
slouken@309
   406
    else
slouken@309
   407
    {
slouken@309
   408
        return ph_EnterFullScreen(this);
slouken@309
   409
    }
slouken@0
   410
      
slouken@309
   411
    return 0;     
slouken@0
   412
}
slouken@0
   413
slouken@0
   414
int ph_EnterFullScreen(_THIS)
slouken@0
   415
{
slouken@309
   416
    if (!currently_fullscreen)
slouken@309
   417
    {
slouken@309
   418
        if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)
slouken@309
   419
        {
slouken@309
   420
#ifdef HAVE_OPENGL
slouken@309
   421
#endif /* HAVE_OPENGL */
slouken@309
   422
           return 0;
slouken@309
   423
        }
slouken@309
   424
        else
slouken@309
   425
        {
slouken@309
   426
            if (old_video_mode==-1)
slouken@309
   427
            {
slouken@309
   428
                PgGetGraphicsHWCaps(&graphics_card_caps);
slouken@309
   429
                old_video_mode=graphics_card_caps.current_video_mode;
slouken@309
   430
                old_refresh_rate=graphics_card_caps.current_rrate;
slouken@309
   431
            }
slouken@0
   432
slouken@309
   433
            if(OCImage.direct_context == NULL)
slouken@309
   434
            {
slouken@309
   435
                OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
slouken@309
   436
            }
slouken@309
   437
            if(!OCImage.direct_context)
slouken@309
   438
            {
slouken@309
   439
                fprintf(stderr, "error: Can't create direct context\n" );
slouken@309
   440
            }
slouken@0
   441
slouken@309
   442
            PdDirectStart(OCImage.direct_context);
slouken@0
   443
slouken@309
   444
            currently_fullscreen = 1;
slouken@309
   445
        }
slouken@309
   446
    }
slouken@0
   447
slouken@309
   448
    return 1;
slouken@0
   449
}
slouken@0
   450
slouken@0
   451
int ph_LeaveFullScreen(_THIS )
slouken@0
   452
{
slouken@309
   453
    PgDisplaySettings_t mymode_settings;
slouken@0
   454
       
slouken@309
   455
    if (currently_fullscreen)
slouken@309
   456
    {
slouken@309
   457
        if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)
slouken@309
   458
        {
slouken@309
   459
#ifdef HAVE_OPENGL
slouken@309
   460
#endif /* HAVE_OPENGL */
slouken@309
   461
           return 0;
slouken@309
   462
        }
slouken@309
   463
        else
slouken@309
   464
        {
slouken@309
   465
            PdDirectStop(OCImage.direct_context);
slouken@309
   466
            PdReleaseDirectContext(OCImage.direct_context);
slouken@0
   467
slouken@309
   468
            /* Restore old video mode */
slouken@309
   469
            if (old_video_mode != -1)
slouken@309
   470
            {
slouken@309
   471
                mymode_settings.mode= (unsigned short) old_video_mode;
slouken@309
   472
                mymode_settings.refresh= (unsigned short) old_refresh_rate;
slouken@309
   473
                mymode_settings.flags = 0;
slouken@309
   474
                if (PgSetVideoMode(&mymode_settings) < 0)
slouken@309
   475
                {
slouken@309
   476
                    fprintf(stderr,"error: PgSetVideoMode failed\n");
slouken@309
   477
                }
slouken@309
   478
            }
slouken@309
   479
slouken@309
   480
            old_video_mode=-1;
slouken@309
   481
            old_refresh_rate=-1;	
slouken@309
   482
        }
slouken@309
   483
slouken@309
   484
    }
slouken@309
   485
    return 1;
slouken@0
   486
}