Ticket #8159: alt-aspect-ratio.diff
File alt-aspect-ratio.diff, 20.6 KB (added by , 21 years ago) |
---|
-
scummvm/Makefile.mingw
diff -ur ScummVM+orig/scummvm/Makefile.mingw ScummVM+hack/scummvm/Makefile.mingw
old new 28 28 LDFLAGS := 29 29 INCLUDES:= -I. -Icommon -Iscumm $(SDL_CFLAGS) 30 30 LIBS := $(SDL_LIBS) -lmingw32 -lwinmm -lopengl32 31 OBJS := scummvmico.o backends/sdl/sdl-common.o backends/sdl/sdl _gl.o31 OBJS := scummvmico.o backends/sdl/sdl-common.o backends/sdl/sdl.o 32 32 EXEEXT :=.exe 33 33 34 34 ####################################################################### -
scummvm/README
diff -ur ScummVM+orig/scummvm/README ScummVM+hack/scummvm/README
old new 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: -
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 ) {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 _aspect_ratio = aspect_ratio; 61 62 // With the current aspect-ratio correction method, it's trivial to 63 // calculate the new Y coordinate from the old: 64 // 65 // Ynew = Yold + (Yold + 1) / 5 66 // 67 // Or the old one from the new: 68 // 69 // Yold = (Ynew * 5 + 3) / 6 70 // 71 // But that may change if we implement a better method. 60 72 61 73 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) ==-1) { 62 74 error("Could not initialize SDL: %s.\n", SDL_GetError()); … … 129 141 130 142 _screenWidth = w; 131 143 _screenHeight = h; 144 145 if (h != 200) 146 _aspect_ratio = false; 147 132 148 CKSUM_NUM = (_screenWidth * _screenHeight / (8 * 8)); 133 149 if (_dirty_checksums) 134 150 free(_dirty_checksums); … … 220 236 // FIXME - calling copy_rect repeatedly is horribly inefficient, as it (un)locks the surface repeatedly 221 237 // and it performs unneeded clipping checks etc. 222 238 // Furthermore, this code is not correct, techincally: the pixels members of an SDLSource may be 0 223 // while it is not locked (e.g. for HW surfaces which are stored in the graphic card's VRAM).239 // while it is not locked (e.g. for HW surfaces which are stored in the xgraphic card's VRAM). 224 240 225 241 // vertical movement 226 242 if (dy > 0) { … … 576 592 } 577 593 } 578 594 579 // Ctr-Alt-a will change aspect ratio in OpenGL backend595 // Ctr-Alt-a will change aspect ratio 580 596 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; 597 property(PROP_TOGGLE_ASPECT_RATIO, NULL); 598 break; 585 599 } 586 600 587 601 // Ctr-Alt-b will change bilinear filtering in OpenGL backend 588 602 if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='b') { 589 590 591 592 603 Property prop; 604 prop.gfx_mode = 12; 605 property(PROP_SET_GFX_MODE, &prop); 606 break; 593 607 } 594 608 595 609 #ifdef QTOPIA … … 698 712 event->mouse.x /= _scaleFactor; 699 713 event->mouse.y /= _scaleFactor; 700 714 715 if (_aspect_ratio) 716 event->mouse.y = (event->mouse.y * 5 + 3) / 6; 701 717 return true; 702 718 703 719 case SDL_MOUSEBUTTONDOWN: … … 718 734 event->mouse.x /= _scaleFactor; 719 735 event->mouse.y /= _scaleFactor; 720 736 737 if (_aspect_ratio) 738 event->mouse.y = (event->mouse.y * 5 + 3) / 6; 739 721 740 return true; 722 741 723 742 case SDL_MOUSEBUTTONUP: … … 731 750 event->mouse.y = ev.button.y; 732 751 event->mouse.x /= _scaleFactor; 733 752 event->mouse.y /= _scaleFactor; 753 754 if (_aspect_ratio) 755 event->mouse.y = (event->mouse.y * 5 + 3) / 6; 756 734 757 return true; 735 758 736 759 case SDL_JOYBUTTONDOWN: … … 835 858 event->mouse.y = km.y; 836 859 event->mouse.x /= _scaleFactor; 837 860 event->mouse.y /= _scaleFactor; 861 862 if (_aspect_ratio) 863 event->mouse.y = (event->mouse.y * 5 + 3) / 6; 864 838 865 return true; 839 866 840 867 case SDL_VIDEOEXPOSE: -
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 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; … … 142 142 int _tmpScreenWidth; 143 143 bool _overlayVisible; 144 144 145 bool _aspect_ratio; 146 145 147 // CD Audio 146 148 SDL_CD *_cdrom; 147 149 int cd_track, cd_num_loops, cd_start_frame, cd_end_frame; -
scummvm/backends/sdl/sdl.cpp
diff -ur ScummVM+orig/scummvm/backends/sdl/sdl.cpp ScummVM+hack/scummvm/backends/sdl/sdl.cpp
old new 42 42 SDL_Surface *_hwscreen; // hardware screen 43 43 44 44 ScalerProc *_scaler_proc; 45 uint16 *_render_buffer; 45 46 46 47 virtual void load_gfx_mode(); 47 48 virtual void unload_gfx_mode(); … … 53 54 } 54 55 55 56 OSystem_SDL::OSystem_SDL() 56 : _hwscreen(0), _scaler_proc(0) 57 : _hwscreen(0), _scaler_proc(0), _render_buffer(0) 57 58 { 58 59 } 59 60 … … 147 148 // 148 149 // Create the surface that contains the scaled graphics in 16 bit mode 149 150 // 150 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16, 151 152 _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, (_aspect_ratio ? 240 : _screenHeight) * _scaleFactor, 16, 151 153 _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE 152 154 ); 153 155 if (_hwscreen == NULL) 154 156 error("_hwscreen failed"); 157 158 // 159 // Intermediate rendering buffer for aspect ratio correction. 160 // 161 if (_aspect_ratio) 162 _render_buffer = (uint16 *) calloc(sizeof(uint16), _screenWidth * _scaleFactor * 240 * _scaleFactor); 155 163 156 164 // 157 165 // Create the surface used for the graphics in 16 bit before scaling, and also the overlay … … 192 200 SDL_FreeSurface(_hwscreen); 193 201 _hwscreen = NULL; 194 202 } 203 204 if (_render_buffer) { 205 free(_render_buffer); 206 _render_buffer = NULL; 207 } 195 208 196 209 if (_tmpscreen) { 197 210 free(_tmpscreen->pixels); … … 214 227 // Release the HW screen surface 215 228 SDL_FreeSurface(_hwscreen); 216 229 230 if (_render_buffer) { 231 free(_render_buffer); 232 _render_buffer = NULL; 233 } 234 217 235 // Setup the new GFX mode 218 236 load_gfx_mode(); 219 237 … … 281 299 uint32 srcPitch, dstPitch; 282 300 SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; 283 301 284 if (_scaler_proc == Normal1x ) {302 if (_scaler_proc == Normal1x && !_aspect_ratio) { 285 303 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 286 304 for(r = _dirty_rect_list; r != last_rect; ++r) { 287 305 dst = *r; … … 308 326 SDL_LockSurface(_tmpscreen); 309 327 SDL_LockSurface(_hwscreen); 310 328 329 byte *dstPtr = (byte *) (_aspect_ratio ? _render_buffer : _hwscreen->pixels); 330 311 331 srcPitch = _tmpscreen->pitch; 312 332 dstPitch = _hwscreen->pitch; 313 333 … … 319 339 if (dst_h > _screenHeight - dst_y) 320 340 dst_h = _screenHeight - dst_y; 321 341 322 342 dst_y *= _scaleFactor; 323 343 324 325 (byte *)_hwscreen->pixels+ r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);344 _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, 345 dstPtr + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h); 326 346 } 327 347 328 348 r->x *= _scaleFactor; 329 349 r->y = dst_y; 330 350 r->w *= _scaleFactor; 331 351 r->h = dst_h * _scaleFactor; 332 }333 352 353 // FIXME: This is a quite stupid stretching 354 // algorithm. Bilinear filtering is said to be 355 // much better. 356 // 357 // The idea of bilinear filtering: 358 // 359 // c0| fx |c1 360 // --+-----+---+-- 361 // | | | 362 // fy| | | 363 // +-----X | 364 // | | 365 // --+---------+-- 366 // c2| |c3 367 // 368 // The colour c at X is 369 // 370 // c = c0 * (1-fx) * (1-fy) 371 // + c1 * fx * (1-fy) 372 // + c2 * (1-fx) * fy 373 // + c3 * fx * fy 374 // 375 // However, we only stretch the height 376 // so fx is always 0, which leads to 377 // the following, simpler, formula: 378 // 379 // c = c0 * (1-fy) + c2 * fy 380 // 381 // But I'm not going to do that right now. 382 383 if (_aspect_ratio) { 384 byte *s = (byte *) _render_buffer + r->x * 2 + r->y * dstPitch; 385 byte *d; 386 int extra_lines = 0; 387 int y, y2, y3; 388 389 y3 = r->y + (r->y + 1) / 5; 390 391 for (y = 0; y < r->h; y++) { 392 y2 = r->y + y + (r->y + y + 1) / 5; 393 d = (byte *) _hwscreen->pixels + r->x * 2 + y2 * dstPitch; 394 memcpy(d, s, r->w * 2); 395 396 if (y2 - y3 > 1) { 397 memcpy(d - dstPitch, s, r->w * 2); 398 extra_lines++; 399 } 400 401 y3 = y2; 402 s += dstPitch; 403 } 404 405 r->h += extra_lines; 406 r->y += ((r->y + 1) / 5); 407 } 408 } 334 409 SDL_UnlockSurface(_tmpscreen); 335 410 SDL_UnlockSurface(_hwscreen); 336 411 } … … 339 414 // This is necessary if shaking is active. 340 415 if (_forceFull) { 341 416 _dirty_rect_list[0].y = 0; 342 _dirty_rect_list[0].h = _screenHeight* _scaleFactor;417 _dirty_rect_list[0].h = (_aspect_ratio ? 240 : _screenHeight) * _scaleFactor; 343 418 } 344 419 345 420 // Finally, blit all our changes to the screen … … 374 449 hotswap_gfx_mode(); 375 450 376 451 return 1; 452 } else if (param == PROP_TOGGLE_ASPECT_RATIO) { 453 if (_screenHeight == 200) { 454 assert(_hwscreen != 0); 455 _aspect_ratio ^= true; 456 hotswap_gfx_mode(); 457 } 377 458 } 378 379 459 return OSystem_SDL_Common::property(param, value); 380 460 } 381 461 -
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 107 107 108 108 void OSystem_SDL_OpenGL::load_gfx_mode() { 109 109 uint32 Rmask, Gmask, Bmask, Amask; 110 111 // HACK: The OpenGL backend has its own handling of aspect ratio 112 _aspect_ratio = false; 113 110 114 // I have to force 16 bit color depth with 565 ordering 111 115 // SDL_SetVideoMode sometimes doesn't accept your color depth definition 112 116 Rmask = 0xF800; // 5 … … 520 524 */ 521 525 522 526 uint32 OSystem_SDL_OpenGL::property(int param, Property *value) { 527 Property prop; 523 528 int i; 524 529 530 if (param == PROP_TOGGLE_ASPECT_RATIO) { 531 param = PROP_SET_GFX_MODE; 532 prop.gfx_mode = 12; 533 value = ∝ 534 } 535 525 536 if (param == PROP_TOGGLE_FULLSCREEN) { 526 537 if (!_usingOpenGL) 527 538 assert(_hwscreen != 0); -
scummvm/common/gameDetector.cpp
diff -ur ScummVM+orig/scummvm/common/gameDetector.cpp ScummVM+hack/scummvm/common/gameDetector.cpp
old new 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 -
scummvm/common/gameDetector.h
diff -ur ScummVM+orig/scummvm/common/gameDetector.h ScummVM+hack/scummvm/common/gameDetector.h
old new 110 110 const String& getGameName(void); 111 111 112 112 bool _fullScreen; 113 bool _aspectRatio; 113 114 114 115 bool _use_adlib; 115 116 -
scummvm/common/system.h
diff -ur ScummVM+orig/scummvm/common/system.h ScummVM+hack/scummvm/common/system.h
old new 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();