src/video/photon/SDL_ph_modes.c
author Sam Lantinga <slouken@lokigames.com>
Thu, 26 Apr 2001 16:45:43 +0000
changeset 0 74212992fb08
child 204 62bad9a82022
permissions -rw-r--r--
Initial revision
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@0
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  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@0
    20
    slouken@devolution.com
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
slouken@0
    29
#include "SDL_ph_modes_c.h"
slouken@0
    30
slouken@0
    31
static unsigned long key1, key2;
slouken@0
    32
static PgVideoModeInfo_t mode_info;
slouken@0
    33
static PgVideoModes_t mode_list;
slouken@0
    34
  /* The current list of available video modes */
slouken@0
    35
 SDL_Rect SDL_modelist[127];
slouken@0
    36
 SDL_Rect *SDLmod_ptr;
slouken@0
    37
 SDL_Rect **SDLmod_ptrptr ;
slouken@0
    38
slouken@0
    39
static int compare_modes_by_res(const void* mode1, const void* mode2)
slouken@0
    40
{
slouken@0
    41
slouken@0
    42
	if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
slouken@0
    43
	{
slouken@0
    44
	    fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    45
        	    *(unsigned short*)mode1);
slouken@0
    46
    	return 0;
slouken@0
    47
	}
slouken@0
    48
	key1 = mode_info.width * mode_info.height;
slouken@0
    49
slouken@0
    50
	if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
slouken@0
    51
	{
slouken@0
    52
    	fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    53
	            *(unsigned short*)mode2);
slouken@0
    54
	    return 0;
slouken@0
    55
	}
slouken@0
    56
    key2 = mode_info.width * mode_info.height;
slouken@0
    57
slouken@0
    58
	if (key1 > key2)
slouken@0
    59
		return 1;
slouken@0
    60
	else if (key1 == key2)
slouken@0
    61
		return 0;
slouken@0
    62
	else
slouken@0
    63
		return -1;
slouken@0
    64
}
slouken@0
    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@0
    92
slouken@0
    93
int ph_GetVideoModes(_THIS)
slouken@0
    94
{
slouken@0
    95
	unsigned short *front;
slouken@0
    96
	int i, bpp_group_size;
slouken@0
    97
slouken@0
    98
	// TODO: add mode_list member to _THIS
slouken@0
    99
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   100
	{
slouken@0
   101
		fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   102
		return -1;
slouken@0
   103
	}
slouken@0
   104
	
slouken@0
   105
	// sort list first by bits per pixel (bpp), 
slouken@0
   106
	// then sort groups with same bpp by resolution.
slouken@0
   107
	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_bpp);
slouken@0
   108
	bpp_group_size = 1;
slouken@0
   109
	front = &mode_list.modes[0];
slouken@0
   110
	for(i=0;i<mode_list.num_modes-2;i++)
slouken@0
   111
	{
slouken@0
   112
		if (compare_modes_by_bpp(&mode_list.modes[i],&mode_list.modes[i+1]))
slouken@0
   113
		{
slouken@0
   114
			qsort(front, bpp_group_size, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   115
			front = &mode_list.modes[i+1];
slouken@0
   116
			bpp_group_size = 1;
slouken@0
   117
		}
slouken@0
   118
		else
slouken@0
   119
		{
slouken@0
   120
			bpp_group_size++;
slouken@0
   121
		}
slouken@0
   122
	}
slouken@0
   123
slouken@0
   124
	//SDL_modelist = (SDL_Rect **)malloc((mode_list.num_modes+1)*sizeof(SDL_Rect *));
slouken@0
   125
	if ( SDL_modelist ) {
slouken@0
   126
		for (i=0;i<mode_list.num_modes;i++) {
slouken@0
   127
        //	SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
slouken@0
   128
	     //   if ( SDL_modelist[i] == NULL ) {
slouken@0
   129
    	  //      break;
slouken@0
   130
	     //   }
slouken@0
   131
		    if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   132
		    {
slouken@0
   133
        		fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
   134
                		mode_list.modes[i]);
slouken@0
   135
		        return -1;
slouken@0
   136
    		}
slouken@0
   137
    	    SDL_modelist[i].x = 0;
slouken@0
   138
	        SDL_modelist[i].y = 0;
slouken@0
   139
    	    SDL_modelist[i].w = mode_info.height;
slouken@0
   140
        	SDL_modelist[i].h = mode_info.width;
slouken@0
   141
	    }
slouken@0
   142
    	//SDL_modelist[i] = NULL;
slouken@0
   143
	}
slouken@0
   144
	else
slouken@0
   145
	{
slouken@0
   146
		fprintf(stderr,"error: malloc failed on SDL_modelist\n");
slouken@0
   147
		return -1;
slouken@0
   148
	}
slouken@0
   149
	
slouken@0
   150
	return 0;
slouken@0
   151
}
slouken@0
   152
slouken@0
   153
static SDL_Rect** ph_SupportedVisual( SDL_PixelFormat *format)
slouken@0
   154
{
slouken@0
   155
	int i = 0;
slouken@0
   156
	int j = 0;
slouken@0
   157
	SDL_Rect Amodelist[127];
slouken@0
   158
slouken@0
   159
slouken@0
   160
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   161
    {
slouken@0
   162
        fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   163
        return NULL;
slouken@0
   164
    }
slouken@0
   165
slouken@0
   166
	mode_info.bits_per_pixel = 0;
slouken@0
   167
slouken@0
   168
	for (i=0; i < mode_list.num_modes; i++) 
slouken@0
   169
	{
slouken@0
   170
            if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   171
            {
slouken@0
   172
                fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
   173
                        mode_list.modes[i]);
slouken@0
   174
                return NULL;
slouken@0
   175
            }
slouken@0
   176
            
slouken@0
   177
            if(mode_info.bits_per_pixel == format->BitsPerPixel)
slouken@0
   178
            {
slouken@0
   179
				Amodelist[j].w = mode_info.width;
slouken@0
   180
				Amodelist[j].h = mode_info.height;
slouken@0
   181
				Amodelist[j].x = 0;
slouken@0
   182
				Amodelist[j].y = 0;
slouken@0
   183
				j++;	
slouken@0
   184
			}
slouken@0
   185
	}
slouken@0
   186
	
slouken@0
   187
	//reorder biggest for smallest , assume width dominates
slouken@0
   188
	   for(i=0; i< j ; i++)
slouken@0
   189
	   {
slouken@0
   190
	     SDL_modelist[i].w = Amodelist[j - i -1].w;
slouken@0
   191
	     SDL_modelist[i].h = Amodelist[j - i -1].h;
slouken@0
   192
	     SDL_modelist[i].x = Amodelist[j - i -1].x;
slouken@0
   193
	     SDL_modelist[i].y = Amodelist[j - i -1].y;
slouken@0
   194
	   }
slouken@0
   195
	
slouken@0
   196
	SDLmod_ptr = SDL_modelist;
slouken@0
   197
	SDLmod_ptrptr = &SDLmod_ptr;
slouken@0
   198
	return SDLmod_ptrptr;
slouken@0
   199
}
slouken@0
   200
slouken@0
   201
SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
slouken@0
   202
{
slouken@0
   203
    return ph_SupportedVisual( format);
slouken@0
   204
}
slouken@0
   205
slouken@0
   206
void ph_FreeVideoModes(_THIS)
slouken@0
   207
{
slouken@0
   208
    int i;
slouken@0
   209
slouken@0
   210
 //   if ( SDL_modelist ) {
slouken@0
   211
 //       for ( i=0; SDL_modelist[i]; ++i ) {
slouken@0
   212
 //           free(SDL_modelist[i]);
slouken@0
   213
 //       }
slouken@0
   214
 //       free(SDL_modelist);
slouken@0
   215
 //       SDL_modelist = NULL;
slouken@0
   216
//    }
slouken@0
   217
}
slouken@0
   218
slouken@0
   219
static void set_best_resolution(_THIS, int width, int height)
slouken@0
   220
{
slouken@0
   221
slouken@0
   222
    if ( use_vidmode ) {
slouken@0
   223
		PgDisplaySettings_t 	settings;
slouken@0
   224
		PgVideoModeInfo_t		current_mode_info;
slouken@0
   225
		unsigned short			current_bpp;
slouken@0
   226
        int i;
slouken@0
   227
slouken@0
   228
		if (PgGetVideoMode( &settings ) < 0)
slouken@0
   229
		{
slouken@0
   230
			fprintf(stderr,"error: PgGetVideoMode failed\n");
slouken@0
   231
			return;
slouken@0
   232
		}
slouken@0
   233
		if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
slouken@0
   234
		{
slouken@0
   235
			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   236
			return;
slouken@0
   237
		}
slouken@0
   238
		current_bpp = current_mode_info.bits_per_pixel;
slouken@0
   239
slouken@0
   240
        if (PgGetVideoModeList(&mode_list) >= 0)
slouken@0
   241
		{
slouken@0
   242
			qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   243
#ifdef PH_DEBUG
slouken@0
   244
  			printf("Available modes:\n");
slouken@0
   245
  			for ( i = 0; i < mode_list.num_modes; ++i ) 
slouken@0
   246
			{
slouken@0
   247
				PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
slouken@0
   248
    			printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
slouken@0
   249
  			}
slouken@0
   250
#endif
slouken@0
   251
            for ( i = mode_list.num_modes-1; i >= 0 ; --i ) 
slouken@0
   252
			{
slouken@0
   253
				if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   254
				{
slouken@0
   255
					fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   256
				}
slouken@0
   257
                if ( (mode_info.width >= width) &&
slouken@0
   258
                     (mode_info.height >= height) &&
slouken@0
   259
					 (mode_info.bits_per_pixel == current_bpp) )
slouken@0
   260
                    break;
slouken@0
   261
            }
slouken@0
   262
			if (i >= 0)
slouken@0
   263
			{
slouken@0
   264
                if ( (mode_info.width != current_mode_info.width) ||
slouken@0
   265
                     (mode_info.height != current_mode_info.height) ) 
slouken@0
   266
				{
slouken@0
   267
					settings.mode = mode_list.modes[i];
slouken@0
   268
					if(PgSetVideoMode( &settings ) < 0)	
slouken@0
   269
					{
slouken@0
   270
						fprintf(stderr,"error: PgSetVideoMode failed\n");
slouken@0
   271
					}
slouken@0
   272
                }
slouken@0
   273
            }
slouken@0
   274
        }
slouken@0
   275
    }
slouken@0
   276
}
slouken@0
   277
slouken@0
   278
static void get_real_resolution(_THIS, int* w, int* h)
slouken@0
   279
{
slouken@0
   280
slouken@0
   281
    if ( use_vidmode ) {
slouken@0
   282
        PgDisplaySettings_t settings;
slouken@0
   283
        int unused;
slouken@0
   284
slouken@0
   285
        if (PgGetVideoMode( &settings ) >= 0) {
slouken@0
   286
			*w = settings.xres;
slouken@0
   287
			*h = settings.yres;
slouken@0
   288
            return;
slouken@0
   289
        }
slouken@0
   290
    }
slouken@0
   291
//    *w = DisplayWidth(SDL_Display, SDL_Screen);
slouken@0
   292
//    *h = DisplayHeight(SDL_Display, SDL_Screen);
slouken@0
   293
}
slouken@0
   294
slouken@0
   295
int ph_ResizeFullScreen(_THIS)
slouken@0
   296
{
slouken@0
   297
slouken@0
   298
    if ( currently_fullscreen ) {
slouken@0
   299
        set_best_resolution(this, current_w, current_h);
slouken@0
   300
    }
slouken@0
   301
    return(1);
slouken@0
   302
}
slouken@0
   303
slouken@0
   304
int get_mode(int width, int height, int bpp)
slouken@0
   305
/* return the mode associated with width, height and bpp */
slouken@0
   306
/* if there is no mode then zero is returned */
slouken@0
   307
{
slouken@0
   308
	int i;
slouken@0
   309
slouken@0
   310
slouken@0
   311
if(width <640)
slouken@0
   312
   width = 640;
slouken@0
   313
if(height < 480)
slouken@0
   314
  height = 480;
slouken@0
   315
slouken@0
   316
slouken@0
   317
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   318
	{
slouken@0
   319
	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   320
    	return -1;
slouken@0
   321
	}
slouken@0
   322
slouken@0
   323
	// search list for exact match
slouken@0
   324
	for (i=0;i<mode_list.num_modes;i++)
slouken@0
   325
	{
slouken@0
   326
		if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   327
		{
slouken@0
   328
			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   329
			return 0;
slouken@0
   330
		}
slouken@0
   331
		
slouken@0
   332
		
slouken@0
   333
		if ((mode_info.width == width) && 
slouken@0
   334
			(mode_info.height == height) && 
slouken@0
   335
			(mode_info.bits_per_pixel == bpp))
slouken@0
   336
			{
slouken@0
   337
			return mode_list.modes[i];
slouken@0
   338
			}
slouken@0
   339
	}
slouken@0
   340
	return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
slouken@0
   341
}
slouken@0
   342
slouken@0
   343
int get_mode_any_format(int width, int height, int bpp)
slouken@0
   344
/* return the mode associated with width, height and bpp */
slouken@0
   345
/* if requested bpp is not found the mode with closest bpp is returned */
slouken@0
   346
{
slouken@0
   347
    int i, closest, delta, min_delta;
slouken@0
   348
slouken@0
   349
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   350
	{
slouken@0
   351
	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   352
	    return -1;
slouken@0
   353
	}
slouken@0
   354
slouken@0
   355
	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   356
	for(i=0;i<mode_list.num_modes;i++)
slouken@0
   357
	{
slouken@0
   358
       if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   359
       {
slouken@0
   360
           fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   361
           return 0;
slouken@0
   362
       }
slouken@0
   363
       if ((mode_info.width == width) &&
slouken@0
   364
           (mode_info.height == height))
slouken@0
   365
           break;
slouken@0
   366
	}
slouken@0
   367
	if (i<mode_list.num_modes)
slouken@0
   368
	{
slouken@0
   369
		// get closest bpp
slouken@0
   370
		closest = i++;
slouken@0
   371
		if (mode_info.bits_per_pixel == bpp)
slouken@0
   372
			return mode_list.modes[ closest ];
slouken@0
   373
slouken@0
   374
		min_delta = abs(mode_info.bits_per_pixel - bpp);
slouken@0
   375
		while(1)
slouken@0
   376
		{
slouken@0
   377
			if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   378
			{
slouken@0
   379
			    fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   380
			    return 0;
slouken@0
   381
			}
slouken@0
   382
slouken@0
   383
			if ((mode_info.width != width) ||
slouken@0
   384
				(mode_info.height != height))
slouken@0
   385
				break;
slouken@0
   386
			else if (mode_info.bits_per_pixel == bpp)
slouken@0
   387
			{
slouken@0
   388
				closest = i;
slouken@0
   389
				break;
slouken@0
   390
			}
slouken@0
   391
			else
slouken@0
   392
			{
slouken@0
   393
				delta = abs(mode_info.bits_per_pixel - bpp);
slouken@0
   394
				if (delta < min_delta)
slouken@0
   395
				{
slouken@0
   396
					closest = i;
slouken@0
   397
					min_delta = delta;
slouken@0
   398
				}
slouken@0
   399
				i++;
slouken@0
   400
			}
slouken@0
   401
		}
slouken@0
   402
		return mode_list.modes[ closest ];
slouken@0
   403
	}
slouken@0
   404
	else
slouken@0
   405
		return 0;
slouken@0
   406
}
slouken@0
   407
slouken@0
   408
void ph_WaitMapped(_THIS);
slouken@0
   409
void ph_WaitUnmapped(_THIS);
slouken@0
   410
void ph_QueueEnterFullScreen(_THIS);
slouken@0
   411
slouken@0
   412
int ph_ToggleFullScreen(_THIS, int on)
slouken@0
   413
{
slouken@0
   414
slouken@0
   415
   if(currently_fullscreen)
slouken@0
   416
        ph_LeaveFullScreen(this);
slouken@0
   417
   else
slouken@0
   418
        ph_EnterFullScreen(this);
slouken@0
   419
      
slouken@0
   420
   return 0;     
slouken@0
   421
slouken@0
   422
}
slouken@0
   423
slouken@0
   424
int ph_EnterFullScreen(_THIS)
slouken@0
   425
{
slouken@0
   426
	if ( ! currently_fullscreen ) 
slouken@0
   427
	{
slouken@0
   428
slouken@0
   429
		if (old_video_mode==-1)
slouken@0
   430
		{
slouken@0
   431
			PgGetGraphicsHWCaps(&graphics_card_caps);
slouken@0
   432
			old_video_mode=graphics_card_caps.current_video_mode;
slouken@0
   433
			old_refresh_rate=graphics_card_caps.current_rrate;
slouken@0
   434
		}
slouken@0
   435
slouken@0
   436
slouken@0
   437
		if(OCImage.direct_context == NULL)
slouken@0
   438
       	 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
slouken@0
   439
        if( !OCImage.direct_context )
slouken@0
   440
             fprintf(stderr, "error: Can't create direct context\n" );
slouken@0
   441
             
slouken@0
   442
       
slouken@0
   443
		/* Remove the cursor if in full screen mode */		
slouken@0
   444
/*
slouken@0
   445
		region_info.cursor_type = Ph_CURSOR_NONE;
slouken@0
   446
		region_info.rid=PtWidgetRid(window);
slouken@0
   447
		PhRegionChange(Ph_REGION_CURSOR,0,&region_info,NULL,NULL);
slouken@0
   448
*/
slouken@0
   449
slouken@0
   450
	 	PdDirectStart( OCImage.direct_context );
slouken@0
   451
slouken@0
   452
		currently_fullscreen = 1;
slouken@0
   453
		}
slouken@0
   454
slouken@0
   455
slouken@0
   456
		
slouken@0
   457
	return 1;
slouken@0
   458
}
slouken@0
   459
slouken@0
   460
int ph_LeaveFullScreen(_THIS )
slouken@0
   461
{
slouken@0
   462
   PgDisplaySettings_t mymode_settings;
slouken@0
   463
       
slouken@0
   464
	if ( currently_fullscreen )
slouken@0
   465
	{
slouken@0
   466
		PdDirectStop(OCImage.direct_context);
slouken@0
   467
		PdReleaseDirectContext(OCImage.direct_context);
slouken@0
   468
slouken@0
   469
		//Restore old video mode	
slouken@0
   470
		if (old_video_mode != -1)
slouken@0
   471
		{
slouken@0
   472
			mymode_settings.mode= (unsigned short) old_video_mode;
slouken@0
   473
			mymode_settings.refresh= (unsigned short) old_refresh_rate;
slouken@0
   474
			mymode_settings.flags = 0;
slouken@0
   475
			if(PgSetVideoMode(&mymode_settings) < 0)
slouken@0
   476
			{
slouken@0
   477
            fprintf(stderr,"error: PgSetVideoMode failed\n");
slouken@0
   478
        	}
slouken@0
   479
		}
slouken@0
   480
	
slouken@0
   481
		old_video_mode=-1;
slouken@0
   482
		old_refresh_rate=-1;	
slouken@0
   483
	
slouken@0
   484
		// Restore cursor	
slouken@0
   485
	
slouken@0
   486
	}
slouken@0
   487
	return 1;
slouken@0
   488
}