Ticket #8353: overlay.v2.diff
File overlay.v2.diff, 32.8 KB (added by , 20 years ago) |
---|
-
backends/sdl/events.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/events.cpp,v retrieving revision 1.7 diff -u -r1.7 events.cpp
79 79 km.y = y; 80 80 81 81 // Adjust for the screen scaling 82 event.mouse.x /= _scaleFactor; 83 event.mouse.y /= _scaleFactor; 82 if (!_overlayVisible) { 83 event.mouse.x /= _scaleFactor; 84 event.mouse.y /= _scaleFactor; 85 } else { 86 event.mouse.x = event.mouse.x * _scaleFactor / _overlayScale; 87 event.mouse.y = event.mouse.y * _scaleFactor / _overlayScale; 88 } 84 89 85 90 // Optionally perform aspect ratio adjusting 86 91 if (_adjustAspectRatio) … … 300 305 if (ev.key.keysym.sym == SDLK_EQUALS || ev.key.keysym.sym == SDLK_PLUS || ev.key.keysym.sym == SDLK_MINUS || 301 306 ev.key.keysym.sym == SDLK_KP_PLUS || ev.key.keysym.sym == SDLK_KP_MINUS) { 302 307 factor += (ev.key.keysym.sym == SDLK_MINUS || ev.key.keysym.sym == SDLK_KP_MINUS) ? -1 : +1; 303 if (0 <= factor && factor < 4 && s_gfxModeSwitchTable[_scalerType][factor] >= 0) { 308 if (0 <= factor && factor < 4 && s_gfxModeSwitchTable[_scalerType][factor] >= 0 309 && factor >= _overlayScale-1) { 304 310 newMode = s_gfxModeSwitchTable[_scalerType][factor]; 305 311 } 306 312 } -
backends/sdl/graphics.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v retrieving revision 1.11 diff -u -r1.11 graphics.cpp
41 41 {0, 0, 0} 42 42 }; 43 43 44 // Scalers used for overlay scaler 45 // [_overlayScale-1][_scaleFactor-1] 46 static ScalerProc *overlayScalers[3][3] = { 47 { Normal1x, Normal2x, Normal3x }, // [1] 1 2 3 48 { 0, Normal1x, Normal1o5x }, // [2] 1 2 3 49 { 0, 0, Normal1x } 50 }; 51 44 52 const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { 45 53 return s_supportedGraphicsModes; 46 54 } … … 135 143 return _mode; 136 144 } 137 145 138 void OSystem_SDL::initSize(uint w, uint h ) {146 void OSystem_SDL::initSize(uint w, uint h, uint overlayScale) { 139 147 // Avoid redundant res changes 140 if ((int)w == _screenWidth && (int)h == _screenHeight )148 if ((int)w == _screenWidth && (int)h == _screenHeight && (int)overlayScale == _overlayScale) 141 149 return; 142 150 143 151 _screenWidth = w; … … 146 154 if (h != 200) 147 155 _adjustAspectRatio = false; 148 156 157 _overlayScale = overlayScale; 158 if (w != 320) 159 _overlayScale = 1; 160 161 _overlayWidth = w * _overlayScale; 162 _overlayHeight = h * _overlayScale; 163 149 164 CKSUM_NUM = (_screenWidth * _screenHeight / (8 * 8)); 150 165 151 166 free(_dirty_checksums); … … 155 170 156 171 unload_gfx_mode(); 157 172 load_gfx_mode(); 173 174 // if initSize() gets called in the middle, overlay is not transparent 175 clearOverlay(); 158 176 } 159 177 160 178 void OSystem_SDL::load_gfx_mode() { 161 179 _forceFull = true; 162 180 _mode_flags |= DF_UPDATE_EXPAND_1_PIXEL; 163 164 _tmpscreen = NULL;165 181 166 182 // 167 183 // Create the surface that contains the 8 bit game data 168 184 // 169 185 _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0); 170 186 if (_screen == NULL) 171 error("allocating _screen failed ");187 error("allocating _screen failed: %s", SDL_GetError()); 172 188 173 189 // 174 190 // Create the surface that contains the scaled graphics in 16 bit mode … … 209 225 InitScalers(565); 210 226 211 227 // Need some extra bytes around when using 2xSaI 212 _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, 213 _screenWidth + 3, 214 _screenHeight + 3, 228 _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 16, 0, 0, 0, 0); 229 230 if (_tmpscreen == NULL) 231 error("allocating _tmpscreen failed"); 232 233 _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 234 _overlayWidth, 235 _overlayHeight, 215 236 16, 216 237 _hwscreen->format->Rmask, 217 238 _hwscreen->format->Gmask, 218 239 _hwscreen->format->Bmask, 219 240 _hwscreen->format->Amask); 220 241 221 if (_tmpscreen == NULL) 222 error("allocating _tmpscreen failed"); 223 242 if (_overlayscreen == NULL) 243 error("allocating _overlayscreen failed"); 244 SDL_SetColorKey(_overlayscreen, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOverlayColorKey); 245 246 int tmpheight = _overlayHeight * _scaleFactor / _overlayScale; 247 if (_adjustAspectRatio) 248 tmpheight = real2Aspect(tmpheight); 249 _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 250 _overlayWidth * _scaleFactor / _overlayScale, 251 tmpheight, 252 16, 253 _hwscreen->format->Rmask, 254 _hwscreen->format->Gmask, 255 _hwscreen->format->Bmask, 256 _hwscreen->format->Amask); 257 258 if (_tmpscreen2 == NULL) 259 error("allocating _tmpscreen2 failed"); 260 SDL_SetColorKey(_tmpscreen2, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOverlayColorKey); 261 224 262 #ifdef USE_OSD 225 263 _osdSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 226 264 _hwscreen->w, … … 258 296 _tmpscreen = NULL; 259 297 } 260 298 299 if (_tmpscreen2) { 300 SDL_FreeSurface(_tmpscreen2); 301 _tmpscreen2 = NULL; 302 } 303 304 if (_overlayscreen) { 305 SDL_FreeSurface(_overlayscreen); 306 _overlayscreen = NULL; 307 } 308 261 309 #ifdef USE_OSD 262 310 if (_osdSurface) { 263 311 SDL_FreeSurface(_osdSurface); … … 270 318 if (!_screen) 271 319 return; 272 320 273 // Keep around the old _screen & _ tmpscreen so we can restore the screen data321 // Keep around the old _screen & _overlayscreen so we can restore the screen data 274 322 // after the mode switch. 275 323 SDL_Surface *old_screen = _screen; 276 SDL_Surface *old_ tmpscreen = _tmpscreen;324 SDL_Surface *old_overlayscreen = _overlayscreen; 277 325 278 326 // Release the HW screen surface 279 327 SDL_FreeSurface(_hwscreen); 280 328 329 SDL_FreeSurface(_tmpscreen); 330 SDL_FreeSurface(_tmpscreen2); 331 281 332 #ifdef USE_OSD 282 333 // Release the OSD surface 283 334 SDL_FreeSurface(_osdSurface); … … 291 342 292 343 // Restore old screen content 293 344 SDL_BlitSurface(old_screen, NULL, _screen, NULL); 294 SDL_BlitSurface(old_tmpscreen, NULL, _tmpscreen, NULL); 345 346 // FIXME: for some reason simple blit doesn't keep keycolor transparency 347 SDL_LockSurface(_overlayscreen); 348 SDL_LockSurface(old_overlayscreen); 349 Normal1x((byte *)old_overlayscreen->pixels, old_overlayscreen->pitch, 350 (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _overlayWidth, _overlayHeight); 351 SDL_UnlockSurface(_overlayscreen); 352 SDL_UnlockSurface(old_overlayscreen); 295 353 296 354 // Free the old surfaces 297 355 SDL_FreeSurface(old_screen); 298 SDL_FreeSurface(old_ tmpscreen);356 SDL_FreeSurface(old_overlayscreen); 299 357 300 358 // Blit everything to the screen 301 359 internUpdateScreen(); … … 380 438 uint32 srcPitch, dstPitch; 381 439 SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; 382 440 383 if (_scaler_proc == Normal1x && !_adjustAspectRatio) { 384 SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; 441 if (_scaler_proc == Normal1x && !_adjustAspectRatio && 0) { 385 442 for (r = _dirty_rect_list; r != last_rect; ++r) { 386 443 dst = *r; 387 444 388 if (_overlayVisible) {389 // FIXME: I don't understand why this is necessary...390 dst.x--;391 dst.y--;392 }393 445 dst.y += _currentShakePos; 394 if (SDL_BlitSurface( target, r, _hwscreen, &dst) != 0)446 if (SDL_BlitSurface(_screen, r, _hwscreen, &dst) != 0) 395 447 error("SDL_BlitSurface failed: %s", SDL_GetError()); 396 448 } 449 if (SDL_BlitSurface(_overlayscreen, 0, _hwscreen, 0) != 0) 450 error("SDL_BlitSurface failed: %s", SDL_GetError()); 397 451 } else { 398 if (!_overlayVisible) { 399 for (r = _dirty_rect_list; r != last_rect; ++r) { 400 dst = *r; 401 dst.x++; // Shift rect by one since 2xSai needs to acces the data around 402 dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. 403 if (SDL_BlitSurface(_screen, r, _tmpscreen, &dst) != 0) 404 error("SDL_BlitSurface failed: %s", SDL_GetError()); 405 } 452 for (r = _dirty_rect_list; r != last_rect; ++r) { 453 dst = *r; 454 dst.x++; // Shift rect by one since 2xSai needs to acces the data around 455 dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. 456 if (SDL_BlitSurface(_screen, r, _tmpscreen, &dst) != 0) 457 error("SDL_BlitSurface failed: %s", SDL_GetError()); 406 458 } 407 459 408 460 SDL_LockSurface(_tmpscreen); … … 439 491 440 492 if (_adjustAspectRatio && orig_dst_y / _scaleFactor < _screenHeight) 441 493 r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); 494 442 495 } 443 496 SDL_UnlockSurface(_tmpscreen); 444 497 SDL_UnlockSurface(_hwscreen); 498 499 srcPitch = _overlayscreen->pitch; 500 dstPitch = _tmpscreen2->pitch; 501 502 SDL_LockSurface(_tmpscreen2); 503 SDL_LockSurface(_overlayscreen); 504 (overlayScalers[_overlayScale-1][_scaleFactor-1])((byte *)_overlayscreen->pixels, srcPitch, 505 (byte *)_tmpscreen2->pixels, dstPitch, _overlayWidth, _overlayHeight); 506 if (_adjustAspectRatio) 507 stretch200To240((uint8 *)_tmpscreen2->pixels, _tmpscreen2->pitch, 508 _overlayWidth * _scaleFactor / _overlayScale, _overlayHeight * _scaleFactor / _overlayScale, 509 0, 0, 0); 510 511 SDL_UnlockSurface(_tmpscreen2); 512 SDL_UnlockSurface(_overlayscreen); 513 if (SDL_BlitSurface(_tmpscreen2, 0, _hwscreen, 0) != 0) 514 error("SDL_BlitSurface failed: %s", SDL_GetError()); 445 515 } 446 516 447 517 // Readjust the dirty rect list in case we are doing a full update. … … 813 883 undraw_mouse(); 814 884 815 885 _overlayVisible = false; 886 clearOverlay(); 816 887 _forceFull = true; 817 888 } 818 889 819 890 void OSystem_SDL::clearOverlay() { 820 if (!_overlayVisible)821 return;822 823 891 Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends 824 892 825 893 // hide the mouse 826 894 undraw_mouse(); 827 895 828 // Clear the overlay by making the game screen "look through" everywhere. 829 SDL_Rect src, dst; 830 src.x = src.y = 0; 831 dst.x = dst.y = 1; 832 src.w = dst.w = _screenWidth; 833 src.h = dst.h = _screenHeight; 834 if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) 835 error("SDL_BlitSurface failed: %s", SDL_GetError()); 836 896 if (!_overlayVisible) { 897 // Fill everything with the "transparent" color, i.e. the colorkey 898 SDL_FillRect(_overlayscreen, 0, kOverlayColorKey); 899 } else { 900 // Clear the overlay by making the game screen "look through" everywhere. 901 SDL_Rect src, dst; 902 src.x = src.y = 0; 903 dst.x = dst.y = 1; 904 src.w = dst.w = _screenWidth; 905 src.h = dst.h = _screenHeight; 906 if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) 907 error("SDL_BlitSurface failed: %s", SDL_GetError()); 908 909 SDL_LockSurface(_tmpscreen); 910 SDL_LockSurface(_overlayscreen); 911 if (_overlayScale == _scaleFactor) { 912 _scaler_proc((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2, 913 _tmpscreen->pitch, (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight); 914 } else { 915 // Quality is degraded here. It is possible to run one-less scaler here, but is it 916 // really needed? Quality will anyway be degraded because of 1.5x scaler. 917 (overlayScalers[0][_overlayScale-1])((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2, 918 _tmpscreen->pitch, (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight); 919 } 920 SDL_UnlockSurface(_tmpscreen); 921 SDL_UnlockSurface(_overlayscreen); 922 } 837 923 _forceFull = true; 838 924 } 839 925 840 926 void OSystem_SDL::grabOverlay(OverlayColor *buf, int pitch) { 841 if (!_overlayVisible) 842 return; 843 844 if (_tmpscreen == NULL) 927 if (_overlayscreen == NULL) 845 928 return; 846 929 847 930 // hide the mouse 848 931 undraw_mouse(); 849 932 850 if (SDL_LockSurface(_ tmpscreen) == -1)933 if (SDL_LockSurface(_overlayscreen) == -1) 851 934 error("SDL_LockSurface failed: %s", SDL_GetError()); 852 935 853 byte *src = (byte *)_ tmpscreen->pixels + _tmpscreen->pitch + 2; // Offset by one row, one column854 int h = _ screenHeight;936 byte *src = (byte *)_overlayscreen->pixels; 937 int h = _overlayHeight; 855 938 do { 856 memcpy(buf, src, _ screenWidth*2);857 src += _ tmpscreen->pitch;939 memcpy(buf, src, _overlayWidth*2); 940 src += _overlayscreen->pitch; 858 941 buf += pitch; 859 942 } while (--h); 860 943 861 SDL_UnlockSurface(_ tmpscreen);944 SDL_UnlockSurface(_overlayscreen); 862 945 } 863 946 864 947 void OSystem_SDL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { 865 if (!_overlayVisible) 866 return; 867 868 if (_tmpscreen == NULL) 948 if (_overlayscreen == NULL) 869 949 return; 870 950 871 951 // Clip the coordinates … … 880 960 y = 0; 881 961 } 882 962 883 if (w > _ screenWidth - x) {884 w = _ screenWidth - x;963 if (w > _overlayWidth - x) { 964 w = _overlayWidth - x; 885 965 } 886 966 887 if (h > _ screenHeight-y) {888 h = _ screenHeight - y;967 if (h > _overlayHeight-y) { 968 h = _overlayHeight - y; 889 969 } 890 970 891 971 if (w <= 0 || h <= 0) … … 893 973 894 974 // Mark the modified region as dirty 895 975 cksum_valid = false; 896 add_dirty_rect( x, y, w, h);976 add_dirty_rect(OverlayToScreen(x), OverlayToScreen(y), OverlayToScreen(w), OverlayToScreen(h)); 897 977 898 978 /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ 899 979 undraw_mouse(); 900 980 901 if (SDL_LockSurface(_ tmpscreen) == -1)981 if (SDL_LockSurface(_overlayscreen) == -1) 902 982 error("SDL_LockSurface failed: %s", SDL_GetError()); 903 983 904 byte *dst = (byte *)_ tmpscreen->pixels + (y + 1) * _tmpscreen->pitch + (x + 1)* 2;984 byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2; 905 985 do { 906 986 memcpy(dst, buf, w * 2); 907 dst += _ tmpscreen->pitch;987 dst += _overlayscreen->pitch; 908 988 buf += pitch; 909 989 } while (--h); 910 990 911 SDL_UnlockSurface(_ tmpscreen);991 SDL_UnlockSurface(_overlayscreen); 912 992 } 913 993 914 994 OverlayColor OSystem_SDL::RGBToColor(uint8 r, uint8 g, uint8 b) { 915 return SDL_MapRGB(_ tmpscreen->format, r, g, b);995 return SDL_MapRGB(_overlayscreen->format, r, g, b); 916 996 } 917 997 918 998 void OSystem_SDL::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { 919 SDL_GetRGB(color, _ tmpscreen->format, &r, &g, &b);999 SDL_GetRGB(color, _overlayscreen->format, &r, &g, &b); 920 1000 } 921 1001 922 1002 … … 950 1030 951 1031 void OSystem_SDL::warpMouse(int x, int y) { 952 1032 if (_mouseCurState.x != x || _mouseCurState.y != y) { 953 SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor); 1033 if (_overlayVisible) 1034 SDL_WarpMouse(x * _scaleFactor / _overlayScale, y * _scaleFactor / _overlayScale); 1035 else 1036 SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor); 954 1037 955 1038 // SDL_WarpMouse() generates a mouse movement event, so 956 1039 // set_mouse_pos() would be called eventually. However, the … … 964 1047 } 965 1048 966 1049 void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) { 1050 int cursorScale = _overlayScale; 1051 int dstPitch; 1052 byte *tmpPtr, *dstPtr; 1053 const byte *srcPtr = buf; 967 1054 968 1055 undraw_mouse(); 969 1056 1057 if (!_cursorScaled) 1058 cursorScale = 1; 1059 970 1060 assert(w <= MAX_MOUSE_W); 971 1061 assert(h <= MAX_MOUSE_H); 972 _mouseCurState.w = w ;973 _mouseCurState.h = h ;1062 _mouseCurState.w = w * cursorScale; 1063 _mouseCurState.h = h * cursorScale; 974 1064 975 _mouseHotspotX = hotspot_x ;976 _mouseHotspotY = hotspot_y ;1065 _mouseHotspotX = hotspot_x * cursorScale; 1066 _mouseHotspotY = hotspot_y * cursorScale; 977 1067 978 1068 _mouseKeycolor = keycolor; 979 1069 980 1070 if (_mouseData) 981 1071 free(_mouseData); 982 1072 983 _mouseData = (byte *)malloc(w * h); 984 memcpy(_mouseData, buf, w * h); 1073 dstPtr = _mouseData = (byte *)malloc(w * h * cursorScale * cursorScale); 1074 1075 if (cursorScale == 1) { 1076 memcpy(_mouseData, buf, w * h); 1077 return; 1078 } 1079 1080 dstPitch = w * cursorScale; 1081 for (uint i = 0; i < h; i++) { 1082 for (uint j = 0; j < w; j++) { 1083 for (int k = 0; k < cursorScale; k++) { 1084 tmpPtr = dstPtr + dstPitch * k; 1085 for (int l = 0; l < cursorScale; l++) { 1086 *tmpPtr++ = *srcPtr; 1087 } 1088 } 1089 srcPtr++; 1090 dstPtr += cursorScale; 1091 } 1092 dstPtr += dstPitch * (cursorScale - 1); 1093 } 985 1094 } 986 1095 987 1096 void OSystem_SDL::toggleMouseGrab() { … … 1002 1111 byte color; 1003 1112 const byte *src = _mouseData; // Image representing the mouse 1004 1113 1005 // clip the mouse rect, and addjust the src pointer accordingly 1114 if (!_overlayVisible) { 1115 x = ScreenToOverlay(x); 1116 y = ScreenToOverlay(y); 1117 } 1118 1119 // clip the mouse rect, and adjust the src pointer accordingly 1006 1120 if (x < 0) { 1007 1121 w += x; 1008 1122 src -= x; … … 1014 1128 y = 0; 1015 1129 } 1016 1130 1017 if (w > _ screenWidth - x)1018 w = _ screenWidth - x;1019 if (h > _ screenHeight - y)1020 h = _ screenHeight - y;1131 if (w > _overlayWidth - x) 1132 w = _overlayWidth - x; 1133 if (h > _overlayHeight - y) 1134 h = _overlayHeight - y; 1021 1135 1022 1136 // Quick check to see if anything has to be drawn at all 1023 1137 if (w <= 0 || h <= 0) 1024 1138 return; 1025 1139 1026 1140 // Draw the mouse cursor; backup the covered area in "bak" 1027 if (SDL_LockSurface(_overlay Visible ? _tmpscreen : _screen) == -1)1141 if (SDL_LockSurface(_overlayscreen) == -1) 1028 1142 error("SDL_LockSurface failed: %s", SDL_GetError()); 1029 1143 1030 1144 // Mark as dirty 1031 add_dirty_rect( x, y, w, h);1145 add_dirty_rect(OverlayToScreen(x), OverlayToScreen(y), OverlayToScreen(w), OverlayToScreen(h)); 1032 1146 1033 if (!_overlayVisible) { 1034 byte *bak = _mouseBackup; // Surface used to backup the area obscured by the mouse 1035 byte *dst; // Surface we are drawing into 1036 1037 dst = (byte *)_screen->pixels + y * _screenWidth + x; 1038 while (h > 0) { 1039 int width = w; 1040 while (width > 0) { 1041 *bak++ = *dst; 1042 color = *src++; 1043 if (color != _mouseKeycolor) // transparent, don't draw 1044 *dst = color; 1045 dst++; 1046 width--; 1047 } 1048 src += _mouseCurState.w - w; 1049 bak += MAX_MOUSE_W - w; 1050 dst += _screenWidth - w; 1051 h--; 1052 } 1147 uint16 *bak = (uint16 *)_mouseBackup; // Surface used to backup the area obscured by the mouse 1148 byte *dst; // Surface we are drawing into 1053 1149 1054 } else { 1055 uint16 *bak = (uint16 *)_mouseBackup; // Surface used to backup the area obscured by the mouse 1056 byte *dst; // Surface we are drawing into 1057 1058 dst = (byte *)_tmpscreen->pixels + (y + 1) * _tmpscreen->pitch + (x + 1) * 2; 1059 while (h > 0) { 1060 int width = w; 1061 while (width > 0) { 1062 *bak++ = *(uint16 *)dst; 1063 color = *src++; 1064 if (color != 0xFF) // 0xFF = transparent, don't draw 1065 *(uint16 *)dst = RGBToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); 1066 dst += 2; 1067 width--; 1068 } 1069 src += _mouseCurState.w - w; 1070 bak += MAX_MOUSE_W - w; 1071 dst += _tmpscreen->pitch - w * 2; 1072 h--; 1073 } 1150 dst = (byte *)_overlayscreen->pixels + (y + 1) * _overlayscreen->pitch + (x + 1) * 2; 1151 while (h > 0) { 1152 int width = w; 1153 while (width > 0) { 1154 *bak++ = *(uint16 *)dst; 1155 color = *src++; 1156 if (color != _mouseKeycolor) // transparent, don't draw 1157 *(uint16 *)dst = RGBToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); 1158 dst += 2; 1159 width--; 1160 } 1161 src += _mouseCurState.w - w; 1162 bak += MAX_MOUSE_W - w; 1163 dst += _overlayscreen->pitch - w * 2; 1164 h--; 1074 1165 } 1075 1166 1076 SDL_UnlockSurface(_overlay Visible ? _tmpscreen : _screen);1167 SDL_UnlockSurface(_overlayscreen); 1077 1168 1078 1169 // Finally, set the flag to indicate the mouse has been drawn 1079 1170 _mouseDrawn = true; … … 1084 1175 return; 1085 1176 _mouseDrawn = false; 1086 1177 1087 if (SDL_LockSurface(_overlay Visible ? _tmpscreen : _screen) == -1)1178 if (SDL_LockSurface(_overlayscreen) == -1) 1088 1179 error("SDL_LockSurface failed: %s", SDL_GetError()); 1089 1180 1090 1181 int old_mouse_x = _mouseCurState.x - _mouseHotspotX; … … 1092 1183 int old_mouse_w = _mouseCurState.w; 1093 1184 int old_mouse_h = _mouseCurState.h; 1094 1185 1186 if (!_overlayVisible) { 1187 old_mouse_x = ScreenToOverlay(old_mouse_x); 1188 old_mouse_y = ScreenToOverlay(old_mouse_y); 1189 } 1190 1095 1191 // clip the mouse rect, and addjust the src pointer accordingly 1096 1192 if (old_mouse_x < 0) { 1097 1193 old_mouse_w += old_mouse_x; … … 1102 1198 old_mouse_y = 0; 1103 1199 } 1104 1200 1105 if (old_mouse_w > _ screenWidth - old_mouse_x)1106 old_mouse_w = _ screenWidth - old_mouse_x;1107 if (old_mouse_h > _ screenHeight - old_mouse_y)1108 old_mouse_h = _ screenHeight - old_mouse_y;1201 if (old_mouse_w > _overlayWidth - old_mouse_x) 1202 old_mouse_w = _overlayWidth - old_mouse_x; 1203 if (old_mouse_h > _overlayHeight - old_mouse_y) 1204 old_mouse_h = _overlayHeight - old_mouse_y; 1109 1205 1110 1206 // Quick check to see if anything has to be drawn at all 1111 1207 if (old_mouse_w <= 0 || old_mouse_h <= 0) … … 1113 1209 1114 1210 1115 1211 int x, y; 1116 if (!_overlayVisible) { 1117 byte *dst, *bak = _mouseBackup; 1118 1119 // No need to do clipping here, since draw_mouse() did that already 1120 dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x; 1121 for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) { 1122 for (x = 0; x < old_mouse_w; ++x) { 1123 dst[x] = bak[x]; 1124 } 1125 } 1212 byte *dst; 1213 uint16 *bak = (uint16 *)_mouseBackup; 1126 1214 1127 } else { 1128 1129 byte *dst; 1130 uint16 *bak = (uint16 *)_mouseBackup; 1131 1132 // No need to do clipping here, since draw_mouse() did that already 1133 dst = (byte *)_tmpscreen->pixels + (old_mouse_y + 1) * _tmpscreen->pitch + (old_mouse_x + 1) * 2; 1134 for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _tmpscreen->pitch) { 1135 for (x = 0; x < old_mouse_w; ++x) { 1136 *((uint16 *)dst + x) = bak[x]; 1137 } 1215 // No need to do clipping here, since draw_mouse() did that already 1216 dst = (byte *)_overlayscreen->pixels + (old_mouse_y + 1) * _overlayscreen->pitch + (old_mouse_x + 1) * 2; 1217 for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _overlayscreen->pitch) { 1218 for (x = 0; x < old_mouse_w; ++x) { 1219 *((uint16 *)dst + x) = bak[x]; 1138 1220 } 1139 1221 } 1140 1222 1141 add_dirty_rect( old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h);1223 add_dirty_rect(OverlayToScreen(old_mouse_x), OverlayToScreen(old_mouse_y), OverlayToScreen(old_mouse_w), OverlayToScreen(old_mouse_h)); 1142 1224 1143 SDL_UnlockSurface(_overlay Visible ? _tmpscreen : _screen);1225 SDL_UnlockSurface(_overlayscreen); 1144 1226 } 1145 1227 1146 1228 -
backends/sdl/sdl-common.h
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v retrieving revision 1.62 diff -u -r1.62 sdl-common.h
43 43 44 44 // Set the size of the video bitmap. 45 45 // Typically, 320x200 46 void initSize(uint w, uint h );46 void initSize(uint w, uint h, uint overlayScale); 47 47 48 48 // Set colors of the palette 49 49 void setPalette(const byte *colors, uint start, uint num); … … 59 59 60 60 // Either show or hide the mouse cursor 61 61 bool showMouse(bool visible); 62 63 // Either scale or not the mouse cursor 64 void setCursorScaled(bool state) { _cursorScaled = state; } 62 65 63 66 // Warp the mouse cursor. Where set_mouse_pos() only informs the 64 67 // backend of the mouse cursor's current position, this function … … 120 123 virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); 121 124 virtual int16 getHeight(); 122 125 virtual int16 getWidth(); 126 virtual int16 getOverlayHeight() { return _overlayHeight; } 127 virtual int16 getOverlayWidth() { return _overlayWidth; } 128 virtual OverlayColor getOverlayKeyColor() { return kOverlayColorKey; } 129 virtual int ScreenToOverlay(int x) { return x * _overlayScale; } 130 virtual int OverlayToScreen(int x) { return x / _overlayScale; } 123 131 124 132 // Methods that convert RGB to/from colors suitable for the overlay. 125 133 virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); … … 165 173 SDL_Surface *_screen; 166 174 int _screenWidth, _screenHeight; 167 175 168 // temporary screen (for scalers/overlay)176 // temporary screens (for scalers) 169 177 SDL_Surface *_tmpscreen; 178 SDL_Surface *_tmpscreen2; 179 180 // overlay 181 SDL_Surface *_overlayscreen; 182 int _overlayWidth, _overlayHeight; 183 int _overlayScale; 170 184 bool _overlayVisible; 185 186 enum { 187 kOverlayColorKey = 1 188 }; 171 189 172 190 // Audio 173 191 int _samplesPerSec; … … 222 240 // mouse 223 241 bool _mouseVisible; 224 242 bool _mouseDrawn; 243 bool _cursorScaled; 225 244 byte *_mouseData; 226 245 byte *_mouseBackup; 227 246 MousePos _mouseCurState; -
backends/sdl/sdl.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v retrieving revision 1.72 diff -u -r1.72 sdl.cpp
94 94 _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), 95 95 #endif 96 96 _hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0), 97 _tmpscreen(0), _overlay Visible(false),98 _ samplesPerSec(0),97 _tmpscreen(0), _overlayscreen(0), _overlayVisible(false), 98 _tmpscreen2(0), _samplesPerSec(0), 99 99 _cdrom(0), _scaler_proc(0), _modeChanged(false), _dirty_checksums(0), 100 100 _mouseVisible(false), _mouseDrawn(false), _mouseData(0), 101 _mouseHotspotX(0), _mouseHotspotY(0), 101 _mouseHotspotX(0), _mouseHotspotY(0), _cursorScaled(true), 102 102 _currentShakePos(0), _newShakePos(0), 103 103 _paletteDirtyStart(0), _paletteDirtyEnd(0), 104 104 _graphicsMutex(0) { -
base/main.cpp
RCS file: /cvsroot/scummvm/scummvm/base/main.cpp,v retrieving revision 1.46 diff -u -r1.46 main.cpp
182 182 183 183 // FIXME - we need to call initSize() here so that we can display for example 184 184 // the launcher dialog. But the Engine object will also call it again (possibly 185 // with a different widht/height! 9However, this method is not for all OSystem185 // with a different widht/height! However, this method is not for all OSystem 186 186 // implementations reentrant (it is so now for the SDL backend). Thus we need 187 187 // to fix all backends to support it, if they don't already. 188 system->initSize(320, 200 );188 system->initSize(320, 200, 2); 189 189 190 190 // FIXME - mouse cursors are currently always set via 8 bit data. 191 191 // Thus for now we need to setup a dummy palette. On the long run, we might -
common/scaler.cpp
RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v retrieving revision 1.63 diff -u -r1.63 scaler.cpp
105 105 106 106 /** 107 107 * Trivial 'scaler' - in fact it doesn't do any scaling but just copies the 108 * source to the desti onation.108 * source to the destination. 109 109 */ 110 110 void Normal1x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 111 111 int width, int height) { … … 169 169 } 170 170 } 171 171 172 #define INTERPOLATE INTERPOLATE<bitFormat> 173 #define Q_INTERPOLATE Q_INTERPOLATE<bitFormat> 174 175 /** 176 * Trivial nearest-neighbour 1.5x scaler. 177 */ 178 template<int bitFormat> 179 void Normal1o5xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 180 int width, int height) { 181 uint8 *r; 182 const uint32 dstPitch2 = dstPitch * 2; 183 const uint32 dstPitch3 = dstPitch * 3; 184 const uint32 srcPitch2 = srcPitch * 2; 185 186 assert(((int)dstPtr & 1) == 0); 187 while (height) { 188 r = dstPtr; 189 for (int i = 0; i < width; i += 2, r += 6) { 190 uint16 color0 = *(((const uint16 *)srcPtr) + i); 191 uint16 color1 = *(((const uint16 *)srcPtr) + i + 1); 192 uint16 color2 = *(((const uint16 *)(srcPtr + srcPitch)) + i); 193 uint16 color3 = *(((const uint16 *)(srcPtr + srcPitch)) + i + 1); 194 195 *(uint16 *)(r + 0) = color0; 196 *(uint16 *)(r + 2) = INTERPOLATE(color0, color1); 197 *(uint16 *)(r + 4) = color1; 198 *(uint16 *)(r + 0 + dstPitch) = INTERPOLATE(color0, color2); 199 *(uint16 *)(r + 2 + dstPitch) = Q_INTERPOLATE(color0, color1, color2, color3); 200 *(uint16 *)(r + 4 + dstPitch) = INTERPOLATE(color1, color3); 201 *(uint16 *)(r + 0 + dstPitch2) = color2; 202 *(uint16 *)(r + 2 + dstPitch2) = INTERPOLATE(color2, color3); 203 *(uint16 *)(r + 4 + dstPitch2) = color3; 204 } 205 srcPtr += srcPitch2; 206 dstPtr += dstPitch3; 207 height -= 2; 208 } 209 } 210 MAKE_WRAPPER(Normal1o5x) 211 172 212 /** 173 213 * The Scale2x filter, also known as AdvMame2x. 174 214 * See also http://scale2x.sourceforge.net -
common/scaler.h
RCS file: /cvsroot/scummvm/scummvm/common/scaler.h,v retrieving revision 1.26 diff -u -r1.26 scaler.h
40 40 DECLARE_SCALER(AdvMame3x); 41 41 DECLARE_SCALER(Normal1x); 42 42 DECLARE_SCALER(Normal2x); 43 DECLARE_SCALER(Normal1o5x); 43 44 DECLARE_SCALER(Normal3x); 44 45 DECLARE_SCALER(TV2x); 45 46 DECLARE_SCALER(DotMatrix); -
common/system.h
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v retrieving revision 1.68 diff -u -r1.68 system.h
216 216 * @param width the new virtual screen width 217 217 * @param height the new virtual screen height 218 218 */ 219 virtual void initSize(uint width, uint height ) = 0;219 virtual void initSize(uint width, uint height, uint overlayScale = 1) = 0; 220 220 221 221 /** 222 222 * Returns the currently set virtual screen height. … … 305 305 virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) = 0; 306 306 virtual int16 getOverlayHeight() { return getHeight(); } 307 307 virtual int16 getOverlayWidth() { return getWidth(); } 308 virtual OverlayColor getOverlayKeyColor() { return RGBToColor(0, 0, 0); } 309 virtual int ScreenToOverlay(int x) { return x; } 310 virtual int OverlayToScreen(int x) { return x; } 308 311 309 312 /** 310 313 * Convert the given RGB triplet into an OverlayColor. A OverlayColor can … … 340 343 /** Show or hide the mouse cursor. */ 341 344 virtual bool showMouse(bool visible) = 0; 342 345 346 /** Scale cursor with screen scale rate change or not */ 347 virtual void setCursorScaled(bool state) { } 348 343 349 /** 344 350 * Move ("warp") the mouse cursor to the specified position in virtual 345 351 * screen coordinates. … … 435 441 /** 436 442 * The mouse coordinates, in virtual screen coordinates. Only valid 437 443 * for mouse events. 438 * Virtual screen coordinates t means: the coordinate system of the444 * Virtual screen coordinates mean: the coordinate system of the 439 445 * screen area as defined by the most recent call to initSize(). 440 446 */ 441 447 Common::Point mouse; -
doc/he/md5s.txt
RCS file: /cvsroot/scummvm/scummvm/doc/he/md5s.txt,v retrieving revision 1.7 diff -u -r1.7 md5s.txt
64 64 42161ad979949daf67924b5227b94f2d airdemo.he4 65 65 765492059d83bc0ae8c30a4feef50a6a airdemo.he9 66 66 67 (spyfox cd/pjs cd/puttzoo cd/he classics cd )67 (spyfox cd/pjs cd/puttzoo cd/he classics cd/freddi2 cd) 68 68 khalek, sev 69 69 7.0.0 (Jul 5 1995 14:46:05) 70 70 a5459bfe36183cf1f4ced00fe325aa90 airdemo.w32 … … 275 275 6daf76c1fe724ce6bf2e4c5175f39352 freddemo.he3 276 276 a8c3ced34ecb16ad1b0eed5b464ad61e freddemo.he4 277 277 278 (spyfox cd/pjs cd/puttzoo cd/he classics cd )278 (spyfox cd/pjs cd/puttzoo cd/he classics cd/freddi2 cd) 279 279 khalek, sev 280 280 7.0.0 (Jul 5 1995 14:46:05) 281 281 25003798cd5f4b51bc1f4d02c6a2e218 freddemo.w32 … … 344 344 faca7509c38beabb37b2347b8b6bb1ea Freddi Demo (2) 345 345 a8c3ced34ecb16ad1b0eed5b464ad61e Freddi Demo (4) 346 346 347 (freddi2 cd) 348 sev 349 D:\Scummsrc.80\Sputm\*.c 350 d06066ae0ba8ffb338d6a00f556ae3ac FREDDI2.W32 351 5057fb0e99e5aa29df1836329232f101 FREDDI2.HE0 352 a586db95af3146aa7793c5e2d0ed9e83 FREDDI2.HE1 353 9ff9a777a343e605278127c0bbdde58f FREDDI2.HE2 354 d22f1b3bd41cb4901f89164043953bc8 FREDDI2.HE4 355 347 356 (russian freddi) 348 357 sev 349 358 D:\Scummsrc.80\Sputm\*.c … … 573 582 4ccd03ca710a9053c42292cae09a6471 Pajama Sam Demo (2) 574 583 6e0fdfcf13e37b659b7155cf5969965f Pajama Sam Demo (4) 575 584 576 (spyfox cd/puttzoo cd/he classics cd/pj2 cd )585 (spyfox cd/puttzoo cd/he classics cd/pj2 cd/freddi2 cd) 577 586 khalek, sev 578 587 1996-10-31 22:34 pjs-demo.w32 579 588 D:\Scummsrc.80\Sputm\*.c … … 920 929 225991e6f8d3d6ac5e519413392c34f3 Putt-Putt Saves the Zoo (2) 921 930 d3235443d88751acd3412c1b0c6cec35 Putt-Putt Saves the Zoo (4) 922 931 923 (spyfox cd/pjs cd/he classics cd )932 (spyfox cd/pjs cd/he classics cd/freddi2 cd) 924 933 khalek 925 934 7.0.0 (Jun 4 1995 15:47:12) 926 935 f3324cfe3dec0288fd38197cf88962af zoodemo.w32 -
scumm/scumm.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v retrieving revision 1.131 diff -u -r1.131 scumm.cpp
808 808 } 809 809 810 810 // Initialize backend 811 syst->initSize(_screenWidth, _screenHeight); 811 syst->initSize(_screenWidth, _screenHeight, 2); 812 syst->setCursorScaled((_features & GF_UNSCALED_CURSORS) == 0); 813 812 814 int cd_num = ConfMan.getInt("cdrom"); 813 815 if (cd_num >= 0 && (_features & GF_AUDIOTRACKS)) 814 816 syst->openCD(cd_num); … … 3195 3197 // specify correct version here 3196 3198 if (game.features & GF_HUMONGOUS && (game.heversion == 60 || game.id == GID_PUTTDEMO)) { 3197 3199 game.heversion = 70; 3198 game.features |= GF_NEW_COSTUMES ;3200 game.features |= GF_NEW_COSTUMES | GF_UNSCALED_CURSORS; 3199 3201 } 3200 3202 break; 3201 3203 case Common::kPlatformFMTowns: -
scumm/scumm.h
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v retrieving revision 1.445 diff -u -r1.445 scumm.h
113 113 GF_FEW_LOCALS = 1 << 13, 114 114 GF_HUMONGOUS = 1 << 14, 115 115 GF_MULTIPLE_VERSIONS = 1 << 15, 116 GF_UNSCALED_CURSORS = 1 << 16, 116 117 117 118 GF_FMTOWNS = 1 << 17, 118 119 GF_AMIGA = 1 << 18,