sdl.c
changeset 128 28ebd80f6521
parent 119 82c0f4713cad
child 129 df1a60bc0d70
equal deleted inserted replaced
127:815ec4d365e2 128:28ebd80f6521
   241 	} else if((int) modes == -1) {
   241 	} else if((int) modes == -1) {
   242 		// all modes available, put some default ones here
   242 		// all modes available, put some default ones here
   243 		memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
   243 		memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
   244 		_num_resolutions = sizeof(default_resolutions) / (sizeof(uint16)*2);
   244 		_num_resolutions = sizeof(default_resolutions) / (sizeof(uint16)*2);
   245 	} else {
   245 	} else {
   246 		int n = 0,  w = 0,  h = 0;
   246 		int n = 0;
   247 		for(i = 0; modes[i]; i++) {
   247 		for(i = 0; modes[i]; i++) {
   248 			if(w == modes[i]->w && h == modes[i]->h) continue; // don't show same resolutions multiple times
   248 			int w = modes[i]->w;
   249 			w = modes[i]->w;
   249 			int h = modes[i]->h;
   250 			h = modes[i]->h;
       
   251 			if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH+1) && 
   250 			if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH+1) && 
   252 					IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT+1) &&
   251 					IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT+1) &&
   253 					w%8 == 0 && h%8 == 0) { // disable screen resolutions which are not multiples of 8
   252 					w%8 == 0 && h%8 == 0) { // disable screen resolutions which are not multiples of 8
   254 				_resolutions[n][0] = w;
   253 				int j;
   255 				_resolutions[n][1] = h;
   254 				for (j = 0; j < n; ++j)
   256 				if (++n == sizeof(_resolutions) / (sizeof(uint16)*2)) break;
   255 					if (_resolutions[j][0] == w && _resolutions[j][1] == h)
       
   256 						break;
       
   257 				if (j == n) {
       
   258 					_resolutions[n][0] = w;
       
   259 					_resolutions[n][1] = h;
       
   260 					if (++n == sizeof(_resolutions) / (sizeof(uint16)*2)) break;
       
   261 				}
   257 			}
   262 			}
   258 		}
   263 		}
   259 		_num_resolutions = n;
   264 		_num_resolutions = n;
   260 		qsort(_resolutions, n, sizeof(uint16)*2, compare_res);
   265 		qsort(_resolutions, n, sizeof(uint16)*2, compare_res);
   261 	}
   266 	}