src/video/gem/SDL_gemvideo.c
branchSDL-1.2
changeset 3944 d59dacd36696
parent 3943 1d9cd0ff67cc
child 4159 a1b03ba2fcd0
equal deleted inserted replaced
3943:1d9cd0ff67cc 3944:d59dacd36696
   619 }
   619 }
   620 
   620 
   621 SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
   621 SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
   622 				int width, int height, int bpp, Uint32 flags)
   622 				int width, int height, int bpp, Uint32 flags)
   623 {
   623 {
   624 	int maxwidth, maxheight;
       
   625 	Uint32 modeflags, screensize;
   624 	Uint32 modeflags, screensize;
   626 	SDL_bool use_shadow1, use_shadow2;
   625 	SDL_bool use_shadow1, use_shadow2;
   627 
       
   628 	/*--- Verify if asked mode can be used ---*/
       
   629 	if (flags & SDL_FULLSCREEN) {
       
   630 		maxwidth=VDI_w;
       
   631 		maxheight=VDI_h;
       
   632 	} else {
       
   633 		/* Windowed mode */
       
   634 		maxwidth=GEM_desk_w;
       
   635 		maxheight=GEM_desk_h;
       
   636 	}
       
   637 
   626 
   638 	/* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
   627 	/* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
   639 	if ((width & 15) != 0) {
   628 	if ((width & 15) != 0) {
   640 		width = (width | 15) +1;
   629 		width = (width | 15) +1;
   641 	}
   630 	}
   642 
   631 
   643 	if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
   632 	/*--- Verify if asked mode can be used ---*/
   644 		SDL_SetError("Couldn't find requested mode in list");
   633 	if (VDI_bpp != bpp) {
       
   634 		SDL_SetError("%d bpp mode not supported", bpp);
   645 		return(NULL);
   635 		return(NULL);
       
   636 	}
       
   637 
       
   638 	if (flags & SDL_FULLSCREEN) {
       
   639 		if ((VDI_w < width) || (VDI_h < height)) {
       
   640 			SDL_SetError("%dx%d mode is too large", width, height);
       
   641 			return(NULL);
       
   642 		}
   646 	}
   643 	}
   647 
   644 
   648 	/*--- Allocate the new pixel format for the screen ---*/
   645 	/*--- Allocate the new pixel format for the screen ---*/
   649 	if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) {
   646 	if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) {
   650 		SDL_SetError("Couldn't allocate new pixel format for requested mode");
   647 		SDL_SetError("Couldn't allocate new pixel format for requested mode");
   748 				SDL_SetError("Can not calculate window attributes");
   745 				SDL_SetError("Can not calculate window attributes");
   749 				return NULL;
   746 				return NULL;
   750 			}
   747 			}
   751 
   748 
   752 			/* Center window */
   749 			/* Center window */
   753 			x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
   750 			x2 = (GEM_desk_w-w2)>>1;
   754 			y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
   751 			y2 = (GEM_desk_h-h2)>>1;
       
   752 			if (x2<0) {
       
   753 				x2 = 0;
       
   754 			}
       
   755 			if (y2<0) {
       
   756 				y2 = 0;
       
   757 			}
       
   758 			x2 += GEM_desk_x;
       
   759 			y2 += GEM_desk_y;
   755 
   760 
   756 			/* Destroy existing window */
   761 			/* Destroy existing window */
   757 			if (GEM_handle >= 0) {
   762 			if (GEM_handle >= 0) {
   758 				wind_close(GEM_handle);
   763 				wind_close(GEM_handle);
   759 				wind_delete(GEM_handle);
   764 				wind_delete(GEM_handle);