Ticket #8353: mouse.v3.diff
File mouse.v3.diff, 25.1 KB (added by , 20 years ago) |
---|
-
backends/sdl/graphics.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v retrieving revision 1.24 diff -u -r1.24 graphics.cpp
42 42 {0, 0, 0} 43 43 }; 44 44 45 // Table of relative scalers magnitudes 46 // [definedScale-1][_scaleFactor-1] 47 static ScalerProc *scalersMagn[3][3] = { 48 { Normal1x, AdvMame2x, AdvMame3x }, 49 { Normal1x, Normal1x, Normal1o5x }, 50 { Normal1x, Normal1x, Normal1x } 51 }; 52 45 53 const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { 46 54 return s_supportedGraphicsModes; 47 55 } … … 367 375 SDL_FreeSurface(old_screen); 368 376 SDL_FreeSurface(old_tmpscreen); 369 377 378 // Update cursor to new scale 379 blitCursor(); 380 370 381 // Blit everything to the screen 371 382 internUpdateScreen(); 372 383 … … 399 410 _forceFull = true; 400 411 } 401 412 402 // Make sure the mouse is drawn, if it should be drawn.403 drawMouse();404 405 413 // Check whether the palette was changed in the meantime and update the 406 414 // screen surface accordingly. 407 415 if (_paletteDirtyEnd != 0) { … … 434 442 } 435 443 #endif 436 444 445 undrawMouse(); 446 437 447 // Force a full redraw if requested 438 448 if (_forceFull) { 439 449 _numDirtyRects = 1; … … 527 537 SDL_BlitSurface(_osdSurface, 0, _hwscreen, 0); 528 538 } 529 539 #endif 530 540 drawMouse(); 541 531 542 // Finally, blit all our changes to the screen 532 543 SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); 544 } else { 545 drawMouse(); 546 if (_numDirtyRects) 547 SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); 533 548 } 534 549 535 550 _numDirtyRects = 0; … … 562 577 assert(_hwscreen != 0); 563 578 _fullscreen ^= true; 564 579 565 undrawMouse();566 567 580 #if defined(MACOSX) && !SDL_VERSION_ATLEAST(1, 2, 6) 568 581 // On OS X, SDL_WM_ToggleFullScreen is currently not implemented. Worse, 569 582 // before SDL 1.2.6 it always returned -1 (which would indicate a … … 672 685 addDirtyRect(x, y, w, h); 673 686 } 674 687 675 /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */676 undrawMouse();677 678 688 // Try to lock the screen surface 679 689 if (SDL_LockSurface(_screen) == -1) 680 690 error("SDL_LockSurface failed: %s", SDL_GetError()); … … 696 706 } 697 707 698 708 699 void OSystem_SDL::addDirtyRect(int x, int y, int w, int h ) {709 void OSystem_SDL::addDirtyRect(int x, int y, int w, int h, bool mouseRect) { 700 710 if (_forceFull) 701 711 return; 702 712 713 if (mouseRect) { 714 SDL_Rect *r = &_dirtyRectList[_numDirtyRects++]; 715 r->x = x; 716 r->y = y; 717 r->w = w; 718 r->h = h; 719 return; 720 } 721 703 722 if (_numDirtyRects == NUM_DIRTY_RECT) 704 723 _forceFull = true; 705 724 else { … … 846 865 847 866 if (start + num > _paletteDirtyEnd) 848 867 _paletteDirtyEnd = start + num; 868 869 // Some games blink cursors with palette 870 if (!_overlayVisible && !_cursorHasOwnPalette) 871 blitCursor(); 872 } 873 874 void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) { 875 const byte *b = colors; 876 uint i; 877 SDL_Color *base = _cursorPalette + start; 878 for (i = 0; i < num; i++) { 879 base[i].r = b[0]; 880 base[i].g = b[1]; 881 base[i].b = b[2]; 882 b += 4; 883 } 884 885 _cursorHasOwnPalette = true; 886 887 if (!_overlayVisible) 888 blitCursor(); 849 889 } 850 890 851 891 void OSystem_SDL::setShakePos(int shake_pos) { … … 862 902 void OSystem_SDL::showOverlay() { 863 903 assert (_transactionMode == kTransactionNone); 864 904 865 // hide the mouse866 undrawMouse();867 868 905 _overlayVisible = true; 869 906 clearOverlay(); 870 907 } … … 872 909 void OSystem_SDL::hideOverlay() { 873 910 assert (_transactionMode == kTransactionNone); 874 911 875 // hide the mouse876 undrawMouse();877 878 912 _overlayVisible = false; 879 913 _forceFull = true; 880 914 } … … 887 921 888 922 Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends 889 923 890 // hide the mouse891 undrawMouse();892 893 924 // Clear the overlay by making the game screen "look through" everywhere. 894 925 SDL_Rect src, dst; 895 926 src.x = src.y = 0; … … 911 942 if (_tmpscreen == NULL) 912 943 return; 913 944 914 // hide the mouse915 undrawMouse();916 917 945 if (SDL_LockSurface(_tmpscreen) == -1) 918 946 error("SDL_LockSurface failed: %s", SDL_GetError()); 919 947 … … 964 992 _cksumValid = false; 965 993 addDirtyRect(x, y, w, h); 966 994 967 /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */968 undrawMouse();969 970 995 if (SDL_LockSurface(_tmpscreen) == -1) 971 996 error("SDL_LockSurface failed: %s", SDL_GetError()); 972 997 … … 1000 1025 bool last = _mouseVisible; 1001 1026 _mouseVisible = visible; 1002 1027 1003 if (visible) 1004 drawMouse(); 1005 else 1006 undrawMouse(); 1028 updateScreen(); 1007 1029 1008 1030 return last; 1009 1031 } 1010 1032 1011 1033 void OSystem_SDL::setMousePos(int x, int y) { 1012 1034 if (x != _mouseCurState.x || y != _mouseCurState.y) { 1013 undrawMouse();1014 1035 _mouseCurState.x = x; 1015 1036 _mouseCurState.y = y; 1016 1037 updateScreen(); … … 1032 1053 } 1033 1054 } 1034 1055 1035 void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) { 1036 1037 undrawMouse(); 1038 1039 assert(w <= MAX_MOUSE_W); 1040 assert(h <= MAX_MOUSE_H); 1041 _mouseCurState.w = w; 1042 _mouseCurState.h = h; 1043 1056 void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { 1044 1057 _mouseHotspotX = hotspot_x; 1045 1058 _mouseHotspotY = hotspot_y; 1046 1059 1047 1060 _mouseKeyColor = keycolor; 1048 1061 1062 _cursorTargetScale = cursorTargetScale; 1063 1064 if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) { 1065 _mouseCurState.w = w; 1066 _mouseCurState.h = h; 1067 1068 if (_mouseOrigSurface) 1069 SDL_FreeSurface(_mouseOrigSurface); 1070 1071 _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 1072 _mouseCurState.w, 1073 _mouseCurState.h, 1074 16, 1075 _hwscreen->format->Rmask, 1076 _hwscreen->format->Gmask, 1077 _hwscreen->format->Bmask, 1078 _hwscreen->format->Amask); 1079 1080 if (_mouseOrigSurface == NULL) 1081 error("allocating _mouseOrigSurface failed"); 1082 SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey); 1083 } 1084 1049 1085 free(_mouseData); 1050 1086 1051 1087 _mouseData = (byte *)malloc(w * h); 1052 1088 memcpy(_mouseData, buf, w * h); 1089 blitCursor(); 1090 } 1091 1092 void OSystem_SDL::blitCursor() { 1093 byte *dstPtr; 1094 const byte *srcPtr = _mouseData; 1095 byte color; 1096 int w, h; 1097 1098 if (!_mouseOrigSurface) 1099 return; 1100 1101 w = _mouseCurState.w; 1102 h = _mouseCurState.h; 1103 1104 SDL_LockSurface(_mouseOrigSurface); 1105 1106 dstPtr = (byte *)_mouseOrigSurface->pixels; 1107 1108 for (int i = 0; i < h; i++) { 1109 for (int j = 0; j < w; j++) { 1110 color = *srcPtr; 1111 if (color != _mouseKeyColor) { // transparent, don't draw 1112 if (_cursorHasOwnPalette && !_overlayVisible) 1113 *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, 1114 _cursorPalette[color].r, _cursorPalette[color].g, 1115 _cursorPalette[color].b); 1116 else 1117 *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, 1118 _currentPalette[color].r, _currentPalette[color].g, 1119 _currentPalette[color].b); 1120 } else { 1121 *(uint16 *)dstPtr = kMouseColorKey; 1122 } 1123 dstPtr += 2; 1124 srcPtr++; 1125 } 1126 dstPtr += _mouseOrigSurface->pitch - w * 2; 1127 } 1128 1129 int hW, hH, hH1; 1130 1131 if (_cursorTargetScale >= _scaleFactor) { 1132 hW = w; 1133 hH = hH1 = h; 1134 } else { 1135 hW = w * _scaleFactor / _cursorTargetScale; 1136 hH = hH1 = h * _scaleFactor / _cursorTargetScale; 1137 } 1138 1139 if (_adjustAspectRatio) { 1140 hH = real2Aspect(hH - 1) + 1; 1141 } 1142 1143 if (_mouseCurState.hW != hW || _mouseCurState.hH != hH) { 1144 _mouseCurState.hW = hW; 1145 _mouseCurState.hH = hH; 1146 1147 if (_mouseSurface) 1148 SDL_FreeSurface(_mouseSurface); 1149 1150 _mouseSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, 1151 _mouseCurState.hW, 1152 _mouseCurState.hH, 1153 16, 1154 _hwscreen->format->Rmask, 1155 _hwscreen->format->Gmask, 1156 _hwscreen->format->Bmask, 1157 _hwscreen->format->Amask); 1158 1159 if (_mouseSurface == NULL) 1160 error("allocating _mouseSurface failed"); 1161 1162 SDL_SetColorKey(_mouseSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey); 1163 } 1164 1165 SDL_LockSurface(_mouseSurface); 1166 (scalersMagn[_cursorTargetScale-1][_scaleFactor-1])((byte *)_mouseOrigSurface->pixels, 1167 _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, 1168 _mouseCurState.w, _mouseCurState.h); 1169 1170 if (_adjustAspectRatio) 1171 stretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, hW, hH1, 0, 0, 0); 1172 1173 SDL_UnlockSurface(_mouseSurface); 1174 SDL_UnlockSurface(_mouseOrigSurface); 1053 1175 } 1054 1176 1055 1177 void OSystem_SDL::toggleMouseGrab() { … … 1059 1181 SDL_WM_GrabInput(SDL_GRAB_OFF); 1060 1182 } 1061 1183 1062 void OSystem_SDL::drawMouse() { 1063 if (_mouseDrawn || !_mouseVisible || !_mouseData) 1064 return; 1065 1066 int x = _mouseCurState.x - _mouseHotspotX; 1067 int y = _mouseCurState.y - _mouseHotspotY; 1068 int w = _mouseCurState.w; 1069 int h = _mouseCurState.h; 1070 byte color; 1071 const byte *src = _mouseData; // Image representing the mouse 1072 1073 // clip the mouse rect, and addjust the src pointer accordingly 1074 if (x < 0) { 1075 w += x; 1076 src -= x; 1077 x = 0; 1078 } 1079 if (y < 0) { 1080 h += y; 1081 src -= y * _mouseCurState.w; 1082 y = 0; 1083 } 1084 1085 if (w > _screenWidth - x) 1086 w = _screenWidth - x; 1087 if (h > _screenHeight - y) 1088 h = _screenHeight - y; 1089 1090 // Quick check to see if anything has to be drawn at all 1091 if (w <= 0 || h <= 0) 1092 return; 1093 1094 // Draw the mouse cursor; backup the covered area in "bak" 1095 if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1) 1096 error("SDL_LockSurface failed: %s", SDL_GetError()); 1097 1098 // Mark as dirty 1099 addDirtyRect(x, y, w, h); 1100 1101 if (!_overlayVisible) { 1102 byte *bak = _mouseBackup; // Surface used to backup the area obscured by the mouse 1103 byte *dst; // Surface we are drawing into 1104 1105 dst = (byte *)_screen->pixels + y * _screenWidth + x; 1106 while (h > 0) { 1107 int width = w; 1108 while (width > 0) { 1109 *bak++ = *dst; 1110 color = *src++; 1111 if (color != _mouseKeyColor) // transparent, don't draw 1112 *dst = color; 1113 dst++; 1114 width--; 1115 } 1116 src += _mouseCurState.w - w; 1117 bak += MAX_MOUSE_W - w; 1118 dst += _screenWidth - w; 1119 h--; 1120 } 1121 1122 } else { 1123 uint16 *bak = (uint16 *)_mouseBackup; // Surface used to backup the area obscured by the mouse 1124 byte *dst; // Surface we are drawing into 1125 1126 dst = (byte *)_tmpscreen->pixels + (y + 1) * _tmpscreen->pitch + (x + 1) * 2; 1127 while (h > 0) { 1128 int width = w; 1129 while (width > 0) { 1130 *bak++ = *(uint16 *)dst; 1131 color = *src++; 1132 if (color != 0xFF) // 0xFF = transparent, don't draw 1133 *(uint16 *)dst = RGBToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); 1134 dst += 2; 1135 width--; 1136 } 1137 src += _mouseCurState.w - w; 1138 bak += MAX_MOUSE_W - w; 1139 dst += _tmpscreen->pitch - w * 2; 1140 h--; 1141 } 1184 void OSystem_SDL::undrawMouse() { 1185 if (_mouseBackup.w) { 1186 if (_adjustAspectRatio) 1187 addDirtyRect(_mouseBackup.x, aspect2Real(_mouseBackup.y), _mouseBackup.w, 1188 _mouseBackup.h); 1189 else 1190 addDirtyRect(_mouseBackup.x, _mouseBackup.y, _mouseBackup.w, 1191 _mouseBackup.h); 1142 1192 } 1143 1144 SDL_UnlockSurface(_overlayVisible ? _tmpscreen : _screen);1145 1146 // Finally, set the flag to indicate the mouse has been drawn1147 _mouseDrawn = true;1148 1193 } 1149 1194 1150 void OSystem_SDL::undrawMouse() { 1151 assert (_transactionMode == kTransactionNone || _transactionMode == kTransactionCommit); 1152 1153 if (!_mouseDrawn) 1154 return; 1155 _mouseDrawn = false; 1156 1157 int old_mouse_x = _mouseCurState.x - _mouseHotspotX; 1158 int old_mouse_y = _mouseCurState.y - _mouseHotspotY; 1159 int old_mouse_w = _mouseCurState.w; 1160 int old_mouse_h = _mouseCurState.h; 1161 1162 // clip the mouse rect, and addjust the src pointer accordingly 1163 if (old_mouse_x < 0) { 1164 old_mouse_w += old_mouse_x; 1165 old_mouse_x = 0; 1166 } 1167 if (old_mouse_y < 0) { 1168 old_mouse_h += old_mouse_y; 1169 old_mouse_y = 0; 1170 } 1171 1172 if (old_mouse_w > _screenWidth - old_mouse_x) 1173 old_mouse_w = _screenWidth - old_mouse_x; 1174 if (old_mouse_h > _screenHeight - old_mouse_y) 1175 old_mouse_h = _screenHeight - old_mouse_y; 1176 1177 // Quick check to see if anything has to be drawn at all 1178 if (old_mouse_w <= 0 || old_mouse_h <= 0) 1179 return; 1180 1181 if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1) 1182 error("SDL_LockSurface failed: %s", SDL_GetError()); 1195 void OSystem_SDL::drawMouse() { 1196 if (!_mouseVisible) { 1197 _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; 1198 return; 1199 } 1200 1201 SDL_Rect src, dst; 1202 bool scale; 1183 1203 1184 int x, y; 1185 if (!_overlayVisible) { 1186 byte *dst, *bak = _mouseBackup; 1187 1188 // No need to do clipping here, since drawMouse() did that already 1189 dst = (byte *)_screen->pixels + old_mouse_y * _screenWidth + old_mouse_x; 1190 for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) { 1191 for (x = 0; x < old_mouse_w; ++x) { 1192 dst[x] = bak[x]; 1193 } 1194 } 1195 1196 } else { 1204 scale = (_scaleFactor > _cursorTargetScale); 1197 1205 1198 byte *dst; 1199 uint16 *bak = (uint16 *)_mouseBackup; 1200 1201 // No need to do clipping here, since drawMouse() did that already 1202 dst = (byte *)_tmpscreen->pixels + (old_mouse_y + 1) * _tmpscreen->pitch + (old_mouse_x + 1) * 2; 1203 for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _tmpscreen->pitch) { 1204 for (x = 0; x < old_mouse_w; ++x) { 1205 *((uint16 *)dst + x) = bak[x]; 1206 } 1207 } 1208 } 1206 dst.x = _mouseCurState.x - _mouseHotspotX / _cursorTargetScale; 1207 dst.y = _mouseCurState.y - _mouseHotspotY / _cursorTargetScale; 1209 1208 1210 addDirtyRect(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); 1209 dst.w = _mouseCurState.hW; 1210 dst.h = _mouseCurState.hH; 1211 src.x = src.y = 0; 1211 1212 1212 SDL_UnlockSurface(_overlayVisible ? _tmpscreen : _screen); 1213 // clip the mouse rect, and adjust the src pointer accordingly 1214 int dx, dy; 1215 1216 dx = dst.x; dy = dst.y; 1217 dx = scale ? dst.x * _scaleFactor / _cursorTargetScale : dst.x; 1218 dy = scale ? dst.y * _scaleFactor / _cursorTargetScale : dst.y; 1219 if (_adjustAspectRatio) 1220 dy = real2Aspect(dy); 1221 1222 if (dst.x < 0) { 1223 dst.w += dx; 1224 src.x -= dx; 1225 dst.x = 0; 1226 } 1227 if (dst.y < 0) { 1228 dst.h += dy; 1229 src.y -= dy; 1230 dst.y = 0; 1231 } 1232 1233 // Quick check to see if anything has to be drawn at all 1234 if (dst.w <= 0 || dst.h <= 0) 1235 return; 1236 1237 src.w = dst.w; 1238 src.h = dst.h; 1239 1240 if (_adjustAspectRatio) 1241 dst.y = real2Aspect(dst.y); 1242 1243 _mouseBackup.x = dst.x; 1244 _mouseBackup.y = dst.y; 1245 _mouseBackup.w = dst.w; 1246 _mouseBackup.h = dst.h; 1247 1248 dst.x *= _scaleFactor; 1249 dst.y *= _scaleFactor; 1250 1251 if (SDL_BlitSurface(_mouseSurface, &src, _hwscreen, &dst) != 0) 1252 error("SDL_BlitSurface failed: %s", SDL_GetError()); 1253 1254 addDirtyRect(dst.x, dst.y, dst.w, dst.h, true); 1213 1255 } 1214 1256 1215 1216 1257 #pragma mark - 1217 1258 #pragma mark --- Mouse --- 1218 1259 #pragma mark - -
backends/sdl/sdl-common.h
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v retrieving revision 1.71 diff -u -r1.71 sdl-common.h
82 82 virtual void warpMouse(int x, int y); // overloaded by CE backend 83 83 84 84 // Set the bitmap that's used when drawing the cursor. 85 void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor); 85 void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); 86 87 // Set colors of cursor palette 88 void setCursorPalette(const byte *colors, uint start, uint num); 86 89 87 90 // Shaking is used in SCUMM. Set current shake position. 88 91 void setShakePos(int shake_pos); … … 258 261 }; 259 262 260 263 struct MousePos { 261 int16 x, y, w, h; 264 int16 x, y, w, h, hW, hH; 265 MousePos() : x(0), y(0), w(0), h(0), hW(0), hH(0) {} 262 266 }; 263 267 264 268 // mouse … … 266 270 bool _mouseVisible; 267 271 bool _mouseDrawn; 268 272 byte *_mouseData; 269 byte *_mouseBackup;273 SDL_Rect _mouseBackup; 270 274 MousePos _mouseCurState; 271 275 int16 _mouseHotspotX; 272 276 int16 _mouseHotspotY; 273 277 byte _mouseKeyColor; 278 int _cursorTargetScale; 279 bool _cursorHasOwnPalette; 280 SDL_Surface *_mouseOrigSurface; 281 SDL_Surface *_mouseSurface; 282 enum { 283 kMouseColorKey = 1 284 }; 274 285 275 286 // joystick 276 287 SDL_Joystick *_joystick; … … 283 294 SDL_Color *_currentPalette; 284 295 uint _paletteDirtyStart, _paletteDirtyEnd; 285 296 297 // Cursor palette data 298 SDL_Color *_cursorPalette; 299 286 300 /** 287 301 * Mutex which prevents multiple threads from interfering with each other 288 302 * when accessing the screen. … … 293 307 void addDirtyRgnAuto(const byte *buf); 294 308 void makeChecksums(const byte *buf); 295 309 296 virtual void addDirtyRect(int x, int y, int w, int h ); // overloaded by CE backend310 virtual void addDirtyRect(int x, int y, int w, int h, bool mouseRect = false); // overloaded by CE backend 297 311 298 312 virtual void drawMouse(); // overloaded by CE backend 299 313 virtual void undrawMouse(); // overloaded by CE backend 314 void blitCursor(); 300 315 301 316 /** Set the position of the virtual mouse cursor. */ 302 317 void setMousePos(int x, int y); -
backends/sdl/sdl.cpp
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v retrieving revision 1.78 diff -u -r1.78 sdl.cpp
100 100 _tmpscreen(0), _overlayVisible(false), 101 101 _samplesPerSec(0), 102 102 _cdrom(0), _scalerProc(0), _modeChanged(false), _dirtyChecksums(0), 103 _mouseVisible(false), _mouseDrawn(false), _mouseData(0), 104 _mouseHotspotX(0), _mouseHotspotY(0), 103 _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0), 104 _mouseOrigSurface(0), _mouseHotspotX(0), _mouseHotspotY(0), _cursorTargetScale(1), 105 _cursorHasOwnPalette(false), 105 106 _joystick(0), 106 107 _currentShakePos(0), _newShakePos(0), 107 108 _paletteDirtyStart(0), _paletteDirtyEnd(0), … … 109 110 110 111 // allocate palette storage 111 112 _currentPalette = (SDL_Color *)calloc(sizeof(SDL_Color), 256); 113 _cursorPalette = (SDL_Color *)calloc(sizeof(SDL_Color), 256); 112 114 113 // allocate the dirty rect storage 114 _mouseBackup = (byte *)malloc(MAX_MOUSE_W * MAX_MOUSE_H * MAX_SCALING * 2); 115 _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; 115 116 116 117 // reset mouse state 117 118 memset(&_km, 0, sizeof(_km)); … … 123 124 OSystem_SDL::~OSystem_SDL() { 124 125 free(_dirtyChecksums); 125 126 free(_currentPalette); 126 free(_ mouseBackup);127 free(_cursorPalette); 127 128 free(_mouseData); 128 129 } 129 130 … … 147 148 return 148 149 (f == kFeatureFullscreenMode) || 149 150 (f == kFeatureAspectRatioCorrection) || 150 (f == kFeatureAutoComputeDirtyRects); 151 (f == kFeatureAutoComputeDirtyRects) || 152 (f == kFeatureCursorHasPalette); 151 153 } 152 154 153 155 void OSystem_SDL::setFeatureState(Feature f, bool enable) { -
common/scaler.cpp
RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v retrieving revision 1.64 diff -u -r1.64 scaler.cpp
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.27 diff -u -r1.27 scaler.h
41 41 DECLARE_SCALER(Normal1x); 42 42 DECLARE_SCALER(Normal2x); 43 43 DECLARE_SCALER(Normal3x); 44 DECLARE_SCALER(Normal1o5x); 44 45 DECLARE_SCALER(TV2x); 45 46 DECLARE_SCALER(DotMatrix); 46 47 DECLARE_SCALER(HQ2x); -
common/system.h
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v retrieving revision 1.86 diff -u -r1.86 system.h
96 96 * Implementing this is purely optional, and no harm should arise 97 97 * when not doing so (except for decreased speed in said frontends). 98 98 */ 99 kFeatureAutoComputeDirtyRects 99 kFeatureAutoComputeDirtyRects, 100 101 /** 102 * This flags determines either cursor can have its own palette or not 103 * It is currently used only by some Macintosh versions of Humongous 104 * Entertainment games. If backend doesn't implement this feature then 105 * engine switches to b/w version of cursors. 106 */ 107 kFeatureCursorHasPalette 100 108 }; 101 109 102 110 /** … … 274 282 virtual void setPalette(const byte *colors, uint start, uint num) = 0; 275 283 276 284 /** 285 * Replace the specified range of cursor the palette with new colors. 286 * The palette entries from 'start' till (start+num-1) will be replaced - so 287 * a full palette update is accomplished via start=0, num=256. 288 * 289 * Backends which implement it should have kFeatureCursorHasPalette flag set 290 * 291 * @see setPalette 292 * @see kFeatureCursorHasPalette 293 */ 294 virtual void setCursorPalette(const byte *colors, uint start, uint num) {}; 295 296 /** 277 297 * Blit a bitmap to the virtual screen. 278 298 * The real screen will not immediately be updated to reflect the changes. 279 299 * Client code has to to call updateScreen to ensure any changes are … … 365 385 /** 366 386 * Set the bitmap used for drawing the cursor. 367 387 * 368 * @param buf the pixmap data to be used (8bit/pixel) 369 * @param w width of the mouse cursor 370 * @param h height of the mouse cursor 371 * @param hotspotX horizontal offset from the left side to the hotspot 372 * @param hotspotY vertical offset from the top side to the hotspot 373 * @param keycolor transparency color index 388 * @param buf the pixmap data to be used (8bit/pixel) 389 * @param w width of the mouse cursor 390 * @param h height of the mouse cursor 391 * @param hotspotX horizontal offset from the left side to the hotspot 392 * @param hotspotY vertical offset from the top side to the hotspot 393 * @param keycolor transparency color index 394 * @param cursorTargetScale scale factor which cursor is designed for 374 395 */ 375 virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255 ) = 0;396 virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1) = 0; 376 397 377 398 //@} 378 399 -
scumm/cursor.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/cursor.cpp,v retrieving revision 2.27 diff -u -r2.27 cursor.cpp
107 107 108 108 void ScummEngine::updateCursor() { 109 109 _system->setMouseCursor(_grabbedCursor, _cursor.width, _cursor.height, 110 _cursor.hotspotX, _cursor.hotspotY); 110 _cursor.hotspotX, _cursor.hotspotY, 255, 111 (_heversion == 70 ? 2 : 1)); 111 112 } 112 113 113 114 void ScummEngine_v6::grabCursor(int x, int y, int w, int h) { -
scumm/resource_v7he.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v7he.cpp,v retrieving revision 1.18 diff -u -r1.18 resource_v7he.cpp
1523 1523 *hotspot_x = dis.readUint16BE(); 1524 1524 *w = *h = 16; 1525 1525 1526 // FIXME 1527 // Color cursors use their own palette. 1528 // So we can't use it for now and use B/W version 1529 return; 1526 // Use b/w cursor on backends which don't support cursor palettes 1527 if (!_vm->_system->hasFeature(OSystem::kFeatureCursorHasPalette)) 1528 return; 1530 1529 1531 1530 dis.readUint32BE(); // reserved 1532 1531 dis.readUint32BE(); // cursorID … … 1591 1590 palette[c * 4 + 3] = 0; 1592 1591 } 1593 1592 1594 // TODO: Here we should set separate cursor palette. 1595 // It requires cursor to be rendered on a different surface at 1596 // least in SDL backend. 1597 // HACK: now set global palett just to see if colors are correct. 1598 // this affects subtitles colors 1599 _vm->_system->setPalette(palette, 0, ctSize); 1593 _vm->_system->setCursorPalette(palette, 0, ctSize); 1600 1594 1601 1595 numBytes = 1602 1596 (iconBounds[2] - iconBounds[0]) *