Ticket #9019: 16bit_step1.patch
File 16bit_step1.patch, 5.4 KB (added by , 15 years ago) |
---|
-
backends/platform/sdl/graphics.cpp
408 408 } 409 409 410 410 // 411 // Create the surface that contains the 16 bit game data 412 // 413 _screen16 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 414 16, 415 _hwscreen->format->Rmask, 416 _hwscreen->format->Gmask, 417 _hwscreen->format->Bmask, 418 _hwscreen->format->Amask); 419 if (_screen16 == NULL) 420 error("allocating _screen16 failed"); 421 422 // 411 423 // Create the surface used for the graphics in 16 bit before scaling, and also the overlay 412 424 // 413 425 … … 484 496 } 485 497 486 498 void OSystem_SDL::unloadGFXMode() { 487 if (_screen ) {488 SDL_FreeSurface(_screen );489 _screen = NULL;499 if (_screen16) { 500 SDL_FreeSurface(_screen16); 501 _screen16 = NULL; 490 502 } 491 503 492 504 if (_hwscreen) { … … 519 531 } 520 532 521 533 bool OSystem_SDL::hotswapGFXMode() { 522 if (!_screen )534 if (!_screen16) 523 535 return false; 524 536 525 537 // Keep around the old _screen & _overlayscreen so we can restore the screen data 526 538 // after the mode switch. 527 SDL_Surface *old_screen = _screen ;539 SDL_Surface *old_screen = _screen16; 528 540 SDL_Surface *old_overlayscreen = _overlayscreen; 529 _screen = NULL;541 _screen16 = NULL; 530 542 _overlayscreen = NULL; 531 543 532 544 // Release the HW screen surface … … 544 556 if (!loadGFXMode()) { 545 557 unloadGFXMode(); 546 558 547 _screen = old_screen;559 _screen16 = old_screen; 548 560 _overlayscreen = old_overlayscreen; 549 561 550 562 return false; … … 554 566 SDL_SetColors(_screen, _currentPalette, 0, 256); 555 567 556 568 // Restore old screen content 557 SDL_BlitSurface(old_screen, NULL, _screen , NULL);569 SDL_BlitSurface(old_screen, NULL, _screen16, NULL); 558 570 SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL); 559 571 560 572 // Free the old surfaces … … 636 648 #endif 637 649 638 650 if (!_overlayVisible) { 639 origSurf = _screen ;651 origSurf = _screen16; 640 652 srcSurf = _tmpscreen; 641 653 width = _videoMode.screenWidth; 642 654 height = _videoMode.screenHeight; … … 781 793 assert (_transactionMode == kTransactionNone); 782 794 assert(src); 783 795 784 if (_screen == NULL) {796 if (_screen16 == NULL) { 785 797 warning("OSystem_SDL::copyRectToScreen: _screen == NULL"); 786 798 return; 787 799 } … … 829 841 } 830 842 831 843 // Try to lock the screen surface 832 if (SDL_LockSurface(_screen ) == -1)844 if (SDL_LockSurface(_screen16) == -1) 833 845 error("SDL_LockSurface failed: %s", SDL_GetError()); 834 846 835 byte *dst = (byte *)_screen ->pixels + y * _videoMode.screenWidth + x;847 byte *dst = (byte *)_screen16->pixels + y * _videoMode.screenWidth * 2 + x * 2; 836 848 837 if (_videoMode.screenWidth == pitch && pitch == w ) {838 memcpy(dst, src, h*w );849 if (_videoMode.screenWidth == pitch && pitch == w * 2) { 850 memcpy(dst, src, h*w*2); 839 851 } else { 840 852 do { 841 memcpy(dst, src, w );853 memcpy(dst, src, w * 2); 842 854 src += pitch; 843 dst += _videoMode.screenWidth ;855 dst += _videoMode.screenWidth * 2; 844 856 } while (--h); 845 857 } 846 858 847 859 // Unlock the screen surface 848 SDL_UnlockSurface(_screen );860 SDL_UnlockSurface(_screen16); 849 861 } 850 862 851 863 Graphics::Surface *OSystem_SDL::lockScreen() { … … 859 871 _screenIsLocked = true; 860 872 861 873 // Try to lock the screen surface 862 if (SDL_LockSurface(_screen ) == -1)874 if (SDL_LockSurface(_screen16) == -1) 863 875 error("SDL_LockSurface failed: %s", SDL_GetError()); 864 876 865 _framebuffer.pixels = _screen ->pixels;866 _framebuffer.w = _screen ->w;867 _framebuffer.h = _screen ->h;868 _framebuffer.pitch = _screen ->pitch;869 _framebuffer.bytesPerPixel = 1;877 _framebuffer.pixels = _screen16->pixels; 878 _framebuffer.w = _screen16->w; 879 _framebuffer.h = _screen16->h; 880 _framebuffer.pitch = _screen16->pitch; 881 _framebuffer.bytesPerPixel = 2; 870 882 871 883 return &_framebuffer; 872 884 } … … 879 891 _screenIsLocked = false; 880 892 881 893 // Unlock the screen surface 882 SDL_UnlockSurface(_screen );894 SDL_UnlockSurface(_screen16); 883 895 884 896 // Trigger a full screen update 885 897 _forceFull = true; … … 1054 1066 // since we don't actually set the palette until the screen is updated. 1055 1067 // But it could indicate a programming error, so let's warn about it. 1056 1068 1057 if (!_screen )1058 warning("OSystem_SDL::setPalette: _screen == NULL");1069 if (!_screen16) 1070 warning("OSystem_SDL::setPalette: _screen16 == NULL"); 1059 1071 1060 1072 const byte *b = colors; 1061 1073 uint i; … … 1179 1191 dst.x = dst.y = 1; 1180 1192 src.w = dst.w = _videoMode.screenWidth; 1181 1193 src.h = dst.h = _videoMode.screenHeight; 1182 if (SDL_BlitSurface(_screen , &src, _tmpscreen, &dst) != 0)1194 if (SDL_BlitSurface(_screen16, &src, _tmpscreen, &dst) != 0) 1183 1195 error("SDL_BlitSurface failed: %s", SDL_GetError()); 1184 1196 1185 1197 SDL_LockSurface(_tmpscreen); -
backends/platform/sdl/sdl.cpp
200 200 #ifdef USE_OSD 201 201 _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), 202 202 #endif 203 _hwscreen(0), _screen (0), _tmpscreen(0),203 _hwscreen(0), _screen16(0), _screen(0), _tmpscreen(0), 204 204 _overlayVisible(false), 205 205 _overlayscreen(0), _tmpscreen2(0), 206 206 _samplesPerSec(0), -
backends/platform/sdl/sdl.h
227 227 228 228 // unseen game screen 229 229 SDL_Surface *_screen; 230 SDL_Surface *_screen16; 230 231 231 232 // temporary screen (for scalers) 232 233 SDL_Surface *_tmpscreen;