Ticket #7927: scummvm-shake2.patch
File scummvm-shake2.patch, 8.0 KB (added by , 22 years ago) |
---|
-
gfx.cpp
diff -Naur scummvm/gfx.cpp scummvm-shake-patch/gfx.cpp
old new 1409 1409 } 1410 1410 1411 1411 void Scumm::setShake(int mode) { 1412 if (mode!=-1) 1412 if (mode < 0) 1413 _shakeMode = 0; 1414 else 1413 1415 _shakeMode = mode; 1414 else 1415 mode = 0; 1416 /* XXX: not implemented */ 1417 warning("stub setShake(%d)",mode); 1416 1417 if (_shakeMode) _shakeFrame = 0; 1418 1419 updateScreen(this); 1420 1421 warning("stub setShake(%d) - half implemented",mode); 1418 1422 } 1419 1423 1420 1424 void Gdi::clearUpperMask() { -
scumm.h
diff -Naur scummvm/scumm.h scummvm-shake-patch/scumm.h
old new 1034 1034 1035 1035 int16 _talkDelay; 1036 1036 int16 _shakeMode; 1037 int16 _shakeFrame; 1038 uint32 _shakeTicks; 1037 1039 1038 1040 int16 _virtual_mouse_x, _virtual_mouse_y; 1039 1041 -
sdl.cpp
diff -Naur scummvm/sdl.cpp scummvm-shake-patch/sdl.cpp
old new 29 29 #include "SDL_thread.h" 30 30 31 31 #define SCALEUP_2x2 32 #define MIN_SHAKE_MS 150 32 33 33 34 Scumm scumm; 34 35 ScummDebugger debugger; … … 38 39 SOUND_DRIVER_TYPE snd_driv; 39 40 40 41 static SDL_Surface *screen; 42 static SDL_Surface *shakebuf; 43 static SDL_Surface *blackness; 41 44 42 45 void updateScreen(Scumm *s); 43 46 … … 56 59 colors[i].unused = 0; 57 60 } 58 61 62 SDL_SetColors(shakebuf, colors, first, num); 59 63 SDL_SetColors(screen, colors, first, num); 60 64 61 65 s->_palDirtyMax = -1; … … 202 206 void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) { 203 207 byte *dst; 204 208 int i; 209 SDL_Surface *target; 205 210 206 211 hide_mouse = true; 207 212 if (has_mouse) { 208 213 s->drawMouse(); 209 214 } 210 215 211 if (SDL_LockSurface(screen)==-1) 216 if (s->_shakeMode || s->_shakeFrame) { 217 target = shakebuf; 218 } else { 219 target = screen; 220 } 221 222 if (SDL_LockSurface(target)==-1) 212 223 error("SDL_LockSurface failed: %s.\n", SDL_GetError()); 213 224 214 225 #if !defined(SCALEUP_2x2) 215 dst = (byte*)screen->pixels + y*320 + x; 216 addDirtyRect(x,y,w,h); 226 dst = (byte*)target->pixels + y*320 + x; 227 if (s->_shakeMode) 228 addDirtyRectClipped(x, y-4, w, h+8); 229 else 230 addDirtyRect(x,y,w,h); 217 231 do { 218 232 memcpy(dst, src, w); 219 233 dst += 320; 220 234 src += 320; 221 235 } while (--h); 222 236 #else 223 dst = (byte*)screen->pixels + y*640*2 + x*2; 224 addDirtyRect(x,y,w,h); 237 dst = (byte*)target->pixels + y*640*2 + x*2; 238 if (s->_shakeMode) 239 addDirtyRectClipped(x, y-4, w, h+8); 240 else 241 addDirtyRect(x,y,w,h); 225 242 do { 226 243 i=0; 227 244 do { … … 234 251 235 252 #endif 236 253 237 SDL_UnlockSurface( screen);254 SDL_UnlockSurface(target); 238 255 } 239 256 240 257 void updateScreen(Scumm *s) { 258 SDL_Rect srcr, destr; 241 259 242 260 if (s->_fastMode&2) 243 261 return; … … 247 265 s->drawMouse(); 248 266 } 249 267 268 if (s->_shakeMode) { 269 /* if a shake has just begun, we take a copy of the screen */ 270 if (s->_shakeFrame == 0) { 271 if (SDL_BlitSurface(screen, NULL, shakebuf, NULL)) 272 error("SDL_BlitSurface failed: %s.\n", SDL_GetError()); 273 } 274 275 276 277 destr.x = 0; destr.y = 0; 278 destr.w = shakebuf->w; 279 srcr.x = 0; srcr.y = 0; 280 srcr.w = screen->w; 281 282 #if defined(SCALEUP_2x2) 283 destr.h = shakebuf->h-4; 284 srcr.h = screen->h-4; 285 #else 286 destr.h = shakebuf->h-2; 287 srcr.h = screen->h-2; 288 #endif 289 290 /* compensate for the fact that this will be called much more 291 * during mouse movement */ 292 if (((SDL_GetTicks()) >= s->_shakeTicks + MIN_SHAKE_MS) || 293 (s->_shakeFrame == 0)) { 294 s->_shakeFrame++; 295 s->_shakeTicks = SDL_GetTicks(); 296 fullRedraw = true; 297 } 298 if (s->_shakeFrame % 2) { 299 #if defined(SCALEUP_2x2) 300 srcr.y += 4; 301 #else 302 srcr.y += 2; 303 #endif 304 305 } else { 306 #if defined(SCALEUP_2x2) 307 destr.y += 4; 308 #else 309 destr.y += 2; 310 #endif 311 } 312 313 314 if (SDL_BlitSurface(shakebuf, &srcr, screen, &destr)) 315 error("SDL_BlitSurface failed: %s.\n", SDL_GetError()); 316 317 318 #if defined(SCALEUP_2x2) 319 destr.h = 4; 320 if (s->_shakeFrame % 2) 321 destr.y = screen->h-4; 322 else 323 destr.y = 0; 324 #else 325 destr.h = 2; 326 if (s->_shakeFrame % 2) 327 destr.y = screen->h-2; 328 else 329 destr.y = 0; 330 #endif 331 if (SDL_BlitSurface(blackness, NULL, screen, &destr)) 332 error("SDL_BlitSurface failed: %s.\n", SDL_GetError()); 333 334 } else if (s->_shakeFrame) { 335 /* shake has just ended, clean up */ 336 fullRedraw = true; 337 if (SDL_BlitSurface(shakebuf, NULL, screen, NULL)) 338 error("SDL_BlitSurface failed: %s.\n", SDL_GetError()); 339 s->_shakeFrame = 0; 340 } 341 250 342 if(s->_palDirtyMax != -1) { 251 343 updatePalette(s); 252 344 } 345 253 346 if (fullRedraw) { 254 347 SDL_UpdateRect(screen, 0,0,0,0); 348 fullRedraw = false; 255 349 #if defined(SHOW_AREA) 256 350 debug(2,"update area 100 %%"); 257 351 #endif … … 273 367 int x,y; 274 368 byte *dst,*bak; 275 369 byte color; 370 SDL_Surface *target; 276 371 277 372 if (hide_mouse) 278 373 visible = false; 279 374 280 if (SDL_LockSurface(screen)==-1) 375 if (s->_shakeMode || s->_shakeFrame) { 376 target = shakebuf; 377 } else { 378 target = screen; 379 } 380 381 if (SDL_LockSurface(target)==-1) 281 382 error("SDL_LockSurface failed: %s.\n", SDL_GetError()); 282 383 283 384 #if defined(SCALEUP_2x2) 284 385 285 386 if (has_mouse) { 286 dst = (byte*) screen->pixels + old_mouse_y*640*2 + old_mouse_x*2;387 dst = (byte*)target->pixels + old_mouse_y*640*2 + old_mouse_x*2; 287 388 bak = old_backup; 288 389 289 390 for (y=0; y<old_mouse_h; y++,bak+=BAK_WIDTH*2,dst+=640*2) { … … 299 400 } 300 401 301 402 if (visible) { 302 dst = (byte*) screen->pixels + ydraw*640*2 + xdraw*2;403 dst = (byte*)target->pixels + ydraw*640*2 + xdraw*2; 303 404 bak = old_backup; 304 405 305 406 for (y=0; y<h; y++,dst+=640*2,bak+=BAK_WIDTH*2,buf+=w) { … … 321 422 } 322 423 #else 323 424 if (has_mouse) { 324 dst = (byte*) screen->pixels + old_mouse_y*320 + old_mouse_x;425 dst = (byte*)target->pixels + old_mouse_y*320 + old_mouse_x; 325 426 bak = old_backup; 326 427 327 428 for (y=0; y<old_mouse_h; y++,bak+=BAK_WIDTH,dst+=320) { … … 335 436 } 336 437 } 337 438 if (visible) { 338 dst = (byte*) screen->pixels + ydraw*320 + xdraw;439 dst = (byte*)target->pixels + ydraw*320 + xdraw; 339 440 bak = old_backup; 340 441 341 442 for (y=0; y<h; y++,dst+=320,bak+=BAK_WIDTH,buf+=w) { … … 355 456 356 457 #endif 357 458 358 SDL_UnlockSurface( screen);459 SDL_UnlockSurface(target); 359 460 360 461 if (has_mouse) { 361 462 has_mouse = false; 362 addDirtyRectClipped(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); 463 if (s->_shakeMode) 464 addDirtyRectClipped(old_mouse_x, old_mouse_y-4, old_mouse_w, old_mouse_h+8); 465 else 466 addDirtyRectClipped(old_mouse_x, old_mouse_y, old_mouse_w, old_mouse_h); 363 467 } 364 468 365 469 if (visible) { 366 470 has_mouse = true; 367 addDirtyRectClipped(xdraw, ydraw, w, h); 471 if (s->_shakeMode) 472 addDirtyRectClipped(xdraw, ydraw-4, w, h+8); 473 else 474 addDirtyRectClipped(xdraw, ydraw, w, h); 368 475 old_mouse_x = xdraw; 369 476 old_mouse_y = ydraw; 370 477 old_mouse_w = w; … … 430 537 } 431 538 432 539 #if !defined(SCALEUP_2x2) 433 screen = SDL_SetVideoMode(320, 200, 8, fullScreen ? (SDL_SWSURFACE | SDL_FULLSCREEN) : SDL_SWSURFACE); 540 if (!(screen = SDL_SetVideoMode(320, 200, 8, 541 fullScreen ? (SDL_SWSURFACE | SDL_FULLSCREEN) : SDL_SWSURFACE))) 542 #else 543 if (!(screen = SDL_SetVideoMode(640, 400, 8, 544 fullScreen ? (SDL_SWSURFACE | SDL_FULLSCREEN) : SDL_SWSURFACE))) 545 #endif 546 error("SDL_SetVideoMode failed: %s.\n", SDL_GetError()); 547 548 if (!(shakebuf = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, 549 screen->h, 8, 0, 0, 0, 0))) 550 error("SDL_CreateRGBSurface failed: %s.\n", SDL_GetError()); 551 552 #if !defined(SCALEUP_2x2) 553 if (!(blackness = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, 2, 554 8, 0, 0, 0, 0))) 434 555 #else 435 screen = SDL_SetVideoMode(640, 400, 8, fullScreen ? (SDL_SWSURFACE | SDL_FULLSCREEN) : SDL_SWSURFACE); 556 if (!(blackness = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, 4, 557 8, 0, 0, 0, 0))) 436 558 #endif 559 error("SDL_CreateRGBSurface failed: %s.\n", SDL_GetError()); 560 561 if(SDL_FillRect(blackness, NULL, 0)) 562 error("SDL_FillRect failed: %s.\n", SDL_GetError()); 437 563 438 564 printf("%d %d, %d %d, %d %d %d, %d %d %d %d %d\n", 439 565 sizeof(int8), sizeof(uint8),