Ticket #8250: aspect-modes2.diff
File aspect-modes2.diff, 28.3 KB (added by , 21 years ago) |
---|
-
scummvm/README
diff -ur ScummVM+orig/scummvm/README ScummVM+hack/scummvm/README
old new 346 346 -x[<num>] - Save game slot to load (default: autosave) 347 347 -f - Full-screen mode. 348 348 -g<mode> - Select graphics scaler. See below. 349 -r<mode> - Select aspect ratio correction mode. See below. 349 350 -e<mode> - Select sound engine. See below. 350 351 -a - Enable amiga pal conversion, for playing Amiga 351 352 versions … … 367 368 current directory 368 369 --multi-midi - enable combination Adlib and native MIDI 369 370 --native-mt32 - true Roland MT-32 (disable GM emulation) 370 --aspect-ratio - enable aspect ratio correction371 371 372 372 373 373 … … 383 383 Ctrl-Alt 0-9 - Switch between graphics filters 384 384 Ctrl-Alt b - Switch beetwen bilinear and non-linear 385 385 filtering [OpenGL backend] 386 Ctrl-Alt a - Toggle aspect-ratio correction on/off. 387 Most of the games use a 320x200 pixel 388 resolution, which may look squashed on 389 modern monitors. Aspect-ratio correction 390 stretches the image to use 320x240 pixels 391 instead, or a multiple thereof. 386 Ctrl-Alt a - Cycle between aspect ratio correction modes. 392 387 393 388 Scumm: 394 389 Ctrl 0-9 and Alt 0-9 - load and save game state … … 458 453 459 454 scummvm -g advmame2x monkey2 460 455 456 In addition ScummVM offers a few different methods for aspect ratio correction 457 to stretch a 320x200 image to 320x240. This provides the correct aspect ratio 458 on modern displays, and can be combined with any of the scalers listed above 459 (except for opengl, which handles aspect ratio correction differently) to 460 produce 640x480 or 960x720 resolutions. 461 462 They are: 463 none - No aspect ratio correction. (default) 464 sloppy - Every fifth screen line is doubled. This is fast, but will 465 look ugly in some cases. 466 fast - Approximated bilinear filtering. This is a little slower, but 467 looks better than sloppy mode. 468 exact - Exact bilinear filtering. This is much slower, but may look a 469 little better than fast mode. 470 471 To select an aspect ratio correction mode, pass its name via the '-r' option 472 to scummvm, for example: 473 474 scummvm -g avdmame2x -r fast monkey2 475 461 476 Note #1: Not all backends support all or any filters. The ones listed above 462 477 are for the default SDL backend. 463 478 … … 468 483 Note #3: The FmTowns version of Zak (zak256 target) uses an original resolution 469 484 of 320x240 - hence for this game scalers will scale to 640x480 or 960x720. 470 485 486 Note #4: The Curse of Monkey Island uses an original resolution of 640x480 - 487 hence for this game scalers will scale to 1280x960 or 1920x1440. However, the 488 anti-aliasing filters are unlikely to improve the graphics much since they are 489 already anti-aliased to begin with. 471 490 472 491 Autosaves: 473 492 ---------- -
scummvm/backends/sdl/sdl-common.cpp
diff -ur ScummVM+orig/scummvm/backends/sdl/sdl-common.cpp ScummVM+hack/scummvm/backends/sdl/sdl-common.cpp
old new 41 41 #define JOY_BUT_SPACE 4 42 42 #define JOY_BUT_F5 5 43 43 44 OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen, bool aspect_ratio) {45 return OSystem_SDL_Common::create(gfx_mode, full_screen, aspect_ratio );44 OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen, int aspect_ratio_mode) { 45 return OSystem_SDL_Common::create(gfx_mode, full_screen, aspect_ratio_mode); 46 46 } 47 47 48 OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen, bool aspect_ratio) {48 OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen, int aspect_ratio_mode) { 49 49 OSystem_SDL_Common *syst = OSystem_SDL_Common::create_intern(); 50 50 51 syst->init_intern(gfx_mode, full_screen, aspect_ratio );51 syst->init_intern(gfx_mode, full_screen, aspect_ratio_mode); 52 52 53 53 return syst; 54 54 } 55 55 56 void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect_ratio) {56 void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, int aspect_ratio_mode) { 57 57 58 58 _mode = gfx_mode; 59 59 _full_screen = full_screen; 60 _a djustAspectRatio = aspect_ratio;60 _aspectRatioMode = aspect_ratio_mode; 61 61 62 62 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) ==-1) { 63 63 error("Could not initialize SDL: %s.\n", SDL_GetError()); … … 132 132 _screenHeight = h; 133 133 134 134 if (h != 200) 135 _a djustAspectRatio = false;135 _aspectRatioMode = ASPECT_NONE; 136 136 137 137 CKSUM_NUM = (_screenWidth * _screenHeight / (8 * 8)); 138 138 if (_dirty_checksums) … … 287 287 h = _screenHeight - y; 288 288 } 289 289 290 if (_a djustAspectRatio)290 if (_aspectRatioMode > ASPECT_SLOPPY) 291 291 makeRectStretchable(x, y, w, h); 292 292 293 293 r->x = x; … … 586 586 587 587 // Ctr-Alt-a will change aspect ratio 588 588 if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='a') { 589 property(PROP_TOGGLE_ASPECT_RATIO, NULL); 589 Property prop; 590 591 if (_aspectRatioMode >= ASPECT_MAX) 592 prop.aspect_ratio_mode = ASPECT_MIN; 593 else 594 prop.aspect_ratio_mode = _aspectRatioMode + 1; 595 property(PROP_SET_ASPECT_RATIO_MODE, &prop); 590 596 break; 591 597 } 592 598 … … 704 710 event->mouse.x /= _scaleFactor; 705 711 event->mouse.y /= _scaleFactor; 706 712 707 if (_a djustAspectRatio)713 if (_aspectRatioMode != ASPECT_NONE) 708 714 event->mouse.y = aspect2Real(event->mouse.y); 709 715 return true; 710 716 … … 726 732 event->mouse.x /= _scaleFactor; 727 733 event->mouse.y /= _scaleFactor; 728 734 729 if (_a djustAspectRatio)735 if (_aspectRatioMode != ASPECT_NONE) 730 736 event->mouse.y = aspect2Real(event->mouse.y); 731 737 732 738 return true; … … 743 749 event->mouse.x /= _scaleFactor; 744 750 event->mouse.y /= _scaleFactor; 745 751 746 if (_a djustAspectRatio)752 if (_aspectRatioMode != ASPECT_NONE) 747 753 event->mouse.y = aspect2Real(event->mouse.y); 748 754 749 755 return true; … … 851 857 event->mouse.x /= _scaleFactor; 852 858 event->mouse.y /= _scaleFactor; 853 859 854 if (_a djustAspectRatio)860 if (_aspectRatioMode != ASPECT_NONE) 855 861 event->mouse.y = aspect2Real(event->mouse.y); 856 862 857 863 return true; -
scummvm/backends/sdl/sdl-common.h
diff -ur ScummVM+orig/scummvm/backends/sdl/sdl-common.h ScummVM+hack/scummvm/backends/sdl/sdl-common.h
old new 25 25 #include "stdafx.h" 26 26 #include "scummsys.h" 27 27 #include "system.h" 28 #include "common/scaler.h" 28 29 29 30 #include <SDL.h> 30 31 #include <SDL_thread.h> … … 123 124 virtual int16 RGBToColor(uint8 r, uint8 g, uint8 b); 124 125 virtual void colorToRGB(int16 color, uint8 &r, uint8 &g, uint8 &b); 125 126 126 static OSystem *create(int gfx_mode, bool full_screenm, bool aspect_ratio);127 static OSystem *create(int gfx_mode, bool full_screenm, int aspect_ratio_mode); 127 128 128 129 protected: 129 130 OSystem_SDL_Common(); … … 131 132 132 133 static OSystem_SDL_Common *create_intern(); 133 134 134 void init_intern(int gfx_mode, bool full_screen, bool aspect_ratio);135 void init_intern(int gfx_mode, bool full_screen, int aspect_ratio_mode); 135 136 136 137 // unseen game screen 137 138 SDL_Surface *_screen; … … 142 143 int _tmpScreenWidth; 143 144 bool _overlayVisible; 144 145 145 bool _adjustAspectRatio;146 int _aspectRatioMode; 146 147 147 148 // CD Audio 148 149 SDL_CD *_cdrom; -
scummvm/backends/sdl/sdl.cpp
diff -ur ScummVM+orig/scummvm/backends/sdl/sdl.cpp ScummVM+hack/scummvm/backends/sdl/sdl.cpp
old new 16 16 * along with this program; if not, write to the Free Software 17 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 18 * 19 * $Header: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v 1.3 7 2003/06/22 14:18:33 kirben Exp $19 * $Header: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v 1.38 2003/06/30 14:31:09 eriktorbjorn Exp $ 20 20 * 21 21 */ 22 22 23 23 #include "sdl-common.h" 24 #include "common/scaler.h"25 24 #include "common/util.h" 26 25 #include "common/engine.h" // Only #included for error() and warning() 27 26 … … 42 41 SDL_Surface *_hwscreen; // hardware screen 43 42 44 43 ScalerProc *_scaler_proc; 44 StretcherProc *_stretcher_proc; 45 45 46 46 virtual void load_gfx_mode(); 47 47 virtual void unload_gfx_mode(); … … 53 53 } 54 54 55 55 OSystem_SDL::OSystem_SDL() 56 : _hwscreen(0), _scaler_proc(0) 56 : _hwscreen(0), _scaler_proc(0), _stretcher_proc(0) 57 57 { 58 58 } 59 59 … … 119 119 break; 120 120 121 121 case GFX_TRIPLESIZE: 122 if (_full_screen) {123 warning("full screen in useless in triplesize mode, reverting to normal mode");124 goto normal_mode;125 }126 122 _scaleFactor = 3; 127 123 _scaler_proc = Normal3x; 128 124 break; 129 125 130 126 case GFX_NORMAL: 131 normal_mode:;132 127 _scaleFactor = 1; 133 128 _scaler_proc = Normal1x; 134 129 break; 135 130 default: 136 131 error("unknown gfx mode %d", _mode); 137 _scaleFactor = 1; 138 _scaler_proc = NULL; 132 } 133 134 switch (_aspectRatioMode) { 135 case ASPECT_NONE: 136 _stretcher_proc = NULL; 137 break; 138 case ASPECT_SLOPPY: 139 _stretcher_proc = stretch200To240Sloppy; 140 break; 141 case ASPECT_FAST: 142 _stretcher_proc = stretch200To240Fast; 143 break; 144 case ASPECT_EXACT: 145 _stretcher_proc = stretch200To240Exact; 146 break; 147 default: 148 error("unknown aspect ratio mode %d", _aspectRatioMode); 139 149 } 140 150 141 151 // … … 149 159 // Create the surface that contains the scaled graphics in 16 bit mode 150 160 // 151 161 152 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor, 16,162 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor, 16, 153 163 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 154 164 ); 155 165 if (_hwscreen == NULL) … … 283 293 uint32 srcPitch, dstPitch; 284 294 SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; 285 295 286 if (_scaler_proc == Normal1x && !_adjustAspectRatio) {296 if (_scaler_proc == Normal1x && _aspectRatioMode == ASPECT_NONE) { 287 297 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 288 298 for (r = _dirty_rect_list; r != last_rect; ++r) { 289 299 dst = *r; … … 325 335 326 336 dst_y *= _scaleFactor; 327 337 328 if (_a djustAspectRatio) {338 if (_aspectRatioMode != ASPECT_NONE) { 329 339 orig_dst_y = dst_y; 330 340 dst_y = real2Aspect(dst_y); 331 341 } … … 339 349 r->w *= _scaleFactor; 340 350 r->h = dst_h * _scaleFactor; 341 351 342 if (_ adjustAspectRatio&& orig_dst_y / _scaleFactor < _screenHeight)343 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y);352 if (_stretcher_proc && orig_dst_y / _scaleFactor < _screenHeight) 353 r->h = _stretcher_proc((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); 344 354 } 345 355 SDL_UnlockSurface(_tmpscreen); 346 356 SDL_UnlockSurface(_hwscreen); … … 350 360 // This is necessary if shaking is active. 351 361 if (_forceFull) { 352 362 _dirty_rect_list[0].y = 0; 353 _dirty_rect_list[0].h = ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor;363 _dirty_rect_list[0].h = ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor; 354 364 } 355 365 356 366 // Finally, blit all our changes to the screen … … 385 395 hotswap_gfx_mode(); 386 396 387 397 return 1; 388 } else if (param == PROP_ TOGGLE_ASPECT_RATIO) {398 } else if (param == PROP_SET_ASPECT_RATIO_MODE) { 389 399 if (_screenHeight == 200) { 390 assert(_hwscreen != 0); 391 _adjustAspectRatio ^= true; 400 _aspectRatioMode = value->aspect_ratio_mode; 392 401 hotswap_gfx_mode(); 393 402 } 394 403 } -
scummvm/backends/sdl/sdl_gl.cpp
diff -ur ScummVM+orig/scummvm/backends/sdl/sdl_gl.cpp ScummVM+hack/scummvm/backends/sdl/sdl_gl.cpp
old new 16 16 * along with this program; if not, write to the Free Software 17 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 18 * 19 * $Header: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v 1.4 2 2003/06/30 02:38:56 kirben Exp $19 * $Header: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v 1.43 2003/06/30 14:31:09 eriktorbjorn Exp $ 20 20 * 21 21 */ 22 22 … … 64 64 SDL_Surface *_hwscreen; // hardware screen (=> _usingOpenGL == false) 65 65 66 66 ScalerProc *_scaler_proc; 67 StretcherProc *_stretcher_proc; 67 68 68 69 virtual void load_gfx_mode(); 69 70 virtual void unload_gfx_mode(); … … 75 76 } 76 77 77 78 OSystem_SDL_OpenGL::OSystem_SDL_OpenGL() 78 : _hwscreen(0), _scaler_proc(0) 79 : _hwscreen(0), _scaler_proc(0), _stretcher_proc(0) 79 80 { 80 81 _glScreenStart = 0; 81 82 _glBilinearFilter = false; … … 159 160 break; 160 161 161 162 case GFX_TRIPLESIZE: 162 if (_full_screen) {163 warning("full screen in useless in triplesize mode, reverting to normal mode");164 goto normal_mode;165 }166 163 _scaleFactor = 3; 167 164 _scaler_proc = Normal3x; 168 165 break; 169 166 170 167 case GFX_NORMAL: 171 normal_mode:;172 168 _scaleFactor = 1; //_usingOpenGL ? 2 : 1; 173 169 _scaler_proc = Normal1x; 174 170 break; … … 180 176 } 181 177 182 178 if (_mode != GFX_NORMAL) { 183 179 _usingOpenGL = false; 184 180 } 185 181 182 switch (_aspectRatioMode) { 183 case ASPECT_NONE: 184 _stretcher_proc = NULL; 185 break; 186 case ASPECT_SLOPPY: 187 _stretcher_proc = stretch200To240Sloppy; 188 break; 189 case ASPECT_FAST: 190 _stretcher_proc = stretch200To240Fast; 191 break; 192 case ASPECT_EXACT: 193 _stretcher_proc = stretch200To240Exact; 194 break; 195 default: 196 error("unknown aspect ratio mode %d", _aspectRatioMode); 197 } 198 186 199 // 187 200 // Create the surface that contains the 8 bit game data 188 201 // … … 218 231 219 232 } else { // SDL backend 220 233 221 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor, 16,234 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor, 16, 222 235 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 223 236 ); 224 237 if (_hwscreen == NULL) … … 432 445 433 446 // Bottom black border height 434 447 tmpBlackRect.h = _glBottomOfTexture - _glBottomOfGameScreen; 435 if (_a djustAspectRatio&& tmpBlackRect.h > 0) {448 if (_aspectRatioMode != ASPECT_NONE && tmpBlackRect.h > 0) { 436 449 SDL_FillRect(tmpSurface, &tmpBlackRect, 0); 437 450 fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 438 451 _glBottomOfGameScreen); … … 441 454 fb2gl.display(); 442 455 } else { // SDL backend 443 456 444 if (_scaler_proc == Normal1x && !_adjustAspectRatio) {457 if (_scaler_proc == Normal1x && _aspectRatioMode == ASPECT_NONE) { 445 458 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 446 459 for (r = _dirty_rect_list; r != last_rect; ++r) { 447 460 dst = *r; … … 483 496 484 497 dst_y *= _scaleFactor; 485 498 486 if (_a djustAspectRatio) {499 if (_aspectRatioMode != ASPECT_NONE) { 487 500 orig_dst_y = dst_y; 488 501 dst_y = real2Aspect(dst_y); 489 502 } … … 497 510 r->w *= _scaleFactor; 498 511 r->h = dst_h * _scaleFactor; 499 512 500 if (_ adjustAspectRatio&& orig_dst_y / _scaleFactor < _screenHeight)501 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y);513 if (_stretcher_proc && orig_dst_y / _scaleFactor < _screenHeight) 514 r->h = _stretcher_proc((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); 502 515 } 503 516 504 517 SDL_UnlockSurface(_tmpscreen); … … 509 522 // This is necessary if shaking is active. 510 523 if (_forceFull) { 511 524 _dirty_rect_list[0].y = 0; 512 _dirty_rect_list[0].h = ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor;525 _dirty_rect_list[0].h = ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor; 513 526 } 514 527 515 528 // Finally, blit all our changes to the screen … … 571 584 #endif 572 585 573 586 return 1; 574 } else if (param == PROP_TOGGLE_ASPECT_RATIO) { 575 576 _adjustAspectRatio ^= true; 587 } else if (param == PROP_SET_ASPECT_RATIO_MODE) { 577 588 if (_usingOpenGL) { 578 if (_adjustAspectRatio) { 589 // OpenGL has only two aspect ratio correction modes. 590 if (value->aspect_ratio_mode == ASPECT_MIN) 591 _aspectRatioMode = ASPECT_MIN; 592 else 593 _aspectRatioMode = ASPECT_MAX; 594 if (_aspectRatioMode != ASPECT_NONE) { 579 595 // Don't use the whole screen (black borders) 580 596 fb2gl.init(0, 0, 0, 15, _glFlags); 581 597 _glScreenStart = _glBorderHeight; … … 611 627 fb2gl.display(); 612 628 } else { 613 629 if (_screenHeight == 200) { 614 assert(_hwscreen != 0);630 _aspectRatioMode = value->aspect_ratio_mode; 615 631 hotswap_gfx_mode(); 616 632 } 617 633 } -
scummvm/common/gameDetector.cpp
diff -ur ScummVM+orig/scummvm/common/gameDetector.cpp ScummVM+hack/scummvm/common/gameDetector.cpp
old new 25 25 #include "engine.h" 26 26 #include "gameDetector.h" 27 27 #include "config-file.h" 28 #include "scaler.h" // Only for gfx_modes 28 #include "scaler.h" // Only for gfx_modes and aspect ratio 29 29 30 30 #if defined(HAVE_CONFIG_H) 31 31 #include "config.h" … … 54 54 "\t-x[<num>] - load this savegame (default: 0 - autosave)\n" 55 55 "\t-f - fullscreen mode\n" 56 56 "\t-g<mode> - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,advmame3x,tv2x,dotmatrix)\n" 57 "\t-r<mode> - aspect ratio correction (none,sloppy,fast,exact)\n" 57 58 "\t-e<mode> - set music engine (see README for details)\n" 58 59 "\t-a - specify game is amiga version\n" 59 60 "\t-q<lang> - specify language (en,de,fr,it,pt,es,jp,zh,kr,hb)\n" … … 82 83 "\n" 83 84 "\t--multi-midi - enable combination Adlib and native MIDI\n" 84 85 "\t--native-mt32 - true Roland MT-32 (disable GM emulation)\n" 85 "\t--aspect-ratio - enable aspect ratio correction\n"86 86 ; 87 87 #endif 88 88 // This contains a pointer to a list of all supported games. … … 110 110 {0, 0, 0} 111 111 }; 112 112 113 static const struct AspectRatioMode aspect_ratio_modes[] = { 114 {"none", "No correction", ASPECT_NONE}, 115 {"sloppy", "Pixel doubling", ASPECT_SLOPPY}, 116 {"fast", "Approximate bilinear filtering", ASPECT_FAST}, 117 {"exact", "Exact bilinear filtering", ASPECT_EXACT}, 118 {0, 0, 0} 119 }; 120 113 121 static const struct Language languages[] = { 114 122 {"en", "English", EN_USA}, 115 123 {"de", "German", DE_DEU}, … … 150 158 151 159 GameDetector::GameDetector() { 152 160 _fullScreen = false; 153 _aspectRatio = false;161 _aspectRatioMode = ASPECT_NONE; 154 162 155 163 _use_adlib = false; 156 164 … … 248 256 } 249 257 250 258 _fullScreen = g_config->getBool("fullscreen", _fullScreen); 251 _aspectRatio = g_config->getBool("aspect_ratio", _aspectRatio); 259 260 if ((val = g_config->get("aspect_ratio"))) 261 if ((_aspectRatioMode = parseAspectRatioMode(val)) == -1) { 262 printf("Error in the config file: invalid aspect_ratio.\n"); 263 printf(USAGE_STRING); 264 exit(-1); 265 } 252 266 253 267 if ((val = g_config->get("gfx_mode"))) 254 268 if ((_gfx_mode = parseGraphicsMode(val)) == -1) { … … 404 418 break; 405 419 case 'r': 406 420 HANDLE_OPTION(); 407 // Ignore -r for now, to ensure backward compatibility. 421 _aspectRatioMode = parseAspectRatioMode(option); 422 if (_aspectRatioMode == -1) 423 goto ShowHelpAndExit; 424 g_config->set("aspect_ratio", option, "scummvm"); 408 425 break; 409 426 case 's': 410 427 HANDLE_OPTION(); … … 457 474 } else if (!strcmp (s, "native-mt32")) { 458 475 _native_mt32 = true; 459 476 g_config->setBool ("native_mt32", true); 460 } else if (!strcmp (s, "aspect-ratio")) {461 _aspectRatio = true;462 g_config->setBool ("aspect_ratio", true);463 477 } else { 464 478 goto ShowHelpAndExit; 465 479 } … … 520 534 return -1; 521 535 } 522 536 537 int GameDetector::parseAspectRatioMode(const char *s) { 538 const AspectRatioMode *arm = aspect_ratio_modes; 539 while(arm->name) { 540 if (!scumm_stricmp(arm->name, s)) 541 return arm->id; 542 arm++; 543 } 544 545 return -1; 546 } 547 523 548 int GameDetector::parseLanguage(const char *s) { 524 549 const Language *l = languages; 525 550 while(l->name) { … … 680 705 return OSystem_PALMOS_create(_gfx_mode); 681 706 #else 682 707 /* SDL is the default driver for now */ 683 return OSystem_SDL_create(_gfx_mode, _fullScreen, _aspectRatio );708 return OSystem_SDL_create(_gfx_mode, _fullScreen, _aspectRatioMode); 684 709 #endif 685 710 } 686 711 -
scummvm/common/gameDetector.h
diff -ur ScummVM+orig/scummvm/common/gameDetector.h ScummVM+hack/scummvm/common/gameDetector.h
old new 85 85 int id; 86 86 }; 87 87 88 struct AspectRatioMode { 89 const char *name; 90 const char *description; 91 int id; 92 }; 93 88 94 struct Language { 89 95 const char *name; 90 96 const char *description; … … 110 116 const String& getGameName(void); 111 117 112 118 bool _fullScreen; 113 bool _aspectRatio;119 int _aspectRatioMode; 114 120 115 121 bool _use_adlib; 116 122 … … 151 157 int getMidiDriverType(); 152 158 153 159 int parseGraphicsMode(const char *s); 160 int parseAspectRatioMode(const char *s); 154 161 void updateconfig(); 155 162 156 163 protected: -
scummvm/common/scaler.cpp
diff -ur ScummVM+orig/scummvm/common/scaler.cpp ScummVM+hack/scummvm/common/scaler.cpp
old new 658 658 return (uint16)((r & redMask) | (g & greenMask) | (b & blueMask)); 659 659 } 660 660 661 static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int scale, int width) { 662 #if 1 663 // Accurate but slightly slower code 664 while (width--) { 665 *dst++ = interpolate5(*srcA++, *srcB++, scale); 666 } 667 #else 661 static inline void interpolate5LineFast(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int scale, int width) { 668 662 // Not fully accurate, but a bit faster 669 663 670 664 if (width & 1) { … … 693 687 *d++ = INTERPOLATE(*sA++, *sB++); 694 688 } 695 689 } 696 #endif 690 } 691 692 static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int scale, int width) { 693 // Accurate but slightly slower code 694 while (width--) { 695 *dst++ = interpolate5(*srcA++, *srcB++, scale); 696 } 697 697 } 698 698 699 699 void makeRectStretchable(int &x, int &y, int &w, int &h) { … … 710 710 711 711 /** 712 712 * Stretch a 16bpp image vertically by factor 1.2. Used to correct the 713 * aspect -ratio in games using 320x200 pixel graphics with non-qudratic713 * aspect ratio in games using 320x200 pixel graphics with non-qudratic 714 714 * pixels. Applying this method effectively turns that into 320x240, which 715 * provides the correct aspect -ratio on modern displays.715 * provides the correct aspect ratio on modern displays. 716 716 * 717 717 * The image would normally have occupied y coordinates origSrcY through 718 718 * origSrcY + height - 1. … … 724 724 * srcY + height - 1, and it should be stretched to Y coordinates srcY 725 725 * through real2Aspect(srcY + height - 1). 726 726 */ 727 int stretch200To240 (uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) {727 int stretch200To240Sloppy(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 728 728 int maxDstY = real2Aspect(origSrcY + height - 1); 729 729 int off = srcY - origSrcY; 730 730 int y; … … 734 734 for (y = maxDstY; y >= srcY; y--) { 735 735 uint8 *srcPtr = buf + srcX * 2 + (aspect2Real(y) + off) * pitch; 736 736 737 #if 0 738 // Don't use bilinear filtering, rather just duplicate pixel lines: 739 // a little bit faster, but looks ugly 737 // Don't use bilinear filtering, rather just duplicate pixel 738 // lines: a little bit faster, but looks ugly 740 739 if (srcPtr == dstPtr) 741 740 break; 742 741 743 742 memcpy(dstPtr, srcPtr, width * 2); 744 #else 743 dstPtr -= pitch; 744 } 745 746 return 1 + maxDstY - srcY; 747 } 748 749 int stretch200To240Fast(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 750 int maxDstY = real2Aspect(origSrcY + height - 1); 751 int off = srcY - origSrcY; 752 int y; 753 754 uint8 *dstPtr = buf + srcX * 2 + maxDstY * pitch; 755 756 for (y = maxDstY; y >= srcY; y--) { 757 uint8 *srcPtr = buf + srcX * 2 + (aspect2Real(y) + off) * pitch; 758 759 // Bilinear filter 760 switch (y % 6) { 761 case 0: 762 case 5: 763 if (srcPtr != dstPtr) 764 memcpy(dstPtr, srcPtr, width * 2); 765 break; 766 case 1: 767 case 4: 768 interpolate5LineFast((uint16 *)dstPtr, (uint16 *)(srcPtr - pitch), (uint16 *)srcPtr, 1, width); 769 break; 770 case 2: 771 case 3: 772 interpolate5LineFast((uint16 *)dstPtr, (uint16 *)(srcPtr - pitch), (uint16 *)srcPtr, 2, width); 773 break; 774 } 775 dstPtr -= pitch; 776 } 777 778 return 1 + maxDstY - srcY; 779 } 780 781 int stretch200To240Exact(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 782 int maxDstY = real2Aspect(origSrcY + height - 1); 783 int off = srcY - origSrcY; 784 int y; 785 786 uint8 *dstPtr = buf + srcX * 2 + maxDstY * pitch; 787 788 for (y = maxDstY; y >= srcY; y--) { 789 uint8 *srcPtr = buf + srcX * 2 + (aspect2Real(y) + off) * pitch; 790 745 791 // Bilinear filter 746 792 switch (y % 6) { 747 793 case 0: … … 758 804 interpolate5Line((uint16 *)dstPtr, (uint16 *)(srcPtr - pitch), (uint16 *)srcPtr, 2, width); 759 805 break; 760 806 } 761 #endif762 807 dstPtr -= pitch; 763 808 } 764 809 -
scummvm/common/scaler.h
diff -ur ScummVM+orig/scummvm/common/scaler.h ScummVM+hack/scummvm/common/scaler.h
old new 51 51 52 52 extern void makeRectStretchable(int &x, int &y, int &w, int &h); 53 53 54 extern int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY); 54 typedef int StretcherProc(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY); 55 56 #define DECLARE_STRETCHER(x) \ 57 extern int x(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) 58 59 DECLARE_STRETCHER(stretch200To240Sloppy); 60 DECLARE_STRETCHER(stretch200To240Fast); 61 DECLARE_STRETCHER(stretch200To240Exact); 55 62 56 63 enum { 57 64 GFX_NORMAL = 0, … … 73 80 74 81 }; 75 82 83 enum { 84 ASPECT_MIN = 0, 85 86 ASPECT_NONE = 0, 87 ASPECT_SLOPPY = 1, 88 ASPECT_FAST = 2, 89 ASPECT_EXACT = 3, 90 91 ASPECT_MAX = 3 92 }; 76 93 77 94 #endif -
scummvm/common/system.h
diff -ur ScummVM+orig/scummvm/common/system.h ScummVM+hack/scummvm/common/system.h
old new 95 95 PROP_GET_FULLSCREEN = 7, 96 96 PROP_GET_FMOPL_ENV_BITS = 8, 97 97 PROP_GET_FMOPL_EG_ENT = 9, 98 PROP_ TOGGLE_ASPECT_RATIO= 1098 PROP_SET_ASPECT_RATIO_MODE = 10 99 99 }; 100 100 union Property { 101 101 const char *caption; 102 102 int cd_num; 103 103 int gfx_mode; 104 int aspect_ratio_mode; 104 105 bool show_cursor; 105 106 }; 106 107 … … 364 365 /* Factory functions. This means we don't have to include the headers for 365 366 * all backends. 366 367 */ 367 extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen, bool aspect_ratio);368 extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen, int aspect_ratio_mode); 368 369 extern OSystem *OSystem_NULL_create(); 369 370 extern OSystem *OSystem_MorphOS_create(int game_id, int gfx_driver, bool full_screen); 370 371 extern OSystem *OSystem_Dreamcast_create(); -
scummvm/scumm/scummvm.cpp
diff -ur ScummVM+orig/scummvm/scumm/scummvm.cpp ScummVM+hack/scummvm/scumm/scummvm.cpp
old new 586 586 _sound->_sound_volume_sfx = detector->_sfx_volume; 587 587 _sound->_sound_volume_music = detector->_music_volume; 588 588 589 /* Initialize backend */ 590 591 syst->init_size(_screenWidth, _screenHeight); 592 prop.cd_num = detector->_cdrom; 593 if (prop.cd_num >= 0 && (_features & GF_AUDIOTRACKS)) 594 syst->property(OSystem::PROP_OPEN_CD, &prop); 595 589 596 // Override global scaler with any game-specific define 590 597 if (g_config->get("gfx_mode")) { 591 598 prop.gfx_mode = detector->parseGraphicsMode(g_config->get("gfx_mode")); 592 599 syst->property(OSystem::PROP_SET_GFX_MODE, &prop); 593 600 } 594 601 595 / * Initialize backend */596 syst->init_size(_screenWidth, _screenHeight);597 prop.cd_num = detector->_cdrom;598 if (prop.cd_num >= 0 && (_features & GF_AUDIOTRACKS))599 syst->property(OSystem::PROP_OPEN_CD, &prop);602 // Override global aspect ratio correction with any game-specific define 603 if (g_config->get("aspect_ratio")) { 604 prop.aspect_ratio_mode = detector->parseAspectRatioMode(g_config->get("aspect_ratio")); 605 syst->property(OSystem::PROP_SET_ASPECT_RATIO_MODE, &prop); 606 } 600 607 601 608 // Override global fullscreen setting with any game-specific define 602 609 if (g_config->getBool("fullscreen", false)) {