Ticket #8249: aspect3.diff
File aspect3.diff, 26.9 KB (added by , 21 years ago) |
---|
-
README
RCS file: /cvsroot/scummvm/scummvm/README,v retrieving revision 1.115 diff -u -d -r1.115 README
339 339 340 340 scummvm [OPTIONS] [GAME] 341 341 342 [GAME] - Short name of game to load. For example, 'monkey' for 343 Monkey Island. 342 [GAME] - Short name of game to load. For example, 'monkey' for 343 Monkey Island. 344 345 -p<path> - Path to where the game is installed. Default is Cwd. 346 -x[<num>] - Save game slot to load (default: autosave) 347 -f - Full-screen mode. 348 -g<mode> - Select graphics scaler. See below. 349 -e<mode> - Select sound engine. See below. 350 -a - Enable amiga pal conversion, for playing Amiga 351 versions 352 -q<lang> - Select language. See below. 353 -c<num> - Drive to play cd audio from. E.g., 0 is first drive. 354 -m<num> - Set the music volume, 0-255. Default is '192' 355 -o<num> - Set the master volume, 0-255. Default is '192' 356 -s<num> - Set the sfx volume, 0-255. Default is '192' 357 -t<num> - Set music tempo. 50-200. Default is '100' (percent) 358 -n - Disable subtitles. Use with games that have voice. 359 -y - Set talk speed ('yak option'). Default is '60' 360 -l<file> - Load alternate configuration file 361 -w[<file>] - Write configuration file 362 -v - Show version information and exit 363 -z - Display list of games 364 -b<num> - Start in room <num>. 365 -d[<num>] - Set debug verbosity to <num> 366 -u - Dump scripts if a directory called 'dumps' exists in 367 current directory 368 --multi-midi - enable combination Adlib and native MIDI 369 --native-mt32 - true Roland MT-32 (disable GM emulation) 370 --aspect-ratio - enable aspect ratio correction 344 371 345 -p<path> - Path to where the game is installed. Default is Cwd.346 -x[<num>] - Save game slot to load (default: autosave)347 -f - Full-screen mode.348 -g<mode> - Select graphics scaler. See below.349 -e<mode> - Select sound engine. See below.350 -a - Enable amiga pal conversion, for playing Amiga versions351 -q<lang> - Select language. See below.352 -c<num> - Drive to play cd audio from. E.g., 0 is first drive.353 -m<num> - Set the music volume, 0-255. Default is '192'354 -o<num> - Set the master volume, 0-255. Default is '192'355 -s<num> - Set the sfx volume, 0-255. Default is '192'356 -t<num> - Set music tempo. 50-200. Default is '100' (percent)357 -n - Disable subtitles. Use with games that have voice.358 -y - Set talk speed ('yak option'). Default is '60'359 -l<file> - Load alternate configuration file360 -w[<file>] - Write configuration file361 -v - Show version information and exit362 -z - Display list of games363 -b<num> - Start in room <num>.364 -d[<num>] - Set debug verbosity to <num>365 -u - Dump scripts if a directory called 'dumps' exists in366 current directory367 --multi-midi - enable combination Adlib and native MIDI368 --native-mt32 - true Roland MT-32 (disable GM emulation)369 372 370 373 371 374 Hot Keys: … … 380 383 Ctrl-Alt 0-9 - Switch between graphics filters 381 384 Ctrl-Alt b - Switch beetwen bilinear and non-linear 382 385 filtering [OpenGL backend] 383 Ctrl-Alt a - Switch between: [OpenGL backend] 384 - Fit the game in the whole screen (No black borders) 385 - Don't fit the game in the whole screen (Black borders) 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. 392 386 393 Scumm: 387 394 Ctrl 0-9 and Alt 0-9 - load and save game state 388 395 Ctrl-g - runs in really REALLY fast mode. -
backends/sdl/sdl-common.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v retrieving revision 1.62 diff -u -d -r1.62 sdl-common.cpp
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 ) {45 return OSystem_SDL_Common::create(gfx_mode, full_screen );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); 46 46 } 47 47 48 OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen ) {48 OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen, bool aspect_ratio) { 49 49 OSystem_SDL_Common *syst = OSystem_SDL_Common::create_intern(); 50 50 51 syst->init_intern(gfx_mode, full_screen );51 syst->init_intern(gfx_mode, full_screen, aspect_ratio); 52 52 53 53 return syst; 54 54 } 55 55 56 void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen ) {56 void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect_ratio) { 57 57 58 58 _mode = gfx_mode; 59 59 _full_screen = full_screen; 60 _adjustAspectRatio = aspect_ratio; 60 61 61 62 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) ==-1) { 62 63 error("Could not initialize SDL: %s.\n", SDL_GetError()); … … 129 130 130 131 _screenWidth = w; 131 132 _screenHeight = h; 133 134 if (h != 200) 135 _adjustAspectRatio = false; 136 132 137 CKSUM_NUM = (_screenWidth * _screenHeight / (8 * 8)); 133 138 if (_dirty_checksums) 134 139 free(_dirty_checksums); … … 576 581 } 577 582 } 578 583 579 // Ctr-Alt-a will change aspect ratio in OpenGL backend584 // Ctr-Alt-a will change aspect ratio 580 585 if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='a') { 581 Property prop; 582 prop.gfx_mode = 11; 583 property(PROP_SET_GFX_MODE, &prop); 584 break; 586 property(PROP_TOGGLE_ASPECT_RATIO, NULL); 587 break; 585 588 } 586 589 587 590 // Ctr-Alt-b will change bilinear filtering in OpenGL backend 588 591 if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='b') { 589 590 prop.gfx_mode = 12;591 592 592 Property prop; 593 prop.gfx_mode = GFX_BILINEAR; 594 property(PROP_SET_GFX_MODE, &prop); 595 break; 593 596 } 594 597 595 598 #ifdef QTOPIA … … 698 701 event->mouse.x /= _scaleFactor; 699 702 event->mouse.y /= _scaleFactor; 700 703 704 if (_adjustAspectRatio) 705 event->mouse.y = aspect2Real(event->mouse.y); 701 706 return true; 702 707 703 708 case SDL_MOUSEBUTTONDOWN: … … 718 723 event->mouse.x /= _scaleFactor; 719 724 event->mouse.y /= _scaleFactor; 720 725 726 if (_adjustAspectRatio) 727 event->mouse.y = aspect2Real(event->mouse.y); 728 721 729 return true; 722 730 723 731 case SDL_MOUSEBUTTONUP: … … 731 739 event->mouse.y = ev.button.y; 732 740 event->mouse.x /= _scaleFactor; 733 741 event->mouse.y /= _scaleFactor; 742 743 if (_adjustAspectRatio) 744 event->mouse.y = aspect2Real(event->mouse.y); 745 734 746 return true; 735 747 736 748 case SDL_JOYBUTTONDOWN: … … 835 847 event->mouse.y = km.y; 836 848 event->mouse.x /= _scaleFactor; 837 849 event->mouse.y /= _scaleFactor; 850 851 if (_adjustAspectRatio) 852 event->mouse.y = aspect2Real(event->mouse.y); 853 838 854 return true; 839 855 840 856 case SDL_VIDEOEXPOSE: -
backends/sdl/sdl-common.h
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v retrieving revision 1.27 diff -u -d -r1.27 sdl-common.h
123 123 virtual int16 RGBToColor(uint8 r, uint8 g, uint8 b); 124 124 virtual void colorToRGB(int16 color, uint8 &r, uint8 &g, uint8 &b); 125 125 126 static OSystem *create(int gfx_mode, bool full_screen );126 static OSystem *create(int gfx_mode, bool full_screenm, bool aspect_ratio); 127 127 128 128 protected: 129 129 OSystem_SDL_Common(); … … 131 131 132 132 static OSystem_SDL_Common *create_intern(); 133 133 134 void init_intern(int gfx_mode, bool full_screen );134 void init_intern(int gfx_mode, bool full_screen, bool aspect_ratio); 135 135 136 136 // unseen game screen 137 137 SDL_Surface *_screen; … … 141 141 SDL_Surface *_tmpscreen; 142 142 int _tmpScreenWidth; 143 143 bool _overlayVisible; 144 145 bool _adjustAspectRatio; 144 146 145 147 // CD Audio 146 148 SDL_CD *_cdrom; -
backends/sdl/sdl.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v retrieving revision 1.35 diff -u -d -r1.35 sdl.cpp
147 147 // 148 148 // Create the surface that contains the scaled graphics in 16 bit mode 149 149 // 150 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16, 150 151 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor, 16, 151 152 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 152 153 ); 153 154 if (_hwscreen == NULL) 154 155 error("_hwscreen failed"); 155 156 156 157 // 157 158 // Create the surface used for the graphics in 16 bit before scaling, and also the overlay 158 159 // … … 192 193 SDL_FreeSurface(_hwscreen); 193 194 _hwscreen = NULL; 194 195 } 195 196 196 197 if (_tmpscreen) { 197 198 free(_tmpscreen->pixels); 198 199 SDL_FreeSurface(_tmpscreen); … … 281 282 uint32 srcPitch, dstPitch; 282 283 SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; 283 284 284 if (_scaler_proc == Normal1x ) {285 if (_scaler_proc == Normal1x && !_adjustAspectRatio) { 285 286 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 286 287 for (r = _dirty_rect_list; r != last_rect; ++r) { 287 288 dst = *r; … … 314 315 for (r = _dirty_rect_list; r != last_rect; ++r) { 315 316 register int dst_y = r->y + _currentShakePos; 316 317 register int dst_h = 0; 318 register int orig_dst_y = 0; 319 317 320 if (dst_y < _screenHeight) { 318 321 dst_h = r->h; 319 322 if (dst_h > _screenHeight - dst_y) 320 323 dst_h = _screenHeight - dst_y; 321 324 322 325 dst_y *= _scaleFactor; 323 326 324 _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, 327 if (_adjustAspectRatio) { 328 orig_dst_y = dst_y; 329 dst_y = real2Aspect(dst_y); 330 } 331 332 _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, 325 333 (byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h); 326 334 } 327 335 328 336 r->x *= _scaleFactor; 329 337 r->y = dst_y; 330 338 r->w *= _scaleFactor; 331 339 r->h = dst_h * _scaleFactor; 332 }333 340 341 if (_adjustAspectRatio && orig_dst_y / _scaleFactor < _screenHeight) 342 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); 343 } 334 344 SDL_UnlockSurface(_tmpscreen); 335 345 SDL_UnlockSurface(_hwscreen); 336 346 } … … 339 349 // This is necessary if shaking is active. 340 350 if (_forceFull) { 341 351 _dirty_rect_list[0].y = 0; 342 _dirty_rect_list[0].h = _screenHeight* _scaleFactor;352 _dirty_rect_list[0].h = (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor; 343 353 } 344 354 345 355 // Finally, blit all our changes to the screen … … 374 384 hotswap_gfx_mode(); 375 385 376 386 return 1; 387 } else if (param == PROP_TOGGLE_ASPECT_RATIO) { 388 if (_screenHeight == 200) { 389 assert(_hwscreen != 0); 390 _adjustAspectRatio ^= true; 391 hotswap_gfx_mode(); 392 } 377 393 } 378 394 379 395 return OSystem_SDL_Common::property(param, value); -
backends/sdl/sdl_gl.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v retrieving revision 1.36 diff -u -d -r1.36 sdl_gl.cpp
54 54 int _glFlags; 55 55 int _glScreenStart; 56 56 bool _glBilinearFilter; 57 bool _glAspectRatio;58 57 bool _usingOpenGL; 59 58 SDL_Surface *tmpSurface; // Used for black rectangles blitting 60 59 SDL_Rect tmpBlackRect; // Black rectangle at end of the GL screen … … 79 78 { 80 79 _glScreenStart = 0; 81 80 _glBilinearFilter = true; 82 _glAspectRatio = false;83 81 _usingOpenGL = false; // false => Switch to filters used in the sdl.cpp version 84 82 _glBottomOfTexture = 256; // height is always 256 85 83 // 640x480 resolution … … 165 163 166 164 case GFX_NORMAL: 167 165 normal_mode:; 168 _scaleFactor = 1;166 _scaleFactor = _usingOpenGL ? 2 : 1; 169 167 _scaler_proc = Normal1x; 170 168 break; 171 169 default: … … 199 197 fb2gl.init(_glWindow.w, _glWindow.h, 0, _glScreenStart? 15: 70, 200 198 _glFlags); 201 199 202 } 203 else { // SDL backend 200 } else { // SDL backend 204 201 205 202 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16, 206 203 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE … … 234 231 Gmask, 235 232 Bmask, 236 233 Amask); 237 } 238 else { // SDL backend 234 } else { // SDL backend 239 235 _tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen, 240 236 _tmpScreenWidth, 241 237 _screenHeight + 3, … … 346 342 347 343 SDL_FillRect(tmpSurface, &blackrect, 0); 348 344 fb2gl.blit16(tmpSurface, 1, &blackrect, 0, 0); 349 } 350 else { // SDL backend 345 } else { // SDL backend 351 346 SDL_Rect blackrect = {0, 0, _screenWidth * _scaleFactor, _newShakePos * _scaleFactor}; 352 347 SDL_FillRect(_hwscreen, &blackrect, 0); 353 348 } … … 545 540 #endif 546 541 547 542 return 1; 548 } 549 else if (param == PROP_SET_GFX_MODE) { 543 } else if (param == PROP_TOGGLE_ASPECT_RATIO) { 544 if (!_usingOpenGL) { 545 _usingOpenGL = true; 546 _mode = GFX_NORMAL; 547 hotswap_gfx_mode(); 548 } 549 550 _adjustAspectRatio ^= true; 551 if (_adjustAspectRatio) { 552 // Don't use the whole screen (black borders) 553 fb2gl.init(0, 0, 0, 15, _glFlags); 554 _glScreenStart = 20; 555 SDL_FillRect(tmpSurface, &tmpBlackRect, 0); 556 fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 0); 557 } else { 558 // Use the whole screen 559 fb2gl.init(0, 0, 0, 70, _glFlags); 560 _glScreenStart = 0; 561 } 562 550 563 SDL_Rect full = {0, 0, _screenWidth, _screenHeight}; 564 fb2gl.blit16(_tmpscreen, 1, &full, 0, _glScreenStart); 565 fb2gl.display(); 566 } else if (param == PROP_SET_GFX_MODE) { 551 567 552 568 if (value->gfx_mode > 10) { // OpenGL modes 553 569 if (!_usingOpenGL) { … … 562 578 _glBilinearFilter ^= true; 563 579 fb2gl.setBilinearMode(_glBilinearFilter); 564 580 break; 565 case GFX_ASPECTRATIO:566 _glAspectRatio ^= true;567 if (_glAspectRatio) {568 // Don't use the whole screen (black borders)569 fb2gl.init(0, 0, 0, 15, _glFlags);570 _glScreenStart = 20;571 SDL_FillRect(tmpSurface, &tmpBlackRect, 0);572 fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 0);573 } else {574 // Use the whole screen575 fb2gl.init(0, 0, 0, 70, _glFlags);576 _glScreenStart = 0;577 }578 break;579 581 default: // SDL backend 580 582 if (value->gfx_mode >= 10) 581 583 return 0; … … 589 591 }; 590 592 591 593 if (_usingOpenGL) { 594 SDL_Rect full = {0, 0, _screenWidth, _screenHeight}; 592 595 fb2gl.blit16(_tmpscreen, 1, &full, 0, _glScreenStart); 593 596 fb2gl.display(); 594 597 } -
common/gameDetector.cpp
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v retrieving revision 1.113 diff -u -d -r1.113 gameDetector.cpp
50 50 "Syntax:\n" 51 51 "\tscummvm [-v] [-d[<num>]] [-n] [-b<num>] [-t<num>] [-s<num>] [-p<path>] [-m<num>] [-f] game\n" 52 52 "Flags:\n" 53 "\t-p<path> - look for game in <path>\n"54 "\t-x[<num>] - load this savegame (default: 0 - autosave)\n"55 "\t-f - fullscreen mode\n"56 "\t-g<mode> - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,advmame3x,tv2x,dotmatrix)\n"57 "\t-e<mode> - set music engine (see README for details)\n"58 "\t-a - specify game is amiga version\n"59 "\t-q<lang> - specify language (en,de,fr,it,pt,es,jp,zh,kr,hb)\n"53 "\t-p<path> - look for game in <path>\n" 54 "\t-x[<num>] - load this savegame (default: 0 - autosave)\n" 55 "\t-f - fullscreen mode\n" 56 "\t-g<mode> - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,advmame3x,tv2x,dotmatrix)\n" 57 "\t-e<mode> - set music engine (see README for details)\n" 58 "\t-a - specify game is amiga version\n" 59 "\t-q<lang> - specify language (en,de,fr,it,pt,es,jp,zh,kr,hb)\n" 60 60 "\n" 61 "\t-c<num> - use cdrom <num> for cd audio\n"62 "\t-m<num> - set music volume to <num> (0-255)\n"63 "\t-o<num> - set master volume to <num> (0-255)\n"64 "\t-s<num> - set sfx volume to <num> (0-255)\n"65 "\t-t<num> - set music tempo (50-200, default 100%%)\n"61 "\t-c<num> - use cdrom <num> for cd audio\n" 62 "\t-m<num> - set music volume to <num> (0-255)\n" 63 "\t-o<num> - set master volume to <num> (0-255)\n" 64 "\t-s<num> - set sfx volume to <num> (0-255)\n" 65 "\t-t<num> - set music tempo (50-200, default 100%%)\n" 66 66 "\n" 67 "\t-n - no subtitles for speech\n"68 "\t-y - set text speed (default: 60)\n"67 "\t-n - no subtitles for speech\n" 68 "\t-y - set text speed (default: 60)\n" 69 69 "\n" 70 "\t-l<file> - load config file instead of default\n"70 "\t-l<file> - load config file instead of default\n" 71 71 #if defined(UNIX) 72 "\t-w[<file>] - write to config file [~/.scummvmrc]\n"72 "\t-w[<file>] - write to config file [~/.scummvmrc]\n" 73 73 #else 74 "\t-w[<file>] - write to config file [scummvm.ini]\n"74 "\t-w[<file>] - write to config file [scummvm.ini]\n" 75 75 #endif 76 "\t-v - show version info and exit\n"77 "\t-z - display list of games\n"76 "\t-v - show version info and exit\n" 77 "\t-z - display list of games\n" 78 78 "\n" 79 "\t-b<num> - start in room <num>\n"80 "\t-d[<num>] - enable debug output (debug level [1])\n"81 "\t-u - dump scripts\n"79 "\t-b<num> - start in room <num>\n" 80 "\t-d[<num>] - enable debug output (debug level [1])\n" 81 "\t-u - dump scripts\n" 82 82 "\n" 83 "\t--multi-midi - enable combination Adlib and native MIDI\n" 84 "\t--native-mt32 - true Roland MT-32 (disable GM emulation)\n" 83 "\t--multi-midi - enable combination Adlib and native MIDI\n" 84 "\t--native-mt32 - true Roland MT-32 (disable GM emulation)\n" 85 "\t--aspect-ratio - enable aspect ratio correction\n" 85 86 ; 86 87 #endif 87 88 // This contains a pointer to a list of all supported games. … … 148 149 149 150 GameDetector::GameDetector() { 150 151 _fullScreen = false; 152 _aspectRatio = false; 151 153 152 154 _use_adlib = false; 153 155 … … 245 247 } 246 248 247 249 _fullScreen = g_config->getBool("fullscreen", _fullScreen); 250 _aspectRatio = g_config->getBool("aspect_ratio", _aspectRatio); 248 251 249 252 if ((val = g_config->get("gfx_mode"))) 250 253 if ((_gfx_mode = parseGraphicsMode(val)) == -1) { … … 453 456 } else if (!strcmp (s, "native-mt32")) { 454 457 _native_mt32 = true; 455 458 g_config->setBool ("native_mt32", true); 459 } else if (!strcmp (s, "aspect-ratio")) { 460 _aspectRatio = true; 461 g_config->setBool ("aspect_ratio", true); 456 462 } else { 457 463 goto ShowHelpAndExit; 458 464 } … … 673 679 return OSystem_PALMOS_create(_gfx_mode); 674 680 #else 675 681 /* SDL is the default driver for now */ 676 return OSystem_SDL_create(_gfx_mode, _fullScreen );682 return OSystem_SDL_create(_gfx_mode, _fullScreen, _aspectRatio); 677 683 #endif 678 684 } 679 685 -
common/gameDetector.h
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.h,v retrieving revision 1.45 diff -u -d -r1.45 gameDetector.h
110 110 const String& getGameName(void); 111 111 112 112 bool _fullScreen; 113 bool _aspectRatio; 113 114 114 115 bool _use_adlib; 115 116 -
common/scaler.cpp
RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v retrieving revision 1.21 diff -u -d -r1.21 scaler.cpp
30 30 static uint32 qcolorMask = 0xE79CE79C; 31 31 static uint32 qlowpixelMask = 0x18631863; 32 32 static uint32 redblueMask = 0xF81F; 33 static uint32 greenMask = 0x7E0; 33 static uint32 redMask = 0xF800; 34 static uint32 greenMask = 0x07E0; 35 static uint32 blueMask = 0x001F; 34 36 35 37 static const uint16 dotmatrix_565[16] = { 36 38 0x01E0, 0x0007, 0x3800, 0x0000, … … 53 55 qcolorMask = 0xE79CE79C; 54 56 qlowpixelMask = 0x18631863; 55 57 redblueMask = 0xF81F; 56 greenMask = 0x7E0; 58 redMask = 0xF800; 59 greenMask = 0x07E0; 60 blueMask = 0x001F; 57 61 dotmatrix = dotmatrix_565; 58 62 } else if (BitFormat == 555) { 59 63 colorMask = 0x7BDE7BDE; … … 61 65 qcolorMask = 0x739C739C; 62 66 qlowpixelMask = 0x0C630C63; 63 67 redblueMask = 0x7C1F; 64 greenMask = 0x3E0; 68 redMask = 0x7C00; 69 greenMask = 0x03E0; 70 blueMask = 0x001F; 65 71 dotmatrix = dotmatrix_555; 66 72 } else { 67 73 return 0; … … 631 637 p += nextlineSrc; 632 638 q += nextlineDst << 1; 633 639 } 640 } 641 642 643 static inline uint32 interpolate5(uint16 A, uint16 B, int scale) { 644 uint16 r = ((A & redMask) * scale + (B & redMask) * (5 - scale)) / 5; 645 uint16 g = ((A & greenMask) * scale + (B & greenMask) * (5 - scale)) / 5; 646 uint16 b = ((A & blueMask) * scale + (B & blueMask) * (5 - scale)) / 5; 647 648 return (r & redMask) | (g & greenMask) | (b & blueMask); 649 } 650 651 static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int scale, int width) { 652 #if 0 653 // Accurate but slightly slower code 654 while (width--) { 655 *dst++ = interpolate5(*srcA++, *srcB++, scale); 656 } 657 #else 658 // Not fully accurate, but a bit faster 659 width /= 2; 660 const uint32 *sA = (const uint32 *)srcA; 661 const uint32 *sB = (const uint32 *)srcB; 662 uint32 *d = (uint32 *)dst; 663 if (scale == 1) { 664 while (width--) { 665 uint32 B = *sB++; 666 *d++ = Q_INTERPOLATE(*sA++, B, B, B); 667 } 668 } else { 669 while (width--) { 670 *d++ = INTERPOLATE(*sA++, *sB++); 671 } 672 } 673 #endif 674 } 675 676 /** 677 * Stretch a 16bpp image vertically by factor 1.2. Used to correct the 678 * aspect-ratio in games using 320x200 pixel graphics with non-qudratic 679 * pixels. Applying this method effectively turns that into 320x240, which 680 * provides the correct aspect-ratio on modern displays. 681 * 682 * The image would normally have occupied y coordinates origSrcY through 683 * origSrcY + height - 1. 684 * 685 * However, we have already placed it at srcY - the aspect-corrected y 686 * coordinate - to allow in-place stretching. 687 * 688 * Therefore, the source image now occupies Y coordinates srcY through 689 * srcY + height - 1, and it should be stretched to Y coordinates srcY 690 * through real2Aspect(srcY + height - 1). 691 * 692 * @todo Implement bilinear filtering instead of stupid pixel doubling? 693 * 694 * The theory of bilinear filtering: 695 * 696 * For each destination pixel, calculate its exact scaled position in the 697 * source image. It is unlikely that it will correspond to any one source pixel 698 * so its colour is interpolated from the four surrounding pixels, like so: 699 * 700 * c0| fx |c1 701 * --+-----+---+-- 702 * | | | 703 * fy| | | 704 * +-----X | 705 * | | 706 * --+---------+-- 707 * c2| |c3 708 * 709 * The colour c at X is 710 * 711 * c = c0 * (1-fx) * (1-fy) 712 * + c1 * fx * (1-fy) 713 * + c2 * (1-fx) * fy 714 * + c3 * fx * fy 715 * 716 * We only stretch the height so fx is always 0, which leads to the following, 717 * simplified formula: 718 * 719 * c = c0 * (1-fy) 720 * + c2 * fy 721 * 722 * And it should be possible to pre-calculate fy as well, since the image is 723 * always stretched to the same proportions. 724 */ 725 int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY) { 726 int maxDstY = real2Aspect(origSrcY + height - 1); 727 int off = srcY - origSrcY; 728 int y; 729 730 uint8 *dstPtr = buf + srcX * 2 + maxDstY * pitch; 731 732 for (y = maxDstY; y >= srcY; y--) { 733 uint8 *srcPtr = buf + srcX * 2 + (aspect2Real(y) + off) * pitch; 734 735 if (srcPtr == dstPtr) 736 break; 737 738 #if 0 739 memcpy(dstPtr, srcPtr, width * 2); 740 #else 741 switch (y % 6) { 742 case 0: 743 case 5: 744 memcpy(dstPtr, srcPtr, width * 2); 745 // interpolate5Line((uint16 *)dstPtr, (uint16 *)(srcPtr - pitch), (uint16 *)srcPtr, 0, width); 746 break; 747 case 1: 748 case 4: 749 interpolate5Line((uint16 *)dstPtr, (uint16 *)(srcPtr - pitch), (uint16 *)srcPtr, 1, width); 750 break; 751 case 2: 752 case 3: 753 interpolate5Line((uint16 *)dstPtr, (uint16 *)(srcPtr - pitch), (uint16 *)srcPtr, 2, width); 754 break; 755 } 756 #endif 757 dstPtr -= pitch; 758 } 759 760 return 1 + maxDstY - srcY; 634 761 } -
common/scaler.h
RCS file: /cvsroot/scummvm/scummvm/common/scaler.h,v retrieving revision 1.11 diff -u -d -r1.11 scaler.h
41 41 DECLARE_SCALER(TV2x); 42 42 DECLARE_SCALER(DotMatrix); 43 43 44 FORCEINLINE int real2Aspect(int y) { 45 return y + (y + 1) / 5; 46 } 47 48 FORCEINLINE int aspect2Real(int y) { 49 return (y * 5 + 3) / 6; 50 } 51 52 extern int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY); 44 53 45 54 enum { 46 55 GFX_NORMAL = 0, … … 54 63 GFX_TV2X = 8, 55 64 GFX_DOTMATRIX = 9, 56 65 57 GFX_ASPECTRATIO = 11, // OpenGL backend58 66 GFX_BILINEAR = 12, // OpenGL backend 59 67 60 68 GFX_FLIPPING = 100, // Palmos -
common/system.h
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v retrieving revision 1.32 diff -u -d -r1.32 system.h
94 94 PROP_GET_SAMPLE_RATE = 6, 95 95 PROP_GET_FULLSCREEN = 7, 96 96 PROP_GET_FMOPL_ENV_BITS = 8, 97 PROP_GET_FMOPL_EG_ENT = 9 97 PROP_GET_FMOPL_EG_ENT = 9, 98 PROP_TOGGLE_ASPECT_RATIO = 10 98 99 }; 99 100 union Property { 100 101 const char *caption; … … 363 364 /* Factory functions. This means we don't have to include the headers for 364 365 * all backends. 365 366 */ 366 extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen );367 extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen, bool aspect_ratio); 367 368 extern OSystem *OSystem_NULL_create(); 368 369 extern OSystem *OSystem_MorphOS_create(int game_id, int gfx_driver, bool full_screen); 369 370 extern OSystem *OSystem_Dreamcast_create();