Ticket #8250: aspect-modes.diff
File aspect-modes.diff, 26.9 KB (added by , 22 years ago) |
---|
-
scummvm/README
diff -ur ScummVM-cvs20030624/scummvm/README ScummVM-cvs20030624+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-cvs20030624/scummvm/backends/sdl/sdl-common.cpp ScummVM-cvs20030624+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-cvs20030624/scummvm/backends/sdl/sdl-common.h ScummVM-cvs20030624+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-cvs20030624/scummvm/backends/sdl/sdl.cpp ScummVM-cvs20030624+hack/scummvm/backends/sdl/sdl.cpp
old new 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 … … 134 134 break; 135 135 default: 136 136 error("unknown gfx mode %d", _mode); 137 _scaleFactor = 1; 138 _scaler_proc = NULL; 137 } 138 139 switch (_aspectRatioMode) { 140 case ASPECT_NONE: 141 _stretcher_proc = NULL; 142 break; 143 case ASPECT_SLOPPY: 144 _stretcher_proc = stretch200To240Sloppy; 145 break; 146 case ASPECT_FAST: 147 _stretcher_proc = stretch200To240Fast; 148 break; 149 case ASPECT_EXACT: 150 _stretcher_proc = stretch200To240Exact; 151 break; 152 default: 153 error("unknown aspect ratio mode %d", _aspectRatioMode); 139 154 } 140 155 141 156 // … … 149 164 // Create the surface that contains the scaled graphics in 16 bit mode 150 165 // 151 166 152 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor, 16,167 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor, 16, 153 168 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 154 169 ); 155 170 if (_hwscreen == NULL) … … 283 298 uint32 srcPitch, dstPitch; 284 299 SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; 285 300 286 if (_scaler_proc == Normal1x && !_adjustAspectRatio) {301 if (_scaler_proc == Normal1x && _aspectRatioMode == ASPECT_NONE) { 287 302 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 288 303 for (r = _dirty_rect_list; r != last_rect; ++r) { 289 304 dst = *r; … … 325 340 326 341 dst_y *= _scaleFactor; 327 342 328 if (_a djustAspectRatio) {343 if (_aspectRatioMode != ASPECT_NONE) { 329 344 orig_dst_y = dst_y; 330 345 dst_y = real2Aspect(dst_y); 331 346 } … … 339 354 r->w *= _scaleFactor; 340 355 r->h = dst_h * _scaleFactor; 341 356 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);357 if (_stretcher_proc && orig_dst_y / _scaleFactor < _screenHeight) 358 r->h = _stretcher_proc((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); 344 359 } 345 360 SDL_UnlockSurface(_tmpscreen); 346 361 SDL_UnlockSurface(_hwscreen); … … 350 365 // This is necessary if shaking is active. 351 366 if (_forceFull) { 352 367 _dirty_rect_list[0].y = 0; 353 _dirty_rect_list[0].h = ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor;368 _dirty_rect_list[0].h = ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor; 354 369 } 355 370 356 371 // Finally, blit all our changes to the screen … … 385 400 hotswap_gfx_mode(); 386 401 387 402 return 1; 388 } else if (param == PROP_ TOGGLE_ASPECT_RATIO) {403 } else if (param == PROP_SET_ASPECT_RATIO_MODE) { 389 404 if (_screenHeight == 200) { 390 assert(_hwscreen != 0); 391 _adjustAspectRatio ^= true; 405 _aspectRatioMode = value->aspect_ratio_mode; 392 406 hotswap_gfx_mode(); 393 407 } 394 408 } -
scummvm/backends/sdl/sdl_gl.cpp
diff -ur ScummVM-cvs20030624/scummvm/backends/sdl/sdl_gl.cpp ScummVM-cvs20030624+hack/scummvm/backends/sdl/sdl_gl.cpp
old new 63 63 SDL_Surface *_hwscreen; // hardware screen (=> _usingOpenGL == false) 64 64 65 65 ScalerProc *_scaler_proc; 66 StretcherProc *_stretcher_proc; 66 67 67 68 virtual void load_gfx_mode(); 68 69 virtual void unload_gfx_mode(); … … 74 75 } 75 76 76 77 OSystem_SDL_OpenGL::OSystem_SDL_OpenGL() 77 : _hwscreen(0), _scaler_proc(0) 78 : _hwscreen(0), _scaler_proc(0), _stretcher_proc(0) 78 79 { 79 80 _glScreenStart = 0; 80 81 _glBilinearFilter = true; … … 178 179 } 179 180 180 181 if (_mode != GFX_NORMAL) 181 182 _usingOpenGL = false; 182 183 184 switch (_aspectRatioMode) { 185 case ASPECT_NONE: 186 _stretcher_proc = NULL; 187 break; 188 case ASPECT_SLOPPY: 189 _stretcher_proc = stretch200To240Sloppy; 190 break; 191 case ASPECT_FAST: 192 _stretcher_proc = stretch200To240Fast; 193 break; 194 case ASPECT_EXACT: 195 _stretcher_proc = stretch200To240Exact; 196 break; 197 default: 198 error("unknown aspect ratio mode %d", _aspectRatioMode); 199 } 200 183 201 // 184 202 // Create the surface that contains the 8 bit game data 185 203 // … … 203 221 204 222 } else { // SDL backend 205 223 206 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor, 16,224 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor, 16, 207 225 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 208 226 ); 209 227 if (_hwscreen == NULL) … … 425 443 fb2gl.display(); 426 444 } else { // SDL backend 427 445 428 if (_scaler_proc == Normal1x && !_adjustAspectRatio) {446 if (_scaler_proc == Normal1x && _aspectRatioMode == ASPECT_NONE) { 429 447 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 430 448 for (r = _dirty_rect_list; r != last_rect; ++r) { 431 449 dst = *r; … … 467 485 468 486 dst_y *= _scaleFactor; 469 487 470 if (_a djustAspectRatio) {488 if (_aspectRatioMode != ASPECT_NONE) { 471 489 orig_dst_y = dst_y; 472 490 dst_y = real2Aspect(dst_y); 473 491 } … … 481 499 r->w *= _scaleFactor; 482 500 r->h = dst_h * _scaleFactor; 483 501 484 if (_ adjustAspectRatio&& orig_dst_y / _scaleFactor < _screenHeight)485 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y);502 if (_stretcher_proc && orig_dst_y / _scaleFactor < _screenHeight) 503 r->h = _stretcher_proc((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); 486 504 } 487 505 488 506 SDL_UnlockSurface(_tmpscreen); … … 493 511 // This is necessary if shaking is active. 494 512 if (_forceFull) { 495 513 _dirty_rect_list[0].y = 0; 496 _dirty_rect_list[0].h = ( _adjustAspectRatio? 240 : _screenHeight) * _scaleFactor;514 _dirty_rect_list[0].h = ((_aspectRatioMode != ASPECT_NONE) ? 240 : _screenHeight) * _scaleFactor; 497 515 } 498 516 499 517 // Finally, blit all our changes to the screen … … 555 573 #endif 556 574 557 575 return 1; 558 } else if (param == PROP_TOGGLE_ASPECT_RATIO) { 559 560 _adjustAspectRatio ^= true; 576 } else if (param == PROP_SET_ASPECT_RATIO_MODE) { 561 577 if (_usingOpenGL) { 562 if (_adjustAspectRatio) { 578 // OpenGL has only two aspect ratio correction modes. 579 if (value->aspect_ratio_mode == ASPECT_MIN) 580 _aspectRatioMode = ASPECT_MIN; 581 else 582 _aspectRatioMode = ASPECT_MAX; 583 if (_aspectRatioMode != ASPECT_NONE) { 563 584 // Don't use the whole screen (black borders) 564 585 fb2gl.init(0, 0, 0, 15, _glFlags); 565 586 _glScreenStart = 20; … … 576 597 fb2gl.display(); 577 598 } else { 578 599 if (_screenHeight == 200) { 579 assert(_hwscreen != 0);600 _aspectRatioMode = value->aspect_ratio_mode; 580 601 hotswap_gfx_mode(); 581 602 } 582 603 } -
scummvm/common/gameDetector.cpp
diff -ur ScummVM-cvs20030624/scummvm/common/gameDetector.cpp ScummVM-cvs20030624+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-cvs20030624/scummvm/common/gameDetector.h ScummVM-cvs20030624+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-cvs20030624/scummvm/common/scaler.cpp ScummVM-cvs20030624+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-cvs20030624/scummvm/common/scaler.h ScummVM-cvs20030624+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-cvs20030624/scummvm/common/system.h ScummVM-cvs20030624+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-cvs20030624/scummvm/scumm/scummvm.cpp ScummVM-cvs20030624+hack/scummvm/scumm/scummvm.cpp
old new 590 590 _sound->_sound_volume_sfx = detector->_sfx_volume; 591 591 _sound->_sound_volume_music = detector->_music_volume; 592 592 593 /* Initialize backend */ 594 595 syst->init_size(_screenWidth, _screenHeight); 596 prop.cd_num = detector->_cdrom; 597 if (prop.cd_num >= 0 && (_features & GF_AUDIOTRACKS)) 598 syst->property(OSystem::PROP_OPEN_CD, &prop); 599 593 600 // Override global scaler with any game-specific define 594 601 if (g_config->get("gfx_mode")) { 595 602 prop.gfx_mode = detector->parseGraphicsMode(g_config->get("gfx_mode")); 596 603 syst->property(OSystem::PROP_SET_GFX_MODE, &prop); 597 604 } 598 605 599 / * Initialize backend */600 syst->init_size(_screenWidth, _screenHeight);601 prop.cd_num = detector->_cdrom;602 if (prop.cd_num >= 0 && (_features & GF_AUDIOTRACKS))603 syst->property(OSystem::PROP_OPEN_CD, &prop);606 // Override global aspect ratio correction with any game-specific define 607 if (g_config->get("aspect_ratio")) { 608 prop.aspect_ratio_mode = detector->parseAspectRatioMode(g_config->get("aspect_ratio")); 609 syst->property(OSystem::PROP_SET_ASPECT_RATIO_MODE, &prop); 610 } 604 611 605 612 // Override global fullscreen setting with any game-specific define 606 613 if (g_config->getBool("fullscreen", false)) {