src/video/gem/SDL_gemvideo.c
changeset 2108 a930c8e4d8b0
parent 2107 757dfb38f574
child 2120 2c835d58faad
equal deleted inserted replaced
2107:757dfb38f574 2108:a930c8e4d8b0
   637 
   637 
   638 SDL_Surface *
   638 SDL_Surface *
   639 GEM_SetVideoMode(_THIS, SDL_Surface * current,
   639 GEM_SetVideoMode(_THIS, SDL_Surface * current,
   640                  int width, int height, int bpp, Uint32 flags)
   640                  int width, int height, int bpp, Uint32 flags)
   641 {
   641 {
   642     int maxwidth, maxheight;
       
   643     Uint32 modeflags, screensize;
   642     Uint32 modeflags, screensize;
   644     SDL_bool use_shadow1, use_shadow2;
   643     SDL_bool use_shadow1, use_shadow2;
   645 
       
   646         /*--- Verify if asked mode can be used ---*/
       
   647     if (flags & SDL_FULLSCREEN) {
       
   648         maxwidth = VDI_w;
       
   649         maxheight = VDI_h;
       
   650     } else {
       
   651         /* Windowed mode */
       
   652         maxwidth = GEM_desk_w;
       
   653         maxheight = GEM_desk_h;
       
   654     }
       
   655 
   644 
   656     /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
   645     /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
   657     if ((width & 15) != 0) {
   646     if ((width & 15) != 0) {
   658         width = (width | 15) + 1;
   647         width = (width | 15) + 1;
   659     }
   648     }
   660 
   649 
   661     if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
   650         /*--- Verify if asked mode can be used ---*/
   662         SDL_SetError("Couldn't find requested mode in list");
   651     if (VDI_bpp != bpp) {
   663         return (NULL);
   652         SDL_SetError("%d bpp mode not supported", bpp);
       
   653         return(NULL);
       
   654     }
       
   655 
       
   656     if (flags & SDL_FULLSCREEN) {
       
   657         if ((VDI_w < width) || (VDI_h < height)) {
       
   658             SDL_SetError("%dx%d mode is too large", width, height);
       
   659             return (NULL);
       
   660         }
   664     }
   661     }
   665 
   662 
   666         /*--- Allocate the new pixel format for the screen ---*/
   663         /*--- Allocate the new pixel format for the screen ---*/
   667     if (!SDL_ReallocFormat
   664     if (!SDL_ReallocFormat
   668         (current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask,
   665         (current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask,
   773                 SDL_SetError("Can not calculate window attributes");
   770                 SDL_SetError("Can not calculate window attributes");
   774                 return NULL;
   771                 return NULL;
   775             }
   772             }
   776 
   773 
   777             /* Center window */
   774             /* Center window */
   778             x2 = GEM_desk_x + ((GEM_desk_w - w2) >> 1);
   775             x2 = (GEM_desk_w - w2) >> 1;
   779             y2 = GEM_desk_y + ((GEM_desk_h - h2) >> 1);
   776             y2 = (GEM_desk_h - h2) >> 1;
       
   777             if (x2<0) {
       
   778                 x2 = 0;
       
   779             }
       
   780             if (y2<0) {
       
   781                 y2 = 0;
       
   782             }
       
   783             x2 += GEM_desk_x;
       
   784             y2 += GEM_desk_y;
   780 
   785 
   781             /* Destroy existing window */
   786             /* Destroy existing window */
   782             if (GEM_handle >= 0) {
   787             if (GEM_handle >= 0) {
   783                 wind_close(GEM_handle);
   788                 wind_close(GEM_handle);
   784                 wind_delete(GEM_handle);
   789                 wind_delete(GEM_handle);